Open Preprint Systems  3.3.0
Journal.inc.php
1 <?php
2 
24 define('PUBLISHING_MODE_OPEN', 0);
25 define('PUBLISHING_MODE_NONE', 2);
26 
27 import('lib.pkp.classes.context.Context');
28 
29 class Journal extends Context {
30 
36  $titleArray = $this->getData('name');
37  $title = null;
38 
39  foreach (array(AppLocale::getLocale(), AppLocale::getPrimaryLocale()) as $locale) {
40  if (isset($titleArray[$locale])) return $titleArray[$locale];
41  }
42  return null;
43  }
44 
50  $logoArray = $this->getData('pageHeaderLogoImage');
51  foreach (array(AppLocale::getLocale(), AppLocale::getPrimaryLocale()) as $locale) {
52  if (isset($logoArray[$locale])) return $logoArray[$locale];
53  }
54  return null;
55  }
56 
57  //
58  // Get/set methods
59  //
60 
65  public function getAssocType() {
66  return ASSOC_TYPE_JOURNAL;
67  }
68 
72  function getDAO() {
73  return DAORegistry::getDAO('JournalDAO');
74  }
75 
76 
77  //
78  // Statistics API
79  //
85  function getMetricTypes($withDisplayNames = false) {
86  // Retrieve report plugins enabled for this journal.
87  $reportPlugins = PluginRegistry::loadCategory('reports', true, $this->getId());
88 
89  // Run through all report plugins and retrieve all supported metrics.
90  $metricTypes = array();
91  foreach ($reportPlugins as $reportPlugin) {
92  $pluginMetricTypes = $reportPlugin->getMetricTypes();
93  if ($withDisplayNames) {
94  foreach ($pluginMetricTypes as $metricType) {
95  $metricTypes[$metricType] = $reportPlugin->getMetricDisplayType($metricType);
96  }
97  } else {
98  $metricTypes = array_merge($metricTypes, $pluginMetricTypes);
99  }
100  }
101 
102  return $metricTypes;
103  }
104 
113  function getDefaultMetricType() {
114  $defaultMetricType = $this->getData('defaultMetricType');
115 
116  // Check whether the selected metric type is valid.
117  $availableMetrics = $this->getMetricTypes();
118  if (empty($defaultMetricType)) {
119  if (count($availableMetrics) === 1) {
120  // If there is only a single available metric then use it.
121  $defaultMetricType = $availableMetrics[0];
122  } else {
123  // Use the site-wide default metric.
124  $application = Application::get();
125  $defaultMetricType = $application->getDefaultMetricType();
126  }
127  } else {
128  if (!in_array($defaultMetricType, $availableMetrics)) return null;
129  }
130  return $defaultMetricType;
131  }
132 
148  function getMetrics($metricType = null, $columns = array(), $filter = array(), $orderBy = array(), $range = null) {
149  // Add a journal filter and run the report.
150  $filter[STATISTICS_DIMENSION_CONTEXT_ID] = $this->getId();
151  $application = Application::get();
152  return $application->getMetrics($metricType, $columns, $filter, $orderBy, $range);
153  }
154 }
155 
156 
DataObject\getData
& getData($key, $locale=null)
Definition: DataObject.inc.php:100
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
Journal\getAssocType
getAssocType()
Definition: Journal.inc.php:65
Context
Basic class describing a context.
Definition: Context.inc.php:23
AppLocale\getPrimaryLocale
static getPrimaryLocale()
Definition: env1/MockAppLocale.inc.php:95
Journal\getLocalizedPageHeaderTitle
getLocalizedPageHeaderTitle()
Definition: Journal.inc.php:35
Journal\getMetrics
getMetrics($metricType=null, $columns=array(), $filter=array(), $orderBy=array(), $range=null)
Definition: Journal.inc.php:148
Journal\getDefaultMetricType
getDefaultMetricType()
Definition: Journal.inc.php:113
PluginRegistry\loadCategory
static loadCategory($category, $enabledOnly=false, $mainContextId=null)
Definition: PluginRegistry.inc.php:103
Journal\getMetricTypes
getMetricTypes($withDisplayNames=false)
Definition: Journal.inc.php:85
DataObject\getId
getId()
Definition: DataObject.inc.php:206
Journal
Describes basic journal properties.
Definition: Journal.inc.php:29
PKPApplication\get
static get()
Definition: PKPApplication.inc.php:235
Journal\getLocalizedPageHeaderLogo
getLocalizedPageHeaderLogo()
Definition: Journal.inc.php:49
AppLocale\getLocale
static getLocale()
Definition: env1/MockAppLocale.inc.php:40
Journal\getDAO
getDAO()
Definition: Journal.inc.php:72