From a51545268d9db6ec7667ee33069a09bf77579349 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Mon, 16 Sep 2013 11:28:09 +0400 Subject: [PATCH 1/3] Add CliLogger.generateOutString() for extend this class. --- logger/CliLogger.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/logger/CliLogger.php b/logger/CliLogger.php index 121cda1..ddbc5cc 100644 --- a/logger/CliLogger.php +++ b/logger/CliLogger.php @@ -14,8 +14,13 @@ class CliLogger extends Logger { // Заменяем окончания строк на их символы $message = str_replace(array("\r", "\n"), array('\r', '\n'), $message); - $out = microtime(true) . " \t: " . $this->pid . trim($message) . PHP_EOL; + $out = $this->generateOutString($message); print($out); } + + protected function generateOutString($message) + { + return microtime(true) . " \t: " . $this->pid . trim($message) . PHP_EOL; + } } From 9625b1e7a41200ae764d88b79ff09c65a9b2f457 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Mon, 23 Sep 2013 13:41:04 +0400 Subject: [PATCH 2/3] Extend MsgViewHelper. Add MsgViewHelper.getTypeToClass() --- view/helpers/MsgViewHelper.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/view/helpers/MsgViewHelper.php b/view/helpers/MsgViewHelper.php index 0a2b89f..1283367 100644 --- a/view/helpers/MsgViewHelper.php +++ b/view/helpers/MsgViewHelper.php @@ -18,6 +18,13 @@ class MsgViewHelper extends ViewHelper const WARNING = 'warning'; + private static $type_to_class = array( + self::SUCCESS => 'success', + self::ERROR => 'error', + self::INFO => 'info', + self::WARNING => 'warning', + ); + protected $css_prefix = ''; public function msg($msg = null, $type = null) @@ -67,8 +74,14 @@ class MsgViewHelper extends ViewHelper $msg = Session::get(__CLASS__, false); if ($msg) { Session::del(__CLASS__); - return '
' . $this->view->escape($msg['message']) . '
'; + $type_to_class = static::getTypeToClass(); + return '
' . $this->view->escape($msg['message']) . '
'; } return ''; } + + protected static function getTypeToClass() + { + return self::$type_to_class; + } } \ No newline at end of file From 0fc1884c933be990fd04eea61ae8549599f6af95 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Mon, 23 Sep 2013 17:22:35 +0400 Subject: [PATCH 3/3] Extend Action.redirect() (add new param "permanently" for set header 301 Moved permanently). --- app/Action.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Action.php b/app/Action.php index 1ad7056..36fd258 100644 --- a/app/Action.php +++ b/app/Action.php @@ -39,9 +39,13 @@ abstract class Action * Redirect * * @param mixed $url + * @param bool $permanently */ - protected function redirect($url = null) + protected function redirect($url = null, $permanently = false) { + if ($permanently) { + header('HTTP/1.1 301 Moved Permanently'); + } header('Location: ' . (($url) ? $url : Env::getRequestUri())); exit(); }