Example #1
0
 /**
  * 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));
 }
Example #2
0
 /**
  * Count all article according to submitter
  * 
  * @param array   $options
  * @param string  $module
  * @return boolean 
  */
 public static function submitterStatistics($options = array(), $module = null)
 {
     if (!$module) {
         return false;
     }
     $limit = $options['list-count'] <= 0 ? 10 : $options['list-count'];
     $time = time();
     $today = strtotime(date('Y-m-d', $time));
     $tomorrow = $today + 24 * 3600;
     $week = $tomorrow - 24 * 3600 * 7;
     $month = $tomorrow - 24 * 3600 * 30;
     $daySets = Stats::getSubmittersInPeriod($today, $tomorrow, $limit, $module);
     $weekSets = Stats::getSubmittersInPeriod($week, $tomorrow, $limit, $module);
     $monthSets = Stats::getSubmittersInPeriod($month, $tomorrow, $limit, $module);
     $historySets = Stats::getSubmittersInPeriod(0, $tomorrow, $limit, $module);
     return array('day' => $daySets, 'week' => $weekSets, 'month' => $monthSets, 'history' => $historySets);
 }
Example #3
0
 /**
  * Get total visits of articles.
  * 
  * @param int     $limit
  * @param int     $category
  * @param string  $module
  * @return array 
  */
 public static function getTotalVisits($limit = null, $category = null, $module = null)
 {
     $where = $columns = array();
     $module = $module ?: self::$module;
     $modelCategory = Pi::model('category', $module);
     if ($category && $category > 1) {
         $categoryIds = $modelCategory->getDescendantIds($category);
         if ($categoryIds) {
             $where['category'] = $categoryIds;
         }
     }
     $articles = Stats::getTopVisits($limit, $module);
     if (!empty($articles)) {
         $where['id'] = array_keys($articles);
     }
     $columns = array('id', 'article' => 'id', 'subject', 'source', 'image', 'pages', 'summary', 'time_publish', 'visits');
     $result = self::getAvailableArticlePage($where, 1, $limit, $columns, null, $module);
     foreach ($articles as $id => &$article) {
         $article = array_merge($article, $result[$id]);
     }
     return $articles;
 }
Example #4
0
 /**
  * Count view number by AJAX
  */
 public function countAction()
 {
     Pi::service('log')->mute();
     $id = $this->params('id', 0);
     if (!empty($id)) {
         Stats::addVisit($id, $this->getModule());
     }
     echo json_encode(array('status' => true, 'message' => __('success')));
     exit;
 }