2 function cmpZones($a, $b)
4 if (count($a['areas'])==1)
5 return count($b['areas'])==1 ?
strcmp($a['name'], $b['name']) : 1;
6 return count($b['areas'])!=1 ?
strcmp($a['name'], $b['name']) : -1;
8 function zoneSortSelect()
10 global $lang, $config, $dDB, $wDB;
11 $cacheFilename = 'quest_zone_sort_'.$config['lang'].'.html';
12 if (checkUseCacheHtml($cacheFilename, 24*60*60))
14 $zone_sort = $dDB->selectCol("SELECT `ZoneOrSort` FROM `quest_template` GROUP BY `ZoneOrSort`");
15 $areas = $wDB->select("SELECT `id` AS ARRAY_KEY, `map_id`, `zone_id`, `name` FROM `wowd_zones` WHERE `id` IN (?a)", $zone_sort);
18 foreach($zone_sort as $z)
23 $map = $area['map_id'];
24 if (!isset($q_zones[$map]))
26 $q_zones[$map]['name'] = getMapName($map);
27 $q_zones[$map]['areas']= array();
29 $q_zones[$map]['areas'][$z]=$area['name'];
32 $q_sort[-$z]=getQuestSort(-$z);
35 uasort($q_zones, 'cmpZones');
36 uasort($q_sort, 'strcmp');
38 echo '<select name="ZoneID" style="width: 49%">';
39 echo '<option value=0>'.$lang['anything'].'</option>'."\n";
40 foreach($q_zones as $map=>$z)
42 if (count($z['areas']) > 1)
44 uasort($z['areas'], 'strcmp');
45 echo '<optgroup label="'.$z['name'].'">';
46 foreach($z['areas'] as $id=>$name)
47 echo '<option value='.$id.'>'.$name.'</option>'."\n";
52 foreach($z['areas'] as $id=>$name)
53 echo '<option value='.$id.'>'.$name.'</option>'."\n";
57 echo '<select name="SortID" style="width: 49%">';
58 echo '<option value=0>'.$lang['anything'].'</option>'."\n";
59 foreach($q_sort as $id=>$name)
60 echo '<option value='.$id.'>'.$name.'</option>'."\n";
62 flushHtmlCache($cacheFilename);