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.')"'
);
return [null, $tab];
return $tab;
}
// $keyX params are string(ref to lv column) or int(fixed value)

View File

@@ -651,32 +651,31 @@ class SmartAI
return true;
}
public function getMarkdown() : string
public function getMarkup() : ?Markup
{
# id | event (footer phase) | chance | action + target
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)
{
$wrapper = '[tabs name=sai width=942px]%s[/tabs]';
$return = '[script]function TalTabClick(id) { $(\'#dsf67g4d-sai\').find(\\\'[href=\\\\\'#sai-actionlist-\' + id + \'\\\\\']\\\').click(); }[/script]' . $return;
$tabs = '';
$return = "[script]function TalTabClick(id) { $('#dsf67g4d-sai').find('[href=\'#sai-actionlist-' + id + '\']').click(); }[/script]" . $return;
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)
$tabs .= $buff;
else
$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

View File

@@ -713,12 +713,12 @@ class SmartAction
break;
case self::ACTION_TALK: // 1 -> any target
case self::ACTION_SIMPLE_TALK: // 84 -> any target
$noSrc = false;
if ($npcId = $this->smartAI->getTarget()->getTalkSource($noSrc))
$playerSrc = false;
if ($npcId = $this->smartAI->getTarget()->getTalkSource($playerSrc))
{
if ($quotes = $this->smartAI->getQuote($npcId, $this->param[0], $npcSrc))
foreach ($quotes as ['text' => $text, 'prefix' => $prefix])
$this->param[10] .= sprintf($text, $noSrc ? '' : sprintf($prefix, $npcSrc), $npcSrc);
foreach ($quotes as ['text' => $text])
$this->param[10] .= sprintf($text, $playerSrc ? Lang::main('thePlayer') : $npcSrc);
}
else
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);
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

View File

@@ -191,24 +191,23 @@ class Game
return $data;
}
public static function getPageText($ptId)
public static function getBook(int $ptId, ?int $startPage = null) : ?Book
{
$pages = [];
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'];
$pages[] = Util::parseHtmlText(Util::localizedString($row, 'Text'));
}
else
{
trigger_error('Referenced PageTextId #'.$ptId.' is not in DB', E_USER_WARNING);
break;
$pages[] = Util::localizedString($row, 'Text');
continue;
}
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
@@ -256,40 +255,33 @@ class Game
if ($talkSource)
$msg = sprintf($msg, $talkSource);
// make type css compatible
switch ($t['talkType'])
// convert [old, new] talkType to css compatible
$t['talkType'] = match ((int)$t['talkType'])
{
case 1: // yell:
case 14: $t['talkType'] = 1; break; // - dark red
case 2: // emote:
case 16: // "
case 3: // boss emote:
case 41: $t['talkType'] = 4; break; // - orange
case 4: // whisper:
case 15: // "
case 5: // boss whisper:
case 42: $t['talkType'] = 3; break; // - pink-ish
default: $t['talkType'] = 2; // [type: 0, 12] say: yellow-ish
}
0, 12 => 2, // say - yellow-ish
1, 14 => 1, // yell - dark red
2, 16, // emote
3, 41 => 4, // boss emote - orange
4, 15, // whisper
5, 42 => 3, // boss whisper - pink-ish
default => 2
};
// prefix
$pre = '';
$prefix = '%s ';
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)
$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
$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(
'range' => $t['range'],
'text' => $msg,
'prefix' => $pre
'text' => $msg
);
$nQuotes++;
$group[] = $line;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -74,7 +74,7 @@ class AreaTriggerPage extends GenericPage
$this->map = $map;
$this->infobox = false;
$this->smartAI = $sai?->getMarkdown();
$this->smartAI = $sai?->getMarkup();
$this->redButtons = array(
BUTTON_LINKS => 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');
// pageText
$pageText = [];
if ($this->pageText = Game::getPageText($this->subject->getField('pageTextId')))
if ($this->pageText = Game::getBook($this->subject->getField('pageTextId')))
$this->addScript(
[SC_JS_FILE, 'js/Book.js'],
[SC_CSS_FILE, 'css/Book.css']

View File

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

View File

@@ -212,7 +212,7 @@ class ObjectPage extends GenericPage
/****************/
// pageText
if ($this->pageText = Game::getPageText($this->subject->getField('pageTextId')))
if ($this->pageText = Game::getBook($this->subject->getField('pageTextId')))
$this->addScript(
[SC_JS_FILE, 'js/Book.js'],
[SC_CSS_FILE, 'css/Book.css']
@@ -271,7 +271,7 @@ class ObjectPage extends GenericPage
$this->map = $map;
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null;
$this->relBoss = $relBoss;
$this->smartAI = $sai ? $sai->getMarkdown() : null;
$this->smartAI = $sai ? $sai->getMarkup() : null;
$this->redButtons = array(
BUTTON_WOWHEAD => true,
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 $id => $data):
?>
<div id="announcement-<?=$id; ?>"></div>
foreach ($this->announcements as $a): ?>
<div id="announcement-<?=$a->id;?>"></div>
<script type="text/javascript">
new Announcement(<?=Util::toJSON($data); ?>);
<?=$a;?>
</script>
<?php
endforeach;
?>
<?php 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
if (!empty($this->pageText)):
?>
namespace Aowow\Template;
use \Aowow\Lang;
if ($this->book): ?>
<div class="clear"></div>
<h3><?=Lang::item('content'); ?></h3>
<div id="book-generic"></div>
<script>//<![CDATA[
new Book({ parent: 'book-generic', pages: <?=Util::toJSON($this->pageText); ?>})
<?=$this->book; ?>
//]]></script>
<?php
endif;
?>
<?php endif; ?>

View File

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

View File

@@ -1,86 +1,53 @@
<?php namespace Aowow; ?>
<?php
namespace Aowow\Template;
use \Aowow\Lang;
?>
<?php
if (!empty($this->lvTabs) || !empty($this->user['characterData']) || !empty($this->user['profileData']) || $this->contribute):
$relTabs = !empty($relTabs);
$tabVar = $relTabs || !empty($this->user) ? 'tabsRelated' : 'myTabs';
$isTabbed = !empty($this->forceTabs) || $relTabs || count($this->lvTabs) > 1;
// lvTab: [file, data, extraInclude]
if ($isTabbed):
if (($this->lvTabs && count($this->lvTabs)) || $this->charactersLvData || $this->profilesLvData || $this->contribute):
if ($this->lvTabs?->isTabbed()):
?>
<div class="clear"></div>
<div id="tabs-generic"></div>
<?php endif; ?>
<div id="lv-generic" class="listview"><?php
foreach ($this->lvTabs as [$tplName, $tabData]):
if ($tplName):
continue;
endif;
echo '<div class="text tabbed-contents" id="tab-'.$tabData['id'].'" style="display:none;">'.$tabData['data'].'</div>';
<div id="lv-generic" class="listview">
<?php
foreach ($this->lvTabs?->getDataContainer() ?? [] as $container):
echo ' '.$container."\n";
endforeach;
?></div>
?>
</div>
<script type="text/javascript">//<![CDATA[
<?php
if (!empty($this->gemScores)): // inherited from items.tpl.php
echo " var fi_gemScores = ".Util::toJSON($this->gemScores).";\n";
// 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)
// 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;
if ($isTabbed):
echo " var ".$tabVar." = new Tabs({parent: \$WH.ge('tabs-generic')".(isset($this->type) ? ", trackable: '".ucfirst(Type::getFileString($this->type)."'") : null)."});\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";
if ($flushTabs = $this->lvTabs?->getFlush()):
echo " ".$flushTabs."\n";
endif;
?>
//]]></script>

View File

@@ -1,11 +1,12 @@
<?php namespace Aowow; ?>
<?php
if ($m = $this->mail):
if (!isset($offset)) // in case we have multiple icons on the page (prominently quest-rewards)
$offset = 0;
namespace Aowow\Template;
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']):
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;">
<?php
foreach ($m['attachments'] as $k => $i):
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";
foreach ($m['attachments'] as $icon):
echo $icon->renderContainer(20, $offset, true);
endforeach;
?>
</table>
<script type="text/javascript">//<![CDATA[
<?php
foreach ($m['attachments'] as $k => $i):
echo ' $WH.ge(\'icontab-icon'.($k + 1 + $offset).'\').appendChild('.$i['globalStr'].'.createIcon('.$i['id'].', 1, '.(empty($i['qty']) ? 0 : $i['qty'])."));\n";
foreach ($m['attachments'] as $icon):
echo $icon->renderJS();
endforeach;
?>
//]]></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>
@@ -6,18 +10,20 @@
if ($enhanced):
?>
<style type="text/css">
.iconlist-col { float: left; width: 31%; margin-right: 2%; }
.iconlist { border-collapse: collapse; margin-top: 4px; }
.iconlist ul { margin: 0!important; padding: 0!important; }
.iconlist ul li { list-style-position: inside; list-style-type: square; padding-left: 13px; }
.iconlist th { min-width: 18px; white-space: nowrap; }
.iconlist td { padding: 4px 0 6px 0; }
.iconlist var { font-size: 1px; }
.iconlist .iconsmall { margin-right: 4px; }
.iconlist a.disclosure-on, .iconlist a.disclosure-off { font-weight: normal; text-decoration: underline; }
.iconlist .iconlist ul li { padding-left: 10px; }
.iconlist .iconlist th, .iconlist .iconlist td { font-size: 11px; }
.iconlist-col table th li { list-style-position: outside; padding: 0; margin-left: 20px; }
.iconlist-col { float: left; width: 31%; margin-right: 2%; }
.iconlist { border-collapse: collapse; margin-top: 4px; }
.iconlist ul { margin: 0!important; padding: 0!important; }
.iconlist ul li { list-style-position: inside; list-style-type: square; padding-left: 13px; }
.iconlist th { min-width: 18px; white-space: nowrap; }
.iconlist td { padding: 4px 0 6px 0; }
.iconlist var { font-size: 1px; }
.iconlist .iconsmall { margin-right: 4px; }
.iconlist a.disclosure-on,
.iconlist a.disclosure-off { font-weight: normal; text-decoration: underline; }
.iconlist .iconlist ul li { padding-left: 10px; }
.iconlist .iconlist th,
.iconlist .iconlist td { font-size: 11px; }
.iconlist-col table th li { list-style-position: outside; padding: 0; margin-left: 20px; }
</style>
<script type="text/javascript">//<![CDATA[
function iconlist_showhide(spn) {
@@ -41,8 +47,8 @@ function iconlist_showhide(spn) {
trs = table.getElementsByTagName('tr');
var opening = spn.className.indexOf('disclosure-off') >= 0;
var isSpell = tr.id.substr(tr.id.lastIndexOf('.')+1, 1) == '6';
var isItem = tr.id.substr(tr.id.lastIndexOf('.')+1, 1) == '3';
var isSpell = tr.id.substr(tr.id.lastIndexOf('.') + 1, 1) == '6';
var isItem = tr.id.substr(tr.id.lastIndexOf('.') + 1, 1) == '3';
if (opening) {
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
var spellCount = 0; var lastTr = 0;
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++;
lastTr = x;
}
@@ -118,7 +124,7 @@ function iconlist_expandall(tableid,doexpand) {
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 thisItem = trs[x].id.substr(0,trs[x].id.lastIndexOf('.'));
@@ -151,7 +157,7 @@ function iconlist_expandall(tableid,doexpand) {
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) {
iconlist_showhide(spn);
}
@@ -170,32 +176,33 @@ if ($enhanced):
<tr>
<th></th>
<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',false);" value="<?=Lang::spell('_collapseAll'); ?>">
<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'); ?>">
</th>
</tr>
<?php
endif;
foreach ($reagents as $k => $itr):
echo '<tr id="reagent-list-generic.'.$itr['path'].'"'.($itr['level'] ? ' style="display: none"' : null).'><th align="right" id="iconlist-icon'.$k.'"></th>' .
'<td'.($itr['level'] ? ' style="padding-left: '.$itr['level'].'em"' : null).'>';
foreach ($reagents as $k => ['path' => $path, 'level' => $level, 'final' => $final, 'typeStr' => $typeStr, 'icon' => $icon]):
$icon->renderContainer(0, $k); // just to set offset
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>';
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;
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;
?>
</table>
<script type="text/javascript">//<![CDATA[
<?php
foreach ($reagents as $k => $itr):
echo "\$WH.ge('iconlist-icon".$k."').appendChild(g_".$itr['typeStr']."s.createIcon(".$itr['typeId'].", 0, ".$itr['qty']."));\n";
foreach ($reagents as ['icon' => $icon]):
echo $icon->renderJS(4);
endforeach;
?>
//]]></script>

View File

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