mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
* Factions: set titles for ListPage
* GameObjects: initial implementation (some filter missing; positions not yet availabe; some custom data to be set; required table will be added later) * MiscTools: fixed random page; 'implemented' missing Screenshots; fixed access to template file * Search: implemented check for CUSTOM_EXCLUDE_FOR_LISTVIEW if user is not in U_GROUP_STAFF; searches should now be cachable * NPCs: three more tabs on detailPage * some work against Quests * fighting the template-system :<
This commit is contained in:
450
pages/object.php
450
pages/object.php
@@ -6,7 +6,8 @@ if (!defined('AOWOW_REVISION'))
|
||||
|
||||
require 'includes/community.class.php';
|
||||
|
||||
$_id = intVal($pageParam);
|
||||
$_id = intVal($pageParam);
|
||||
$_path = [0, 5];
|
||||
|
||||
$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_OBJECT, $_id, -1, User::$localeId]);
|
||||
$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_OBJECT, $_id, -1, User::$localeId]);
|
||||
@@ -20,7 +21,7 @@ if (isset($_GET['power']))
|
||||
|
||||
if (!$smarty->loadCache($cacheKeyTooltip, $x))
|
||||
{
|
||||
$object = new GameObjectList(array(['entry', $_id]));
|
||||
$object = new GameObjectList(array(['id', $_id]));
|
||||
if ($object->error)
|
||||
die('$WowheadPower.registerObject('.$_id.', '.User::$localeId.', {});');
|
||||
|
||||
@@ -41,34 +42,169 @@ if (isset($_GET['power']))
|
||||
// regular page
|
||||
if (!$smarty->loadCache($cacheKeyPage, $pageData))
|
||||
{
|
||||
$object = new GameObjectList(array(['entry', $_id]));
|
||||
$object = new GameObjectList(array(['id', $_id]));
|
||||
if ($object->error)
|
||||
$smarty->notFound(Lang::$game['gameObject'], $_id);
|
||||
|
||||
$_path[] = $object->getField('typeCat');
|
||||
|
||||
|
||||
/* NOTE
|
||||
|
||||
much like items GOs should have difficulty versions of itself, that are spawned for bosses, but this data is mostly contained in scripts
|
||||
also certain chests/caches/ect should be linked to their boss mob
|
||||
|
||||
all of this has to be done manually
|
||||
*/
|
||||
|
||||
/***********/
|
||||
/* Infobox */
|
||||
/***********/
|
||||
|
||||
$infobox = [];
|
||||
|
||||
// Reaction
|
||||
$_ = function ($r)
|
||||
{
|
||||
if ($r == 1) return 2;
|
||||
if ($r == -1) return 10;
|
||||
return;
|
||||
};
|
||||
$infobox[] = Lang::$npc['react'].Lang::$colon.'[color=q'.$_($object->getField('A')).']A[/color] [color=q'.$_($object->getField('H')).']H[/color]';
|
||||
|
||||
// reqSkill
|
||||
switch ($object->getField('typeCat'))
|
||||
{
|
||||
case -3: // Herbalism
|
||||
$infobox[] = sprintf(Lang::$game['requires'], Lang::$spell['lockType'][2].' ('.$object->getField('reqSkill').')');
|
||||
break;
|
||||
case -4: // Mining
|
||||
$infobox[] = sprintf(Lang::$game['requires'], Lang::$spell['lockType'][3].' ('.$object->getField('reqSkill').')');
|
||||
break;
|
||||
case -5: // Lockpicking
|
||||
$infobox[] = sprintf(Lang::$game['requires'], Lang::$spell['lockType'][1].' ('.$object->getField('reqSkill').')');
|
||||
break;
|
||||
default: // requires key .. maybe
|
||||
{
|
||||
$locks = Lang::getLocks($object->getField('lockId'));
|
||||
$l = '';
|
||||
foreach ($locks as $idx => $_)
|
||||
{
|
||||
if ($idx < 0)
|
||||
continue;
|
||||
|
||||
Util::$pageTemplate->extendGlobalIds(TYPE_ITEM, $idx);
|
||||
$l = Lang::$gameObject['key'].Lang::$colon.'[item='.$idx.']';
|
||||
}
|
||||
|
||||
// if no propper item is found use a skill
|
||||
if ($locks)
|
||||
$infobox[] = $l ? $l : array_pop($locks);
|
||||
}
|
||||
}
|
||||
|
||||
// linked trap
|
||||
if ($_ = $object->getField('linkedTrap'))
|
||||
{
|
||||
Util::$pageTemplate->extendGlobalIds(TYPE_OBJECT, $_);
|
||||
$infobox[] = Lang::$gameObject['trap'].Lang::$colon.'[object='.$_.']';
|
||||
}
|
||||
|
||||
// trap for
|
||||
$trigger = new GameObjectList(array(['linkedTrap', $_id]));
|
||||
if (!$trigger->error)
|
||||
{
|
||||
$trigger->addGlobalsToJScript(Util::$pageTemplate);
|
||||
$infobox[] = Lang::$gameObject['triggeredBy'].Lang::$colon.'[object='.$trigger->id.']';
|
||||
}
|
||||
|
||||
// SpellFocus
|
||||
if ($_ = $object->getField('spellFocusId'))
|
||||
$infobox[] = '[tooltip name=focus]'.Lang::$gameObject['focusDesc'].'[/tooltip][span class=tip tooltip=focus]'.Lang::$gameObject['focus'].Lang::$colon.Util::localizedString(DB::Aowow()->selectRow('SELECT * FROM ?_spellFocusObject WHERE id = ?d', $_), 'name').'[/span]';
|
||||
|
||||
// lootinfo: [min, max, restock]
|
||||
if (($_ = $object->getField('lootStack')) && $_[0])
|
||||
{
|
||||
$buff = Lang::$item['charges'].Lang::$colon.$_[0];
|
||||
if ($_[0] < $_[1])
|
||||
$buff .= Lang::$game['valueDelim'].$_[1];
|
||||
|
||||
// since Veins don't have charges anymore, the timer is questionable
|
||||
$infobox[] = $_[2] > 1 ? '[tooltip name=restock][Recharges every '.Util::formatTime($_[2] * 1000).'][/tooltip][span class=tip tooltip=restock]'.$buff.'[/span]' : $buff;
|
||||
}
|
||||
|
||||
// meeting stone [minLevel, maxLevel, zone]
|
||||
if ($object->getField('type') == OBJECT_MEETINGSTONE)
|
||||
{
|
||||
if ($_ = $object->getField('mStone'))
|
||||
{
|
||||
Util::$pageTemplate->extendGlobalIds(TYPE_ZONE, $_[2]);
|
||||
$m = Lang::$game['meetingStone'].Lang::$colon.'[zone='.$_[2].']';
|
||||
|
||||
$l = $_[0];
|
||||
if ($_[0] > 1 && $_[1] > $_[0])
|
||||
$l .= Lang::$game['valueDelim'].min($_[1], MAX_LEVEL);
|
||||
|
||||
$infobox[] = $l ? '[tooltip name=meetingstone]'.sprintf(Lang::$game['reqLevel'], $l).'[/tooltip][span class=tip tooltip=meetingstone]'.$m.'[/span]' : $m;
|
||||
}
|
||||
}
|
||||
|
||||
// capture area [minPlayer, maxPlayer, minTime, maxTime, radius]
|
||||
if ($object->getField('type') == OBJECT_CAPTURE_POINT)
|
||||
{
|
||||
if ($_ = $object->getField('capture'))
|
||||
{
|
||||
$buff = Lang::$gameObject['capturePoint'];
|
||||
|
||||
if ($_[2] > 1 || $_[0])
|
||||
$buff .= Lang::$colon.'[ul]';
|
||||
|
||||
if ($_[2] > 1)
|
||||
$buff .= '[li]'.Lang::$game['duration'].Lang::$colon.($_[3] > $_[2] ? Util::FormatTime($_[3] * 1000, true).' - ' : null).Util::FormatTime($_[2] * 1000, true).'[/li]';
|
||||
|
||||
if ($_[1])
|
||||
$buff .= '[li]'.Lang::$main['players'].Lang::$colon.$_[0].($_[1] > $_[0] ? ' - '.$_[1] : null).'[/li]';
|
||||
|
||||
if ($_[4])
|
||||
$buff .= '[li]'.sprintf(Lang::$spell['range'], $_[4]).'[/li]';
|
||||
|
||||
if ($_[2] > 1 || $_[0])
|
||||
$buff .= '[/ul]';
|
||||
}
|
||||
|
||||
$infobox[] = $buff;
|
||||
}
|
||||
|
||||
// AI
|
||||
if (User::isInGroup(U_GROUP_STAFF))
|
||||
{
|
||||
if ($_ = $object->getField('ScriptName'))
|
||||
$infobox[] = 'Script'.Lang::$colon.$_;
|
||||
else if ($_ = $object->getField('AIName'))
|
||||
$infobox[] = 'AI'.Lang::$colon.$_;
|
||||
}
|
||||
|
||||
|
||||
/****************/
|
||||
/* Main Content */
|
||||
/****************/
|
||||
|
||||
// pageText
|
||||
$pageText = [];
|
||||
if ($next = $object->getField('pageTextId'))
|
||||
{
|
||||
while ($next)
|
||||
{
|
||||
$row = DB::Aowow()->selectRow('SELECT *, text as Text_loc0 FROM page_text pt LEFT JOIN locales_page_text lpt ON pt.entry = lpt.entry WHERE pt.entry = ?d', $next);
|
||||
$next = $row['next_page'];
|
||||
$pageText[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
|
||||
}
|
||||
}
|
||||
|
||||
// positions
|
||||
$positions = [];
|
||||
/*
|
||||
ListView for fishing holes
|
||||
|
||||
id:'fished-in',
|
||||
hiddenCols:['instancetype', 'level', 'territory', 'category'],
|
||||
extraCols:[{if $percent}Listview.extraCols.percent{/if}],
|
||||
sort:['-percent', 'name'],
|
||||
|
||||
*/
|
||||
|
||||
// NYI -> die()
|
||||
$smarty->error();
|
||||
|
||||
|
||||
|
||||
// path(0, 5, $object['type']),
|
||||
|
||||
// $object['starts'] = array();
|
||||
// $object['ends'] = array();
|
||||
// array(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT),
|
||||
// $object['criteria_of'] = array();
|
||||
// object contains [..]
|
||||
|
||||
$object['position'] = position($object['entry'], 'gameobject');
|
||||
$positions = position($object['entry'], 'gameobject');
|
||||
// Исправить type, чтобы подсвечивались event-овые объекты
|
||||
if ($object['position'])
|
||||
foreach ($object['position'] as $z => $zone)
|
||||
@@ -79,33 +215,255 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
|
||||
$object['position'][$z]['points'][$p]['type'] = 4;
|
||||
$object['position'][$z]['points'][$p]['events'] = implode(", ", $names);
|
||||
}
|
||||
*/
|
||||
|
||||
// menuId 5: Object g_initPath()
|
||||
// tabId 0: Database g_initHeader()
|
||||
$pageData = array(
|
||||
'page' => array(
|
||||
'title' => $object->getField('name', true).' - '.Util::ucFirst(Lang::$game['gameObject']),
|
||||
'path' => json_encode($_path, JSON_NUMERIC_CHECK),
|
||||
'name' => $object->getField('name', true),
|
||||
'tab' => 0,
|
||||
'type' => TYPE_OBJECT,
|
||||
'typeId' => $_id,
|
||||
'infobox' => $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null,
|
||||
'pageText' => $pageText,
|
||||
'positions' => $positions,
|
||||
'redButtons' => array(
|
||||
BUTTON_WOWHEAD => true,
|
||||
BUTTON_LINKS => true,
|
||||
BUTTON_VIEW3D => ['displayId' => $object->getField('displayId'), 'type' => TYPE_OBJECT, 'typeId' => $_id]
|
||||
),
|
||||
'reqCSS' => array(
|
||||
$pageText ? ['path' => 'template/css/Book.css'] : null,
|
||||
// ['path' => 'template/css/Mapper.css'],
|
||||
// ['path' => 'template/css/Mapper_ie6.css', 'ieCond' => 'lte IE 6']
|
||||
),
|
||||
'reqJS' => array(
|
||||
$pageText ? 'template/js/Book.js' : null,
|
||||
// 'template/js/Mapper.js',
|
||||
'template/js/swfobject.js'
|
||||
)
|
||||
),
|
||||
'relTabs' => []
|
||||
);
|
||||
|
||||
|
||||
/**************/
|
||||
/* Extra Tabs */
|
||||
/**************/
|
||||
|
||||
// tab: summoned by
|
||||
$conditions = array(
|
||||
'OR',
|
||||
['AND', ['effect1Id', [50, 76, 104, 105, 106, 107]], ['effect1MiscValue', $_id]],
|
||||
['AND', ['effect2Id', [50, 76, 104, 105, 106, 107]], ['effect2MiscValue', $_id]],
|
||||
['AND', ['effect3Id', [50, 76, 104, 105, 106, 107]], ['effect3MiscValue', $_id]]
|
||||
);
|
||||
|
||||
$summons = new SpellList($conditions);
|
||||
if (!$summons->error)
|
||||
{
|
||||
$summons->addGlobalsToJScript($smarty, GLOBALINFO_SELF | GLOBALINFO_RELATED);
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'spell',
|
||||
'data' => $summons->getListviewData(),
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'id' => 'summoned-by',
|
||||
'name' => '$LANG.tab_summonedby'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// tab: related spells
|
||||
if ($_ = $object->getField('spells'))
|
||||
{
|
||||
$relSpells = new SpellList(array(['id', $_]));
|
||||
if (!$relSpells->error)
|
||||
{
|
||||
$relSpells->addGlobalsToJScript($smarty, GLOBALINFO_SELF | GLOBALINFO_RELATED);
|
||||
$data = $relSpells->getListviewData();
|
||||
|
||||
foreach ($data as $relId => $d)
|
||||
$data[$relId]['trigger'] = array_search($relId, $_);
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'spell',
|
||||
'data' => $data,
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'id' => 'spells',
|
||||
'name' => '$LANG.tab_spells',
|
||||
'hiddenCols' => "$['skill']",
|
||||
'extraCols' => "$[Listview.funcBox.createSimpleCol('trigger', 'Condition', '10%', 'trigger')]"
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// tab: criteria of
|
||||
$acvs = new AchievementList(array(['ac.type', [ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT]], ['ac.value1', $_id]));
|
||||
if (!$acvs->error)
|
||||
{
|
||||
$acvs->addGlobalsToJScript($smarty, GLOBALINFO_SELF | GLOBALINFO_RELATED);
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'achievement',
|
||||
'data' => $acvs->getListviewData(),
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'id' => 'criteria-of',
|
||||
'name' => '$LANG.tab_criteriaof'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// tab: starts
|
||||
$started = new QuestList(array(['goStart.id', $_id]));
|
||||
if (!$started->error)
|
||||
{
|
||||
$started->addGlobalsToJScript(Util::$pageTemplate);
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'quest',
|
||||
'data' => $started->getListviewData(),
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'name' => '$LANG.tab_starts',
|
||||
'id' => 'starts'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// tab: ends
|
||||
$ends = new QuestList(array(['goEnd.id', $_id]));
|
||||
if (!$ends->error)
|
||||
{
|
||||
$ends->addGlobalsToJScript(Util::$pageTemplate);
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'quest',
|
||||
'data' => $ends->getListviewData(),
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'name' => '$LANG.tab_ends',
|
||||
'id' => 'ends'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// tab: related quests
|
||||
if ($_ = $object->getField('reqQuest'))
|
||||
{
|
||||
$relQuest = new QuestList(array(['id', $_]));
|
||||
if (!$relQuest->error)
|
||||
{
|
||||
$relQuest->addGlobalsToJScript(Util::$pageTemplate);
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'quest',
|
||||
'data' => $relQuest->getListviewData(),
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'name' => '$LANG.tab_quests',
|
||||
'id' => 'quests'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// tab: contains
|
||||
$reqQuest = [];
|
||||
if ($_ = $object->getField('lootId'))
|
||||
{
|
||||
if ($itemLoot = Util::handleLoot(LOOT_GAMEOBJECT, $_, User::isInGroup(U_GROUP_STAFF), $extraCols))
|
||||
{
|
||||
$hiddenCols = ['source', 'side', 'slot', 'reqlevel'];
|
||||
foreach ($itemLoot as $l => $lv)
|
||||
{
|
||||
if (!empty($hiddenCols))
|
||||
foreach ($hiddenCols as $k => $str)
|
||||
if (!empty($lv[$str]))
|
||||
unset($hiddenCols[$k]);
|
||||
|
||||
if (!$lv['quest'])
|
||||
continue;
|
||||
|
||||
$extraCols[] = 'Listview.extraCols.condition';
|
||||
|
||||
$reqQuest[$lv['id']] = 0;
|
||||
|
||||
$itemLoot[$l]['condition'] = ['type' => TYPE_QUEST, 'typeId' => &$reqQuest[$lv['id']], 'status' => 1];
|
||||
}
|
||||
|
||||
$extraCols[] = 'Listview.extraCols.percent';
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'item',
|
||||
'data' => $itemLoot,
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'name' => '$LANG.tab_contains',
|
||||
'id' => 'contains',
|
||||
'extraCols' => "$[".implode(', ', array_unique($extraCols))."]",
|
||||
'hiddenCols' => $hiddenCols ? '$'.json_encode(array_values($hiddenCols)) : null
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($reqIds = array_keys($reqQuest)) // apply quest-conditions as back-reference
|
||||
{
|
||||
$conditions = array(
|
||||
'OR',
|
||||
['requiredSourceItemId1', $reqIds], ['requiredSourceItemId2', $reqIds],
|
||||
['requiredSourceItemId3', $reqIds], ['requiredSourceItemId4', $reqIds],
|
||||
['requiredItemId1', $reqIds], ['requiredItemId2', $reqIds], ['requiredItemId3', $reqIds],
|
||||
['requiredItemId4', $reqIds], ['requiredItemId5', $reqIds], ['requiredItemId6', $reqIds]
|
||||
);
|
||||
|
||||
$reqQuests = new QuestList($conditions);
|
||||
$reqQuests->addGlobalsToJscript($smarty);
|
||||
|
||||
foreach ($reqQuests->iterate() as $qId => $__)
|
||||
{
|
||||
if (empty($reqQuests->requires[$qId][TYPE_ITEM]))
|
||||
continue;
|
||||
|
||||
foreach ($reqIds as $rId)
|
||||
if (in_array($rId, $reqQuests->requires[$qId][TYPE_ITEM]))
|
||||
$reqQuest[$rId] = $reqQuests->id;
|
||||
}
|
||||
}
|
||||
|
||||
// tab: Same model as .. whats the fucking point..?
|
||||
$sameModel = new GameObjectList(array(['displayId', $object->getField('displayId')], ['id', $_id, '!']));
|
||||
if (!$sameModel->error)
|
||||
{
|
||||
$sameModel->addGlobalsToJScript(Util::$pageTemplate);
|
||||
|
||||
$pageData['relTabs'][] = array(
|
||||
'file' => 'object',
|
||||
'data' => $sameModel->getListviewData(),
|
||||
'params' => [
|
||||
'tabs' => '$tabsRelated',
|
||||
'name' => '$LANG.tab_samemodelas',
|
||||
'id' => 'same-model-as'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$smarty->saveCache($cacheKeyPage, $pageData);
|
||||
}
|
||||
|
||||
|
||||
// menuId 5: Object g_initPath()
|
||||
// tabId 0: Database g_initHeader()
|
||||
$smarty->updatePageVars(array(
|
||||
'title' => $pageData['title'].' - '.Util::ucFirst(Lang::$game['gameObject']),
|
||||
'path' => $pageData['path'],
|
||||
'tab' => 0,
|
||||
'type' => TYPE_OBJECT,
|
||||
'typeId' => $_id,
|
||||
'reqCSS' => array(
|
||||
$object['pageText'] ? ['path' => 'template/css/Book.css'] : null,
|
||||
['path' => 'template/css/Mapper.css'],
|
||||
['path' => 'template/css/Mapper_ie6.css', 'ieCond' => 'lte IE 6']
|
||||
),
|
||||
'reqJS' => array(
|
||||
$object['pageText'] ? 'template/js/Book.js' : null,
|
||||
'template/js/Mapper.js'
|
||||
)
|
||||
));
|
||||
$smarty->updatePageVars($pageData['page']);
|
||||
$smarty->assign('community', CommunityContent::getAll(TYPE_OBJECT, $_id)); // comments, screenshots, videos
|
||||
$smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$object, ['colon' => Lang::$colon]));
|
||||
$smarty->assign('lvData', $pageData);
|
||||
$smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$item, Lang::$gameObject, ['colon' => Lang::$colon]));
|
||||
$smarty->assign('lvData', $pageData['relTabs']);
|
||||
|
||||
// load the page
|
||||
$smarty->display('object.tpl');
|
||||
|
||||
Reference in New Issue
Block a user