getTag(); $model = $this -> getModel(self :: MODEL); $this -> statistics = $model -> getProjectStatistics($locale); $this -> minStartYear = ($this -> statistics['startYear'] -> data == NULL) ? date('Y') : min(array_keys($this -> statistics['startYear'] -> data)); $this -> maxStartYear = ($this -> statistics['startYear'] -> data == NULL) ? date('Y') : max(array_keys($this -> statistics['startYear'] -> data)); $this -> minEndYear = ($this -> statistics['endYear'] -> data == NULL) ? date('Y') : min(array_keys($this -> statistics['endYear'] -> data)); $this -> maxEndYear = ($this -> statistics['endYear'] -> data == NULL) ? date('Y') : max(array_keys($this -> statistics['endYear'] -> data)); $input = JFactory :: getApplication() -> input; $this -> itemId = JRequest :: getUInt('Itemid', 0); $this -> keywords = $this -> getParameter('keyword'); $this -> fields = $this -> getParameter('field'); $this -> constraints = $this -> getParameter('constraint'); $this -> funders = $this -> getParameter('funder'); $this -> fundingStreams = $this -> getParameter('fundingStream'); $this -> scientificAreas = $this -> getParameter('scientificArea'); $this -> startDate = JRequest :: getInt('startDate', -1); $this -> startFromMonth = JRequest :: getUInt('startFromMonth', self :: DEFAULT_FROM_MONTH); $this -> startFromYear = JRequest :: getUInt('startFromYear', $this -> minStartYear); $this -> startToMonth = JRequest :: getUInt('startToMonth', self :: DEFAULT_TO_MONTH); $this -> startToYear = JRequest :: getUInt('startToYear', $this -> maxStartYear); $this -> endDate = JRequest :: getInt('endDate', -1); $this -> endFromMonth = JRequest :: getUInt('endFromMonth', self :: DEFAULT_FROM_MONTH); $this -> endFromYear = JRequest :: getUInt('endFromYear', $this -> minEndYear); $this -> endToMonth = JRequest :: getUInt('endToMonth', self :: DEFAULT_TO_MONTH); $this -> endToYear = JRequest :: getUInt('endToYear', $this -> maxEndYear); $this -> sc39s = $this -> getParameter('sc39'); $this -> sc39s = array_filter(array_map(function ($sc39) {switch ($sc39) {case 'true': return TRUE; case 'false': return FALSE; default: return NULL;}}, $this -> sc39s), function ($sc39) {return $sc39 !== NULL;}); $this -> filters = array(); $funder = JRequest :: getString('funderFilter'); if ($funder != NULL) { $this -> filters['funderFilter'] = new JObject(); $this -> filters['funderFilter'] -> name = 'funderFilter'; $this -> filters['funderFilter'] -> value = $funder; } $fundingStream = JRequest :: getString('fundingStreamFilter'); if ($fundingStream != NULL) { $this -> filters['fundingStreamFilter'] = new JObject(); $this -> filters['fundingStreamFilter'] -> name = 'fundingStreamFilter'; $this -> filters['fundingStreamFilter'] -> value = $fundingStream; } $scientificArea = JRequest :: getString('scientificAreaFilter'); if ($scientificArea != NULL) { $this -> filters['scientificAreaFilter'] = new JObject(); $this -> filters['scientificAreaFilter'] -> name = 'scientificAreaFilter'; $this -> filters['scientificAreaFilter'] -> value = $scientificArea; } $startYear = intval(JRequest :: getString('startYearFilter')); if ($startYear != NULL) { $this -> filters['startYearFilter'] = new JObject(); $this -> filters['startYearFilter'] -> name = 'startYearFilter'; $this -> filters['startYearFilter'] -> value = $startYear; } $endYear = intval(JRequest :: getString('endYearFilter')); if ($endYear != NULL) { $this -> filters['endYearFilter'] = new JObject(); $this -> filters['endYearFilter'] -> name = 'endYearFilter'; $this -> filters['endYearFilter'] -> value = $endYear; } $sc39 = JRequest :: getString('sc39Filter'); switch ($sc39) { case 'true': $sc39 = TRUE; break; case 'false': $sc39 = FALSE; break; default: $sc39 = NULL; } if ($sc39 !== NULL) { $this -> filters['sc39Filter'] = new JObject(); $this -> filters['sc39Filter'] -> name = 'sc39Filter'; $this -> filters['sc39Filter'] -> value = $sc39; } $this -> page = JRequest :: getUInt('page', self :: DEFAULT_PAGE); $this -> size = JRequest :: getUInt('size', self :: MIN_SIZE); if ((($this -> keywords != NULL) && ($this -> fields != NULL) && ($this -> constraints != NULL)) || ($this -> funders != NULL) || ($this -> fundingStreams != NULL) || ($this -> scientificAreas != NULL) || ($this -> startDate != -1) || ($this -> endDate != -1) || ($this -> sc39s != NULL)) { JView :: loadHelper('PiwikHelper'); PiwikHelper :: logPageView('advancedSearchProjects', 'keywords=' . urlencode(implode(',', $this -> keywords)) . '&fields=' . urlencode(implode(',', $this -> fields)) . '&constraints=' . urlencode(implode(',', $this -> constraints)) . '&funders=' . urlencode(implode(',', $this -> funders)) . '&fundingStreams=' . urlencode(implode(',', $this -> fundingStreams)) . '&scientificAreas=' . urlencode(implode(',', $this -> scientificAreas)) . '&startDate=' . urlencode($this -> startDate) . '&startFromMonth=' . urlencode($this -> startFromMonth) . '&startFromYear=' . urlencode($this -> startFromYear) . '&startToMonth=' . urlencode($this -> startToMonth) . '&startToYear=' . urlencode($this -> startToYear) . '&endDate=' . urlencode($this -> endDate) . '&endFromMonth=' . urlencode($this -> endFromMonth) . '&endFromYear=' . urlencode($this -> endFromYear) . '&endToMonth=' . urlencode($this -> endToMonth) . '&endToYear=' . urlencode($this -> endToYear) . '&sc39s=' . urlencode(implode(',', $this -> sc39s)) . '&funder=' . urlencode($funder) . '&fundingStream=' . urlencode($thisfundingStream) . '&scientificArea=' . urlencode($scientificArea) . '&startYear=' . urlencode($startYear) . '&endYear=' . urlencode($endYear) . '&sc39=' . urlencode($sc39) . '&page=' . urlencode($this -> page) . '&size=' . urlencode($this -> size) . '&locale=' . urlencode($locale)); $this -> result = $model -> advancedSearchProjects($this -> keywords, $this -> fields, $this -> constraints, $this -> funders, $this -> fundingStreams, $this -> scientificAreas, $this -> startDate, $this -> startFromMonth, $this -> startFromYear, $this -> startToMonth, $this -> startToYear, $this -> endDate, $this -> endFromMonth, $this -> endFromYear, $this -> endToMonth, $this -> endToYear, $this -> sc39s, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $this -> page, $this -> size, $locale); $this -> totalPages = ($this -> result == NULL) ? NULL : ceil($this -> result -> totalProjects / $this -> size); if ($this -> totalPages == NULL) $this -> totalPages = 1; $this -> pagingStart = $this -> page; $this -> pagingEnd = $this -> page; while (($this -> pagingEnd - $this -> pagingStart < self :: MAX_PAGES - 1) && (($this -> pagingStart != 1) || ($this -> pagingEnd != $this -> totalPages))) { if ($this -> pagingStart > 1) $this -> pagingStart --; if ($this -> pagingEnd < $this -> totalPages) $this -> pagingEnd++; } } else $this -> result = NULL; if (count($errors = $this -> get('Errors')) > 0) { JLog :: add('Error viewing advancedsearchprojects: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG); return FALSE; } parent :: display($template); } private function getParameter($name) { $values = JFactory :: getApplication() -> input -> get($name, NULL, NULL); if ($values == NULL) $values = array(); else if (!is_array($values)) { $value = $values; $values = array(); $values[] = $value; } return $values; } }