diff --git a/pages/sound.php b/endpoints/sound/sound.php similarity index 72% rename from pages/sound.php rename to endpoints/sound/sound.php index c90a0a69..6207cf2a 100644 --- a/pages/sound.php +++ b/endpoints/sound/sound.php @@ -6,97 +6,82 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -// menuId 19: Sound g_initPath() -// tabId 0: Database g_initHeader() -class SoundPage extends GenericPage +class SoundBaseResponse extends TemplateResponse implements ICache { - use TrDetailPage; + use TrDetailPage, TrCache; - protected $type = Type::SOUND; - protected $typeId = 0; - protected $tpl = 'sound'; - protected $path = [0, 19]; - protected $tabId = 0; - protected $mode = CACHE_TYPE_PAGE; + protected int $cacheType = CACHE_TYPE_PAGE; - protected $special = false; - protected $_get = ['playlist' => ['filter' => FILTER_CALLBACK, 'options' => 'Aowow\GenericPage::checkEmptySet']]; + protected string $template = 'sound'; + protected string $pageName = 'sound'; + protected ?int $activeTab = parent::TAB_DATABASE; + protected array $breadcrumb = [0, 19]; - private $cat = 0; + public int $type = Type::SOUND; + public int $typeId = 0; - public function __construct($pageCall, $id) + private SoundList $subject; + + public function __construct(string $id) { - parent::__construct($pageCall, $id); + parent::__construct($id); - // special case - if (!$id && $this->_get['playlist']) - { - $this->special = true; - $this->name = Lang::sound('cat', 1000); - $this->cat = 1000; - $this->articleUrl = 'sound&playlist'; - $this->contribute = CONTRIBUTE_NONE; - $this->mode = CACHE_TYPE_NONE; - } - // regular case - else - { - $this->typeId = intVal($id); - - $this->subject = new SoundList(array(['id', $this->typeId])); - if ($this->subject->error) - $this->notFound(Lang::game('sound'), Lang::sound('notFound')); - - $this->name = $this->subject->getField('name'); - $this->cat = $this->subject->getField('cat'); - } + $this->typeId = intVal($id); + $this->contribute = Type::getClassAttrib($this->type, 'contribute') ?? CONTRIBUTE_NONE; } - protected function generatePath() + protected function generate() : void { - $this->path[] = $this->cat; - } + $this->subject = new SoundList(array(['id', $this->typeId])); + if ($this->subject->error) + $this->generateNotFound(Lang::game('sound'), Lang::sound('notFound')); - protected function generateTitle() - { - array_unshift($this->title, $this->name, Util::ucFirst(Lang::game('sound'))); - } + $this->h1 = $this->subject->getField('name'); - protected function generateContent() - { - if ($this->special) - $this->generatePlaylistContent(); - else - $this->generateDefaultContent(); - } + $this->gPageInfo += array( + 'type' => $this->type, + 'typeId' => $this->typeId, + 'name' => $this->h1 + ); - private function generatePlaylistContent() - { + $_cat = $this->subject->getField('cat'); + + + /*************/ + /* Menu Path */ + /*************/ + + $this->breadcrumb[] = $_cat; + + + /**************/ + /* Page Title */ + /**************/ + + array_unshift($this->title, $this->h1, Util::ucFirst(Lang::game('sound'))); - } - private function generateDefaultContent() - { /****************/ /* Main Content */ /****************/ - $this->addScript([SC_JS_FILE, '?data=zones']); - // get spawns - $map = null; if ($spawns = $this->subject->getSpawns(SPAWNINFO_FULL)) { - $map = ['data' => ['parent' => 'mapper-generic'], 'mapperData' => &$spawns, 'foundIn' => Lang::sound('foundIn')]; - foreach ($spawns as $areaId => &$areaData) - $map['extra'][$areaId] = ZoneList::getName($areaId); + $this->addDataLoader('zones'); + $this->map = array( + ['parent' => 'mapper-generic'], // Mapper + $spawns, // mapperData + null, // ShowOnMap + [Lang::sound('foundIn')] // foundIn + ); + foreach ($spawns as $areaId => $__) + $this->map[3][$areaId] = ZoneList::getName($areaId); } - // get full path ingame for sound (workaround for missing PlaySoundKit()) + // get full path in-game for sound (workaround for missing PlaySoundKit()) $fullpath = DB::Aowow()->selectCell('SELECT IF(sf.`path` <> "", CONCAT(sf.`path`, "\\\\", sf.`file`), sf.`file`) FROM ?_sounds_files sf JOIN ?_sounds s ON s.`soundFile1` = sf.`id` WHERE s.`id` = ?d', $this->typeId); - $this->map = $map; - $this->headIcons = [$this->subject->getField('iconString')]; $this->redButtons = array( BUTTON_WOWHEAD => true, BUTTON_PLAYLIST => true, @@ -109,11 +94,15 @@ class SoundPage extends GenericPage $this->extendGlobalData($this->subject->getJSGlobals()); + parent::generate(); + /**************/ /* Extra Tabs */ /**************/ + $this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"], 'tabsRelated', true); + // tab: Spells // skipping (always empty): ready, castertargeting, casterstate, targetstate $displayIds = DB::Aowow()->selectCol( @@ -134,9 +123,9 @@ class SoundPage extends GenericPage $cnd = array( 'OR', - ['AND', ['effect1Id', 132], ['effect1MiscValue', $this->typeId]], - ['AND', ['effect2Id', 132], ['effect2MiscValue', $this->typeId]], - ['AND', ['effect3Id', 132], ['effect3MiscValue', $this->typeId]] + ['AND', ['effect1Id', [SPELL_EFFECT_PLAY_MUSIC, SPELL_EFFECT_PLAY_SOUND]], ['effect1MiscValue', $this->typeId]], + ['AND', ['effect2Id', [SPELL_EFFECT_PLAY_MUSIC, SPELL_EFFECT_PLAY_SOUND]], ['effect2MiscValue', $this->typeId]], + ['AND', ['effect3Id', [SPELL_EFFECT_PLAY_MUSIC, SPELL_EFFECT_PLAY_SOUND]], ['effect3MiscValue', $this->typeId]] ); if ($displayIds) @@ -145,19 +134,18 @@ class SoundPage extends GenericPage if ($seMiscValues) $cnd[] = array( 'OR', - ['AND', ['effect1AuraId', 260], ['effect1MiscValue', $seMiscValues]], - ['AND', ['effect2AuraId', 260], ['effect2MiscValue', $seMiscValues]], - ['AND', ['effect3AuraId', 260], ['effect3MiscValue', $seMiscValues]] + ['AND', ['effect1AuraId', SPELL_AURA_SCREEN_EFFECT], ['effect1MiscValue', $seMiscValues]], + ['AND', ['effect2AuraId', SPELL_AURA_SCREEN_EFFECT], ['effect2MiscValue', $seMiscValues]], + ['AND', ['effect3AuraId', SPELL_AURA_SCREEN_EFFECT], ['effect3MiscValue', $seMiscValues]] ); $spells = new SpellList($cnd); if (!$spells->error) { $this->extendGlobalData($spells->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = [SpellList::$brickFile, ['data' => array_values($spells->getListviewData())]]; + $this->lvTabs->addListviewTab(new Listview(['data' => $spells->getListviewData()], SpellList::$brickFile)); } - // tab: Items $subClasses = []; if ($subClassMask = DB::Aowow()->selectCell('SELECT `subClassMask` FROM ?_items_sounds WHERE `soundId` = ?d', $this->typeId)) @@ -179,11 +167,10 @@ class SoundPage extends GenericPage if (!$items->error) { $this->extendGlobalData($items->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = [ItemList::$brickFile, ['data' => array_values($items->getListviewData())]]; + $this->lvTabs->addListviewTab(new Listview(['data' => $items->getListviewData()], ItemList::$brickFile)); } } - // tab: Zones if ($zoneIds = DB::Aowow()->select('SELECT `id`, `worldStateId`, `worldStateValue` FROM ?_zones_sounds WHERE `ambienceDay` = ?d OR `ambienceNight` = ?d OR `musicDay` = ?d OR `musicNight` = ?d OR `intro` = ?d', $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId)) { @@ -240,14 +227,13 @@ class SoundPage extends GenericPage } } - $tabData['data'] = array_values($zoneData); + $tabData['data'] = $zoneData; $tabData['hiddenCols'] = ['territory']; - $this->lvTabs[] = [ZoneList::$brickFile, $tabData]; + $this->lvTabs->addListviewTab(new Listview($tabData, ZoneList::$brickFile)); } } - // tab: Races (VocalUISounds (containing error voice overs)) if ($vo = DB::Aowow()->selectCol('SELECT `raceId` FROM ?_races_sounds WHERE `soundId` = ?d GROUP BY `raceId`', $this->typeId)) { @@ -255,11 +241,10 @@ class SoundPage extends GenericPage if (!$races->error) { $this->extendGlobalData($races->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = [CharRaceList::$brickFile, ['data' => array_values($races->getListviewData())]]; + $this->lvTabs->addListviewTab(new Listview(['data' => $races->getListviewData()], CharRaceList::$brickFile)); } } - // tab: Emotes (EmotesTextSound (containing emote audio)) if ($em = DB::Aowow()->selectCol('SELECT `emoteId` FROM ?_emotes_sounds WHERE `soundId` = ?d GROUP BY `emoteId` UNION SELECT `id` FROM ?_emotes WHERE `soundId` = ?d', $this->typeId, $this->typeId)) { @@ -267,10 +252,10 @@ class SoundPage extends GenericPage if (!$races->error) { $this->extendGlobalData($races->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = [EmoteList::$brickFile, array( - 'data' => array_values($races->getListviewData()), + $this->lvTabs->addListviewTab(new Listview(array( + 'data' => $races->getListviewData(), 'name' => Util::ucFirst(Lang::game('emotes')) - ), 'emote']; + ), EmoteList::$brickFile, 'emote')); } } @@ -289,7 +274,7 @@ class SoundPage extends GenericPage `injury` = ?d OR `injurycritical` = ?d OR `death` = ?d OR `stun` = ?d OR `stand` = ?d OR `aggro` = ?d OR `wingflap` = ?d OR `wingglide` = ?d OR `alert` = ?d OR `fidget` = ?d OR `customattack` = ?d OR `loop` = ?d OR `jumpstart` = ?d OR `jumpend` = ?d OR `petattack` = ?d OR - `petorder` = ?d OR `petdismiss` = ?d OR `birth` = ?d OR `spellcast` = ?d OR `submerge` = ?d OR `submerged` = ?d', + `petorder` = ?d OR `petdismiss` = ?d OR `birth` = ?d OR `spellcast` = ?d OR `submerge` = ?d OR `submerged` = ?d', $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, $this->typeId, @@ -319,10 +304,10 @@ class SoundPage extends GenericPage $npcs = new CreatureList($cnds); if (!$npcs->error) { - $this->addScript([SC_JS_FILE, '?data=zones']); - $this->extendGlobalData($npcs->getJSGlobals(GLOBALINFO_SELF)); - $this->lvTabs[] = [CreatureList::$brickFile, ['data' => array_values($npcs->getListviewData())]]; + + $this->addDataLoader('zones'); + $this->lvTabs->addListviewTab(new Listview(['data' => $npcs->getListviewData()], CreatureList::$brickFile)); } } } diff --git a/endpoints/sound/sound_playlist.php b/endpoints/sound/sound_playlist.php new file mode 100644 index 00000000..334117ae --- /dev/null +++ b/endpoints/sound/sound_playlist.php @@ -0,0 +1,26 @@ +h1 = Lang::sound('cat', 1000); + + array_unshift($this->title, $this->h1, Util::ucFirst(Lang::game('sound'))); + + parent::generate(); + } +} + +?> diff --git a/endpoints/sounds/sounds.php b/endpoints/sounds/sounds.php new file mode 100644 index 00000000..3ed6eaa6 --- /dev/null +++ b/endpoints/sounds/sounds.php @@ -0,0 +1,117 @@ + ['filter' => FILTER_VALIDATE_REGEXP, 'options' => ['regexp' => Filter::PATTERN_PARAM]] + ); + protected array $validCats = [1, 2, 3, 4, 6, 9, 10, 12, 13, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 50, 52, 53]; + + public function __construct(string $pageParam) + { + $this->getCategoryFromUrl($pageParam); + if ($this->category) + $this->forward('?sounds&filter=ty='.$this->category[0]); + + parent::__construct($pageParam); + + $this->subCat = $pageParam !== '' ? '='.$pageParam : ''; + $this->filter = new SoundListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); + $this->filterError = $this->filter->error; + } + + protected function generate() : void + { + $this->h1 = Util::ucFirst(Lang::game('sounds')); + + $this->filter->evalCriteria(); + + $conditions = []; + + if (!User::isInGroup(U_GROUP_EMPLOYEE)) + $conditions[] = [['cuFlags', CUSTOM_EXCLUDE_FOR_LISTVIEW, '&'], 0]; + + if ($_ = $this->filter->getConditions()) + $conditions[] = $_; + + $this->filterError = $this->filter->error; // maybe the evalX() caused something + + + /**************/ + /* Page Title */ + /**************/ + + $fiForm = $this->filter->values; + + array_unshift($this->title, $this->h1); + if (count($fiForm['ty']) == 1) + array_unshift($this->title, Lang::sound('cat', $fiForm['ty'][0])); + + + /*************/ + /* Menu Path */ + /*************/ + + if (count($fiForm['ty']) == 1) + $this->breadcrumb[] = $fiForm['ty'][0]; + + + /****************/ + /* Main Content */ + /****************/ + + $this->redButtons = array( + BUTTON_WOWHEAD => true, + BUTTON_PLAYLIST => true + ); + if ($fiQuery = $this->filter->buildGETParam()) + $this->wowheadLink .= '&filter='.$fiQuery; + + $tabData = []; + $sounds = new SoundList($conditions, ['calcTotal' => true]); + if (!$sounds->error) + { + $tabData['data'] = $sounds->getListviewData(); + + // create note if search limit was exceeded; overwriting 'note' is intentional + if ($sounds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) + { + $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_soundsfound', $sounds->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); + $tabData['_truncated'] = 1; + } + } + + $this->lvTabs = new Tabs(['parent' => "\$\$WH.ge('tabs-generic')"]); + + $this->lvTabs->addListviewTab(new Listview($tabData, SoundList::$brickFile)); + + parent::generate(); + + $this->setOnCacheLoaded([self::class, 'onBeforeDisplay']); + } + + public static function onBeforeDisplay() + { + // sort for dropdown-menus in filter + Lang::sort('sound', 'cat'); + } +} + +?> diff --git a/pages/sounds.php b/pages/sounds.php deleted file mode 100644 index ea064f36..00000000 --- a/pages/sounds.php +++ /dev/null @@ -1,93 +0,0 @@ - ['filter' => FILTER_UNSAFE_RAW]]; - - public function __construct($pageCall, $pageParam) - { - $this->getCategoryFromUrl($pageParam); - if (isset($this->category[0])) - header('Location: ?sounds&filter=ty='.$this->category[0], true, 302); - - parent::__construct($pageCall, $pageParam); - - $this->filterObj = new SoundListFilter($this->_get['filter'] ?? '', ['parentCats' => $this->category]); - - $this->name = Util::ucFirst(Lang::game('sounds')); - } - - protected function generateContent() - { - $this->redButtons = array( - BUTTON_WOWHEAD => true, - BUTTON_PLAYLIST => true - ); - - $this->filterObj->evalCriteria(); - - $conditions = []; - if ($_ = $this->filterObj->getConditions()) - $conditions[] = $_; - - $tabData = []; - $sounds = new SoundList($conditions, ['calcTotal' => true]); - if (!$sounds->error) - { - $tabData['data'] = array_values($sounds->getListviewData()); - - // create note if search limit was exceeded; overwriting 'note' is intentional - if ($sounds->getMatches() > Cfg::get('SQL_LIMIT_DEFAULT')) - { - $tabData['note'] = sprintf(Util::$tryFilteringString, 'LANG.lvnote_soundsfound', $sounds->getMatches(), Cfg::get('SQL_LIMIT_DEFAULT')); - $tabData['_truncated'] = 1; - } - - if ($this->filterObj->error) - $tabData['_errors'] = 1; - } - $this->lvTabs[] = [SoundList::$brickFile, $tabData]; - } - - protected function postCache() - { - // sort for dropdown-menus - Lang::sort('sound', 'cat'); - } - - protected function generateTitle() - { - array_unshift($this->title, $this->name); - - $form = $this->filterObj->values; - if (count($form['ty']) == 1) - array_unshift($this->title, Lang::sound('cat', $form['ty'][0])); - } - - protected function generatePath() - { - $form = $this->filterObj->values; - if (count($form['ty']) == 1) - $this->path[] = $form['ty'][0]; - } -} - -?> diff --git a/template/pages/sound-playlist.tpl.php b/template/pages/sound-playlist.tpl.php new file mode 100644 index 00000000..1d561627 --- /dev/null +++ b/template/pages/sound-playlist.tpl.php @@ -0,0 +1,68 @@ +brick('header'); +?> +
+
+
+ +brick('announcement'); + + $this->brick('pageTemplate'); +?> + +
+

h1; ?>

+ +brick('markup', ['markup' => $this->article]); ?> + +
+
+ +
+
+
+ +brick('footer'); ?> diff --git a/template/pages/sound.tpl.php b/template/pages/sound.tpl.php index b52e3841..6dbb1a32 100644 --- a/template/pages/sound.tpl.php +++ b/template/pages/sound.tpl.php @@ -1,7 +1,10 @@ - +brick('header'); ?> + use \Aowow\Lang; + $this->brick('header'); +?>
@@ -17,68 +20,19 @@ $this->brick('redButtons'); ?> -

name; ?>

+

h1; ?>

brick('article'); + $this->brick('markup', ['markup' => $this->article]); - if ($this->special): -?> -
-
- -
- -map)): - $this->brick('mapper'); - endif; + $this->brickIf($this->map, 'mapper'); ?>