diff --git a/config/config.php.in b/config/config.php.in index d7cbf4a8..a9ba6dea 100644 --- a/config/config.php.in +++ b/config/config.php.in @@ -47,20 +47,21 @@ $AoWoWconf['characters'][0] = array( // $AoWoWconf['characters'][] = []; // -- Site Configuration -- -$AoWoWconf['page']['cacheTimer'] = 1 * WEEK; // Time to keep cache in seconds (Default: 1 week) -$AoWoWconf['page']['name'] = 'Aowow Database Viewer (ADV)'; // Title of the website -$AoWoWconf['page']['shortName'] = 'Aowow'; // used in Feeds -$AoWoWconf['ttl'] = 60; // time to live for RSS -$AoWowConf['sessionTimeout'] = 1 * HOUR; // non-permanent session times out in time() + X -$AoWoWconf['register'] = true; // Allow account creating -// $AoWoWconf['loginFailCount'] = 5; // how often invalid passwords are tollerated -// $AoWoWconf['loginFailTime'] = 15 * MINUTE; // how long an account is closed after exceeding above limit -// $AoWoWconf['contactEmail'] = "feedback@aowow.org"; // ah well... -$AoWoWconf['boardUrl'] = "http://www.wowhead.com/forums?board="; // a javascript thing.. -$AoWoWconf['sqlLimit'] = 300; // Limit of some SQL queries -$AoWoWconf['debug'] = true; // Disable cache, show smarty console panel, enable sql-errors -$AoWoWconf['map_grouping'] = 0; // Map object grouping factor. Meters = 10^param. 0:disabled; 1|2|3:enabled (1:recommended) -$AoWoWconf['battlegroup'] = 'Pure Pwnage'; // pretend, we belong to a battlegroup to satisfy profiler-related Jscripts; region can be determined from realmlist.timezone -$AoWoWconf['maintainance'] = false; // brb gnomes say hi +$AoWoWconf['ttl'] = 1 * MINUTE; // default: 60 - time to live for RSS +$AoWoWconf['cacheTimer'] = 1 * WEEK; // default: 60 * 60 * 7 - Time to keep cache in seconds (Default: 1 week) +$AoWowConf['sessionTimeout'] = 1 * HOUR; // default: 60 * 60 - non-permanent session times out in time() + X +// $AoWoWconf['loginFailTime'] = 15 * MINUTE; // default: 15 * 60 - how long an account is closed after exceeding above limit +// $AoWoWconf['loginFailCount'] = 5; // default: 5 - how often invalid passwords are tollerated +$AoWoWconf['defaultLimit'] = 300; // default: 300 - Limit of some SQL queries +$AoWoWconf['searchLimit'] = 500; // default: 500 - Limit of some SQL queries +$AoWoWconf['debug'] = true; // default: false - Disable cache, show smarty console panel, enable sql-errors +$AoWoWconf['map_grouping'] = 0; // default: 1 - Map object grouping factor. Meters = 10^param. 0:disabled; 1|2|3:enabled (1:recommended) +$AoWoWconf['register'] = true; // Allow account creating +$AoWoWconf['boardUrl'] = "http://www.wowhead.com/forums?board="; // a javascript thing.. +// $AoWoWconf['contactEmail'] = "feedback@aowow.org"; // ah well... +$AoWoWconf['name'] = 'Aowow Database Viewer (ADV)'; // Title of the website +$AoWoWconf['shortName'] = 'Aowow'; // used in Feeds +$AoWoWconf['battlegroup'] = 'Pure Pwnage'; // pretend, we belong to a battlegroup to satisfy profiler-related Jscripts; region can be determined from realmlist.timezone +$AoWoWconf['maintainance'] = false; // brb gnomes say hi ?> diff --git a/includes/defines.php b/includes/defines.php index 4a042f51..c24a21e0 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -50,7 +50,7 @@ define('AUTH_BANNED', 3); define('AUTH_IPBANNED', 4); // Cookie Names -define('COOKIE_AUTH', 'aw_a'); +define('COOKIE_AUTH', 'aw_a'); // Times define('MINUTE', 60); @@ -87,6 +87,15 @@ define('LOCALE_DE', 3); define('LOCALE_ES', 6); define('LOCALE_RU', 8); +// red buttons on the top of the page (ASC:: right -> left) +define('BUTTON_WOWHEAD', 0); +define('BUTTON_UPGRADE', 1); +define('BUTTON_COMPARE', 2); +define('BUTTON_VIEW3D', 3); +define('BUTTON_LINKS', 4); +define('BUTTON_FORUM', 5); +define('BUTTON_TALENT', 6); + // generic filter handler define('FILTER_CR_BOOLEAN', 1); define('FILTER_CR_FLAG', 2); diff --git a/includes/kernel.php b/includes/kernel.php index 1a846556..233b8e7d 100644 --- a/includes/kernel.php +++ b/includes/kernel.php @@ -12,7 +12,11 @@ require 'config/config.php'; $e = !!$AoWoWconf['debug'] ? (E_ALL & ~(E_DEPRECATED|E_USER_DEPRECATED|E_STRICT)) : 0; error_reporting($e); -define('STATIC_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1)); +define('STATIC_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1)); + +define('SQL_LIMIT_NONE', 0); +define('SQL_LIMIT_SEARCH', $AoWoWconf['searchLimit']); +define('SQL_LIMIT_DEFAULT', $AoWoWconf['defaultLimit']); require 'includes/libs/Smarty-2.6.26/libs/Smarty.class.php';// Libraray: http://www.smarty.net/ // require 'includes/libs/Smarty-3.1.14/libs/Smarty.class.php'; // Libraray: http://www.smarty.net/ diff --git a/includes/types/basetype.class.php b/includes/types/basetype.class.php index 07ea4a31..bb945829 100644 --- a/includes/types/basetype.class.php +++ b/includes/types/basetype.class.php @@ -50,11 +50,9 @@ abstract class BaseType */ public function __construct($conditions = [], $applyFilter = false) { - global $AoWoWconf; // yes i hate myself.. - $where = []; $linking = ' AND '; - $limit = $AoWoWconf['sqlLimit']; + $limit = SQL_LIMIT_DEFAULT; $className = get_class($this); if (!$this->queryBase || $conditions === null) diff --git a/includes/types/gameobject.class.php b/includes/types/gameobject.class.php index e82a8672..51ecfb7d 100644 --- a/includes/types/gameobject.class.php +++ b/includes/types/gameobject.class.php @@ -12,7 +12,7 @@ class GameObjectList extends BaseType protected $queryBase = 'SELECT *, go.entry AS ARRAY_KEY FROM gameobject_template go'; protected $queryOpts = array( - 'go' => [['lg']], + 'go' => [['lg', 'l']], 'lg' => ['j' => ['locales_gameobject lg ON go.entry = lg.entry', true]], 'l' => ['j' => ['?_lock l ON l.id = IF(go.type = 3, data0, null)', true], 's' => ', l.type1, l.properties1, l.reqSkill1, l.type2, l.properties2, l.reqSkill2'] ); diff --git a/includes/types/item.class.php b/includes/types/item.class.php index 6cbbd80d..48bf3b11 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -75,105 +75,147 @@ class ItemList extends BaseType return Util::localizedString($n, 'name'); } - // todo (high): there are cases, where the same items has different extendedCosts attached (through different vendors) - // needs a way to filter for a specific currency/token to accomodate currencyFor-Tabs - // needs a way to filter for a specific vendor to accomodate soldBy-Tabs - - public function getExtendedCost(&$reqRating = 0) + // todo (med): information will get lost if one vendor sells one item multiple times with different costs (e.g. for item 54637) + // wowhead seems to have had the same issues + public function getExtendedCost($filter = [], &$reqRating = 0) { - if (!empty($this->vendors)) - return $this->vendors; - - $ids = array_keys($this->templates); - $itemz = DB::Aowow()->select(' - SELECT nv.item AS ARRAY_KEY1, nv.entry AS ARRAY_KEY2, 0 AS eventId, nv.maxcount, iec.* FROM npc_vendor nv LEFT JOIN ?_itemextendedcost iec ON nv.extendedCost = iec.id WHERE nv.item IN (?a) - UNION - SELECT genv.item AS ARRAY_KEY1, c.id AS ARRAY_KEY2, genv.eventEntry AS eventId, genv.maxcount, iec.* FROM game_event_npc_vendor genv JOIN creature c ON c.guid = genv.guid LEFT JOIN ?_itemextendedcost iec ON genv.extendedCost = iec.id WHERE genv.item IN (?a)', - $ids, - $ids - ); - - $cItems = []; - foreach ($itemz as &$vendors) + if (empty($this->vendors)) { - foreach ($vendors as $k => $costs) + $ids = array_keys($this->templates); + $itemz = DB::Aowow()->select(' + SELECT nv.item AS ARRAY_KEY1, nv.entry AS ARRAY_KEY2, 0 AS eventId, nv.maxcount, iec.* FROM npc_vendor nv LEFT JOIN ?_itemextendedcost iec ON nv.extendedCost = iec.id WHERE nv.item IN (?a) + UNION + SELECT genv.item AS ARRAY_KEY1, c.id AS ARRAY_KEY2, genv.eventEntry AS eventId, genv.maxcount, iec.* FROM game_event_npc_vendor genv JOIN creature c ON c.guid = genv.guid LEFT JOIN ?_itemextendedcost iec ON genv.extendedCost = iec.id WHERE genv.item IN (?a)', + $ids, + $ids + ); + + $cItems = []; + foreach ($itemz as &$vendors) { - $data = array( - 'stock' => $costs['maxcount'] ? $costs['maxcount'] : -1, - 'event' => $costs['eventId'] - ); + foreach ($vendors as $k => $costs) + { + $data = array( + 'stock' => $costs['maxcount'] ? $costs['maxcount'] : -1, + 'event' => $costs['eventId'], + 'reqRtg' => $costs['reqPersonalRating'] + ); + + if ($_ = $this->getField('buyPrice')) // somewhat nonsense.. is identical for all vendors (obviously) + $data[0] = $_; + + // hardcode arena(103) & honor(104) + if ($_ = @$costs['reqArenaPoints']) + { + $data[-103] = $_; + Util::$pageTemplate->extendGlobalIds(TYPE_CURRENCY, 103); + } + + if ($_ = @$costs['reqHonorPoints']) + { + $data[-104] = $_; + Util::$pageTemplate->extendGlobalIds(TYPE_CURRENCY, 104); + } + + for ($i = 1; $i < 6; $i++) + { + if (($_ = @$costs['reqItemId'.$i]) && $costs['itemCount'.$i] > 0) + { + $data[$_] = $costs['itemCount'.$i]; + $cItems[] = $_; + } + } + + $vendors[$k] = $data; + } + } + + // convert items to currency if possible + $moneyItems = new CurrencyList(array(['itemId', $cItems])); + $moneyItems->addGlobalsToJscript(Util::$pageTemplate); + + foreach ($itemz as $id => &$vendors) + { + foreach ($vendors as &$costs) + { + foreach ($costs as $k => $v) + { + if (in_array($k, $cItems)) + { + $found = false; + foreach ($moneyItems->iterate() as $__) + { + if ($moneyItems->getField('itemId') == $k) + { + unset($costs[$k]); + $costs[-$moneyItems->id] = $v; + $found = true; + break; + } + } + + if (!$found) + Util::$pageTemplate->extendGlobalIds(TYPE_ITEM, $k); + } + } + } + + $this->vendors[$id] = $vendors; + } + } + + $result = $this->vendors; + + // apply filter if given + $tok = @$filter[TYPE_ITEM]; + $cur = @$filter[TYPE_CURRENCY]; + $npc = @$filter[TYPE_NPC]; // bought at specific vendor + + $reqRating = -1; + foreach ($result as $itemId => $data) + { + foreach ($data as $npcId => $costs) + { + if ($npc && $npcId != $npc) + { + + unset($data[$npcId]); + continue; + } + + if ($tok || $cur) // bought with specific token or currency + { + $valid = false; + foreach ($costs as $k => $qty) + { + + + if ((!$tok || $k == $tok) && (!$cur || $k == -$cur)) + { + $valid = true; + break; + } + } + + if (!$valid) + unset($data[$npcId]); + } // reqRating ins't really a cost .. so pass it by ref instead of return + // use lowest total value // note: how to distinguish between brackets .. or team/pers-rating? - if ($_ = @$costs['reqPersonalRating']) - $reqRating = $_; - - if ($_ = $this->getField('buyPrice')) // somewhat nonsense.. is identical for all vendors (obviously) - $data[0] = $_; - - // hardcode arena(103) & honor(104) - if ($_ = @$costs['reqArenaPoints']) - { - $data[-103] = $_; - Util::$pageTemplate->extendGlobalIds(TYPE_CURRENCY, 103); - } - - if ($_ = @$costs['reqHonorPoints']) - { - $data[-104] = $_; - Util::$pageTemplate->extendGlobalIds(TYPE_CURRENCY, 104); - } - - for ($i = 1; $i < 6; $i++) - { - if (($_ = @$costs['reqItemId'.$i]) && $costs['itemCount'.$i] > 0) - { - $data[$_] = $costs['itemCount'.$i]; - $cItems[] = $_; - } - } - - $vendors[$k] = $data; - } - } - - // convert items to currency if possible - $moneyItems = new CurrencyList(array(['itemId', $cItems])); - $moneyItems->addGlobalsToJscript(Util::$pageTemplate); - - foreach ($itemz as $id => &$vendors) - { - foreach ($vendors as &$costs) - { - foreach ($costs as $k => $v) - { - if (in_array($k, $cItems)) - { - $found = false; - foreach ($moneyItems->iterate() as $__) - { - if ($moneyItems->getField('itemId') == $k) - { - unset($costs[$k]); - $costs[-$moneyItems->id] = $v; - $found = true; - break; - } - } - - if (!$found) - Util::$pageTemplate->extendGlobalIds(TYPE_ITEM, $k); - } - } + if (isset($data[$npcId]) && ($reqRating > $costs['reqRtg'] || $reqRating < 0 )) + $reqRating = $costs['reqRtg']; } - $this->vendors[$id] = $vendors; + if (empty($data)) + unset($result[$itemId]); } - return $this->vendors; + return $result; } - public function getListviewData($addInfoMask = 0x0) + public function getListviewData($addInfoMask = 0x0, $miscData = null) { /* * ITEMINFO_JSON (0x01): itemMods (including spells) and subitems parsed @@ -224,9 +266,12 @@ class ItemList extends BaseType if ($addInfoMask & ITEMINFO_VENDOR) { - // just use the first reseults - if ($cost = @reset($this->getExtendedCost()[$this->id])); + // just use the first results + // todo (med): dont use first result; search for the right one + $cost = @reset($this->getExtendedCost($miscData)[$this->id]); + if ($cost) { + $currency = []; $tokens = []; foreach ($cost as $k => $qty) @@ -678,7 +723,7 @@ class ItemList extends BaseType $x .= sprintf(Lang::$game['reqLevel'], $_reqLvl).'
'; // required arena team raing / perosnal rating / todo (low): sort out what kind of rating - if (@$this->getExtendedCost($reqRating)[$this->id] && $reqRating) + if (@$this->getExtendedCost([], $reqRating)[$this->id] && $reqRating) $x .= sprintf(Lang::$item['reqRating'], $reqRating); // item level diff --git a/includes/utilities.php b/includes/utilities.php index dbe753b4..6337846c 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -288,7 +288,7 @@ class SmartyAoWoW extends Smarty $cwd = str_replace("\\", "/", getcwd()); - $this->assign('appName', $config['page']['name']); + $this->assign('appName', $config['name']); $this->assign('AOWOW_REVISION', AOWOW_REVISION); $this->config = $config; $this->template_dir = $cwd.'/template/'; @@ -308,7 +308,8 @@ class SmartyAoWoW extends Smarty 'typeId' => null, // [int] entry to display 'path' => '[]' // [string] (js:array) path to preselect in the menu ); - $this->_tpl_vars['jsGlobals'] = []; + $this->_tpl_vars['jsGlobals'] = []; + $this->_tpl_vars['redButtons'] = []; } // using Smarty::assign would overwrite every pair and result in undefined indizes diff --git a/pages/achievement.php b/pages/achievement.php index 189b16e3..29caea5c 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -92,6 +92,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'path' => $tmpPath, 'infobox' => array_merge($infobox, Lang::getInfoBoxForFlags($acv->getField('cuFlags'))), 'relTabs' => [], + 'buttons' => array( + BUTTON_LINKS => ['color' => 'ffffff00', 'linkId' => Util::$typeStrings[TYPE_ACHIEVEMENT].':'.$_id.':"..UnitGUID("player")..":0:0:0:0:0:0:0:0'], + BUTTON_WOWHEAD => true + ), 'page' => array( 'name' => $acv->getField('name', true), 'description' => $acv->getField('description', true), @@ -407,6 +411,7 @@ $smarty->updatePageVars(array( 'type' => TYPE_ACHIEVEMENT, 'typeId' => $_id )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_ACHIEVEMENT, $_id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); diff --git a/pages/achievements.php b/pages/achievements.php index 56245248..f6098ee4 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -90,9 +90,9 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $pageData['params']['extraCols'] = '$fi_getExtraCols(fi_extraCols, 0, 0)'; // create note if search limit was exceeded - if ($acvList->getMatches() > $AoWoWconf['sqlLimit']) + if ($acvList->getMatches() > SQL_LIMIT_DEFAULT) { - $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), $AoWoWconf['sqlLimit']); + $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_achievementsfound', $acvList->getMatches(), SQL_LIMIT_DEFAULT); $pageData['params']['_truncated'] = 1; } diff --git a/pages/class.php b/pages/class.php index 6263b577..80a7508c 100644 --- a/pages/class.php +++ b/pages/class.php @@ -31,6 +31,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($cl->error) $smarty->notFound(Lang::$game['class']); + /***********/ + /* Infobox */ + /***********/ + $infobox = []; // hero class if ($cl->getField('hero')) @@ -64,45 +68,74 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $infobox[] = Lang::$game['specs'].Lang::$colon.'[ul][li]'.implode('[/li][li]', $specList).'[/li][/ul]'; + /****************/ + /* Main Content */ + /****************/ + $pageData = array ( - 'title' => $cl->getField('name', true).' - '.Util::ucFirst(Lang::$game['class']), - 'path' => $_path, - 'infobox' => '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]', - 'relTabs' => [], - 'page' => array( + 'title' => $cl->getField('name', true).' - '.Util::ucFirst(Lang::$game['class']), + 'path' => $_path, + 'infobox' => '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]', + 'relTabs' => [], + 'buttons' => array( + BUTTON_LINKS => ['color' => '', 'linkId' => ''], + BUTTON_WOWHEAD => true, + BUTTON_TALENT => ['href' => '?talent#'.Util::$tcEncoding[$tcClassId[$_id] * 3], 'pet' => false], + BUTTON_FORUM => false // doto (low): $GLOBALS['AoWoWconf']['boardUrl'] + X + ), + 'page' => array( 'name' => $cl->getField('name', true), - 'talentCalc' => Util::$tcEncoding[$tcClassId[$_id] * 3], 'icon' => 'class_'.strtolower($cl->getField('fileString')), 'expansion' => Util::$expansionString[$cl->getField('expansion')] ) ); -/* - note! - newer listviews support subTabs - i.e.: - Spells => Abilities, Talents, Glyphs, Proficiencies - Items => grouping by subclass -*/ - // Quests + /**************/ + /* Extra Tabs */ + /**************/ + + // Tab: Spells (grouped) + // '$LANG.tab_armorproficiencies', + // '$LANG.tab_weaponskills', + // '$LANG.tab_glyphs', + // '$LANG.tab_abilities', + // '$LANG.tab_talents', $conditions = array( - ['RequiredClasses', $_mask, '&'], - [['RequiredClasses', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'] + ['s.typeCat', [-13, -11, -2, 7]], + [['s.cuFlags', (SPELL_CU_TRIGGERED | SPELL_CU_EXCLUDE_CATEGORY_SEARCH), '&'], 0], + [ + 'OR', + ['s.reqClassMask', $_mask, '&'], // Glyphs, Proficiencies + ['s.skillLine1', $classSkills[$_id]], // Abilities / Talents + ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $classSkills[$_id]]] + ], + [ // last rank or unranked + 'OR', + ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], + ['s.rankId', 0] + ] ); - $quests = new QuestList($conditions); - $quests->addGlobalsToJscript($smarty); + $genSpells = new SpellList($conditions); + $genSpells->addGlobalsToJscript($smarty, GLOBALINFO_SELF); $pageData['relTabs'][] = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), + 'file' => 'spell', + 'data' => $genSpells->getListviewData(), 'params' => array( - 'sort' => "$['reqlevel', 'name']", - 'tabs' => '$tabsRelated' + 'id' => 'spells', + 'name' => '$LANG.tab_spells', + 'visibleCols' => "$['level', 'schools', 'type', 'classes']", + 'hiddenCols' => "$['reagents', 'skill']", + 'sort' => "$['-level', 'type', 'name']", + 'tabs' => '$tabsRelated', + 'computeDataFunc' => '$Listview.funcBox.initSpellFilter', + 'onAfterCreate' => '$Listview.funcBox.addSpellIndicator' ) ); - // Items + // Tab: Items (grouped) $conditions = array( ['requiredClass', 0, '>'], ['requiredClass', $_mask, '&'], @@ -133,9 +166,25 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); + // Tab: Quests + $conditions = array( + ['RequiredClasses', $_mask, '&'], + [['RequiredClasses', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'] + ); + $quests = new QuestList($conditions); + $quests->addGlobalsToJscript($smarty); - // Itemsets + $pageData['relTabs'][] = array( + 'file' => 'quest', + 'data' => $quests->getListviewData(), + 'params' => array( + 'sort' => "$['reqlevel', 'name']", + 'tabs' => '$tabsRelated' + ) + ); + + // Tab: Itemsets $sets = new ItemsetList(array(['classMask', $_mask, '&'])); $sets->addGlobalsToJscript($smarty, GLOBALINFO_SELF); @@ -150,8 +199,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - - // Trainer + // Tab: Trainer $conditions = array( ['npcflag', 0x30, '&'], // is trainer ['trainer_type', 0], // trains class spells @@ -170,142 +218,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - - // Armor Proficiencies - $conditions = array( - ['s.typeCat', -11], - ['s.skillLine1', SpellList::$skillLines[8]], - ['s.reqClassMask', $_mask, '&'] - ); - - $armorProf = new SpellList($conditions); - $armorProf->addGlobalsToJscript($smarty, GLOBALINFO_SELF); - - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $armorProf->getListviewData(), - 'params' => array( - 'id' => 'armor-proficiencies', - 'name' => '$LANG.tab_armorproficiencies', - 'visibleCols' => "$['type', 'classes']", - 'hiddenCols' => "$['reagents', 'skill']", - 'tabs' => '$tabsRelated' - ) - ); - - - // Weapon Proficiencies - $conditions = array( - ['s.typeCat', -11], - ['OR', ['s.skillLine1', SpellList::$skillLines[6]], ['s.skillLine1', -3]], - ['s.reqClassMask', $_mask, '&'] - ); - - $weaponProf = new SpellList($conditions); - $weaponProf->addGlobalsToJscript($smarty, GLOBALINFO_SELF); - - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $weaponProf->getListviewData(), - 'params' => array( - 'id' => 'weapon-skills', - 'name' => '$LANG.tab_weaponskills', - 'visibleCols' => "$['type', 'classes']", - 'hiddenCols' => "$['reagents', 'skill']", - 'tabs' => '$tabsRelated' - ) - ); - - - // Glyphs - $conditions = array( - ['s.typeCat', -13], - ['s.reqClassMask', $_mask, '&'] - ); - - $glyphs = new SpellList($conditions); - $glyphs->addGlobalsToJscript($smarty, GLOBALINFO_SELF); - - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $glyphs->getListviewData(), - 'params' => array( - 'id' => 'glyphs', - 'name' => '$LANG.tab_glyphs', - 'visibleCols' => "$['type']", - 'hiddenCols' => "$['reagents']", - 'tabs' => '$tabsRelated' - ) - ); - - - // Abilities - $conditions = array( - ['s.typeCat', [7, -2]], - [['s.cuFlags', (SPELL_CU_TALENTSPELL | SPELL_CU_TALENT | SPELL_CU_TRIGGERED | SPELL_CU_EXCLUDE_CATEGORY_SEARCH), '&'], 0], - [ // select class by skillLine - 'OR', - ['s.skillLine1', $classSkills[$_id]], - ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $classSkills[$_id]]] - ], - [ // last rank or unranked - 'OR', - ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], - ['s.rankId', 0] - ] - ); - - $abilities = new SpellList($conditions); - $abilities->addGlobalsToJscript($smarty, GLOBALINFO_SELF); - - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $abilities->getListviewData(), - 'params' => array( - 'id' => 'abilities', - 'name' => '$LANG.tab_abilities', - 'note' => sprintf(Util::$filterResultString, '?spells=7.'.$_id), - 'visibleCols' => "$['level', 'schools']", - 'sort' => "$['skill', 'name']", - 'tabs' => '$tabsRelated' - ) - ); - - - // Talents - $conditions = array( - ['s.typeCat', -2], - ['cuFlags', (SPELL_CU_TALENT | SPELL_CU_TALENTSPELL), '&'], - [ // select class by skillLine - 'OR', - ['s.skillLine1', $classSkills[$_id]], - ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $classSkills[$_id]]] - ], - [ // last rank or unranked - 'OR', - ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], - ['s.rankId', 0] - ] - ); - - $talents = new SpellList($conditions); - $talents->addGlobalsToJscript($smarty, GLOBALINFO_SELF); - - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $talents->getListviewData(), - 'params' => array( - 'id' => "talents", - 'name' => '$LANG.tab_talents', - 'note' => sprintf(Util::$filterResultString, '?spells=-2.'.$_id), - 'visibleCols' => "$['level', 'schools', 'tier']", - 'sort' => "$['skill', 'tier']", - 'tabs' => '$tabsRelated' - ) - ); - - - // Races + // Tab: Races $races = new CharRaceList(array(['classMask', $_mask, '&'])); $pageData['relTabs'][] = array( @@ -328,11 +241,11 @@ $smarty->updatePageVars(array( 'tab' => 0, 'type' => TYPE_CLASS, 'typeId' => $_id, - // 'boardUrl' => '', //$GLOBALS['AoWoWconf']['boardUrl'] + X, 'reqJS' => array( 'template/js/swfobject.js' ) )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_CLASS, $_id)); // comments, screenshots, videos $smarty->assign('lang', Lang::$main); $smarty->assign('lvData', $pageData); diff --git a/pages/item.php b/pages/item.php index cbe06474..83e3400b 100644 --- a/pages/item.php +++ b/pages/item.php @@ -80,9 +80,6 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) $_class = $item->getField('class'); $_subClass = $item->getField('subClass'); $_bagFamily = $item->getField('bagFamily'); - $_extCost = []; - if ($_ = @$item->getExtendedCost($_reqRating)[$item->id]) - $_extCost = $_; /***********/ /* Infobox */ @@ -130,33 +127,49 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) if ($tName = DB::Aowow()->selectRow('SELECT * FROM ?_totemCategory WHERE id = ?d', $tId)) $quickInfo[] = Lang::$item['tool'].Lang::$colon.'[url=?items&filter=cr=91;crs='.$tId.';crv=0]'.Util::localizedString($tName, 'name').'[/url]'; - $each = $item->getField('stackable') > 1 ? '[color=q0] ('.Lang::$item['each'].')[/color]' : null; - $tokens = $currency = []; - if ($_ = reset($_extCost)) + $each = $item->getField('stackable') > 1 ? '[color=q0] ('.Lang::$item['each'].')[/color]' : null; + + if ($_ = @$item->getExtendedCost([], $_reqRating)[$item->id]) { - foreach ($_ as $c => $qty) + $handled = []; + $costList = []; + foreach ($_ as $npcId => $data) { - if (is_string($c)) + if (in_array(md5(serialize($data)), $handled)) // display every cost-combination only once continue; - if ($c < 0) // currency items (and honor or arena) - $currency[] = -$c.','.$qty; - else if ($c > 0) // plain items (item1,count1,item2,count2,...) - $tokens[$c] = $c.','.$qty; + $handled[] = md5(serialize($data)); + + $tokens = []; + $currency = []; + foreach ($data as $c => $qty) + { + if (is_string($c)) + continue; + + if ($c < 0) // currency items (and honor or arena) + $currency[] = -$c.','.$qty; + else if ($c > 0) // plain items (item1,count1,item2,count2,...) + $tokens[$c] = $c.','.$qty; + } + + $cost = isset($_[0]) ? '[money='.$_[0] : '[money'; + + if ($tokens) + $cost .= ' items='.implode(',', $tokens); + + if ($currency) + $cost .= ' currency='.implode(',', $currency); + + $cost .= ']'; + + $costList[] = $cost; } - $cost = isset($_[0]) ? '[money='.$_[0] : '[money'; - - if ($tokens) - $cost .= ' items='.implode(',', $tokens); - - if ($currency) - $cost .= ' currency='.implode(',', $currency); - - $cost .= ']'; - - if ($cost) - $quickInfo[] = Lang::$item['cost'].Lang::$colon.$cost.$each; + if (count($costList) == 1) + $quickInfo[] = Lang::$item['cost'].Lang::$colon.$costList[0].$each; + else if (count($costList) > 1) + $quickInfo[] = Lang::$item['cost'].$each.Lang::$colon.'[ul][li]'.implode('[/li][li]', $costList).'[/li][/ul]'; if ($_reqRating) $quickInfo[] = sprintf(Lang::$item['reqRating'], $_reqRating); @@ -228,6 +241,9 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) /* Main Content */ /****************/ + $cmpUpg = in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) || $item->getField('gemEnchantmentId'); + $view3D = in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) && $item->getField('displayId'); + $pageData = array( 'infobox' => $quickInfo ? '[ul][li]'.implode('[/li][li]', $quickInfo).'[/li][/ul]' : null, 'relTabs' => [], @@ -235,16 +251,18 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) 'path' => [0, 0], 'title' => [$item->getField('name', true), Util::ucFirst(Lang::$game['item'])], 'pageText' => [], - 'buttons' => in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) || $item->getField('gemEnchantmentId'), + 'buttons' => array( + BUTTON_WOWHEAD => true, + BUTTON_LINKS => ['color' => 'ff'.Util::$rarityColorStings[$item->getField('quality')], 'linkId' => 'item:'.$_id.':0:0:0:0:0:0:0:0'], + BUTTON_VIEW3D => $view3D ? ['displayId' => $item->getField('displayId'), 'slot' => $_slot, 'type' => TYPE_ITEM, 'typeId' => $_id] : false, + BUTTON_COMPARE => $cmpUpg, // bool required + BUTTON_UPGRADE => $cmpUpg ? ['class' => $_class, 'slot' => $_slot] : false + ), 'page' => array( - 'color' => Util::$rarityColorStings[$item->getField('quality')], 'quality' => $item->getField('quality'), 'icon' => $item->getField('iconString'), 'name' => $item->getField('name', true), - 'displayId' => in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) && $item->getField('displayId') ? $item->getField('displayId') : null, - 'slot' => $_slot, 'stack' => $item->getField('stackable'), - 'class' => $_class ) ); @@ -360,7 +378,7 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) foreach ($sources as $lootTpl => $lootData) { // cap fetched entries to the sql-limit to guarantee, that the highest chance items get selected first - $ids = array_slice(array_keys($lootData), 0, $AoWoWconf['sqlLimit']); + $ids = array_slice(array_keys($lootData), 0, SQL_LIMIT_DEFAULT); switch ($lootTpl) { @@ -759,6 +777,7 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) 'AND', ['class', $_class], ['subClass', $_subClass], + ['slot', $_slot], ['itemLevel', $item->getField('itemLevel') - 15, '>'], ['itemLevel', $item->getField('itemLevel') + 15, '<'], ['quality', $item->getField('quality')], @@ -789,10 +808,10 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) $starts = new QuestList(array(['qt.id', $qId])); if (!$starts->error) { - $starts->addGlobalsToJscript($stmarty); + $starts->addGlobalsToJscript($smarty); $pageData['relTabs'][] = array( - 'file' => 'item', + 'file' => 'quest', 'data' => $starts->getListviewData(), 'params' => [ 'tabs' => '$tabsRelated', @@ -869,7 +888,7 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) } // tab: sold by - if ($vendors = $_extCost) + if ($vendors = @$item->getExtendedCost([], $_reqRating)[$item->id]) { $soldBy = new CreatureList(array(['id', array_keys($vendors)])); if (!$soldBy->error) @@ -954,21 +973,24 @@ if (!$smarty->loadCache($cacheKeyPage, $item)) else $w = 'iec.reqItemId1 = '.$_id.' OR iec.reqItemId2 = '.$_id.' OR iec.reqItemId3 = '.$_id.' OR iec.reqItemId4 = '.$_id.' OR iec.reqItemId5 = '.$_id; - $baughtBy = DB::Aowow()->selectCol(' + $boughtBy = DB::Aowow()->selectCol(' SELECT item FROM npc_vendor nv JOIN ?_itemExtendedCost iec ON iec.id = nv.extendedCost WHERE '.$w.' UNION SELECT item FROM game_event_npc_vendor genv JOIN ?_itemExtendedCost iec ON iec.id = genv.extendedCost WHERE '.$w ); - if ($baughtBy) + if ($boughtBy) { - $baughtBy = new ItemList(array(['id', $baughtBy])); - if (!$baughtBy->error) + $boughtBy = new ItemList(array(['id', $boughtBy])); + if (!$boughtBy->error) { - $baughtBy->addGlobalsToJscript($smarty); + $boughtBy->addGlobalsToJscript($smarty); + + $iCur = new CurrencyList(array(['itemId', $_id])); + $filter = $iCur->error ? [TYPE_ITEM => $_id] : [TYPE_CURRENCY => $iCur->id]; $pageData['relTabs'][] = array( 'file' => 'item', - 'data' => $baughtBy->getListviewData(ITEMINFO_VENDOR), + 'data' => $boughtBy->getListviewData(ITEMINFO_VENDOR, $filter), 'params' => [ 'tabs' => '$tabsRelated', 'name' => '$LANG.tab_currencyfor', @@ -1051,6 +1073,7 @@ $smarty->updatePageVars(array( $pageData['pageText'] ? ['path' => 'template/css/Book.css'] : null, ) )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_ITEM, $_id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$item, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); diff --git a/pages/items.php b/pages/items.php index 86b184e8..fd43c1df 100644 --- a/pages/items.php +++ b/pages/items.php @@ -321,9 +321,9 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) } // create note if search limit was exceeded; overwriting 'note' is intentional - if ($items->getMatches() > $AoWoWconf['sqlLimit'] && empty($filter['upg'])) + if ($items->getMatches() > SQL_LIMIT_DEFAULT && empty($filter['upg'])) { - $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), $AoWoWconf['sqlLimit']); + $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsfound', $items->getMatches(), SQL_LIMIT_DEFAULT); $pageData['params']['_truncated'] = 1; } diff --git a/pages/itemset.php b/pages/itemset.php index d2134919..60914b70 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -26,6 +26,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $_na = $iSet->getField('name', true); $_cnt = count($iSet->getField('pieces')); + /***********/ + /* Infobox */ + /***********/ + $infobox = []; // unavailable (todo (low): set data) if ($iSet->getField('cuFlags') & CUSTOM_UNAVAILABLE) @@ -71,6 +75,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($_ta) $infobox[] = Lang::$itemset['_tag'].Lang::$colon.'[url=?itemsets&filter=ta='.$_ta.']'.Lang::$itemset['notes'][$_ta].'[/url]'; + /****************/ + /* Main Content */ + /****************/ + // pieces + Summary $pieces = []; $eqList = []; @@ -173,7 +181,12 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'relTabs' => [], 'pieces' => $pieces, 'spells' => $spells, - 'view3D' => json_encode($eqList, JSON_NUMERIC_CHECK), + 'buttons' => array( + BUTTON_WOWHEAD => $_id > 0, // bool only + BUTTON_LINKS => ['color' => '', 'linkId' => ''], + BUTTON_VIEW3D => ['type' => TYPE_ITEMSET, 'typeId' => $_id, 'equipList' => $eqList], + BUTTON_COMPARE => ['eqList' => implode(':', $compare), 'qty' => $_cnt] + ), 'compare' => array( 'qty' => $_cnt, 'items' => $compare, @@ -190,6 +203,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $iSet->addGlobalsToJscript($smarty); + /**************/ + /* Extra Tabs */ + /**************/ + // related sets (priority: 1: similar tag + class; 2: has event; 3: no tag + similar type, 4: similar type + profession) $rel = []; @@ -259,6 +276,7 @@ $smarty->updatePageVars(array( 'template/js/swfobject.js' ) )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_ITEMSET, $_id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main, Lang::$itemset, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); diff --git a/pages/itemsets.php b/pages/itemsets.php index 2f2f47b8..2fd3288f 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -32,9 +32,9 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $path[] = $filter['cl']; // create note if search limit was exceeded - if ($itemsets->getMatches() > $AoWoWconf['sqlLimit']) + if ($itemsets->getMatches() > SQL_LIMIT_DEFAULT) { - $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsetsfound', $itemsets->getMatches(), $AoWoWconf['sqlLimit']); + $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_itemsetsfound', $itemsets->getMatches(), SQL_LIMIT_DEFAULT); $pageData['params']['_truncated'] = 1; } diff --git a/pages/miscTools.php b/pages/miscTools.php index 2f125d0e..aea76704 100644 --- a/pages/miscTools.php +++ b/pages/miscTools.php @@ -116,9 +116,9 @@ if (strstr($pageCall, 'latest') || $pageCall == 'most-comments') $xml = "\n". "\n\t\n". - "\t\t".$AoWoWconf['page']['shortName'].' - '.Lang::$main['utilities'][$menu] . ($_title ? Lang::$colon . $_title : null)."\n". + "\t\t".$AoWoWconf['shortName'].' - '.Lang::$main['utilities'][$menu] . ($_title ? Lang::$colon . $_title : null)."\n". "\t\t".STATIC_URL.'?'.$pageCall . ($pageParam ? '='.$pageParam : null)."\n". - "\t\t".$AoWoWconf['page']['name']."\n". + "\t\t".$AoWoWconf['name']."\n". "\t\t".implode('-', str_split(User::$localeString, 2))."\n". "\t\t".$AoWoWconf['ttl']."\n". // Sat, 31 Aug 2013 15:33:16 -0500 diff --git a/pages/pet.php b/pages/pet.php index 02aa54e4..1f06b848 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -16,6 +16,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($pet->error) $smarty->notFound(Lang::$game['pet']); + /***********/ + /* Infobox */ + /***********/ + $infobox = []; // level range @@ -25,13 +29,21 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($pet->getField('exotic')) $infobox[] = '[url=?spell=53270]'.Lang::$pet['exotic'].'[/url]'; + /****************/ + /* Main Content */ + /****************/ + $pageData = array( 'title' => $pet->getField('name', true), 'path' => '[0, 8, '.$pet->getField('type').']', 'infobox' => '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]', 'relTabs' => [], + 'buttons' => array( + BUTTON_WOWHEAD => true, + BUTTON_LINKS => true, + BUTTON_TALENT => ['href' => '?petcalc#'.Util::$tcEncoding[(int)($_id / 10)] . Util::$tcEncoding[(2 * ($_id % 10) + ($pet->getField('exotic') ? 1 : 0))], 'pet' => true] + ), 'page' => array( - 'petCalc' => Util::$tcEncoding[(int)($_id / 10)] . Util::$tcEncoding[(2 * ($_id % 10) + ($pet->getField('exotic') ? 1 : 0))], 'name' => $pet->getField('name', true), 'id' => $_id, 'icon' => $pet->getField('iconString'), @@ -39,7 +51,11 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ), ); - // tameable & gallery + /**************/ + /* Extra Tabs */ + /**************/ + + // tab: tameable & gallery $condition = array( ['ct.type', 1], // Beast ['ct.type_flags', 0x1, '&'], // tameable @@ -73,7 +89,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - // diet + // tab: diet $list = []; $mask = $pet->getField('foodMask'); for ($i = 1; $i < 7; $i++) @@ -95,7 +111,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - // spells + // tab: spells $mask = 0x0; foreach (Util::$skillLineMask[-1] as $idx => $pair) { @@ -137,7 +153,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - // talents + // tab: talents $conditions = array( ['s.typeCat', -7], [ // last rank or unranked @@ -186,6 +202,7 @@ $smarty->updatePageVars(array( 'template/js/swfobject.js' ) )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_PET, $_id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main, Lang::$game)); $smarty->assign('lvData', $pageData); diff --git a/pages/race.php b/pages/race.php index f0bb4f50..a761c225 100644 --- a/pages/race.php +++ b/pages/race.php @@ -10,7 +10,7 @@ $_id = intVal($pageParam); $_mask = 1 << ($_id - 1); $_path = [0, 13, $_id]; -$mountVendors = array( // [starter, argent tournament] +$mountVendors = array( // race => [starter, argent tournament] null, [384, 33307], [3362, 33553], @@ -34,7 +34,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $smarty->notFound(Lang::$game['race']); /***********/ - /* INFOBOX */ + /* Infobox */ /***********/ $infobox = []; // unfortunately is all of this custom data :/ @@ -64,11 +64,19 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $infobox[] = Lang::$class['startZone'].Lang::$colon.'[zone='.$_.']'; } + /****************/ + /* Main Content */ + /****************/ + $pageData = array ( 'title' => $race->getField('name', true).' - '.Util::ucFirst(Lang::$game['race']), 'path' => $_path, 'infobox' => '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]', 'relTabs' => [], + 'buttons' => array( + BUTTON_WOWHEAD => true, + BUTTON_LINKS => true + ), 'page' => array( 'name' => $race->getField('name', true), 'icon' => strtolower($race->getField('fileString')), @@ -76,9 +84,9 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - /********/ - /* TABS */ - /********/ + /**************/ + /* Extra Tabs */ + /**************/ // Classes $classes = new CharClassList(array(['racemask', $_mask, '&'])); @@ -92,7 +100,6 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - // Tongues $conditions = array( ['typeCat', -11], // proficiencies @@ -133,7 +140,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) ) ); - // Quests + // Quests $conditions = array( ['RequiredRaces', $_mask, '&'], [['RequiredRaces', RACE_MASK_ALL, '&'], RACE_MASK_ALL, '!'], @@ -189,6 +196,7 @@ $smarty->updatePageVars(array( 'type' => TYPE_RACE, 'typeId' => $_id )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_RACE, $_id)); // comments, screenshots, videos $smarty->assign('lang', Lang::$main); $smarty->assign('lvData', $pageData); diff --git a/pages/skill.php b/pages/skill.php index 4281f74a..e4344060 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -18,10 +18,18 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $_cat = $skill->getField('typeCat'); + /****************/ + /* Main Content */ + /****************/ + $pageData = array( 'title' => $skill->getField('name', true), 'path' => [0, 14], 'relTabs' => [], + 'buttons' => array( + BUTTON_WOWHEAD => true, + BUTTON_LINKS => true + ), 'page' => array( 'name' => $skill->getField('name', true), 'icon' => $skill->getField('iconString'), @@ -31,6 +39,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) $pageData['path'][] = (in_array($_cat, [9, 11]) || $_id == 762) ? $_id : $_cat; + /**************/ + /* Extra Tabs */ + /**************/ + if (in_array($_cat, [-5, 9, 11])) { $condition = array( @@ -346,6 +358,7 @@ $smarty->updatePageVars(array( 'type' => TYPE_SKILL, 'typeId' => $_id )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_SKILL, $_id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main)); $smarty->assign('lvData', $pageData); diff --git a/pages/spell.php b/pages/spell.php index 86792481..3ae931bb 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -246,7 +246,11 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) 'path' => json_encode($path, JSON_NUMERIC_CHECK), 'infobox' => $infobox, 'relTabs' => [], - 'view3D' => 0, + 'buttons' => array( + BUTTON_LINKS => ['color' => 'ff71d5ff', 'linkId' => Util::$typeStrings[TYPE_SPELL].':'.$_id], + BUTTON_VIEW3D => false, + BUTTON_WOWHEAD => true + ), 'page' => array( 'scaling' => '', 'powerCost' => $spell->createPowerCostForCurrent(), @@ -579,7 +583,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if (!$summon->error) { $_ = '('.$summon->getField('name', true).')'; - $pageData['view3D'] = $summon->getRandomModelId(); + $pageData['buttons'][BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $summon->getRandomModelId()]; } $foo['name'] .= Lang::$colon.$_; @@ -633,7 +637,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($n/*!$summon->error*/) { $_ = '('.$n/*$summon->getField('name', true)*/.')'; - //$pageData['view3D'] = $summon->getRandomModelId(); + //$pageData['buttons'][BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $summon->getRandomModelId()]; } $foo['name'] .= Lang::$colon.$_; @@ -751,7 +755,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) case 36: // Shapeshift if ($st = DB::Aowow()->selectRow('SELECT *, displayIdA as model1, displayIdH as model2 FROM ?_shapeshiftForms WHERE id = ?d', $effMV)) { - $pageData['view3D'] = $st['model2'] ? $st['model'.rand(1, 2)]: $st['model1']; + $pageData['buttons'][BUTTON_VIEW3D] = array( + 'type' => TYPE_NPC, + 'displayId' => $st['model2'] ? $st['model'.rand(1, 2)]: $st['model1'] + ); if ($st['creatureType'] > 0) $pageData['infobox'][] = '[li]'.Lang::$game['type'].Lang::$colon.Lang::$game['ct'][$st['creatureType']].'[/li]'; @@ -901,6 +908,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if (!$transform->error) { $pageData['view3D'] = $transform->getRandomModelId(); + $pageData['buttons'][BUTTON_VIEW3D] = ['type' => TYPE_NPC, 'displayId' => $transform->getRandomModelId()]; $bar = ' ('.$transform->getField('name', true).')'; } else @@ -1578,9 +1586,10 @@ $smarty->updatePageVars(array( 'type' => TYPE_SPELL, 'typeId' => $_id, 'reqJS' => array( - $pageData['view3D'] ? 'template/js/swfobject.js' : null + $pageData['buttons'][BUTTON_VIEW3D] ? 'template/js/swfobject.js' : null ) )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_SPELL, $_id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$spell, ['colon' => Lang::$colon])); $smarty->assign('lvData', $pageData); diff --git a/pages/spells.php b/pages/spells.php index 84ec9da9..42b8e860 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -392,9 +392,9 @@ if (!$smarty->loadCache($cacheKey, $pageData, $filter)) $spells->addGlobalsToJscript($smarty, GLOBALINFO_SELF | GLOBALINFO_RELATED); // create note if search limit was exceeded; overwriting 'note' is intentional - if ($spells->getMatches() > $AoWoWconf['sqlLimit']) + if ($spells->getMatches() > SQL_LIMIT_DEFAULT) { - $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_spellsfound', $spells->getMatches(), $AoWoWconf['sqlLimit']); + $pageData['params']['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_spellsfound', $spells->getMatches(), SQL_LIMIT_DEFAULT); $pageData['params']['_truncated'] = 1; } diff --git a/pages/title.php b/pages/title.php index b7c94e9a..601393cd 100644 --- a/pages/title.php +++ b/pages/title.php @@ -16,6 +16,10 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($title->error) $smarty->notFound(Lang::$game['title']); + /***********/ + /* Infobox */ + /***********/ + $infobox = []; if ($title->getField('side') == SIDE_ALLIANCE) $infobox[] = Lang::$main['side'].Lang::$colon.'[span class=alliance-icon]'.Lang::$game['si'][SIDE_ALLIANCE].'[/span]'; @@ -30,17 +34,29 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) if ($e = $title->getField('eventId')) $infobox[] = Lang::$game['eventShort'].Lang::$colon.'[url=?event='.$e.']'.WorldEventList::getName($e).'[/url]'; + /****************/ + /* Main Content */ + /****************/ + $pageData = array( 'title' => Util::ucFirst(trim(str_replace('%s', '', str_replace(',', '', $title->getField('male', true))))), 'path' => '[0, 10, '.$title->getField('category').']', 'infobox' => '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]', 'relTabs' => [], + 'buttons' => array( + BUTTON_WOWHEAD => true, + BUTTON_LINKS => true + ), 'page' => array( 'name' => $title->getHtmlizedName(), 'expansion' => Util::$expansionString[$title->getField('expansion')] ) ); + /**************/ + /* Extra Tabs */ + /**************/ + if (!empty($title->sources[$_id])) { foreach ($title->sources[$_id] as $type => $entries) @@ -98,6 +114,7 @@ $smarty->updatePageVars(array( 'type' => TYPE_TITLE, 'typeId' => $_id )); +$smarty->assign('redButtons', $pageData['buttons']); $smarty->assign('community', CommunityContent::getAll(TYPE_TITLE, $_id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main)); $smarty->assign('lvData', $pageData); diff --git a/search.php b/search.php index 337e7934..f6f8beed 100644 --- a/search.php +++ b/search.php @@ -50,16 +50,16 @@ todo 26: Listview - template: 'profile', id: 'characters', name: LANG. 29: Arena Teams..? */ -$search = urlDecode(trim($pageParam)); -$query = Util::sqlEscape(str_replace('?', '_', str_replace('*', '%', ($search))), true); -$type = @intVal($_GET['type']); -$searchMask = 0x0; -$found = []; -$jsGlobals = []; -$maxResults = 500; // todo: move to config +$search = urlDecode(trim($pageParam)); +$query = Util::sqlEscape(str_replace('?', '_', str_replace('*', '%', ($search))), true); +$type = @intVal($_GET['type']); +$searchMask = 0x0; +$found = []; +$jsGlobals = []; +$maxResults = SQL_LIMIT_SEARCH; -$_wt = isset($_GET['wt']) ? explode(':', $_GET['wt']) : null; -$_wtv = isset($_GET['wtv']) ? explode(':', $_GET['wtv']) : null; +$_wt = isset($_GET['wt']) ? explode(':', $_GET['wt']) : null; +$_wtv = isset($_GET['wtv']) ? explode(':', $_GET['wtv']) : null; if (isset($_GET['json'])) { @@ -331,12 +331,12 @@ if ($searchMask & 0x40) if (($searchMask & SEARCH_TYPE_JSON) && $type == TYPE_ITEMSET && isset($found['itemset'])) { - $conditions = [['i.id', array_keys($found['itemset']['pcsToSet'])], 0]; + $conditions = [['i.id', array_keys($found['itemset']['pcsToSet'])], SQL_LIMIT_NONE]; $miscData = ['pcsToSet' => @$found['itemset']['pcsToSet']]; } else if (($searchMask & SEARCH_TYPE_JSON) && $type == TYPE_ITEM) { - $conditions = [['i.class', [ITEM_CLASS_WEAPON, ITEM_CLASS_GEM, ITEM_CLASS_ARMOR]], ['name_loc'.User::$localeId, $query], $AoWoWconf['sqlLimit']]; + $conditions = [['i.class', [ITEM_CLASS_WEAPON, ITEM_CLASS_GEM, ITEM_CLASS_ARMOR]], ['name_loc'.User::$localeId, $query], SQL_LIMIT_DEFAULT]; $miscData = ['wt' => $_wt, 'wtv' => $_wtv]; } else diff --git a/template/achievement.tpl b/template/achievement.tpl index b374f482..ac703f38 100644 --- a/template/achievement.tpl +++ b/template/achievement.tpl @@ -67,8 +67,8 @@ $WH.ge('h1-icon-generic').appendChild(Icon.create('{$lvData.page.iconname|escape:"javascript"}', 1)); //]]> - {$lang.links}{$lang.links} - WowheadWowhead +{include file='bricks/redButtons.tpl'} +

{$lvData.page.name}

{$lvData.page.description} diff --git a/template/bricks/redButtons.tpl b/template/bricks/redButtons.tpl new file mode 100644 index 00000000..da37c6e5 --- /dev/null +++ b/template/bricks/redButtons.tpl @@ -0,0 +1,61 @@ +{* +found this button(?) in item.tpl .. no script, data or style found for this id +
+*} + +{if isset($redButtons[$smarty.const.BUTTON_LINKS])} + {assign var='b' value=$redButtons[$smarty.const.BUTTON_LINKS]} + {if $b} + {$lang.links}{$lang.links} + {else} + {$lang.links}{$lang.links} + {/if} +{/if} +{if isset($redButtons[$smarty.const.BUTTON_WOWHEAD])} + {assign var='b' value=$redButtons[$smarty.const.BUTTON_WOWHEAD]} + {if $b} + WowheadWowhead + {else} + WowheadWowhead + {/if} +{/if} +{if isset($redButtons[$smarty.const.BUTTON_VIEW3D])} + {assign var='b' value=$redButtons[$smarty.const.BUTTON_VIEW3D]} + {if $b} + {$lang.view3D}{$lang.view3D} + {else} + {$lang.view3D}{$lang.view3D} + {/if} +{/if} +{if isset($redButtons[$smarty.const.BUTTON_COMPARE])} + {assign var='b' value=$redButtons[$smarty.const.BUTTON_COMPARE]} + {if $b} + {$lang.compare}{$lang.compare} + {else} + {$lang.compare}{$lang.compare} + {/if} +{/if} +{if isset($redButtons[$smarty.const.BUTTON_UPGRADE])} + {assign var='b' value=$redButtons[$smarty.const.BUTTON_UPGRADE]} + {if $b} + {$lang.findUpgrades}{$lang.findUpgrades} + {else} + {$lang.findUpgrades}{$lang.findUpgrades} + {/if} +{/if} +{if isset($redButtons[$smarty.const.BUTTON_TALENT])} + {assign var='b' value=$redButtons[$smarty.const.BUTTON_TALENT]} + {if $b} + {if $b.pet}{$lang.petCalc}{else}{$lang.talentCalc}{/if}{if $b.pet}{$lang.petCalc}{else}{$lang.talentCalc}{/if} + {else} + {if $b.pet}{$lang.petCalc}{else}{$lang.talentCalc}{/if}{if $b.pet}{$lang.petCalc}{else}{$lang.talentCalc}{/if} + {/if} +{/if} +{if isset($redButtons[$smarty.const.BUTTON_FORUM])} + {assign var='b' value=$redButtons[$smarty.const.BUTTON_FORUM]} + {if $b} + {$lang.forum}{$lang.forum} + {else} + {$lang.forum}{$lang.forum} + {/if} +{/if} diff --git a/template/class.tpl b/template/class.tpl index ed2c3516..4e4195c7 100644 --- a/template/class.tpl +++ b/template/class.tpl @@ -23,10 +23,9 @@ - WowheadWowhead - {$lang.links}{$lang.links} - {$lang.talentCalc}{$lang.talentCalc} - {$lang.forum}{$lang.forum} + +{include file='bricks/redButtons.tpl'} +

{if $lvData.page.expansion}{$lvData.page.name}{else}{$lvData.page.name}{/if}

{include file='bricks/article.tpl'} diff --git a/template/item.tpl b/template/item.tpl index 5e606c38..dc0c550b 100644 --- a/template/item.tpl +++ b/template/item.tpl @@ -19,12 +19,9 @@ {include file='bricks/infobox.tpl' info=$lvData.infobox}
- {$lang.links}{$lang.links} - {$lang.view3D}{$lang.view3D} - {$lang.compare}{$lang.compare} - {$lang.findUpgrades}{$lang.findUpgrades} - WowheadWowhead -{*
what the heck.. this div has neither data nor style or script associated with *} + +{include file='bricks/redButtons.tpl'} +

{$lvData.page.name}

{include file='bricks/tooltip.tpl'} diff --git a/template/itemset.tpl b/template/itemset.tpl index 1e77f5f0..97343add 100644 --- a/template/itemset.tpl +++ b/template/itemset.tpl @@ -19,10 +19,9 @@ {include file='bricks/infobox.tpl' info=$lvData.infobox}
- {$lang.links}{$lang.links} - {$lang.view3D}{$lang.view3D} - {$lang.compare}{$lang.compare} - WowheadWowhead + +{include file='bricks/redButtons.tpl'} +

{$lvData.page.name}

{include file='bricks/article.tpl'} diff --git a/template/js/global.js b/template/js/global.js index ec45e27e..5ac0c5c6 100644 --- a/template/js/global.js +++ b/template/js/global.js @@ -1039,7 +1039,7 @@ function g_getMoneyHtml(money, side, costItems, costCurrency, achievementPoints) html += '' + $WH.number_format(count) + ''; } else if (currencyId == 104) { // honor - html += '' + $WH.number_format(count) + ''; + html += '' + (side == 3 ? '' : '') + $WH.number_format(count) + (side == 3 ? '' : '') + ''; } else { // tokens html += '' + count + ''; @@ -5981,6 +5981,70 @@ Listview.funcBox = { } }, + initSpellFilter: function (row) { + if (this._spellTypes == null) { + this._spellTypes = {}; + } + + if (this._spellTypes[row.cat] == null) { + this._spellTypes[row.cat] = 0; + } + + this._spellTypes[row.cat]++; + }, + + addSpellIndicator: function () { + var it = location.hash.match(/:type=([^:]+)/); + + var f = function (spellCat, updatePound) { + g_setSelectedLink(this, "spellType"); + + lv.customPound = lv.id + (spellCat != null ? ":type=" + spellCat : ""); + lv.customFilter = function (spell) { + return spellCat == null || spell.cat == spellCat; + }; + lv.updateFilters(1); + lv.applySort(); + lv.refreshRows(); + if (updatePound) { + lv.updatePound(1) + } + }; + + var + lv = this, + categories = [], + a; + + a = $("" + LANG.pr_note_all + ""); + a[0].f = f.bind(a[0], null, 1); + a.click(a[0].f); + var firstCallback = f.bind(a[0], null, 0); + firstCallback(); + categories.push($('').append(a).append($("" + LANG.pr_note_all + ""))); + for (var i in g_spell_categories) { + if (!this._spellTypes[i]) { + continue; + } + a = $("" + g_spell_categories[i] + " (" + this._spellTypes[i] + ")"); + a[0].f = f.bind(a[0], i, 1); + a.click(a[0].f); + + categories.push($('').append(a).append($("" + g_spell_categories[i] + " (" + this._spellTypes[i] + ")"))); + + if (it && it[1] == i) { + (a[0].f)(); + } + } + if (categories.length > 2) { + for (var i = 0, len = categories.length; i < len; ++i) { + this.createIndicator(categories[i], null, $("a", categories[i])[0].f) + } + $(this.noteTop).css("padding-bottom", "12px"); + $(this.noteIndicators).append($('
')).insertAfter($(this.navTop)) + } + }, + initStatisticFilter: function(row) { if(this._achievTypes == null) diff --git a/template/pet.tpl b/template/pet.tpl index 2dad9ac6..3e3d12d3 100644 --- a/template/pet.tpl +++ b/template/pet.tpl @@ -19,9 +19,9 @@ {include file='bricks/infobox.tpl' info=$lvData.infobox}
- {$lang.links}{$lang.links} - {$lang.petCalc}{$lang.petCalc} - WowheadWowhead + +{include file='bricks/redButtons.tpl'} +
- WowheadWowhead - {$lang.links}{$lang.links} +{include file='bricks/redButtons.tpl'} +

{if $lvData.page.expansion}{$lvData.page.name}{else}{$lvData.page.name}{/if}

{include file='bricks/article.tpl'} diff --git a/template/skill.tpl b/template/skill.tpl index 40a1eb96..6f507c9d 100644 --- a/template/skill.tpl +++ b/template/skill.tpl @@ -25,8 +25,8 @@ $WH.ge('h1-icon-generic').appendChild(Icon.create('{$lvData.page.icon|escape:"javascript"}', 1)); //]]> - {$lang.links}{$lang.links} - WowheadWowhead +{include file='bricks/redButtons.tpl'} +

{$lvData.page.name}

{include file='bricks/article.tpl'} diff --git a/template/spell.tpl b/template/spell.tpl index 2925ae63..9f060d62 100644 --- a/template/spell.tpl +++ b/template/spell.tpl @@ -1,6 +1,4 @@ {include file='header.tpl'} -{assign var="iconlist1" value="1"} -{assign var="iconlist2" value="1"}
@@ -21,27 +19,19 @@ {include file='bricks/infobox.tpl' info=$lvData.infobox}
- {$lang.links}{$lang.links} - View in 3DView in 3D - WowheadWowhead +{include file='bricks/redButtons.tpl'}

{$lvData.page.name}

{include file='bricks/tooltip.tpl'} -{if $lvData.page.reagents}{if $lvData.page.tools}
{/if} -

{$lang.reagents}

- -{section name=i loop=$lvData.page.reagents} - -{/section} -
{$lvData.page.reagents[i].name}{if $lvData.page.reagents[i].count > 1} ({$lvData.page.reagents[i].count}){/if}
- -{if $lvData.page.tools}
{/if}{/if} -{if $lvData.page.tools}{if $lvData.page.reagents}
{/if} +{if $lvData.page.reagents} + {if $lvData.page.tools}
{/if} +{include file='bricks/reagentList.tpl' reagent=$lvData.page.reagents} + {if $lvData.page.tools}
{/if} +{/if} + +{if $lvData.page.tools} + {if $lvData.page.reagents}
{/if}

{$lang.tools}

{section name=i loop=$lvData.page.tools} @@ -53,7 +43,8 @@ $WH.ge('iconlist-icon{$iconlist2++}').appendChild(g_items.createIcon({$lvData.page.tools[i].itemId}, 0, 1)); {/if}{/section} -{if $lvData.page.reagents}{/if}{/if} + {if $lvData.page.reagents}{/if}{ +/if}
diff --git a/template/title.tpl b/template/title.tpl index cfa30a58..b1d745cb 100644 --- a/template/title.tpl +++ b/template/title.tpl @@ -19,8 +19,9 @@ {include file='bricks/infobox.tpl' info=$lvData.infobox}
- {$lang.links}{$lang.links} - WowheadWowhead + +{include file='bricks/redButtons.tpl'} +

{if isset($lvData.page.expansion)}{$lvData.page.name}{else}{$lvData.page.name}{/if}

{include file='bricks/article.tpl'}