Example #1
0
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     if ($this->subject->getField('side') == SIDE_ALLIANCE) {
         $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-alliance]' . Lang::game('si', SIDE_ALLIANCE) . '[/span]';
     } else {
         if ($this->subject->getField('side') == SIDE_HORDE) {
             $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-horde]' . Lang::game('si', SIDE_HORDE) . '[/span]';
         } else {
             $infobox[] = Lang::main('side') . Lang::main('colon') . Lang::game('si', SIDE_BOTH);
         }
     }
     if ($g = $this->subject->getField('gender')) {
         $infobox[] = Lang::main('gender') . Lang::main('colon') . '[span class=icon-' . ($g == 2 ? 'female' : 'male') . ']' . Lang::main('sex', $g) . '[/span]';
     }
     if ($eId = $this->subject->getField('eventId')) {
         $this->extendGlobalIds(TYPE_WORLDEVENT, $eId);
         $infobox[] = Lang::game('eventShort') . Lang::main('colon') . '[event=' . $eId . ']';
     }
     /****************/
     /* Main Content */
     /****************/
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->expansion = Util::$expansionString[$this->subject->getField('expansion')];
     $this->redButtons = array(BUTTON_WOWHEAD => true, BUTTON_LINKS => ['name' => $this->nameFixed]);
     // factionchange-equivalent
     if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_titles WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) {
         $altTitle = new TitleList(array(['id', abs($pendant)]));
         if (!$altTitle->error) {
             $this->transfer = sprintf(Lang::title('_transfer'), $altTitle->id, $altTitle->getHtmlizedName(), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2));
         }
     }
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: quest source
     $quests = new QuestList(array(['rewardTitleId', $this->typeId]));
     if (!$quests->error) {
         $this->extendGlobalData($quests->getJSGlobals(GLOBALINFO_REWARDS));
         $this->lvTabs[] = ['quest', array('data' => array_values($quests->getListviewData()), 'id' => 'reward-from-quest', 'name' => '$LANG.tab_rewardfrom', 'hiddenCols' => ['experience', 'money'], 'visibleCols' => ['category'])];
     }
     // tab: achievement source
     if ($aIds = DB::World()->selectCol('SELECT entry FROM achievement_reward WHERE title_A = ?d OR title_H = ?d', $this->typeId, $this->typeId)) {
         $acvs = new AchievementList(array(['id', $aIds]));
         if (!$acvs->error) {
             $this->extendGlobalData($acvs->getJSGlobals());
             $this->lvTabs[] = ['achievement', array('data' => array_values($acvs->getListviewData()), 'id' => 'reward-from-achievement', 'name' => '$LANG.tab_rewardfrom', 'visibleCols' => ['category'], 'sort' => ['reqlevel', 'name'])];
         }
     }
     // tab: criteria of (to be added by TC)
 }
Example #2
0
 protected function generateContent()
 {
     $conditions = [];
     if (!User::isInGroup(U_GROUP_EMPLOYEE)) {
         // hide unused titles
         $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0];
     }
     if ($this->category) {
         $conditions[] = ['category', $this->category[0]];
     }
     $titles = new TitleList($conditions);
     if (!$titles->error) {
         $params = [];
         if ($titles->hasDiffFields(['category'])) {
             $params['visibleCols'] = "\$['category']";
         }
         if (!$titles->hasAnySource()) {
             $params['hiddenCols'] = "\$['source']";
         }
         $this->lvTabs[] = array('file' => 'title', 'data' => $titles->getListviewData(), 'params' => $params);
     }
 }
Example #3
0
 private function _searchTitle($cndBase)
 {
     $result = [];
     $cnd = array_merge($cndBase, [$this->createLookup(['male_loc' . User::$localeId, 'female_loc' . User::$localeId])]);
     $titles = new TitleList($cnd);
     if ($data = $titles->getListviewData()) {
         if ($this->searchMask & SEARCH_TYPE_OPEN) {
             foreach ($titles->iterate() as $id => $__) {
                 $data[$id]['param1'] = $titles->getField('side');
             }
         }
         $result = array('type' => TYPE_TITLE, 'appendix' => ' (Title)', 'matches' => $titles->getMatches(), 'file' => TitleList::$brickFile, 'data' => $data, 'params' => []);
         if ($titles->getMatches() > $this->maxResults) {
             // $result['params']['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $titles->getMatches(), $this->maxResults);
             $result['params']['_truncated'] = 1;
         }
     }
     return $result;
 }
Example #4
0
 protected function generateContent()
 {
     /***********/
     /* Infobox */
     /***********/
     $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags'));
     // points
     if ($_ = $this->subject->getField('points')) {
         $infobox[] = Lang::achievement('points') . Lang::main('colon') . '[achievementpoints=' . $_ . ']';
     }
     // location
     // todo (low)
     // faction
     switch ($this->subject->getField('faction')) {
         case 1:
             $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-alliance]' . Lang::game('si', SIDE_ALLIANCE) . '[/span]';
             break;
         case 2:
             $infobox[] = Lang::main('side') . Lang::main('colon') . '[span class=icon-horde]' . Lang::game('si', SIDE_HORDE) . '[/span]';
             break;
         default:
             // case 3
             $infobox[] = Lang::main('side') . Lang::main('colon') . Lang::game('si', SIDE_BOTH);
     }
     // realm first available?
     if ($this->subject->getField('flags') & 0x100 && DB::isConnectable(DB_AUTH)) {
         $avlb = [];
         foreach (DB::Auth()->selectCol('SELECT id AS ARRAY_KEY, name FROM realmlist WHERE allowedSecurityLevel = 0 AND gamebuild = ?d', WOW_VERSION) as $rId => $name) {
             if (!DB::isConnectable(DB_CHARACTERS . $rId)) {
                 continue;
             }
             if (!DB::Characters($rId)->selectCell('SELECT 1 FROM character_achievement WHERE achievement = ?d LIMIT 1', $this->typeId)) {
                 $avlb[] = $name;
             }
         }
         if ($avlb) {
             $infobox[] = Lang::achievement('rfAvailable') . implode(', ', $avlb);
         }
     }
     /**********/
     /* Series */
     /**********/
     $series = [];
     if ($c = $this->subject->getField('chainId')) {
         $chainAcv = new AchievementList(array(['chainId', $c]));
         foreach ($chainAcv->iterate() as $aId => $__) {
             $pos = $chainAcv->getField('chainPos');
             if (!isset($series[$pos])) {
                 $series[$pos] = [];
             }
             $series[$pos][] = array('side' => $chainAcv->getField('faction'), 'typeStr' => Util::$typeStrings[TYPE_ACHIEVEMENT], 'typeId' => $aId, 'name' => $chainAcv->getField('name', true));
         }
     }
     /****************/
     /* Main Content */
     /****************/
     $this->mail = $this->createMail($reqBook);
     $this->headIcons = [$this->subject->getField('iconString')];
     $this->infobox = $infobox ? '[ul][li]' . implode('[/li][li]', $infobox) . '[/li][/ul]' : null;
     $this->series = $series ? [[$series, null]] : null;
     $this->description = $this->subject->getField('description', true);
     $this->redButtons = array(BUTTON_LINKS => ['color' => 'ffffff00', 'linkId' => Util::$typeStrings[TYPE_ACHIEVEMENT] . ':' . $this->typeId . ':"..UnitGUID("player")..":0:0:0:0:0:0:0:0'], BUTTON_WOWHEAD => !($this->subject->getField('cuFlags') & CUSTOM_SERVERSIDE));
     $this->criteria = array('reqQty' => $this->subject->getField('reqCriteriaCount'), 'icons' => [], 'data' => []);
     if ($reqBook) {
         $this->addCss(['path' => 'Book.css']);
     }
     // create rewards
     if ($foo = $this->subject->getField('rewards')) {
         array_walk($foo, function (&$item) {
             $item = $item[0] != TYPE_ITEM ? null : $item[1];
         });
         $bar = new ItemList(array(['i.id', $foo]));
         foreach ($bar->iterate() as $id => $__) {
             $this->rewards['item'][] = array('name' => $bar->getField('name', true), 'quality' => $bar->getField('quality'), 'typeStr' => Util::$typeStrings[TYPE_ITEM], 'id' => $id, 'globalStr' => 'g_items');
         }
     }
     if ($foo = $this->subject->getField('rewards')) {
         array_walk($foo, function (&$item) {
             $item = $item[0] != TYPE_TITLE ? null : $item[1];
         });
         $bar = new TitleList(array(['id', $foo]));
         foreach ($bar->iterate() as $__) {
             $this->rewards['title'][] = sprintf(Lang::achievement('titleReward'), $bar->id, trim(str_replace('%s', '', $bar->getField('male', true))));
         }
     }
     $this->rewards['text'] = $this->subject->getField('reward', true);
     // factionchange-equivalent
     if ($pendant = DB::World()->selectCell('SELECT IF(horde_id = ?d, alliance_id, -horde_id) FROM player_factionchange_achievement WHERE alliance_id = ?d OR horde_id = ?d', $this->typeId, $this->typeId, $this->typeId)) {
         $altAcv = new AchievementList(array(['id', abs($pendant)]));
         if (!$altAcv->error) {
             $this->transfer = sprintf(Lang::achievement('_transfer'), $altAcv->id, 1, $altAcv->getField('iconString'), $altAcv->getField('name', true), $pendant > 0 ? 'alliance' : 'horde', $pendant > 0 ? Lang::game('si', 1) : Lang::game('si', 2));
         }
     }
     /**************/
     /* Extra Tabs */
     /**************/
     // tab: see also
     $conditions = array(['name_loc' . User::$localeId, $this->subject->getField('name', true)], ['id', $this->typeId, '!']);
     $saList = new AchievementList($conditions);
     $this->lvTabs[] = array('file' => 'achievement', 'data' => $saList->getListviewData(), 'params' => array('id' => 'see-also', 'name' => '$LANG.tab_seealso', 'visibleCols' => "\$['category']"));
     $this->extendGlobalData($saList->getJSGlobals());
     // tab: criteria of
     $refs = DB::Aowow()->SelectCol('SELECT refAchievementId FROM ?_achievementcriteria WHERE Type = ?d AND value1 = ?d', ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT, $this->typeId);
     if (!empty($refs)) {
         $coList = new AchievementList(array(['id', $refs]));
         $this->lvTabs[] = array('file' => 'achievement', 'data' => $coList->getListviewData(), 'params' => array('id' => 'criteria-of', 'name' => '$LANG.tab_criteriaof', 'visibleCols' => "\$['category']"));
         $this->extendGlobalData($coList->getJSGlobals());
     }
     /*****************/
     /* Criteria List */
     /*****************/
     $iconId = 1;
     $rightCol = [];
     foreach ($this->subject->getCriteria() as $i => $crt) {
         // hide hidden criteria for regular users (really do..?)
         // if (($crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_HIDDEN) && User::$perms > 0)
         // continue;
         // alternative display option
         $displayMoney = $crt['completionFlags'] & ACHIEVEMENT_CRITERIA_FLAG_MONEY_COUNTER;
         $crtName = Util::localizedString($crt, 'name');
         $tmp = array('id' => $crt['id'], 'name' => $crtName, 'type' => $crt['type']);
         $obj = (int) $crt['value1'];
         $qty = (int) $crt['value2'];
         switch ($crt['type']) {
             // link to npc
             case ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE:
             case ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE:
                 $tmp['link'] = array('href' => '?npc=' . $obj, 'text' => $crtName);
                 $tmp['extraText'] = Lang::achievement('slain');
                 break;
                 // link to area (by map)
             // link to area (by map)
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_BG:
             case ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA:
             case ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA:
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND:
             case ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP:
                 if ($zoneId = DB::Aowow()->selectCell('SELECT id FROM ?_zones WHERE mapId = ? LIMIT 1', $obj)) {
                     $tmp['link'] = array('href' => '?zone=' . $zoneId, 'text' => $crtName);
                 } else {
                     $tmp['extraText'] = $crtName;
                 }
                 break;
                 // link to area
             // link to area
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE:
             case ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA:
                 $tmp['link'] = array('href' => '?zone=' . $obj, 'text' => $crtName);
                 break;
                 // link to skills
             // link to skills
             case ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
                 $tmp['link'] = array('href' => '?skill=' . $obj, 'text' => $crtName);
                 break;
                 // link to class
             // link to class
             case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
                 $tmp['link'] = array('href' => '?class=' . $obj, 'text' => $crtName);
                 break;
                 // link to race
             // link to race
             case ACHIEVEMENT_CRITERIA_TYPE_HK_RACE:
                 $tmp['link'] = array('href' => '?race=' . $obj, 'text' => $crtName);
                 break;
                 // link to title - todo (low): crosslink
             // link to title - todo (low): crosslink
             case ACHIEVEMENT_CRITERIA_TYPE_EARNED_PVP_TITLE:
                 $tmp['extraText'] = Util::ucFirst(Lang::game('title')) . Lang::main('colon') . $crtName;
                 break;
                 // link to achivement (/w icon)
             // link to achivement (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_ACHIEVEMENT:
                 $tmp['link'] = array('href' => '?achievement=' . $obj, 'text' => $crtName);
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_achievements', 'id' => $obj);
                 $this->extendGlobalIds(TYPE_ACHIEVEMENT, $obj);
                 break;
                 // link to quest
             // link to quest
             case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST:
                 // $crtName = ;
                 $tmp['link'] = array('href' => '?quest=' . $obj, 'text' => $crtName ?: QuestList::getName($obj));
                 break;
                 // link to spell (/w icon)
             // link to spell (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET:
             case ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL:
             case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2:
                 $tmp['link'] = array('href' => '?spell=' . $obj, 'text' => $crtName ?: SpellList::getName($obj));
                 $this->extendGlobalIds(TYPE_SPELL, $obj);
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_spells', 'id' => $obj);
                 break;
                 // link to item (/w icon)
             // link to item (/w icon)
             case ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM:
             case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM:
                 $crtItm = new ItemList(array(['i.id', $obj]));
                 $tmp['link'] = array('href' => '?item=' . $obj, 'text' => $crtName ?: $crtItm->getField('name', true), 'quality' => $crtItm->getField('quality'), 'count' => $qty);
                 $this->extendGlobalData($crtItm->getJSGlobals());
                 $tmp['icon'] = $iconId;
                 $this->criteria['icons'][] = array('itr' => $iconId++, 'type' => 'g_items', 'id' => $obj, 'count' => $qty);
                 break;
                 // link to faction (/w target reputation)
             // link to faction (/w target reputation)
             case ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION:
                 $tmp['link'] = array('href' => '?faction=' . $obj, 'text' => $crtName ?: FactionList::getName($obj));
                 $tmp['extraText'] = ' (' . Lang::getReputationLevelForPoints($qty) . ')';
                 break;
                 // link to GObject
             // link to GObject
             case ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT:
             case ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT:
                 $tmp['link'] = array('href' => '?object=' . $obj, 'text' => $crtName);
                 break;
             default:
                 // Add a gold coin icon if required
                 $tmp['extraText'] = $displayMoney ? Util::formatMoney($qty) : $crtName;
                 break;
         }
         // If the right column
         if ($i % 2) {
             $this->criteria['data'][] = $tmp;
         } else {
             $rightCol[] = $tmp;
         }
     }
     // If you found the second column - merge data from it to the end of the main body
     if ($rightCol) {
         $this->criteria['data'] = array_merge($this->criteria['data'], $rightCol);
     }
 }
Example #5
0
function profiler()
{
    $success = true;
    $scripts = [];
    /**********/
    /* Quests */
    /**********/
    $scripts[] = function () {
        $success = true;
        $condition = [CFG_SQL_LIMIT_NONE, 'AND', [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW], 0], [['flags', QUEST_FLAG_DAILY | QUEST_FLAG_WEEKLY | QUEST_FLAG_REPEATABLE | QUEST_FLAG_AUTO_REWARDED, '&'], 0], [['specialFlags', QUEST_FLAG_SPECIAL_REPEATABLE | QUEST_FLAG_SPECIAL_DUNGEON_FINDER | QUEST_FLAG_SPECIAL_MONTHLY, '&'], 0]];
        $questz = new QuestList($condition);
        $_ = [];
        $currencies = array_column($questz->rewards, TYPE_CURRENCY);
        foreach ($currencies as $curr) {
            foreach ($curr as $cId => $qty) {
                $_[] = $cId;
            }
        }
        $relCurr = new CurrencyList(array(['id', $_]));
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(20);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_gatheredcurrencies;\n";
            foreach ($relCurr->getListviewData() as $id => $data) {
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            $buff .= "\n\nvar _ = g_quests;\n";
            foreach ($questz->getListviewData() as $id => $data) {
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            $buff .= "\ng_quest_catorder = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n";
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-quests', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /****************/
    /* Achievements */
    /****************/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], [['flags', 1, '&'], 0]);
        $achievez = new AchievementList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $sumPoints = 0;
            $buff = "var _ = g_achievements;\n";
            foreach ($achievez->getListviewData(ACHIEVEMENTINFO_PROFILE) as $id => $data) {
                $sumPoints += $data['points'];
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            // categories to sort by
            $buff .= "\ng_achievement_catorder = [92, 14863, 97, 169, 170, 171, 172, 14802, 14804, 14803, 14801, 95, 161, 156, 165, 14806, 14921, 96, 201, 160, 14923, 14808, 14805, 14778, 14865, 14777, 14779, 155, 14862, 14861, 14864, 14866, 158, 162, 14780, 168, 14881, 187, 14901, 163, 14922, 159, 14941, 14961, 14962, 14981, 15003, 15002, 15001, 15041, 15042, 81]";
            // sum points
            $buff .= "\ng_achievement_points = [" . $sumPoints . "];\n";
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-achievements', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /**********/
    /* Titles */
    /**********/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]);
        $titlez = new TitleList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            foreach ([0, 1] as $g) {
                $buff = "var _ = g_titles;\n";
                foreach ($titlez->getListviewData() as $id => $data) {
                    $data['name'] = Util::localizedString($titlez->getEntry($id), $g ? 'female' : 'male');
                    unset($data['namefemale']);
                    $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
                }
                if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-titles-' . $g, $buff)) {
                    $success = false;
                }
            }
        }
        return $success;
    };
    /**********/
    /* Mounts */
    /**********/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['typeCat', -5]);
        $mountz = new SpellList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_spells;\n";
            foreach ($mountz->getListviewData(ITEMINFO_MODEL) as $id => $data) {
                $data['quality'] = $data['name'][0];
                $data['name'] = mb_substr($data['name'], 1);
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-mounts', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /**************/
    /* Companions */
    /**************/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['typeCat', -6]);
        $companionz = new SpellList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_spells;\n";
            foreach ($companionz->getListviewData(ITEMINFO_MODEL) as $id => $data) {
                $data['quality'] = $data['name'][0];
                $data['name'] = mb_substr($data['name'], 1);
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-companions', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /************/
    /* Factions */
    /************/
    $scripts[] = function () {
        $success = true;
        $condition = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]);
        $factionz = new FactionList($condition);
        foreach (CLISetup::$localeIds as $l) {
            set_time_limit(5);
            User::useLocale($l);
            Lang::load(Util::$localeStrings[$l]);
            $buff = "var _ = g_factions;\n";
            foreach ($factionz->getListviewData() as $id => $data) {
                $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
            }
            $buff .= "\ng_faction_order = [0, 469, 891, 1037, 1118, 67, 1052, 892, 936, 1117, 169, 980, 1097];\n";
            if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-factions', $buff)) {
                $success = false;
            }
        }
        return $success;
    };
    /***********/
    /* Recipes */
    /***********/
    $scripts[] = function () {
        // special case: secondary skills are always requested, so put them in one single file (185, 129, 356); it also contains g_skill_order
        $skills = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, [185, 129, 356]];
        $success = true;
        $baseCnd = array(CFG_SQL_LIMIT_NONE, [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0], ['effect1Id', [6, 45, 57, 127, 33, 158, 99, 28, 95], '!'], ['effect2Id', [118, 60], '!'], ['OR', ['typeCat', 9], ['typeCat', 11]]);
        foreach ($skills as $s) {
            $file = is_array($s) ? 'sec' : (string) $s;
            $cnd = array_merge($baseCnd, [['skillLine1', $s]]);
            $recipez = new SpellList($cnd);
            $created = '';
            foreach ($recipez->iterate() as $__) {
                foreach ($recipez->canCreateItem() as $idx) {
                    $id = $recipez->getField('effect' . $idx . 'CreateItemId');
                    $created .= "g_items.add(" . $id . ", {'icon':'" . $recipez->relItems->getEntry($id)['iconString'] . "'});\n";
                }
            }
            foreach (CLISetup::$localeIds as $l) {
                set_time_limit(10);
                User::useLocale($l);
                Lang::load(Util::$localeStrings[$l]);
                $buff = '';
                foreach ($recipez->getListviewData() as $id => $data) {
                    $buff .= '_[' . $id . '] = ' . Util::toJSON($data) . ";\n";
                }
                if (!$buff) {
                    // this behaviour is intended, do not create an error
                    CLISetup::log('profiler - file datasets/' . User::$localeString . '/p-recipes-' . $file . ' has no content => skipping', CLISetup::LOG_WARN);
                    continue;
                }
                $buff = $created . "\nvar _ = g_spells;\n" . $buff;
                if (is_array($s)) {
                    $buff .= "\ng_skill_order = [171, 164, 333, 202, 182, 773, 755, 165, 186, 393, 197, 185, 129, 356];\n";
                }
                if (!CLISetup::writeFile('datasets/' . User::$localeString . '/p-recipes-' . $file, $buff)) {
                    $success = false;
                }
            }
        }
        return $success;
    };
    // check directory-structure
    foreach (Util::$localeStrings as $dir) {
        if (!CLISetup::writeDir('datasets/' . $dir)) {
            $success = false;
        }
    }
    // run scripts
    foreach ($scripts as $func) {
        if (!$func()) {
            $success = false;
        }
    }
    return $success;
}
Example #6
0
 private function _searchTitle($cndBase)
 {
     $cnd = array_merge($cndBase, [$this->createLookup(['male_loc' . User::$localeId, 'female_loc' . User::$localeId])]);
     $titles = new TitleList($cnd);
     if ($data = $titles->getListviewData()) {
         $result['data'] = array_values($data);
         $osInfo = [TYPE_TITLE, ' (Title)', $titles->getMatches(), []];
         if ($this->searchMask & SEARCH_TYPE_OPEN) {
             foreach ($titles->iterate() as $id => $__) {
                 $osInfo[3][$id] = $titles->getField('side');
             }
         }
         if ($titles->getMatches() > $this->maxResults) {
             // $result['note'] = sprintf(Util::$tryNarrowingString, 'LANG.lvnote_', $titles->getMatches(), $this->maxResults);
             $result['_truncated'] = 1;
         }
         return ['title', $result, null, $osInfo];
     }
     return false;
 }