本文整理汇总了PHP中blogPostModel::getAddedPostCount方法的典型用法代码示例。如果您正苦于以下问题:PHP blogPostModel::getAddedPostCount方法的具体用法?PHP blogPostModel::getAddedPostCount怎么用?PHP blogPostModel::getAddedPostCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blogPostModel
的用法示例。
在下文中一共展示了blogPostModel::getAddedPostCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareView
/**
* @param array $items
* @param array $options
* @param array $extend_data
* @return array
*/
public function prepareView($items, $options = array(), $extend_data = array())
{
$extend_options = array_merge($this->extend_options, $options);
$extend_data = array_merge($this->extend_data, (array) $extend_data);
foreach ($items as &$item) {
blogHelper::extendIcon($item);
if (!isset($extend_options['link']) || $extend_options['link']) {
$item['link'] = blogBlog::getUrl($item, true);
}
if (!empty($extend_options['escape'])) {
$item['name'] = htmlspecialchars($item['name'], ENT_QUOTES, 'utf-8');
$item['link'] = htmlspecialchars($item['link'], ENT_QUOTES, 'utf-8');
}
unset($item);
}
if (isset($options['new']) && $options['new']) {
$post_model = new blogPostModel();
$blog_activity = blogActivity::getInstance();
$posts_update = $post_model->getAddedPostCount(blogActivity::getUserActivity(), array_keys($items), true);
if ($posts_update) {
foreach ($posts_update as $blog_id => $new) {
if (isset($items[$blog_id])) {
$items[$blog_id]['new_post'] = 0;
$post_ids = explode(':', $new);
foreach ($post_ids as $post_id) {
if ($blog_activity->isNew("b.{$blog_id}", $post_id, isset($options['expire']) ? $options['expire'] : null)) {
++$items[$blog_id]['new_post'];
}
}
if (!$items[$blog_id]['new_post']) {
unset($items[$blog_id]['new_post']);
}
}
}
}
}
/**
* Prepare blog data
* Extend each blog item via plugins data
* @event prepare_blogs_frontend
* @event prepare_blogs_backend
* @param array $items
* @param int $items[]['id']
* @return void
*/
wa()->event('prepare_blogs_' . wa()->getEnv(), $items);
return $items;
}
示例2: onCount
public function onCount()
{
$full = !func_get_args();
$app = $this->getApplication();
$user = waSystem::getInstance()->getUser();
$user_id = $user->getId();
$type = explode(':', $user->getSettings($app, 'type_items_count'));
$type = array_filter(array_map('trim', $type), 'strlen');
if (!$type) {
$type = array('posts', 'comments_to_my_post', 'overdue');
}
$activity_datetime = blogActivity::getUserActivity($user_id, false);
$blogs = array_keys(blogHelper::getAvailable(false));
$counter = array();
$post_model = new blogPostModel();
if (in_array('posts', $type) && $full && $blogs) {
$post_new_count = $post_model->getAddedPostCount($activity_datetime, $blogs);
$post_new_count = array_sum($post_new_count);
$counter['posts'] = $post_new_count;
} else {
$counter['posts'] = false;
}
if (in_array('comments', $type) && $full && $blogs) {
$comment_model = new blogCommentModel();
$counter['comments'] = $comment_model->getCount($blogs, null, $activity_datetime, 0);
} else {
$counter['comments'] = false;
}
if (in_array('comments_to_my_post', $type) && $full && $blogs) {
$comment_model = new blogCommentModel();
$counter['comments_to_my_post'] = $comment_model->getCount($blogs, null, $activity_datetime, 0, $user_id);
} else {
$counter['comments_to_my_post'] = false;
}
if (in_array('overdue', $type) && $blogs) {
if (!isset($post_model)) {
$post_model = new blogPostModel();
}
$where = "status = '" . blogPostModel::STATUS_DEADLINE . "'";
$where .= " AND blog_id IN (" . implode(', ', $blogs) . ")";
$where .= " AND contact_id = {$user_id}";
$where .= " AND datetime <= '" . waDateTime::date("Y-m-d") . "'";
$count_overdue = $post_model->select("count(id)")->where($where)->fetchField();
$counter['overdue'] = $count_overdue ? $count_overdue : 0;
} else {
$counter['overdue'] = false;
}
$count = array_sum($counter);
$url = $this->getBackendUrl(true) . $this->application . '/';
if ($count) {
switch ($count) {
case $counter['comments']:
case $counter['comments_to_my_post']:
$url .= '?module=comments';
break;
case $counter['overdue']:
$url .= '?action=calendar';
break;
}
}
//debug
//$counter['type'] = $type;
//$counter['activity_datetime'] = $activity_datetime;
//$counter['current_datetime'] = date("Y-m-d H:i:s",time());
//waLog::log('$counter = '.var_export($counter,true),"blog-counter-{$user_id}.log");
return array('count' => $count == 0 ? null : $count, 'url' => $url);
}