Example #1
0
 private static function GetFilterForNPCs()
 {
     $filter_string = null;
     $andOr = 1;
     $all_filters = WoW::GetFilters();
     if (is_array($all_filters)) {
         foreach ($all_filters as $filter) {
             if (!isset($filter['key']) || !isset($filter['values'])) {
                 continue;
             }
             $val_count = count($filter['values']);
             switch ($filter['key']) {
                 // Family
                 case 'fa':
                     if ($val_count == 1) {
                         $filter_string .= '{COND} `a`.`family` = ' . $filter['values'][0];
                     } else {
                         $filter_string .= '{COND} `a`.`family` IN (';
                         self::ApplyMultiFiltersToString($val_count, $filter, $filter_string);
                     }
                     break;
             }
         }
     }
     return str_replace('{COND}', $andOr == 2 ? 'OR' : 'AND', $filter_string);
 }
Example #2
0
 private static function GetFiltersForItems()
 {
     $filter_string = null;
     $andOr = 1;
     $all_filters = WoW::GetFilters();
     if (is_array($all_filters)) {
         foreach ($all_filters as $filter) {
             if (!isset($filter['key']) || !isset($filter['values'])) {
                 continue;
             }
             $val_count = count($filter['values']);
             switch ($filter['key']) {
                 // Name
                 case 'na':
                     if (WoW_Locale::GetLocaleID() > 0) {
                         $filter_string .= sprintf(" {COND} ((`b`.`name_loc%d` LIKE '%s') OR (`a`.`name` LIKE '%s'))", WoW_Locale::GetLocaleID(), '%' . $filter['values'][0] . '%', '%' . $filter['values'][0] . '%');
                     } else {
                         $filter_string .= sprintf("' {COND} `a`.`name` LIKE '%s'", '%' . $filter['values'][0] . '%');
                     }
                     break;
                     // Quality
                 // Quality
                 case 'qu':
                     if ($val_count == 1) {
                         $filter_string .= sprintf(' {COND} `a`.`Quality` = %d', $filter['values'][0]);
                     } else {
                         $filter_string .= ' {COND} `a`.`Quality` IN ( ';
                         self::ApplyMultiFiltersToString($val_count, $filter, $filter_string);
                     }
                     break;
                     // Min item level
                 // Min item level
                 case 'minle':
                     $filter_string .= sprintf(' {COND} `a`.`ItemLevel` >= %d', $filter['values'][0]);
                     break;
                     // Max item level
                 // Max item level
                 case 'maxle':
                     $filter_string .= sprintf(' {COND} `a`.`ItemLevel` <= %d', $filter['values'][0]);
                     break;
                     // At least one?
                 // At least one?
                 case 'ma':
                     if ($filter['values'][0] == 1) {
                         $andOr = 2;
                     }
                     break;
                     // Min req level
                 // Min req level
                 case 'minrl':
                     $filter_string .= sprintf(' {COND} `a`.`RequiredLevel` >= %d', $filter['values'][0]);
                     break;
                     // Max req level
                 // Max req level
                 case 'maxrl':
                     $filter_string .= sprintf(' {COND} `a`.`RequiredLevel` <= %d', $filter['values'][0]);
                     break;
                     // Slot
                 // Slot
                 case 'sl':
                     if ($val_count == 1) {
                         $filter_string .= sprintf(' {COND} `a`.`InventoryType` = %d', $filter['values'][0]);
                         WoW_Template::SetPageData('breadcrumb', WoW_Template::GetPageData('breadcrumb') . ',' . $filter['values'][0]);
                     } else {
                         $filter_string .= ' {COND} `a`.`InventoryType` IN( ';
                         self::ApplyMultiFiltersToString($val_count, $filter, $filter_string);
                     }
                     break;
                     // Side
                 // Side
                 case 'si':
                     switch ($filter['values'][0]) {
                         case -1:
                             // Alliance only
                             $filter_string .= ' {COND} `a`.`AllowableRace` = ' . WoW_Utils::GetFactionBitMaskByFactionId(FACTION_ALLIANCE);
                             break;
                         case 1:
                             // Alliance
                             $filter_string .= ' {COND} `a`.`AllowableRace` & ' . WoW_Utils::GetFactionBitMaskByFactionId(FACTION_ALLIANCE);
                             break;
                         case -2:
                             // Horde only
                             $filter_string .= ' {COND} `a`.`AllowableRace` = ' . WoW_Utils::GetFactionBitMaskByFactionId(FACTION_HORDE);
                             break;
                         case 2:
                             // Horde
                             $filter_string .= ' {COND} `a`.`AllowableRace` & ' . WoW_Utils::GetFactionBitMaskByFactionId(FACTION_HORDE);
                             break;
                         default:
                             // Skip "3" - useable by all
                             break;
                     }
                     break;
                     // Useable by class ID
                 // Useable by class ID
                 case 'ub':
                     if (!($filter['values'][0] < CLASS_WARRIOR) && !($filter['values'][0] >= MAX_CLASSES)) {
                         $filter_string .= ' {COND} `a`.`AllowableClass` & ' . WoW_Utils::GetClassBitMaskByClassId($filter['values'][0]);
                     }
                     break;
             }
         }
     }
     if (self::$m_items_class >= 0) {
         $filter_string .= sprintf(' {COND} `a`.`class` = %d', self::$m_items_class);
     }
     if (self::$m_items_subclass >= 0) {
         $filter_string .= sprintf(' {COND} `a`.`subclass` = %d', self::$m_items_subclass);
     }
     $filter_string = str_replace('{COND}', $andOr == 2 ? 'OR' : 'AND', $filter_string);
     $filter_string = substr($filter_string, 5);
     return $filter_string;
 }