diff --git a/pages/race.php b/endpoints/race/race.php similarity index 52% rename from pages/race.php rename to endpoints/race/race.php index eca3f5b0..2134bedc 100644 --- a/pages/race.php +++ b/endpoints/race/race.php @@ -6,76 +6,92 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -// menuId 13: Race g_initPath() -// tabId 0: Database g_initHeader() -class RacePage extends GenericPage +class RaceBaseResponse extends TemplateResponse implements ICache { - use TrDetailPage; + use TrDetailPage, TrCache; - protected $type = Type::CHR_RACE; - protected $typeId = 0; - protected $tpl = 'detail-page-generic'; - protected $path = [0, 13]; - protected $tabId = 0; - protected $mode = CACHE_TYPE_PAGE; - protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; + private const MOUNT_VENDORS = 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] + ); - public function __construct($pageCall, $id) + protected int $cacheType = CACHE_TYPE_PAGE; + + protected string $template = 'detail-page-generic'; + protected string $pageName = 'race'; + protected ?int $activeTab = parent::TAB_DATABASE; + protected array $breadcrumb = [0, 13]; + + protected array $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; + + public int $type = Type::CHR_RACE; + public int $typeId = 0; + public ?string $expansion = null; + + private CharRaceList $subject; + + public function __construct(string $id) { - parent::__construct($pageCall, $id); + parent::__construct($id); - $this->typeId = intVal($id); + $this->typeId = intVal($id); + $this->contribute = Type::getClassAttrib($this->type, 'contribute') ?? CONTRIBUTE_NONE; + } + protected function generate() : void + { $this->subject = new CharRaceList(array(['id', $this->typeId])); if ($this->subject->error) - $this->notFound(Lang::game('race'), Lang::race('notFound')); + $this->generateNotFound(Lang::game('race'), Lang::race('notFound')); - $this->name = $this->subject->getField('name', true); - } + $this->h1 = $this->subject->getField('name', true); - protected function generatePath() - { - $this->path[] = $this->typeId; - } - - protected function generateTitle() - { - array_unshift($this->title, $this->subject->getField('name', true), Util::ucFirst(Lang::game('class'))); - } - - protected function generateContent() - { - $infobox = []; - $ra = ChrRace::from($this->typeId); - $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] + $this->gPageInfo += array( + 'type' => $this->type, + 'typeId' => $this->typeId, + 'name' => $this->h1 ); + + /*************/ + /* Menu Path */ + /*************/ + + $this->breadcrumb[] = $this->typeId; + + + /**************/ + /* Page Title */ + /**************/ + + array_unshift($this->title, $this->h1, Util::ucFirst(Lang::game('race'))); + + /***********/ /* Infobox */ /***********/ + $ra = ChrRace::from($this->typeId); + $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); // side if ($_ = $this->subject->getField('side')) - $infobox[] = Lang::main('side').Lang::main('colon').'[span class=icon-'.($_ == SIDE_HORDE ? 'horde' : 'alliance').']'.Lang::game('si', $_).'[/span]'; + $infobox[] = Lang::main('side').'[span class=icon-'.($_ == SIDE_HORDE ? 'horde' : 'alliance').']'.Lang::game('si', $_).'[/span]'; // faction if ($_ = $this->subject->getField('factionId')) { - $fac = new FactionList(array(['f.id', $_])); - $this->extendGlobalData($fac->getJSGlobals()); - $infobox[] = Util::ucFirst(Lang::game('faction')).Lang::main('colon').'[faction='.$fac->id.']'; + $this->extendGlobalIds(Type::FACTION, $_); + $infobox[] = Util::ucFirst(Lang::game('faction')).Lang::main('colon').'[faction='.$_.']'; } // leader if ($_ = $this->subject->getField('leader')) { $this->extendGlobalIds(Type::NPC, $_); - $infobox[] = Lang::race('racialLeader').Lang::main('colon').'[npc='.$_.']'; + $infobox[] = Lang::race('racialLeader').'[npc='.$_.']'; } // start area @@ -85,12 +101,14 @@ class RacePage extends GenericPage $infobox[] = Lang::race('startZone').Lang::main('colon').'[zone='.$_.']'; } + if ($infobox) + $this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF, 'dbpage' => true], 'infobox-contents0'); + /****************/ /* Main Content */ /****************/ - $this->infobox = '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]'; $this->expansion = Util::$expansionString[$this->subject->getField('expansion')]; $this->headIcons = ['race_'.$ra->json().'_male', 'race_'.$ra->json().'_female']; $this->redButtons = array( @@ -103,12 +121,14 @@ class RacePage extends GenericPage /* Extra Tabs */ /**************/ + $this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true); + // Classes $classes = new CharClassList(array(['racemask', $ra->toMask(), '&'])); if (!$classes->error) { $this->extendGlobalData($classes->getJSGlobals()); - $this->lvTabs[] = [CharClassList::$brickFile, ['data' => array_values($classes->getListviewData())]]; + $this->lvTabs->addListviewTab(new Listview(['data' => $classes->getListviewData()], CharClassList::$brickFile)); } // Tongues @@ -121,12 +141,12 @@ class RacePage extends GenericPage if (!$tongues->error) { $this->extendGlobalData($tongues->getJSGlobals()); - $this->lvTabs[] = [SpellList::$brickFile, array( - 'data' => array_values($tongues->getListviewData()), + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $tongues->getListviewData(), 'id' => 'languages', 'name' => '$LANG.tab_languages', 'hiddenCols' => ['reagents'] - )]; + ), SpellList::$brickFile)); } // Racials @@ -140,16 +160,15 @@ class RacePage extends GenericPage { $this->extendGlobalData($racials->getJSGlobals()); $tabData = array( - 'data' => array_values($racials->getListviewData()), + 'data' => $racials->getListviewData(), 'id' => 'racial-traits', 'name' => '$LANG.tab_racialtraits', 'hiddenCols' => ['reagents'] ); - if ($racials->hasDiffFields('reqClassMask')) $tabData['visibleCols'] = ['classes']; - $this->lvTabs[] = [SpellList::$brickFile, $tabData]; + $this->lvTabs->addListviewTab(new Listview($tabData, SpellList::$brickFile)); } // Quests @@ -163,29 +182,33 @@ class RacePage extends GenericPage if (!$quests->error) { $this->extendGlobalData($quests->getJSGlobals()); - $this->lvTabs[] = [QuestList::$brickFile, ['data' => array_values($quests->getListviewData())]]; + $this->lvTabs->addListviewTab(new Listview(['data' => $quests->getListviewData()], QuestList::$brickFile)); } // Mounts // ok, this sucks, but i rather hardcode the trainer, than fetch items by namepart - $items = isset($mountVendors[$this->typeId]) ? DB::World()->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) + if (isset(self::MOUNT_VENDORS[$this->typeId])) { - $this->extendGlobalData($mounts->getJSGlobals()); - $this->lvTabs[] = [ItemList::$brickFile, array( - 'data' => array_values($mounts->getListviewData()), - 'id' => 'mounts', - 'name' => '$LANG.tab_mounts', - 'hiddenCols' => ['slot', 'type'] - )]; + if ($items = DB::World()->selectCol('SELECT `item` FROM npc_vendor WHERE `entry` IN (?a)', self::MOUNT_VENDORS[$this->typeId])) + { + $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->lvTabs->addListviewTab(new Listview(array( + 'data' => $mounts->getListviewData(), + 'id' => 'mounts', + 'name' => '$LANG.tab_mounts', + 'hiddenCols' => ['slot', 'type'] + ), ItemList::$brickFile)); + } + } } // Sounds @@ -199,10 +222,10 @@ class RacePage extends GenericPage foreach ($data as $id => &$d) $d['gender'] = $vo[$id]; - $this->lvTabs[] = [SoundList::$brickFile, array( - 'data' => array_values($data), + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $data, 'extraCols' => ['$Listview.templates.title.columns[1]'] - )]; + ), SoundList::$brickFile)); } } @@ -212,8 +235,10 @@ class RacePage extends GenericPage if ($tab = $cnd->toListviewTab('condition-for', '$LANG.tab_condition_for')) { $this->extendGlobalData($cnd->getJsGlobals()); - $this->lvTabs[] = $tab; + $this->lvTabs->addDataTab(...$tab); } + + parent::generate(); } } diff --git a/endpoints/races/races.php b/endpoints/races/races.php new file mode 100644 index 00000000..e5c67324 --- /dev/null +++ b/endpoints/races/races.php @@ -0,0 +1,52 @@ +getCategoryFromUrl($pageParam); + + parent::__construct($pageParam); + } + + protected function generate() : void + { + $this->h1 = Util::ucFirst(Lang::game('races')); + + + array_unshift($this->title, $this->h1); + + + $this->redButtons[BUTTON_WOWHEAD] = true; + + $conditions = []; + if (!User::isInGroup(U_GROUP_EMPLOYEE)) + $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; + + $this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]); + + $races = new CharRaceList($conditions); + if (!$races->error) + $this->lvTabs->addListviewTab(new Listview(['data' => $races->getListviewData()], CharRaceList::$brickFile)); + + parent::generate(); + } +} + +?> diff --git a/localization/locale_dede.php b/localization/locale_dede.php index dda00253..bc1da2fb 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -1175,7 +1175,7 @@ $lang = array( ), 'race' => array( 'notFound' => "Dieses Volk existiert nicht.", - 'racialLeader' => "Volksanführer", + 'racialLeader' => "Volksanführer: ", 'startZone' => "Startgebiet", ), 'maps' => array( diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 1884ddbe..83038634 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -1175,7 +1175,7 @@ $lang = array( ), 'race' => array( 'notFound' => "This race doesn't exist.", - 'racialLeader' => "Racial leader", + 'racialLeader' => "Racial leader: ", 'startZone' => "Starting zone", ), 'maps' => array( diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 40954459..2859056e 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -1175,7 +1175,7 @@ $lang = array( ), 'race' => array( 'notFound' => "Esta raza no existe.", - 'racialLeader' => "Lider racial", + 'racialLeader' => "Lider racial: ", 'startZone' => "Zona de inicio", ), 'maps' => array( diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 3a5745ba..761c271a 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -1175,7 +1175,7 @@ $lang = array( ), 'race' => array( 'notFound' => "Cette race n'existe pas.", - 'racialLeader' => "Leader racial", + 'racialLeader' => "Leader racial : ", 'startZone' => "Zone initiales", ), 'maps' => array( diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 885e45d8..3009a5d3 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -1175,7 +1175,7 @@ $lang = array( ), 'race' => array( 'notFound' => "Такая раса не существует.", - 'racialLeader' => "Лидер расы", + 'racialLeader' => "Лидер расы: ", 'startZone' => "Начальная локация", ), 'maps' => array( diff --git a/localization/locale_zhcn.php b/localization/locale_zhcn.php index ec659bbf..a6b92f10 100644 --- a/localization/locale_zhcn.php +++ b/localization/locale_zhcn.php @@ -1174,7 +1174,7 @@ $lang = array( ), 'race' => array( 'notFound' => "这个种族不存在。", - 'racialLeader' => "种族领袖", + 'racialLeader' => "种族领袖:", 'startZone' => "起始区域" ), 'maps' => array( diff --git a/pages/races.php b/pages/races.php deleted file mode 100644 index 1f3d5d6f..00000000 --- a/pages/races.php +++ /dev/null @@ -1,51 +0,0 @@ -name = Util::ucFirst(Lang::game('races')); - } - - protected function generateContent() - { - $conditions = []; - - if (!User::isInGroup(U_GROUP_EMPLOYEE)) - $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; - - $data = []; - $races = new CharRaceList($conditions); - if (!$races->error) - $data = array_values($races->getListviewData()); - - $this->lvTabs[] = [CharRaceList::$brickFile, ['data' => $data]]; - } - - protected function generateTitle() - { - array_unshift($this->title, Util::ucFirst(Lang::game('races'))); - } - - protected function generatePath() {} -} - -?>