Example #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'];
 }
 /**
  * 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'];
     }
 }