Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
UsageStatsLoader.inc.php
1 <?php
2 
16 import('lib.pkp.plugins.generic.usageStats.PKPUsageStatsLoader');
17 
18 class UsageStatsLoader extends PKPUsageStatsLoader {
19 
23  function UsageStatsLoader($args) {
24  parent::PKPUsageStatsLoader($args);
25  }
26 
27 
28  //
29  // Protected methods.
30  //
34  protected function getExpectedPageAndOp() {
35  $pageAndOp = parent::getExpectedPageAndOp();
36 
37  $pageAndOp = $pageAndOp + array(
38  ASSOC_TYPE_SUBMISSION_FILE => array(
39  'catalog/download'),
40  ASSOC_TYPE_MONOGRAPH => array(
41  'catalog/book'),
42  ASSOC_TYPE_SERIES => array(
43  'catalog/series')
44  );
45 
46  $pageAndOp[Application::getContextAssocType()][] = 'catalog/index';
47 
48  return $pageAndOp;
49  }
50 
54  protected function getAssoc($assocType, $contextPaths, $page, $op, $args) {
55  list($assocTypeToReturn, $assocId) = parent::getAssoc($assocType, $contextPaths, $page, $op, $args);
56 
57  if (!$assocId && !$assocTypeToReturn) {
58  switch ($assocType) {
59  case ASSOC_TYPE_SUBMISSION_FILE:
60  if (!isset($args[0])) break;
61  $submissionId = $args[0];
62  $submissionDao = DAORegistry::getDAO('MonographDAO');
63  $monograph = $submissionDao->getById($submissionId);
64  if (!$monograph) break;
65 
66  if (!isset($args[2])) break;
67  $fileIdAndRevision = $args[2];
68  list($fileId, $revision) = array_map(create_function('$a', 'return (int) $a;'), preg_split('/-/', $fileIdAndRevision));
69 
70  $monographFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $monographFileDao SubmissionFileDAO */
71  $monographFile = $monographFileDao->getRevision($fileId, $revision);
72  if ($monographFile) {
73  $assocId = $monographFile->getFileId();
74  }
75 
76  $assocTypeToReturn = $assocType;
77  break;
78  case ASSOC_TYPE_SERIES:
79  if (!isset($args[0])) break;
80  $seriesPath = $args[0];
81  $seriesDao = Application::getSectionDAO(); /* @var $seriesDao SeriesDAO */
82  if (isset($this->_contextsByPath[current($contextPaths)])) {
83  $context = $this->_contextsByPath[current($contextPaths)];
84  $series = $seriesDao->getByPath($seriesPath, $context->getId());
85  if ($series) {
86  $assocId = $series->getId();
87  }
88  }
89 
90  break;
91  }
92  }
93 
94  return array($assocId, $assocType);
95  }
96 
100  protected function getMetricType() {
101  return OMP_METRIC_TYPE_COUNTER;
102  }
103 
104 }
105 ?>
static & getDAO($name, $dbconn=null)
static getContextAssocType()
getAssoc($assocType, $contextPaths, $page, $op, $args)
static getSectionDAO()
Scheduled task to extract transform and load usage statistics data into database. ...