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 OpenAireViewSearchPeople 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
|
$country = JRequest :: getString('country');
|
23
|
if ($country != NULL) {
|
24
|
$this -> filters['country'] = new JObject();
|
25
|
$this -> filters['country'] -> name = 'country';
|
26
|
$this -> filters['country'] -> value = $country;
|
27
|
}
|
28
|
$this -> page = JRequest :: getUInt('page', self :: DEFAULT_PAGE);
|
29
|
$this -> size = JRequest :: getUInt('size', self :: DEFAULT_SIZE);
|
30
|
if ($this -> keyword == NULL)
|
31
|
$this -> statistics = $model -> getPeopleStatistics($locale);
|
32
|
else {
|
33
|
JViewLegacy:: loadHelper('PiwikHelper');
|
34
|
PiwikHelper :: logPageView('searchPeople', 'keyword=' . urlencode($this -> keyword) . '&country=' . urlencode($country) . '&page=' . urlencode($this -> page) . '&size=' . urlencode($this -> size) . '&locale=' . urlencode($locale));
|
35
|
$this -> result = $model -> searchPeople($this -> keyword, $country, $this -> page, $this -> size, $locale);
|
36
|
$this -> totalPages = ($this -> result == NULL) ? NULL : ceil($this -> result -> totalPeople / $this -> size);
|
37
|
if ($this -> totalPages == NULL)
|
38
|
$this -> totalPages = 1;
|
39
|
$this -> pagingStart = $this -> page;
|
40
|
$this -> pagingEnd = $this -> page;
|
41
|
while (($this -> pagingEnd - $this -> pagingStart < self :: MAX_PAGES - 1) && (($this -> pagingStart != 1) || ($this -> pagingEnd != $this -> totalPages))) {
|
42
|
if ($this -> pagingStart > 1)
|
43
|
$this -> pagingStart --;
|
44
|
if ($this -> pagingEnd < $this -> totalPages)
|
45
|
$this -> pagingEnd++;
|
46
|
}
|
47
|
}
|
48
|
if (count($errors = $this -> get('Errors')) > 0) {
|
49
|
JLog :: add('Error viewing searchpeople: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG);
|
50
|
return FALSE;
|
51
|
}
|
52
|
parent :: display($template);
|
53
|
}
|
54
|
}
|
55
|
|