diff --git a/includes/genericPage.class.php b/includes/genericPage.class.php index bc95f63d..cc7f9ef3 100644 --- a/includes/genericPage.class.php +++ b/includes/genericPage.class.php @@ -6,8 +6,7 @@ if (!defined('AOWOW_REVISION')) trait DetailPage { - - // require 'includes/community.class.php'; + protected $hasComContent = true; function generateCacheKey($cacheType, $params = '-1') { @@ -53,7 +52,6 @@ class GenericPage protected $name = ''; // for h1-Element protected $tabId = 0; protected $community = ['co' => [], 'sc' => [], 'vi' => []]; - protected $hasComContent = false; private $js = []; private $css = []; @@ -103,7 +101,7 @@ class GenericPage $this->saveCache(); } - if ($this->hasComContent) + if (!empty($this->hasComContent)) $this->community = CommunityContent::getAll($this->type, $this->typeId); $this->mysql = DB::Aowow()->getStatistics(); diff --git a/includes/types/faction.class.php b/includes/types/faction.class.php index 770e6683..e008113c 100644 --- a/includes/types/faction.class.php +++ b/includes/types/faction.class.php @@ -12,7 +12,8 @@ class FactionList extends BaseType protected $queryBase = 'SELECT f.*, f.parentFactionId AS cat2, f.id AS ARRAY_KEY FROM ?_factions f'; protected $queryOpts = array( 'f' => [['f2']], - 'f2' => ['j' => ['?_factions f2 ON f.parentFactionId = f2.id', true], 's' => ', IFNULL(f2.parentFactionId, 0) AS cat'] + 'f2' => ['j' => ['?_factions f2 ON f.parentFactionId = f2.id', true], 's' => ', IFNULL(f2.parentFactionId, 0) AS cat'], + 'ft' => ['j' => '?_factiontemplate ft ON ft.factionId = f.id'] ); public function __construct($conditions = []) diff --git a/index.php b/index.php index d62806b2..a803268f 100644 --- a/index.php +++ b/index.php @@ -15,19 +15,16 @@ require 'includes/kernel.php'; if (version_compare(PHP_VERSION, '5.4.0') <= 0) { if (User::isInGroup(U_GROUP_EMPLOYEE)) - $smarty->internalNotice(U_GROUP_EMPLOYEE, 'PHP Version 5.4.0 or higher required! Your version is '.PHP_VERSION."\nCore functions are unavailable!"); + Util::addNote(U_GROUP_EMPLOYEE, 'PHP Version 5.4.0 or higher required! Your version is '.PHP_VERSION."[br]Core functions are unavailable!"); else - $smarty->brb(); + (new GenericPage)->maintenance(); } -if (CFG_MAINTENANCE && !User::isInGroup(U_GROUP_EMPLOYEE)) - $smarty->brb(); -else if (CFG_MAINTENANCE && User::isInGroup(U_GROUP_EMPLOYEE)) - $smarty->internalNotice(U_GROUP_EMPLOYEE, 'Maintenance mode enabled!'); - switch ($pageCall) { /* called by user */ + case '': // no parameter given -> MainPage + $pageCall = 'main'; case 'account': // account management [nyi] case 'achievement': case 'achievements': @@ -73,15 +70,10 @@ switch ($pageCall) case 'user': // tool: user profiles [nyi] case 'zone': case 'zones': - if (file_exists('pages/'.$pageCall.'.php')) - require 'pages/'.$pageCall.'.php'; - else - $smarty->error(); + $_ = $pageCall.'Page'; + new $_($pageParam); break; /* other pages */ - case '': // no parameter given -> MainPage - require 'pages/main.php'; - break; case 'whats-new': case 'searchplugins': case 'searchbox': @@ -89,7 +81,7 @@ switch ($pageCall) case 'help': case 'faq': case 'aboutus': - require 'pages/more.php'; + new MorePage($pageCall); break; case 'latest-additions': case 'latest-articles': @@ -141,7 +133,7 @@ switch ($pageCall) if (isset($_GET['power'])) die('$WowheadPower.register(0, '.User::$localeId.', {})'); else // in conjunction with a propper rewriteRule in .htaccess... - $smarty->error(); + (new GenericPage)->error(); break; } diff --git a/pages/class.php b/pages/class.php index 1d78f5d8..dd5b6abb 100644 --- a/pages/class.php +++ b/pages/class.php @@ -4,236 +4,262 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -require 'includes/community.class.php'; - -$_id = intVal($pageParam); -$_mask = 1 << ($_id - 1); -$_path = [0, 12, $_id]; -$tcClassId = [null, 8, 3, 1, 5, 4, 9, 6, 2, 7, null, 0]; // see TalentCalc.js -$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_CLASS, $_id, -1, User::$localeId]); - -if (!$smarty->loadCache($cacheKeyPage, $pageData)) +// menuId 12: Class g_initPath() +// tabId 0: Database g_initHeader() +class ClassPage extends GenericPage { - $cl = new CharClassList(array(['id', $_id])); - if ($cl->error) - $smarty->notFound(Lang::$game['class'], $_id); + use DetailPage; - /***********/ - /* Infobox */ - /***********/ + protected $type = TYPE_CLASS; + protected $typeId = 0; + protected $tpl = 'detail-page-generic'; + protected $path = [0, 12]; + protected $tabId = 0; + protected $mode = CACHETYPE_PAGE; + protected $js = ['swfobject.js']; - $infobox = []; - // hero class - if ($cl->getField('flags') & 0x40) - $infobox[] = '[tooltip=tooltip_heroclass]'.Lang::$game['heroClass'].'[/tooltip]'; + public function __construct($id) + { + $this->typeId = intVal($id); - // resource - if ($_id == 11) // special Druid case - $infobox[] = Lang::$game['resources'].Lang::$colon. - '[tooltip name=powertype1]'.Lang::$game['st'][0].', '.Lang::$game['st'][31].', '.Lang::$game['st'][2].'[/tooltip][span class=tip tooltip=powertype1]'.Util::ucFirst(Lang::$spell['powerTypes'][0]).'[/span], '. - '[tooltip name=powertype2]'.Lang::$game['st'][5].', '.Lang::$game['st'][8].'[/tooltip][span class=tip tooltip=powertype2]'.Util::ucFirst(Lang::$spell['powerTypes'][1]).'[/span], '. - '[tooltip name=powertype8]'.Lang::$game['st'][1].'[/tooltip][span class=tip tooltip=powertype8]'.Util::ucFirst(Lang::$spell['powerTypes'][3]).'[/span]'; - else if ($_id == 6) // special DK case - $infobox[] = Lang::$game['resources'].Lang::$colon.'[span]'.Util::ucFirst(Lang::$spell['powerTypes'][5]).', '.Util::ucFirst(Lang::$spell['powerTypes'][$cl->getField('powerType')]).'[/span]'; - else // regular case - $infobox[] = Lang::$game['resource'].Lang::$colon.'[span]'.Util::ucFirst(Lang::$spell['powerTypes'][$cl->getField('powerType')]).'[/span]'; + $this->subject = new CharClassList(array(['id', $id])); + if ($this->subject->error) + $this->notFound(Lang::$game['class']); - // roles - $roles = []; - for ($i = 0; $i < 4; $i++) - if ($cl->getField('roles') & (1 << $i)) - $roles[] = (count($roles) == 2 ? '\n' : '').Lang::$game['_roles'][$i]; + $this->name = $this->subject->getField('name', true); + $this->gPageInfo = array( + 'type' => $this->type, + 'typeId' => $this->typeId, + 'name' => $this->name + ); - if ($roles) - $infobox[] = (count($roles) > 1 ? Lang::$game['roles'] : Lang::$game['role']).Lang::$colon.implode(', ', $roles); + parent::__construct(); + } - // specs - $specList = []; - $skills = new SkillList(array(['id', $cl->getField('skills')])); - $skills->addGlobalsToJscript(); - foreach ($skills->iterate() as $k => $__) - $specList[$k] = '[icon name='.$skills->getField('iconString').'][url=?spells=7.'.$_id.'.'.$k.']'.$skills->getField('name', true).'[/url][/icon]'; + protected function generatePath() + { + $this->path[] = $this->typeId; + } - if ($specList) - $infobox[] = Lang::$game['specs'].Lang::$colon.'[ul][li]'.implode('[/li][li]', $specList).'[/li][/ul]'; + protected function generateTitle() + { + array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['class'])); + } - /****************/ - /* Main Content */ - /****************/ - - // menuId 12: Class g_initPath() - // tabId 0: Database g_initHeader() - $pageData = array ( - 'page' => array( - 'title' => $cl->getField('name', true).' - '.Util::ucFirst(Lang::$game['class']), - 'path' => json_encode($_path, JSON_NUMERIC_CHECK), - 'tab' => 0, - 'type' => TYPE_CLASS, - 'typeId' => $_id, - 'reqJS' => [STATIC_URL.'/js/swfobject.js'], - 'name' => $cl->getField('name', true), - 'expansion' => Util::$expansionString[$cl->getField('expansion')], - 'infobox' => '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]', - 'headIcons' => ['class_'.strtolower($cl->getField('fileString'))], - 'redButtons' => array( - BUTTON_LINKS => ['color' => '', 'linkId' => ''], - BUTTON_WOWHEAD => true, - BUTTON_TALENT => ['href' => '?talent#'.Util::$tcEncoding[$tcClassId[$_id] * 3], 'pet' => false], - BUTTON_FORUM => false // doto (low): CFG_BOARD_URL + X - ) - ), - 'relTabs' => [], - ); - - /**************/ - /* Extra Tabs */ - /**************/ - - // Tab: Spells (grouped) - // '$LANG.tab_armorproficiencies', - // '$LANG.tab_weaponskills', - // '$LANG.tab_glyphs', - // '$LANG.tab_abilities', - // '$LANG.tab_talents', - $conditions = array( - ['s.typeCat', [-13, -11, -2, 7]], - [['s.cuFlags', (SPELL_CU_TRIGGERED | CUSTOM_EXCLUDE_FOR_LISTVIEW), '&'], 0], - [ - 'OR', - ['s.reqClassMask', $_mask, '&'], // Glyphs, Proficiencies - ['s.skillLine1', $cl->getField('skills')], // Abilities / Talents - ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $cl->getField('skills')]] - ], - [ // last rank or unranked - 'OR', - ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], - ['s.rankId', 0] - ] - ); - - $genSpells = new SpellList($conditions); - $genSpells->addGlobalsToJScript(GLOBALINFO_SELF); - - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $genSpells->getListviewData(), - 'params' => array( - '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' - ) - ); + protected function generateContent() + { + $infobox = []; + $_mask = 1 << ($this->typeId - 1); + $tcClassId = [null, 8, 3, 1, 5, 4, 9, 6, 2, 7, null, 0]; // see TalentCalc.js - // Tab: Items (grouped) - $conditions = array( - ['requiredClass', 0, '>'], - ['requiredClass', $_mask, '&'], - [['requiredClass', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'], - ['itemset', 0], // hmm, do or dont..? - 0 - ); + /***********/ + /* Infobox */ + /***********/ - $items = new ItemList($conditions); - $items->addGlobalsToJscript(); + // hero class + if ($this->subject->getField('flags') & 0x40) + $infobox[] = '[tooltip=tooltip_heroclass]'.Lang::$game['heroClass'].'[/tooltip]'; - if (!$items->hasDiffFields(['requiredRace'])) - $hidden = "$['side']"; + // resource + if ($this->typeId == 11) // special Druid case + $infobox[] = Lang::$game['resources'].Lang::$main['colon']. + '[tooltip name=powertype1]'.Lang::$game['st'][0].', '.Lang::$game['st'][31].', '.Lang::$game['st'][2].'[/tooltip][span class=tip tooltip=powertype1]'.Util::ucFirst(Lang::$spell['powerTypes'][0]).'[/span], '. + '[tooltip name=powertype2]'.Lang::$game['st'][5].', '.Lang::$game['st'][8].'[/tooltip][span class=tip tooltip=powertype2]'.Util::ucFirst(Lang::$spell['powerTypes'][1]).'[/span], '. + '[tooltip name=powertype8]'.Lang::$game['st'][1].'[/tooltip][span class=tip tooltip=powertype8]'.Util::ucFirst(Lang::$spell['powerTypes'][3]).'[/span]'; + else if ($this->typeId == 6) // special DK case + $infobox[] = Lang::$game['resources'].Lang::$main['colon'].'[span]'.Util::ucFirst(Lang::$spell['powerTypes'][5]).', '.Util::ucFirst(Lang::$spell['powerTypes'][$this->subject->getField('powerType')]).'[/span]'; + else // regular case + $infobox[] = Lang::$game['resource'].Lang::$main['colon'].'[span]'.Util::ucFirst(Lang::$spell['powerTypes'][$this->subject->getField('powerType')]).'[/span]'; - $pageData['relTabs'][] = array( - 'file' => 'item', - 'data' => $items->getListviewData(), - 'params' => array( - 'id' => 'items', - 'name' => '$LANG.tab_items', - 'tabs' => '$tabsRelated', - 'visibleCols' => "$['dps', 'armor', 'slot']", - 'hiddenCols' => isset($hidden) ? $hidden : null, - 'computeDataFunc' => '$Listview.funcBox.initSubclassFilter', - 'onAfterCreate' => '$Listview.funcBox.addSubclassIndicator', - 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=152;crs='.$_id.';crv=0'), - '_truncated' => 1 - ) - ); + // roles + $roles = []; + for ($i = 0; $i < 4; $i++) + if ($this->subject->getField('roles') & (1 << $i)) + $roles[] = (count($roles) == 2 ? "\n" : '').Lang::$game['_roles'][$i]; - // Tab: Quests - $conditions = array( - ['reqClassMask', $_mask, '&'], - [['reqClassMask', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'] - ); + if ($roles) + $infobox[] = (count($roles) > 1 ? Lang::$game['roles'] : Lang::$game['role']).Lang::$main['colon'].implode(', ', $roles); - $quests = new QuestList($conditions); - $quests->addGlobalsToJscript(); + // specs + $specList = []; + $skills = new SkillList(array(['id', $this->subject->getField('skills')])); + foreach ($skills->iterate() as $k => $__) + $specList[$k] = '[icon name='.$skills->getField('iconString').'][url=?spells=7.'.$this->typeId.'.'.$k.']'.$skills->getField('name', true).'[/url][/icon]'; - $pageData['relTabs'][] = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), - 'params' => array( - 'sort' => "$['reqlevel', 'name']", - 'tabs' => '$tabsRelated' - ) - ); + if ($specList) + $infobox[] = Lang::$game['specs'].Lang::$main['colon'].'[ul][li]'.implode('[/li][li]', $specList).'[/li][/ul]'; - // Tab: Itemsets - $sets = new ItemsetList(array(['classMask', $_mask, '&'])); - $sets->addGlobalsToJScript(GLOBALINFO_SELF); - $pageData['relTabs'][] = array( - 'file' => 'itemset', - 'data' => $sets->getListviewData(), - 'params' => array( - 'note' => sprintf(Util::$filterResultString, '?itemsets&filter=cl='.$_id), - 'hiddenCols' => "$['classes']", - 'sort' => "$['-level', 'name']", - 'tabs' => '$tabsRelated' - ) - ); + /****************/ + /* Main Content */ + /****************/ - // Tab: Trainer - $conditions = array( - ['npcflag', 0x30, '&'], // is trainer - ['trainerType', 0], // trains class spells - ['trainerClass', $_id] - ); + $this->infobox = '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]'; + $this->expansion = Util::$expansionString[$this->subject->getField('expansion')]; + $this->headIcons = ['class_'.strtolower($this->subject->getField('fileString'))]; + $this->redButtons = array( + BUTTON_LINKS => ['color' => '', 'linkId' => ''], + BUTTON_WOWHEAD => true, + BUTTON_TALENT => ['href' => '?talent#'.Util::$tcEncoding[$tcClassId[$this->typeId] * 3], 'pet' => false], + BUTTON_FORUM => false // todo (low): CFG_BOARD_URL + X + ); - $trainer = new CreatureList($conditions); - $pageData['relTabs'][] = array( - 'file' => 'creature', - 'data' => $trainer->getListviewData(), - 'params' => array( - 'id' => 'trainers', - 'name' => '$LANG.tab_trainers', - 'tabs' => '$tabsRelated' - ) - ); + /**************/ + /* Extra Tabs */ + /**************/ - // Tab: Races - $races = new CharRaceList(array(['classMask', $_mask, '&'])); + // Tab: Spells (grouped) + // '$LANG.tab_armorproficiencies', + // '$LANG.tab_weaponskills', + // '$LANG.tab_glyphs', + // '$LANG.tab_abilities', + // '$LANG.tab_talents', + $conditions = array( + ['s.typeCat', [-13, -11, -2, 7]], + [['s.cuFlags', (SPELL_CU_TRIGGERED | CUSTOM_EXCLUDE_FOR_LISTVIEW), '&'], 0], + [ + 'OR', + ['s.reqClassMask', $_mask, '&'], // Glyphs, Proficiencies + ['s.skillLine1', $this->subject->getField('skills')], // Abilities / Talents + ['AND', ['s.skillLine1', 0, '>'], ['s.skillLine2OrMask', $this->subject->getField('skills')]] + ], + [ // last rank or unranked + 'OR', + ['s.cuFlags', SPELL_CU_LAST_RANK, '&'], + ['s.rankId', 0] + ] + ); - $pageData['relTabs'][] = array( - 'file' => 'race', - 'data' => $races->getListviewData(), - 'params' => array( - 'tabs' => '$tabsRelated' - ) - ); + $genSpells = new SpellList($conditions); + if (!$genSpells->error) + { + $this->extendGlobalData($genSpells->getJSGlobals(GLOBALINFO_SELF)); - $smarty->saveCache($cacheKeyPage, $pageData); + $this->lvData[] = array( + 'file' => 'spell', + 'data' => $genSpells->getListviewData(), + 'params' => array( + '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' + ) + ); + } + + // Tab: Items (grouped) + $conditions = array( + ['requiredClass', 0, '>'], + ['requiredClass', $_mask, '&'], + [['requiredClass', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'], + ['itemset', 0], // hmm, do or dont..? + 0 + ); + + $items = new ItemList($conditions); + if (!$items->error) + { + $this->extendGlobalData($items->getJSGlobals()); + + if (!$items->hasDiffFields(['requiredRace'])) + $hidden = "$['side']"; + + $this->lvData[] = array( + 'file' => 'item', + 'data' => $items->getListviewData(), + 'params' => array( + 'id' => 'items', + 'name' => '$LANG.tab_items', + 'tabs' => '$tabsRelated', + 'visibleCols' => "$['dps', 'armor', 'slot']", + 'hiddenCols' => isset($hidden) ? $hidden : null, + 'computeDataFunc' => '$Listview.funcBox.initSubclassFilter', + 'onAfterCreate' => '$Listview.funcBox.addSubclassIndicator', + 'note' => sprintf(Util::$filterResultString, '?items&filter=cr=152;crs='.$this->typeId.';crv=0'), + '_truncated' => 1 + ) + ); + } + + // Tab: Quests + $conditions = array( + ['reqClassMask', $_mask, '&'], + [['reqClassMask', CLASS_MASK_ALL, '&'], CLASS_MASK_ALL, '!'] + ); + + $quests = new QuestList($conditions); + if (!$quests->error) + { + $this->extendGlobalData($quests->getJSGlobals()); + + $this->lvData[] = array( + 'file' => 'quest', + 'data' => $quests->getListviewData(), + 'params' => array( + 'sort' => "$['reqlevel', 'name']", + 'tabs' => '$tabsRelated' + ) + ); + } + + // Tab: Itemsets + $sets = new ItemsetList(array(['classMask', $_mask, '&'])); + if (!$sets->error) + { + $this->extendGlobalData($sets->getJSGlobals(GLOBALINFO_SELF)); + + $this->lvData[] = array( + 'file' => 'itemset', + 'data' => $sets->getListviewData(), + 'params' => array( + 'note' => sprintf(Util::$filterResultString, '?itemsets&filter=cl='.$this->typeId), + 'hiddenCols' => "$['classes']", + 'sort' => "$['-level', 'name']", + 'tabs' => '$tabsRelated' + ) + ); + } + + // Tab: Trainer + $conditions = array( + ['npcflag', 0x30, '&'], // is trainer + ['trainerType', 0], // trains class spells + ['trainerClass', $this->typeId] + ); + + $trainer = new CreatureList($conditions); + if (!$trainer->error) + { + $this->lvData[] = array( + 'file' => 'creature', + 'data' => $trainer->getListviewData(), + 'params' => array( + 'id' => 'trainers', + 'name' => '$LANG.tab_trainers', + 'tabs' => '$tabsRelated' + ) + ); + } + + // Tab: Races + $races = new CharRaceList(array(['classMask', $_mask, '&'])); + if (!$races->error) + { + $this->lvData[] = array( + 'file' => 'race', + 'data' => $races->getListviewData(), + 'params' => array( + 'tabs' => '$tabsRelated' + ) + ); + } + } } - -$smarty->updatePageVars($pageData['page']); -$smarty->assign('community', CommunityContent::getAll(TYPE_CLASS, $_id)); // comments, screenshots, videos -$smarty->assign('lang', array_merge(Lang::$main, ['colon' => Lang::$colon])); -$smarty->assign('lvData', $pageData['relTabs']); - -// load the page -$smarty->display('detail-page-generic.tpl'); - ?> diff --git a/pages/classes.php b/pages/classes.php index f7ade61c..a8de57ad 100644 --- a/pages/classes.php +++ b/pages/classes.php @@ -4,38 +4,44 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -$cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_CLASS, -1, -1, User::$localeId]); - -if (!$smarty->loadCache($cacheKey, $pageData)) +// menuId 12: Class g_initPath() +// tabId 0: Database g_initHeader() +class ClassesPage extends GenericPage { - $classes = new CharClassList(); + use ListPage; - // menuId 12: Class g_initPath() - // tabId 0: Database g_initHeader() - $pageData = array( - 'page' => array( - 'title' => Util::ucFirst(Lang::$game['classes']), - 'path' => "[0, 12]", - 'tab' => 0 - ), - 'lv' => array( - array( + protected $type = TYPE_CLASS; + protected $tpl = 'list-page-generic'; + protected $path = [0, 12]; + protected $tabId = 0; + protected $mode = CACHETYPE_PAGE; + + public function __construct() + { + $this->name = Util::ucFirst(Lang::$game['classes']); + + parent::__construct(); + } + + protected function generateContent() + { + $classes = new CharClassList(); + if (!$classes->error) + { + $this->lvData[] = array( 'file' => 'class', 'data' => $classes->getListviewData(), 'params' => [] - ) - ) - ); + ); + } + } - $smarty->saveCache($cacheKey, $pageData); + protected function generateTitle() + { + array_unshift($this->title, Util::ucFirst(Lang::$game['classes'])); + } + + protected function generatePath() {} } - -$smarty->updatePageVars($pageData['page']); -$smarty->assign('lang', Lang::$main); -$smarty->assign('lvData', $pageData['lv']); - -// load the page -$smarty->display('list-page-generic.tpl'); - ?> diff --git a/pages/main.php b/pages/main.php index 58e30383..ca1e8b83 100644 --- a/pages/main.php +++ b/pages/main.php @@ -5,22 +5,26 @@ if (!defined('AOWOW_REVISION')) /* - todo: + todo (med): - different styles for newsbox - flags for news .. disabled, deleted, recurring, whatever.. */ -// load news -$rows = DB::Aowow()->select('SELECT * FROM ?_news ORDER BY time DESC, id DESC LIMIT 5'); +class MainPage extends GenericPage +{ + protected $tpl = 'main'; + protected $news = []; -foreach ($rows as $i => $row) - $rows[$i]['text'] = Util::localizedString($row, 'text'); + protected function generateContent() + { + // load news + $rows = DB::Aowow()->select('SELECT * FROM ?_news ORDER BY time DESC, id DESC LIMIT 5'); + foreach ($rows as $i => $row) + $this->news[$i]['text'] = Util::localizedString($row, 'text'); + } - -$smarty->assign('news', isset($rows) ? $rows : NULL); -$smarty->assign('lang', Lang::$main); - -// load the page -$smarty->display('main.tpl'); + protected function generateTitle() {} + protected function generatePath() {} +} ?> diff --git a/pages/race.php b/pages/race.php index 4ad8718d..bae5c383 100644 --- a/pages/race.php +++ b/pages/race.php @@ -4,202 +4,217 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -require 'includes/community.class.php'; - -$_id = intVal($pageParam); -$_mask = 1 << ($_id - 1); -$_path = [0, 13, $_id]; - -$mountVendors = array( // race => [starter, argent tournament] - null, - [384, 33307], - [3362, 33553], - [1261, 33310], - [4730, 33653], - [4731, 33555], - [3685, 33556], - [7955, 33650], - [7952, 33554], - null, - [16264, 33557], - [17584, 33657] -); - -$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_RACE, $_id, -1, User::$localeId]); - -if (!$smarty->loadCache($cacheKeyPage, $pageData)) +// menuId 13: Race g_initPath() +// tabId 0: Database g_initHeader() +class RacePage extends GenericPage { - $race = new CharRaceList(array(['id', $_id])); // should this be limited to playable races..? - if ($race->error) - $smarty->notFound(Lang::$game['race'], $_id); + use DetailPage; - /***********/ - /* Infobox */ - /***********/ + protected $type = TYPE_RACE; + protected $typeId = 0; + protected $tpl = 'detail-page-generic'; + protected $path = [0, 13]; + protected $tabId = 0; + protected $mode = CACHETYPE_PAGE; + protected $js = ['swfobject.js']; - $infobox = []; // unfortunately is all of this custom data :/ - - // side - if ($_ = $race->getField('side')) - $infobox[] = Lang::$main['side'].Lang::$colon.'[span class=icon-'.($_ == 2 ? 'horde' : 'alliance').']'.Lang::$game['si'][$_].'[/span]'; - - // faction - if ($_ = $race->getField('factionId')) + public function __construct($id) { - $smarty->extendGlobalIds(TYPE_FACTION, $_); - $infobox[] = Util::ucFirst(Lang::$game['faction']).Lang::$colon.'[faction='.$_.']'; + $this->typeId = intVal($id); + + $this->subject = new CharRaceList(array(['id', $id])); + if ($this->subject->error) + $this->notFound(Lang::$game['race']); + + $this->name = $this->subject->getField('name', true); + $this->gPageInfo = array( + 'type' => $this->type, + 'typeId' => $this->typeId, + 'name' => $this->name + ); + + parent::__construct(); } - // leader - if ($_ = $race->getField('leader')) + protected function generatePath() { - $smarty->extendGlobalIds(TYPE_NPC, $_); - $infobox[] = Lang::$class['racialLeader'].Lang::$colon.'[npc='.$_.']'; + $this->path[] = $this->typeId; } - // start area - if ($_ = $race->getField('startAreaId')) + protected function generateTitle() { - $smarty->extendGlobalIds(TYPE_ZONE, $_); - $infobox[] = Lang::$class['startZone'].Lang::$colon.'[zone='.$_.']'; + array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::$game['class'])); } - /****************/ - /* Main Content */ - /****************/ + protected function generateContent() + { + $infobox = []; + $_mask = 1 << ($this->typeId - 1); + $mountVendors = array( // race => [starter, argent tournament] + null, [384, 33307], [3362, 33553], [1261, 33310], + [4730, 33653], [4731, 33555], [3685, 33556], [7955, 33650], + [7952, 33554], null, [16264, 33557], [17584, 33657] + ); - // menuId 13: Race g_initPath() - // tabId 0: Database g_initHeader() - $pageData = array ( - 'page' => array( - 'name' => $race->getField('name', true), - 'expansion' => Util::$expansionString[$race->getField('expansion')], - 'title' => $race->getField('name', true).' - '.Util::ucFirst(Lang::$game['race']), - 'path' => json_encode($_path, JSON_NUMERIC_CHECK), - 'tab' => 0, - 'type' => TYPE_RACE, - 'typeId' => $_id, - 'infobox' => '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]', - 'headIcons' => array( - 'race_'.strtolower($race->getField('fileString')).'_male', - 'race_'.strtolower($race->getField('fileString')).'_female' - ), - 'redButtons' => array( - BUTTON_WOWHEAD => true, - BUTTON_LINKS => true - ) - ), - 'relTabs' => [] - ); - /**************/ - /* Extra Tabs */ - /**************/ + /***********/ + /* Infobox */ + /***********/ - // Classes - $classes = new CharClassList(array(['racemask', $_mask, '&'])); - $classes->addGlobalsToJscript(); + $infobox = []; // unfortunately, all of this is custom data :/ - $pageData['relTabs'][] = array( - 'file' => 'class', - 'data' => $classes->getListviewData(), - 'params' => array( - 'tabs' => '$tabsRelated' - ) - ); + // side + if ($_ = $this->subject->getField('side')) + $infobox[] = Lang::$main['side'].Lang::$main['colon'].'[span class=icon-'.($_ == 2 ? 'horde' : 'alliance').']'.Lang::$game['si'][$_].'[/span]'; - // Tongues - $conditions = array( - ['typeCat', -11], // proficiencies - ['reqRaceMask', $_mask, '&'] // only languages are race-restricted - ); + // faction + if ($_ = $this->subject->getField('factionId')) + { + $fac = new FactionList(array(['ft.id', $_])); + $this->extendGlobalData($fac->getJSGlobals()); + $infobox[] = Util::ucFirst(Lang::$game['faction']).Lang::$main['colon'].'[faction='.$fac->id.']'; + } - $tongues = new SpellList($conditions); - $tongues->addGlobalsToJscript(); + // leader + if ($_ = $this->subject->getField('leader')) + { + $this->extendGlobalIds(TYPE_NPC, $_); + $infobox[] = Lang::$class['racialLeader'].Lang::$main['colon'].'[npc='.$_.']'; + } - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $tongues->getListviewData(), - 'params' => array( - 'id' => 'languages', - 'name' => '$LANG.tab_languages', - 'hiddenCols' => "$['reagents']", - 'tabs' => '$tabsRelated' - ) - ); + // start area + if ($_ = $this->subject->getField('startAreaId')) + { + $this->extendGlobalIds(TYPE_ZONE, $_); + $infobox[] = Lang::$class['startZone'].Lang::$main['colon'].'[zone='.$_.']'; + } - // Racials - $conditions = array( - ['typeCat', -4], // racial traits - ['reqRaceMask', $_mask, '&'] - ); - $racials = new SpellList($conditions); - $racials->addGlobalsToJscript(); + /****************/ + /* Main Content */ + /****************/ - $pageData['relTabs'][] = array( - 'file' => 'spell', - 'data' => $racials->getListviewData(), - 'params' => array( - 'id' => 'racial-traits', - 'name' => '$LANG.tab_racialtraits', - 'hiddenCols' => "$['reagents']", - 'tabs' => '$tabsRelated' - ) - ); + $this->infobox = '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]'; + $this->expansion = Util::$expansionString[$this->subject->getField('expansion')]; + $this->headIcons = array( + 'race_'.strtolower($this->subject->getField('fileString')).'_male', + 'race_'.strtolower($this->subject->getField('fileString')).'_female' + ); + $this->redButtons = array( + BUTTON_WOWHEAD => true, + BUTTON_LINKS => true + ); - // Quests - $conditions = array( - ['reqRaceMask', $_mask, '&'], - [['reqRaceMask', RACE_MASK_HORDE, '&'], RACE_MASK_HORDE, '!'], - [['reqRaceMask', RACE_MASK_ALLIANCE, '&'], RACE_MASK_ALLIANCE, '!'] - ); - $quests = new QuestList($conditions); - $quests->addGlobalsToJscript(); + /**************/ + /* Extra Tabs */ + /**************/ - $pageData['relTabs'][] = array( - 'file' => 'quest', - 'data' => $quests->getListviewData(), - 'params' => array( - 'tabs' => '$tabsRelated' - ) - ); + // Classes + $classes = new CharClassList(array(['racemask', $_mask, '&'])); + if (!$classes->error) + { + $this->extendGlobalData($classes->getJSGlobals()); + $this->lvData[] = array( + 'file' => 'class', + 'data' => $classes->getListviewData(), + 'params' => array( + 'tabs' => '$tabsRelated' + ) + ); + } - // Mounts - // ok, this sucks, but i rather hardcode the trainer, than fetch items by namepart - $items = isset($mountVendors[$_id]) ? DB::Aowow()->selectCol('SELECT item FROM npc_vendor WHERE entry IN (?a)', $mountVendors[$_id]) : 0; + // Tongues + $conditions = array( + ['typeCat', -11], // proficiencies + ['reqRaceMask', $_mask, '&'] // only languages are race-restricted + ); - $conditions = array( - ['i.id', $items], - ['i.class', ITEM_CLASS_MISC], - ['i.subClass', 5], // mounts - ); + $tongues = new SpellList($conditions); + if (!$tongues->error) + { + $this->extendGlobalData($tongues->getJSGlobals()); + $this->lvData[] = array( + 'file' => 'spell', + 'data' => $tongues->getListviewData(), + 'params' => array( + 'id' => 'languages', + 'name' => '$LANG.tab_languages', + 'hiddenCols' => "$['reagents']", + 'tabs' => '$tabsRelated' + ) + ); + } - $mounts = new ItemList($conditions); - $mounts->addGlobalsToJscript(); + // Racials + $conditions = array( + ['typeCat', -4], // racial traits + ['reqRaceMask', $_mask, '&'] + ); - $pageData['relTabs'][] = array( - 'file' => 'item', - 'data' => $mounts->getListviewData(), - 'params' => array( - 'id' => 'mounts', - 'name' => '$LANG.tab_mounts', - 'tabs' => '$tabsRelated', - 'hiddenCols' => "$['slot', 'type']" - ) - ); + $racials = new SpellList($conditions); + if (!$racials->error) + { + $this->extendGlobalData($racials->getJSGlobals()); + $this->lvData[] = array( + 'file' => 'spell', + 'data' => $racials->getListviewData(), + 'params' => array( + 'id' => 'racial-traits', + 'name' => '$LANG.tab_racialtraits', + 'hiddenCols' => "$['reagents']", + 'tabs' => '$tabsRelated' + ) + ); + } - $smarty->saveCache($cacheKeyPage, $pageData); + // Quests + $conditions = array( + ['reqRaceMask', $_mask, '&'], + [['reqRaceMask', RACE_MASK_HORDE, '&'], RACE_MASK_HORDE, '!'], + [['reqRaceMask', RACE_MASK_ALLIANCE, '&'], RACE_MASK_ALLIANCE, '!'] + ); + + $quests = new QuestList($conditions); + if (!$quests->error) + { + $this->extendGlobalData($quests->getJSGlobals()); + $this->lvData[] = array( + 'file' => 'quest', + 'data' => $quests->getListviewData(), + 'params' => array( + 'tabs' => '$tabsRelated' + ) + ); + } + + // Mounts + // ok, this sucks, but i rather hardcode the trainer, than fetch items by namepart + $items = isset($mountVendors[$this->typeId]) ? DB::Aowow()->selectCol('SELECT item FROM npc_vendor WHERE entry IN (?a)', $mountVendors[$this->typeId]) : 0; + + $conditions = array( + ['i.id', $items], + ['i.class', ITEM_CLASS_MISC], + ['i.subClass', 5], // mounts + ); + + $mounts = new ItemList($conditions); + if (!$mounts->error) + { + $this->extendGlobalData($mounts->getJSGlobals()); + $this->lvData[] = array( + 'file' => 'item', + 'data' => $mounts->getListviewData(), + 'params' => array( + 'id' => 'mounts', + 'name' => '$LANG.tab_mounts', + 'tabs' => '$tabsRelated', + 'hiddenCols' => "$['slot', 'type']" + ) + ); + } + } } -$smarty->updatePageVars($pageData['page']); -$smarty->assign('community', CommunityContent::getAll(TYPE_RACE, $_id)); // comments, screenshots, videos -$smarty->assign('lang', Lang::$main); -$smarty->assign('lvData', $pageData['relTabs']); - -// load the page -$smarty->display('detail-page-generic.tpl'); - ?> diff --git a/pages/races.php b/pages/races.php index b7c08e4d..39fb0828 100644 --- a/pages/races.php +++ b/pages/races.php @@ -4,38 +4,44 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -$cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_RACE, -1, -1, User::$localeId]); - -if (!$smarty->loadCache($cacheKey, $pageData)) +// menuId 13: Race g_initPath() +// tabId 0: Database g_initHeader() +class RacesPage extends GenericPage { - $races = new CharRaceList(array(['side', 0, '!'])); // only playable + use ListPage; - // menuId 13: Race g_initPath() - // tabId 0: Database g_initHeader() - $pageData = array( - 'page' => array( - 'title' => Util::ucFirst(Lang::$game['races']), - 'path' => "[0, 13]", - 'tab' => 0 - ), - 'lv' => array( - array( + protected $type = TYPE_CLASS; + protected $tpl = 'list-page-generic'; + protected $path = [0, 13]; + protected $tabId = 0; + protected $mode = CACHETYPE_PAGE; + + public function __construct() + { + $this->name = Util::ucFirst(Lang::$game['races']); + + parent::__construct(); + } + + protected function generateContent() + { + $races = new CharRaceList(array(['side', 0, '!'])); + if (!$races->error) + { + $this->lvData[] = array( 'file' => 'race', 'data' => $races->getListviewData(), 'params' => [] - ) - ) - ); + ); + } + } - $smarty->saveCache($cacheKey, $pageData); + protected function generateTitle() + { + array_unshift($this->title, Util::ucFirst(Lang::$game['races'])); + } + + protected function generatePath() {} } - -$smarty->updatePageVars($pageData['page']); -$smarty->assign('lang', Lang::$main); -$smarty->assign('lvData', $pageData['lv']); - -// load the page -$smarty->display('list-page-generic.tpl'); - ?> diff --git a/static/js/global.js b/static/js/global.js index 039c6ecb..fdd6517d 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -11131,7 +11131,8 @@ Listview.templates = { buff = 'coexist'; // without condition break; case 2: - buff2 = '(from same caster)'; + case 4: + buff2 = spell.stackRule == 2 ? '(from same caster)' : '(strongest effect is applied)'; case 1: buff = 'exclusive'; // without condition break; diff --git a/template/bricks/rewards.tpl.php b/template/bricks/rewards.tpl.php index 3ca9aaeb..35930ade 100644 --- a/template/bricks/rewards.tpl.php +++ b/template/bricks/rewards.tpl.php @@ -31,4 +31,4 @@ if ($this->rewards['data']): //]]> \ No newline at end of file +?> diff --git a/template/globals/class.tpl.php b/template/globals/class.tpl.php index b7a61c4b..d90c6c7b 100644 --- a/template/globals/class.tpl.php +++ b/template/globals/class.tpl.php @@ -1,5 +1,4 @@ var _ = g_classes; -{strip} $data): echo '_['.$id.']={name_'.User::$localeString.':\''.Util::jsEscape($data['name']).'\'};'; diff --git a/template/globals/creature.tpl.php b/template/globals/creature.tpl.php index 25881314..94c69a14 100644 --- a/template/globals/creature.tpl.php +++ b/template/globals/creature.tpl.php @@ -1,5 +1,4 @@ var _ = g_npcs; -{strip} $data): echo '_['.$id.']={name_'.User::$localeString.':\''.Util::jsEscape($data['name']).'\'};'; diff --git a/template/globals/event.tpl.php b/template/globals/event.tpl.php index bbaffbb5..b619292e 100644 --- a/template/globals/event.tpl.php +++ b/template/globals/event.tpl.php @@ -1,5 +1,4 @@ var _ = g_holidays; -{strip} $data): echo '_['.$id.']={' . diff --git a/template/globals/faction.tpl.php b/template/globals/faction.tpl.php index a378779a..0d81db04 100644 --- a/template/globals/faction.tpl.php +++ b/template/globals/faction.tpl.php @@ -1,5 +1,4 @@ var _ = g_factions; -{strip} $data): echo '_['.$id.']={name_'.User::$localeString.':\''.Util::jsEscape($data['name']).'\'};'; diff --git a/template/listviews/character.tpl.php b/template/listviews/character.tpl.php index 796805ac..7defc165 100644 --- a/template/listviews/character.tpl.php +++ b/template/listviews/character.tpl.php @@ -24,4 +24,3 @@ "pinned":0 } ]); -{/strip} \ No newline at end of file diff --git a/template/listviews/item.tpl.php b/template/listviews/item.tpl.php index c1334084..516d360a 100644 --- a/template/listviews/item.tpl.php +++ b/template/listviews/item.tpl.php @@ -75,4 +75,4 @@ new Listview({ // } // ] // }); -?> \ No newline at end of file +?> diff --git a/template/pages/detail-page-generic.tpl.php b/template/pages/detail-page-generic.tpl.php index 5d97f787..0f7bcb05 100644 --- a/template/pages/detail-page-generic.tpl.php +++ b/template/pages/detail-page-generic.tpl.php @@ -23,7 +23,7 @@ $this->brick('redButtons'); ?> -