moved articles to template-class .. and am fed up with smarty by now..

This commit is contained in:
Sarjuuk
2013-06-27 22:04:45 +02:00
parent 3d66eacb90
commit bbfc4f5820
7 changed files with 456 additions and 336 deletions

View File

@@ -309,6 +309,60 @@ trait listviewHelper
}
trait spawnHelper
{
private static $spawnQuery = " SELECT a.guid AS ARRAY_KEY, map, position_x, position_y, spawnMask, phaseMask, spawntimesecs, eventEntry, pool_entry AS pool FROM ?# a LEFT JOIN ?# b ON a.guid = b.guid LEFT JOIN ?# c ON a.guid = c.guid WHERE id = ?d";
private function fetch()
{
if (!$this->id)
return false;
switch (get_class($this))
{
case 'CreatureList':
return DB::Aowow()->select(self::$spawnQuery, 'creature', 'game_event_creature', 'pool_creature', $this->id);
case 'GameObjectList':
return DB::Aowow()->select(self::$spawnQuery, 'gameobject', 'game_event_gameobject', 'pool_gameobject', $this->id);
default:
return false;
}
}
public function getSpawns($short = false)
{
// short: true => only the most populated area and only coordinates
$data = [];
$raw = $this->fetch();
if (!$raw)
return [];
/*
long:
$data = array(
areaId => array(
floorNo => array (
posX =>
posY =>
respawn =>
phaseMask =>
spawnMask =>
eventId =>
poolId =>
)
)
)
short: zoneId, [pos-sets]
$data = [6456, [[51,42.2],[51,43]]];
*/
return $data;
}
}
class Lang
{
public static $main;
@@ -584,10 +638,55 @@ class SmartyAoWoW extends Smarty
public function display($tpl)
{
// since it's the same for every page, except index..
if ($this->_tpl_vars['query'][0] && !preg_match('/[^a-z]/i', $this->_tpl_vars['query'][0]))
$tv = &$this->_tpl_vars;
$_ = [];
if ($tv['page']['type'] && $tv['page']['typeId'])
{
$ann = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE status = 1 AND (page = ?s OR page = "*")', $this->_tpl_vars['query'][0]);
if ($article = DB::Aowow()->selectRow('SELECT id, article, quickInfo FROM ?_articles WHERE type = ?d AND typeId = ?d AND locale = ?d', $tv['page']['type'], $tv['page']['typeId'], User::$localeId))
{
$globals = DB::Aowow()->select('SELECT type, typeId FROM ?_article_items WHERE id = ?d', $article['id']);
$tv['article'] = $article['article'];
@$tv['infoBox'] .= $article['quickInfo'];
foreach ($globals as $glob)
{
if (!isset($_[$glob['type']]))
$_[$glob['type']] = [];
$_[$glob['type']][] = $glob['typeId'];
}
foreach ($_ as $type => $ids)
{
switch ($type)
{
case TYPE_NPC: (new CreatureList(array(['ct.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_OBJECT: (new GameobjectList(array(['gt.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_ITEM: (new ItemList(array(['it.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_ITEMSET: (new ItemsetList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_QUEST: (new QuestList(array(['qt.entry', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_SPELL: (new SpellList(array(['s.id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_ZONE: (new ZoneList(array(['z.id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_FACTION: (new FactionList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_PET: (new PetList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_ACHIEVEMENT: (new AchievementList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_TITLE: (new TitleList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_WORLDEVENT: (new WorldEventList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_CLASS: (new CharClassList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_RACE: (new CharRaceList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_SKILL: (new SkillList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
case TYPE_CURRENCY: (new CurrencyList(array(['id', $ids])))->addGlobalsToJscript($tv['lvData']); break;
}
}
}
}
// since it's the same for every page, except index..
if ($tv['query'][0] && !preg_match('/[^a-z]/i', $tv['query'][0]))
{
$ann = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE status = 1 AND (page = ?s OR page = "*")', $tv['query'][0]);
foreach ($ann as $k => $v)
{
if ($t = Util::localizedString($v, 'text'))

View File

@@ -164,7 +164,6 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
'title' => $name, // for header
'path' => $path,
'infobox' => $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : null,
'article' => null, // todo (med): hmm, move to $smarty..?
'pieces' => $pieces,
'spells' => $spells,
'view3D' => json_encode($eqList, JSON_NUMERIC_CHECK),

View File

@@ -3,16 +3,20 @@
<div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
{include file='bricks/community.tpl'}
var g_pageInfo = {ldelim}type: {$page.type}, typeId: {$page.typeId}, name: '{$lvData.page.name|escape:"quotes"}'{rdelim}; // username:XXX in profiles
g_initPath({$page.path});
</script>
//]]></script>
{* include file='bricks/infobox.tpl' *}
<table class="infobox">
<tr><th>{$lang.quickFacts}</th></tr>
@@ -25,7 +29,7 @@
{*<li><div>Location: {$lvData.page.location}</div></li> todo: need to be parsed first *}
</ul>
</td></tr>
{strip}{*************** CHAIN OF ACHIEVEMENTS ***************}
{strip}{*************** CHAIN OF ACHIEVEMENTS ***************}
{if isset($lvData.page.series)}
<tr><th>{$lang.series}</th></tr>
<tr><td><div class="infobox-spacer"></div>
@@ -59,13 +63,11 @@
<div id="h1-icon-generic" class="h1-icon"></div>
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
ge('h1-icon-generic').appendChild(Icon.create('{$lvData.page.iconname|escape:"javascript"}', 1));
</script>
//]]></script>
<a href="javascript:;" id="open-links-button" class="button-red" onclick="this.blur();
Links.show({ldelim} type: 10, typeId: {$lvData.page.id}, linkColor: 'ffffff00', linkId: '{$lvData.page.id}:&quot;..UnitGUID(&quot;player&quot;)..&quot;:0:0:0:0:0:0:0:0', linkName: '{$lvData.page.name|escape:'javascript'}' {rdelim});">
<em><b><i>{$lang.links}</i></b><span>{$lang.links}</span></em></a>
<a href="javascript:;" id="open-links-button" class="button-red" onclick="this.blur(); Links.show({ldelim} type: 10, typeId: {$lvData.page.id}, linkColor: 'ffffff00', linkId: '{$lvData.page.id}:&quot;..UnitGUID(&quot;player&quot;)..&quot;:0:0:0:0:0:0:0:0', linkName: '{$lvData.page.name|escape:'javascript'}' {rdelim});"><em><b><i>{$lang.links}</i></b><span>{$lang.links}</span></em></a>
<a href="http://old.wowhead.com/?{$query[0]}={$query[1]}" class="button-red"><em><b><i>Wowhead</i></b><span>Wowhead</span></em></a>
<h1 class="h1-icon">{$lvData.page.name}</h1>
@@ -105,11 +107,11 @@
</div>
{strip}
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
{foreach from=$lvData.page.icons item=ic}
ge('iconlist-icon{$ic.itr}').appendChild({$ic.type}.createIcon({$ic.id}, 0, {if isset($ic.count) && $ic.count > 0}{$ic.count}{else}0{/if}));
{/foreach}
</script>
//]]></script>
{/strip}
@@ -123,11 +125,11 @@
{foreach from=$lvData.page.itemReward item=i name=item key=id}
<th id="icontab-icon{$smarty.foreach.item.index}"></th><td><span class="q{$i.quality}"><a href="?item={$id}">{$i.name}</a></span></td>
{/foreach}
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
{foreach from=$lvData.page.itemReward item=i name=item key=id}
ge('icontab-icon{$smarty.foreach.item.index}').appendChild(g_items.createIcon({$id}, 1, 1));
{/foreach}
</script>
//]]></script>
</tr>
</table>
{/if}
@@ -148,16 +150,16 @@
<div id="tabs-generic"></div>
<div id="listview-generic" class="listview"></div>
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
var tabsRelated = new Tabs({ldelim}parent: ge('tabs-generic'){rdelim});
{if $lvData.page.saData} {include file='bricks/listviews/achievement.tpl' data=$lvData.page.saData params=$lvData.page.saParams}{/if}
{if isset($lvData.page.coData)} {include file='bricks/listviews/achievement.tpl' data=$lvData.page.coData params=$lvData.page.coParams}{/if}
{if $lvData.page.saData} {include file='bricks/listviews/achievement.tpl' data=$lvData.page.saData params=$lvData.page.saParams}{/if}
{if isset($lvData.page.coData)} {include file='bricks/listviews/achievement.tpl' data=$lvData.page.coData params=$lvData.page.coParams}{/if}
new Listview({ldelim}template: 'comment', id: 'comments', name: LANG.tab_comments, tabs: tabsRelated, parent: 'listview-generic', data: lv_comments{rdelim});
new Listview({ldelim}template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: tabsRelated, parent: 'listview-generic', data: lv_screenshots{rdelim});
if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))
new Listview({ldelim}template: 'video', id: 'videos', name: LANG.tab_videos, tabs: tabsRelated, parent: 'listview-generic', data: lv_videos{rdelim});
tabsRelated.flush();
</script>
//]]></script>
{include file='bricks/contribute.tpl'}

View File

@@ -0,0 +1,8 @@
{if !empty($article)}
<div id="article-generic" class="left"></div>
<script type="text/javascript">//<![CDATA[
Markup.printHtml("{$article}", "article-generic", {ldelim}mode:Markup.MODE_ARTICLE{rdelim});
//]]></script>
<div class="pad2"></div>
{/if}

View File

@@ -3,17 +3,18 @@
<div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
{include file='bricks/community.tpl'}
var g_pageInfo = {ldelim}type: {$page.type}, typeId: {$page.typeId}, name: '{$lvData.page.name|escape:"quotes"}'{rdelim};
g_initPath({$page.path});
</script>
//]]></script>
{include file='bricks/infobox.tpl'}
@@ -24,12 +25,7 @@
<a href="{if $lvData.page.id > 0}http://old.wowhead.com/?{$query[0]}={$query[1]}{else}javascript:;{/if}" class="button-red{if $lvData.page.id < 0} button-red-disabled{/if}"><em><b><i>Wowhead</i></b><span>Wowhead</span></em></a>
<h1>{$lvData.page.name}</h1>
{if $lvData.article}
<div id="article-generic" class="left"></div>
<script type="text/javascript">//<![CDATA[
Markup.printHtml("{$lvData.article}", "article-generic", {ldelim}mode:Markup.MODE_ARTICLE{rdelim});
//]]></script>
{/if}
{include file='bricks/article.tpl'}
{$lvData.page.description}
@@ -45,11 +41,11 @@
{/section}
</table>
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
{section name=i loop=$lvData.pieces}
ge('iconlist-icon{$smarty.section.i.index + 1}').appendChild(g_items.createIcon({$lvData.pieces[i].id}, 0, 0));
{/section}
</script>
//]]></script>
{if $lvData.page.unavailable}
<div class="pad"></div><b style="color: red">{$lang._unavailable}</b>
@@ -86,7 +82,7 @@
tabsRelated.flush();
//]]></script>
{include file='bricks/contribute.tpl'}
{include file='bricks/contribute.tpl'}
</div><!-- main-contents -->
</div><!-- main -->

View File

@@ -1,10 +1,16 @@
{include file='header.tpl'}
{assign var="iconlist1" value="1"}
{assign var="iconlist2" value="1"}
<div id="main">
<div id="main-precontents"></div>
<div id="main">
<div id="main-precontents" class="main-precontents"></div>
<div id="main-contents" class="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">
{include file='bricks/community.tpl'}
var g_pageInfo = {ldelim}type: {$page.type}, typeId: {$page.typeId}, name: '{$lvData.page.name|escape:"javascript"}'{rdelim};
@@ -71,6 +77,9 @@
{if $lvData.page.reagents}</div>{/if}{/if}
<div class="clear"></div>
{include file='bricks/article.tpl'}
<h3>{$lang._spellDetails}</h3>
<table class="grid" id="spelldetails">
@@ -179,7 +188,7 @@
<div id="tabs-generic"></div>
<div id="listview-generic" class="listview"></div>
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
var tabsRelated = new Tabs({ldelim}parent: ge('tabs-generic'){rdelim});
{if isset($lvData.taughtbynpc)} {include file='bricks/listviews/creature.tpl' data=$lvData.taughtbynpc.data params=$lvData.taughtbynpc.params } {/if}
{if isset($lvData.taughtbyitem)} {include file='bricks/listviews/item.tpl' data=$lvData.taughtbyitem.data params=$lvData.taughtbyitem.params } {/if}
@@ -192,10 +201,15 @@
{if isset($lvData.seealso)} {include file='bricks/listviews/spell.tpl' data=$lvData.seealso.data params=$lvData.seealso.params } {/if}
{if isset($lvData.criteria_of)} {include file='bricks/listviews/achievement.tpl' data=$lvData.criteria_of.data params=$lvData.criteria_of.params } {/if}
new Listview({ldelim}template: 'comment', id: 'comments', name: LANG.tab_comments, tabs: tabsRelated, parent: 'listview-generic', data: lv_comments{rdelim});
new Listview({ldelim}template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: tabsRelated, parent: 'listview-generic', data: lv_screenshots{rdelim});
if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))
new Listview({ldelim}template: 'video', id: 'videos', name: LANG.tab_videos, tabs: tabsRelated, parent: 'listview-generic', data: lv_videos{rdelim});
tabsRelated.flush();
</script>
{include file='bricks/contribute.tpl'}
</div>
</div>
//]]></script>
{include file='bricks/contribute.tpl'}
</div><!-- main-contents -->
</div><!-- main -->
{include file='footer.tpl'}

View File

@@ -3,26 +3,28 @@
<div class="main" id="main">
<div class="main-precontents" id="main-precontents"></div>
<div class="main-contents" id="main-contents">
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">
<script type="text/javascript">//<![CDATA[
{include file='bricks/community.tpl'}
var g_pageInfo = {ldelim}type: {$page.type}, typeId: {$page.typeId}, name: '{$lvData.page.name|escape:"quotes"}'{rdelim};
g_initPath({$page.path});
</script>
//]]></script>
{include file='bricks/infobox.tpl'}
<div class="text">
<a href="javascript:;" id="open-links-button" class="button-red" onclick="this.blur(); Links.show({ldelim} type: 11, typeId: {$lvData.page.id} {rdelim});">
<em><b><i>{$lang.links}</i></b><span>{$lang.links}</span></em>
</a>
<a href="javascript:;" id="open-links-button" class="button-red" onclick="this.blur(); Links.show({ldelim} type: 11, typeId: {$lvData.page.id} {rdelim});"><em><b><i>{$lang.links}</i></b><span>{$lang.links}</span></em></a>
<a href="http://old.wowhead.com/?{$query[0]}={$query[1]}" class="button-red"><em><b><i>Wowhead</i></b><span>Wowhead</span></em></a>
<h1 class="h1-icon">{if isset($lvData.page.expansion)}<span class="{$lvData.page.expansion}-icon-right">{$lvData.page.name}</span>{else}{$lvData.page.name}{/if}</h1>
{include file='bricks/article.tpl'}
<h2 class="clear">{$lang.related}</h2>
</div>
@@ -30,8 +32,8 @@
<div id="listview-generic" class="listview"></div>
<script type="text/javascript">//<![CDATA[
var tabsRelated = new Tabs({ldelim}parent: ge('tabs-generic'){rdelim});
{if isset($lvData.page.acvReward)} {include file='bricks/listviews/achievement.tpl' data=$lvData.page.acvReward params=$lvData.page.acvParams } {/if}
{if isset($lvData.page.questReward)} {include file='bricks/listviews/quest.tpl' data=$lvData.page.questReward params=$lvData.page.questParams} {/if}
{if isset($lvData.page.acvReward)} {include file='bricks/listviews/achievement.tpl' data=$lvData.page.acvReward params=$lvData.page.acvParams } {/if}
{if isset($lvData.page.questReward)} {include file='bricks/listviews/quest.tpl' data=$lvData.page.questReward params=$lvData.page.questParams} {/if}
new Listview({ldelim}template: 'comment', id: 'comments', name: LANG.tab_comments, tabs: tabsRelated, parent: 'listview-generic', data: lv_comments{rdelim});
new Listview({ldelim}template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: tabsRelated, parent: 'listview-generic', data: lv_screenshots{rdelim});
if (lv_videos.length || (g_user && g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_VIDEO)))
@@ -39,7 +41,7 @@
tabsRelated.flush();
//]]></script>
{include file='bricks/contribute.tpl'}
{include file='bricks/contribute.tpl'}
</div><!-- main-contents -->
</div><!-- main -->