1 |
17220
|
thanos.pap
|
<?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 OpenAireViewBrowseProjects extends JView {
|
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 |
18541
|
thanos.pap
|
$this -> filters = array();
|
21 |
|
|
$funder = JRequest :: getString('funder');
|
22 |
|
|
if ($funder != NULL) {
|
23 |
|
|
$this -> filters['funder'] = new JObject();
|
24 |
|
|
$this -> filters['funder'] -> name = 'funder';
|
25 |
|
|
$this -> filters['funder'] -> value = $funder;
|
26 |
|
|
}
|
27 |
|
|
$fundingStream = JRequest :: getString('fundingStream');
|
28 |
|
|
if ($fundingStream != NULL) {
|
29 |
30943
|
katerina.i
|
$this -> filters['fundingStream'] = new JObject();
|
30 |
|
|
$this -> filters['fundingStream'] -> name = 'fundingStream';
|
31 |
|
|
$this -> filters['fundingStream'] -> value = $fundingStream;
|
32 |
18541
|
thanos.pap
|
}
|
33 |
|
|
$scientificArea = JRequest :: getString('scientificArea');
|
34 |
|
|
if ($scientificArea != NULL) {
|
35 |
30943
|
katerina.i
|
$this -> filters['scientificArea'] = new JObject();
|
36 |
|
|
$this -> filters['scientificArea'] -> name = 'scientificArea';
|
37 |
|
|
$this -> filters['scientificArea'] -> value = $scientificArea;
|
38 |
18541
|
thanos.pap
|
}
|
39 |
|
|
$startYear = JRequest :: getUInt('startYear', NULL);
|
40 |
|
|
if ($startYear != NULL) {
|
41 |
|
|
$this -> filters['startYear'] = new JObject();
|
42 |
|
|
$this -> filters['startYear'] -> name = 'startYear';
|
43 |
|
|
$this -> filters['startYear'] -> value = $startYear;
|
44 |
|
|
}
|
45 |
|
|
$endYear = JRequest :: getUInt('endYear', NULL);
|
46 |
|
|
if ($endYear != NULL) {
|
47 |
|
|
$this -> filters['endYear'] = new JObject();
|
48 |
|
|
$this -> filters['endYear'] -> name = 'endYear';
|
49 |
|
|
$this -> filters['endYear'] -> value = $endYear;
|
50 |
|
|
}
|
51 |
|
|
$sc39 = JRequest :: getString('sc39', NULL);
|
52 |
|
|
switch ($sc39) {
|
53 |
17220
|
thanos.pap
|
case 'true':
|
54 |
18541
|
thanos.pap
|
$sc39 = TRUE;
|
55 |
17220
|
thanos.pap
|
break;
|
56 |
|
|
case 'false':
|
57 |
18541
|
thanos.pap
|
$sc39 = FALSE;
|
58 |
17220
|
thanos.pap
|
break;
|
59 |
|
|
default:
|
60 |
18541
|
thanos.pap
|
$sc39 = NULL;
|
61 |
17220
|
thanos.pap
|
}
|
62 |
18541
|
thanos.pap
|
if ($sc39 !== NULL) {
|
63 |
|
|
$this -> filters['sc39'] = new JObject();
|
64 |
|
|
$this -> filters['sc39'] -> name = 'sc39';
|
65 |
|
|
$this -> filters['sc39'] -> value = $sc39;
|
66 |
|
|
}
|
67 |
17220
|
thanos.pap
|
$this -> page = JRequest :: getUInt('page', self :: DEFAULT_PAGE);
|
68 |
|
|
$this -> size = JRequest :: getUInt('size', self :: DEFAULT_SIZE);
|
69 |
25013
|
thanos.pap
|
JView :: loadHelper('PiwikHelper');
|
70 |
|
|
PiwikHelper :: logPageView('browseProjects', 'funder=' . urlencode($funder) . '&fundingStream=' . urlencode($fundingStream) . '&scientificArea=' . urlencode($scientificArea) . '&startYear=' . urlencode($startYear) . '&endYear=' . urlencode($endYear) . '&sc39=' . urlencode($sc39) . '&page=' . urlencode($this -> page) . '&size=' . urlencode($this -> size) . '&locale=' . urlencode($locale));
|
71 |
18541
|
thanos.pap
|
$this -> result = $model -> browseProjects($funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $this -> page, $this -> size, $locale);
|
72 |
17220
|
thanos.pap
|
$this -> totalPages = ($this -> result == NULL) ? NULL : ceil($this -> result -> totalProjects / $this -> size);
|
73 |
|
|
if ($this -> totalPages == NULL)
|
74 |
|
|
$this -> totalPages = 1;
|
75 |
|
|
$this -> pagingStart = $this -> page;
|
76 |
|
|
$this -> pagingEnd = $this -> page;
|
77 |
|
|
while (($this -> pagingEnd - $this -> pagingStart < self :: MAX_PAGES - 1) && (($this -> pagingStart != 1) || ($this -> pagingEnd != $this -> totalPages))) {
|
78 |
|
|
if ($this -> pagingStart > 1)
|
79 |
|
|
$this -> pagingStart--;
|
80 |
|
|
if ($this -> pagingEnd < $this -> totalPages)
|
81 |
|
|
$this -> pagingEnd++;
|
82 |
|
|
}
|
83 |
|
|
if (count($errors = $this -> get('Errors')) > 0) {
|
84 |
17260
|
thanos.pap
|
JLog :: add('Error viewing browseprojects: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
|
85 |
17220
|
thanos.pap
|
return FALSE;
|
86 |
|
|
}
|
87 |
|
|
parent :: display($template);
|
88 |
|
|
}
|
89 |
|
|
}
|