From 6c3439acf9b31c14f5f72c59aa77b7ee5df94881 Mon Sep 17 00:00:00 2001 From: slawkens Date: Wed, 11 Oct 2017 15:24:54 +0200 Subject: [PATCH] * check if plugin exist before uninstalling * fixed some bug when you uninstall and then try to install again on the same page * moved some characters.frags code to twig template --- system/pages/admin/plugins.php | 36 +++++++++++-------- system/pages/characters.php | 3 +- system/templates/admin.plugins.form.html.twig | 2 +- system/templates/characters.html.twig | 2 +- system/templates/news.archive.html.twig | 36 +++++++++---------- 5 files changed, 42 insertions(+), 37 deletions(-) diff --git a/system/pages/admin/plugins.php b/system/pages/admin/plugins.php index a420805d..341dd0c7 100644 --- a/system/pages/admin/plugins.php +++ b/system/pages/admin/plugins.php @@ -40,25 +40,31 @@ function deleteDirectory($dir) { if(isset($_REQUEST['uninstall'])){ $uninstall = $_REQUEST['uninstall']; - $string = file_get_contents(BASE . 'plugins/' . $uninstall . '.json'); - $plugin_info = json_decode($string, true); - if($plugin_info == false) { - warning('Cannot load plugin info ' . $uninstall . '.json'); + $filename = BASE . 'plugins/' . $uninstall . '.json'; + if(!file_exists($filename)) { + error('Plugin ' . $uninstall . ' does not exist.'); } else { - $success = true; - foreach($plugin_info['uninstall'] as $file) { - $file = BASE . $file; - if(!deleteDirectory($file)) { - $success = false; - } - } - - if($success) { - success('Successfully uninstalled plugin ' . $uninstall); + $string = file_get_contents($filename); + $plugin_info = json_decode($string, true); + if($plugin_info == false) { + warning('Cannot load plugin info ' . $uninstall . '.json'); } else { - error('Error while uninstalling plugin ' . $uninstall . ': ' . error_get_last()); + $success = true; + foreach($plugin_info['uninstall'] as $file) { + $file = BASE . $file; + if(!deleteDirectory($file)) { + $success = false; + } + } + + if($success) { + success('Successfully uninstalled plugin ' . $uninstall); + } + else { + error('Error while uninstalling plugin ' . $uninstall . ': ' . error_get_last()); + } } } } diff --git a/system/pages/characters.php b/system/pages/characters.php index 4621ee9d..47a70e40 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -335,8 +335,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil foreach($player_frags as $frag) { $description = 'Fragged ' . $frag[name] . ' at level ' . $frag[level]; - $description .= '. ('.(($frag['unjustified'] == 0) ? 'Justified' : 'Unjustified').')'; - $frags[] = array('time' => $frag['date'], 'description' => $description); + $frags[] = array('time' => $frag['date'], 'description' => $description, 'unjustified' => $frag['unjustified'] != 0); } } } diff --git a/system/templates/admin.plugins.form.html.twig b/system/templates/admin.plugins.form.html.twig index 09d43275..75043336 100644 --- a/system/templates/admin.plugins.form.html.twig +++ b/system/templates/admin.plugins.form.html.twig @@ -1,4 +1,4 @@ -
+ diff --git a/system/templates/characters.html.twig b/system/templates/characters.html.twig index f5792656..6af7c7b1 100644 --- a/system/templates/characters.html.twig +++ b/system/templates/characters.html.twig @@ -242,7 +242,7 @@ {% for frag in frags %} - + {% endfor %}
{{ frag.time|date("j M Y, H:i") }}{{ frag.description }}{{ frag.description }}({% if frag.unjustified %}Unjustified{% else %}Justified{% endif %})
diff --git a/system/templates/news.archive.html.twig b/system/templates/news.archive.html.twig index fbb73c16..ee36b05b 100644 --- a/system/templates/news.archive.html.twig +++ b/system/templates/news.archive.html.twig @@ -1,21 +1,21 @@ - - - + + + - {% set i = 0 %} - {% for news in newses %} - {% set i = i + 1 %} - - - - - - {% endfor %} + {% set i = 0 %} + {% for news in newses %} + {% set i = i + 1 %} + + + + + + {% endfor %}
News archive
News archive
-
- -
-
{{ news.date|date('j.n.Y') }} - {{ news.title }} -
+
+ +
+
{{ news.date|date('j.n.Y') }} + {{ news.title }} +
\ No newline at end of file