本文整理汇总了PHP中Reply类的典型用法代码示例。如果您正苦于以下问题:PHP Reply类的具体用法?PHP Reply怎么用?PHP Reply使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reply类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionReadTopic
public function actionReadTopic($id)
{
$thread = Thread::model()->getThreadInfoById($id);
$this->forumBreadcrumb = array('Programs' => array('forum/index'), $thread['program_name'] => array('forum/programView', 'programId' => $thread['program_id']), $thread['semester_name'] => array('forum/viewTopics', 'programId' => $thread['program_id'], 'semesterId' => $thread['semester_id']), $thread['title'] < Yii::app()->params['forum_max_crumb_length'] ? $thread['title'] : substr($thread['title'], 0, Yii::app()->params['forum_max_crumb_length']) . '...');
$this->areaLarge = $thread['program_name'];
$this->areaSmall = $thread['semester_name'];
$reply = new Reply();
$complaint = new Complaint('postComplaint');
if (isset($_POST['Reply'])) {
$reply->attributes = $_POST['Reply'];
$reply->post_item_id = $id;
if ($reply->save()) {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
$reply->unsetAttributes();
} else {
Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
}
}
if (isset($_POST['Complaint'])) {
$complaint->attributes = $_POST['Complaint'];
if ($complaint->save()) {
if ($complaint->post_item_id == $id) {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
} else {
Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
}
$complaint->unsetAttributes();
} else {
Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
}
}
$dataProvider = Thread::model()->getPostsDataInThread($id);
Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
$this->render('view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
}
示例2: run
public function run()
{
$controller = $this->getController();
$controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Replys') . ' - ' . $controller->_setting['site_name'];
//我的回复
$uid = Yii::app()->user->id;
$comment_mod = new Comment();
$reply_mod = new Reply();
$criteria = new CDbCriteria();
$criteria->addColumnCondition(array('t.user_id' => $uid));
$criteria->order = 't.id DESC';
//分页
$count = $reply_mod->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = 15;
$pages->applyLimit($criteria);
$datalist = $reply_mod->findAll($criteria);
foreach ((array) $datalist as $k => $v) {
$reply = $comment_mod->findByPk($v->cid);
if ($reply) {
$c_mod_class = $controller->_content_models[$reply->type];
$c_mod_name = strtolower($c_mod_class);
$content_mod = new $c_mod_class();
$content = $content_mod->findByPk($reply->content_id);
$datalist[$k]['title'] = $content->title;
$datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $reply->content_id));
}
}
$controller->render('my_replys', array('datalist' => $datalist, 'pages' => $pages));
}
示例3: generate
public function generate(Reply $reply, $perPage = 20)
{
$precedingReplyCount = $reply->getPrecedingReplyCount();
// $numberthreadsBefore = Thread::where('parent_id', '=', $thread->parent_id)->where('created_at', '<', $thread->created_at)->count();
$pageNumber = $this->getPageNumber($precedingReplyCount, $perPage);
// $page = round($numberthreadsBefore / $this->threadsPerPage, 0, PHP_ROUND_HALF_DOWN) + 1;
// return Redirect::to(action('ForumController@getViewThread', [$thread]) . "?page={$page}#thread-{$threadId}");
return "?page={$pageNumber}#reply-{$reply->id}";
}
示例4: run
public function run()
{
$ids = Yii::app()->request->getParam('id');
$command = Yii::app()->request->getParam('command');
empty($ids) && $this->controller->message('error', Yii::t('admin', 'No Select'));
if (!is_array($ids)) {
$ids = array($ids);
}
$criteria = new CDbCriteria();
$criteria->addInCondition('id', $ids);
switch ($command) {
case 'delete':
//删除
Reply::model()->deleteAll($criteria);
break;
case 'show':
//显示
Reply::model()->updateAll(['status' => Reply::STATUS_SHOW], $criteria);
break;
case 'hide':
//隐藏
Reply::model()->updateAll(['status' => Reply::STATUS_HIDE], $criteria);
break;
default:
$this->controller->message('error', Yii::t('admin', 'Error Operation'));
}
$this->controller->message('success', Yii::t('admin', 'Batch Operate Success'));
}
示例5: actionIndex
public function actionIndex()
{
$shop_id = Yii::app()->request->getParam('shop_id');
if (!$shop_id) {
Error::output(Error::ERR_NO_SHOPID);
}
//获取该店的留言
$criteria = new CDbCriteria();
$criteria->order = 't.order_id DESC';
$criteria->condition = 't.shop_id=:shop_id AND t.status=:status';
$criteria->params = array(':shop_id' => $shop_id, ':status' => 1);
$messageMode = Message::model()->with('members', 'shops', 'replys')->findAll($criteria);
$message = array();
foreach ($messageMode as $k => $v) {
$message[$k] = $v->attributes;
$message[$k]['shop_name'] = $v->shops->name;
$message[$k]['user_name'] = $v->members->name;
$message[$k]['create_time'] = date('Y-m-d H:i:s', $v->create_time);
$message[$k]['status_text'] = Yii::app()->params['message_status'][$v->status];
$message[$k]['status_color'] = Yii::app()->params['status_color'][$v->status];
$_replys = Reply::model()->with('members')->findAll(array('condition' => 'message_id=:message_id', 'params' => array(':message_id' => $v->id)));
if (!empty($_replys)) {
foreach ($_replys as $kk => $vv) {
$message[$k]['replys'][$kk] = $vv->attributes;
$message[$k]['replys'][$kk]['create_time'] = date('Y-m-d H:i:s', $vv->create_time);
$message[$k]['replys'][$kk]['user_name'] = $vv->user_id == -1 ? '前台妹子说' : $vv->members->name;
}
}
}
Out::jsonOutput($message);
}
示例6: getRelatedRelpies
public function getRelatedRelpies()
{
$cate = Input::get('cate', '');
$id = Input::get('id', 0);
$last_id = Input::get('last_id', 0);
$per_page = Input::get('per_page', 30);
$mapping = Reply::getRepliableCate();
try {
if (array_key_exists($cate, $mapping)) {
$cate = $mapping[$cate];
} else {
throw new Exception("需要传入有效的评论分类", 2001);
}
$query = Reply::with(['user'])->select('replies.*')->where('replies.status', '=', 1);
if ($last_id) {
$query = $query->where('replies.id', '<', $last_id);
}
$query = $query->join('repliables', function ($q) use($cate, $id) {
$q->on('repliables.reply_id', '=', 'replies.id')->where('repliables.repliable_type', '=', $cate)->where('repliables.repliable_id', '=', $id);
});
$list = $query->orderBy('replies.id', 'DESC')->paginate($per_page);
$data = [];
foreach ($list as $key => $reply) {
$data[] = $reply->showInList();
}
$re = Tools::reTrue('获取评论成功', $data);
} catch (Exception $e) {
$re = Tools::reFalse($e->getCode(), '获取评论失败:' . $e->getMessage());
}
return Response::json($re);
}
示例7: callback
/**
* 重载callback()
* 将微信服务器请求的数据进行解析
* 并回调控制器的接口方法
*/
public function callback()
{
$postXML = parent::callback();
empty($_GET) && die;
// 必须有附带参数
extract($_GET);
if ($this->sha1_sign($postXML->Encrypt, $timest, $nonce, $msg_signature)) {
$req = $this->crypt_extract(parent::callback());
$reply = '';
switch (strtolower($req->MsgType)) {
case 'text':
$reply = ES_controller::get_instance()->_keywords($req->Content);
break;
case 'event':
$reply = ES_controller::get_instance()->_events($req);
break;
}
empty($reply) && die;
list($method, $args) = $reply;
$args = array('to' => $req->FromUserName, 'from' => $req->ToUserName) + $args;
$reflector = new ReflectionClass('Reply');
$rMethod = $reflector->getMethod($method);
$xml = $rMethod->invokeArgs($reflector->newInstanceWithoutConstructor(), $args);
// log_msg($xml); // 未加密的消息体
$xml = $this->crypt_generate($xml);
$signature = $this->set_sha1_sign($xml, $timestamp, $nonce);
$xml = Reply::crypt_xml($xml, $signature, $timestamp, $nonce);
// log_msg($xml); // 加密后的消息体
echo $xml;
exit;
}
exit;
}
示例8: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$replies = Reply::all();
$markdown = new Markdown();
$transfer_count = 0;
$convert_count = 0;
foreach ($replies as $reply) {
if (empty($reply->body_original)) {
// store the original data
$reply->body_original = $reply->body;
// convert to markdown
$reply->body = $markdown->convertMarkdownToHtml($reply->body);
$reply->save();
$transfer_count++;
} else {
// convert to markdown
$reply->body = $markdown->convertMarkdownToHtml($reply->body_original);
$reply->save();
$convert_count++;
}
}
$this->info("Transfer old data count: " . $transfer_count);
$this->info("Convert original to body count: " . $convert_count);
$this->info("It's Done, have a good day.");
}
示例9: loadReplyList
protected function loadReplyList()
{
$this->num_per_page = $this->db->real_escape_string($this->num_per_page);
$this->page_num = $this->db->real_escape_string($this->page_num);
$this->newsID = trim($this->db->real_escape_string($this->newsID));
$start_record = $this->page_num * $this->num_per_page;
$query = "select nr.*, ur.UserID, ur.displayName, ur.fullname, ur.fbName, \n\t\t\t\t\tnr.createdDateTime as replyCreatedDateTime from `news_reply` nr \n\t\t\t\t\tinner join user_registration ur on ur.userID = nr.userID\n\t\t\t\t\twhere nr.replyStatus = 'active'\n\t\t\t\t\tand nr.newsID = {$this->newsID} and parentReplyID = 0\n\t\t\t\t\torder by nr.createdDateTime desc limit {$start_record}, {$this->num_per_page}";
$resultArr = $this->db->query($query);
if (is_array($resultArr) && count($resultArr) > 0) {
$replyObj = new Reply(0, $this->withSubReplies);
foreach ($resultArr as $id => $reply) {
$replyResult = $replyObj->setModelReply($reply)->getArray();
$resultArr[$id] = $replyResult["reply"];
}
$this->replyArr["replyList"] = $resultArr;
}
}
示例10: delete
public function delete($id)
{
$reply = Reply::find($id);
$this->authorOrAdminPermissioinRequire($reply->user_id);
$reply->delete();
$reply->topic->decrement('reply_count', 1);
Flash::success(lang('Operation succeeded.'));
return Redirect::route('topics.show', $reply->topic_id);
}
示例11: run
public function run()
{
$this->controller->layout = false;
if (Yii::app()->request->isPostRequest) {
//当前登录用户id
$uid = Yii::app()->user->id;
if (!$uid) {
exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'You Need Login'))));
}
$cid = intval($_POST['cid']);
$reply_id = intval($_POST['reply_id']);
$content = $_POST['content'];
$comment = Comment::model()->findByPk($cid);
$reply = Reply::model()->findByPk($reply_id);
if ($comment) {
//不能对自己的评论和回复而回复
if ($comment->user_id == $uid && !$reply || $reply && $reply->user_id == $uid) {
exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'You Can not Rely Yourself'))));
}
if (!$content || strlen($content) < 10) {
exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Content Is Too Small'))));
}
$model = new Reply('create');
$model->cid = $cid;
$model->user_id = $uid;
$model->reply_id = $reply_id;
$model->content = $content;
$model->status = 'Y';
$model->create_time = time();
if ($model->save()) {
exit(CJSON::encode(array('status' => 'success', 'message' => Yii::t('common', 'Reply Success'))));
} else {
exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Failed'))));
}
} else {
exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Failed'))));
}
} else {
exit(CJSON::encode(array('status' => 'error', 'message' => Yii::t('common', 'Reply Failed'))));
}
}
示例12: loadModel
/**
* 判断数据是否存在
*
* return \$this->model
*/
public function loadModel()
{
if ($this->model === null) {
if (isset($_GET['id'])) {
$this->model = Reply::model()->findbyPk($_GET['id']);
}
if ($this->model === null) {
throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.'));
}
}
return $this->model;
}
示例13: run
public function run()
{
$faker = Faker::create();
$users = User::lists('id');
$topics = Topic::lists('id');
foreach (range(1, 500) as $index) {
Reply::create(['user_id' => $faker->randomElement($users), 'topic_id' => $faker->randomElement($topics), 'body' => $faker->sentence()]);
}
foreach (range(1, 60) as $index) {
Reply::create(['user_id' => 1, 'topic_id' => $faker->randomElement($topics), 'body' => $faker->sentence()]);
}
}
示例14: run
public function run()
{
$model = new Reply();
//条件
$criteria = new CDbCriteria();
$status = trim(Yii::app()->request->getParam('status'));
$status && $criteria->addColumnCondition(array('status' => $status));
$title = trim(Yii::app()->request->getParam('content'));
$title && $criteria->addSearchCondition('content', $title);
$criteria->order = 't.id DESC';
$count = $model->count($criteria);
//分页
$pages = new CPagination($count);
$pages->pageSize = 10;
$pages->applyLimit($criteria);
//查询
$result = $model->findAll($criteria);
Yii::app()->clientScript->registerCssFile($this->controller->_static_public . "/js/kindeditor/code/prettify.css");
Yii::app()->clientScript->registerScriptFile($this->controller->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
$this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
}
示例15: actionReplyMsg
public function actionReplyMsg()
{
$message_id = Yii::app()->request->getParam('message_id');
$content = Yii::app()->request->getParam('content');
if (!$content) {
$this->errorOutput(array('errorCode' => 1, 'errorText' => '回复内容不能为空'));
}
if (!$message_id) {
$this->errorOutput(array('errorCode' => 2, 'errorText' => '没有留言id'));
}
$model = new Reply();
$model->message_id = $message_id;
$model->user_id = -1;
$model->content = $content;
$model->create_time = time();
if ($model->save()) {
$this->output(array('success' => 1, 'successText' => '回复成功'));
} else {
$this->errorOutput(array('errorCode' => 3, 'errorText' => '回复失败'));
}
}