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


PHP blogPostModel::getAddedPostCount方法代码示例

本文整理汇总了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;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:54,代码来源:blogBlog.model.php

示例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);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:67,代码来源:blogConfig.class.php


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