From 9f1cbc02335a4fcf9da7005d5b83f97b5bc86715 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 11 Apr 2023 13:56:25 +0200 Subject: [PATCH] HTML/Scripts * append a filemtime timestamp to js/css files to work around browser caching after update * shuffle script handling around a bit * also user pages cant have community content * also fix breadcrumbs on items page --- includes/defines.php | 13 ++++-- includes/types/user.class.php | 15 ++++--- pages/account.php | 7 ++- pages/achievement.php | 2 +- pages/achievements.php | 2 +- pages/admin.php | 26 +++++------ pages/areatrigger.php | 2 +- pages/areatriggers.php | 2 +- pages/arenateam.php | 9 ++-- pages/arenateams.php | 8 +++- pages/class.php | 4 +- pages/compare.php | 16 +++---- pages/currency.php | 2 +- pages/enchantments.php | 2 +- pages/event.php | 2 +- pages/faction.php | 2 +- pages/genericPage.class.php | 83 ++++++++++++++++++++++++++++------- pages/guide.php | 62 +++++++++++++------------- pages/guild.php | 9 ++-- pages/guilds.php | 4 +- pages/home.php | 9 ++-- pages/icons.php | 2 +- pages/item.php | 16 +++---- pages/items.php | 12 ++--- pages/itemset.php | 2 +- pages/itemsets.php | 4 +- pages/maps.php | 8 ++-- pages/more.php | 2 +- pages/npc.php | 5 +-- pages/npcs.php | 4 +- pages/object.php | 10 ++--- pages/objects.php | 4 +- pages/pet.php | 4 +- pages/profile.php | 22 +++++----- pages/profiler.php | 9 ++-- pages/profiles.php | 10 +++-- pages/quest.php | 5 +-- pages/quests.php | 2 +- pages/race.php | 2 +- pages/screenshot.php | 3 +- pages/search.php | 4 +- pages/skill.php | 2 +- pages/sound.php | 4 +- pages/sounds.php | 2 +- pages/spell.php | 4 +- pages/spells.php | 2 +- pages/talent.php | 24 +++++----- pages/user.php | 9 ++-- pages/zone.php | 4 +- pages/zones.php | 2 +- template/bricks/head.tpl.php | 31 +++---------- 51 files changed, 275 insertions(+), 220 deletions(-) diff --git a/includes/defines.php b/includes/defines.php index e2673f8e..40d2c0bc 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -35,10 +35,15 @@ define('CACHE_TYPE_XML', 4); // only used by item define('CACHE_MODE_FILECACHE', 0x1); define('CACHE_MODE_MEMCACHED', 0x2); -define ('CSS_FILE', 1); -define ('CSS_STRING', 2); -define ('JS_FILE', 3); -define ('JS_STRING', 4); +define ('SC_CSS_FILE', 1); +define ('SC_CSS_STRING', 2); +define ('SC_JS_FILE', 3); +define ('SC_JS_STRING', 4); +define ('SC_FLAG_PREFIX', 0x01); +define ('SC_FLAG_NO_TIMESTAMP', 0x02); +define ('SC_FLAG_APPEND_LOCALE', 0x04); +define ('SC_FLAG_LOCALIZED', 0x08); + define('SEARCH_TYPE_REGULAR', 0x10000000); define('SEARCH_TYPE_OPEN', 0x20000000); diff --git a/includes/types/user.class.php b/includes/types/user.class.php index 2fbceb18..cc5b1765 100644 --- a/includes/types/user.class.php +++ b/includes/types/user.class.php @@ -6,14 +6,15 @@ if (!defined('AOWOW_REVISION')) class UserList extends BaseType { - public static $type = Type::USER; - public static $brickFile = 'user'; - public static $dataTable = ''; // doesn't have community content + public static $type = Type::USER; + public static $brickFile = 'user'; + public static $dataTable = ''; // doesn't have community content + public static $contribute = CONTRIBUTE_NONE; - public $sources = []; + public $sources = []; - protected $queryBase = 'SELECT *, a.id AS ARRAY_KEY FROM ?_account a'; - protected $queryOpts = array( + protected $queryBase = 'SELECT *, a.id AS ARRAY_KEY FROM ?_account a'; + protected $queryOpts = array( 'a' => [['r']], 'r' => ['j' => ['?_account_reputation r ON r.userId = a.id', true], 's' => ', IFNULL(SUM(r.amount), 0) AS reputation', 'g' => 'a.id'] ); @@ -49,7 +50,7 @@ class UserList extends BaseType // more optional data // sig: markdown formated string (only used in forum?) - // border: seen as null|1|3 .. changes the border around the avatar (i suspect its meaning changed and got decupled from premium-status with the introduction of patron-status) + // border: seen as null|1|3 .. changes the border around the avatar (i suspect its meaning changed and got decupled from premium-status with the introduction of patreon-status) } return [Type::USER => $data]; diff --git a/pages/account.php b/pages/account.php index 589fc067..cf9697de 100644 --- a/pages/account.php +++ b/pages/account.php @@ -8,8 +8,11 @@ if (!defined('AOWOW_REVISION')) class AccountPage extends GenericPage { protected $tpl = 'acc-dashboard'; - protected $js = [[JS_FILE, 'user.js'], [JS_FILE, 'profile.js']]; - protected $css = [[CSS_FILE, 'Profiler.css']]; + protected $scripts = array( + [SC_JS_FILE, 'js/user.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_CSS_FILE, 'css/Profiler.css'] + ); protected $mode = CACHE_TYPE_NONE; protected $category = null; protected $validCats = array( diff --git a/pages/achievement.php b/pages/achievement.php index 6570116b..21891494 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -173,7 +173,7 @@ class AchievementPage extends GenericPage ); if ($reqBook) - $this->addScript([CSS_FILE, 'Book.css']); + $this->addScript([SC_CSS_FILE, 'css/Book.css']); // create rewards if ($foo = $this->subject->getField('rewards')) diff --git a/pages/achievements.php b/pages/achievements.php index 1aa1fdd6..d4e8ef60 100644 --- a/pages/achievements.php +++ b/pages/achievements.php @@ -15,7 +15,7 @@ class AchievementsPage extends GenericPage protected $path = [0, 9]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; diff --git a/pages/admin.php b/pages/admin.php index 46e0f782..57aa1d0c 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -98,13 +98,13 @@ class AdminPage extends GenericPage private function handleConfig() : void { $this->addScript( - [CSS_STRING, '.grid input[type=\'text\'], .grid input[type=\'number\'] { width:250px; text-align:left; }'], - [CSS_STRING, '.grid input[type=\'button\'] { width:65px; padding:2px; }'], - [CSS_STRING, '.grid a.tip { margin:0px 5px; opacity:0.8; }'], - [CSS_STRING, '.grid a.tip:hover { opacity:1; }'], - [CSS_STRING, '.grid tr { height:30px; }'], - [CSS_STRING, '.grid .disabled { opacity:0.4 !important; }'], - [CSS_STRING, '.grid .status { position:absolute; right:5px; }'] + [SC_CSS_STRING, '.grid input[type=\'text\'], .grid input[type=\'number\'] { width:250px; text-align:left; }'], + [SC_CSS_STRING, '.grid input[type=\'button\'] { width:65px; padding:2px; }'], + [SC_CSS_STRING, '.grid a.tip { margin:0px 5px; opacity:0.8; }'], + [SC_CSS_STRING, '.grid a.tip:hover { opacity:1; }'], + [SC_CSS_STRING, '.grid tr { height:30px; }'], + [SC_CSS_STRING, '.grid .disabled { opacity:0.4 !important; }'], + [SC_CSS_STRING, '.grid .status { position:absolute; right:5px; }'] ); $head = ''; @@ -148,7 +148,7 @@ class AdminPage extends GenericPage private function handlePhpInfo() : void { $this->addScript([ - CSS_STRING, "\npre {margin: 0px; font-family: monospace;}\n" . + SC_CSS_STRING, "\npre {margin: 0px; font-family: monospace;}\n" . "td, th { border: 1px solid #000000; vertical-align: baseline;}\n" . ".p {text-align: left;}\n" . ".e {background-color: #ccccff; font-weight: bold; color: #000000;}\n" . @@ -212,9 +212,9 @@ class AdminPage extends GenericPage private function handleScreenshots() : void { $this->addScript( - [JS_FILE, 'screenshot.js'], - [CSS_STRING, '.layout {margin: 0px 25px; max-width: inherit; min-width: 1200px; }'], - [CSS_STRING, '#highlightedRow { background-color: #322C1C; }'] + [SC_JS_FILE, 'js/screenshot.js'], + [SC_CSS_STRING, '.layout {margin: 0px 25px; max-width: inherit; min-width: 1200px; }'], + [SC_CSS_STRING, '#highlightedRow { background-color: #322C1C; }'] ); $ssGetAll = $this->_get['all']; @@ -250,8 +250,8 @@ class AdminPage extends GenericPage private function handleWeightPresets() : void { $this->addScript( - [JS_FILE, 'filters.js'], - [CSS_STRING, '.wt-edit {display:inline-block; vertical-align:top; width:350px;}'] + [SC_JS_FILE, 'js/filters.js'], + [SC_CSS_STRING, '.wt-edit {display:inline-block; vertical-align:top; width:350px;}'] ); $head = $body = ''; diff --git a/pages/areatrigger.php b/pages/areatrigger.php index b5ea1743..c32763a4 100644 --- a/pages/areatrigger.php +++ b/pages/areatrigger.php @@ -45,7 +45,7 @@ class AreaTriggerPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $_type = $this->subject->getField('type'); diff --git a/pages/areatriggers.php b/pages/areatriggers.php index 47d94079..f8b8441b 100644 --- a/pages/areatriggers.php +++ b/pages/areatriggers.php @@ -16,7 +16,7 @@ class AreaTriggersPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $validCats = [0, 1, 2, 3, 4, 5]; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $reqUGroup = U_GROUP_STAFF; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; diff --git a/pages/arenateam.php b/pages/arenateam.php index 8c67667e..a5c76380 100644 --- a/pages/arenateam.php +++ b/pages/arenateam.php @@ -17,8 +17,11 @@ class ArenaTeamPage extends GenericPage protected $tabId = 1; protected $path = [1, 5, 3]; protected $tpl = 'roster'; - protected $js = [[JS_FILE, 'profile_all.js'], [JS_FILE, 'profile.js']]; - protected $css = [[CSS_FILE, 'Profiler.css']]; + protected $scripts = array( + [SC_JS_FILE, 'js/profile_all.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_CSS_FILE, 'css/Profiler.css'] + ); public function __construct($pageCall, $pageParam) { @@ -97,7 +100,7 @@ class ArenaTeamPage extends GenericPage if ($this->doResync) return; - $this->addScript([JS_FILE, '?data=realms.weight-presets&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=realms.weight-presets']); $this->redButtons[BUTTON_RESYNC] = [$this->subjectGUID, 'arena-team']; diff --git a/pages/arenateams.php b/pages/arenateams.php index 4bbb6492..2a0a9f7e 100644 --- a/pages/arenateams.php +++ b/pages/arenateams.php @@ -15,7 +15,11 @@ class ArenaTeamsPage extends GenericPage protected $tabId = 1; protected $path = [1, 5, 3]; protected $tpl = 'arena-teams'; - protected $js = [[JS_FILE, 'filters.js'], [JS_FILE, 'profile_all.js'], [JS_FILE, 'profile.js']]; + protected $scripts = array( + [SC_JS_FILE, 'js/filters.js'], + [SC_JS_FILE, 'js/profile_all.js'], + [SC_JS_FILE, 'js/profile.js'] + ); protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; @@ -57,7 +61,7 @@ class ArenaTeamsPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=realms&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=realms']); $conditions = []; if (!User::isInGroup(U_GROUP_EMPLOYEE)) diff --git a/pages/class.php b/pages/class.php index 45ed32a7..9c5f6276 100644 --- a/pages/class.php +++ b/pages/class.php @@ -16,7 +16,7 @@ class ClassPage extends GenericPage protected $path = [0, 12]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; public function __construct($pageCall, $id) { @@ -43,7 +43,7 @@ class ClassPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $infobox = Lang::getInfoBoxForFlags($this->subject->getField('cuFlags')); $_mask = 1 << ($this->typeId - 1); diff --git a/pages/compare.php b/pages/compare.php index 8dd896f3..80780353 100644 --- a/pages/compare.php +++ b/pages/compare.php @@ -11,14 +11,14 @@ class ComparePage extends GenericPage protected $tabId = 1; protected $path = [1, 3]; protected $mode = CACHE_TYPE_NONE; - protected $js = array( - [JS_FILE, 'profile.js'], - [JS_FILE, 'Draggable.js'], - [JS_FILE, 'filters.js'], - [JS_FILE, 'Summary.js'], - [JS_FILE, 'swfobject.js'], + protected $scripts = array( + [SC_JS_FILE, 'js/profile.js'], + [SC_JS_FILE, 'js/Draggable.js'], + [SC_JS_FILE, 'js/filters.js'], + [SC_JS_FILE, 'js/Summary.js'], + [SC_JS_FILE, 'js/swfobject.js'], + [SC_CSS_FILE, 'css/Summary.css'] ); - protected $css = [[CSS_FILE, 'Summary.css']]; protected $summary = []; protected $cmpItems = []; @@ -44,7 +44,7 @@ class ComparePage extends GenericPage protected function generateContent() { // add conditional js - $this->addScript([JS_FILE, '?data=weight-presets.gems.enchants.itemsets&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=weight-presets.gems.enchants.itemsets']); $this->summary = array( 'template' => 'compare', diff --git a/pages/currency.php b/pages/currency.php index 34f8a40d..34810b9a 100644 --- a/pages/currency.php +++ b/pages/currency.php @@ -50,7 +50,7 @@ class CurrencyPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $_itemId = $this->subject->getField('itemId'); diff --git a/pages/enchantments.php b/pages/enchantments.php index c4a55527..a5329d2d 100644 --- a/pages/enchantments.php +++ b/pages/enchantments.php @@ -15,7 +15,7 @@ class EnchantmentsPage extends GenericPage protected $path = [0, 101]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; diff --git a/pages/event.php b/pages/event.php index 841203c3..6a02d331 100644 --- a/pages/event.php +++ b/pages/event.php @@ -67,7 +67,7 @@ class EventPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); /***********/ /* Infobox */ diff --git a/pages/faction.php b/pages/faction.php index 8fcc114f..016f60fb 100644 --- a/pages/faction.php +++ b/pages/faction.php @@ -48,7 +48,7 @@ class FactionPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); /***********/ /* Infobox */ diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index c7e275a9..3752fd9d 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -181,8 +181,19 @@ class GenericPage protected $name = ''; // for h1-Element protected $tabId = null; protected $gDataKey = false; // adds the dataKey to the user vars - protected $js = []; - protected $css = []; + protected $scripts = array( + [SC_JS_FILE, 'js/jquery-1.12.4.min.js', SC_FLAG_NO_TIMESTAMP], + [SC_JS_FILE, 'js/basic.js' ], + [SC_JS_FILE, 'widgets/power.js', SC_FLAG_NO_TIMESTAMP], + [SC_JS_FILE, 'js/locale_%s.js', SC_FLAG_LOCALIZED ], + [SC_JS_FILE, 'js/global.js' ], + [SC_JS_FILE, 'js/locale.js' ], + [SC_JS_FILE, 'js/Markup.js' ], + [SC_CSS_FILE, 'css/basic.css' ], + [SC_CSS_FILE, 'css/global.css' ], + [SC_CSS_FILE, 'css/aowow.css' ], + [SC_CSS_FILE, 'css/locale_%s.css', SC_FLAG_LOCALIZED ] + ); // private vars don't get cached private $time = 0; @@ -198,6 +209,8 @@ class GenericPage private $memcached = null; private $mysql = ['time' => 0, 'count' => 0]; + private $js = []; + private $css = []; private $headerLogo = ''; private $fullParams = ''; @@ -301,6 +314,16 @@ class GenericPage else if (CFG_MAINTENANCE && User::isInGroup(U_GROUP_EMPLOYEE)) Util::addNote(U_GROUP_EMPLOYEE, 'Maintenance mode enabled!'); + // prep js+css includes + $parentVars = get_class_vars(__CLASS__); + if ($parentVars['scripts'] != $this->scripts) // additions set in child class + $this->scripts = array_merge($parentVars['scripts'], $this->scripts); + + $this->addScript(...$this->scripts); + + if (User::isInGroup(U_GROUP_STAFF | U_GROUP_SCREENSHOT | U_GROUP_VIDEO)) + $this->addScript([SC_CSS_FILE, 'css/staff.css'], [SC_JS_FILE, 'js/staff.js']); + // get errors from previous page from session and apply to template if (method_exists($this, 'applyCCErrors')) $this->applyCCErrors(); @@ -437,33 +460,59 @@ class GenericPage public function addScript(array ...$structs) : void { - foreach ($structs as $s) // iType, sContent, bFront, sIeCnd + array_walk($structs, function(&$x) { $x = array_pad($x, 3, 0); }); + + foreach ($structs as [$type, $str, $flags]) { - if (empty($s[1])) + if (empty($str)) { trigger_error('GenericPage::addScript - content empty', E_USER_WARNING); continue; } - $s = array_pad($s, 4, ''); - switch ($s[0]) + $dynData = strpos($str, '?data=') === 0; + $app = []; + + // insert locale string + if ($flags & SC_FLAG_LOCALIZED) + $str = sprintf($str, User::$localeString); + + if ($dynData) { - case JS_FILE: - case JS_STRING: - if (empty($s[2])) - $this->js[] = $s; + $app[] = 'locale='.User::$localeId; + $app[] = 't='.$_SESSION['dataKey']; + } + else if (($flags & SC_FLAG_APPEND_LOCALE) && User::$localeId) + $app[] = 'lang='.Util::$subDomains[User::$localeId]; + + // append anti-cache timestamp + if (!($flags & SC_FLAG_NO_TIMESTAMP) && !$dynData) + if ($type == SC_JS_FILE || $type == SC_CSS_FILE) + $app[] = filemtime('static/'.$str) ?: 0; + + if ($app) + $str .= ($dynData ? '&' : '?').implode('&', $app); + + switch ($type) + { + case SC_JS_FILE: + $str = ($dynData ? HOST_URL : STATIC_URL).'/'.$str; + case SC_JS_STRING: + if ($flags & SC_FLAG_PREFIX) + array_unshift($this->js, [$type, $str]); else - array_unshift($this->js, $s); + $this->js[] = [$type, $str]; break; - case CSS_FILE: - case CSS_STRING: - if (empty($s[2])) - $this->css[] = $s; + case SC_CSS_FILE: + $str = STATIC_URL.'/'.$str; + case SC_CSS_STRING: + if ($flags & SC_FLAG_PREFIX) + array_unshift($this->css, [$type, $str]); else - array_unshift($this->css, $s); + $this->css[] = [$type, $str]; break; default: - trigger_error('GenericPage::addScript - unknown script type #'.$s[0], E_USER_WARNING); + trigger_error('GenericPage::addScript - unknown script type #'.$type, E_USER_WARNING); } } } diff --git a/pages/guide.php b/pages/guide.php index ab3fb85a..7a05486a 100644 --- a/pages/guide.php +++ b/pages/guide.php @@ -85,7 +85,7 @@ class GuidePage extends GenericPage // main container should be tagged:
// why is this here: is there a mediawiki like diff function for staff? - $this->addScript([CSS_STRING, 'li input[type="radio"] {margin:0}']); + $this->addScript([SC_CSS_STRING, 'li input[type="radio"] {margin:0}']); $this->typeId = $this->_get['id']; // just to display sensible not-found msg if ($id = DB::Aowow()->selectCell('SELECT `id` FROM ?_guides WHERE `id` = ?d', $this->typeId)) @@ -308,7 +308,7 @@ class GuidePage extends GenericPage if ($this->subject->getField('status') == GUIDE_STATUS_REVIEW && User::isInGroup(U_GROUP_STAFF) && $this->_get['rev']) { - $this->addScript([JS_STRING, ' + $this->addScript([SC_JS_STRING, ' DomContentLoaded.addEvent(function() { let send = function (status) { @@ -364,7 +364,7 @@ class GuidePage extends GenericPage private function displayChangelog() : void { - $this->addScript([JS_STRING, ' + $this->addScript([SC_JS_STRING, ' $(document).ready(function() { var radios = $("input[type=radio]"); function limit(col, val) { @@ -419,21 +419,21 @@ class GuidePage extends GenericPage private function initNew() : void { $this->addScript( - [JS_FILE, 'article-description.js'], - [JS_FILE, 'article-editing.js'], - [JS_FILE, 'guide-editing.js'], - [JS_FILE, 'fileuploader.js'], - [JS_FILE, 'toolbar.js'], - [JS_FILE, 'AdjacentPreview.js'], - [CSS_FILE, 'article-editing.css'], - [CSS_FILE, 'fileuploader.css'], - [CSS_FILE, 'guide-edit.css'], - [CSS_FILE, 'AdjacentPreview.css'], + [SC_JS_FILE, 'js/article-description.js'], + [SC_JS_FILE, 'js/article-editing.js'], + [SC_JS_FILE, 'js/guide-editing.js'], + [SC_JS_FILE, 'js/fileuploader.js'], + [SC_JS_FILE, 'js/toolbar.js'], + [SC_JS_FILE, 'js/AdjacentPreview.js'], + [SC_CSS_FILE, 'css/article-editing.css'], + [SC_CSS_FILE, 'css/fileuploader.css'], + [SC_CSS_FILE, 'css/guide-edit.css'], + [SC_CSS_FILE, 'css/AdjacentPreview.css'], - [CSS_STRING, '#upload-result input[type=text] { padding: 0px 2px; font-size: 12px; }'], - [CSS_STRING, '#upload-result > span { display:block; height: 22px; }'], - [CSS_STRING, '#upload-result { display: inline-block; text-align:right; }'], - [CSS_STRING, '#upload-progress { display: inline-block; margin-right:8px; }'] + [SC_CSS_STRING, '#upload-result input[type=text] { padding: 0px 2px; font-size: 12px; }'], + [SC_CSS_STRING, '#upload-result > span { display:block; height: 22px; }'], + [SC_CSS_STRING, '#upload-result { display: inline-block; text-align:right; }'], + [SC_CSS_STRING, '#upload-progress { display: inline-block; margin-right:8px; }'] ); $this->articleUrl = 'new'; @@ -448,21 +448,21 @@ class GuidePage extends GenericPage private function initEdit() : bool { $this->addScript( - [JS_FILE, 'article-description.js'], - [JS_FILE, 'article-editing.js'], - [JS_FILE, 'guide-editing.js'], - [JS_FILE, 'fileuploader.js'], - [JS_FILE, 'toolbar.js'], - [JS_FILE, 'AdjacentPreview.js'], - [CSS_FILE, 'article-editing.css'], - [CSS_FILE, 'fileuploader.css'], - [CSS_FILE, 'guide-edit.css'], - [CSS_FILE, 'AdjacentPreview.css'], + [SC_JS_FILE, 'js/article-description.js'], + [SC_JS_FILE, 'js/article-editing.js'], + [SC_JS_FILE, 'js/guide-editing.js'], + [SC_JS_FILE, 'js/fileuploader.js'], + [SC_JS_FILE, 'js/toolbar.js'], + [SC_JS_FILE, 'js/AdjacentPreview.js'], + [SC_CSS_FILE, 'css/article-editing.css'], + [SC_CSS_FILE, 'css/fileuploader.css'], + [SC_CSS_FILE, 'css/guide-edit.css'], + [SC_CSS_FILE, 'css/AdjacentPreview.css'], - [CSS_STRING, '#upload-result input[type=text] { padding: 0px 2px; font-size: 12px; }'], - [CSS_STRING, '#upload-result > span { display:block; height: 22px; }'], - [CSS_STRING, '#upload-result { display: inline-block; text-align:right; }'], - [CSS_STRING, '#upload-progress { display: inline-block; margin-right:8px; }'] + [SC_CSS_STRING, '#upload-result input[type=text] { padding: 0px 2px; font-size: 12px; }'], + [SC_CSS_STRING, '#upload-result > span { display:block; height: 22px; }'], + [SC_CSS_STRING, '#upload-result { display: inline-block; text-align:right; }'], + [SC_CSS_STRING, '#upload-progress { display: inline-block; margin-right:8px; }'] ); $this->articleUrl = 'edit'; diff --git a/pages/guild.php b/pages/guild.php index 25bd3490..950cdbc5 100644 --- a/pages/guild.php +++ b/pages/guild.php @@ -17,8 +17,11 @@ class GuildPage extends GenericPage protected $tabId = 1; protected $path = [1, 5, 2]; protected $tpl = 'roster'; - protected $js = [[JS_FILE, 'profile_all.js'], [JS_FILE, 'profile.js']]; - protected $css = [[CSS_FILE, 'Profiler.css']]; + protected $scripts = array( + [SC_JS_FILE, 'js/profile_all.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_CSS_FILE, 'css/Profiler.css'] + ); public function __construct($pageCall, $pageParam) { @@ -97,7 +100,7 @@ class GuildPage extends GenericPage if ($this->doResync) return; - $this->addScript([JS_FILE, '?data=realms.weight-presets&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=realms.weight-presets']); $this->redButtons[BUTTON_RESYNC] = [$this->subjectGUID, 'guild']; diff --git a/pages/guilds.php b/pages/guilds.php index 402561b6..070977fb 100644 --- a/pages/guilds.php +++ b/pages/guilds.php @@ -15,7 +15,7 @@ class GuildsPage extends GenericPage protected $tabId = 1; protected $path = [1, 5, 2]; protected $tpl = 'guilds'; - protected $js = [[JS_FILE, 'filters.js'], [JS_FILE, 'profile_all.js'], [JS_FILE, 'profile.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js'], [SC_JS_FILE, 'js/profile_all.js'], [SC_JS_FILE, 'js/profile.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; @@ -57,7 +57,7 @@ class GuildsPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=realms&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=realms']); $conditions = array( ['c.deleteInfos_Account', null], diff --git a/pages/home.php b/pages/home.php index 36b0f4f7..e4e46564 100644 --- a/pages/home.php +++ b/pages/home.php @@ -7,8 +7,11 @@ if (!defined('AOWOW_REVISION')) class HomePage extends GenericPage { protected $tpl = 'home'; - protected $js = [[JS_FILE, 'home.js']]; - protected $css = [[CSS_FILE, 'home.css']]; + protected $scripts = array( + [SC_JS_FILE, 'js/home.js'], + [SC_CSS_FILE, 'css/home.css'], + [SC_CSS_STRING, '.announcement { margin: auto; max-width: 1200px; padding: 0px 15px 15px 15px }'] + ); protected $featuredBox = []; protected $oneliner = ''; @@ -21,8 +24,6 @@ class HomePage extends GenericPage protected function generateContent() { - $this->addScript([CSS_STRING, '.announcement { margin: auto; max-width: 1200px; padding: 0px 15px 15px 15px }']); - // load oneliner if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_home_oneliner WHERE active = 1 LIMIT 1')) $this->oneliner = Util::jsEscape(Util::localizedString($_, 'text')); diff --git a/pages/icons.php b/pages/icons.php index de087fe6..8b17f6bb 100644 --- a/pages/icons.php +++ b/pages/icons.php @@ -15,7 +15,7 @@ class IconsPage extends GenericPage protected $path = [0, 31]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; diff --git a/pages/item.php b/pages/item.php index ac53190b..48c513e3 100644 --- a/pages/item.php +++ b/pages/item.php @@ -17,10 +17,10 @@ class ItemPage extends genericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $enhancedTT = []; - protected $js = array( - [JS_FILE, 'swfobject.js'], // view in 3d, ok - [JS_FILE, 'profile.js'], // item upgrade search, also ok - [JS_FILE, 'filters.js'] // lolwut? + protected $scripts = array( + [SC_JS_FILE, 'js/swfobject.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_JS_FILE, 'js/filters.js'] ); protected $_get = array( @@ -121,7 +121,7 @@ class ItemPage extends genericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=weight-presets.zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=weight-presets.zones']); $_flags = $this->subject->getField('flags'); $_slot = $this->subject->getField('slot'); @@ -348,12 +348,10 @@ class ItemPage extends genericPage // pageText $pageText = []; if ($this->pageText = Game::getPageText($this->subject->getField('pageTextId'))) - { $this->addScript( - [JS_FILE, 'Book.js'], - [CSS_FILE, 'Book.css'] + [SC_JS_FILE, 'js/Book.js'], + [SC_CSS_FILE, 'css/Book.css'] ); - } $this->headIcons = [$this->subject->getField('iconString', true, true), $this->subject->getField('stackable')]; $this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null; diff --git a/pages/items.php b/pages/items.php index 5ef5a882..b565f0d2 100644 --- a/pages/items.php +++ b/pages/items.php @@ -15,7 +15,7 @@ class ItemsPage extends GenericPage protected $path = [0, 0]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'filters.js'], [JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js'], [SC_JS_FILE, 'js/swfobject.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; @@ -96,7 +96,7 @@ class ItemsPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=weight-presets&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=weight-presets']); $conditions = []; @@ -466,10 +466,10 @@ class ItemsPage extends GenericPage // if slot-dropdown is available && Armor && $path points to Armor-Class $form = $this->filterObj->getForm(); - if (count($this->path) == 4 && $this->category[0] == 4 && isset($form['sl']) && !is_array($form['sl'])) - $this->path[] = $form['sl']; - else if (!empty($this->category[0]) && $this->category[0] == 0 && isset($form['ty']) && !is_array($form['ty'])) - $this->path[] = $form['ty']; + if (count($this->path) == 4 && $this->category[0] == 4 && isset($form['sl']) && count($form['sl']) == 1) + $this->path[] = $form['sl'][0]; + else if (isset($this->category[0]) && $this->category[0] == 0 && isset($form['ty']) && count($form['ty']) == 1) + $this->path[] = $form['ty'][0]; } // fetch best possible gems for chosen weights diff --git a/pages/itemset.php b/pages/itemset.php index 786d0149..70ad0a55 100644 --- a/pages/itemset.php +++ b/pages/itemset.php @@ -16,7 +16,7 @@ class ItemsetPage extends GenericPage protected $path = [0, 2]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'swfobject.js'], [JS_FILE, 'Summary.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js'], [SC_JS_FILE, 'js/Summary.js']]; protected $summary = []; diff --git a/pages/itemsets.php b/pages/itemsets.php index af93f910..4f8d9212 100644 --- a/pages/itemsets.php +++ b/pages/itemsets.php @@ -15,7 +15,7 @@ class ItemsetsPage extends GenericPage protected $path = [0, 2]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; @@ -31,7 +31,7 @@ class ItemsetsPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=weight-presets&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=weight-presets']); $conditions = []; diff --git a/pages/maps.php b/pages/maps.php index 2ab00810..c22db698 100644 --- a/pages/maps.php +++ b/pages/maps.php @@ -11,8 +11,10 @@ class MapsPage extends GenericPage protected $tabId = 1; protected $path = [1, 1]; protected $mode = CACHE_TYPE_NONE; - protected $js = [[JS_FILE, 'maps.js']]; - protected $css = [[CSS_STRING, 'zone-picker { margin-left: 4px }']]; + protected $scripts = array( + [SC_JS_FILE, 'js/maps.js'], + [SC_CSS_STRING, 'zone-picker { margin-left: 4px }'] + ); public function __construct($pageCall, $__) { @@ -24,7 +26,7 @@ class MapsPage extends GenericPage protected function generateContent() { // add conditional js - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); } protected function generateTitle() diff --git a/pages/more.php b/pages/more.php index ea1b8532..d072617b 100644 --- a/pages/more.php +++ b/pages/more.php @@ -14,7 +14,7 @@ class MorePage extends GenericPage protected $path = []; protected $tabId = 0; protected $mode = CACHE_TYPE_NONE; - protected $js = [[JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; private $page = []; private $req2priv = array( diff --git a/pages/npc.php b/pages/npc.php index 2b3d8788..19095895 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -16,8 +16,7 @@ class NpcPage extends GenericPage protected $path = [0, 4]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'swfobject.js']]; - protected $css = [[CSS_FILE, 'Profiler.css']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js'], [SC_CSS_FILE, 'css/Profiler.css']]; protected $_get = ['domain' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkDomain']]; @@ -57,7 +56,7 @@ class NpcPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $_typeFlags = $this->subject->getField('typeFlags'); $_altIds = []; diff --git a/pages/npcs.php b/pages/npcs.php index a3ea70de..8d50ade6 100644 --- a/pages/npcs.php +++ b/pages/npcs.php @@ -16,7 +16,7 @@ class NpcsPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $validCats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; @@ -33,7 +33,7 @@ class NpcsPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $conditions = []; diff --git a/pages/object.php b/pages/object.php index 9e31ddc6..0da9d7d9 100644 --- a/pages/object.php +++ b/pages/object.php @@ -16,7 +16,7 @@ class ObjectPage extends GenericPage protected $path = [0, 5]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; protected $_get = ['domain' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkDomain']]; @@ -51,7 +51,7 @@ class ObjectPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); /***********/ /* Infobox */ @@ -214,12 +214,10 @@ class ObjectPage extends GenericPage // pageText if ($this->pageText = Game::getPageText($next = $this->subject->getField('pageTextId'))) - { $this->addScript( - [JS_FILE, 'Book.js'], - [CSS_FILE, 'Book.css'] + [SC_JS_FILE, 'js/Book.js'], + [SC_CSS_FILE, 'css/Book.css'] ); - } // get spawns and path $map = null; diff --git a/pages/objects.php b/pages/objects.php index 028c88de..f0d5e63f 100644 --- a/pages/objects.php +++ b/pages/objects.php @@ -16,7 +16,7 @@ class ObjectsPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $validCats = [-2, -3, -4, -5, -6, 0, 3, 9, 25]; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; @@ -33,7 +33,7 @@ class ObjectsPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $conditions = []; diff --git a/pages/pet.php b/pages/pet.php index 29d68ebf..7d5a16fd 100644 --- a/pages/pet.php +++ b/pages/pet.php @@ -16,7 +16,7 @@ class PetPage extends GenericPage protected $path = [0, 8]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; public function __construct($pageCall, $id) { @@ -43,7 +43,7 @@ class PetPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); /***********/ /* Infobox */ diff --git a/pages/profile.php b/pages/profile.php index fd216101..b0ff28ac 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -18,17 +18,15 @@ class ProfilePage extends GenericPage protected $tabId = 1; protected $path = [1, 5, 1]; protected $tpl = 'profile'; - protected $js = array( - [JS_FILE, 'filters.js'], - [JS_FILE, 'TalentCalc.js'], - [JS_FILE, 'swfobject.js'], - [JS_FILE, 'profile_all.js'], - [JS_FILE, 'profile.js'], - [JS_FILE, 'Profiler.js'] - ); - protected $css = array( - [CSS_FILE, 'talentcalc.css'], - [CSS_FILE, 'Profiler.css'] + protected $scripts = array( + [SC_JS_FILE, 'js/filters.js'], + [SC_JS_FILE, 'js/TalentCalc.js'], + [SC_JS_FILE, 'js/swfobject.js'], + [SC_JS_FILE, 'js/profile_all.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_JS_FILE, 'js/Profiler.js'], + [SC_CSS_FILE, 'css/talentcalc.css'], + [SC_CSS_FILE, 'css/Profiler.css'] ); protected $_get = array( @@ -150,7 +148,7 @@ class ProfilePage extends GenericPage return; // + .titles ? - $this->addScript([JS_FILE, '?data=enchants.gems.glyphs.itemsets.pets.pet-talents.quick-excludes.realms.statistics.weight-presets.achievements&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=enchants.gems.glyphs.itemsets.pets.pet-talents.quick-excludes.realms.statistics.weight-presets.achievements']); // as demanded by the raid activity tracker $bossIds = array( diff --git a/pages/profiler.php b/pages/profiler.php index d6cf5288..aabe7fd6 100644 --- a/pages/profiler.php +++ b/pages/profiler.php @@ -10,8 +10,11 @@ class ProfilerPage extends GenericPage protected $tabId = 1; protected $tpl = 'profiler'; protected $gDataKey = true; - protected $js = [[JS_FILE, 'profile_all.js'], [JS_FILE, 'profile.js']]; - protected $css = [[CSS_FILE, 'Profiler.css']]; + protected $scripts = array( + [SC_JS_FILE, 'js/profile_all.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_CSS_FILE, 'css/Profiler.css'] + ); public function __construct($pageCall, $pageParam) { @@ -23,7 +26,7 @@ class ProfilerPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=realms&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=realms']); } protected function generatePath() { } diff --git a/pages/profiles.php b/pages/profiles.php index 6017fc7b..8382ba89 100644 --- a/pages/profiles.php +++ b/pages/profiles.php @@ -17,8 +17,12 @@ class ProfilesPage extends GenericPage protected $tabId = 1; protected $path = [1, 5, 0]; protected $tpl = 'profiles'; - protected $js = [[JS_FILE, 'filters.js'], [JS_FILE, 'profile_all.js'], [JS_FILE, 'profile.js']]; - protected $css = [[CSS_FILE, 'Profiler.css']]; + protected $scripts = array( + [SC_JS_FILE, 'js/filters.js'], + [SC_JS_FILE, 'js/profile_all.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_CSS_FILE, 'css/Profiler.css'] + ); protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; @@ -62,7 +66,7 @@ class ProfilesPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=weight-presets.realms&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=weight-presets.realms']); $conditions = []; diff --git a/pages/quest.php b/pages/quest.php index fd26b1a7..038b4f8f 100644 --- a/pages/quest.php +++ b/pages/quest.php @@ -16,8 +16,7 @@ class QuestPage extends GenericPage protected $path = [0, 3]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'ShowOnMap.js']]; - protected $css = [[CSS_FILE, 'Book.css']]; + protected $scripts = [[SC_JS_FILE, 'js/ShowOnMap.js'], [SC_CSS_FILE, 'css/Book.css']]; protected $_get = ['domain' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkDomain']]; @@ -570,7 +569,7 @@ class QuestPage extends GenericPage /* Mapper */ /**********/ - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); // gather points of interest $mapNPCs = $mapGOs = []; // [typeId, start|end|objective, startItemId] diff --git a/pages/quests.php b/pages/quests.php index 90738f3a..1319e6a8 100644 --- a/pages/quests.php +++ b/pages/quests.php @@ -15,7 +15,7 @@ class QuestsPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $validCats = []; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; diff --git a/pages/race.php b/pages/race.php index fb369710..cbaa1230 100644 --- a/pages/race.php +++ b/pages/race.php @@ -16,7 +16,7 @@ class RacePage extends GenericPage protected $path = [0, 13]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; public function __construct($pageCall, $id) { diff --git a/pages/screenshot.php b/pages/screenshot.php index c58e6e64..4bda0464 100644 --- a/pages/screenshot.php +++ b/pages/screenshot.php @@ -12,8 +12,7 @@ class ScreenshotPage extends GenericPage const MAX_H = 325; protected $tpl = 'screenshot'; - protected $js = [[JS_FILE, 'Cropper.js']]; - protected $css = [[CSS_FILE, 'Cropper.css']]; + protected $scripts = [[SC_JS_FILE, 'js/Cropper.js'], [SC_CSS_FILE, 'css/Cropper.css']]; protected $reqAuth = true; protected $tabId = 0; diff --git a/pages/search.php b/pages/search.php index 8cc86e8e..111d7001 100644 --- a/pages/search.php +++ b/pages/search.php @@ -30,7 +30,7 @@ class SearchPage extends GenericPage protected $tpl = 'search'; protected $tabId = 0; protected $mode = CACHE_TYPE_SEARCH; - protected $js = [[JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; protected $lvTabs = []; // [file, data, extraInclude, osInfo] // osInfo:[type, appendix, nMatches, param1, param2] protected $forceTabs = true; protected $search = ''; // output @@ -208,7 +208,7 @@ class SearchPage extends GenericPage if ($this->mode == CACHE_TYPE_NONE) // search is invalid return; - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $this->performSearch(); } diff --git a/pages/skill.php b/pages/skill.php index 92b2dcc2..17f5113b 100644 --- a/pages/skill.php +++ b/pages/skill.php @@ -264,7 +264,7 @@ class SkillPage extends GenericPage $list = $spellIds ? DB::World()->selectCol('SELECT cdt.CreatureId FROM creature_default_trainer cdt JOIN trainer_spell ts ON ts.TrainerId = cdt.TrainerId WHERE ts.SpellID IN (?a)', $spellIds) : []; if ($list) { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $trainer = new CreatureList(array(CFG_SQL_LIMIT_NONE, ['ct.id', $list], ['s.guid', NULL, '!'], ['ct.npcflag', 0x10, '&'])); diff --git a/pages/sound.php b/pages/sound.php index fb476401..dfc2ba8e 100644 --- a/pages/sound.php +++ b/pages/sound.php @@ -78,7 +78,7 @@ class SoundPage extends GenericPage /* Main Content */ /****************/ - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); // get spawns $map = null; @@ -331,7 +331,7 @@ class SoundPage extends GenericPage $npcs = new CreatureList($cnds); if (!$npcs->error) { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $this->extendGlobalData($npcs->getJSGlobals(GLOBALINFO_SELF)); $this->lvTabs[] = ['creature', ['data' => array_values($npcs->getListviewData())]]; diff --git a/pages/sounds.php b/pages/sounds.php index d2e76a27..632000bb 100644 --- a/pages/sounds.php +++ b/pages/sounds.php @@ -16,7 +16,7 @@ class SoundsPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $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]; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; diff --git a/pages/spell.php b/pages/spell.php index 3a0a2133..8ad93a93 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -16,7 +16,7 @@ class SpellPage extends GenericPage protected $path = [0, 1]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'swfobject.js']]; + protected $scripts = [[SC_JS_FILE, 'js/swfobject.js']]; protected $_get = ['domain' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkDomain']]; @@ -130,7 +130,7 @@ class SpellPage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); $_cat = $this->subject->getField('typeCat'); diff --git a/pages/spells.php b/pages/spells.php index 779c2b1d..89dc7bd5 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -15,7 +15,7 @@ class SpellsPage extends GenericPage protected $path = [0, 1]; protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; - protected $js = [[JS_FILE, 'filters.js']]; + protected $scripts = [[SC_JS_FILE, 'js/filters.js']]; protected $_get = ['filter' => ['filter' => FILTER_UNSAFE_RAW]]; diff --git a/pages/talent.php b/pages/talent.php index 8ebe3b9f..ec36cf91 100644 --- a/pages/talent.php +++ b/pages/talent.php @@ -12,10 +12,10 @@ class TalentPage extends GenericPage protected $path = [1]; protected $mode = CACHE_TYPE_NONE; protected $gDataKey = true; - protected $js = [[JS_FILE, 'TalentCalc.js']]; - protected $css = array( - [CSS_FILE, 'talentcalc.css'], - [CSS_FILE, 'talent.css'] + protected $scripts = array( + [SC_JS_FILE, 'js/TalentCalc.js'], + [SC_CSS_FILE, 'css/talentcalc.css'], + [SC_CSS_FILE, 'css/talent.css'] ); private $isPetCalc = false; @@ -31,15 +31,17 @@ class TalentPage extends GenericPage protected function generateContent() { // add conditional js & css - $this->addScript( - [JS_FILE, ($this->isPetCalc ? '?data=pet-talents.pets' : '?data=glyphs').'&locale='.User::$localeId.'&t='.$_SESSION['dataKey']], - [JS_FILE, $this->isPetCalc ? 'petcalc.js' : 'talent.js'] - ); - if ($this->isPetCalc) $this->addScript( - [JS_FILE, 'swfobject.js'], - [CSS_FILE, 'petcalc.css'] + [SC_JS_FILE, '?data=pet-talents.pets'], + [SC_JS_FILE, 'js/petcalc.js'], + [SC_JS_FILE, 'js/swfobject.js'], + [SC_CSS_FILE, 'css/petcalc.css'] + ); + else + $this->addScript( + [SC_JS_FILE, '?data=glyphs'], + [SC_JS_FILE, 'js/talent.js'] ); $this->tcType = $this->isPetCalc ? 'pc' : 'tc'; diff --git a/pages/user.php b/pages/user.php index 125454f5..10006f37 100644 --- a/pages/user.php +++ b/pages/user.php @@ -7,8 +7,11 @@ if (!defined('AOWOW_REVISION')) class UserPage extends GenericPage { protected $tpl = 'user'; - protected $js = [[JS_FILE, 'user.js'], [JS_FILE, 'profile.js']]; - protected $css = [[CSS_FILE, 'Profiler.css']]; + protected $scripts = array( + [SC_JS_FILE, 'js/user.js'], + [SC_JS_FILE, 'js/profile.js'], + [SC_CSS_FILE, 'css/Profiler.css'] + ); protected $mode = CACHE_TYPE_NONE; protected $typeId = 0; @@ -237,7 +240,7 @@ class UserPage extends GenericPage $profiles = new LocalProfileList($conditions); if (!$profiles->error) { - $this->addScript([JS_FILE, '?data=weight-presets&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=weight-presets']); // Characters if ($chars = $profiles->getListviewData(PROFILEINFO_CHARACTER | PROFILEINFO_USER)) diff --git a/pages/zone.php b/pages/zone.php index d05ba3db..25f0bd8a 100644 --- a/pages/zone.php +++ b/pages/zone.php @@ -14,7 +14,7 @@ class ZonePage extends GenericPage protected $tabId = 0; protected $type = Type::ZONE; protected $tpl = 'detail-page-generic'; - protected $js = [[JS_FILE, 'ShowOnMap.js']]; + protected $scripts = [[SC_JS_FILE, 'js/ShowOnMap.js']]; protected $zoneMusic = []; @@ -33,7 +33,7 @@ class ZonePage extends GenericPage protected function generateContent() { - $this->addScript([JS_FILE, '?data=zones&locale='.User::$localeId.'&t='.$_SESSION['dataKey']]); + $this->addScript([SC_JS_FILE, '?data=zones']); /***********/ /* Infobox */ diff --git a/pages/zones.php b/pages/zones.php index 47286f99..9832eb63 100644 --- a/pages/zones.php +++ b/pages/zones.php @@ -16,7 +16,7 @@ class ZonesPage extends GenericPage protected $tabId = 0; protected $mode = CACHE_TYPE_PAGE; protected $validCats = [true, true, [0, 1, 2], [0, 1, 2], false, false, true, false, true, true, true]; - protected $js = [[JS_FILE, 'ShowOnMap.js']]; + protected $scripts = [[SC_JS_FILE, 'js/ShowOnMap.js']]; public function __construct($pageCall, $pageParam) { diff --git a/template/bricks/head.tpl.php b/template/bricks/head.tpl.php index 35580f35..1b7efcec 100644 --- a/template/bricks/head.tpl.php +++ b/template/bricks/head.tpl.php @@ -3,19 +3,11 @@ - - - - \n"; -endif; - foreach ($this->css as [$type, $css]): - if ($type == CSS_FILE): - echo ' \n"; - elseif ($type == CSS_STRING): + if ($type == SC_CSS_FILE): + echo ' \n"; + elseif ($type == SC_CSS_STRING): echo ' \n"; endif; endforeach; @@ -30,22 +22,11 @@ if ($this->gDataKey): endif; ?> - - - - - - - \n"; -endif; - foreach ($this->js as [$type, $js]): - if ($type == JS_FILE): - echo ' \n"; - elseif ($type == JS_STRING): + if ($type == SC_JS_FILE): + echo ' \n"; + elseif ($type == SC_JS_STRING): echo ' \n"; endif; endforeach;
KeyValueOptions