Esempio n. 1
0
 /**
  * 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'];
 }
Esempio n. 2
0
 /**
  * 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)
 {
     $arrRanges = static::getPriceRanges();
     // !HOOK: custom price ranges
     if (isset($GLOBALS['ISO_HOOKS']['getFilterPriceRanges']) && is_array($GLOBALS['ISO_HOOKS']['getFilterPriceRanges'])) {
         foreach ($GLOBALS['ISO_HOOKS']['getFilterPriceRanges'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $arrRanges = $objCallback->{$callback}[1]($arrRanges, $arrCategories, $objTemplate, $objModule, $blnGenURL);
         }
     }
     if ($blnGenURL) {
         $arrPosted = (array) \Input::post(static::$strKey);
         //return the URL fragment needed for this filter to pass to the lister
         if (!empty($arrPosted)) {
             $arrURLFilters = array();
             foreach ($arrPosted as $post) {
                 //Check that they exist
                 if (strlen(trim($post)) && (in_array($post, array_keys($arrRanges)) || in_array(htmlentities($post), array_keys($arrRanges)))) {
                     $arrURLFilters[] = $post;
                 }
             }
             if (count($arrURLFilters) > 0) {
                 return static::$strKey . '/' . urlencode(Filter::cleanChars(implode(',', $arrURLFilters)));
             }
         }
         return false;
     }
     if (count($arrRanges) > 0) {
         $arrChecked = \Input::get(static::$strKey) ? explode(',', \Input::get(static::$strKey)) : array();
         $objTemplate->hasPriceFilter = true;
         $objTemplate->price = array_map('htmlentities', $arrRanges);
         $objTemplate->priceselected = array_map('htmlentities', array_map(array('IsotopeDirect\\Filter\\Filter', 'uncleanChars'), $arrChecked));
         $objTemplate->ppriceLabel = $GLOBALS['TL_LANG']['MSC'][static::$strKey . 'FilterLabel'];
         $objTemplate->priceBlankLabel = $GLOBALS['TL_LANG']['MSC']['directBlankOptionLabel'];
     }
 }
 /**
  * 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);
 }