From cdf3dfae82acf2dde5db1adb3b87c642a894d4d4 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 12 Apr 2014 07:33:42 +0200 Subject: Make the error templates path configurable --- system/core/Exceptions.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 041869641..398459d54 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -44,6 +44,13 @@ class CI_Exceptions { */ public $ob_level; + /** + * Path to the error templates + * + * @var string + */ + protected $_templates_path; + /** * List if available error levels * @@ -73,6 +80,12 @@ class CI_Exceptions { { $this->ob_level = ob_get_level(); // Note: Do not log messages from this constructor. + + $config =& get_config(); + + $this->_templates_path = (isset($config['error_templates_path']) && $config['error_templates_path'] !== '') + ? $config['error_templates_path'] + : VIEWPATH.'errors'.DIRECTORY_SEPARATOR; } // -------------------------------------------------------------------- @@ -162,7 +175,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include(VIEWPATH.'errors'.DIRECTORY_SEPARATOR.$template.'.php'); + include($this->_templates_path.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; @@ -205,7 +218,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include(VIEWPATH.'errors'.DIRECTORY_SEPARATOR.$template.'.php'); + include($this->_templates_path.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; -- cgit v1.2.3-24-g4f1b From 511a6b8eb67e34820c1b9446cfc8891b52df90c7 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 14 Apr 2014 14:33:55 +0200 Subject: Rename config item "error_templates_path" to "error_views_path" --- system/core/Exceptions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 398459d54..0c247f916 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -83,8 +83,8 @@ class CI_Exceptions { $config =& get_config(); - $this->_templates_path = (isset($config['error_templates_path']) && $config['error_templates_path'] !== '') - ? $config['error_templates_path'] + $this->_templates_path = (isset($config['error_views_path']) && $config['error_views_path'] !== '') + ? $config['error_views_path'] : VIEWPATH.'errors'.DIRECTORY_SEPARATOR; } -- cgit v1.2.3-24-g4f1b From 08ea83bb19146eab8e792acc35f02f6e8d055894 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 14 Apr 2014 14:34:06 +0200 Subject: Different method for handling "error_views_path" config item --- system/core/Exceptions.php | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'system') diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 0c247f916..5bcb7c1c5 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -44,13 +44,6 @@ class CI_Exceptions { */ public $ob_level; - /** - * Path to the error templates - * - * @var string - */ - protected $_templates_path; - /** * List if available error levels * @@ -80,12 +73,6 @@ class CI_Exceptions { { $this->ob_level = ob_get_level(); // Note: Do not log messages from this constructor. - - $config =& get_config(); - - $this->_templates_path = (isset($config['error_views_path']) && $config['error_views_path'] !== '') - ? $config['error_views_path'] - : VIEWPATH.'errors'.DIRECTORY_SEPARATOR; } // -------------------------------------------------------------------- @@ -158,6 +145,10 @@ class CI_Exceptions { */ public function show_error($heading, $message, $template = 'error_general', $status_code = 500) { + $templates_path = config_item('error_views_path') + ? config_item('error_views_path') + : VIEWPATH.'errors'.DIRECTORY_SEPARATOR; + if (is_cli()) { $message = "\t".(is_array($message) ? implode("\n\t", $message) : $message); @@ -175,7 +166,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include($this->_templates_path.$template.'.php'); + include($templates_path.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; @@ -194,6 +185,10 @@ class CI_Exceptions { */ public function show_php_error($severity, $message, $filepath, $line) { + $templates_path = config_item('error_views_path') + ? config_item('error_views_path') + : VIEWPATH.'errors'.DIRECTORY_SEPARATOR; + $severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity; // For safety reasons we don't show the full file path in non-CLI requests @@ -218,7 +213,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include($this->_templates_path.$template.'.php'); + include($templates_path.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; -- cgit v1.2.3-24-g4f1b