14 require_once(dirname(dirname(__FILE__)).
'/classes/COUNTER/COUNTER.php');
16 define(
'COUNTER_EXCEPTION_WARNING', 0);
17 define(
'COUNTER_EXCEPTION_ERROR', 1);
18 define(
'COUNTER_EXCEPTION_PARTIAL_DATA', 4);
19 define(
'COUNTER_EXCEPTION_NO_DATA', 8);
20 define(
'COUNTER_EXCEPTION_BAD_COLUMNS', 16);
21 define(
'COUNTER_EXCEPTION_BAD_FILTERS', 32);
22 define(
'COUNTER_EXCEPTION_BAD_ORDERBY', 64);
23 define(
'COUNTER_EXCEPTION_BAD_RANGE', 128);
24 define(
'COUNTER_EXCEPTION_INTERNAL', 256);
26 define(
'COUNTER_CLASS_PREFIX',
'CounterReport');
29 define(
'COUNTER_LITERAL_ARTICLE',
'Article');
30 define(
'COUNTER_LITERAL_JOURNAL',
'Journal');
31 define(
'COUNTER_LITERAL_PROPRIETARY',
'Proprietary');
50 $this->_release = $release;
67 return substr(get_class($this), strlen(COUNTER_CLASS_PREFIX));
77 case STATISTICS_FILE_TYPE_HTML:
78 $metricTypeKey =
'ft_html';
80 case STATISTICS_FILE_TYPE_PDF:
81 $metricTypeKey =
'ft_pdf';
83 case STATISTICS_FILE_TYPE_OTHER:
85 $metricTypeKey =
'other';
87 return $metricTypeKey;
109 function getReportItems($columns = array(), $filters = array(), $orderBy = array(), $range =
null) {
118 return $this->_errors ? $this->_errors : array();
126 if (!$this->_errors) {
127 $this->_errors = array();
129 array_push($this->_errors, $error);
139 $journal = $request->getContext();
140 $journalId = $journal ? $journal->getId() :
'';
143 if (isset($filters[STATISTICS_DIMENSION_CONTEXT_ID]) && $filters[STATISTICS_DIMENSION_CONTEXT_ID] != $journalId) {
144 $this->
setError(
new Exception(__(
'plugins.reports.counter.generic.exception.filter'), COUNTER_EXCEPTION_WARNING | COUNTER_EXCEPTION_BAD_FILTERS));
146 $filters[STATISTICS_DIMENSION_CONTEXT_ID] = $journalId;
163 DateTime::createFromFormat(
'Ymd His', $period.
'01 000000'),
164 DateTime::createFromFormat(
'Ymd His', $period.date(
't', strtotime(substr($period, 0, 4).
'-'.substr($period, 4).
'-01')).
' 235959')
169 }
catch (Exception $e) {
170 $this->
setError($e, COUNTER_EXCEPTION_ERROR | COUNTER_EXCEPTION_INTERNAL);
183 foreach ($errors as $error) {
184 if ($error->getCode() & COUNTER_EXCEPTION_ERROR) {
199 __(
'plugins.reports.counter.allCustomers')
202 $this->getVendorID(),
210 }
catch (Exception $e) {
211 $this->
setError($e, COUNTER_EXCEPTION_ERROR | COUNTER_EXCEPTION_INTERNAL);
213 if (isset($report)) {
214 return (
string) $report;
267 $site = $request->getSite();
268 $context = $request->getContext();
270 $availableContexts = $contextDao->getAvailable();
273 if ($availableContexts->getCount() > 1) {
274 $name = $site->getLocalizedTitle();
276 $name = $context->getData(
'publisherInstitution');
278 $name = $context->getLocalizedName();
283 return $request->getBaseUrl();
286 if ($availableContexts->getCount() > 1) {
287 $contactName = $site->getLocalizedContactName();
288 $contactEmail = $site->getLocalizedContactEmail();
290 $contactName = $context->getContactName();
291 $contactEmail = $context->getContactEmail();
294 }
catch (Exception $e) {
300 return $request->getBaseUrl();