Allow simultaneous loading of config.ini and config.php in templates

This commit is contained in:
tobi132 2019-07-16 23:52:28 +02:00
parent 0c207ce12d
commit f5374e8ce7
6 changed files with 48 additions and 36 deletions

View File

@ -54,25 +54,29 @@ else {
if(file_exists(BASE . $template_path . '/config.php')) {
require BASE . $template_path . '/config.php';
}
$tmp = '';
if ($cache->enabled() && $cache->fetch('template_ini_' . $template_name, $tmp)) {
$template_ini = unserialize($tmp);
}
else {
$file = BASE . $template_path . '/config.ini';
$exists = file_exists($file);
if ($exists || ($config['backward_support'] && file_exists(BASE . $template_path . '/layout_config.ini'))) {
if (!$exists)
if (!$exists) {
$file = BASE . $template_path . '/layout_config.ini';
}
$template_ini = parse_ini_file($file);
if ($cache->enabled()) {
$tmp = '';
if ($cache->fetch('template_ini_' . $template_name, $tmp))
$template_ini = unserialize($tmp);
else {
$template_ini = parse_ini_file($file);
$cache->set('template_ini_' . $template_name, serialize($template_ini));
}
} else
$template_ini = parse_ini_file($file);
}
}
foreach ($template_ini as $key => $value)
if (isset($template_ini)) {
foreach ($template_ini as $key => $value) {
$config[$key] = $value;
}
}
@ -134,10 +138,17 @@ function get_template_menus() {
}
$new_menus = array();
foreach(config('menu_categories') as $id => $options) {
if(isset($menus[$id]))
/**
* @var array $configMenuCategories
* @var int $id
* @var array $options
*/
$configMenuCategories = config('menu_categories');
foreach($configMenuCategories as $id => $options) {
if(isset($menus[$id])) {
$new_menus[$id] = $menus[$id];
}
}
return $new_menus;
}

View File

@ -0,0 +1,3 @@
darkborder = "#d0cdb4"
lightborder = "#e5e3d7"
vdarkborder = "#afab89"

View File

@ -1,7 +1,4 @@
<?php
$config['darkborder'] = "#d0cdb4";
$config['lightborder'] = "#e5e3d7";
$config['vdarkborder'] = "#afab89";
$config['menu_categories'] = array(
MENU_CATEGORY_NEWS => array('id' => 'news', 'name' => 'Latest News'),
MENU_CATEGORY_ACCOUNT => array('id' => 'account', 'name' => 'Account'),
@ -9,5 +6,3 @@ $config['menu_categories'] = array(
MENU_CATEGORY_LIBRARY => array('id' => 'library', 'name' => 'Library'),
MENU_CATEGORY_SHOP => array('id' => 'shops', 'name' => 'Shop')
);
?>

View File

@ -0,0 +1,18 @@
darkborder = "#D4C0A1"
lightborder = "#F1E0C6"
vdarkborder = "#505050"
logo_monster = "Wyrm"
; List: newcomer,gallery,premium,poll,highscores,networks
boxes = "highscores,newcomer,gallery,networks,poll"
; leave empty to disable
network_facebook = "tibia"
; leave empty to disable
network_twitter = "tibia"
background_image = "background-artwork.jpg"
logo_image = "tibia-logo-artwork-top.gif"
gallery_image_id_from_database = 1

View File

@ -1,18 +1,4 @@
<?php
$config['darkborder'] = "#D4C0A1";
$config['lightborder'] = "#F1E0C6";
$config['vdarkborder'] = "#505050";
$config['logo_monster'] = "Wyrm";
// separated by comma
// sequence is important! they will be shown in same order that you add them to the list
// List: newcomer,gallery,premium,poll,highscores,networks
$config['boxes'] = "highscores,newcomer,gallery,networks,poll";
$config['network_facebook'] = 'tibia'; // leave empty to disable
$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_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'),
@ -21,4 +7,3 @@ $config['menu_categories'] = array(
MENU_CATEGORY_LIBRARY => array('id' => 'library', 'name' => 'Library'),
MENU_CATEGORY_SHOP => array('id' => 'shops', 'name' => 'Shop')
);
?>