Example #1
0
 public static function InitFilters($parsePost = true)
 {
     if ($_POST && $parsePost) {
         $filter_filters = null;
         foreach ($_POST as $filterKey => $filterValue) {
             if ((!is_string($filterValue) || $filterValue == null || empty($filterValue)) && (!is_array($filterValue) || !$filterValue)) {
                 continue;
             }
             if (is_array($filterValue) && count($filterValue) > 0) {
                 $filter_filters .= $filterKey . '=';
                 $max = count($filterValue);
                 $current = 1;
                 foreach ($filterValue as $val) {
                     if ($val === null) {
                         continue;
                     }
                     $filter_filters .= $val;
                     if ($current < $max) {
                         $filter_filters .= ':';
                     }
                 }
                 $filter_filters .= ';';
             } elseif ($filterValue !== null) {
                 $filter_filters .= $filterKey . '=' . $filterValue . ';';
             }
         }
         $filter_filters = str_replace(array(':;', '=;'), ';', $filter_filters);
         WoW::RedirectTo(self::GetPageAction() . '?filter=' . $filter_filters);
     }
     /*
         COMMON FILTERS:
             [na] => Name
             [si] => Side (1 - Alliance, -1 - Alliance only, 2 - Horde, -2 - Horde only, 3 - both)
             [cr] => CommonFilterID
             [crs] => FirstFilterValID
             [crv] => SecondFilterValID
         ITEM FILTERS:
             [sl] => SlotID
             [qu] => QualityID
             [minle] => MinItemLevel
             [maxle] => MaxItemLevel
             [minrl] => MinRequiredLevel
             [maxrl] => MaxRequiredLevel
             [ub] => UseableClassID
             [gt] => GetTypes
         ACHIEVEMENTS FILTERS:
             [minpt] => Min Points
             [maxpt] => Max Points
         QUESTS FILTERS:
             [minle] => MinQuestLevel
             [maxle] => MaxQuestLevel
         SPELLS FILTERS:
             [me] => MechanicID
             [dt] => DispellTypeID
             [sc] => SpellSchoolID
             [ra] => RaceID
         NPCS FILTERS:
             [ra] => ReactionAlliance
             [rh] => ReactionHorde
             [fa] => FamilyID
             [cl] => ClassificationID
         ITEMSET FILTERS:
             [ta] => ItemsetTag
             [ty] => ItemInventoryTypeID
     */
     //WoW_Template::SetPageIndex('filters');
     if (!isset($_GET['filter'])) {
         return false;
     }
     // Try to explode
     $filter_items = explode(';', $_GET['filter']);
     if (!$filter_items) {
         return false;
     }
     $filter = array();
     $advanced_filters = array();
     $nextId = 0;
     foreach ($filter_items as $item) {
         $current = explode('=', $item);
         if (!$current || !isset($current[1])) {
             continue;
         }
         $each = explode(':', $current[1]);
         if ($each) {
             $temp = array('key' => $current[0], 'values' => array());
             if (in_array($current[0], array('cr', 'crv', 'crs'))) {
                 $advanced_filters[$current[0]] = array('key' => $current[0], 'values' => array());
             }
             foreach ($each as $value) {
                 if ($value !== null) {
                     $temp['values'][] = $value;
                 }
                 if (in_array($current[0], array('cr', 'crv', 'crs')) && !empty($value)) {
                     $advanced_filters[$current[0]]['values'][] = $value;
                 }
             }
         } else {
             $temp = array('key' => $current[0], 'values' => $current[1]);
             if (in_array($current[0], array('cr', 'crv', 'crs'))) {
                 $advanced_filters[$current[0]] = array('key' => $current[0], 'values' => array($current[1]));
             }
         }
         ++$nextId;
         $filter[] = $temp;
     }
     WoW_Template::SetPageData('advanced_filters', $advanced_filters);
     self::$m_filters = $filter;
     unset($filter, $item);
 }