コード例 #1
0
ファイル: StatsController.php プロジェクト: Andyyang1981/pi
 /**
  * Default page 
  */
 public function indexAction()
 {
     $topVisitsEver = Entity::getTotalVisits(10);
     $topVisits7 = Entity::getVisitsRecently(7, 10);
     $topVisits30 = Entity::getVisitsRecently(30, 10);
     $totalEver = Stats::getTotalRecently();
     $total7 = Stats::getTotalRecently(7);
     $total30 = Stats::getTotalRecently(30);
     $totalEverByCategory = Stats::getTotalRecentlyByCategory();
     $total7ByCategory = Stats::getTotalRecentlyByCategory(7);
     $total30ByCategory = Stats::getTotalRecentlyByCategory(30);
     $topSubmittersEver = Stats::getSubmittersRecently(null, 10);
     $topSubmitters7 = Stats::getSubmittersRecently(7, 10);
     $topSubmitters30 = Stats::getSubmittersRecently(30, 10);
     if ($this->config('enable_tag') && Pi::service('tag')->active()) {
         $topTags = Pi::service('tag')->top(10, $this->getModule(), null);
         $this->view()->assign('topTags', $topTags);
     }
     $this->view()->assign(array('title' => _a('Statistic'), 'topVisitsEver' => $topVisitsEver, 'topVisits7' => $topVisits7, 'topVisits30' => $topVisits30, 'totalEver' => $totalEver, 'total7' => $total7, 'total30' => $total30, 'totalEverByCategory' => $totalEverByCategory, 'total7ByCategory' => $total7ByCategory, 'total30ByCategory' => $total30ByCategory, 'topSubmittersEver' => $topSubmittersEver, 'topSubmitters7' => $topSubmitters7, 'topSubmitters30' => $topSubmitters30));
 }
コード例 #2
0
ファイル: Block.php プロジェクト: Andyyang1981/pi
 /**
  * List hot articles by visit count
  * 
  * @param array   $options
  * @param string  $module
  * @return boolean 
  */
 public static function hotArticles($options = array(), $module = null)
 {
     if (!$module) {
         return false;
     }
     $limit = isset($options['list-count']) ? (int) $options['list-count'] : 10;
     $config = Pi::config('', $module);
     $image = $config['default_feature_thumb'];
     $image = Pi::service('asset')->getModuleAsset($image, $module);
     $day = $options['day-range'] ? intval($options['day-range']) : 7;
     if ($options['is-topic']) {
         $params = Pi::service('url')->getRouteMatch()->getParams();
         if (is_string($params)) {
             $params['topic'] = Pi::model('topic', $module)->slugToId($params['topic']);
         }
         $articles = Topic::getVisitsRecently($day, $limit, null, isset($params['topic']) ? $params['topic'] : null, $module);
     } else {
         $articles = Entity::getVisitsRecently($day, $limit, null, $module);
     }
     foreach ($articles as &$article) {
         $article['subject'] = mb_substr($article['subject'], 0, $options['max_subject_length'], 'UTF-8');
         $article['summary'] = mb_substr($article['summary'], 0, $options['max_summary_length'], 'UTF-8');
         $article['image'] = $article['image'] ? Media::getThumbFromOriginal(Pi::url($article['image'])) : $image;
     }
     return array('articles' => $articles, 'target' => $options['target'], 'elements' => (array) $options['element'], 'column' => $options['column-number'], 'config' => $config, 'rows' => $options['description_rows']);
 }