diff --git a/includes/kernel.php b/includes/kernel.php index 4f6f06eb..3e51aa8d 100644 --- a/includes/kernel.php +++ b/includes/kernel.php @@ -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( diff --git a/pages/achievement.php b/pages/achievement.php index 84a8abf7..da10979a 100644 --- a/pages/achievement.php +++ b/pages/achievement.php @@ -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); diff --git a/pages/compare.php b/pages/compare.php index f17eb1c3..466d4b48 100644 --- a/pages/compare.php +++ b/pages/compare.php @@ -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'); diff --git a/pages/error.php b/pages/error.php index 79b7cf0d..42102a68 100644 --- a/pages/error.php +++ b/pages/error.php @@ -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(); diff --git a/pages/maps.php b/pages/maps.php index 6c5d4a97..23eb7e1d 100644 --- a/pages/maps.php +++ b/pages/maps.php @@ -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'); diff --git a/pages/talent.php b/pages/talent.php index c950a106..c7f97cef 100644 --- a/pages/talent.php +++ b/pages/talent.php @@ -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'); diff --git a/pages/title.php b/pages/title.php index b56e3997..a6512aad 100644 --- a/pages/title.php +++ b/pages/title.php @@ -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'); ?> diff --git a/pages/titles.php b/pages/titles.php index 6463d679..8c0a8a06 100644 --- a/pages/titles.php +++ b/pages/titles.php @@ -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'); ?> diff --git a/search.php b/search.php index 1c0b3a3b..eefa1406 100644 --- a/search.php +++ b/search.php @@ -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'); } diff --git a/template/404.tpl b/template/404.tpl index bb9fe25c..8b1e1127 100644 --- a/template/404.tpl +++ b/template/404.tpl @@ -1,17 +1,21 @@ {include file='header.tpl'} -
+
+
+
+{if !empty($announcements)} + {foreach from=$announcements item=item} + {include file='bricks/announcement.tpl' an=$item} + {/foreach} +{/if} -
-
+
-
- -
-

{$page.subject} #{$page.id}

-
{$page.notFound}
- -
+
+

{$page.subject} #{$page.id}

+
{$page.notFound}
+
+
{include file='footer.tpl'} \ No newline at end of file diff --git a/template/compare.tpl b/template/compare.tpl index 5c664c3c..d39a4157 100644 --- a/template/compare.tpl +++ b/template/compare.tpl @@ -3,11 +3,11 @@
- {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}
diff --git a/template/error.tpl b/template/error.tpl index a56a18de..a561a52b 100644 --- a/template/error.tpl +++ b/template/error.tpl @@ -3,11 +3,11 @@
- {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}

{$lang.errNotFound}

diff --git a/template/maps.tpl b/template/maps.tpl index 308d9e87..45976489 100644 --- a/template/maps.tpl +++ b/template/maps.tpl @@ -3,11 +3,11 @@
- {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}
diff --git a/template/search.tpl b/template/search.tpl index b3377752..8210b56e 100644 --- a/template/search.tpl +++ b/template/search.tpl @@ -1,22 +1,22 @@ {include file='header.tpl'} -
-
-
- {if !empty($announcements)} - {foreach from=$announcements item=item} - {include file='bricks/announcement.tpl' an=$item} - {/foreach} - {/if} -
- WowheadWowhead - {if !empty($found)} -

{$lang.foundResult} {$search|escape:"html"}

-
-
-
- - {else} -

{$lang.noResult} {$search|escape:"html"}

+ myTabs.flush(); + + {else} +

{$lang.noResult} {$search|escape:"html"}

- {$lang.tryAgain} - {/if} -
- -
+ {$lang.tryAgain} + {/if} +
+ +
{include file='footer.tpl'} diff --git a/template/talent.tpl b/template/talent.tpl index 2194bdf1..3c256174 100644 --- a/template/talent.tpl +++ b/template/talent.tpl @@ -3,11 +3,11 @@
- {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}

{if $tcType == 'tc'}{$lang.chooseClass}{else}{$lang.chooseFamily}{/if}:

diff --git a/template/title.tpl b/template/title.tpl index 94fc7e92..55586c3f 100644 --- a/template/title.tpl +++ b/template/title.tpl @@ -21,7 +21,7 @@ {$lang.link}{$lang.link} - WowheadWowhead + WowheadWowhead

{if isset($data.page.expansion)}{$data.page.name}{else}{$data.page.name}{/if}

{$lang.related}

diff --git a/template/titles.tpl b/template/titles.tpl index 46563720..ace03734 100644 --- a/template/titles.tpl +++ b/template/titles.tpl @@ -1,24 +1,24 @@ {include file='header.tpl'} -
-
-
- {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} + -
- +
+ -
-
+
+
{include file='footer.tpl'}