Template/Update (Part 1)

* update TrinityCore components to return new Frontend objects
   - SmartAI => Markup
   - Conditions => Data Listview
  * update template files to accept the new Frontend objects
This commit is contained in:
Sarjuuk
2025-08-05 21:50:15 +02:00
parent 226f521439
commit e943e27b5b
25 changed files with 186 additions and 235 deletions

View File

@@ -345,7 +345,7 @@ class Conditions
'name' => ($name ?: '$LANG.tab_conditions') . '+" ('.$nCnd.')"' 'name' => ($name ?: '$LANG.tab_conditions') . '+" ('.$nCnd.')"'
); );
return [null, $tab]; return $tab;
} }
// $keyX params are string(ref to lv column) or int(fixed value) // $keyX params are string(ref to lv column) or int(fixed value)

View File

@@ -651,32 +651,31 @@ class SmartAI
return true; return true;
} }
public function getMarkdown() : string public function getMarkup() : ?Markup
{ {
# id | event (footer phase) | chance | action + target # id | event (footer phase) | chance | action + target
if (!$this->rawData) if (!$this->rawData)
return ''; return null;
$return = '[style]#text-generic .grid { clear:left; } #text-generic .tabbed-contents { padding:0px; clear:left; }[/style][pad][h3][toggler id=sai]SmartAI'.$this->title.'[/toggler][/h3][div id=sai clear=left]%s[/div]'; $wrapper = '[table class=grid width=940px]%s[/table]';
$return = '[style]#smartai-generic .grid { clear:left; } #smartai-generic .tabbed-contents { padding:0px; clear:left; }[/style][pad][h3][toggler id=sai]SmartAI'.$this->title.'[/toggler][/h3][div id=sai clear=left]%s[/div]';
$tabs = '';
if (count($this->tabs) > 1) if (count($this->tabs) > 1)
{ {
$wrapper = '[tabs name=sai width=942px]%s[/tabs]'; $wrapper = '[tabs name=sai width=942px]%s[/tabs]';
$return = '[script]function TalTabClick(id) { $(\'#dsf67g4d-sai\').find(\\\'[href=\\\\\'#sai-actionlist-\' + id + \'\\\\\']\\\').click(); }[/script]' . $return; $return = "[script]function TalTabClick(id) { $('#dsf67g4d-sai').find('[href=\'#sai-actionlist-' + id + '\']').click(); }[/script]" . $return;
$tabs = '';
foreach ($this->tabs as $guid => $data) foreach ($this->tabs as $guid => $data)
{ {
$buff = '[tab name=\"'.($guid ? 'ActionList #'.$guid : 'Main').'\"][table class=grid width=940px]'.$data.'[/table][/tab]'; $buff = '[tab name="'.($guid ? 'ActionList #'.$guid : 'Main').'"][table class=grid width=940px]'.$data.'[/table][/tab]';
if ($guid) if ($guid)
$tabs .= $buff; $tabs .= $buff;
else else
$tabs = $buff . $tabs; $tabs = $buff . $tabs;
} }
return sprintf($return, sprintf($wrapper, $tabs));
} }
else
return sprintf($return, '[table class=grid width=940px]'.$this->tabs[0].'[/table]'); return new Markup(sprintf($return, sprintf($wrapper, $tabs ?: $this->tabs[0])), ['allow' => Markup::CLASS_ADMIN], 'smartai-generic');
} }
public function addJsGlobals(array $jsg) : void public function addJsGlobals(array $jsg) : void

View File

@@ -713,12 +713,12 @@ class SmartAction
break; break;
case self::ACTION_TALK: // 1 -> any target case self::ACTION_TALK: // 1 -> any target
case self::ACTION_SIMPLE_TALK: // 84 -> any target case self::ACTION_SIMPLE_TALK: // 84 -> any target
$noSrc = false; $playerSrc = false;
if ($npcId = $this->smartAI->getTarget()->getTalkSource($noSrc)) if ($npcId = $this->smartAI->getTarget()->getTalkSource($playerSrc))
{ {
if ($quotes = $this->smartAI->getQuote($npcId, $this->param[0], $npcSrc)) if ($quotes = $this->smartAI->getQuote($npcId, $this->param[0], $npcSrc))
foreach ($quotes as ['text' => $text, 'prefix' => $prefix]) foreach ($quotes as ['text' => $text])
$this->param[10] .= sprintf($text, $noSrc ? '' : sprintf($prefix, $npcSrc), $npcSrc); $this->param[10] .= sprintf($text, $playerSrc ? Lang::main('thePlayer') : $npcSrc);
} }
else else
trigger_error('SmartAI::action - could not determine talk source for action #'.$this->type); trigger_error('SmartAI::action - could not determine talk source for action #'.$this->type);

View File

@@ -20,7 +20,8 @@ class LocString
trigger_error('LocString - is entrirely empty', E_USER_WARNING); trigger_error('LocString - is entrirely empty', E_USER_WARNING);
foreach (Locale::cases() as $l) foreach (Locale::cases() as $l)
$this->store[$l] = (string)$callback($data[$key.'_loc'.$l->value] ?? ''); if ($l->validate())
$this->store[$l] = (string)$callback($data[$key.'_loc'.$l->value] ?? '');
} }
public function __toString() : string public function __toString() : string

View File

@@ -191,24 +191,23 @@ class Game
return $data; return $data;
} }
public static function getPageText($ptId) public static function getBook(int $ptId, ?int $startPage = null) : ?Book
{ {
$pages = []; $pages = [];
while ($ptId) while ($ptId)
{ {
if ($row = DB::World()->selectRow('SELECT ptl.Text AS Text_loc?d, pt.* FROM page_text pt LEFT JOIN page_text_locale ptl ON pt.ID = ptl.ID AND locale = ? WHERE pt.ID = ?d', Lang::getLocale()->value, Lang::getLocale()->json(), $ptId)) if ($row = DB::World()->selectRow('SELECT ptl.`Text` AS Text_loc?d, pt.* FROM page_text pt LEFT JOIN page_text_locale ptl ON pt.`ID` = ptl.`ID` AND locale = ? WHERE pt.`ID` = ?d', Lang::getLocale()->value, Lang::getLocale()->json(), $ptId))
{ {
$ptId = $row['NextPageID']; $ptId = $row['NextPageID'];
$pages[] = Util::parseHtmlText(Util::localizedString($row, 'Text')); $pages[] = Util::localizedString($row, 'Text');
} continue;
else
{
trigger_error('Referenced PageTextId #'.$ptId.' is not in DB', E_USER_WARNING);
break;
} }
trigger_error('Referenced PageTextId #'.$ptId.' is not in DB', E_USER_WARNING);
break;
} }
return $pages; return $pages ? new Book($pages, page: $startPage) : null;
} }
public static function getQuotesForCreature(int $creatureId, bool $asHTML = false, string $talkSource = '') : array public static function getQuotesForCreature(int $creatureId, bool $asHTML = false, string $talkSource = '') : array
@@ -256,40 +255,33 @@ class Game
if ($talkSource) if ($talkSource)
$msg = sprintf($msg, $talkSource); $msg = sprintf($msg, $talkSource);
// make type css compatible // convert [old, new] talkType to css compatible
switch ($t['talkType']) $t['talkType'] = match ((int)$t['talkType'])
{ {
case 1: // yell: 0, 12 => 2, // say - yellow-ish
case 14: $t['talkType'] = 1; break; // - dark red 1, 14 => 1, // yell - dark red
case 2: // emote: 2, 16, // emote
case 16: // " 3, 41 => 4, // boss emote - orange
case 3: // boss emote: 4, 15, // whisper
case 41: $t['talkType'] = 4; break; // - orange 5, 42 => 3, // boss whisper - pink-ish
case 4: // whisper: default => 2
case 15: // " };
case 5: // boss whisper:
case 42: $t['talkType'] = 3; break; // - pink-ish
default: $t['talkType'] = 2; // [type: 0, 12] say: yellow-ish
}
// prefix // prefix
$pre = ''; $prefix = '%s ';
if ($t['talkType'] != 4) if ($t['talkType'] != 4)
$pre = ($talkSource ?: '%s').' '.Lang::npc('textTypes', $t['talkType']).Lang::main('colon').($t['lang'] ? '['.Lang::game('languages', $t['lang']).'] ' : null); $prefix = ($talkSource ?: '%s').' '.Lang::npc('textTypes', $t['talkType']).Lang::main('colon').($t['lang'] ? '['.Lang::game('languages', $t['lang']).'] ' : ' ');
if ($asHTML) if ($asHTML)
$msg = '<div><span class="s'.$t['talkType'].'">%s'.($t['range'] ? sprintf(Util::$dfnString, Lang::npc('textRanges', $t['range']), $msg) : $msg).'</span></div>'; $msg = '<div><span class="s'.$t['talkType'].'">'.$prefix.($t['range'] ? sprintf(Util::$dfnString, Lang::npc('textRanges', $t['range']), $msg) : $msg).'</span></div>';
else else
$msg = '[div][span class=s'.$t['talkType'].']%s'.html_entity_decode($msg).'[/span][/div]'; $msg = '[div][span class=s'.$t['talkType'].']'.$prefix.html_entity_decode($msg).'[/span][/div]';
$line = array( $line = array(
'range' => $t['range'], 'range' => $t['range'],
'text' => $msg, 'text' => $msg
'prefix' => $pre
); );
$nQuotes++; $nQuotes++;
$group[] = $line; $group[] = $line;
} }

View File

@@ -33,6 +33,7 @@ $lang = array(
'gender' => "Geschlecht", 'gender' => "Geschlecht",
'sex' => [null, "Mann", "Frau"], 'sex' => [null, "Mann", "Frau"],
'players' => "Spieler", 'players' => "Spieler",
'thePlayer' => "Der Spieler",
'quickFacts' => "Kurzübersicht", 'quickFacts' => "Kurzübersicht",
'screenshots' => "Screenshots", 'screenshots' => "Screenshots",
'videos' => "Videos", 'videos' => "Videos",

View File

@@ -33,6 +33,7 @@ $lang = array(
'gender' => "Gender", 'gender' => "Gender",
'sex' => [null, "Male", "Female"], 'sex' => [null, "Male", "Female"],
'players' => "Players", 'players' => "Players",
'thePlayer' => "The Player",
'quickFacts' => "Quick Facts", 'quickFacts' => "Quick Facts",
'screenshots' => "Screenshots", 'screenshots' => "Screenshots",
'videos' => "Videos", 'videos' => "Videos",

View File

@@ -33,6 +33,7 @@ $lang = array(
'gender' => "Género", 'gender' => "Género",
'sex' => [null, "Hombre", "Mujer"], 'sex' => [null, "Hombre", "Mujer"],
'players' => "Jugadores", 'players' => "Jugadores",
'thePlayer' => "El Jugador",
'quickFacts' => "Notas rápidas", 'quickFacts' => "Notas rápidas",
'screenshots' => "Capturas de pantalla", 'screenshots' => "Capturas de pantalla",
'videos' => "Videos", 'videos' => "Videos",

View File

@@ -33,6 +33,7 @@ $lang = array(
'gender' => "Genre", 'gender' => "Genre",
'sex' => [null, "Homme", "Femme"], 'sex' => [null, "Homme", "Femme"],
'players' => "Joueurs", 'players' => "Joueurs",
'thePlayer' => "Le joueur",
'quickFacts' => "En bref", 'quickFacts' => "En bref",
'screenshots' => "Captures d'écran", 'screenshots' => "Captures d'écran",
'videos' => "Vidéos", 'videos' => "Vidéos",

View File

@@ -33,6 +33,7 @@ $lang = array(
'gender' => "Пол", 'gender' => "Пол",
'sex' => [null, "Мужчина", "Женщина"], 'sex' => [null, "Мужчина", "Женщина"],
'players' => "Игрокам", 'players' => "Игрокам",
'thePlayer' => "Игрок",
'quickFacts' => "Краткая информация", 'quickFacts' => "Краткая информация",
'screenshots' => "Изображения", 'screenshots' => "Изображения",
'videos' => "Видео", 'videos' => "Видео",

View File

@@ -34,6 +34,7 @@ $lang = array(
'gender' => "性别", 'gender' => "性别",
'sex' => [null, "男性", "女性"], 'sex' => [null, "男性", "女性"],
'players' => "玩家", 'players' => "玩家",
'thePlayer' => "玩家",
'quickFacts' => "相关信息", 'quickFacts' => "相关信息",
'screenshots' => "屏幕截图", 'screenshots' => "屏幕截图",
'videos' => "视频", 'videos' => "视频",

View File

@@ -74,7 +74,7 @@ class AreaTriggerPage extends GenericPage
$this->map = $map; $this->map = $map;
$this->infobox = false; $this->infobox = false;
$this->smartAI = $sai?->getMarkdown(); $this->smartAI = $sai?->getMarkup();
$this->redButtons = array( $this->redButtons = array(
BUTTON_LINKS => false, BUTTON_LINKS => false,
BUTTON_WOWHEAD => false BUTTON_WOWHEAD => false

View File

@@ -382,8 +382,7 @@ class ItemPage extends genericPage
$_cu = in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) || $this->subject->getField('gemEnchantmentId'); $_cu = in_array($_class, [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) || $this->subject->getField('gemEnchantmentId');
// pageText // pageText
$pageText = []; if ($this->pageText = Game::getBook($this->subject->getField('pageTextId')))
if ($this->pageText = Game::getPageText($this->subject->getField('pageTextId')))
$this->addScript( $this->addScript(
[SC_JS_FILE, 'js/Book.js'], [SC_JS_FILE, 'js/Book.js'],
[SC_CSS_FILE, 'css/Book.css'] [SC_CSS_FILE, 'css/Book.css']

View File

@@ -406,7 +406,7 @@ class NpcPage extends GenericPage
$this->accessory = $accessory; $this->accessory = $accessory;
$this->quotes = $this->getQuotes(); $this->quotes = $this->getQuotes();
$this->reputation = $this->getOnKillRep($_altIds, $mapType); $this->reputation = $this->getOnKillRep($_altIds, $mapType);
$this->smartAI = $sai ? $sai->getMarkdown() : null; $this->smartAI = $sai ? $sai->getMarkup() : null;
$this->redButtons = array( $this->redButtons = array(
BUTTON_WOWHEAD => true, BUTTON_WOWHEAD => true,
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId],

View File

@@ -212,7 +212,7 @@ class ObjectPage extends GenericPage
/****************/ /****************/
// pageText // pageText
if ($this->pageText = Game::getPageText($this->subject->getField('pageTextId'))) if ($this->pageText = Game::getBook($this->subject->getField('pageTextId')))
$this->addScript( $this->addScript(
[SC_JS_FILE, 'js/Book.js'], [SC_JS_FILE, 'js/Book.js'],
[SC_CSS_FILE, 'css/Book.css'] [SC_CSS_FILE, 'css/Book.css']
@@ -271,7 +271,7 @@ class ObjectPage extends GenericPage
$this->map = $map; $this->map = $map;
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null; $this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null;
$this->relBoss = $relBoss; $this->relBoss = $relBoss;
$this->smartAI = $sai ? $sai->getMarkdown() : null; $this->smartAI = $sai ? $sai->getMarkup() : null;
$this->redButtons = array( $this->redButtons = array(
BUTTON_WOWHEAD => true, BUTTON_WOWHEAD => true,
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId], BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId],

View File

@@ -1,12 +1,9 @@
<?php namespace Aowow; ?> <?php
namespace Aowow\Template;
<?php foreach ($this->announcements as $a): ?>
foreach ($this->announcements as $id => $data): <div id="announcement-<?=$a->id;?>"></div>
?>
<div id="announcement-<?=$id; ?>"></div>
<script type="text/javascript"> <script type="text/javascript">
new Announcement(<?=Util::toJSON($data); ?>); <?=$a;?>
</script> </script>
<?php <?php endforeach; ?>
endforeach;
?>

View File

@@ -1,13 +0,0 @@
<?php namespace Aowow; ?>
<?php
if (!empty($this->article)):
?>
<div id="article-generic" class="left"></div>
<script type="text/javascript">//<![CDATA[
Markup.printHtml("<?=strtr($this->article['text'], ['scr\\"+\\"ipt' => 'scr"+"ipt']);?>", "article-generic", <?=Util::toJSON($this->article['params']);?>);
//]]></script>
<div class="pad2"></div>
<?php
endif;
?>

View File

@@ -1,15 +1,14 @@
<?php namespace Aowow; ?>
<?php <?php
if (!empty($this->pageText)): namespace Aowow\Template;
?>
use \Aowow\Lang;
if ($this->book): ?>
<div class="clear"></div> <div class="clear"></div>
<h3><?=Lang::item('content'); ?></h3> <h3><?=Lang::item('content'); ?></h3>
<div id="book-generic"></div> <div id="book-generic"></div>
<script>//<![CDATA[ <script>//<![CDATA[
new Book({ parent: 'book-generic', pages: <?=Util::toJSON($this->pageText); ?>}) <?=$this->book; ?>
//]]></script> //]]></script>
<?php <?php endif; ?>
endif;
?>

View File

@@ -1,38 +1,42 @@
<?php namespace Aowow; ?> <?php
namespace Aowow\Template;
use \Aowow\Lang;
?>
<?php <?php
if (!empty($this->infobox) || !empty($this->contributions) || !empty($this->series) || $this->contribute & (CONTRIBUTE_SS | CONTRIBUTE_VI)): if ($this->infobox || $this->contributions || $this->series || $this->contribute & (CONTRIBUTE_SS | CONTRIBUTE_VI)):
echo " <table class=\"infobox\">\n"; echo " <table class=\"infobox\">\n";
if (!empty($this->infobox)): if ($this->infobox):
?> ?>
<tr><th id="infobox-quick-facts"><?=Lang::main('quickFacts'); ?></th></tr> <tr><th id="infobox-quick-facts"><?=Lang::main('quickFacts'); ?></th></tr>
<tr><td> <tr><td>
<div class="infobox-spacer"></div> <div class="infobox-spacer"></div>
<div id="infobox-contents0"></div> <div id="infobox-contents0"></div>
<script type="text/javascript"> <script type="text/javascript">
Markup.printHtml("<?=Util::jsEscape($this->infobox); ?>", "infobox-contents0", { allow: Markup.CLASS_STAFF, dbpage: true }); <?=$this->infobox; ?>
</script> </script>
</td></tr> </td></tr>
<?php <?php
endif; endif;
if (!empty($this->contributions)): if ($this->contributions):
?> ?>
<tr><th id="infobox-contributions"><?=Lang::user('contributions'); ?></th></tr> <tr><th id="infobox-contributions"><?=Lang::user('contributions'); ?></th></tr>
<tr><td> <tr><td>
<div class="infobox-spacer"></div> <div class="infobox-spacer"></div>
<div id="infobox-contents1"></div> <div id="infobox-contents1"></div>
<script type="text/javascript"> <script type="text/javascript">
Markup.printHtml('<?=Util::jsEscape($this->contributions); ?>', 'infobox-contents1', { allow: Markup.CLASS_STAFF }); <?=$this->contributions; ?>
</script> </script>
</td></tr> </td></tr>
<?php <?php
endif; endif;
if (!empty($this->series)): if ($this->series):
foreach ($this->series as $s): foreach ($this->series as [$list, $title]):
$this->brick('series', ['list' => $s[0], 'listTitle' => $s[1]]); $this->brick('series', ['list' => $list, 'listTitle' => $title]);
endforeach; endforeach;
endif; endif;
@@ -43,7 +47,7 @@ echo " <table class=\"infobox\">\n";
<?php <?php
endif; endif;
if ($this->contribute & CONTRIBUTE_VI && (User::isInGroup(U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO) || !empty($this->community['vi']))): if ($this->contribute & CONTRIBUTE_VI && ($this->user::isInGroup(U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO) || !empty($this->community['vi']))):
?> ?>
<tr><th id="infobox-videos"><?=Lang::main('videos'); ?></th></tr> <tr><th id="infobox-videos"><?=Lang::main('videos'); ?></th></tr>
<tr><td><div class="infobox-spacer"></div><div id="infobox-sticky-vi"></div></td></tr> <tr><td><div class="infobox-spacer"></div><div id="infobox-sticky-vi"></div></td></tr>
@@ -56,7 +60,7 @@ echo " <table class=\"infobox\">\n";
<?php <?php
endif; endif;
if ($this->contribute & CONTRIBUTE_VI && (User::isInGroup(U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO) || !empty($this->community['vi']))): if ($this->contribute & CONTRIBUTE_VI && ($this->user::isInGroup(U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO) || !empty($this->community['vi']))):
?> ?>
<script type="text/javascript">vi_appendSticky()</script> <script type="text/javascript">vi_appendSticky()</script>
<?php <?php

View File

@@ -1,86 +1,53 @@
<?php namespace Aowow; ?> <?php
namespace Aowow\Template;
use \Aowow\Lang;
?>
<?php <?php
if (!empty($this->lvTabs) || !empty($this->user['characterData']) || !empty($this->user['profileData']) || $this->contribute): if (($this->lvTabs && count($this->lvTabs)) || $this->charactersLvData || $this->profilesLvData || $this->contribute):
$relTabs = !empty($relTabs); if ($this->lvTabs?->isTabbed()):
$tabVar = $relTabs || !empty($this->user) ? 'tabsRelated' : 'myTabs';
$isTabbed = !empty($this->forceTabs) || $relTabs || count($this->lvTabs) > 1;
// lvTab: [file, data, extraInclude]
if ($isTabbed):
?> ?>
<div class="clear"></div> <div class="clear"></div>
<div id="tabs-generic"></div> <div id="tabs-generic"></div>
<?php endif; ?> <?php endif; ?>
<div id="lv-generic" class="listview"><?php <div id="lv-generic" class="listview">
foreach ($this->lvTabs as [$tplName, $tabData]): <?php
if ($tplName): foreach ($this->lvTabs?->getDataContainer() ?? [] as $container):
continue; echo ' '.$container."\n";
endif;
echo '<div class="text tabbed-contents" id="tab-'.$tabData['id'].'" style="display:none;">'.$tabData['data'].'</div>';
endforeach; endforeach;
?></div> ?>
</div>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
if (!empty($this->gemScores)): // inherited from items.tpl.php // seems like WH keeps their modules separated, as fi_gemScores should be with the other fi_ items but are here instead and originally the dbtype globals used by the listviews were also here)
echo " var fi_gemScores = ".Util::toJSON($this->gemScores).";\n"; // May 2025: WH no longer calculates gems into item scores. Dude .. why?
if ($this->gemScores) // set by ItemsBaseResponse
echo ' var fi_gemScores = '.$this->json($this->gemScores).";\n";
// g_items, g_spells, etc required by the listviews used to be here
echo $this->lvTabs;
if ($this->charactersLvData):
echo ' us_addCharactersTab('.$this->json('charactersLvData').");\n";
endif;
if ($this->profilesLvData):
echo ' us_addProfilesTab('.$this->json('profilesLvData').");\n";
endif;
if ($this->contribute & CONTRIBUTE_CO):
echo " new Listview({template: 'comment', id: 'comments', name: LANG.tab_comments".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_comments});\n";
endif;
if ($this->contribute & CONTRIBUTE_SS):
echo " new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_screenshots});\n";
endif;
if ($this->contribute & CONTRIBUTE_VI):
echo " if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))\n";
echo " new Listview({template: 'video', id: 'videos', name: LANG.tab_videos".($this->lvTabs ? ", tabs: ".$this->lvTabs->__tabVar : '').", parent: 'lv-generic', data: lv_videos});\n";
endif; endif;
if ($isTabbed): if ($flushTabs = $this->lvTabs?->getFlush()):
echo " var ".$tabVar." = new Tabs({parent: \$WH.ge('tabs-generic')".(isset($this->type) ? ", trackable: '".ucfirst(Type::getFileString($this->type)."'") : null)."});\n"; echo " ".$flushTabs."\n";
endif;
foreach ($this->lvTabs as [$tplName, $tabData, $include]):
if (empty($tabData['data']) && $relTabs && count($this->lvTabs) != 1):
continue;
endif;
if ($isTabbed):
$tabData['tabs'] = '$'.$tabVar;
endif;
if ($tplName):
// extra functions on top of lv
if (isset($include)):
$this->lvBrick($include);
endif;
if (isset($this->lvTemplates[$tplName])):
echo "new Listview(".Util::toJSON(array_merge($this->lvTemplates[$tplName], $tabData)).");\n";
else:
// does not appear as announcement, those have already been handled at this point
trigger_error('requested undefined listview: '.$tplName, E_USER_ERROR);
endif;
elseif ($isTabbed):
$n = $tabData['name'][0] == '$' ? substr($tabData['name'], 1) : "'".$tabData['name']."'";
echo $tabVar.".add(".$n.", { id: '".$tabData['id']."' });\n";
endif;
endforeach;
if (!empty($this->user)):
if (!empty($this->user['characterData'])):
echo ' us_addCharactersTab('.Util::toJSON($this->user['characterData']).");\n";
endif;
if (!empty($this->user['profileData'])):
echo ' us_addProfilesTab('.Util::toJSON($this->user['profileData']).");\n";
endif;
elseif ($relTabs):
if ($this->contribute & CONTRIBUTE_CO):
echo " new Listview({template: 'comment', id: 'comments', name: LANG.tab_comments, tabs: ".$tabVar.", parent: 'lv-generic', data: lv_comments});\n";
endif;
if ($this->contribute & CONTRIBUTE_SS):
echo " new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: ".$tabVar.", parent: 'lv-generic', data: lv_screenshots});\n";
endif;
if ($this->contribute & CONTRIBUTE_VI):
echo " if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))\n";
echo " new Listview({template: 'video', id: 'videos', name: LANG.tab_videos, tabs: ".$tabVar.", parent: 'lv-generic', data: lv_videos});\n";
endif;
endif;
if ($isTabbed):
echo " ".$tabVar.".flush();\n";
endif; endif;
?> ?>
//]]></script> //]]></script>

View File

@@ -1,11 +1,12 @@
<?php namespace Aowow; ?>
<?php <?php
if ($m = $this->mail): namespace Aowow\Template;
if (!isset($offset)) // in case we have multiple icons on the page (prominently quest-rewards)
$offset = 0;
echo ' <h3>'.sprintf(Lang::mail('mailDelivery'), $m['id'], $m['sender'], $m['delay'])."</h3>\n"; use \Aowow\Lang;
if ($m = $this->mail):
$offset ??= 0; // in case we have multiple icons on the page (prominently quest-rewards)
echo ' <h3>'.Lang::mail('mailDelivery', $m['header'])."</h3>\n";
if ($m['subject']): if ($m['subject']):
echo ' <div class="book"><div class="page">'.$m['subject']."</div></div>\n"; echo ' <div class="book"><div class="page">'.$m['subject']."</div></div>\n";
@@ -19,16 +20,16 @@ if ($m = $this->mail):
?> ?>
<table class="icontab icontab-box" style="padding-left:10px;"> <table class="icontab icontab-box" style="padding-left:10px;">
<?php <?php
foreach ($m['attachments'] as $k => $i): foreach ($m['attachments'] as $icon):
echo '<tr><th id="icontab-icon'.($k + 1 + $offset).'"></th><td><span class="q'.(isset($i['quality']) ? $i['quality'] : null).'"><a href="?'.$i['typeStr'].'='.$i['id'].'">'.$i['name']."</a></span></td></tr>\n"; echo $icon->renderContainer(20, $offset, true);
endforeach; endforeach;
?> ?>
</table> </table>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
foreach ($m['attachments'] as $k => $i): foreach ($m['attachments'] as $icon):
echo ' $WH.ge(\'icontab-icon'.($k + 1 + $offset).'\').appendChild('.$i['globalStr'].'.createIcon('.$i['id'].', 1, '.(empty($i['qty']) ? 0 : $i['qty'])."));\n"; echo $icon->renderJS();
endforeach; endforeach;
?> ?>
//]]></script> //]]></script>

View File

@@ -0,0 +1,8 @@
<?php if ($markup): ?>
<div id="<?=$markup->getParent(); ?>" class="left"></div>
<script type="text/javascript">//<![CDATA[
<?=$markup;?>
//]]></script>
<div class="pad2"></div>
<?php endif; ?>

View File

@@ -1,4 +1,8 @@
<?php namespace Aowow; ?> <?php
namespace Aowow\Template;
use \Aowow\Lang;
?>
<h3><?=Lang::spell('reagents'); ?></h3> <h3><?=Lang::spell('reagents'); ?></h3>
@@ -6,18 +10,20 @@
if ($enhanced): if ($enhanced):
?> ?>
<style type="text/css"> <style type="text/css">
.iconlist-col { float: left; width: 31%; margin-right: 2%; } .iconlist-col { float: left; width: 31%; margin-right: 2%; }
.iconlist { border-collapse: collapse; margin-top: 4px; } .iconlist { border-collapse: collapse; margin-top: 4px; }
.iconlist ul { margin: 0!important; padding: 0!important; } .iconlist ul { margin: 0!important; padding: 0!important; }
.iconlist ul li { list-style-position: inside; list-style-type: square; padding-left: 13px; } .iconlist ul li { list-style-position: inside; list-style-type: square; padding-left: 13px; }
.iconlist th { min-width: 18px; white-space: nowrap; } .iconlist th { min-width: 18px; white-space: nowrap; }
.iconlist td { padding: 4px 0 6px 0; } .iconlist td { padding: 4px 0 6px 0; }
.iconlist var { font-size: 1px; } .iconlist var { font-size: 1px; }
.iconlist .iconsmall { margin-right: 4px; } .iconlist .iconsmall { margin-right: 4px; }
.iconlist a.disclosure-on, .iconlist a.disclosure-off { font-weight: normal; text-decoration: underline; } .iconlist a.disclosure-on,
.iconlist .iconlist ul li { padding-left: 10px; } .iconlist a.disclosure-off { font-weight: normal; text-decoration: underline; }
.iconlist .iconlist th, .iconlist .iconlist td { font-size: 11px; } .iconlist .iconlist ul li { padding-left: 10px; }
.iconlist-col table th li { list-style-position: outside; padding: 0; margin-left: 20px; } .iconlist .iconlist th,
.iconlist .iconlist td { font-size: 11px; }
.iconlist-col table th li { list-style-position: outside; padding: 0; margin-left: 20px; }
</style> </style>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
function iconlist_showhide(spn) { function iconlist_showhide(spn) {
@@ -41,8 +47,8 @@ function iconlist_showhide(spn) {
trs = table.getElementsByTagName('tr'); trs = table.getElementsByTagName('tr');
var opening = spn.className.indexOf('disclosure-off') >= 0; var opening = spn.className.indexOf('disclosure-off') >= 0;
var isSpell = tr.id.substr(tr.id.lastIndexOf('.')+1, 1) == '6'; var isSpell = tr.id.substr(tr.id.lastIndexOf('.') + 1, 1) == '6';
var isItem = tr.id.substr(tr.id.lastIndexOf('.')+1, 1) == '3'; var isItem = tr.id.substr(tr.id.lastIndexOf('.') + 1, 1) == '3';
if (opening) { if (opening) {
if (isSpell) { //find any other open spells on this branch and close them if (isSpell) { //find any other open spells on this branch and close them
@@ -68,7 +74,7 @@ function iconlist_showhide(spn) {
if (isItem) { //check to see if there is one spell for this item.. if so, expand it if (isItem) { //check to see if there is one spell for this item.. if so, expand it
var spellCount = 0; var lastTr = 0; var spellCount = 0; var lastTr = 0;
for (var x = 0; x < trs.length; x++) { for (var x = 0; x < trs.length; x++) {
if ((trs[x].id.indexOf(tr.id+'.6') == 0) && (trs[x].id.lastIndexOf('-') == tr.id.length + 2)) { if ((trs[x].id.indexOf(tr.id + '.6') == 0) && (trs[x].id.lastIndexOf('-') == tr.id.length + 2)) {
spellCount++; spellCount++;
lastTr = x; lastTr = x;
} }
@@ -118,7 +124,7 @@ function iconlist_expandall(tableid,doexpand) {
continue; continue;
} }
if (trs[x].id.substr(trs[x].id.lastIndexOf('.')+1,1) == '6') { //is spell if (trs[x].id.substr(trs[x].id.lastIndexOf('.') + 1, 1) == '6') { //is spell
var skipOut = false; var skipOut = false;
var thisItem = trs[x].id.substr(0,trs[x].id.lastIndexOf('.')); var thisItem = trs[x].id.substr(0,trs[x].id.lastIndexOf('.'));
@@ -151,7 +157,7 @@ function iconlist_expandall(tableid,doexpand) {
continue; continue;
} }
var spn = document.getElementById('spn.'+trs[x].id); var spn = document.getElementById('spn.' + trs[x].id);
if (spn && spn.className.indexOf('disclosure-on') >= 0) { if (spn && spn.className.indexOf('disclosure-on') >= 0) {
iconlist_showhide(spn); iconlist_showhide(spn);
} }
@@ -170,32 +176,33 @@ if ($enhanced):
<tr> <tr>
<th></th> <th></th>
<th align="left"> <th align="left">
<input type="button" style="font-size: 11px; margin-right: 0.5em" onclick="iconlist_expandall('reagent-list-generic',true);" value="<?=Lang::spell('_expandAll'); ?>"> <input type="button" style="font-size: 11px; margin-right: 0.5em" onclick="iconlist_expandall('reagent-list-generic', true);" value="<?=Lang::spell('_expandAll'); ?>">
<input type="button" style="font-size: 11px; margin-right: 0.5em" onclick="iconlist_expandall('reagent-list-generic',false);" value="<?=Lang::spell('_collapseAll'); ?>"> <input type="button" style="font-size: 11px; margin-right: 0.5em" onclick="iconlist_expandall('reagent-list-generic', false);" value="<?=Lang::spell('_collapseAll'); ?>">
</th> </th>
</tr> </tr>
<?php <?php
endif; endif;
foreach ($reagents as $k => $itr): foreach ($reagents as $k => ['path' => $path, 'level' => $level, 'final' => $final, 'typeStr' => $typeStr, 'icon' => $icon]):
echo '<tr id="reagent-list-generic.'.$itr['path'].'"'.($itr['level'] ? ' style="display: none"' : null).'><th align="right" id="iconlist-icon'.$k.'"></th>' . $icon->renderContainer(0, $k); // just to set offset
'<td'.($itr['level'] ? ' style="padding-left: '.$itr['level'].'em"' : null).'>'; echo '<tr id="reagent-list-generic.'.$path.'"'.($level ? ' style="display: none"' : '').'><th align="right" id="iconlist-icon'.$k.'"></th>' .
'<td'.($level ? ' style="padding-left: '.$level.'em"' : '').'>';
if (!empty($itr['final']) && $enhanced): if ($final && $enhanced):
echo '<div class="iconlist-tree" style="width: 15px; float: left">&nbsp;</div>'; echo '<div class="iconlist-tree" style="width: 15px; float: left">&nbsp;</div>';
elseif ($enhanced): elseif ($enhanced):
echo '<div class="iconlist-tree disclosure-off" onclick="iconlist_showhide(this);" style="padding-left: 0; cursor: pointer; width: 15px; float: left" id="spn.reagent-list-generic.'.$itr['path'].'">&nbsp;</div>'; echo '<div class="iconlist-tree disclosure-off" onclick="iconlist_showhide(this);" style="padding-left: 0; cursor: pointer; width: 15px; float: left" id="spn.reagent-list-generic.'.$path.'">&nbsp;</div>';
endif; endif;
echo '<span class="q'.($itr['type'] == Type::ITEM ? $itr['quality'] : null).'"><a href="?'.$itr['typeStr'].'='.$itr['typeId'].'">'.$itr['name'].'</a></span>'.($itr['qty'] > 1 ? '&nbsp;('.$itr['qty'].')' : null)."</td></tr>\n"; echo '<span class="'.$icon->quality.'"><a href="?'.$typeStr.'='.$icon->typeId.'">'.$icon->text.'</a></span>'.($icon->num > 1 ? '&nbsp;('.$icon->num.')' : '')."</td></tr>\n";
endforeach; endforeach;
?> ?>
</table> </table>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
foreach ($reagents as $k => $itr): foreach ($reagents as ['icon' => $icon]):
echo "\$WH.ge('iconlist-icon".$k."').appendChild(g_".$itr['typeStr']."s.createIcon(".$itr['typeId'].", 0, ".$itr['qty']."));\n"; echo $icon->renderJS(4);
endforeach; endforeach;
?> ?>
//]]></script> //]]></script>

View File

@@ -1,12 +1,10 @@
<?php namespace Aowow; ?>
<?php <?php
namespace Aowow\Template;
if (!isset($offset)) // in case we have multiple icons on the page (prominently quest-rewards) $offset ??= 0; // in case we have multiple icons on the page (prominently quest-rewards)
$offset = 0;
if ($rewTitle): if ($rewTitle):
echo $rewTitle.Lang::main('colon').(isset($extra) ? $extra : null); echo $rewTitle.' '.($extra ?? '')."\n";
endif; endif;
if ($rewards): if ($rewards):
@@ -15,9 +13,10 @@ if ($rewards):
<table class="icontab icontab-box"> <table class="icontab icontab-box">
<tr> <tr>
<?php <?php
foreach ($rewards as $k => $i): $last = array_key_last($rewards);
echo '<th id="icontab-icon'.($k + 1 + $offset).'"></th><td><span class="q'.(isset($i['quality']) ? $i['quality'] : null).'"><a href="?'.$i['typeStr'].'='.$i['id'].'">'.$i['name']."</a></span></td>\n"; foreach ($rewards as $k => $icon):
echo $k % 2 ? '</tr><tr>' : null; echo $icon->renderContainer(24, $offset);
echo $k % 2 && $k != $last ? str_repeat(' ', 24) . "</tr><tr>" : '';
endforeach; endforeach;
if (count($rewards) % 2): if (count($rewards) % 2):
@@ -29,8 +28,8 @@ if ($rewards):
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
<?php <?php
foreach ($rewards as $k => $i): foreach ($rewards as $icon):
echo ' $WH.ge(\'icontab-icon'.($k + 1 + $offset).'\').appendChild('.$i['globalStr'].'.createIcon('.$i['id'].', 1, '.(empty($i['qty']) ? 0 : $i['qty'])."));\n"; echo $icon->renderJS(20);
endforeach; endforeach;
?> ?>
//]]></script> //]]></script>

View File

@@ -1,4 +1,8 @@
<?php namespace Aowow; ?> <?php
namespace Aowow\Template;
use \Aowow\Lang;
?>
<tr><th id="infobox-series"><?=$listTitle ?: Lang::achievement('series'); ?></th></tr> <tr><th id="infobox-series"><?=$listTitle ?: Lang::achievement('series'); ?></th></tr>
<tr><td> <tr><td>
@@ -6,26 +10,7 @@
<table class="series"> <table class="series">
<?php <?php
foreach ($list as $idx => $itr): foreach ($list as $idx => $itr):
echo ' <tr><th>'.($idx + 1).'</th><td><div>'; echo $this->renderSeriesItem($idx, $itr, 12);
$_ = array_keys($itr);
$end = array_pop($_);
foreach ($itr as $k => $i): // itemItr
switch ($i['side']):
case 1: $wrap = '<span class="icon-alliance-padded">%s</span>'; break;
case 2: $wrap = '<span class="icon-horde">%s</span>'; break;
default: $wrap = '%s'; break;
endswitch;
if ($i['typeId'] == $this->typeId):
echo sprintf($wrap, '<b>'.$i['name'].'</b>');
else:
echo sprintf($wrap, '<a href="?'.$i['typeStr'].'='.$i['typeId'].'">'.$i['name'].'</a>');
endif;
echo $end == $k ? null : '<br />';
endforeach;
echo "</div></td></tr>\n";
endforeach; endforeach;
?> ?>
</table> </table>