getModel(self :: MODEL); $locale = JFactory :: getLanguage() -> getTag(); $this -> itemId = JRequest :: getUInt('Itemid', 0); $this -> keyword = JRequest :: getString('keyword'); $this -> filters = array(); $funder = JRequest :: getString('funder'); if ($funder != NULL) { $this -> filters['funder'] = new JObject(); $this -> filters['funder'] -> name = 'funder'; $this -> filters['funder'] -> value = $funder; } $fundingStream = JRequest :: getString('fundingStream'); if ($fundingStream != NULL) { $this -> filters['fundingStream'] = new JObject(); $this -> filters['fundingStream'] -> name = 'fundingStream'; $this -> filters['fundingStream'] -> value = $fundingStream; } $fundingStreamLevel1 = JRequest :: getString('fundingStreamLevel1'); if ($fundingStreamLevel1 != NULL) { $this -> filters['fundingStreamLevel1'] = new JObject(); $this -> filters['fundingStreamLevel1'] -> name = 'fundingStreamLevel1'; $this -> filters['fundingStreamLevel1'] -> value = $fundingStreamLevel1; } $fundingStreamLevel2 = JRequest :: getString('fundingStreamLevel2'); if ($fundingStreamLevel2 != NULL) { $this -> filters['fundingStreamLevel2'] = new JObject(); $this -> filters['fundingStreamLevel2'] -> name = 'fundingStreamLevel2'; $this -> filters['fundingStreamLevel2'] -> value = $fundingStreamLevel2; } $startYear = JRequest :: getUInt('startYear', NULL); if ($startYear != NULL) { $this -> filters['startYear'] = new JObject(); $this -> filters['startYear'] -> name = 'startYear'; $this -> filters['startYear'] -> value = $startYear; } $endYear = JRequest :: getUInt('endYear', NULL); if ($endYear != NULL) { $this -> filters['endYear'] = new JObject(); $this -> filters['endYear'] -> name = 'endYear'; $this -> filters['endYear'] -> value = $endYear; } $sc39 = JRequest :: getString('sc39', NULL); switch ($sc39) { case 'true': $sc39 = TRUE; break; case 'false': $sc39 = FALSE; break; default: $sc39 = NULL; } if ($sc39 !== NULL) { $this -> filters['sc39'] = new JObject(); $this -> filters['sc39'] -> name = 'sc39'; $this -> filters['sc39'] -> value = $sc39; } $this -> page = JRequest :: getUInt('page', self :: DEFAULT_PAGE); $this -> size = self :: DEFAULT_SIZE; //JRequest :: getUInt('size', self :: DEFAULT_SIZE); if ($this -> keyword == NULL) $this -> statistics = $model -> getProjectStatistics($locale,false); else { JViewLegacy:: loadHelper('PiwikHelper'); PiwikHelper :: logPageView('searchProjects', 'keyword=' . urlencode($this -> keyword) . '&funder=' . urlencode($funder) . '&fundingStream=' . urlencode($fundingStream) . '&fundingStreamLevel1=' . urlencode($fundingStreamLevel1) . '&startYear=' . urlencode($startYear) . '&endYear=' . urlencode($endYear) . '&sc39=' . urlencode($sc39) . '&page=' . urlencode($this -> page) . '&size=' . urlencode($this -> size) . '&locale=' . urlencode($locale)); $this -> result = $model -> searchProjects($this -> keyword, $funder, $fundingStream, $fundingStreamLevel1, $fundingStreamLevel2, $startYear, $endYear, $sc39, $this -> page, $this -> size, $locale, TRUE); $this -> totalPages = ($this -> result == NULL) ? NULL : ceil($this -> result -> totalProjects / $this -> size); if ($this -> totalPages == NULL) $this -> totalPages = 1; $this -> page = ($this -> page > $this -> totalPages)? $this -> totalPages:$this -> page; $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++; } } if (count($errors = $this -> get('Errors')) > 0) { JLog :: add('Error viewing searchprojects: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG); return FALSE; } parent :: display($template); } }