1 |
35459
|
argiro.kok
|
<?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 OpenAireViewSearchDatasets extends JViewLegacy{
|
10 |
|
|
const LOG = 'openaire';
|
11 |
|
|
const MODEL = 'search';
|
12 |
|
|
const DEFAULT_PAGE = 1;
|
13 |
|
|
const DEFAULT_SIZE = 10;
|
14 |
|
|
const MAX_PAGES = 5;
|
15 |
|
|
|
16 |
|
|
function display($template = NULL) {
|
17 |
|
|
$model = $this -> getModel(self :: MODEL);
|
18 |
|
|
$locale = JFactory :: getLanguage() -> getTag();
|
19 |
|
|
$this -> itemId = JRequest :: getUInt('Itemid', 0);
|
20 |
|
|
$this -> keyword = JRequest :: getString('keyword');
|
21 |
|
|
$this -> filters = array();
|
22 |
|
|
$type = JRequest :: getString('type');
|
23 |
|
|
if ($type != NULL) {
|
24 |
|
|
$this -> filters['type'] = new JObject();
|
25 |
|
|
$this -> filters['type'] -> name = 'type';
|
26 |
|
|
$this -> filters['type'] -> value = $type;
|
27 |
|
|
}
|
28 |
|
|
$language = JRequest :: getString('languageFilter');
|
29 |
|
|
if ($language != NULL) {
|
30 |
|
|
$this -> filters['languageFilter'] = new JObject();
|
31 |
|
|
$this -> filters['languageFilter'] -> name = 'languageFilter';
|
32 |
|
|
$this -> filters['languageFilter'] -> value = $language;
|
33 |
|
|
}
|
34 |
|
|
$funder = JRequest :: getString('funder');
|
35 |
|
|
if ($funder != NULL) {
|
36 |
|
|
$this -> filters['funder'] = new JObject();
|
37 |
|
|
$this -> filters['funder'] -> name = 'funder';
|
38 |
|
|
$this -> filters['funder'] -> value = $funder;
|
39 |
|
|
}
|
40 |
|
|
$fundingStream = JRequest :: getString('fundingStream');
|
41 |
|
|
if ($fundingStream != NULL) {
|
42 |
|
|
$this -> filters['fundingStream'] = new JObject();
|
43 |
|
|
$this -> filters['fundingStream'] -> name = 'fundingStream';
|
44 |
|
|
$this -> filters['fundingStream'] -> value = $fundingStream;
|
45 |
|
|
}
|
46 |
|
|
$scientificArea = JRequest :: getString('scientificArea');
|
47 |
|
|
if ($scientificArea != NULL) {
|
48 |
|
|
$this -> filters['scientificArea'] = new JObject();
|
49 |
|
|
$this -> filters['scientificArea'] -> name = 'scientificArea';
|
50 |
|
|
$this -> filtesr['scientificArea'] -> value = $scientificArea;
|
51 |
|
|
}
|
52 |
|
|
$year = JRequest :: getUInt('year', NULL);
|
53 |
|
|
if ($year != NULL) {
|
54 |
|
|
$this -> filters['year'] = new JObject();
|
55 |
|
|
$this -> filters['year'] -> name = 'year';
|
56 |
|
|
$this -> filters['year'] -> value = $year;
|
57 |
|
|
}
|
58 |
|
|
$accessMode = JRequest :: getString('accessMode');
|
59 |
|
|
if ($accessMode != NULL) {
|
60 |
|
|
$this -> filters['accessMode'] = new JObject();
|
61 |
|
|
$this -> filters['accessMode'] -> name = 'accessMode';
|
62 |
|
|
$this -> filters['accessMode'] -> value = $accessMode;
|
63 |
|
|
}
|
64 |
|
|
$datasource = JRequest :: getString('datasource');
|
65 |
|
|
if ($datasource != NULL) {
|
66 |
|
|
$this -> filters['datasource'] = new JObject();
|
67 |
|
|
$this -> filters['datasource'] -> name = 'datasource';
|
68 |
|
|
$this -> filters['datasource'] -> value = $datasource;
|
69 |
|
|
}
|
70 |
|
|
$this -> page = JRequest :: getUInt('page', self :: DEFAULT_PAGE);
|
71 |
|
|
$this -> size = JRequest :: getUInt('size', self :: DEFAULT_SIZE);
|
72 |
|
|
if ($this -> keyword == NULL)
|
73 |
|
|
$this -> statistics = $model -> getDatasetStatistics($locale);
|
74 |
|
|
else {
|
75 |
|
|
JViewLegacy:: loadHelper('PiwikHelper');
|
76 |
|
|
PiwikHelper :: logPageView('searchDatasets', 'keyword=' . urlencode($this -> keyword) . '&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));
|
77 |
|
|
$this -> result = $model -> searchDatasets($this -> keyword, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $this -> page, $this -> size, $locale);
|
78 |
|
|
$this -> totalPages = ($this -> result == NULL) ? NULL : ceil($this -> result -> totalDatasets / $this -> size);
|
79 |
|
|
if ($this -> totalPages == NULL)
|
80 |
|
|
$this -> totalPages = 1;
|
81 |
|
|
$this -> pagingStart = $this -> page;
|
82 |
|
|
$this -> pagingEnd = $this -> page;
|
83 |
|
|
while (($this -> pagingEnd - $this -> pagingStart < self :: MAX_PAGES - 1) && (($this -> pagingStart != 1) || ($this -> pagingEnd != $this -> totalPages))) {
|
84 |
|
|
if ($this -> pagingStart > 1)
|
85 |
|
|
$this -> pagingStart --;
|
86 |
|
|
if ($this -> pagingEnd < $this -> totalPages)
|
87 |
|
|
$this -> pagingEnd++;
|
88 |
|
|
}
|
89 |
|
|
}
|
90 |
|
|
if (count($errors = $this -> get('Errors')) > 0) {
|
91 |
|
|
JLog :: add('Error viewing searchdatasets: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
|
92 |
|
|
return FALSE;
|
93 |
|
|
}
|
94 |
|
|
parent :: display($template);
|
95 |
|
|
}
|
96 |
|
|
}
|