当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::count方法代码示例

本文整理汇总了PHP中Comment::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::count方法的具体用法?PHP Comment::count怎么用?PHP Comment::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comment的用法示例。


在下文中一共展示了Comment::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $controller = $this->getController();
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Comments') . ' - ' . $controller->_setting['site_name'];
     //我的评论
     $uid = Yii::app()->user->id;
     $comment_mod = new Comment();
     $criteria = new CDbCriteria();
     $criteria->addColumnCondition(array('t.user_id' => $uid));
     $criteria->order = 't.id DESC';
     //分页
     $count = $comment_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $pages->applyLimit($criteria);
     $datalist = $comment_mod->findAll($criteria);
     foreach ((array) $datalist as $k => $v) {
         $c_mod_class = $controller->_content_models[$v->type];
         $c_mod_name = strtolower($c_mod_class);
         $content_mod = new $c_mod_class();
         $content = $content_mod->findByPk($v->content_id);
         $datalist[$k]['title'] = $content->title;
         $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $content->id));
     }
     $controller->render('my_comments', array('datalist' => $datalist, 'pages' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:26,代码来源:MycommentsAction.php

示例2: actionIndex

 /**
  * 评论管理
  *
  */
 public function actionIndex()
 {
     $this->_model_type = ModelType::model()->findAll();
     $model = new Comment();
     $criteria = new CDbCriteria();
     $condition = '1';
     $status = $this->_request->getParam('status');
     $title = $this->_request->getParam('postTitle');
     $content = $this->_request->getParam('content');
     $type = $this->_request->getParam('type') ? $this->_request->getParam('type') : $this->_type_ids['post'];
     $type && ($condition .= " AND type={$type}");
     $status && ($condition .= " AND t.status='{$status}'");
     $table = array_search($type, $this->_type_ids);
     if ($table == 'goods') {
         $title && ($condition .= " AND {$table}.goods_name LIKE '%{$title} %'");
     } else {
         $title && ($condition .= " AND {$table}.title LIKE '%{$title} %'");
     }
     $content && ($condition .= ' AND t.content LIKE \'%' . $content . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $criteria->with = array($table);
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = $this->buildCondition($_GET, array('postTitle', 'status', 'content', 'type'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     Yii::app()->clientScript->registerCssFile($this->_static_public . "/js/kindeditor/code/prettify.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/kindeditor/code/prettify.js", CClientScript::POS_END);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages, 'table' => $table));
 }
开发者ID:redtreelchao,项目名称:wander-moon,代码行数:38,代码来源:CommentController.php

示例3: index

 public function index($request)
 {
     $data = [];
     $counts = [];
     $counts['videos'] = Video::count();
     $counts['users'] = User::count();
     $counts['channels'] = UserChannel::count();
     $counts['comments'] = Comment::count();
     $counts['total_views'] = Video::sumViews();
     $counts['channel_user_ratio'] = round($counts['channels'] / $counts['users'], 2);
     $counts['videos_that_has_comments'] = Statistic::countVideosHavingComments();
     $counts['channels_having_videos'] = Video::find_by_sql('SELECT count(DISTINCT poster_id) as count from `videos`')[0]->count;
     $counts['part_of_commented_videos'] = round($counts['videos_that_has_comments'] / $counts['videos'] * 100, 2);
     $counts['part_of_channels_having_videos'] = round($counts['channels_having_videos'] / $counts['channels'] * 100, 2);
     $counts['user_1_channel'] = Statistic::countUserHavingChannels('= 1');
     $counts['user_2_channel'] = Statistic::countUserHavingChannels('= 2');
     $counts['user_3_channel'] = Statistic::countUserHavingChannels('= 3');
     $counts['user_more3_channel'] = Statistic::countUserHavingChannels('> 3');
     $counts['user_1_channel_part'] = round($counts['user_1_channel'] / $counts['users'] * 100, 2);
     $counts['user_2_channel_part'] = round($counts['user_2_channel'] / $counts['users'] * 100, 2);
     $counts['user_3_channel_part'] = round($counts['user_3_channel'] / $counts['users'] * 100, 2);
     $counts['user_more3_channel_part'] = round($counts['user_more3_channel'] / $counts['users'] * 100, 2);
     $data['counts'] = $counts;
     return new ViewResponse('admin/statistic/index', $data);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:25,代码来源:statistic_controller.php

示例4: admin

 private function admin()
 {
     $today = strtotime('today');
     $month = strtotime('first day of this month');
     $last30 = strtotime('-30 days');
     // Users statistics
     $users['today'] = number_format(User::whereGt('reg_date', $today)->count());
     $users['month'] = number_format(User::whereGt('reg_date', $month)->count());
     $users['last30'] = number_format(User::whereGt('reg_date', $last30)->count());
     $users['total'] = number_format(User::count());
     View::set('users', $users);
     // Playlists statistics
     $playlists['today'] = number_format(Playlist::whereGt('date', $today)->count());
     $playlists['month'] = number_format(Playlist::whereGt('date', $month)->count());
     $playlists['last30'] = number_format(Playlist::whereGt('date', $last30)->count());
     $playlists['total'] = number_format(Playlist::count());
     View::set('playlists', $playlists);
     // Tracks statistics
     $tracks = number_format(Track::count());
     View::set('tracks', $tracks);
     // Tags statistics
     $tags = number_format(Tag::count());
     View::set('tags', $tags);
     // Comments statistics
     $comments = number_format(Comment::count());
     View::set('comments', $comments);
     // Likes
     $likes = number_format(PlaylistLike::count());
     View::set('likes', $likes);
     // Reports
     $reports = number_format(Report::count());
     View::set('reports', $reports);
     View::show('admin/admin');
 }
开发者ID:nytr0gen,项目名称:plur-music-explorer,代码行数:34,代码来源:admin.php

示例5: run

 public function run()
 {
     $model = new Comment();
     //条件
     $criteria = new CDbCriteria();
     $type = trim(Yii::app()->request->getParam('type'));
     $type && $criteria->addColumnCondition(array('type' => $type));
     $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);
     //全部类型
     $model_types = ModelType::model()->findAll();
     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, 'model_types' => $model_types, 'datalist' => $result, 'pagebar' => $pages));
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:25,代码来源:IndexAction.php

示例6: run

 public function run()
 {
     $controller = $this->getController();
     $this->_setting = $controller->_setting;
     $this->_stylePath = $controller->_stylePath;
     $this->_static_public = $controller->_static_public;
     $controller->_seoTitle = Yii::t('common', 'User Center') . ' - ' . Yii::t('common', 'My Comments') . ' - ' . $this->_setting['site_name'];
     //加载css,js
     Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/user.css");
     Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js");
     //我的评论
     $uid = Yii::app()->user->id;
     $comment_mod = new Comment();
     $model_type = new ModelType();
     $uid = Yii::app()->user->id;
     $criteria = new CDbCriteria();
     $criteria->condition = 't.user_id=' . $uid;
     $criteria->order = 't.id DESC';
     //分页
     $count = $comment_mod->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 15;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $datalist = $comment_mod->findAll($criteria);
     foreach ((array) $datalist as $k => $v) {
         $c_mod_class = $controller->_content_models[$v->type];
         $c_mod_name = strtolower($c_mod_class);
         $content_mod = new $c_mod_class();
         $content = $content_mod->findByPk($v->topic_id);
         $datalist[$k]['title'] = $content->title;
         $datalist[$k]['url'] = $controller->createUrl($c_mod_name . '/view', array('id' => $content->id));
     }
     $controller->render('my_comments', array('datalist' => $datalist));
 }
开发者ID:SallyU,项目名称:yiicms,代码行数:35,代码来源:MycommentsAction.php

示例7: index

 public function index($request)
 {
     $appConfig = new Config(CONFIG . 'app.json');
     $appConfig->parseFile();
     $data = [];
     $data['stats'] = ["videos_suspended" => ["Vidéo(s) suspendue(s)", Video::getSizeOfSuspendedVideos(), 'videos/suspended'], "videos_flagged" => ["Vidéo(s) reportée(s)", Video::getSizeOfReportedVideos(), 'videos/reported'], "comments_flagged" => ["Commentaire(s) reporté(s)", Comment::count(['flagged' => 1]), 'comments']];
     $data['view_icons'] = ["videos_suspended" => ["fa-ban", "fa-video-camera"], "videos_flagged" => ["fa-flag", "fa-video-camera"], "comments_flagged" => ["fa-flag", "fa-comments"]];
     $data['view_colors'] = ["videos_suspended" => "red", "videos_flagged" => "yellow", "comments_flagged" => "yellow"];
     return new ViewResponse('admin/moderation/index', $data);
 }
开发者ID:boulama,项目名称:DreamVids,代码行数:10,代码来源:moderation_controller.php

示例8: smarty_function_mtentrycommentcount

function smarty_function_mtentrycommentcount($args, &$ctx)
{
    $entry = $ctx->stash('entry');
    if (isset($args['top']) and $args['top'] == 1) {
        $where = "(comment_parent_id is NULL\n           or comment_parent_id = 0)\n           and comment_visible = 1 \n           and comment_entry_id = " . $entry->entry_id;
        require_once 'class.mt_comment.php';
        $comment = new Comment();
        $count = $comment->count(array('where' => $where));
    } else {
        $count = $entry->entry_comment_count;
    }
    return $ctx->count_format($count, $args);
}
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:13,代码来源:function.mtentrycommentcount.php

示例9: execute

 function execute()
 {
     global $wgUser, $wgOut, $wgVoteDirectory, $wgCommentsDirectory, $IP;
     require_once "{$wgVoteDirectory}/VoteClass.php";
     require_once "{$wgVoteDirectory}/Publish.php";
     require_once "{$wgVoteDirectory}/RSS.php";
     require_once "{$wgCommentsDirectory}/CommentClass.php";
     if ($_POST["mk"] == md5($_POST["pid"] . 'pants' . $wgUser->mName)) {
         require_once "{$IP}/extensions/UserStats/UserStatsClass.php";
         $stats = new UserStatsTrack(1, $wgUser->mId, $wgUser->mName);
         if (($_GET["Action"] == 1 || $_GET["Action"] == 2) && is_numeric($_POST["pid"]) && (is_numeric($_POST["TheVote"]) || $_GET["Action"] == 2)) {
             //echo 'test2';
             $Vote = new Vote($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             if ($_GET["Action"] == 1) {
                 $Vote->insert($_POST["TheVote"]);
                 $stats->incVoteCount();
             } else {
                 $Vote->delete();
             }
             $CommentList = new Comment($_POST["pid"]);
             $publish = new Publish();
             $publish->PageID = $_POST["pid"];
             $publish->VoteCount = $Vote->count(1);
             $publish->CommentCount = $CommentList->count();
             $publish->check_score();
             echo $Vote->count(1);
         }
         if ($_GET["Action"] == 3) {
             $Vote = new VoteStars($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             $Vote->insert($_POST["TheVote"]);
             $stats->incVoteCount();
             echo $Vote->display();
         }
         if ($_GET["Action"] == 4) {
             $Vote = new VoteStars($_POST["pid"]);
             $Vote->setUser($wgUser->mName, $wgUser->mId);
             $Vote->delete();
             echo $Vote->display();
         }
     }
     // This line removes the navigation and everything else from the
     // page, if you don't set it, you get what looks like a regular wiki
     // page, with the body you defined above.
     $wgOut->setArticleBodyOnly(true);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:47,代码来源:VoteAction.php

示例10: index

 function index($name)
 {
     $a = new Account();
     if ($name != "") {
         $c = new Campaign();
         $c->where('nickname', $name)->get();
         if ($c->id > 0) {
             $data['campaign_id'] = $c->id;
             $data['name'] = $c->name;
             $data['description'] = $c->description;
             $data['photo'] = $c->photo;
             $data['countryid'] = $c->countryid;
             $data['categoryid'] = $c->categoryid;
             $data['isInfo'] = $c->isInfo;
             $data['title'] = $c->name;
             /*
              * get comments for the campaign
              */
             $com = new Comment();
             $com->where('campaign_id', $c->id)->get();
             //$comments = new ArrayObject();
             $commentsStr = "[";
             $flag = 0;
             foreach ($com->all as $comment) {
                 $usr = new Account();
                 $usr->where('id', $comment->user_id)->get();
                 $preCom = "<img src = '" . base_url() . "/images/profile/" . $usr->photo . "' align='left'><i>says </i>";
                 if ($flag) {
                     $commentsStr = $commentsStr . ",";
                 }
                 $flag = 1;
                 $commentsStr = $commentsStr . "\"" . $preCom . $comment->comment . "\"";
                 //$data['comments'][] = $comment->comment;
                 //$data['comments_uid'][] = $comment->user_id;
             }
             $commentsStr = $commentsStr . "]";
             $data['commentsStr'] = $commentsStr;
             $data['commentsNum'] = $com->count();
         }
     }
     $data['a'] = $a;
     $_SESSION['url'] = site_url('destination/index/' . $name);
     $this->load->view('destination', $data);
 }
开发者ID:parag,项目名称:travelohic,代码行数:44,代码来源:destination.php

示例11: comments_list

 /**
  * Comments list
  *
  * @param $request
  * @return mixed
  */
 public function comments_list($request)
 {
     // Delete page
     if ($request->get('delete')) {
         $delete = $request->get('delete');
         if ($delete != 'all') {
             $comment = \Comment::find_by_id(intval($delete));
             if ($comment) {
                 // Delete child comments
                 \Comment::table()->delete('parent_id = ' . $comment->id);
                 if ($comment->delete()) {
                     $this->view->assign('message', $this->lang->translate('form.deleted'));
                 }
             }
         } else {
             \Comment::table()->delete('1');
             $this->view->assign('message', $this->lang->translate('form.deleted'));
         }
     }
     // Filter
     $filter = [];
     if ($request->get('author')) {
         $author = \User::find($request->get('author'));
         if ($author) {
             $filter['conditions'] = ['author_id = ?', $author->id];
         }
     }
     $filter['order'] = 'id DESC';
     if ($request->order) {
         $filter['order'] = $request->order;
     }
     /** @var Listing $paginator */
     $paginator = NCService::load('Paginator.Listing', [$request->page, \Comment::count('all')]);
     $filter = array_merge($filter, $paginator->limit());
     // Filter users
     $comments = \Comment::all($filter);
     $comments = \Comment::as_array($comments);
     return $this->view->render('comment/list.twig', ['title' => $this->lang->translate('comment.list'), 'comments_list' => $comments, 'listing' => $paginator->pages(), 'page' => $paginator->cur_page]);
 }
开发者ID:Max201,项目名称:nanocore,代码行数:45,代码来源:Control.php

示例12: countComments

 /**
  * Count the comments that are related to this download.
  * 
  * @return int
  */
 public function countComments()
 {
     return Comment::count('downloads', $this->id);
 }
开发者ID:chirilo,项目名称:Contentify,代码行数:9,代码来源:Download.php

示例13: countComments

 /**
  * Count the comments that are related to this video.
  * 
  * @return int
  */
 public function countComments()
 {
     return Comment::count('videos', $this->id);
 }
开发者ID:chirilo,项目名称:Contentify,代码行数:9,代码来源:Video.php

示例14: run

 public function run()
 {
     $this->controller->layout = false;
     $view_url = Yii::app()->request->getParam('view_url');
     $content_id = Yii::app()->request->getParam('content_id');
     $topic_type = Yii::app()->request->getParam('topic_type');
     $cur_url = Yii::app()->request->hostinfo . Yii::app()->request->getUrl();
     $post = false;
     //评论类型
     switch ($topic_type) {
         case 'post':
             $post = Post::model()->findByPk($content_id);
             break;
         case 'image':
             $post = Image::model()->findByPk($content_id);
             break;
         case 'soft':
             $post = Soft::model()->findByPk($content_id);
             break;
         case 'video':
             $post = Video::model()->findByPk($content_id);
             break;
     }
     if (!$post) {
         throw new CHttpException(404, Yii::t('admin', 'Loading Error'));
     }
     //评论内容
     $model = new Comment('create');
     $criteria = new CDbCriteria();
     $criteria->with = array('user');
     $criteria->addColumnCondition(array('content_id' => $content_id));
     $criteria->addColumnCondition(array('t.status' => Comment::STATUS_SHOW));
     $criteria->addColumnCondition(array('type' => $this->controller->_type_ids[$topic_type]));
     $criteria->addCondition('u.uid > 0');
     $criteria->order = 't.id DESC';
     $criteria->select = 't.id, user_id, content_id, content, t.create_time ';
     //分页
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $comments = $model->findAll($criteria);
     //回复
     if ($comments) {
         foreach ($comments as $c) {
             $replies[$c->id] = Reply::model()->with('user')->findAll(array('condition' => 'cid = ' . $c->id . ' AND t.status = "' . Reply::STATUS_SHOW . '" AND u.uid > 0', 'order' => 'id'));
         }
     } else {
         $comments = array();
         $replies = array();
     }
     if (Yii::app()->request->isPostRequest) {
         $uid = Yii::app()->user->id;
         if (!$uid) {
             $this->message('script', Yii::t('common', 'You Need Login'));
         }
         $model->attributes = $_POST['Comment'];
         $model->content_id = $content_id;
         $model->type = $this->controller->_type_ids[$topic_type];
         $model->user_id = $uid;
         $model->status = 'N';
         $model->client_ip = Yii::app()->request->userHostAddress;
         $model->create_time = time();
         $ret_url = $_POST['ret_url'];
         if ($model->save()) {
             $this->controller->message('script', Yii::t('common', 'Submit Success, Waiting Pass'), $ret_url);
         }
     }
     $data = array('model' => $model, 'view_url' => $view_url, 'cur_url' => $cur_url, 'comments' => $comments, 'pagebar' => $pages, 'replies' => $replies);
     $this->controller->render('create', $data);
 }
开发者ID:jerrylsxu,项目名称:yiifcms,代码行数:72,代码来源:CreateAction.php

示例15: category_comment_count

 public function category_comment_count($args)
 {
     $cat_id = intval($args['category_id']);
     $where = "placement_category_id = {$cat_id}\n              and entry_status=2\n              and comment_visible=1";
     $join['mt_entry'] = array('condition' => 'comment_entry_id = entry_id');
     $join['mt_placement'] = array('condition' => 'entry_id = placement_entry_id');
     require_once 'class.mt_comment.php';
     $comment = new Comment();
     $result = $comment->count(array('where' => $where, 'join' => $join));
     return $result;
 }
开发者ID:OCMO,项目名称:movabletype,代码行数:11,代码来源:mtdb.base.php


注:本文中的Comment::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。