From 5b14c6d4d4db447933c46405d6a2c43f9e3c890c Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 11 Sep 2017 17:41:27 +0200 Subject: [PATCH] * fixed global config variable in twig templates * rest from account.create_character moved to twig * fixed some grammar errors * fixed some separators in kathrine template --- admin/index.php | 2 + config.php | 2 +- index.php | 2 + system/functions.php | 17 +--- system/init.php | 1 - system/pages/accountmanagement.php | 63 ++++--------- system/pages/characters.php | 6 +- system/pages/forum.php | 1 - system/pages/news.php | 1 - .../templates/account.change_info.html.twig | 38 ++++---- .../account.create_character.html.twig | 91 ++++++++++++++++++- system/templates/account.management.html.twig | 2 +- templates/kathrine/template.php | 31 +++---- 13 files changed, 148 insertions(+), 109 deletions(-) diff --git a/admin/index.php b/admin/index.php index 35f4d536..fecc26c1 100644 --- a/admin/index.php +++ b/admin/index.php @@ -25,6 +25,8 @@ require(SYSTEM . 'status.php'); require(SYSTEM . 'login.php'); require(ADMIN . 'includes/functions.php'); +$twig->addGlobal('config', $config); + // if we're not logged in - show login box if(!$logged || !admin()) { $page = 'login'; diff --git a/config.php b/config.php index e239407b..79eafde6 100644 --- a/config.php +++ b/config.php @@ -45,7 +45,7 @@ $config = array( // footer 'footer' => ''/*'
Your Server © 2016. All rights reserved.'*/, - 'debug_level' => 0, // 0 - disabled, 1 - show load time, 2 - show db query counter, 3 - both, 4 - memory usage, 5 - load time & load time, 6 - queries & memory usage, 7 - all + 'debug_level' => 0, // 0 - disabled, 1 - show load time, 2 - show db query counter, 3 - both, 4 - memory usage, 5 - load time & memory usage, 6 - queries & memory usage, 7 - all 'language' => 'en', // default language (currently only 'en' available) 'language_allow_change' => false, diff --git a/index.php b/index.php index 33305ed5..c6a05105 100644 --- a/index.php +++ b/index.php @@ -55,6 +55,8 @@ require_once(SYSTEM . 'login.php'); require_once(SYSTEM . 'status.php'); require_once(SYSTEM . 'template.php'); +$twig->addGlobal('config', $config); + // database migrations $tmp = ''; if(fetchDatabaseConfig('database_version', $tmp)) { // we got version diff --git a/system/functions.php b/system/functions.php index 6f77edb7..de2bcf56 100644 --- a/system/functions.php +++ b/system/functions.php @@ -601,7 +601,7 @@ function check_name_new_char($name, &$error = '') $player = new OTS_Player(); $player->find($name); if($player->isLoaded()) { - $error = 'Player with this name already exist.'; + $error = 'Character with this name already exist.'; return false; } @@ -614,28 +614,19 @@ function check_name_new_char($name, &$error = '') } } - $monsters = $db->query( - 'SELECT ' . $db->fieldName('name') . - ' FROM ' . $db->tableName(TABLE_PREFIX . 'monsters') . - ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower)); + $monsters = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'monsters` WHERE `name` LIKE ' . $db->quote($name_lower)); if($monsters->rowCount() > 0) { $error = 'Your name cannot contains monster name.'; return false; } - $spells_name = $db->query( - 'SELECT ' . $db->fieldName('name') . - ' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') . - ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower)); + $spells_name = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'spells` WHERE `name` LIKE ' . $db->quote($name_lower)); if($spells_name->rowCount() > 0) { $error = 'Your name cannot contains spell name.'; return false; } - $spells_words = $db->query( - 'SELECT ' . $db->fieldName('words') . - ' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') . - ' WHERE ' . $db->fieldName('words') . ' = ' . $db->quote($name_lower)); + $spells_words = $db->query('SELECT `words` FROM `' . TABLE_PREFIX . 'spells` WHERE `words` = ' . $db->quote($name_lower)); if($spells_words->rowCount() > 0) { $error = 'Your name cannot contains spell name.'; return false; diff --git a/system/init.php b/system/init.php index 3911d59d..29abf443 100644 --- a/system/init.php +++ b/system/init.php @@ -39,7 +39,6 @@ $function = new Twig_SimpleFunction('getStyle', function ($i) { return getStyle($i); }); $twig->addFunction($function); -$twig->addGlobal('config', $config); // trim values we receive if(isset($_POST)) diff --git a/system/pages/accountmanagement.php b/system/pages/accountmanagement.php index 0231d5b6..a1d16c20 100644 --- a/system/pages/accountmanagement.php +++ b/system/pages/accountmanagement.php @@ -130,7 +130,6 @@ if(!$logged) 'account_registered' => $account_registered, 'account_rlname' => $account_rlname, 'account_location' => $account_location, - 'config' => $config, 'actions' => $actions, 'players' => $players )); @@ -195,7 +194,6 @@ if(!$logged) if($config['mail_enabled'] && $config['send_mail_when_change_password']) { $mailBody = $twig->render('mail.password_changed.html.twig', array( - 'config' => $config, 'new_password' => $org_pass )); @@ -314,7 +312,7 @@ if(!$logged) $account_logged->setCustomField("rlname", $new_rlname); $account_logged->setCustomField("location", $new_location); $account_logged->setCustomField("country", $new_country); - $account_logged->logAction('Changed Real Name to ' . $new_rlname . ', Location to ' . $new_location . ' and Country to ' . $config['countries'][$new_country] . '.'); + $account_logged->logAction('Changed Real Name to ' . $new_rlname . ', Location to ' . $new_location . ' and Country to ' . $config['countries'][$new_country] . '.'); echo $twig->render('success.html.twig', array( 'title' => 'Public Information Changed', 'description' => 'Your public information has been changed.' @@ -380,7 +378,7 @@ if(!$logged) echo '
'; } else - $reg_errors[] = 'Your account is already registred.'; + $reg_errors[] = 'Your account is already registered.'; } else $reg_errors[] = 'Wrong password to account.'; @@ -666,7 +664,6 @@ if(!$logged) echo $twig->render('error_box.html.twig', array('errors' => $errors)); } echo $twig->render('account.change_sex.html.twig', array( - 'config' => $config, 'players' => $account_logged->getPlayersList(), 'player_sex' => isset($player) ? $player->getSex() : -1, 'points' => $points @@ -747,12 +744,18 @@ if(!$logged) if(isset($_POST['savecharacter']) && $_POST['savecharacter'] == 1) { if(empty($newchar_name)) $errors[] = 'Please enter a name for your character!'; - - if(strlen($newchar_name) > 25) + else if(strlen($newchar_name) > 25) $errors[] = 'Name is too long. Max. lenght 25 letters.'; else if(strlen($newchar_name) < 3) - $errors[] = 'Name is too short. Min. lenght 25 letters.'; - + $errors[] = 'Name is too short. Min. lenght 3 letters.'; + else { + $exist = new OTS_Player(); + $exist->find($newchar_name); + if($exist->isLoaded()) { + $errors[] = 'Character with this name already exist.'; + } + } + if(empty($newchar_sex) && $newchar_sex != "0") $errors[] = 'Please select the sex for your character!'; @@ -772,12 +775,6 @@ if(!$logged) $newchar_town = $config['character_towns'][0]; } - $exist = new OTS_Player(); - $exist->find($newchar_name); - if($exist->isLoaded()) { - $errors[] .= 'Character with this name already exist.'; - } - if(empty($errors)) { $error = ''; if(!admin() && !check_name_new_char($newchar_name, $error)) { @@ -923,39 +920,11 @@ if(!$logged) if(!$newchar_created) { echo $twig->render('account.create_character.html.twig', array( - 'config' => $config, - 'newchar_name' => $newchar_name - + 'name' => $newchar_name, + 'sex' => $newchar_sex, + 'vocation' => $newchar_vocation, + 'town' => $newchar_town )); - - echo '
'; - if(count($config['character_samples']) > 1) - { - echo '

Select your vocation:
'; - foreach($config['character_samples'] as $key => $sample_char) - { - echo ''; - } - echo '
'; - } - if(count($config['character_towns']) > 1) - { - echo '

Select your city:
'; - foreach($config['character_towns'] as $town_id) - { - echo ''; - } - echo '
'; - } - else - echo ''; - echo '
'; } } ?> diff --git a/system/pages/characters.php b/system/pages/characters.php index 27d27872..4bee5e82 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -80,7 +80,8 @@ if($player->isLoaded() && !$player->isDeleted()) $account = $player->getAccount(); $rows = 0; - $outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); + if($config['characters']['outfit']) + $outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); $flag = ''; if($config['account_country']) @@ -396,10 +397,9 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil } echo $twig->render('characters.html.twig', array( - 'outfit' => $outfit, + 'outfit' => isset($outfit) ? $outfit : null, 'player' => $player, 'account' => $account, - 'config' => $config, 'flag' => $flag, 'oldName' => $oldName, 'sex' => $player_sex, diff --git a/system/pages/forum.php b/system/pages/forum.php index fb8b82d8..1d35e82c 100644 --- a/system/pages/forum.php +++ b/system/pages/forum.php @@ -621,7 +621,6 @@ if($action == 'new_thread') echo $twig->render('forum.new_thread.html.twig', array( 'section_id' => $section_id, - 'config' => $config, 'players' => $players_from_account, 'post_player_id' => $char_id, 'post_thread' => $post_topic, diff --git a/system/pages/news.php b/system/pages/news.php index 72c2377a..d37c2fe6 100644 --- a/system/pages/news.php +++ b/system/pages/news.php @@ -280,7 +280,6 @@ if(!$news_cached) $account_players->orderBy('group_id', POT::ORDER_DESC); echo $twig->render('news.add.html.twig', array( - 'config' => $config, 'action' => $action, 'news_link' => getPageLink(PAGE), 'news_link_form' => getPageLink('news', ($action == 'edit' ? 'edit' : 'add')), diff --git a/system/templates/account.change_info.html.twig b/system/templates/account.change_info.html.twig index af9511f4..e4301ff2 100644 --- a/system/templates/account.change_info.html.twig +++ b/system/templates/account.change_info.html.twig @@ -16,7 +16,7 @@ Here you can tell other players about yourself. This information will be display - {{ config.darkborder }} +
@@ -42,25 +42,25 @@ Here you can tell other players about yourself. This information will be display diff --git a/system/templates/account.create_character.html.twig b/system/templates/account.create_character.html.twig index da871aaf..d138f511 100644 --- a/system/templates/account.create_character.html.twig +++ b/system/templates/account.create_character.html.twig @@ -45,17 +45,17 @@ In any case the name must not violate the naming conventions stated in the @@ -63,4 +63,85 @@ In any case the name must not violate the naming conventions stated in the
-
+
Please enter your character name.
{% set i = 0 %} - {% for id, _sex in config.genders|reverse(true) %} + {% for id, gender in config.genders|reverse(true) %} {% set i = i + 1 %} -
+
{% endfor %}
-
\ No newline at end of file + +
+ + + {% if config.character_samples|length > 1 %} + + {% endif %} + +
+ + + + + +

Select your vocation:
+ + {% for key, sample_char in config.character_samples %} + + + + {% endfor %} +
+ + +
+
+ {% endif %} + {% if config.character_towns|length > 1 %} +
+ + + + + +

Select your city:
+ + {% for town_id in config.character_towns %} + + + + {% endfor %} +
+ + +
+
+
+
+ + + + +
+ + + + + +
+ + + + + +
+
+
+
+
+
+ + + + + + +
+
+
+
\ No newline at end of file diff --git a/system/templates/account.management.html.twig b/system/templates/account.management.html.twig index f3962e01..4ff0a4f8 100644 --- a/system/templates/account.management.html.twig +++ b/system/templates/account.management.html.twig @@ -174,7 +174,7 @@ {{ account_status }} - Registred: + Registered: {{ account_registered }} {% endautoescape %} diff --git a/templates/kathrine/template.php b/templates/kathrine/template.php index 84a9567f..04183f79 100644 --- a/templates/kathrine/template.php +++ b/templates/kathrine/template.php @@ -90,31 +90,28 @@ defined('MYAAC') or die('Direct access not allowed!');
Characters Guilds - Wars - '; - ?> + if(isset($config['wars'])): ?> + + Wars + + Highscores Last Deaths Houses - - - + + Bans - - - - '; - ?> + + + Forum + + Team