From db8e13ec35a455fdbbc43e4cdc400ed147f578ac Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 20 Feb 2014 17:38:32 +0100 Subject: [PATCH] Merging and renaming tags yields status messages Previously, it just redirected back to tag list without any kind of notification about success. --- src/Bootstrap.php | 4 ++-- src/Controllers/TagController.php | 8 ++++---- src/Helpers/StatusHelper.php | 3 +++ src/Views/tag-merge.phtml | 2 ++ src/Views/tag-rename.phtml | 2 ++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 6fa7854f..9e2cb4ce 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -62,14 +62,14 @@ class Bootstrap { if ($e instanceof SimpleNotFoundException) http_response_code(404); - StatusHelper::failure(rtrim($e->getMessage(), '.') . '.'); + StatusHelper::failure($e->getMessage()); if (!$this->context->handleExceptions) $this->context->viewName = 'message'; $this->render(); } catch (Exception $e) { - StatusHelper::failure(rtrim($e->getMessage(), '.') . '.'); + StatusHelper::failure($e->getMessage()); $this->context->transport->exception = $e; $this->context->transport->queries = Database::getLogs(); $this->context->viewName = 'error-exception'; diff --git a/src/Controllers/TagController.php b/src/Controllers/TagController.php index c57118b2..1b95fe34 100644 --- a/src/Controllers/TagController.php +++ b/src/Controllers/TagController.php @@ -47,6 +47,7 @@ class TagController public function mergeAction() { $this->context->viewName = 'tag-list-wrapper'; + $this->context->handleExceptions = true; PrivilegesHelper::confirmWithException(Privilege::MergeTags); if (InputHelper::get('submit')) @@ -61,9 +62,8 @@ class TagController TagModel::merge($suppliedSourceTag, $suppliedTargetTag); - \Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list')); LogHelper::log('{user} merged {source} with {target}', ['source' => TextHelper::reprTag($suppliedSourceTag), 'target' => TextHelper::reprTag($suppliedTargetTag)]); - StatusHelper::success(); + StatusHelper::success('Tags merged successfully.'); } } @@ -73,6 +73,7 @@ class TagController public function renameAction() { $this->context->viewName = 'tag-list-wrapper'; + $this->context->handleExceptions = true; PrivilegesHelper::confirmWithException(Privilege::MergeTags); if (InputHelper::get('submit')) @@ -87,9 +88,8 @@ class TagController TagModel::rename($suppliedSourceTag, $suppliedTargetTag); - \Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list')); LogHelper::log('{user} renamed {source} to {target}', ['source' => TextHelper::reprTag($suppliedSourceTag), 'target' => TextHelper::reprTag($suppliedTargetTag)]); - StatusHelper::success(); + StatusHelper::success('Tag renamed successfully.'); } } diff --git a/src/Helpers/StatusHelper.php b/src/Helpers/StatusHelper.php index 774cae96..59db5964 100644 --- a/src/Helpers/StatusHelper.php +++ b/src/Helpers/StatusHelper.php @@ -6,6 +6,9 @@ class StatusHelper $context = \Chibi\Registry::getContext(); if (!empty($message)) { + if (!preg_match('/[.?!]$/', $message)) + $message .= '.'; + $context->transport->message = $message; $context->transport->messageHtml = TextHelper::parseMarkdown($message, true); } diff --git a/src/Views/tag-merge.phtml b/src/Views/tag-merge.phtml index faebf8ca..9a010fde 100644 --- a/src/Views/tag-merge.phtml +++ b/src/Views/tag-merge.phtml @@ -14,6 +14,8 @@ + renderFile('message') ?> +
diff --git a/src/Views/tag-rename.phtml b/src/Views/tag-rename.phtml index 0f4a4e0b..7307dcef 100644 --- a/src/Views/tag-rename.phtml +++ b/src/Views/tag-rename.phtml @@ -14,6 +14,8 @@ + renderFile('message') ?> +