Пример #1
0
 /**
  * Get filter & sorting configuration
  * @param boolean
  * @return array
  */
 protected function getFiltersAndSorting($blnNativeSQL = true)
 {
     $arrFilters = array();
     $arrSorting = array();
     if (is_array($this->iso_filterModules)) {
         $arrModules = array_reverse($this->iso_filterModules);
         foreach ($arrModules as $module) {
             if (is_array($GLOBALS['ISO_FILTERS'][$module])) {
                 $arrFilters = array_merge($arrFilters, $GLOBALS['ISO_FILTERS'][$module]);
             }
             if (is_array($GLOBALS['ISO_SORTING'][$module])) {
                 $arrSorting = array_merge($arrSorting, $GLOBALS['ISO_SORTING'][$module]);
             }
             if ($GLOBALS['ISO_LIMIT'][$module] > 0) {
                 $this->perPage = $GLOBALS['ISO_LIMIT'][$module];
             }
         }
     }
     if (empty($arrSorting) && $this->iso_listingSortField != '') {
         $arrSorting[$this->iso_listingSortField] = array($this->iso_listingSortDirection == 'DESC' ? SORT_DESC : SORT_ASC, SORT_REGULAR);
     }
     // Thanks to certo web & design for sponsoring this feature
     if ($blnNativeSQL) {
         $strWhere = '';
         $arrWhere = array();
         $arrValues = array();
         // Initiate native SQL filtering
         foreach ($arrFilters as $k => $filter) {
             if ($filter['group'] == '' && !in_array($filter['attribute'], $GLOBALS['ISO_CONFIG']['dynamicAttributes'])) {
                 $operator = IsotopeFrontend::convertFilterOperator($filter['operator'], 'SQL');
                 $arrWhere[] = "{$filter['attribute']} {$operator} ?";
                 $arrValues[] = $filter['value'];
                 unset($arrFilters[$k]);
             }
         }
         if (count($arrWhere)) {
             $time = time();
             $strWhere = " AND ((p1." . implode(' AND p1.', $arrWhere) . ") OR p1.id IN (SELECT pid FROM tl_iso_products WHERE language='' AND " . implode(' AND ', $arrWhere) . (BE_USER_LOGGED_IN === true ? '' : " AND published='1' AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time})") . "))";
             $arrValues = array_merge($arrValues, $arrValues);
         }
         return array($arrFilters, $arrSorting, $strWhere, $arrValues);
     }
     return array($arrFilters, $arrSorting);
 }