moved announcements to template-class .. its the same for every single page...

This commit is contained in:
Sarjuuk
2013-03-10 23:43:53 +01:00
parent 74df6f77ef
commit 1ff2819de9
17 changed files with 95 additions and 125 deletions

View File

@@ -70,6 +70,21 @@ class Smarty_AoWoW extends Smarty
$this->_tpl_vars['page'][$var] = $val;
}
public function display($tpl)
{
// since it's the same for every page, except index..
if ($this->_tpl_vars['query'][0])
{
$ann = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = ?s OR page = "*")', $this->_tpl_vars['query'][0]);
foreach ($ann as $k => $v)
$ann[$k]['text'] = Util::localizedString($v, 'text');
$this->_tpl_vars['announcements'] = $ann;
}
parent::display($tpl);
}
// creates the actual cache file
public function saveCache($key, $data)
{
@@ -157,10 +172,9 @@ User::setLocale();
User::assignUserToTemplate($smarty, true);
// parse page-parameters .. sanitize before use!
$query = $_SERVER['QUERY_STRING'];
$smarty->assign('query', $query);
@list($str, $trash) = explode('&', $query, 2);
@list($str, $trash) = explode('&', $_SERVER['QUERY_STRING'], 2);
@list($pageCall, $pageParam) = explode('=', $str, 2);
$smarty->assign('query', [$pageCall, $pageParam]);
// init global vars for smarty
$pageData = array(

View File

@@ -377,10 +377,6 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
$smarty->saveCache($cacheKeyPage, $pageData);
}
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "achievement" OR page = "*")');
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$vars = array(
'title' => implode(" - ", $pageData['title']),
'path' => "[".implode(", ", $pageData['path'])."]",// menuId 9: Achievement (g_initPath)
@@ -391,7 +387,6 @@ $vars = array(
$smarty->updatePageVars($vars);
$smarty->assign('community', CommunityContent::getAll(TYPE_ACHIEVEMENT, $id)); // comments, screenshots, videos
$smarty->assign('announcements', $announcements);
$smarty->assign('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement));
$smarty->assign('data', $pageData);

View File

@@ -64,10 +64,6 @@ if ($compareString)
}
}
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "compare" OR page = "*")');
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$page = array(
'title' => Lang::$compare['compare'],
@@ -89,7 +85,6 @@ $page = array(
$smarty->updatePageVars($page);
$smarty->assign('data', $pageData);
$smarty->assign('lang', array_merge(Lang::$main, Lang::$compare));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('compare.tpl');

View File

@@ -3,14 +3,8 @@
if (!defined('AOWOW_REVISION'))
die('illegal access');
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "*")');
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$smarty->assign('lang', array_merge(Lang::$main, Lang::$error));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('error.tpl');
exit();

View File

@@ -4,11 +4,6 @@ if (!defined('AOWOW_REVISION'))
die('illegal access');
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "maps" OR page = "*")');
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$page = array(
'reqCSS' => array(
array('string' => 'zone-picker { margin-left: 4px }'),
@@ -27,7 +22,6 @@ $page = array(
$smarty->updatePageVars($page);
$smarty->assign('lang', array_merge(Lang::$main, Lang::$maps));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('maps.tpl');

View File

@@ -6,13 +6,6 @@ if (!defined('AOWOW_REVISION'))
$petCalc = $pageCall == 'petcalc';
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = ?s OR page = "*")',
$petCalc ? 'petcalc' : 'talent'
);
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$page = array(
'reqCSS' => array(
array('path' => 'template/css/TalentCalc.css', 'condition' => false),
@@ -43,7 +36,6 @@ if ($petCalc)
$smarty->updatePageVars($page);
$smarty->assign('tcType', $petCalc ? 'pc' : 'tc');
$smarty->assign('lang', array_merge(Lang::$main, Lang::$talent));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('talent.tpl');

View File

@@ -102,16 +102,10 @@ $smarty->updatePageVars(array(
));
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "title" OR page = "*")');
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$smarty->assign('community', CommunityContent::getAll(TYPE_TITLE, $id)); // comments, screenshots, videos
$smarty->assign('lang', array_merge(Lang::$main));
$smarty->assign('data', $pageData);
$smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->assign('announcements', $announcements);
$smarty->display('title.tpl');
?>

View File

@@ -30,11 +30,6 @@ if (!$smarty->loadCache($cacheKey, $pageData))
$smarty->saveCache($cacheKey, $pageData);
}
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "titles" OR page = "*")');
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$page = array(
'tab' => 0, // for g_initHeader($tab)
'title' => implode(" - ", $title),
@@ -45,7 +40,6 @@ $smarty->updatePageVars($page);
$smarty->assign('lang', Lang::$main);
$smarty->assign('data', $pageData);
$smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->assign('announcements', $announcements);
$smarty->display('titles.tpl');
?>

View File

@@ -492,11 +492,6 @@ else /* if ($searchMask & SEARCH_TYPE_REGULAR) */
// die();
// }
// Announcements
$announcements = DB::Aowow()->Select('SELECT * FROM ?_announcements WHERE flags & 0x10 AND (page = "search" OR page = "*")');
foreach ($announcements as $k => $v)
$announcements[$k]['text'] = Util::localizedString($v, 'text');
$vars = array(
'title' => $search.' - '.Lang::$search['search'],
'tab' => 0, // tabId 0: Database for g_initHeader($tab)
@@ -510,7 +505,6 @@ else /* if ($searchMask & SEARCH_TYPE_REGULAR) */
$smarty->assign('search', $search);
$smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->assign('util', new Util); // just for debugging / optimizing
$smarty->assign('announcements', $announcements);
$smarty->display('search.tpl');
}

View File

@@ -1,17 +1,21 @@
{include file='header.tpl'}
<div id="main">
<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}
<div id="main-precontents"></div>
<div id="main-contents" class="main-contents">
<div class="pad3"></div>
<div class="pad3"></div>
<div class="inputbox">
<h1>{$page.subject} #{$page.id}</h1>
<div id="inputbox-error">{$page.notFound}</div>
<!-- -->
</div>
<div class="inputbox">
<h1>{$page.subject} #{$page.id}</h1>
<div id="inputbox-error">{$page.notFound}</div>
<!-- -->
</div>
</div>
</div>
{include file='footer.tpl'}

View File

@@ -3,11 +3,11 @@
<div id="main">
<div id="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}
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<script type="text/javascript">g_initPath([1,3])</script>
<div class="text">

View File

@@ -3,11 +3,11 @@
<div id="main">
<div id="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}
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<div class="text">
<h1>{$lang.errNotFound}</h1>
<div class="left">

View File

@@ -3,11 +3,11 @@
<div id="main">
<div id="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}
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<div class="text">
<div style="text-align: center">
<script type="text/javascript">g_initPath([1,1])</script>

View File

@@ -1,22 +1,22 @@
{include file='header.tpl'}
<div id="main">
<div 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}
<div class="text">
<a href="http://www.wowhead.com/?{$query}" class="button-red"><em><b><i>Wowhead</i></b><span>Wowhead</span></em></a>
{if !empty($found)}
<h1>{$lang.foundResult} <i>{$search|escape:"html"}</i></h1>
</div>
<div id="tabs-generic"></div>
<div id="listview-generic" class="listview"></div>
<script type="text/javascript">
var myTabs = new Tabs({ldelim}parent: ge('tabs-generic'){rdelim});
<div id="main">
<div 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}
<div class="text">
<a href="http://www.wowhead.com/?{$query[0]}={$query[1]}" class="button-red"><em><b><i>Wowhead</i></b><span>Wowhead</span></em></a>
{if !empty($found)}
<h1>{$lang.foundResult} <i>{$search|escape:"html"}</i></h1>
</div>
<div id="tabs-generic"></div>
<div id="listview-generic" class="listview"></div>
<script type="text/javascript">
var myTabs = new Tabs({ldelim}parent: ge('tabs-generic'){rdelim});
{if isset($found.class)} {include file='bricks/class_table.tpl' data=$found.class.data params=$found.class.params } {/if}
{if isset($found.race)} {include file='bricks/race_table.tpl' data=$found.race.data params=$found.race.params } {/if}
{if isset($found.title)} {include file='bricks/title_table.tpl' data=$found.title.data params=$found.title.params } {/if}
@@ -39,17 +39,17 @@
{if isset($found.event)} {include file='bricks/event_table.tpl' data=$found.event.data params=$found.event.params } {/if}
{if isset($found.skill)} {include file='bricks/skill_table.tpl' data=$found.skill.data params=$found.skill.params } {/if}
{if isset($found.currency)} {include file='bricks/currency_table.tpl' data=$found.currency.data params=$found.currency.params } {/if}
myTabs.flush();
</script>
{else}
<h1>{$lang.noResult} <i>{$search|escape:"html"}</i></h1>
myTabs.flush();
</script>
{else}
<h1>{$lang.noResult} <i>{$search|escape:"html"}</i></h1>
{$lang.tryAgain}
{/if}
<div class="clear"></div>
</div>
{$lang.tryAgain}
{/if}
<div class="clear"></div>
</div>
</div>
{include file='footer.tpl'}

View File

@@ -3,11 +3,11 @@
<div id="main">
<div id="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}
{if !empty($announcements)}
{foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item}
{/foreach}
{/if}
<div id="{$tcType}-classes">
<div id="{$tcType}-classes-outer">
<div id="{$tcType}-classes-inner"><p>{if $tcType == 'tc'}{$lang.chooseClass}{else}{$lang.chooseFamily}{/if}:</p></div>

View File

@@ -21,7 +21,7 @@
<a href="javascript:;" id="open-links-button" class="button-red" onclick="this.blur(); Links.show({ldelim} type: 11, typeId: {$data.page.id} {rdelim});">
<em><b><i>{$lang.link}</i></b><span>{$lang.link}</span></em>
</a>
<a href="http://old.wowhead.com/?{$query}" class="button-red"><em><b><i>Wowhead</i></b><span>Wowhead</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($data.page.expansion)}<span class="{$data.page.expansion}-icon-right">{$data.page.name}</span>{else}{$data.page.name}{/if}</h1>
<h2 class="clear">{$lang.related}</h2>
</div>

View File

@@ -1,24 +1,24 @@
{include file='header.tpl'}
<div id="main">
<div id="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">
g_initPath({$page.path});
</script>
<div id="main">
<div id="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">
g_initPath({$page.path});
</script>
<div id="lv-titles" class="listview"></div>
<script type="text/javascript">
{include file='bricks/title_table.tpl' data=$data.page params=$data.params}
</script>
<div id="lv-titles" class="listview"></div>
<script type="text/javascript">
{include file='bricks/title_table.tpl' data=$data.page params=$data.params}
</script>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</div>
{include file='footer.tpl'}