コード例 #1
0
 private static function SortAchievements()
 {
     if (!self::IsLoaded() && !self::LoadAchievements()) {
         return false;
     }
     $categories = DB::WoW()->select("SELECT `id`, `categoryId` FROM `DBPREFIX_achievement` WHERE `id` IN (%s)", self::GetAchievementsIDs());
     if (!$categories) {
         WoW_Log::WriteError('%s : unable to find achievements categories!', __METHOD__);
         return false;
     }
     $storage = array();
     foreach ($categories as $category) {
         if (!isset($storage[$category['categoryId']])) {
             $storage[$category['categoryId']] = array();
         }
         $current_id = $category['id'];
         foreach (self::$achievements_storage as $achievement) {
             if ($achievement['achievement'] == $current_id) {
                 $storage[$category['categoryId']][] = $achievement;
                 break;
             }
         }
     }
     self::$sorted_storage = $storage;
     // Criterias
     $criterias = array();
     foreach (self::$criterias_storage as $criteria) {
         $criterias[$criteria['criteria']] = $criteria;
     }
     self::$criterias_storage = $criterias;
     unset($storage, $criterias);
     return true;
 }