/** * Add this filter to the module's template or get the URL params * @param array * @param Contao\Template * @param Contao\Module * @param boolean * @return mixed string|bool|void */ public static function generateFilter(&$arrCategories, &$objTemplate, $objModule, $blnGenURL = false) { if ($blnGenURL) { // Return the URL fragment needed for this filter to pass to the lister if (\Input::post(static::$strKey) && trim(\Input::post(static::$strKey)) != $GLOBALS['TL_LANG']['MSC']['defaultSearchText']) { return static::$strKey . '/' . urlencode(Filter::cleanChars(\Input::post(static::$strKey))); } return false; } $objTemplate->hasSearch = true; $objTemplate->hasAutocomplete = strlen($objModule->iso_searchAutocomplete) ? true : false; $objTemplate->keywords = htmlentities(Filter::uncleanChars(\Input::get(static::$strKey))); $objTemplate->pkeywordsLabel = $GLOBALS['TL_LANG']['MSC'][static::$strKey . 'FilterLabel']; $objTemplate->defaultSearchText = $GLOBALS['TL_LANG']['MSC']['defaultSearchText']; }
/** * Handle incoming filter requests and generate appropriate URL * @return void */ protected function handleRequests() { if (!$this->jumpTo) { global $objPage; } else { $objPage = \PageModel::findWithDetails($this->jumpTo); } $arrRedirectParams = array(); $strRedirectParams = ''; $arrFilterTypes = deserialize($this->iso_filterTypes, true); // Loop through each filter type to get the URL params foreach ($arrFilterTypes as $filterType) { if (!isset($GLOBALS['PRODUCT_FILTERS'][$filterType])) { continue; } $strClass = $GLOBALS['PRODUCT_FILTERS'][$filterType]['class']; if (!class_exists($strClass)) { continue; } $varReturn = $strClass::generateFilter($this->arrCategories, $objTemplate, $this, true); if (!empty($varReturn)) { $arrRedirectParams[] = $varReturn; } } // Get any previously submitted URL params that aren't updated by this module $arrKeys = array_diff(array_keys($GLOBALS['PRODUCT_FILTERS']), $arrFilterTypes); foreach ($arrKeys as $key) { if (\Input::get($key)) { $arrRedirectParams[] = $key . '/' . Filter::uncleanChars(\Input::get($key)); } } $strRedirectParams = implode('/', $arrRedirectParams); $strRedirect = \Controller::generateFrontendUrl($objPage->row(), strlen($strRedirectParams) ? '/' . $strRedirectParams : null); \Controller::redirect($strRedirect); }