From 35e4cd459605dc4d82309babd18f88138ae28a06 Mon Sep 17 00:00:00 2001 From: whiteblXK Date: Mon, 29 Apr 2019 20:42:03 +0200 Subject: [PATCH 1/5] Houses page to twig --- index.php | 3 +- system/pages/houses.php | 425 +++++++++---------------- system/templates/houses.html.twig | 166 ++++++++++ system/templates/houses.view.html.twig | 51 +++ 4 files changed, 371 insertions(+), 274 deletions(-) create mode 100644 system/templates/houses.html.twig create mode 100644 system/templates/houses.view.html.twig diff --git a/index.php b/index.php index 20f2c706..5afc0972 100644 --- a/index.php +++ b/index.php @@ -123,7 +123,8 @@ else { '/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'), '/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'), '/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'), - '/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2') + '/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'), + '/^houses\/view\/?$/' => array('subtopic' => 'houses', 'page' => 'view') ); foreach($rules as $rule => $redirect) { diff --git a/system/pages/houses.php b/system/pages/houses.php index 51585bd8..32e318a0 100644 --- a/system/pages/houses.php +++ b/system/pages/houses.php @@ -5,309 +5,188 @@ * @package MyAAC * @author Gesior * @author Slawkens - * @copyright 2017 MyAAC + * @author whiteblXK + * @copyright 2019 MyAAC * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Houses'; +$errors = array(); if(!$db->hasColumn('houses', 'name')) { - echo 'Houses list is not available on this server.'; + $errors[] = 'Houses list is not available on this server.'; + + $twig->display('houses.html.twig', array( + 'errors' => $errors + )); return; } -$rent = trim(strtolower($config['lua']['houseRentPeriod'])); -if($rent != 'yearly' && $rent != 'monthly' && $rent != 'weekly' && $rent != 'daily') - $rent = 'never'; + +$rentType = trim(strtolower($config['lua']['houseRentPeriod'])); +if($rentType != 'yearly' && $rentType != 'monthly' && $rentType != 'weekly' && $rentType != 'daily') + $rentType = 'never'; $state = ''; $order = ''; $type = ''; -?> - - - - - - -
-query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId)); - if($house->rowCount() > 0) - { - $house = $house->fetch(); - $houseId = $house['id']; +if(isset($_GET['page']) && $_GET['page'] == 'view' && isset($_REQUEST['house'])) +{ + $beds = array("", "one", "two", "three", "fourth", "fifth"); + $houseName = $_REQUEST['house']; + $houseId = (Validator::number($_REQUEST['house']) ? $_REQUEST['house'] : -1); + $selectHouse = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId)); - $title = $house['name'] . ' - ' . $title; - echo ' - - -
'; - $img_path = 'images/houses/' . $houseId . '.gif'; - if(file_exists($img_path)) - echo ''; - else - echo ''; + $house = array(); + if($selectHouse->rowCount() > 0) + { + $house = $selectHouse->fetch(); + $houseId = $house['id']; - echo ' - ' . $house['name'] . '
This house '; - $houseBeds = $house['beds']; - if($houseBeds > 0) - echo 'has ' . (isset($beds[$houseBeds]) ? $beds[$houseBeds] : $houseBeds) . ' bed' . ($houseBeds > 1 ? 's' : ''); - else - echo 'dont have any beds'; + $title = $house['name'] . ' - ' . $title; - echo '.

The house has a size of ' . $house['size'] . ' square meters.'; + $imgPath = 'images/houses/' . $houseId . '.gif'; + if(!file_exists($imgPath)) { + $imgPath = 'images/houses/default.jpg'; + } - if($rent != 'never') - echo ' The ' . $rent . ' rent is ' . $house['rent'] . ' gold and will be debited to the bank account on ' . $config['lua']['serverName'] . '.'; + $bedsMessage = null; + $houseBeds = $house['beds']; + if($houseBeds > 0) + $bedsMessage = 'House have ' . (isset($beds[$houseBeds]) ? $beds[$houseBeds] : $houseBeds) . ' bed' . ($houseBeds > 1 ? 's' : ''); + else + $bedsMessage = 'This house dont have any beds'; - $houseOwner = $house['owner']; - if($houseOwner > 0) - { - $guild = NULL; - echo '

The house has been rented by '; - if(isset($house['guild']) && $house['guild'] == 1) - { - $guild = new OTS_Guild(); - $guild->load($houseOwner); - echo getGuildLink($guild->getName()); - } - else - echo getCreatureName($houseOwner); + $houseOwner = $house['owner']; + if($houseOwner > 0) + { + $guild = NULL; + $owner = null; + if(isset($house['guild']) && $house['guild'] == 1) + { + $guild = new OTS_Guild(); + $guild->load($houseOwner); + $owner = getGuildLink($guild->getName()); + } + else + $owner = getCreatureName($houseOwner); - echo '.'; + if($rentType != 'never' && $house['paid'] > 0) + { + $who = ''; + if($guild) + $who = $guild->getName(); + else + { + $player = new OTS_Player(); + $player->load($houseOwner); + if($player->isLoaded()) + { + $sexs = array('She', 'He'); + $who = $sexs[$player->getSex()]; + } + } + $owner .= ' ' . $who . ' has paid the rent until ' . date("M d Y, H:i:s", $house['paid']) . ' CEST.'; + } + } + } + else + $errors[] = 'House with name ' . $houseName . ' does not exists.'; - if($rent != 'never' && $house['paid'] > 0) - { - $who = ''; - if($guild) - $who = $guild->getName(); - else - { - $player = new OTS_Player(); - $player->load($houseOwner); - if($player->isLoaded()) - { - $sexs = array('She', 'He'); - $who = $sexs[$player->getSex()]; - } - } - echo ' ' . $who . ' has paid the rent until ' . date("M d Y, H:i:s", $house['paid']) . ' CEST.'; - } - } + $twig->display('houses.view.html.twig', array( + 'errors' => $errors, + 'imgPath' => isset($imgPath) ? $imgPath : null, + 'houseName' => isset($house['name']) ? $house['name'] : null, + 'bedsMessage' => isset($bedsMessage) ? $bedsMessage : null, + 'houseSize' => isset($house['size']) ? $house['size'] : null, + 'houseRent' => isset($house['rent']) ? $house['rent'] : null, + 'owner' => isset($owner) ? $owner : null, + 'rentType' => isset($rentType) ? $rentType : null + )); - echo '
'; - } - else - echo 'House with name ' . $houseName . ' does not exists.'; - } - else - { - echo ' - Here you can see the list of all available houses, flats' . ($db->hasTable('houses', 'guild') ? ' or guildhall' : '') . '. - Click on any view button to get more information about a house or adjust - the search criteria and start a new search.

'; - if(isset($config['lua']['houseCleanOld'])) { - $cleanOld = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60)); - if($cleanOld > 0 || $rent != 'never') - { - echo 'Every morning during global server save there is automatic house cleaning. Server delete house owners who have not logged in last ' . $cleanOld . ' days'; - if($rent != 'never') - { - echo ' or have not paid ' . $rent . ' house rent. Remember to leave money for a rent in '; - $bank = getBoolean($config['lua']['bankSystem']); - if($bank) - echo 'your house bank account or '; + if (count($errors) > 0) { + return; + } +} - echo 'depo in same city where you have house!'; - } - else - echo '.'; +$cleanOldHouse = null; +if(isset($config['lua']['houseCleanOld'])) { + $cleanOldHouse = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60)); +} - echo '

'; - } - } +if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && (isset($_POST['type']) || !$db->hasColumn('houses', 'guild'))) +{ + $townName = $config['towns'][$_POST['town']]; + $order = $_POST['order']; + $orderby = '`name`'; + if(!empty($order)) + { + if($order == 'size') + $orderby = '`size`'; + else if($order == 'rent') + $orderby = '`rent`'; + } - echo '
'; + $town = 'town'; + if($db->hasColumn('houses', 'town_id')) + $town = 'town_id'; + else if($db->hasColumn('houses', 'townid')) + $town = 'townid'; - if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) - && (isset($_POST['type']) || !$db->hasColumn('houses', 'guild'))) - { - $order = $_POST['order']; - $orderby = '`name`'; - if(!empty($order)) - { - if($order == 'size') - $orderby = '`size`'; - else if($order == 'rent') - $orderby = '`rent`'; - } + $whereby = '`' . $town . '` = ' .(int)$_POST['town']; + $state = $_POST['state']; + if(!empty($state)) + $whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0'; - $town = 'town'; - if($db->hasColumn('houses', 'town_id')) - $town = 'town_id'; - else if($db->hasColumn('houses', 'townid')) - $town = 'townid'; - - $whereby = '`' . $town . '` = ' .(int)$_POST['town']; - $state = $_POST['state']; - if(!empty($state)) - $whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0'; + $type = isset($_POST['type']) ? $_POST['type'] : NULL; + if($type == 'guildhalls' && !$db->hasColumn('houses', 'guild')) + $type = 'all'; - $type = isset($_POST['type']) ? $_POST['type'] : NULL; - if($type == 'guildhalls' && !$db->hasColumn('houses', 'guild')) - $type = 'all'; + if(!empty($type) && $type != 'all') + $whereby .= ' AND `guild` ' . ($type == 'guildhalls' ? '!' : '') . '= 0'; - if(!empty($type) && $type != 'all') - $whereby .= ' AND `guild` ' . ($type == 'guildhalls' ? '!' : '') . '= 0'; + $houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby); + $houses_count = $houses_info->rowCount(); - $houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby); + $players_info = $db->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`"); + $players = array(); + foreach($players_info->fetchAll() as $player) + $players[$player['houseid']] = array('name' => $player['ownername']); - echo ' - - - - - '; - if($houses_info->rowCount() > 0) - { - echo ' - - - + $houses = array(); + foreach($houses_info->fetchAll() as $house) + { + $owner = isset($players[$house['id']]) ? $players[$house['id']] : array(); - - '; - } - else - echo ''; + $houseRent = null; + if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0) + { + $guild = new OTS_Guild(); + $guild->load($house['owner']); + $houseRent = 'Rented by ' . getGuildLink($guild->getName()); + } + else + { + if(!empty($owner['name'])) + $houseRent = 'Rented by ' . getPlayerLink($owner['name']); + else + $houseRent = 'Free'; + } - echo ''; + $houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => $house['size'], 'rent' => $house['rent'], 'rentedBy' => $houseRent); + } +} - $players_info = $db->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`"); - $players = array(); - foreach($players_info->fetchAll() as $player) - $players[$player['houseid']] = array('name' => $player['ownername']); - - $rows = 1; - foreach($houses_info->fetchAll() as $house) - { - $owner = isset($players[$house['id']]) ? $players[$house['id']] : array(); - echo - ' - - - - - - '; - $rows++; - } - echo - '
Available ' . ($type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats').' in '.$config['towns'][$_POST['town']].' on '.$config['lua']['serverName'].'
NameSizeRentStatus No ' . ($type == 'guildhalls' ? 'guildhalls' : 'houses') . ' with specified criterias.
'.$house['name'].''.$house['size'].' sqm'.$house['rent'].' gold'; - if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0) - { - $guild = new OTS_Guild(); - $guild->load($house['owner']); - echo 'Rented by ' . getGuildLink($guild->getName()); - } - else - { - if(!empty($owner['name'])) - echo 'Rented by ' . getPlayerLink($owner['name']); - else - echo - 'Free'; - } - - echo ' - - - - - -
- - -
-
'. - '

'; - } - - echo ' -
- - - - - - - - - - - - - - '; - - if($db->hasColumn('houses', 'guild')) { - echo ' - - - '; - } - echo ' -
House Search
TownStatusOrder
'; - $townId = isset($_POST['town']) ? $_POST['town'] : ''; - $i = 0; - $checked = false; - foreach($config['towns'] as $id => $name) - { - if($id == 0) - continue; - - $i++; - if(((empty($townId) && !empty($name)) || $id == $townId) && !$checked) - { - $add = 'CHECKED'; - $checked = true; - } - else - $add = ''; - - if(!empty($name)) - echo '
'; - } - - echo ' -
-
-
-
-
-
-
-
-
- all
- houses and flats
- guildhalls
-
-
-
-
- ' . $twig->render('buttons.submit.html.twig') . ' -
-
'; - } - echo ' -
- '; -?> +$guild = $db->hasTable('houses', 'guild') ? ' or guildhall' : ''; +$twig->display('houses.html.twig', array( + 'state' => $state, + 'order' => $order, + 'type' => $type, + 'houseType' => $type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats', + 'townName' => isset($townName) ? $townName : null, + 'townId' => isset($_POST['town']) ? $_POST['town'] : null, + 'guild' => $guild, + 'cleanOldHouse' => isset($cleanOld) ? $cleanOld : null, + 'housesCount' => isset($houses_count) ? $houses_count : null, + 'houses' => isset($houses) ? $houses : null +)); \ No newline at end of file diff --git a/system/templates/houses.html.twig b/system/templates/houses.html.twig new file mode 100644 index 00000000..16a8ce71 --- /dev/null +++ b/system/templates/houses.html.twig @@ -0,0 +1,166 @@ +
+ {% if errors is not empty %} + {% for error in errors %} +

{{ error }}

+ {% endfor %} + {% else %} + +
+
+ + + + +
House Search
+ + + + +
+
+ + + + +
+
+ Here you can see the list of all available houses, flats{{ guildString }}. + Click on any view button to get more information about a house or adjust + the search criteria and start a new search. +

+ {% if cleanOldHouse is not empty or rentType != 'never' %} + Every morning during global server save there is automatic house cleaning. Server delete house owners who have not logged in last {{ cleanOldHouse }} days{% if rentType != 'never' %} or have not paid {{ rentType }} house rent. Remember to leave money for a rent in {% if config.lua.bankSystem is not empty %}your house bank or {% else %}depo in same city where you have house!{% endif %}{% else %}.{% endif %} +

+ {% endif %} + + {% if houses is not empty %} + + + + + + + + {% if housesCount > 0 %} + + + + + + + {% else %} + + {% endif %} + + + {% set i = 0 %} + {% for house in houses %} + {% set i = i + 1 %} + + + + + + + + + + + + {% endfor %} + +
Available {{ houseType }} {% if townName is not empty %}in {{ townName }}{% endif %}on {{ config.lua.serverName }}
NameSizeRentStatus No {{ houseType }} with specified criterias.
+ {{ house.name }} + + {{ house.size }} + + {{ house.rent }} golds + + {{ house.rentedBy|raw }} + +
+ + +
+
+
+ {% endif %} + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
House Search
TownStatusOrder
+ {% set checked = false %} + {% for id, name in config.towns if id > 0 %} + {% if ((townId is empty and name is not empty) or id == townId) and not checked %} + {% set variable = "checked" %} + {% set checked = true %} + {% else %} + {% set variable = "" %} + {% endif %} + + + +
+ {% endfor %} +
+ +
+ + +
+ + +
+
+ +
+ + +
+ + +
+
+ all
+ houses and flats
+ guildhalls
+
+
+ + + + + + + +
+ {{ include('buttons.submit.html.twig') }} +
+
+
+
+ {% endif %} +
\ No newline at end of file diff --git a/system/templates/houses.view.html.twig b/system/templates/houses.view.html.twig new file mode 100644 index 00000000..31fc5c23 --- /dev/null +++ b/system/templates/houses.view.html.twig @@ -0,0 +1,51 @@ +
+ {% if errors is not empty %} + {% for error in errors %} +

{{ error }}

+ {% endfor %} + {% else %} + +
+
+ + + + +
{{ houseName }}
+ + + + +
+
+ + + + +
+
+ + + + + +
+ {{ bedsMessage }} and has a size of {{ houseSize }} square meters. + + {% if rentType != 'never' %} + The {{ rentType }} is {{ houseRent }} gold and will be debited to the bank account on {{ config.lua.serverName }}. + {% endif %} +
+ + {% if owner is not empty %} + The house has been rented by {{ owner|raw }}. + {% else %} + No one has bought this house yet. + {% endif %} +
+
+
+ {% endif %} + +
+

\ No newline at end of file From d594fa1a5489f1d184d527e48f63fbb68dba78d7 Mon Sep 17 00:00:00 2001 From: whiteblXK Date: Fri, 3 May 2019 12:47:28 +0200 Subject: [PATCH 2/5] Now it will properly shows Available Houses --- system/pages/houses.php | 6 ++-- system/templates/houses.html.twig | 58 ++++++++++++++++--------------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/system/pages/houses.php b/system/pages/houses.php index 32e318a0..5c596059 100644 --- a/system/pages/houses.php +++ b/system/pages/houses.php @@ -114,6 +114,7 @@ if(isset($config['lua']['houseCleanOld'])) { $cleanOldHouse = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60)); } +$housesSearch = false; if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && (isset($_POST['type']) || !$db->hasColumn('houses', 'guild'))) { $townName = $config['towns'][$_POST['town']]; @@ -146,7 +147,6 @@ if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && $whereby .= ' AND `guild` ' . ($type == 'guildhalls' ? '!' : '') . '= 0'; $houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby); - $houses_count = $houses_info->rowCount(); $players_info = $db->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`"); $players = array(); @@ -175,6 +175,8 @@ if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && $houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => $house['size'], 'rent' => $house['rent'], 'rentedBy' => $houseRent); } + + $housesSearch = true; } $guild = $db->hasTable('houses', 'guild') ? ' or guildhall' : ''; @@ -187,6 +189,6 @@ $twig->display('houses.html.twig', array( 'townId' => isset($_POST['town']) ? $_POST['town'] : null, 'guild' => $guild, 'cleanOldHouse' => isset($cleanOld) ? $cleanOld : null, - 'housesCount' => isset($houses_count) ? $houses_count : null, + 'housesSearch' => $housesSearch, 'houses' => isset($houses) ? $houses : null )); \ No newline at end of file diff --git a/system/templates/houses.html.twig b/system/templates/houses.html.twig index 16a8ce71..a87bf98a 100644 --- a/system/templates/houses.html.twig +++ b/system/templates/houses.html.twig @@ -31,54 +31,56 @@

{% endif %} - {% if houses is not empty %} + {% if houses is not empty or housesSearch %} - + - {% if housesCount > 0 %} + {% if houses is not empty %} - {% else %} + {% elseif housesSearch %} {% endif %} - {% set i = 0 %} - {% for house in houses %} - {% set i = i + 1 %} - - + {% if houses is not empty %} + {% set i = 0 %} + {% for house in houses %} + {% set i = i + 1 %} + + - + - + - + - - - {% endfor %} + + + {% endfor %} + {% endif %}
Available {{ houseType }} {% if townName is not empty %}in {{ townName }}{% endif %}on {{ config.lua.serverName }}Available {{ houseType }}{% if townName is not empty %} in {{ townName }}{% endif %} on {{ config.lua.serverName }}
Name Size Rent Status  No {{ houseType }} with specified criterias.
- {{ house.name }} -
+ {{ house.name }} + - {{ house.size }} - + {{ house.size }} + - {{ house.rent }} golds - + {{ house.rent }} golds + - {{ house.rentedBy|raw }} - + {{ house.rentedBy|raw }} + -
- - -
-
+
+ + +
+

From ed6a740eeebe5c43a0e1321b8548f3f416ef8637 Mon Sep 17 00:00:00 2001 From: whiteblXK Date: Fri, 3 May 2019 14:08:46 +0200 Subject: [PATCH 3/5] Fix undefined variable in serverinfo for old TFS --- system/pages/serverinfo.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/system/pages/serverinfo.php b/system/pages/serverinfo.php index b91384a1..ac62c0bb 100644 --- a/system/pages/serverinfo.php +++ b/system/pages/serverinfo.php @@ -98,12 +98,12 @@ $twig->display('serverinfo.html.twig', array( 'redSkullLength' => $redSkullLength, 'blackSkull' => $blackSkull, 'blackSkullLength' => $blackSkullLength, - 'dailyFragsToRedSkull' => isset($config['lua']['dailyFragsToRedSkull']) ? $config['lua']['dailyFragsToRedSkull'] : $config['lua']['kills_per_day_red_skull'], - 'weeklyFragsToRedSkull' => isset($config['lua']['weeklyFragsToRedSkull']) ? $config['lua']['weeklyFragsToRedSkull'] : $config['lua']['kills_per_week_red_skull'], - 'monthlyFragsToRedSkull' => isset($config['lua']['monthlyFragsToRedSkull']) ? $config['lua']['monthlyFragsToRedSkull'] : $config['lua']['kills_per_month_red_skull'], - 'dailyFragsToBlackSkull' => isset($config['lua']['dailyFragsToBlackSkull']) ? $config['lua']['dailyFragsToBlackSkull'] : isset($config['lua']['kills_per_day_black_skull']) ? $config['lua']['kills_per_day_black_skull'] : null, - 'weeklyFragsToBlackSkull' => isset($config['lua']['weeklyFragsToBlackSkull']) ? $config['lua']['weeklyFragsToBlackSkull'] : isset($config['lua']['kills_per_week_black_skull']) ? $config['lua']['kills_per_week_black_skull'] : null, - 'monthlyFragsToBlackSkull' => isset($config['lua']['monthlyFragsToBlackSkull']) ? $config['lua']['monthlyFragsToBlackSkull'] : isset($config['lua']['kills_per_month_black_skull']) ? $config['lua']['kills_per_month_black_skull'] : null, + 'dailyFragsToRedSkull' => isset($config['lua']['dailyFragsToRedSkull']) ? $config['lua']['dailyFragsToRedSkull'] : (isset($config['lua']['kills_per_day_red_skull']) ? $config['lua']['kills_per_day_red_skull'] : null), + 'weeklyFragsToRedSkull' => isset($config['lua']['weeklyFragsToRedSkull']) ? $config['lua']['weeklyFragsToRedSkull'] : (isset($config['lua']['kills_per_week_red_skull']) ? $config['lua']['kills_per_week_red_skull'] : null), + 'monthlyFragsToRedSkull' => isset($config['lua']['monthlyFragsToRedSkull']) ? $config['lua']['monthlyFragsToRedSkull'] : (isset($config['lua']['kills_per_month_red_skull']) ? $config['lua']['kills_per_month_red_skull'] : null), + 'dailyFragsToBlackSkull' => isset($config['lua']['dailyFragsToBlackSkull']) ? $config['lua']['dailyFragsToBlackSkull'] : (isset($config['lua']['kills_per_day_black_skull']) ? $config['lua']['kills_per_day_black_skull'] : null), + 'weeklyFragsToBlackSkull' => isset($config['lua']['weeklyFragsToBlackSkull']) ? $config['lua']['weeklyFragsToBlackSkull'] : (isset($config['lua']['kills_per_week_black_skull']) ? $config['lua']['kills_per_week_black_skull'] : null), + 'monthlyFragsToBlackSkull' => isset($config['lua']['monthlyFragsToBlackSkull']) ? $config['lua']['monthlyFragsToBlackSkull'] : (isset($config['lua']['kills_per_month_black_skull']) ? $config['lua']['kills_per_month_black_skull'] : null), 'banishmentLength' => isset($config['lua']['banishment_length']) ? eval('return (' . $config['lua']['banishment_length'] . ') / (24 * 60 * 60);') : null, 'finalBanishmentLength' => isset($config['lua']['final_banishment_length']) ? eval('return (' . $config['lua']['final_banishment_length'] . ') / (24 * 60 * 60);') : null, 'ipBanishmentLength' => isset($config['lua']['ip_banishment_length']) ? eval('return (' . $config['lua']['ip_banishment_length'] . ') / (24 * 60 * 60);') : null, From 69064839a7d8bb133185959eae65b6e2b82568da Mon Sep 17 00:00:00 2001 From: whiteblXK Date: Fri, 3 May 2019 19:12:07 +0200 Subject: [PATCH 4/5] Guilds List to twig --- system/pages/guilds/list_of_guilds.php | 147 +++++------------------ system/templates/guilds.list.html.twig | 160 +++++++++++++++++++++++++ 2 files changed, 190 insertions(+), 117 deletions(-) create mode 100644 system/templates/guilds.list.html.twig diff --git a/system/pages/guilds/list_of_guilds.php b/system/pages/guilds/list_of_guilds.php index 2463e191..74b790fe 100644 --- a/system/pages/guilds/list_of_guilds.php +++ b/system/pages/guilds/list_of_guilds.php @@ -1,126 +1,39 @@ + * @author Slawkens + * @author whiteblXK + * @copyright 2019 MyAAC + * @link http://my-aac.org + */ +defined('MYAAC') or die('Direct access not allowed!'); $guilds_list = new OTS_Guilds_List(); - -if(!isset($_REQUEST['preview'])) - $_REQUEST['preview'] = 1; - $guilds_list->orderBy("name"); -//echo 'Guilds needs to have atleast 4 members, otherwise it will be deleted automatically after 4 days.

Guild statistics are self-updated once per 3 days.

'; - -//echo 'Normal preview / Advanced ranks & statistics

-echo ' - - - '; -if($_REQUEST['preview'] == 2) { - echo ' - - - '; - /* - - - - ';*/ -} -else - echo ' - - - '; - -echo ' - '; -$showed_guilds = 0; - -if($_REQUEST['preview'] == 2) +$guilds = array(); +if(count($guilds_list) > 0) { - if(count($guilds_list) > 0) - { - foreach($guilds_list as $guild) - { - $guild_logo = $guild->getCustomField('logo_name'); - if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) - $guild_logo = "default.gif"; - - echo ' - '; - // - - echo ''; - } - } - else - echo ' - - '; -} -else -{ - if(count($guilds_list) > 0) - { - foreach($guilds_list as $guild) - { - $guild_logo = $guild->getCustomField('logo_name'); - if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) - $guild_logo = "default.gif"; + foreach ($guilds_list as $guild) { + $guild_logo = $guild->getCustomField('logo_name'); + if (empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) + $guild_logo = "default.gif"; - $description = $guild->getCustomField('description'); - $description_with_lines = str_replace(array("\r\n", "\n", "\r"), '
', $description, $count); - if($count < $config['guild_description_lines_limit']) - $description = wordwrap(nl2br($description), 60, "
", true); + $description = $guild->getCustomField('description'); + $description_with_lines = str_replace(array("\r\n", "\n", "\r"), '
', $description, $count); + if ($count < $config['guild_description_lines_limit']) + $description = wordwrap(nl2br($description), 60, "
", true); - echo ' - '; - } - } - else - echo ' - - '; -} + $guildName = $guild->getName(); + $guilds[] = array('name' => $guildName, 'logo' => $guild_logo, 'link' => getGuildLink($guildName, false), 'description' => $description); + } +}; - -echo '
Active Guilds on '.$config['lua']['serverName'].'
RankLogoGuild nameMembersTotal levelAverage levelFragsLogoDescription
'.($show_ranks ? $showed_guilds.'.' : '-').''.$guild->getName().'
'; - if(admin()) - echo '
Delete this guild (for ADMIN only!)'; - echo '
'.$guild->getCustomField('total_members').''.$guild->getCustomField('total_level').''; - //if($guild->getCustomField('total_members') > 0) - // echo ceil($guild->getCustomField('total_level')/$guild->getCustomField('total_members')); - //echo ''.$guild->getCustomField('frags').'
-Create guild
Actually there is no guild on server.' . ($logged ? ' Create first! Press button "Create Guild".' : '') . '
'; - if($logged) - echo ' -
- -
'; - - echo ' -
'.$guild->getName().'
'.$description.''; - if(admin()) - echo '
Delete this guild (for ADMIN only!)'; - echo '
- -
-
Create guild
Actually there is no guild on server.' . ($logged ? ' Create first! Press button "Create Guild".' : '') . '
'; - if($logged) - echo '
- -
'; - echo ' -


'; -if($logged) - echo '
- -
-
If you have any problem with guilds try: -
Cleanup players - can\'t join guild/be invited? Can\'t create guild? Try cleanup players. -
Cleanup guilds - made guild, you are a leader, but you are not on players list? Cleanup guilds!'; -else - echo 'Before you can create guild you must login.
- -
'; -?> \ No newline at end of file +$twig->display('guilds.list.html.twig', array( + 'guilds' => $guilds, + 'logged' => isset($logged) ? $logged : false, + 'isAdmin' => admin(), +)); \ No newline at end of file diff --git a/system/templates/guilds.list.html.twig b/system/templates/guilds.list.html.twig new file mode 100644 index 00000000..a24cbb67 --- /dev/null +++ b/system/templates/guilds.list.html.twig @@ -0,0 +1,160 @@ +
+
+
+ + + + +
Active Guilds on {{ config.lua.serverName }}
+ + + + +
+
+ + + + + + + +
+
+ + + + + + +
+
+ + + {% if guilds|length > 0 %} + + + + + + + {% set i = 0 %} + {% for guild in guilds %} + {% set i = i + 1 %} + + + + + + + + {% endfor %} + {% else %} + + + + {% if logged %} + + {% endif %} + + {% endif %} + +
LogoDescription 
+ + + + {{ guild.name }}{% if isAdmin %} - Delete this guild (for ADMIN only!){% endif %} + + + {% if guild.description is not empty %} +
+ {{ guild.description }} + {% endif %} +
+ + + + + + +
+
+ +
+
+
+ Create Guild +
+ Actually there is no guild on server.{% if logged %} Create first! Press button "Create Guild"{% endif %} +
+ + + + + + +
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + +
+ + + + + {% if logged %} + + + + + + {% else %} + Before you can create guild you must login. +
+ + + + + + {% endif %} + +
+ +
+ +
+ + {% if logged %} +
+ If you have any problem with guilds try: +
+ Cleanup players - can\'t join guild/be invited? Can\'t create guild? Try cleanup players. +
+ Cleanup guilds - made guild, you are a leader, but you are not on players list? Cleanup guilds!'; + {% endif %} +
+ +
+ + + + From 257d4dbdad8e6d7dc478e3c5c0c1de81657babdb Mon Sep 17 00:00:00 2001 From: whiteblXK Date: Fri, 3 May 2019 19:17:28 +0200 Subject: [PATCH 5/5] Typo, should be "List" --- system/pages/guilds/list_of_guilds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/pages/guilds/list_of_guilds.php b/system/pages/guilds/list_of_guilds.php index 74b790fe..86f58b8a 100644 --- a/system/pages/guilds/list_of_guilds.php +++ b/system/pages/guilds/list_of_guilds.php @@ -1,6 +1,6 @@