Move tibiacom boxes to Twig templates

Yes they are looking and working same as before ;)
This commit is contained in:
slawkens 2018-10-16 01:42:15 +02:00
parent ff8105f809
commit 2695995211
14 changed files with 140 additions and 130 deletions

View File

@ -4,14 +4,10 @@ if(PAGE !== 'news') {
return;
}
$query = $db->query('SELECT `thumb` FROM `' . TABLE_PREFIX . 'gallery` WHERE `id` = ' . $db->quote($config['gallery_image']));
if($query->rowCount() == 1):
$query = $db->query('SELECT `thumb` FROM `' . TABLE_PREFIX . 'gallery` WHERE `id` = ' . $db->quote($config['gallery_image_id_from_database']));
if($query->rowCount() === 1) {
$image = $query->fetch();
?>
<div id="GalleryBox" class="Themebox" style="background-image:url(<?php echo $template_path; ?>/images/themeboxes/gallery/gallerybox.gif);">
<a href="?subtopic=gallery&image=<?php echo $config['gallery_image']; ?>" >
<img id="GalleryContent" class="ThemeboxContent" src="<?php echo $image['thumb']; ?>" alt="Screenshot of the Day" />
</a>
<div class="Bottom" style="background-image:url(<?php echo $template_path; ?>/images/general/box-bottom.gif);"></div>
</div>
<?php endif; ?>
$twig->display('gallery.html.twig', array(
'image' => $image
));
}

View File

@ -1,68 +1,5 @@
<style type="text/css" media="all">
.Toplevelbox {
top: -4px;
position: relative;
margin-bottom: 10px;
width: 180px;
height: 200px;
}
.top_level {
position: absolute;
top: 29px;
left: 6px;
height: 160px;
width: 168px;
z-index: 20;
text-align: center;
padding-top: 6px;
font-family: Tahoma, Geneva, sans-serif;
font-size: 9.2pt;
color: #FFF;
font-weight: bold;
text-align: right;
text-decoration: inherit;
text-shadow: 0.1em 0.1em #333
}
<?php
#Topbar a {
text-decoration: none;
}
.online {
color: #008000;
}
.offline {
color: #FF0000;
}
a.topfont {
font-family: Verdana, Arial, Helvetica;
font-size: 11px;
text-decoration: none
}
a:hover.topfont {
font-family: Verdana, Arial, Helvetica;
font-size: 11px;
color: #CCC;
text-decoration:none
}
</style>
<div id="Topbar" class="Themebox" style="background-image:url(<?PHP echo $template_path; ?>/images/themeboxes/highscores/highscores.png);">
<div class="top_level" style="background:url(<?PHP echo $template_path; ?>/images/themeboxes/bg_top.png)" align=" ">
<?php
foreach(getTopPlayers(5) as $player) {
echo '<div style="text-align:left"><a href="'.getPlayerLink($player['name'], false).'" class="topfont ' . ($player['online'] == 1 ? 'online' : 'offline') . '">
<span style="color: #CCC">&nbsp;&nbsp;&nbsp;&nbsp;'.$player['rank'].' - </span>'.$player['name'].'
<br>
<small><span style="color: white">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Level: ('.$player['level'].')</span></small>
<br>
</a>
</div>';
}
?>
<div class="Bottom" style="background-image:url(<?PHP echo $template_path; ?>/images/general/box-bottom.gif); top: 159px;; left:-5px;">
</div>
</div>
</div>
<br/><br/><br/>
$twig->display('highscores.html.twig', array(
'topPlayers' => getTopPlayers(5)
));

View File

@ -1,31 +1,5 @@
<div id="NetworksBox" class="Themebox" style="background-image:url(<?php echo $template_path; ?>/images/themeboxes/networks/networksbox.png);">
<?php if(!empty($config['network_facebook'])) {?>
<div id="FacebookBlock">
<div id="FacebookLikeBox">
<div class="fb-like-box fb_iframe_widget" data-href="https://www.facebook.com/<?php echo $config['network_facebook']; ?>" data-width="175" data-height="180" data-show-faces="true" data-stream="false" data-border-color="none" data-header="false" fb-xfbml-state="rendered">
<span style="vertical-align: bottom; width: 181px; height: 180px;">
</span>
</div>
</div>
<div id="FacebookSendBox">
<div class="fb-send fb_iframe_widget" data-href="https://www.facebook.com/<?php echo $config['network_facebook']; ?>" data-width="50" data-height="20" fb-xfbml-state="rendered">
<span style="vertical-align: bottom; width: 50px; height: 20px;">
</span>
</div>
</div>
<div id="FacebookLikes">
<div class="fb-like fb_edge_widget_with_comment fb_iframe_widget" data-href="https://www.facebook.com/<?php echo $config['network_facebook']; ?>" data-send="false" data-width="225" data-show-faces="false" fb-xfbml-state="rendered">
<span style="height: 28px; width: 225px;">
</span>
</div>
</div>
</div>
<?php } ?>
<?php if(!empty($config['network_twitter'])){ ?>
<div id="TwitterBlock">
<a href="https://twitter.com/<?php echo $config['network_twitter']; ?>" class="twitter-follow-button" data-show-count="false">Follow @<?php echo $config['network_twitter']; ?></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>
<?php } ?>
<div class="Bottom" style="background-image:url(<?php echo $template_path; ?>/images/general/box-bottom.gif);"></div>
</div>
<?php
$twig->display('networks.html.twig', array(
'topPlayers' => getTopPlayers(5)
));

View File

@ -1,5 +1,3 @@
<div id="NewcomerBox" class="Themebox" style="background-image:url(<?php echo $template_path; ?>/images/themeboxes/newcomer/newcomerbox.gif);">
<a class="ThemeboxButton" href="<?php echo getLink('account/create'); ?>" onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/sbutton.gif);"><div class="BigButtonOver" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/sbutton_over.gif);"></div><div class="ButtonText" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/_sbutton_jointibia.gif);"></div>
</a>
<div class="Bottom" style="background-image:url(<?php echo $template_path; ?>/images/general/box-bottom.gif);"></div>
</div>
<?php
$twig->display('newcomer.html.twig');

View File

@ -7,15 +7,7 @@ if(PAGE !== 'news') {
$poll = $db->query('SELECT `id`, `question` FROM `z_polls` WHERE end > ' . time() . ' ORDER BY `end` LIMIT 1');
if($poll->rowCount() > 0) {
$poll = $poll->fetch();
?>
<div id="CurrentPollBox" class="Themebox"
style="background-image:url(<?php echo $template_path; ?>/images/themeboxes/current-poll/currentpollbox.gif);">
<div id="CurrentPollText"><?php echo $poll['question']; ?></div>
<a class="ThemeboxButton" href="<?php echo getLink('polls') . '/' . $poll['id']; ?>" onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/sbutton.gif);"><div class="BigButtonOver" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/sbutton_over.gif);"></div><div class="ButtonText" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/_sbutton_votenow.gif);"></div>
</a>
<div class="Bottom"
style="background-image:url(<?php echo $template_path; ?>/images/general/box-bottom.gif);"></div>
</div>
<?php
$twig->display('poll.html.twig', array(
'poll' => $poll
));
}
?>

View File

@ -1,5 +1,3 @@
<div id="PremiumBox" class="Themebox" style="background-image:url(<?php echo $template_path; ?>/images/themeboxes/premium/premiumbox.gif);">
<a class="ThemeboxButton" href="<?php echo getLink('premium'); ?>" onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/sbutton.gif);"><div class="BigButtonOver" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/sbutton_over.gif);"></div><div class="ButtonText" style="background-image:url(<?php echo $template_path; ?>/images/global/buttons/_sbutton_getpremium.gif);"></div>
</a>
<div class="Bottom" style="background-image:url(<?php echo $template_path; ?>/images/general/box-bottom.gif);"></div>
</div>
<?php
$twig->display('premium.html.twig');

View File

@ -0,0 +1,6 @@
<div id="GalleryBox" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/gallery/gallerybox.gif);">
<a href="?subtopic=gallery&image={{ config['gallery_image_id_from_database'] }}" >
<img id="GalleryContent" class="ThemeboxContent" src="{{ image['thumb'] }}" alt="Screenshot of the Day" />
</a>
<div class="Bottom" style="background-image:url({{ template_path }}/images/general/box-bottom.gif);"></div>
</div>

View File

@ -0,0 +1,59 @@
<style type="text/css">
.top_level {
position: absolute;
top: 29px;
left: 6px;
height: 160px;
width: 168px;
z-index: 20;
padding-top: 6px;
font-family: Tahoma, Geneva, sans-serif;
font-size: 9.2pt;
color: #FFF;
font-weight: bold;
text-align: right;
text-decoration: inherit;
text-shadow: 0.1em 0.1em #333
}
#Topbar a {
text-decoration: none;
}
.online {
color: #008000;
}
.offline {
color: #FF0000;
}
a.topfont {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
text-decoration: none
}
a:hover.topfont {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #CCC;
text-decoration:none
}
</style>
<div id="Topbar" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/highscores/highscores.png);">
<div class="top_level" style="background:url({{ template_path }}/images/themeboxes/bg_top.png)" align=" ">
{% for player in topPlayers %}
<div style="text-align:left"><a href="{{ getPlayerLink(player['name'], false) }} " class="topfont {% if player['online'] %}online{% else %}offline{% endif %}">
<span style="color: #CCC">&nbsp;&nbsp;&nbsp;&nbsp;{{ player['rank'] }} - </span>{{ player['name'] }}
<br>
<small><span style="color: white">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Level: ({{ player['level'] }})</span></small>
<br>
</a>
</div>
{% endfor %}
<div class="Bottom" style="background-image:url({{ template_path }}/images/general/box-bottom.gif); top: 159px;; left:-5px;">
</div>
</div>
</div>
<br/><br/><br/>

View File

@ -0,0 +1,31 @@
<div id="NetworksBox" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/networks/networksbox.png);">
{% if config['network_facebook'] is not empty %}
<div id="FacebookBlock">
<div id="FacebookLikeBox">
<div class="fb-like-box fb_iframe_widget" data-href="https://www.facebook.com/{{ config['network_facebook'] }}" data-width="175" data-height="180" data-show-faces="true" data-stream="false" data-border-color="none" data-header="false" fb-xfbml-state="rendered">
<span style="vertical-align: bottom; width: 181px; height: 180px;">
</span>
</div>
</div>
<div id="FacebookSendBox">
<div class="fb-send fb_iframe_widget" data-href="https://www.facebook.com/{{ config['network_facebook'] }}" data-width="50" data-height="20" fb-xfbml-state="rendered">
<span style="vertical-align: bottom; width: 50px; height: 20px;">
</span>
</div>
</div>
<div id="FacebookLikes">
<div class="fb-like fb_edge_widget_with_comment fb_iframe_widget" data-href="https://www.facebook.com/{{ config['network_facebook'] }}" data-send="false" data-width="225" data-show-faces="false" fb-xfbml-state="rendered">
<span style="height: 28px; width: 225px;">
</span>
</div>
</div>
</div>
{% endif %}
{% if config['network_twitter'] is not empty %}
<div id="TwitterBlock">
<a href="https://twitter.com/<?php echo $config['network_twitter']; ?>" class="twitter-follow-button" data-show-count="false">Follow @<?php echo $config['network_twitter']; ?></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</div>
{% endif %}
<div class="Bottom" style="background-image:url({{ template_path }}/images/general/box-bottom.gif);"></div>
</div>

View File

@ -0,0 +1,5 @@
<div id="NewcomerBox" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/newcomer/newcomerbox.gif);">
<a class="ThemeboxButton" href="{{ getLink('account/create') }}" onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" style="background-image:url({{ template_path }}/images/global/buttons/sbutton.gif);"><div class="BigButtonOver" style="background-image:url({{ template_path }}/images/global/buttons/sbutton_over.gif);"></div><div class="ButtonText" style="background-image:url({{ template_path }}/images/global/buttons/_sbutton_jointibia.gif);"></div>
</a>
<div class="Bottom" style="background-image:url({{ template_path }}/images/general/box-bottom.gif);"></div>
</div>

View File

@ -0,0 +1,7 @@
<div id="CurrentPollBox" class="Themebox"
style="background-image:url({{ template_path }}/images/themeboxes/current-poll/currentpollbox.gif);">
<div id="CurrentPollText">{{ poll['question'] }}</div>
<a class="ThemeboxButton" href="{{ getLink('polls') . '/' . poll['id'] }}" onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" style="background-image:url({{ template_path }}/images/global/buttons/sbutton.gif);"><div class="BigButtonOver" style="background-image:url({{ template_path }}/images/global/buttons/sbutton_over.gif);"></div><div class="ButtonText" style="background-image:url({{ template_path }}/images/global/buttons/_sbutton_votenow.gif);"></div>
</a>
<div class="Bottom" style="background-image:url({{ template_path }}/images/general/box-bottom.gif);"></div>
</div>

View File

@ -0,0 +1,5 @@
<div id="PremiumBox" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/premium/premiumbox.gif);">
<a class="ThemeboxButton" href="{{ getLink('premium') }}" onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" style="background-image:url({{ template_path }}/images/global/buttons/sbutton.gif);"><div class="BigButtonOver" style="background-image:url({{ template_path }}/images/global/buttons/sbutton_over.gif);"></div><div class="ButtonText" style="background-image:url({{ template_path }}/images/global/buttons/_sbutton_getpremium.gif);"></div>
</a>
<div class="Bottom" style="background-image:url({{ template_path }}/images/general/box-bottom.gif);"></div>
</div>

View File

@ -12,7 +12,7 @@ $config['network_twitter'] = 'tibia'; // leave empty to disable
$config['background_image'] = "background-artwork.jpg";
$config['logo_image'] = "tibia-logo-artwork-top.gif";
$config['gallery_image'] = 1;
$config['gallery_image_id_from_database'] = 1;
$config['menu_categories'] = array(
MENU_CATEGORY_NEWS => array('id' => 'news', 'name' => 'Latest News'),
MENU_CATEGORY_ACCOUNT => array('id' => 'account', 'name' => 'Account'),

View File

@ -421,6 +421,8 @@ foreach($config['menu_categories'] as $id => $cat) {
<div id="Themeboxes">
<?php
$twig_loader->prependPath(__DIR__ . '/boxes/templates');
foreach($config['boxes'] as $box) {
/** @var string $template_name */
$file = TEMPLATES . $template_name . '/boxes/' . $box . '.php';