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; $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 // creates the actual cache file
public function saveCache($key, $data) public function saveCache($key, $data)
{ {
@@ -157,10 +172,9 @@ User::setLocale();
User::assignUserToTemplate($smarty, true); User::assignUserToTemplate($smarty, true);
// parse page-parameters .. sanitize before use! // parse page-parameters .. sanitize before use!
$query = $_SERVER['QUERY_STRING']; @list($str, $trash) = explode('&', $_SERVER['QUERY_STRING'], 2);
$smarty->assign('query', $query);
@list($str, $trash) = explode('&', $query, 2);
@list($pageCall, $pageParam) = explode('=', $str, 2); @list($pageCall, $pageParam) = explode('=', $str, 2);
$smarty->assign('query', [$pageCall, $pageParam]);
// init global vars for smarty // init global vars for smarty
$pageData = array( $pageData = array(

View File

@@ -377,10 +377,6 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData))
$smarty->saveCache($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( $vars = array(
'title' => implode(" - ", $pageData['title']), 'title' => implode(" - ", $pageData['title']),
'path' => "[".implode(", ", $pageData['path'])."]",// menuId 9: Achievement (g_initPath) 'path' => "[".implode(", ", $pageData['path'])."]",// menuId 9: Achievement (g_initPath)
@@ -391,7 +387,6 @@ $vars = array(
$smarty->updatePageVars($vars); $smarty->updatePageVars($vars);
$smarty->assign('community', CommunityContent::getAll(TYPE_ACHIEVEMENT, $id)); // comments, screenshots, videos $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('lang', array_merge(Lang::$main, Lang::$game, Lang::$achievement));
$smarty->assign('data', $pageData); $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( $page = array(
'title' => Lang::$compare['compare'], 'title' => Lang::$compare['compare'],
@@ -89,7 +85,6 @@ $page = array(
$smarty->updatePageVars($page); $smarty->updatePageVars($page);
$smarty->assign('data', $pageData); $smarty->assign('data', $pageData);
$smarty->assign('lang', array_merge(Lang::$main, Lang::$compare)); $smarty->assign('lang', array_merge(Lang::$main, Lang::$compare));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('compare.tpl'); $smarty->display('compare.tpl');

View File

@@ -3,14 +3,8 @@
if (!defined('AOWOW_REVISION')) if (!defined('AOWOW_REVISION'))
die('illegal access'); 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('lang', array_merge(Lang::$main, Lang::$error));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('error.tpl'); $smarty->display('error.tpl');
exit(); exit();

View File

@@ -4,11 +4,6 @@ if (!defined('AOWOW_REVISION'))
die('illegal access'); 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( $page = array(
'reqCSS' => array( 'reqCSS' => array(
array('string' => 'zone-picker { margin-left: 4px }'), array('string' => 'zone-picker { margin-left: 4px }'),
@@ -27,7 +22,6 @@ $page = array(
$smarty->updatePageVars($page); $smarty->updatePageVars($page);
$smarty->assign('lang', array_merge(Lang::$main, Lang::$maps)); $smarty->assign('lang', array_merge(Lang::$main, Lang::$maps));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('maps.tpl'); $smarty->display('maps.tpl');

View File

@@ -6,13 +6,6 @@ if (!defined('AOWOW_REVISION'))
$petCalc = $pageCall == 'petcalc'; $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( $page = array(
'reqCSS' => array( 'reqCSS' => array(
array('path' => 'template/css/TalentCalc.css', 'condition' => false), array('path' => 'template/css/TalentCalc.css', 'condition' => false),
@@ -43,7 +36,6 @@ if ($petCalc)
$smarty->updatePageVars($page); $smarty->updatePageVars($page);
$smarty->assign('tcType', $petCalc ? 'pc' : 'tc'); $smarty->assign('tcType', $petCalc ? 'pc' : 'tc');
$smarty->assign('lang', array_merge(Lang::$main, Lang::$talent)); $smarty->assign('lang', array_merge(Lang::$main, Lang::$talent));
$smarty->assign('announcements', $announcements);
$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->display('talent.tpl'); $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('community', CommunityContent::getAll(TYPE_TITLE, $id)); // comments, screenshots, videos
$smarty->assign('lang', array_merge(Lang::$main)); $smarty->assign('lang', array_merge(Lang::$main));
$smarty->assign('data', $pageData); $smarty->assign('data', $pageData);
$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->assign('announcements', $announcements);
$smarty->display('title.tpl'); $smarty->display('title.tpl');
?> ?>

View File

@@ -30,11 +30,6 @@ if (!$smarty->loadCache($cacheKey, $pageData))
$smarty->saveCache($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( $page = array(
'tab' => 0, // for g_initHeader($tab) 'tab' => 0, // for g_initHeader($tab)
'title' => implode(" - ", $title), 'title' => implode(" - ", $title),
@@ -45,7 +40,6 @@ $smarty->updatePageVars($page);
$smarty->assign('lang', Lang::$main); $smarty->assign('lang', Lang::$main);
$smarty->assign('data', $pageData); $smarty->assign('data', $pageData);
$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->assign('announcements', $announcements);
$smarty->display('titles.tpl'); $smarty->display('titles.tpl');
?> ?>

View File

@@ -492,11 +492,6 @@ else /* if ($searchMask & SEARCH_TYPE_REGULAR) */
// die(); // 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( $vars = array(
'title' => $search.' - '.Lang::$search['search'], 'title' => $search.' - '.Lang::$search['search'],
'tab' => 0, // tabId 0: Database for g_initHeader($tab) '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('search', $search);
$smarty->assign('mysql', DB::Aowow()->getStatistics()); $smarty->assign('mysql', DB::Aowow()->getStatistics());
$smarty->assign('util', new Util); // just for debugging / optimizing $smarty->assign('util', new Util); // just for debugging / optimizing
$smarty->assign('announcements', $announcements);
$smarty->display('search.tpl'); $smarty->display('search.tpl');
} }

View File

@@ -1,9 +1,13 @@
{include file='header.tpl'} {include file='header.tpl'}
<div id="main"> <div id="main">
<div id="main-precontents" class="main-precontents"></div>
<div id="main-precontents"></div>
<div id="main-contents" class="main-contents"> <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 class="pad3"></div> <div class="pad3"></div>

View File

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

View File

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

View File

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

View File

@@ -3,13 +3,13 @@
<div id="main"> <div id="main">
<div id="main-precontents"></div> <div id="main-precontents"></div>
<div class="main-contents" id="main-contents"> <div class="main-contents" id="main-contents">
{if !empty($announcements)} {if !empty($announcements)}
{foreach from=$announcements item=item} {foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item} {include file='bricks/announcement.tpl' an=$item}
{/foreach} {/foreach}
{/if} {/if}
<div class="text"> <div class="text">
<a href="http://www.wowhead.com/?{$query}" class="button-red"><em><b><i>Wowhead</i></b><span>Wowhead</span></em></a> <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)} {if !empty($found)}
<h1>{$lang.foundResult} <i>{$search|escape:"html"}</i></h1> <h1>{$lang.foundResult} <i>{$search|escape:"html"}</i></h1>
</div> </div>

View File

@@ -3,11 +3,11 @@
<div id="main"> <div id="main">
<div id="main-precontents"></div> <div id="main-precontents"></div>
<div id="main-contents" class="main-contents"> <div id="main-contents" class="main-contents">
{if !empty($announcements)} {if !empty($announcements)}
{foreach from=$announcements item=item} {foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item} {include file='bricks/announcement.tpl' an=$item}
{/foreach} {/foreach}
{/if} {/if}
<div id="{$tcType}-classes"> <div id="{$tcType}-classes">
<div id="{$tcType}-classes-outer"> <div id="{$tcType}-classes-outer">
<div id="{$tcType}-classes-inner"><p>{if $tcType == 'tc'}{$lang.chooseClass}{else}{$lang.chooseFamily}{/if}:</p></div> <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});"> <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> <em><b><i>{$lang.link}</i></b><span>{$lang.link}</span></em>
</a> </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> <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> <h2 class="clear">{$lang.related}</h2>
</div> </div>

View File

@@ -3,11 +3,11 @@
<div id="main"> <div id="main">
<div id="main-precontents"></div> <div id="main-precontents"></div>
<div id="main-contents" class="main-contents"> <div id="main-contents" class="main-contents">
{if !empty($announcements)} {if !empty($announcements)}
{foreach from=$announcements item=item} {foreach from=$announcements item=item}
{include file='bricks/announcement.tpl' an=$item} {include file='bricks/announcement.tpl' an=$item}
{/foreach} {/foreach}
{/if} {/if}
<script type="text/javascript"> <script type="text/javascript">
g_initPath({$page.path}); g_initPath({$page.path});
</script> </script>