From 40b5c992e22e745588b82bd09e249bd2b729be5b Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sun, 27 Jul 2025 03:42:23 +0200 Subject: [PATCH] Misc/Fixup * make time formatting js compatible * add auto-discovery for rss feeds * fix typos * define more magic numbers --- includes/ajaxHandler/data.class.php | 6 ++-- includes/defines.php | 10 +++--- includes/locale.class.php | 2 +- includes/setup/cli.class.php | 2 +- includes/types/basetype.class.php | 4 +-- includes/types/enchantment.class.php | 2 +- includes/types/item.class.php | 2 +- includes/utilities.php | 35 ++++++++++---------- localization/lang.class.php | 4 +-- localization/locale_ruru.php | 2 +- pages/admin.php | 2 +- pages/npc.php | 4 +-- pages/profile.php | 2 +- pages/spells.php | 48 ++++++++++++++-------------- setup/tools/filegen/itemsets.ss.php | 2 +- setup/tools/setupScript.class.php | 2 +- static/js/global.js | 2 +- template/bricks/head.tpl.php | 4 ++- 18 files changed, 70 insertions(+), 65 deletions(-) diff --git a/includes/ajaxHandler/data.class.php b/includes/ajaxHandler/data.class.php index 0dd74805..ae6ba054 100644 --- a/includes/ajaxHandler/data.class.php +++ b/includes/ajaxHandler/data.class.php @@ -55,10 +55,10 @@ class AjaxData extends AjaxHandler $result .= $this->loadProfilerData($set); break; case 'companions': - $result .= $this->loadProfilerData($set, '778'); + $result .= $this->loadProfilerData($set, SKILL_COMPANIONS); break; case 'mounts': - $result .= $this->loadProfilerData($set, '777'); + $result .= $this->loadProfilerData($set, SKILL_MOUNTS); break; case 'quests': $catg = isset($this->_get['catg']) ? $this->_get['catg'] : 'null'; @@ -81,7 +81,7 @@ class AjaxData extends AjaxHandler $result .= "\n\$WowheadProfiler.loadOnDemand('recipes', null);\n"; break; - // locale independant + // locale independent case 'quick-excludes': case 'weight-presets': case 'item-scaling': diff --git a/includes/defines.php b/includes/defines.php index 2ddd6cfa..ac71c8b8 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -846,16 +846,16 @@ define('ITEM_CLASS_CONTAINER', 1); define('ITEM_CLASS_WEAPON', 2); define('ITEM_CLASS_GEM', 3); define('ITEM_CLASS_ARMOR', 4); -define('ITEM_CLASS_REAGENT', 5); +define('ITEM_CLASS_REAGENT', 5); // OBSOLETE (reagents are in Class:Misc; SubClass:Reagent) define('ITEM_CLASS_AMMUNITION', 6); define('ITEM_CLASS_TRADEGOOD', 7); -define('ITEM_CLASS_GENERIC', 8); +define('ITEM_CLASS_GENERIC', 8); // OBSOLETE define('ITEM_CLASS_RECIPE', 9); define('ITEM_CLASS_MONEY', 10); define('ITEM_CLASS_QUIVER', 11); define('ITEM_CLASS_QUEST', 12); define('ITEM_CLASS_KEY', 13); -define('ITEM_CLASS_PERMANENT', 14); +define('ITEM_CLASS_PERMANENT', 14); // OBSOLETE define('ITEM_CLASS_MISC', 15); define('ITEM_CLASS_GLYPH', 16); @@ -918,7 +918,7 @@ define('ITEM_SUBCLASS_PRISMATIC_GEM', 8); // ItemSubClass - Armor (4) define('ITEM_SUBCLASS_MISC_ARMOR', 0); define('ITEM_SUBCLASS_CLOTH_ARMOR', 1); -define('ITEM_SUBCLASS_LETHER_ARMOR', 2); +define('ITEM_SUBCLASS_LEATHER_ARMOR', 2); define('ITEM_SUBCLASS_MAIL_ARMOR', 3); define('ITEM_SUBCLASS_PLATE_ARMOR', 4); define('ITEM_SUBCLASS_BUCKLER', 5); @@ -1735,6 +1735,8 @@ define('SKILL_LOCKPICKING', 633); define('SKILL_JEWELCRAFTING', 755); define('SKILL_RIDING', 762); define('SKILL_INSCRIPTION', 773); +define('SKILL_MOUNTS', 777); +define('SKILL_COMPANIONS', 778); define('SKILLS_TRADE_PRIMARY', [SKILL_BLACKSMITHING, SKILL_LEATHERWORKING, SKILL_ALCHEMY, SKILL_HERBALISM, SKILL_MINING, SKILL_TAILORING, SKILL_ENGINEERING, SKILL_ENCHANTING, SKILL_SKINNING, SKILL_JEWELCRAFTING, SKILL_INSCRIPTION]); define('SKILLS_TRADE_SECONDARY', [SKILL_FIRST_AID, SKILL_COOKING, SKILL_FISHING, SKILL_RIDING]); diff --git a/includes/locale.class.php b/includes/locale.class.php index af653bd2..a8d8923e 100644 --- a/includes/locale.class.php +++ b/includes/locale.class.php @@ -28,7 +28,7 @@ enum Locale : int return match ($this) { self::EN => 'en', - self::KR => 'kt', + self::KR => 'ko', self::FR => 'fr', self::DE => 'de', self::CN => 'cn', diff --git a/includes/setup/cli.class.php b/includes/setup/cli.class.php index 20172df6..14cda6cf 100644 --- a/includes/setup/cli.class.php +++ b/includes/setup/cli.class.php @@ -205,7 +205,7 @@ abstract class CLI $path .= ($path ? DIRECTORY_SEPARATOR : '').trim($fileOrPath); - // remove double quotes (from erronous user input), single quotes are + // remove double quotes (from erroneous user input), single quotes are // valid chars for filenames and removing those mutilates several wow icons $path = str_replace('"', '', $path); diff --git a/includes/types/basetype.class.php b/includes/types/basetype.class.php index a5e2b919..57c2ca8a 100644 --- a/includes/types/basetype.class.php +++ b/includes/types/basetype.class.php @@ -50,7 +50,7 @@ abstract class BaseType * ['flags2', 0xF, '&'], * ] * [['mask', 0x3, '&'], 0], - * ['joinedTbl.field', NULL] // NULL must be explicitly specified "['joinedTbl.field']" would be skipped as erronous definition (only really usefull when left-joining) + * ['joinedTbl.field', NULL] // NULL must be explicitly specified "['joinedTbl.field']" would be skipped as erroneous definition (only really usefull when left-joining) * 'OR', * 5 * ) @@ -1002,7 +1002,7 @@ abstract class Filter protected const ENUM_RACE = array( null, 1, 2, 3, 4, 5, 6, 7, 8, null, 10, 11, true, false); protected const ENUM_PROFESSION = array( null, 171, 164, 185, 333, 202, 129, 755, 165, 186, 197, true, false, 356, 182, 773); - public $error = false; // erronous search fields + public $error = false; // erroneous search fields private $cndSet = []; diff --git a/includes/types/enchantment.class.php b/includes/types/enchantment.class.php index c4c7b1f0..e756b551 100644 --- a/includes/types/enchantment.class.php +++ b/includes/types/enchantment.class.php @@ -60,7 +60,7 @@ class EnchantmentList extends BaseType // issue with scaling stats enchantments // stats are stored as NOT NULL to be usable by the search filters and such become indistinguishable from scaling enchantments that _actually_ use the value 0 // so filter the stats container and if it is empty, rebuild from self. .. there are no mixed scaling/static enchantments, right!? - $this->jsonStats[$this->id] = (new StatsContainer)->fromJson($curTpl, true)->filter(); + $this->jsonStats[$this->id] = (new StatsContainer())->fromJson($curTpl, true)->filter(); if (!count($this->jsonStats[$this->id])) $this->jsonStats[$this->id]->fromEnchantment($curTpl); } diff --git a/includes/types/item.class.php b/includes/types/item.class.php index a935c371..07e762d3 100644 --- a/includes/types/item.class.php +++ b/includes/types/item.class.php @@ -2673,7 +2673,7 @@ class ItemListFilter extends Filter return in_array($v, $sl); // armor - any; any armor - else if ($c[0] == ITEM_CLASS_ARMOR && (!isset($c[1]) || in_array($c[1], [ITEM_SUBCLASS_CLOTH_ARMOR, ITEM_SUBCLASS_LETHER_ARMOR, ITEM_SUBCLASS_MAIL_ARMOR, ITEM_SUBCLASS_PLATE_ARMOR]))) + else if ($c[0] == ITEM_CLASS_ARMOR && (!isset($c[1]) || in_array($c[1], [ITEM_SUBCLASS_CLOTH_ARMOR, ITEM_SUBCLASS_LEATHER_ARMOR, ITEM_SUBCLASS_MAIL_ARMOR, ITEM_SUBCLASS_PLATE_ARMOR]))) return in_array($v, $sl); return false; diff --git a/includes/utilities.php b/includes/utilities.php index 478fa9d0..5ee41de7 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -288,45 +288,46 @@ abstract class Util public static function formatTime(int $msec, bool $short = false) : string { [$ms, $s, $m, $h, $d] = self::parseTime(abs($msec)); + // \u00A0 is  , but also usable by js if ($short) { - if ($_ = round($d / 364)) - return $_." ".Lang::timeUnits('ab', 0); + if ($_ = round($d / 365)) + return $_."\u{00A0}".Lang::timeUnits('ab', 0); if ($_ = round($d / 30)) - return $_." ".Lang::timeUnits('ab', 1); + return $_."\u{00A0}".Lang::timeUnits('ab', 1); if ($_ = round($d / 7)) - return $_." ".Lang::timeUnits('ab', 2); + return $_."\u{00A0}".Lang::timeUnits('ab', 2); if ($_ = round($d)) - return $_." ".Lang::timeUnits('ab', 3); + return $_."\u{00A0}".Lang::timeUnits('ab', 3); if ($_ = round($h)) - return $_." ".Lang::timeUnits('ab', 4); + return $_."\u{00A0}".Lang::timeUnits('ab', 4); if ($_ = round($m)) - return $_." ".Lang::timeUnits('ab', 5); + return $_."\u{00A0}".Lang::timeUnits('ab', 5); if ($_ = round($s + $ms / 1000, 2)) - return $_." ".Lang::timeUnits('ab', 6); + return $_."\u{00A0}".Lang::timeUnits('ab', 6); if ($ms) - return $ms." ".Lang::timeUnits('ab', 7); + return $ms."\u{00A0}".Lang::timeUnits('ab', 7); return '0 '.Lang::timeUnits('ab', 6); } else { $_ = $d + $h / 24; - if ($_ > 1 && !($_ % 364)) // whole years - return round(($d + $h / 24) / 364, 2)." ".Lang::timeUnits($d / 364 == 1 && !$h ? 'sg' : 'pl', 0); + if ($_ > 1 && !($_ % 365)) // whole years + return round(($d + $h / 24) / 364, 2)."\u{00A0}".Lang::timeUnits($d / 364 == 1 && !$h ? 'sg' : 'pl', 0); if ($_ > 1 && !($_ % 30)) // whole month - return round(($d + $h / 24) / 30, 2)." ".Lang::timeUnits($d / 30 == 1 && !$h ? 'sg' : 'pl', 1); + return round(($d + $h / 24) / 30, 2)."\u{00A0}".Lang::timeUnits($d / 30 == 1 && !$h ? 'sg' : 'pl', 1); if ($_ > 1 && !($_ % 7)) // whole weeks - return round(($d + $h / 24) / 7, 2)." ".Lang::timeUnits($d / 7 == 1 && !$h ? 'sg' : 'pl', 2); + return round(($d + $h / 24) / 7, 2)."\u{00A0}".Lang::timeUnits($d / 7 == 1 && !$h ? 'sg' : 'pl', 2); if ($d) - return round($d + $h / 24, 2)." ".Lang::timeUnits($d == 1 && !$h ? 'sg' : 'pl', 3); + return round($d + $h / 24, 2)."\u{00A0}".Lang::timeUnits($d == 1 && !$h ? 'sg' : 'pl', 3); if ($h) - return round($h + $m / 60, 2)." ".Lang::timeUnits($h == 1 && !$m ? 'sg' : 'pl', 4); + return round($h + $m / 60, 2)."\u{00A0}".Lang::timeUnits($h == 1 && !$m ? 'sg' : 'pl', 4); if ($m) - return round($m + $s / 60, 2)." ".Lang::timeUnits($m == 1 && !$s ? 'sg' : 'pl', 5); + return round($m + $s / 60, 2)."\u{00A0}".Lang::timeUnits($m == 1 && !$s ? 'sg' : 'pl', 5); if ($s) - return round($s + $ms / 1000, 2)." ".Lang::timeUnits($s == 1 && !$ms ? 'sg' : 'pl', 6); + return round($s + $ms / 1000, 2)."\u{00A0}".Lang::timeUnits($s == 1 && !$ms ? 'sg' : 'pl', 6); if ($ms) return $ms." ".Lang::timeUnits($ms == 1 ? 'sg' : 'pl', 7); diff --git a/localization/lang.class.php b/localization/lang.class.php index 90da9654..54324fbf 100644 --- a/localization/lang.class.php +++ b/localization/lang.class.php @@ -625,9 +625,9 @@ class Lang { case -1: // default Lang::vspf case case self::FMT_HTML: - return sprintf('%3s', $rgb, $a, $text); + return sprintf('%3$s', $rgb, $a, $text); case self::FMT_MARKUP: - return sprintf('[span color=#%1s]%3s[/span]', $rgb, $text); // doesn't support alpha + return sprintf('[span color=#%1$s]%3$s[/span]', $rgb, $a, $text); // doesn't support alpha case self::FMT_RAW: default: return $text; diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index f212cf23..2da19751 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -53,7 +53,7 @@ $lang = array( 'or' => " или ", 'back' => "Назад", 'reputationTip' => "Очки репутации", - 'byUser' => 'От %1s ', + 'byUser' => 'От %1$s ', 'help' => "Справка", 'status' => "Статус", 'yes' => "Да", diff --git a/pages/admin.php b/pages/admin.php index e6627efc..412c5805 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -17,7 +17,7 @@ class AdminPage extends GenericPage protected $extraHTML = ''; protected $tpl = null; // depends on the subject - protected $reqUGroup = U_GROUP_NONE; // actual group dependant on the subPage + protected $reqUGroup = U_GROUP_NONE; // actual group dependent on the subPage protected $reqAuth = true; protected $path = [4]; protected $tabId = 4; diff --git a/pages/npc.php b/pages/npc.php index 8cdd0e2a..189f888b 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -258,7 +258,7 @@ class NpcPage extends GenericPage // > Stats $stats = []; $modes = []; // get difficulty versions if set - $hint = '[tooltip name=%3$s][table cellspacing=10][tr]%1s[/tr][/table][/tooltip][span class=tip tooltip=%3$s]%2s[/span]'; + $hint = '[tooltip name=%3$s][table cellspacing=10][tr]%1$s[/tr][/table][/tooltip][span class=tip tooltip=%3$s]%2$s[/span]'; $modeRow = '[tr][td]%s  [/td][td]%s[/td][/tr]'; // Health $health = $this->subject->getBaseStats('health'); @@ -438,7 +438,7 @@ class NpcPage extends GenericPage if ($auras = DB::World()->selectCell('SELECT auras FROM creature_template_addon WHERE entry = ?d', $this->typeId)) { - $auras = preg_replace('/[^\d ]/', ' ', $auras); // remove erronous chars from string + $auras = preg_replace('/[^\d ]/', ' ', $auras); // remove erroneous chars from string $genSpells = array_merge($genSpells, array_filter(explode(' ', $auras))); } diff --git a/pages/profile.php b/pages/profile.php index db80279c..38320159 100644 --- a/pages/profile.php +++ b/pages/profile.php @@ -119,7 +119,7 @@ class ProfilePage extends GenericPage if ($char['guildGUID']) { - // create empty guild if nessecary to satisfy foreign keys + // create empty guild if necessary to satisfy foreign keys $char['guild'] = DB::Aowow()->selectCell('SELECT id FROM ?_profiler_guild WHERE realm = ?d AND realmGUID = ?d', $this->realmId, $char['guildGUID']); if (!$char['guild']) $char['guild'] = DB::Aowow()->query('INSERT INTO ?_profiler_guild (realm, realmGUID, cuFlags, name) VALUES (?d, ?d, ?d, ?)', $this->realmId, $char['guildGUID'], PROFILER_CU_NEEDS_RESYNC, $char['guildName']); diff --git a/pages/spells.php b/pages/spells.php index f4068c9a..3bb19e2d 100644 --- a/pages/spells.php +++ b/pages/spells.php @@ -59,35 +59,35 @@ class SpellsPage extends GenericPage 9 => [355, 354, 593], 11 => [574, 134, 573] ), - 9 => [129, 185, 356, 762], // Secondary Skills + 9 => SKILLS_TRADE_SECONDARY, // Secondary Skills 11 => array( // Professions: Skill => Spell - 171 => true, - 164 => [9788, 9787, 17041, 17040, 17039], - 333 => true, - 202 => [20219, 20222], - 182 => true, - 773 => true, - 755 => true, - 165 => [10656, 10658, 10660], - 186 => true, - 393 => true, - 197 => [26798, 26801, 26797], + SKILL_ALCHEMY => true, + SKILL_BLACKSMITHING => [9788, 9787, 17041, 17040, 17039], + SKILL_ENCHANTING => true, + SKILL_ENGINEERING => [20219, 20222], + SKILL_HERBALISM => true, + SKILL_INSCRIPTION => true, + SKILL_JEWELCRAFTING => true, + SKILL_LEATHERWORKING => [10656, 10658, 10660], + SKILL_MINING => true, + SKILL_SKINNING => true, + SKILL_TAILORING => [26798, 26801, 26797], ) ); private $shortFilter = array( - 129 => [ 6, 7], // First Aid - 164 => [ 2, 4], // Blacksmithing - 165 => [ 8, 1], // Leatherworking - 171 => [ 1, 6], // Alchemy - 185 => [ 3, 5], // Cooking - 186 => [ 9, 0], // Mining - 197 => [10, 2], // Tailoring - 202 => [ 5, 3], // Engineering - 333 => [ 4, 8], // Enchanting - 356 => [ 0, 9], // Fishing - 755 => [ 7, 10], // Jewelcrafting - 773 => [15, 0], // Inscription + SKILL_FIRST_AID => [ 6, 7], + SKILL_BLACKSMITHING => [ 2, 4], + SKILL_LEATHERWORKING => [ 8, 1], + SKILL_ALCHEMY => [ 1, 6], + SKILL_COOKING => [ 3, 5], + SKILL_MINING => [ 9, 0], + SKILL_TAILORING => [10, 2], + SKILL_ENGINEERING => [ 5, 3], + SKILL_ENCHANTING => [ 4, 8], + SKILL_FISHING => [ 0, 9], + SKILL_JEWELCRAFTING => [ 7, 10], + SKILL_INSCRIPTION => [15, 0], ); diff --git a/setup/tools/filegen/itemsets.ss.php b/setup/tools/filegen/itemsets.ss.php index 544159df..514b5f7f 100644 --- a/setup/tools/filegen/itemsets.ss.php +++ b/setup/tools/filegen/itemsets.ss.php @@ -89,7 +89,7 @@ CLISetup::registerSetup("build", new class extends SetupScript $_spells[] = $set['spell'.$i]; } - // costy and locale-independant -> cache + // costy and locale-independent -> cache if ($_spells) $jsonBonus += (new SpellList(array(['s.id', $_spells])))->getStatGain(); diff --git a/setup/tools/setupScript.class.php b/setup/tools/setupScript.class.php index c26ef13e..39a4ad8f 100644 --- a/setup/tools/setupScript.class.php +++ b/setup/tools/setupScript.class.php @@ -406,7 +406,7 @@ abstract class SetupScript protected $worldDependency = []; // query when this table changed (--sync command) protected $info = []; // arr: 0 => self, n => genSteps cmd => [[arr:optionalArgs], int:argFlags, str:description] - protected $setupAfter = [[], []]; // [[sqlgen], [filegen]] used to sort scripts that rely on each other being executed in the right order (script names are not nessecarily the same as their table names) + protected $setupAfter = [[], []]; // [[sqlgen], [filegen]] used to sort scripts that rely on each other being executed in the right order (script names are not necessarily the same as their table names) protected $success = true; protected $localized = false; // push locale directories onto $requiredDirs? diff --git a/static/js/global.js b/static/js/global.js index cead8fe9..2d64f0bb 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -592,7 +592,7 @@ var PageTemplate = new function() { className: (character.pinned ? 'icon-star-right ' : '') + 'c' + character.classs, // tinyIcon: $WH.g_getProfileIcon(character.race, character.classs, character.gender, character.level, character.id, 'tiny') - // aowow: profileId should not be nessecary here + // aowow: profileId should not be necessary here tinyIcon: $WH.g_getProfileIcon(character.race, character.classs, character.gender, character.level, 0, 'tiny') }]; diff --git a/template/bricks/head.tpl.php b/template/bricks/head.tpl.php index 06349ab0..18c1ff15 100644 --- a/template/bricks/head.tpl.php +++ b/template/bricks/head.tpl.php @@ -5,7 +5,9 @@ -rss)): ?> + +css as [$type, $css]): if ($type == SC_CSS_FILE): echo ' \n";