mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Home/Featuredbox
* allow defining a time span during which the box should be displayed * added fields optional fields to point to diffenret header and home logos for the duration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
define('AOWOW_REVISION', 20);
|
||||
define('AOWOW_REVISION', 21);
|
||||
define('CLI', PHP_SAPI === 'cli');
|
||||
|
||||
|
||||
|
||||
@@ -1014,7 +1014,7 @@ class Util
|
||||
|
||||
return $data;
|
||||
}
|
||||
else
|
||||
|
||||
return htmlspecialchars(trim($data), ENT_QUOTES, 'utf-8');
|
||||
}
|
||||
|
||||
@@ -1027,7 +1027,7 @@ class Util
|
||||
|
||||
return $data;
|
||||
}
|
||||
else
|
||||
|
||||
return strtr(trim($data), array(
|
||||
'\\' => '\\\\',
|
||||
"'" => "\\'",
|
||||
@@ -1037,6 +1037,24 @@ class Util
|
||||
));
|
||||
}
|
||||
|
||||
public static function defStatic($data)
|
||||
{
|
||||
if (is_array($data))
|
||||
{
|
||||
foreach ($data as &$v)
|
||||
$v = self::defStatic($v);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return strtr($data, array(
|
||||
'<script' => '<scr"+"ipt',
|
||||
'script>' => 'scr"+"ipt>',
|
||||
'HOST_URL' => HOST_URL,
|
||||
'STATIC_URL' => STATIC_URL
|
||||
));
|
||||
}
|
||||
|
||||
// default back to enUS if localization unavailable
|
||||
public static function localizedString($data, $field, $silent = false)
|
||||
{
|
||||
|
||||
@@ -103,6 +103,8 @@ class GenericPage
|
||||
private $memcached = null;
|
||||
private $mysql = ['time' => 0, 'count' => 0];
|
||||
|
||||
private $headerLogo = '';
|
||||
|
||||
private $lvTemplates = array(
|
||||
'achievement' => ['template' => 'achievement', 'id' => 'achievements', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_achievements' ],
|
||||
'calendar' => ['template' => 'holidaycal', 'id' => 'calendar', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_calendar' ],
|
||||
@@ -158,6 +160,10 @@ class GenericPage
|
||||
$this->mode = CACHE_TYPE_XML;
|
||||
else
|
||||
{
|
||||
// get alt header logo
|
||||
if ($ahl = DB::Aowow()->selectCell('SELECT altHeaderLogo FROM ?_home_featuredbox WHERE ?d BETWEEN startDate AND endDate ORDER BY id DESC', time()))
|
||||
$this->headerLogo = Util::defStatic($ahl);
|
||||
|
||||
$this->gUser = User::getUserGlobals();
|
||||
$this->pageTemplate['pageName'] = strtolower($pageCall);
|
||||
|
||||
@@ -325,15 +331,8 @@ class GenericPage
|
||||
foreach ($article as $text)
|
||||
(new Markup($text))->parseGlobalsFromText($this->jsgBuffer);
|
||||
|
||||
$replace = array(
|
||||
'<script' => '<scr"+"ipt',
|
||||
'script>' => 'scr"+"ipt>',
|
||||
'HOST_URL' => HOST_URL,
|
||||
'STATIC_URL' => STATIC_URL
|
||||
);
|
||||
|
||||
$this->article = array(
|
||||
'text' => strtr($article['article'], $replace),
|
||||
'text' => Util::defStatic($article['article']),
|
||||
'params' => []
|
||||
);
|
||||
|
||||
@@ -374,22 +373,17 @@ class GenericPage
|
||||
{
|
||||
if ($t = Util::localizedString($v, 'text'))
|
||||
{
|
||||
$replace = array(
|
||||
'HOST_URL' => HOST_URL,
|
||||
'STATIC_URL' => STATIC_URL
|
||||
);
|
||||
|
||||
$_ = array(
|
||||
'parent' => 'announcement-'.$k,
|
||||
'id' => $v['id'],
|
||||
'mode' => $v['mode'],
|
||||
'status' => $v['status'],
|
||||
'name' => $v['name'],
|
||||
'text' => strtr($t, $replace)
|
||||
'text' => Util::defStatic($t)
|
||||
);
|
||||
|
||||
if ($v['style']) // may be empty
|
||||
$_['style'] = strtr($v['style'], $replace);
|
||||
$_['style'] = Util::defStatic($v['style']);
|
||||
|
||||
$this->announcements[$k] = $_;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class HomePage extends GenericPage
|
||||
protected $js = ['home.js'];
|
||||
protected $css = [['path' => 'home.css']];
|
||||
|
||||
protected $news = [];
|
||||
protected $featuredBox = [];
|
||||
protected $oneliner = '';
|
||||
|
||||
public function __construct()
|
||||
@@ -26,27 +26,27 @@ class HomePage extends GenericPage
|
||||
if ($_ = DB::Aowow()->selectRow('SELECT * FROM ?_home_oneliner WHERE active = 1 LIMIT 1'))
|
||||
$this->oneliner = Util::jsEscape(Util::localizedString($_, 'text'));
|
||||
|
||||
// load news
|
||||
$this->news = DB::Aowow()->selectRow('SELECT id as ARRAY_KEY, n.* FROM ?_home_featuredbox n WHERE active = 1 ORDER BY id DESC LIMIT 1');
|
||||
if (!$this->news)
|
||||
// load featuredBox (user web server time)
|
||||
$this->featuredBox = DB::Aowow()->selectRow('SELECT id as ARRAY_KEY, n.* FROM ?_home_featuredbox n WHERE ?d BETWEEN startDate AND endDate ORDER BY id DESC LIMIT 1', time());
|
||||
if (!$this->featuredBox)
|
||||
return;
|
||||
|
||||
$this->news['text'] = Util::localizedString($this->news, 'text', true);
|
||||
$this->featuredBox = Util::defStatic($this->featuredBox);
|
||||
|
||||
if ($_ = (new Markup($this->news['text']))->parseGlobalsFromText())
|
||||
$this->featuredBox['text'] = Util::localizedString($this->featuredBox, 'text', true);
|
||||
|
||||
if ($_ = (new Markup($this->featuredBox['text']))->parseGlobalsFromText())
|
||||
$this->extendGlobalData($_);
|
||||
|
||||
if (empty($this->news['bgImgUrl']))
|
||||
$this->news['bgImgUrl'] = STATIC_URL.'/images/'.User::$localeString.'/mainpage-bg-news.jpg';
|
||||
else
|
||||
$this->news['bgImgUrl'] = strtr($this->news['bgImgUrl'], ['HOST_URL' => HOST_URL, 'STATIC_URL' => STATIC_URL]);
|
||||
if (empty($this->featuredBox['boxBG']))
|
||||
$this->featuredBox['boxBG'] = STATIC_URL.'/images/'.User::$localeString.'/mainpage-bg-news.jpg';
|
||||
|
||||
// load overlay links
|
||||
$this->news['overlays'] = DB::Aowow()->select('SELECT * FROM ?_home_featuredbox_overlay WHERE featureId = ?d', $this->news['id']);
|
||||
foreach ($this->news['overlays'] as &$o)
|
||||
$this->featuredBox['overlays'] = DB::Aowow()->select('SELECT * FROM ?_home_featuredbox_overlay WHERE featureId = ?d', $this->featuredBox['id']);
|
||||
foreach ($this->featuredBox['overlays'] as &$o)
|
||||
{
|
||||
$o['title'] = Util::localizedString($o, 'title', true);
|
||||
$o['title'] = strtr($o['title'], ['HOST_URL' => HOST_URL, 'STATIC_URL' => STATIC_URL]);
|
||||
$o['title'] = Util::defStatic($o['title']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -758,9 +758,12 @@ CREATE TABLE `aowow_home_featuredbox` (
|
||||
`id` smallint(5) unsigned NOT NULL,
|
||||
`editorId` int(10) unsigned DEFAULT NULL,
|
||||
`editDate` int(10) unsigned NOT NULL,
|
||||
`active` tinyint(1) unsigned NOT NULL,
|
||||
`startDate` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`endDate` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`extraWide` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||
`bgImgUrl` varchar(150) NOT NULL DEFAULT '',
|
||||
`boxBG` varchar(150) NULL DEFAULT NULL,
|
||||
`altHomeLogo` varchar(150) NULL DEFAULT NULL,
|
||||
`altHeaderLogo` varchar(150) NULL DEFAULT NULL,
|
||||
`text_loc0` text NOT NULL,
|
||||
`text_loc2` text NOT NULL,
|
||||
`text_loc3` text NOT NULL,
|
||||
@@ -2520,7 +2523,7 @@ UNLOCK TABLES;
|
||||
|
||||
LOCK TABLES `aowow_home_featuredbox` WRITE;
|
||||
/*!40000 ALTER TABLE `aowow_home_featuredbox` DISABLE KEYS */;
|
||||
INSERT INTO `aowow_home_featuredbox` VALUES (1,NULL,0,1,0,'','[pad]Welcome to [b][span class=q5]AoWoW[/span][/b]!','[pad]Bienvenue à [b][span class=q5]AoWoW[/span][/b]!','[pad]Willkommen bei [b][span class=q5]AoWoW[/span][/b]!','','Добро[pad] пожаловать на [b][span class=q5]AoWoW[/span][/b]!'),(2,NULL,0,0,1,'STATIC_URL/images/logos/newsbox-explained.png','[ul]\n[li][i]just demoing the newsbox here..[/i][/li]\n[li][b][url=http://www.example.com]..with urls[/url][/b][/li]\n[li][b]..typeLinks [item=45533][/b][/li]\n[li][b]..also, over there to the right is an overlay-trigger =>[/b][/li]\n[/ul]\n\n[ul]\n[li][tooltip name=demotip]hey, it hints you stuff![/tooltip][b][span class=tip tooltip=demotip]..hover me[/span][/b][/li]\n[/ul]','','','','');
|
||||
INSERT INTO `aowow_home_featuredbox` VALUES (1,NULL,0,0,0,0,'',NULL,NULL,'[pad]Welcome to [b][span class=q5]AoWoW[/span][/b]!','[pad]Bienvenue à [b][span class=q5]AoWoW[/span][/b]!','[pad]Willkommen bei [b][span class=q5]AoWoW[/span][/b]!','','Добро[pad] пожаловать на [b][span class=q5]AoWoW[/span][/b]!'),(2,NULL,0,0,0,1,'STATIC_URL/images/logos/newsbox-explained.png',NULL,NULL,'[ul]\n[li][i]just demoing the newsbox here..[/i][/li]\n[li][b][url=http://www.example.com]..with urls[/url][/b][/li]\n[li][b]..typeLinks [item=45533][/b][/li]\n[li][b]..also, over there to the right is an overlay-trigger =>[/b][/li]\n[/ul]\n\n[ul]\n[li][tooltip name=demotip]hey, it hints you stuff![/tooltip][b][span class=tip tooltip=demotip]..hover me[/span][/b][/li]\n[/ul]','','','','');
|
||||
/*!40000 ALTER TABLE `aowow_home_featuredbox` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
8
setup/updates/1484926142_01.sql
Normal file
8
setup/updates/1484926142_01.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
ALTER TABLE `aowow_home_featuredbox`
|
||||
CHANGE COLUMN `active` `startDate` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `editDate`,
|
||||
ADD COLUMN `endDate` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `startDate`;
|
||||
|
||||
ALTER TABLE `aowow_home_featuredbox`
|
||||
CHANGE COLUMN `bgImgUrl` `boxBG` VARCHAR(150) NULL DEFAULT NULL AFTER `extraWide`,
|
||||
ADD COLUMN `altHomeLogo` VARCHAR(150) NULL DEFAULT NULL AFTER `boxBG`,
|
||||
ADD COLUMN `altHeaderLogo` VARCHAR(150) NULL DEFAULT NULL AFTER `altHomeLogo`;
|
||||
@@ -6,6 +6,14 @@
|
||||
|
||||
<body<?=(User::isPremium() ? ' class="premium-logo"' : null); ?>>
|
||||
<div id="layers"></div>
|
||||
<?php if ($this->headerLogo): ?>
|
||||
<style type="text/css">
|
||||
.header-logo {
|
||||
background: url(<?=$this->headerLogo; ?>) no-repeat center 0 !important;
|
||||
margin-bottom: 1px !important;
|
||||
}
|
||||
</style>
|
||||
<?php endif; ?>
|
||||
<div class="layout nosidebar" id="layout">
|
||||
<div class="layout-inner" id="layout-inner">
|
||||
<div class="header" id="header">
|
||||
|
||||
@@ -6,6 +6,14 @@
|
||||
</head>
|
||||
<body class="home<?=(User::isPremium() ? ' premium-logo' : null); ?>">
|
||||
<div id="layers"></div>
|
||||
<?php if (!empty($this->featuredBox['altHomeLogo'])): ?>
|
||||
<style type="text/css">
|
||||
.home-logo {
|
||||
background: url(<?=$this->featuredBox['altHomeLogo'];?>) no-repeat center 0 !important;
|
||||
margin-bottom: 1px !important;
|
||||
}
|
||||
</style>
|
||||
<?php endif; ?>
|
||||
<div class="home-wrapper">
|
||||
<h1>Aowow</h1>
|
||||
<div class="home-logo" id="home-logo"></div>
|
||||
@@ -26,18 +34,18 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
Markup.printHtml('<?=$this->oneliner;?>', 'home-oneliner');
|
||||
//]]></script>
|
||||
<?php elseif ($this->news): ?>
|
||||
<?php elseif ($this->featuredBox): ?>
|
||||
<div class="pad"></div>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ($this->news):
|
||||
if ($this->featuredBox):
|
||||
?>
|
||||
<div class="home-featuredbox<?=(empty($this->news['extraWide']) ? null : ' home-featuredbox-extended'); ?>" style="background-image: url(<?=$this->news['bgImgUrl']; ?>);" id="home-featuredbox">
|
||||
<?php if ($this->news['overlays']): ?>
|
||||
<div class="home-featuredbox<?=(empty($this->featuredBox['extraWide']) ? null : ' home-featuredbox-extended'); ?>" style="background-image: url(<?=$this->featuredBox['boxBG']; ?>);" id="home-featuredbox">
|
||||
<?php if ($this->featuredBox['overlays']): ?>
|
||||
<div class="home-featuredbox-links">
|
||||
<?php
|
||||
foreach ($this->news['overlays'] as $o):
|
||||
foreach ($this->featuredBox['overlays'] as $o):
|
||||
echo ' <a href="'.$o['url'].'" title="'.$o['title'].'" style="left: '.$o['left'].'px; top: 18px; width:'.$o['width'].'px; height: 160px"></a>'."\n";
|
||||
echo ' <var style="left: '.$o['left'].'px; top: 18px; width:'.$o['width'].'px; height: 160px"></var>'."\n";
|
||||
endforeach;
|
||||
@@ -57,8 +65,8 @@ if (User::$localeId):
|
||||
endif;
|
||||
echo $this->writeGlobalVars();
|
||||
|
||||
if ($this->news):
|
||||
echo " Markup.printHtml(".Util::toJSON($this->news['text']).", 'news-generic', { allow: Markup.CLASS_ADMIN });\n";
|
||||
if ($this->featuredBox):
|
||||
echo " Markup.printHtml(".Util::toJSON($this->featuredBox['text']).", 'news-generic', { allow: Markup.CLASS_ADMIN });\n";
|
||||
endif;
|
||||
?>
|
||||
//]]></script>
|
||||
|
||||
Reference in New Issue
Block a user