Inheritance: extends Gc\Db\AbstractTable
Example #1
0
 /**
  * Display statistics for visitors
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     $visitorModel = new Visitor();
     $settings = array('back_colour' => '#FFFFFF', 'stroke_colour' => '#C2C2C2', 'back_stroke_width' => 0, 'back_stroke_colour' => '#C2C2C2', 'axis_colour' => '#333', 'axis_overlap' => 1, 'axis_font' => 'Verdana', 'axis_font_size' => 10, 'grid_colour' => '#888888', 'label_colour' => '#555555', 'pad_right' => 10, 'pad_left' => 10, 'project_angle' => 45, 'minimum_grid_spacing' => 40);
     $graph = new SVGGraph(600, 400, $settings);
     $graph->colours = array(array('#855D10', '#855D10'));
     $data = array();
     $array = array('hours' => 'HOUR', 'days' => 'DAY', 'months' => 'MONTH', 'years' => 'YEAR');
     foreach ($array as $type => $sqlValue) {
         $label = '';
         switch ($type) {
             case 'hours':
                 $label = 'This day';
                 break;
             case 'days':
                 $label = 'This month';
                 break;
             case 'months':
                 $label = 'This year';
                 break;
             case 'years':
                 $label = 'All the time';
                 break;
         }
         $data[$type] = array('label' => $label, 'labels' => array('visitors' => 'Visitors', 'pagesviews' => 'Pages views', 'urlsviews' => 'Most urls views', 'referers' => 'Referers'), 'values' => array('visitors' => $visitorModel->getNbVisitors($sqlValue), 'pagesviews' => $visitorModel->getNbPagesViews($sqlValue), 'urlsviews' => $visitorModel->getUrlsViews($sqlValue), 'referers' => $visitorModel->getReferers($sqlValue)));
     }
     return array('graph' => $graph, 'groups' => $data);
 }
Example #2
0
 /**
  * Display dashboard
  *
  * @return array
  */
 public function indexAction()
 {
     $data = array();
     $data['version'] = Version::VERSION;
     $data['versionIsLatest'] = Version::isLatest();
     $data['versionLatest'] = Version::getLatest();
     $documents = new Collection();
     $contentStats = array();
     $contentStats['online_documents'] = array('count' => count($documents->getAvailableDocuments()), 'label' => 'Online documents', 'route' => 'content');
     $contentStats['total_documents'] = array('count' => count($documents->select()->toArray()), 'label' => 'Total documents', 'route' => 'content');
     $data['contentStats'] = $contentStats;
     $visitorModel = new Visitor();
     $data['userStats'] = array('total_visitors' => array('count' => $visitorModel->getTotalVisitors(), 'label' => 'Total visitors', 'route' => 'statistics'), 'total_visits' => array('count' => $visitorModel->getTotalPageViews(), 'label' => 'Total page views', 'route' => 'statistics'));
     $coreConfig = $this->getServiceLocator()->get('CoreConfig');
     $widgets = @unserialize($coreConfig->getValue('dashboard_widgets'));
     $data['dashboardSortable'] = !empty($widgets['sortable']) ? Json::encode($widgets['sortable']) : '{}';
     $data['dashboardWelcome'] = !empty($widgets['welcome']);
     $data['customeWidgets'] = array();
     $this->events()->trigger(__CLASS__, 'dashboard', $this, array('widgets' => &$data['customeWidgets']));
     return $data;
 }
Example #3
0
 /**
  * Log visitor informations
  *
  * @param boolean $isPreview Is the current page is a preview
  * @param boolean $isAdmin   Is an admin is connected
  *
  * @return void
  */
 protected function logVisitor($isPreview, $isAdmin)
 {
     if (!$isPreview and !$isAdmin) {
         try {
             $visitor = new Visitor();
             $session = new SessionContainer();
             $sessionId = $session->getDefaultManager()->getId();
             $session->visitorId = $visitor->getVisitorId($sessionId);
         } catch (Exception $e) {
             //don't care
         }
     }
 }