本文整理汇总了PHP中Comments::count_total方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::count_total方法的具体用法?PHP Comments::count_total怎么用?PHP Comments::count_total使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::count_total方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_dashboard
/**
* Handles get requests for the dashboard
* @todo update check should probably be cron'd and cached, not re-checked every load
*/
public function get_dashboard()
{
// Not sure how best to determine this yet, maybe set an option on install, maybe do this:
$firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
$this->theme->active_time = HabariDateTime::date_create($firstpostdate);
// get the active theme, so we can check it
// @todo this should be worked into the main Update::check() code for registering beacons
$active_theme = Themes::get_active();
$active_theme = $active_theme->name . ':' . $active_theme->version;
// check to see if we have updates to display
$this->theme->updates = Options::get('updates_available', array());
// collect all the stats we display on the dashboard
$this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, false), 'tag_count' => Tags::vocabulary()->count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id)));
$this->fetch_dashboard_modules();
// check for first run
$u = User::identify();
if (!isset($u->info->experience_level)) {
$this->theme->first_run = true;
$u->info->experience_level = 'user';
$u->info->commit();
} else {
$this->theme->first_run = false;
}
$this->display('dashboard');
}
示例2: get_stat
public static function get_stat($type, $month = NULL)
{
$str = 'chicklet_stat_' . $type;
if ($month != NULL) {
$str .= '_' . $month;
}
if (Cache::has($str)) {
return Cache::get($str);
}
switch ($type) {
case 'entries':
case 'posts':
$params = array('content_type' => array(Post::type('entry'), Post::type('link')), 'nolimit' => TRUE);
$stat = count(Posts::get($params));
break;
case 'subscribers':
$stat = self::fetch();
break;
case 'comments':
$stat = Comments::count_total(Comment::STATUS_APPROVED);
break;
case 'tags':
$stat = count(Tags::vocabulary()->get_tree());
break;
default:
$stat = 0;
break;
}
Cache::set($str, $stat);
return $stat;
}
示例3: get_dashboard
/**
* Handles get requests for the dashboard
* @todo update check should probably be cron'd and cached, not re-checked every load
*/
public function get_dashboard()
{
// Not sure how best to determine this yet, maybe set an option on install, maybe do this:
$firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
if ($firstpostdate) {
$this->theme->active_time = DateTime::create($firstpostdate);
}
// check to see if we have updates to display
$this->theme->updates = Options::get('updates_available', array());
// collect all the stats we display on the dashboard
$user = User::identify();
$this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'post_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total('approved', false), 'tag_count' => Tags::vocabulary()->count_total(), 'user_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('draft'), 'user_id' => $user->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total('unapproved', false) : Comments::count_by_author(User::identify()->id, Comment::status('unapproved')), 'spam_comment_count' => $user->can('manage_all_comments') ? Comments::count_total('spam', false) : Comments::count_by_author($user->id, Comment::status('spam')), 'user_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => $user->id)));
// check for first run
$u = User::identify();
$uinfo = $u->info;
if (!isset($uinfo->experience_level)) {
$this->theme->first_run = true;
$u->info->experience_level = 'user';
$u->info->commit();
} else {
$this->theme->first_run = false;
}
$this->get_additem_form();
Stack::add('admin_header_javascript', 'dashboard-js');
$this->display('dashboard');
}
示例4: get_comments
/**
* Output an Atom collection of comments based on the supplied parameters.
*
* @param array $params An array of parameters passed to Comments::get() to retrieve comments
*/
function get_comments( $params = array() )
{
$comments = null;
$comments_count = null;
// Assign self link.
$self = '';
// Assign alternate link.
$alternate = '';
$updated = HabariDateTime::date_create();
// Check if this is a feed for a single post
if ( isset( $params['slug'] ) || isset( $params['id'] ) ) {
if ( isset( $params['slug'] ) ) {
$post = Post::get( array( 'slug' => $params['slug'] ) );
}
elseif ( isset( $params['id'] ) ) {
$post = Post::get( array( 'id' => $params['id'] ) );
}
// If the post doesn't exist, send a 404
if ( !$post instanceOf Post ) {
header( 'HTTP/1.1 404 Not Found', true, 404 );
die('The post could not be found');
}
$comments = $post->comments->approved;
$comments_count = count( $comments );
$content_type = Post::type_name( $post->content_type );
$self = URL::get( "atom_feed_{$content_type}_comments", $post, false );
$alternate = URL::get( "display_{$content_type}", $post, false );
if ( $comments_count ) {
$updated = $comments[$comments_count - 1]->date;
}
}
else {
$self = URL::get( 'atom_feed_comments' );
$alternate = URL::get( 'display_home' );
$params['status'] = Comment::STATUS_APPROVED;
$comments = Comments::get( $params );
$comments_count = Comments::count_total( Comment::status( 'approved' ) );
if ( $comments_count ) {
$updated = $comments[0]->date;
}
}
$id = isset( $params['slug'] ) ? $params['slug'] : 'atom_comments';
$xml = $this->create_atom_wrapper( $alternate, $self, $id, $updated );
$xml = $this->add_pagination_links( $xml, $comments_count );
$xml = $this->add_comments( $xml, $comments );
Plugins::act( 'atom_get_comments', $xml, $params, $this->handler_vars );
$xml = $xml->asXML();
ob_clean();
header( 'Content-Type: application/atom+xml' );
print $xml;
}
示例5: get_dashboard
/**
* Handles get requests for the dashboard
* @todo update check should probably be cron'd and cached, not re-checked every load
*/
public function get_dashboard()
{
// Not sure how best to determine this yet, maybe set an option on install, maybe do this:
$firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
if (intval($firstpostdate) !== 0) {
$firstpostdate = time() - $firstpostdate;
}
$this->theme->active_time = array('years' => floor($firstpostdate / 31556736), 'months' => floor($firstpostdate % 31556736 / 2629728), 'days' => round($firstpostdate % 2629728 / 86400));
// get the active theme, so we can check it
$active_theme = Themes::get_active();
$active_theme = $active_theme->name . ':' . $active_theme->version;
// if the active plugin list has changed, expire the updates cache
if (Cache::has('dashboard_updates') && Cache::get('dashboard_updates_plugins') != Options::get('active_plugins')) {
Cache::expire('dashboard_updates');
}
// if the theme version has changed, expire the updates cache
if (Cache::has('dashboard_updates') && Cache::get('dashboard_updates_theme') != $active_theme) {
Cache::expire('dashboard_updates');
}
/*
* Check for updates to core and any hooked plugins
* cache the output so we don't make a request every load but can still display updates
*/
if (Cache::has('dashboard_updates')) {
$this->theme->updates = Cache::get('dashboard_updates');
} else {
$updates = Update::check();
if (!Error::is_error($updates)) {
Cache::set('dashboard_updates', $updates);
$this->theme->updates = $updates;
// cache the set of plugins we just used to check for
Cache::set('dashboard_updates_plugins', Options::get('active_plugins'));
// cache the active theme we just used to check for
Cache::set('dashboard_updates_theme', $active_theme);
} else {
$this->theme->updates = array();
}
}
$this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, FALSE), 'tag_count' => Tags::count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, FALSE) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, FALSE) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id)));
$this->fetch_dashboard_modules();
// check for first run
$u = User::identify();
if (!isset($u->info->experience_level)) {
$this->theme->first_run = true;
$u->info->experience_level = 'user';
$u->info->commit();
} else {
$this->theme->first_run = false;
}
$this->display('dashboard');
}
示例6: action_admin_info
/**
* Inject the delete all button
*
* @return void
**/
public function action_admin_info($theme, $page)
{
if ($page == 'comments' && Options::get('spamview__spambutton') == TRUE) {
$spamcount = Comments::count_total(Comment::STATUS_SPAM, FALSE);
echo '<a href="#" id="deleteallspam" class="deleteall">' . sprintf(_t('Clear spam'), $spamcount) . '</a>';
}
if ($page == 'logs' && Options::get('spamview__logbutton') == TRUE) {
echo '<a href="#" id="deletealllogs" class="deleteall">' . _t('Clear logs') . '</a>';
}
return;
}
示例7: action_template_footer
/**
* Ouputs the default menu in the template footer, and runs the 'hadminstrip' plugin filter.
* You can add menu items via the filter. See the 'filter_hadminstrip' method for
* an example.
*/
public function action_template_footer()
{
if (User::identify()->loggedin) {
?>
<div id="adminstrip">
<?php
$unapprovedcomments = Comments::count_total(Comment::STATUS_UNAPPROVED, FALSE);
$postnumber = Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published')));
$commentnumber = Comments::count_total(Comment::STATUS_APPROVED, FALSE);
$spamnumber = Comments::count_total(Comment::STATUS_SPAM);
$tagscount = Tags::vocabulary()->count_total();
$pagecount = Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published')));
?>
<a id="striplink" href="<?php
echo URL::get('admin', 'page=dashboard');
?>
" title="Visit the Dashboard.."><span id="admin">DASHBOARD</span></a>
· <a id="striplink" href="<?php
echo URL::get('user', 'page=logout');
?>
" title="Log out..">Logout</a>
· <a id="striplink" href="<?php
echo URL::get('admin', 'page=publish');
?>
" title="Write an entry..">Write</a>
· <a id="striplink" href="<?php
echo URL::get('admin', 'page=plugins');
?>
" title="Plugins">Plugins</a>
· <a id="striplink" href="<?php
echo URL::get('admin', 'page=options');
?>
" title="Update settings..">Options</a>
<?php
if ($unapprovedcomments != 0) {
?>
· <a id="modcomments" href="<?php
echo URL::get('admin', 'page=comments');
?>
" title="Unapproved Comments"><?php
echo $unapprovedcomments;
?>
moderate</a><?php
}
?>
<?php
if ($spamnumber != 0) {
?>
· <a id="admincomments" href="<?php
echo URL::get('admin', 'page=comments');
?>
?status=2" title="Spam Comments"><?php
echo $spamnumber;
?>
spam</a><?php
}
?>
· There are <a id="striplink" href="<?php
echo URL::get('admin', 'page=posts&type=' . Post::type('entry'));
?>
" title="<?php
echo $postnumber;
?>
posts"><?php
echo $postnumber;
?>
posts</a>, <a id="striplink" href="<?php
echo URL::get('admin', 'page=posts&type=' . Post::type('page'));
?>
" title="<?php
echo $pagecount;
?>
pages"><?php
echo $pagecount;
?>
pages</a> and <a id="striplink" href="<?php
echo URL::get('admin', 'page=comments');
?>
" title="Comments"><?php
echo $commentnumber;
?>
comments</a> within <a id="striplink" href="<?php
echo URL::get('admin', 'page=tags');
?>
" Tags="Tags"><?php
echo $tagscount;
?>
tags</a>
//.........这里部分代码省略.........