Ejemplo n.º 1
0
 /**
  * Statistics reporting
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function statisticsAction()
 {
     $view = $this->createViewModel();
     $config = ConfigReader::getConfig();
     $statsFilled = array('search' => false, 'record' => false);
     // Search statistics
     $search = new \VuFind\Statistics\Search();
     $search->setServiceLocator($this->getServiceLocator());
     $view->searchesBySource = $config->Statistics->searchesBySource ?: false;
     $searchSummary = $search->getStatsSummary(7, $config->Statistics->searchesBySource);
     $view->topSearches = isset($searchSummary['top']) ? $searchSummary['top'] : null;
     $view->emptySearches = isset($searchSummary['empty']) ? $searchSummary['empty'] : null;
     $view->totalSearches = isset($searchSummary['total']) ? $searchSummary['total'] : null;
     // Record statistics
     $records = new \VuFind\Statistics\Record();
     $records->setServiceLocator($this->getServiceLocator());
     $view->recordsBySource = $config->Statistics->recordsBySource ?: false;
     $recordSummary = $records->getStatsSummary(5, $config->Statistics->recordsBySource);
     $view->topRecords = isset($recordSummary['top']) ? $recordSummary['top'] : null;
     $view->totalRecordViews = isset($recordSummary['total']) ? $recordSummary['total'] : null;
     // Browser statistics
     $view->currentBrowser = $search->getBrowser($this->getRequest()->getServer('HTTP_USER_AGENT'));
     // Look for universal statistics recorder
     $matchFound = false;
     foreach ($search->getDriversForSource(null) as $currentDriver) {
         $browserStats = $currentDriver->getBrowserStats(false, 5);
         if (!empty($browserStats)) {
             $matchFound = true;
             break;
         }
     }
     // If no full coverage mode found, take the first valid source
     if (!$matchFound) {
         $drivers = $search->getDriversForSource(null, true);
         foreach ($drivers as $currentDriver) {
             $browserStats = $currentDriver->getBrowserStats(false, 5);
             if (!empty($browserStats)) {
                 $matchFound = true;
                 break;
             }
         }
     }
     // Initialize browser/version data in view based on what we found above:
     if ($matchFound) {
         $view->browserStats = $browserStats;
         $view->topVersions = $currentDriver->getBrowserStats(true, 5);
     } else {
         $view->browserStats = $view->topVersions = null;
     }
     return $view;
 }
Ejemplo n.º 2
0
 /**
  * Home (default) action -- forward to requested (or default) tab.
  *
  * @return mixed
  */
 public function homeAction()
 {
     // Forward to default tab (first fixing it if it is invalid):
     $driver = $this->loadRecord();
     $tabs = $driver->getTabs();
     if (!isset($tabs[$this->defaultTab])) {
         $keys = array_keys($tabs);
         $this->defaultTab = $keys[0];
     }
     // Save statistics:
     if ($this->logStatistics) {
         $statController = new \VuFind\Statistics\Record();
         $statController->setServiceLocator($this->getServiceLocator());
         $statController->log($driver, $this->getRequest());
     }
     return $this->showTab($this->params()->fromRoute('tab', $this->defaultTab));
 }