From d9675b1bc6743eeeed88f7aa3ee16c053ad69448 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Thu, 23 Nov 2017 17:55:42 +0100 Subject: [PATCH] * (internal) moved changelog to twig * added changelog menu item to kathrine template * (fix) if changelog type or where is set to 0 then display as unknown --- images/changelog/unknown.png | Bin 0 -> 797 bytes index.php | 1 + install/includes/schema.sql | 1 + system/migrations/17.php | 1 + system/pages/changelog.php | 76 ++++++++------------------- system/templates/changelog.html.twig | 38 ++++++++++++++ 6 files changed, 62 insertions(+), 55 deletions(-) create mode 100644 images/changelog/unknown.png create mode 100644 system/templates/changelog.html.twig diff --git a/images/changelog/unknown.png b/images/changelog/unknown.png new file mode 100644 index 0000000000000000000000000000000000000000..9cf7605f58a961777fa9156f1a2482753a6818a3 GIT binary patch literal 797 zcmV+&1LFLNP)}cm@p> z(LgjcCOS{4DITUbZEjt(V&J!jw~3wBP2cUaJghY7V1V@0{DH3 z@q{M5HLPmpBvfKNiK^9D^Sfl@T^9ZWd`jp=CrD^@5R_rgI7e@;txbT)C~3oYbb>K#Ej{B=IOF%zKoeWyp+p zK|d-LCKPr~!zY?=OU#V%I~ANGoPSuEFZPaYM9Ir}w2rN#pvge4JPdZ38aZ`3)T3Pf7*Ei1J-=7r}6qFnq8k$YWqS0s^GLH!f389m*H{q(I bb%)?P@6ev@d$7BL00000NkvXXu0mjfs)l=! literal 0 HcmV?d00001 diff --git a/index.php b/index.php index 124d9cf9..fee0c8e7 100644 --- a/index.php +++ b/index.php @@ -93,6 +93,7 @@ else { '/^account\/character\/comment\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_comment'), '/^account\/confirm_email\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'confirm_email', 'v' => '$2'), '/^characters\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'characters', 'name' => '$1'), + '/^changelog\/[0-9]+\/?$/' => array('subtopic' => 'changelog', 'page' => '$1'), '/^commands\/add\/?$/' => array('subtopic' => 'commands', 'action' => 'add'), '/^commands\/edit\/?$/' => array('subtopic' => 'commands', 'action' => 'edit'), '/^faq\/add\/?$/' => array('subtopic' => 'faq', 'action' => 'add'), diff --git a/install/includes/schema.sql b/install/includes/schema.sql index 9b0bd744..d45965b0 100644 --- a/install/includes/schema.sql +++ b/install/includes/schema.sql @@ -155,6 +155,7 @@ CREATE TABLE `myaac_menu` /* MENU_CATEGORY_NEWS kathrine */ INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Latest News', 'news', 1, 0); INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'News Archive', 'news/archive', 1, 1); +INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Changelog', 'changelog', 1, 2); /* MENU_CATEGORY_ACCOUNT kathrine */ INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Account Management', 'account/manage', 2, 0); INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Create Account', 'account/create', 2, 1); diff --git a/system/migrations/17.php b/system/migrations/17.php index 5d5b0f8c..751df6f6 100644 --- a/system/migrations/17.php +++ b/system/migrations/17.php @@ -18,6 +18,7 @@ CREATE TABLE `myaac_menu` /* MENU_CATEGORY_NEWS kathrine */ INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Latest News', 'news', 1, 0); INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'News Archive', 'news/archive', 1, 1); +INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Changelog', 'changelog', 1, 2); /* MENU_CATEGORY_ACCOUNT kathrine */ INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Account Management', 'account/manage', 2, 0); INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Create Account', 'account/create', 2, 1); diff --git a/system/pages/changelog.php b/system/pages/changelog.php index 04620f81..7b1a5c6c 100644 --- a/system/pages/changelog.php +++ b/system/pages/changelog.php @@ -15,66 +15,32 @@ $id = isset($_GET['id']) ? $_GET['id'] : 0; $limit = 30; $offset = $_page * $limit; $next_page = false; -?> -
- - - - - - - -query('SELECT * FROM `' . TABLE_PREFIX . 'changelog' . '` WHERE `hidden` = 0 ORDER BY `id` DESC LIMIT ' . ($limit + 1) . ' OFFSET ' . $offset)->fetchAll(); -$changelogs = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'changelog') . ' ORDER BY ' . $db->fieldName('id') . ' DESC LIMIT ' . $limit . ' OFFSET ' . $offset); -if(!$changelogs->rowCount()) +$i = 0; +foreach($changelogs as $key => &$log) { -?> - - - - - - - - - - -= $limit) - $next_page = true; + if($i < $limit) { + $log['type'] = getChangelogType($log['type']); + $log['where'] = getChangelogWhere($log['where']); + } + else { + unset($changelogs[$key]); } -?> -
TypeWhereDateDescription
There are no change logs for the moment.
- - - -
- 0) - echo ''; - if($next_page) - echo ''; -?> -
Previous Page
Next Page
-= $limit) + $next_page = true; + + $i++; } -?> - -render('changelog.html.twig', array( + 'changelogs' => $changelogs, + 'page' => $_page, + 'next_page' => $next_page, +)); + function getChangelogType($v) { switch($v) { @@ -88,7 +54,7 @@ function getChangelogType($v) return 'fixed'; } - return 'Unknown type'; + return 'unknown'; } function getChangelogWhere($v) @@ -100,6 +66,6 @@ function getChangelogWhere($v) return 'website'; } - return 'Unknown where'; + return 'unknown'; } ?> diff --git a/system/templates/changelog.html.twig b/system/templates/changelog.html.twig new file mode 100644 index 00000000..c9e266b8 --- /dev/null +++ b/system/templates/changelog.html.twig @@ -0,0 +1,38 @@ +
+ + + + + + + + {% if changelogs|length > 0%} + {% set i = 0 %} + {% for log in changelogs %} + + + + + + + {% set i = i + 1 %} + {% endfor %} + {% else %} + + + + {% endif %} + +
TypeWhereDateDescription
+ + + + {{ log.date|date("j.m.Y") }}{{ log.body|raw }}
There are no change logs for the moment.
+ {% if page > 0 %} + + {% endif %} + {% if next_page %} + + {% endif %} +
Previous Page
Next Page
+ \ No newline at end of file