private function incrementStatisticsCounter($docId)
 {
     try {
         $statistics = Opus_Statistic_LocalCounter::getInstance();
         $statistics->countFrontdoor($docId);
     } catch (Exception $e) {
         $this->getLogger()->err("Counting frontdoor statistics failed: " . $e);
     }
 }
 /**
  * Generate PNG file that shows graph with month overview
  *
  * @return void
  *
  */
 public function monthAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $id = $this->getRequest()->getParam('id');
     if (isset($id) === FALSE) {
         //TODO: create own exception
         throw new Exception("Parameter id must be set.");
     }
     $dataPdf = Opus_Statistic_LocalCounter::getInstance()->readMonths($id);
     $dataFrontdoor = Opus_Statistic_LocalCounter::getInstance()->readMonths($id, 'frontdoor');
     for ($i = 1; $i < 13; $i++) {
         if (isset($dataPdf[$i]) === FALSE) {
             $dataPdf[$i] = 0;
         }
         if (isset($dataFrontdoor[$i]) === FALSE) {
             $dataFrontdoor[$i] = 0;
         }
     }
     ksort($dataPdf);
     ksort($dataFrontdoor);
     $graph = new Statistic_Model_StatisticGraph($this->view->translate('graph_month_title'), $dataPdf, $dataFrontdoor);
     $graph->setXAxisTitle($this->view->translate('graph_month_xaxis'));
     $graph->setYAxisTitle($this->view->translate('graph_yaxis'));
     $graph->setLegendFilesLabel($this->view->translate('graph_legend_files'));
     $graph->setLegendFrontdoorLabel($this->view->translate('graph_legend_frontdoor'));
     $graph->drawGraph();
 }
Exemple #3
0
 public function indexAction()
 {
     $docId = $this->getRequest()->getParam("docId");
     if (isset($docId) === FALSE) {
         throw new Exception("docId must be set");
     }
     $this->view->docId = $docId;
     $document = new Opus_Document($docId);
     $titles = $document->getTitleMain();
     $authors = $document->getPersonAuthor();
     $session = new Zend_Session_Namespace();
     if (isset($session->language)) {
         $language = $session->language;
     } else {
         $language = 'en';
     }
     foreach ($titles as $title) {
         if ($title->getLanguage() == $language) {
             $this->view->title = $title->getValue();
         }
     }
     $authorsArray = array();
     foreach ($authors as $author) {
         $authorsArray[] = $author->getName();
     }
     $this->view->authors = implode(', ', $authorsArray);
     //get statistics from db for total count and for image tag (accessibility)
     $statistic = Opus_Statistic_LocalCounter::getInstance();
     $totalAbstractPage = $statistic->readTotal($docId, 'frontdoor');
     $totalFiles = $statistic->readTotal($docId, 'files');
     $yearAbstractPage = $statistic->readYears($docId, 'frontdoor');
     $yearFiles = $statistic->readYears($docId, 'files');
     $this->view->totalAbstractPage = $totalAbstractPage;
     $this->view->totalFiles = $totalFiles;
     $years = array_merge(array_keys($yearAbstractPage), array_keys($yearFiles));
     if (count($years) == 0) {
         $years = array(date('Y'));
     }
     foreach ($years as $year) {
         if (isset($yearFiles[$year]) === false) {
             $yearFiles[$year] = 0;
         }
         if (isset($yearAbstractPage[$year]) === false) {
             $yearAbstractPage[$year] = 0;
         }
     }
     ksort($yearFiles);
     ksort($yearAbstractPage);
     foreach (array_keys($yearAbstractPage) as $year) {
         $lines[] = $year . ': ' . $yearAbstractPage[$year] . ', ' . $yearFiles[$year];
     }
     $this->view->altTextStat = implode('; ', $lines);
 }