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