1
|
<?php
|
2
|
|
3
|
defined('_JEXEC') or die('Access denied');
|
4
|
|
5
|
jimport('joomla.application.component.view');
|
6
|
jimport('joomla.environment.request');
|
7
|
jimport('joomla.log.log');
|
8
|
|
9
|
class OpenAireViewAdvancedSearchPublications extends JView {
|
10
|
const LOG = 'openaire';
|
11
|
const MODEL = 'search';
|
12
|
const TITLE = 'title';
|
13
|
const AUTHOR = 'author';
|
14
|
const PUBLISHER = 'publisher';
|
15
|
const SUBJECT = 'subject';
|
16
|
const ALL = 'all';
|
17
|
const ANY = 'any';
|
18
|
const DEFAULT_PAGE = 1;
|
19
|
const MIN_SIZE = 10;
|
20
|
const MAX_SIZE = 50;
|
21
|
const SIZE_STEP = 10;
|
22
|
const DEFAULT_FROM_MONTH = 1;
|
23
|
const DEFAULT_TO_MONTH = 12;
|
24
|
const MAX_PAGES = 5;
|
25
|
|
26
|
public function __construct($configuration = array()) {
|
27
|
parent :: __construct($configuration);
|
28
|
}
|
29
|
|
30
|
function display($template = NULL) {
|
31
|
$locale = JFactory :: getLanguage() -> getTag();
|
32
|
$model = $this -> getModel(self :: MODEL);
|
33
|
$this -> statistics = $model -> getPublicationStatistics($locale);
|
34
|
$this -> minYear = ($this -> statistics['year'] -> data == NULL) ? date('Y') : min(array_keys($this -> statistics['year'] -> data));
|
35
|
$this -> maxYear = ($this -> statistics['year'] -> data == NULL) ? date('Y') : max(array_keys($this -> statistics['year'] -> data));
|
36
|
$input = JFactory :: getApplication() -> input;
|
37
|
$this -> itemId = JRequest :: getUInt('Itemid', 0);
|
38
|
$this -> keywords = $this -> getParameter('keyword');
|
39
|
$this -> fields = $this -> getParameter('field');
|
40
|
$this -> constraints = $this -> getParameter('constraint');
|
41
|
$this -> types = $this -> getParameter('type');
|
42
|
$this -> languages = $this -> getParameter('languageSearch');
|
43
|
$this -> funders = $this -> getParameter('funder');
|
44
|
$this -> fundingStreams = $this -> getParameter('fundingStream');
|
45
|
$this -> scientificAreas = $this -> getParameter('scientificArea');
|
46
|
$this -> date = JRequest :: getInt('date', -1);
|
47
|
$this -> fromMonth = JRequest :: getUInt('fromMonth', self :: DEFAULT_FROM_MONTH);
|
48
|
$this -> fromYear = JRequest :: getUInt('fromYear', $this -> minYear);
|
49
|
$this -> toMonth = JRequest :: getUInt('toMonth', self :: DEFAULT_TO_MONTH);
|
50
|
$this -> toYear = JRequest :: getUInt('toYear', $this -> maxYear);
|
51
|
$this -> accessModes = $this -> getParameter('accessMode');
|
52
|
$this -> datasources = $this -> getParameter('datasource');
|
53
|
$this -> filters = array();
|
54
|
$type = JRequest :: getString('typeFilter');
|
55
|
if ($type != NULL) {
|
56
|
$this -> filters['typeFilter'] = new JObject();
|
57
|
$this -> filters['typeFilter'] -> name = 'typeFilter';
|
58
|
$this -> filters['typeFilter'] -> value = $type;
|
59
|
}
|
60
|
$language = JRequest :: getString('languageFilter');
|
61
|
if ($language != NULL) {
|
62
|
$this -> filters['languageFilter'] = new JObject();
|
63
|
$this -> filters['languageFilter'] -> name = 'languageFilter';
|
64
|
$this -> filters['languageFilter'] -> value = $language;
|
65
|
}
|
66
|
$funder = JRequest :: getString('funderFilter');
|
67
|
if ($funder != NULL) {
|
68
|
$this -> filters['funderFilter'] = new JObject();
|
69
|
$this -> filters['funderFilter'] -> name = 'funderFilter';
|
70
|
$this -> filters['funderFilter'] -> value = $funder;
|
71
|
}
|
72
|
$fundingStream = JRequest :: getString('fundingStreamFilter');
|
73
|
if ($fundingStream != NULL) {
|
74
|
$this -> filters['fundingStreamFilter'] = new JObject();
|
75
|
$this -> filters['fundingStreamFilter'] -> name = 'fundingStreamFilter';
|
76
|
$this -> filters['fundingStreamFilter'] -> value = $fundingStream;
|
77
|
}
|
78
|
$scientificArea = JRequest :: getString('scientificAreaFilter');
|
79
|
if ($scientificArea != NULL) {
|
80
|
$this -> filters['scientificAreaFilter'] = new JObject();
|
81
|
$this -> filters['scientificAreaFilter'] -> name = 'scientificAreaFilter';
|
82
|
$this -> filters['scientificAreaFilter'] -> value = $scientificArea;
|
83
|
}
|
84
|
$year = JRequest :: getString('yearFilter');
|
85
|
if ($year != NULL) {
|
86
|
$this -> filters['yearFilter'] = new JObject();
|
87
|
$this -> filters['yearFilter'] -> name = 'yearFilter';
|
88
|
$this -> filters['yearFilter'] -> value = $year;
|
89
|
}
|
90
|
$accessMode = JRequest :: getString('accessModeFilter');
|
91
|
if ($accessMode != NULL) {
|
92
|
$this -> filters['accessModeFilter'] = new JObject();
|
93
|
$this -> filters['accessModeFilter'] -> name = 'accessModeFilter';
|
94
|
$this -> filters['accessModeFilter'] -> value = $accessMode;
|
95
|
}
|
96
|
$datasource = JRequest :: getString('datasourceFilter');
|
97
|
if ($datasource != NULL) {
|
98
|
$this -> filters['datasourceFilter'] = new JObject();
|
99
|
$this -> filters['datasourceFilter'] -> name = 'datasourceFilter';
|
100
|
$this -> filters['datasourceFilter'] -> value = $datasource;
|
101
|
}
|
102
|
$this -> page = JRequest :: getUInt('page', self :: DEFAULT_PAGE);
|
103
|
$this -> size = JRequest :: getUInt('size', self :: MIN_SIZE);
|
104
|
if ((($this -> keywords != NULL) && ($this -> fields != NULL) && ($this -> constraints != NULL)) || ($this -> types != NULL) || ($this -> languages != NULL) || ($this -> funders != NULL) || ($this -> fundingStreams != NULL) || ($this -> scientificAreas != NULL) || ($this -> date != -1) || ($this -> accessModes != NULL) || ($this -> datasources != NULL)) {
|
105
|
|
106
|
JView :: loadHelper('PiwikHelper');
|
107
|
PiwikHelper :: logPageView('advancedSearchPublications', 'keywords=' . urlencode(implode(',', $this -> keywords)) . '&fields=' . urlencode(implode(',', $this -> fields)) . '&constraints=' . urlencode(implode(',', $this -> constraints)) . '&types=' . urlencode(implode(',', $this -> types)) . '&languages=' . urlencode(implode($this -> languages)) . '&funders=' . urlencode(implode(',', $this -> funders)) . '&fundingStreams=' . urlencode(implode(',', $this -> fundingStreams)) . '&scientificAreas=' . urlencode(implode(',', $this -> scientificAreas)) . '&date=' . urlencode($this -> date) . '&fromMonth=' . urlencode($this -> fromMonth) . '&fromYear=' . urlencode($this -> fromYear) . '&toMonth=' . urlencode($this -> toMonth) . '&toYear=' . urlencode($this -> toYear) . '&accessModes=' . urlencode(implode(',', $this -> accessModes)) . '&datasources=' . urlencode(implode($this -> datasources)) . '&type=' . urlencode($type) . '&language=' . urlencode($language) . '&funder=' . urlencode($funder) . '&fundingStream=' . urlencode($fundingStream) . '&scientificArea=' . urlencode($scientificArea) . '&year=' . urlencode($year) . '&accessMode=' . urlencode($accessMode) . '&datasource=' . urlencode($datasource) . '&page=' . urlencode($this -> page) . '&size=' . urlencode($this -> size) . '&locale=' . urlencode($locale));
|
108
|
$this -> result = $model -> advancedSearchPublications($this -> keywords, $this -> fields, $this -> constraints, $this -> types, $this -> languages, $this -> funders, $this -> fundingStreams, $this -> scientificAreas, $this -> date, $this -> fromMonth, $this -> fromYear, $this -> toMonth, $this -> toYear, $this -> accessModes, $this -> datasources, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $this -> page, $this -> size, $locale);
|
109
|
$this -> totalPages = ($this -> result == NULL) ? NULL : ceil($this -> result -> totalPublications / $this -> size);
|
110
|
if ($this -> totalPages == NULL)
|
111
|
$this -> totalPages = 1;
|
112
|
$this -> pagingStart = $this -> page;
|
113
|
$this -> pagingEnd = $this -> page;
|
114
|
while (($this -> pagingEnd - $this -> pagingStart < self :: MAX_PAGES - 1) && (($this -> pagingStart != 1) || ($this -> pagingEnd != $this -> totalPages))) {
|
115
|
if ($this -> pagingStart > 1)
|
116
|
$this -> pagingStart --;
|
117
|
if ($this -> pagingEnd < $this -> totalPages)
|
118
|
$this -> pagingEnd++;
|
119
|
}
|
120
|
} else
|
121
|
$this -> result = NULL;
|
122
|
if (count($errors = $this -> get('Errors')) > 0) {
|
123
|
JLog :: add('Error viewing advancedsearchpublications: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
|
124
|
return FALSE;
|
125
|
}
|
126
|
parent :: display($template);
|
127
|
}
|
128
|
|
129
|
private function getParameter($name) {
|
130
|
$values = JFactory :: getApplication() -> input -> get($name, NULL, NULL);
|
131
|
if ($values == NULL)
|
132
|
$values = array();
|
133
|
else if (!is_array($values)) {
|
134
|
$value = $values;
|
135
|
$values = array();
|
136
|
$values[] = $value;
|
137
|
}
|
138
|
return $values;
|
139
|
}
|
140
|
}
|
141
|
|