示例#1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return BOL_SiteStatisticService
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
示例#2
0
 /**
  * On before render
  *
  * @return void
  */
 public function onBeforeRender()
 {
     $service = BOL_SiteStatisticService::getInstance();
     // get statistics
     $entities = $service->getStatistics($this->entityTypes, $this->period);
     // translate and process the data entities
     $data = array();
     $total = array();
     $index = 0;
     foreach ($entities as $entity => $values) {
         $list = array_values($values);
         $data[] = array_merge(array('label' => $this->entityLabels[$entity], 'data' => $list), $this->getChartColor($index));
         $total[] = array('label' => $this->entityLabels[$entity], 'count' => array_sum($list));
         $index++;
     }
     // assign view variables
     $this->assign('chartId', $this->chartId);
     $this->assign('categories', json_encode($this->entityCategories()));
     $this->assign('data', json_encode($data, JSON_NUMERIC_CHECK));
     $this->assign('total', $total);
     // include js and css files
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'chart.js');
 }
示例#3
0
 public function onUserLoginSaveStatistics(OW_Event $event)
 {
     $params = $event->getParams();
     BOL_SiteStatisticService::getInstance()->addEntity('user_login', $params['userId']);
 }