本文整理汇总了PHP中Comments::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::model方法的具体用法?PHP Comments::model怎么用?PHP Comments::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionShowPosts
public function actionShowPosts($id, $mid, $sid)
{
$posts = Posts::model()->findByPk($sid);
$multimedia = json_decode($posts->multimedia);
$count = count($multimedia);
foreach ($multimedia as $ind => $file) {
if ($file->nomber == $mid) {
$num = $ind + 1;
if ($ind == 0) {
$prev = $multimedia[$count - 1]->nomber . '/' . $sid;
} else {
$prev = $multimedia[$ind - 1]->nomber . '/' . $sid;
}
if ($ind == $count - 1) {
$next = $multimedia[0]->nomber . '/' . $sid;
} else {
$next = $multimedia[$ind + 1]->nomber . '/' . $sid;
}
$current_photo = $file;
}
}
$myPage = $id == Yii::app()->user->id;
$myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
$ext = Files::model()->findByPk($current_photo->id)->extension;
$aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next);
$comments = Comments::model()->getLast('posts_' . $sid, $mid, 10);
$comments = array_reverse($comments);
$file = array('id' => $current_photo->id, 'file' => $current_photo->id, 'image' => array('extension' => $ext), 'description' => '', 'upload_date' => $current_photo->upload_date);
$this->renderPartial('show_photo', array('photo' => $file, 'nav_link' => 'showposts', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'posts_' . $sid, 'comments_item_id' => $mid));
}
示例2: actionIndex
public function actionIndex()
{
$step = Yii::app()->request->getParam("step", 1);
switch ($step) {
case 1:
$this->render('index');
break;
case 2:
$this->render('check', array('check' => environmentChecksUpdate::run()));
break;
case 3:
$authGet = Yii::app()->request->getParam("auth", 'sorry');
if (Yii::app()->request->csrfToken != $authGet) {
$this->render('check');
}
databaseConfiguration::SplitSQL(Yii::app()->getModulePath() . '/update/data/0_4/mysql_update.sql');
$updated = array();
$comments = Comments::model()->findAll();
foreach ($comments as $comment) {
if (!in_array($comment->comment_resourceid . "," . $comment->module_id, $updated)) {
$module = Modules::model()->findByPk($comment->module_id)->module_className;
$modelClass = new $module();
$project = $modelClass::model()->findByPk($comment->comment_resourceid)->project_id;
Comments::model()->updateAll(array('project_id' => $project), 'comment_resourceid = :resourceid AND module_id = :moduleid', array(':resourceid' => $comment->comment_resourceid, ':moduleid' => $comment->module_id));
array_push($updated, $comment->comment_resourceid . "," . $comment->module_id);
}
}
$this->render('finish');
break;
default:
$this->render('index');
break;
}
}
示例3: actionSave_comment
/**
* Добавление / редактирование комментариев
*/
public function actionSave_comment()
{
if (Yii::app()->user->isGuest) {
$this->redirect($this->createAbsoluteUrl('base'));
}
// Редактирование или добавление новой
if (isset($_GET['idComment'])) {
$model = Comments::model()->findByPk($_GET['idComment']);
} else {
$model = new Comments();
}
if (isset($_POST['idArticle']) && isset($_POST['text']) && isset($_POST['idAuthor'])) {
$model->idArticle = $_POST['idArticle'];
$model->text = $_POST['text'];
$model->idUser = empty($this->_user) ? Users::getIdUserForAdmin() : $this->_user['idUser'];
$model->typeUser = $model->idUser == $_POST['idAuthor'] ? 'author' : (empty($this->_user) ? 'admin' : 'user');
if ($model->save()) {
if (Yii::app()->request->isAjaxRequest) {
$criteria = new CDbCriteria();
$criteria->with = array('idUser0');
$criteria->condition = 'idArticle = :idArticle AND deleted = 0 AND public = 1';
$criteria->params = array(':idArticle' => $_POST['idArticle']);
$comments = Comments::model()->findAll($criteria);
$commentsDataProvider = new CArrayDataProvider($comments, array('keyField' => 'idComment', 'pagination' => array('pageSize' => 50)));
$listComments = $this->renderPartial('_list_comments', array('dataProvider' => $commentsDataProvider), true);
echo CJSON::encode(array('listComments' => $listComments));
exit;
}
}
}
}
示例4: actionShow
public function actionShow($id, $mid)
{
//$photos = Photos::model();
//$photo = $photos->findByPk($mid);
$ap = Bookmarks::model()->findAll(array('select' => 'content_id', 'condition' => 'owner_id = :id AND type = 1', 'params' => array(':id' => $id)));
$count = count($ap);
foreach ($ap as $ind => $ph) {
if ($ph['content_id'] == $mid) {
$num = $ind + 1;
if ($ind == 0) {
$prev = $ap[$count - 1]['content_id'];
} else {
$prev = $ap[$ind - 1]['content_id'];
}
if ($ind == $count - 1) {
$next = $ap[0]['content_id'];
} else {
$next = $ap[$ind + 1]['content_id'];
}
}
}
$aroundInfo = array('num' => $num, 'count' => $count, 'prev' => $prev, 'next' => $next);
$myProfile = UserProfile::model()->getUserProfile(Yii::app()->user->id);
$myPage = $id == Yii::app()->user->id;
$comments = Comments::model()->getLast('photos', $mid, 10);
$comments = array_reverse($comments);
$photo = Photos::model()->findByPk($mid);
$this->renderPartial('_show_photo', array('photo' => $photo, 'nav_link' => 'show', 'user_id' => $id, 'aroundInfo' => $aroundInfo, 'myProfile' => $myProfile, 'myPage' => $myPage, 'comments' => $comments, 'comments_tbl' => 'photos'));
}
示例5: loadModel
public function loadModel($id)
{
$model = Comments::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例6: run
public function run()
{
$criteria = new CDbCriteria();
$criteria->order = "id DESC";
$criteria->limit = 2;
// $criteria->addCondition("is_deleted = 0");
$this->render('lastComment', array('comments' => Comments::model()->findAll($criteria)));
}
示例7: actionSystemmain
/**
* 后台主页信息
*/
public function actionSystemmain()
{
$SYS = array('PHP版本:' => $_SERVER['SERVER_SOFTWARE'], '当前系统类型:' => php_uname('s'), 'PHP运行方式:' => php_sapi_name(), '服务器域名:' => $_SERVER['SERVER_NAME'], '服务器端口:' => $_SERVER['SERVER_PORT'], '北京时间:' => date('Y年m月d日 H:i:s', time()));
$count = array('会员总数:' => Account::model()->count('id!=:ID', array(':ID' => 0)), '文章总数:' => article::model()->count('id!=:ID', array(':ID' => 0)), '评论总数:' => Comments::model()->count('id!=:ID', array(':ID' => 0)));
$Role = Role::model()->find('id=:ID', array(':ID' => Yii::app()->session['USER_ACCOUNT']['roleId']));
$basic = array('权限级别:' => $Role->name);
$this->render('Systemmain', array('SYS' => $SYS, 'Info' => $count, 'basic' => $basic));
}
示例8: actionStat
public function actionStat()
{
$posts = Posts::model()->count();
$commentsNum = Comments::model()->count();
$attachsNum = Attachments::model()->count();
$feedbackNum = Feedback::model()->count();
$arr = array('posts' => $posts, 'commentsNum' => $commentsNum, 'attachsNum' => $attachsNum, 'feedbackNum' => $feedbackNum);
$this->render('stat', $arr);
}
示例9: getListUserCommentedOnPost
public function getListUserCommentedOnPost($post_id)
{
$criteria = new CDbCriteria();
$criteria->select = 't.created_by';
$criteria->condition = "t.post_id = {$post_id}";
$criteria->distinct = true;
$data = Comments::model()->findAll($criteria);
return $data;
}
示例10: getCommentsByEvent
public function getCommentsByEvent($event_id, $limit, $offset)
{
$criteria = new CDbCriteria();
$criteria->limit = $limit;
$criteria->offset = $offset;
$criteria->condition = "event_id = {$event_id}";
$data = Comments::model()->findAll($criteria);
return $data;
}
示例11: actionGetContentByID
public function actionGetContentByID($id)
{
$arr = explode(",", $id);
$id = $arr[count($arr) - 1];
$model = Comments::model()->findByPk($id);
$data = array();
$data[0] = $model->content;
$data[1] = $model->title;
$data[2] = $model->address;
echo json_encode($data);
}
示例12: actionComment
public function actionComment()
{
$rows = Comments::model()->findAll();
$model = new Comments();
if (isset($_POST['Comments'])) {
$model->attributes = $_POST['Comments'];
if ($model->save()) {
$this->redirect($this->createUrl('pages/comment'));
}
}
$this->render('comment', array('rows' => $rows, 'model' => $model));
}
示例13: actionGetCommentByEvent
public function actionGetCommentByEvent()
{
$request = Yii::app()->request;
try {
$event_id = StringHelper::filterString($request->getQuery('event_id'));
$limit = StringHelper::filterString($request->getQuery('limit'));
$offset = StringHelper::filterString($request->getQuery('offset'));
$data = Comments::model()->getCommentsByEvent($event_id, $limit, $offset);
ResponseHelper::JsonReturnSuccess($data, 'Success');
} catch (Exception $ex) {
var_dump($ex->getMessage());
}
}
示例14: actionApprove
/**
* Changes whether or not the comment should be approved or not
*
* With approval I'm not too worried about the parent->child tree being messed up, as the nodes still exist in the tree
* and are simply ignored.
*
* @param int $id The id of the comment
* @return boolean If the comment was modified or not
*/
public function actionApprove($id = NULL)
{
if ($id === NULL) {
throw new CHttpException(400, Yii::t('Dashboard.main', 'No comment with that id exists.'));
}
$comment = Comments::model()->findByPk($id);
if ($comment->approved != 1) {
$comment->approved = 1;
} else {
$comment->approved = -1;
}
return $comment->save();
}
示例15: actionGetCounters
public function actionGetCounters()
{
Yii::import('mod.cart.models.Order');
Yii::import('mod.cart.models.ProductNotifications');
Yii::import('mod.support.models.TicketMessage');
$json = array();
if (Yii::app()->hasModule('comments')) {
$json['comments'] = (int) Comments::model()->waiting()->count();
}
$json['orders'] = (int) Order::model()->new()->count();
$json['notify'] = (int) ProductNotifications::model()->count();
$json['support'] = (int) TicketMessage::model()->count();
echo CJSON::encode($json);
}