Exemplo n.º 1
0
 protected function handleLoad()
 {
     /*  params
                 id: profileId
                 items: string       [itemIds.join(':')]
                 unnamed: unixtime   [only to force the browser to reload instead of cache]
             return
                 lots...
         */
     // titles, achievements, characterData, talents (, pets)
     // and some onLoad-hook to .. load it registerProfile($data)
     // everything else goes through data.php .. strangely enough
     if (!$this->_get['id']) {
         return;
     }
     $char = new ProfileList(array(['id', $this->_get['id'][0]]));
     // or string or whatever
     $buff = '';
     if ($it = array_column($char->getField('inventory'), 0)) {
         $itemz = new ItemList(array(['id', $it, CFG_SQL_LIMIT_NONE]));
         $data = $itemz->getListviewData(ITEMINFO_JSON | ITEMINFO_SUBITEMS);
         // get and apply inventory
         foreach ($itemz->iterate() as $iId => $__) {
             $buff .= 'g_items.add(' . $iId . ', {name_' . User::$localeString . ":'" . Util::jsEscape($itemz->getField('name', true)) . "', quality:" . $itemz->getField('quality') . ", icon:'" . $itemz->getField('iconString') . "', jsonequip:" . Util::toJSON($data[$iId]) . "});\n";
         }
         $buff .= "\n";
     }
     if ($au = $char->getField('auras')) {
         $auraz = new SpellList(array(['id', $char->getField('auras')], CFG_SQL_LIMIT_NONE));
         $dataz = $auraz->getListviewData();
         $modz = $auraz->getProfilerMods();
         // get and apply aura-mods
         foreach ($dataz as $id => $data) {
             $mods = [];
             if (!empty($modz[$id])) {
                 foreach ($modz[$id] as $k => $v) {
                     if (is_array($v)) {
                         $mods[] = $v;
                     } else {
                         if ($str = @Util::$itemMods[$k]) {
                             $mods[$str] = $v;
                         }
                     }
                 }
             }
             $buff .= 'g_spells.add(' . $id . ", {id:" . $id . ", name:'" . Util::jsEscape(mb_substr($data['name'], 1)) . "', icon:'" . $data['icon'] . "', modifier:" . Util::toJSON($mods) . "});\n";
         }
         $buff .= "\n";
     }
     /* depending on progress-achievements
            // required by progress in JScript move to handleLoad()?
            Util::$pageTemplate->extendGlobalIds(TYPE_NPC, [29120, 31134, 29306, 29311, 23980, 27656, 26861, 26723, 28923, 15991]);
        */
     // load available titles
     Util::loadStaticFile('p-titles-' . $char->getField('gender'), $buff, true);
     // load available achievements
     if (!Util::loadStaticFile('p-achievements', $buff, true)) {
         $buff .= "\n\ng_achievement_catorder = [];";
         $buff .= "\n\ng_achievement_points = [0];";
     }
     // excludes; structure UNK type => [maskBit => [typeIds]] ?
     /*
         g_user.excludes = [type:[typeIds]]
         g_user.includes = [type:[typeIds]]
         g_user.excludegroups = groupMask        // requires g_user.settings != null
     
         maskBit are matched against fieldId from excludeGroups
         id: 1, label: LANG.dialog_notavail
         id: 2, label: LANG.dialog_tcg
         id: 4, label: LANG.dialog_collector
         id: 8, label: LANG.dialog_promo
         id: 16, label: LANG.dialog_nonus
         id: 96, label: LANG.dialog_faction
         id: 896, label: LANG.dialog_profession
         id: 1024, label: LANG.dialog_noexalted
     */
     // $buff .= "\n\ng_excludes = {};";
     // add profile to buffer
     $buff .= "\n\n\$WowheadProfiler.registerProfile(" . Util::toJSON($char->getEntry(2)) . ");";
     // can't use JSON_NUMERIC_CHECK or the talent-string becomes a float
     return $buff . "\n";
 }