diff options
author | Andrey Andreev <narf@devilix.net> | 2014-04-14 15:02:17 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-04-14 15:02:17 +0200 |
commit | db0873365aabce72390fe9ccf19081de143a1d51 (patch) | |
tree | 8368a786a4c9c7ffb57596abf66d8b80fde73c66 | |
parent | 72daa197768f5ff86e009ff7afc171da21adc8db (diff) | |
parent | 787fe1384287ff3a2360815036e70a9a79c714da (diff) |
Merge pull request #2999 from vlakoff/error-templates
Make the error templates path configurable
-rw-r--r-- | application/config/config.php | 15 | ||||
-rw-r--r-- | system/core/Exceptions.php | 12 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 3 | ||||
-rw-r--r-- | user_guide_src/source/general/managing_apps.rst | 2 | ||||
-rw-r--r-- | user_guide_src/source/helpers/smiley_helper.rst | 2 |
5 files changed, 26 insertions, 8 deletions
diff --git a/application/config/config.php b/application/config/config.php index ae89715c0..ba6867fb7 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -223,7 +223,7 @@ $config['log_threshold'] = 0; |-------------------------------------------------------------------------- | | Leave this BLANK unless you would like to set something other than the default -| application/logs/ folder. Use a full server path with trailing slash. +| application/logs/ directory. Use a full server path with trailing slash. | */ $config['log_path'] = ''; @@ -255,11 +255,22 @@ $config['log_date_format'] = 'Y-m-d H:i:s'; /* |-------------------------------------------------------------------------- +| Error Views Directory Path +|-------------------------------------------------------------------------- +| +| Leave this BLANK unless you would like to set something other than the default +| application/views/errors/ directory. Use a full server path with trailing slash. +| +*/ +$config['error_views_path'] = ''; + +/* +|-------------------------------------------------------------------------- | Cache Directory Path |-------------------------------------------------------------------------- | | Leave this BLANK unless you would like to set something other than the default -| application/cache/ folder. Use a full server path with trailing slash. +| application/cache/ directory. Use a full server path with trailing slash. | */ $config['cache_path'] = ''; diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 041869641..5bcb7c1c5 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -145,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); @@ -162,7 +166,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include(VIEWPATH.'errors'.DIRECTORY_SEPARATOR.$template.'.php'); + include($templates_path.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; @@ -181,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 @@ -205,7 +213,7 @@ class CI_Exceptions { ob_end_flush(); } ob_start(); - include(VIEWPATH.'errors'.DIRECTORY_SEPARATOR.$template.'.php'); + include($templates_path.$template.'.php'); $buffer = ob_get_contents(); ob_end_clean(); echo $buffer; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 9d3ceb08e..a4669773f 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -48,6 +48,8 @@ Release Date: Not Released - Removed previously deprecated EXT constant. - Updated all classes to be written in PHP 5 style, with visibility declarations and no ``var`` usage for properties. - Moved error templates to *application/views/errors/*. + - Added support non-HTML error templates for CLI applications. + - Made error templates path configurable using ``$config['error_views_path']``. - Moved the Log class to *application/core/* - Global config files are loaded first, then environment ones. Environment config keys overwrite base ones, allowing to only set the keys we want changed per environment. - Changed detection of ``$view_folder`` so that if it's not found in the current path, it will now also be searched for under the application folder. @@ -56,7 +58,6 @@ Release Date: Not Released - Changed environment defaults to report all errors in *development* and only fatal ones in *testing*, *production* but only display them in *development*. - Updated *ip_address* database field lengths from 16 to 45 for supporting IPv6 address on :doc:`Trackback Library <libraries/trackback>` and :doc:`Captcha Helper <helpers/captcha_helper>`. - Removed *cheatsheets* and *quick_reference* PDFs from the documentation. - - Added support non-HTML error templates for CLI applications. - Added availability checks where usage of dangerous functions like ``eval()`` and ``exec()`` is required. - Added support for changing the file extension of log files using ``$config['log_file_extension']``. - Added support for turning newline standardization on/off via ``$config['standardize_newlines']``. diff --git a/user_guide_src/source/general/managing_apps.rst b/user_guide_src/source/general/managing_apps.rst index 3ca0e03a7..4861ba71a 100644 --- a/user_guide_src/source/general/managing_apps.rst +++ b/user_guide_src/source/general/managing_apps.rst @@ -40,14 +40,12 @@ and "bar". You could structure your application directories like this:: applications/foo/ applications/foo/config/ applications/foo/controllers/ - applications/foo/errors/ applications/foo/libraries/ applications/foo/models/ applications/foo/views/ applications/bar/ applications/bar/config/ applications/bar/controllers/ - applications/bar/errors/ applications/bar/libraries/ applications/bar/models/ applications/bar/views/ diff --git a/user_guide_src/source/helpers/smiley_helper.rst b/user_guide_src/source/helpers/smiley_helper.rst index b98084089..e7a5724a8 100644 --- a/user_guide_src/source/helpers/smiley_helper.rst +++ b/user_guide_src/source/helpers/smiley_helper.rst @@ -75,7 +75,7 @@ the :doc:`Table Class <../libraries/table>`:: } -In your **application/views/** folder, create a file called **smiley_view.php** +In your **application/views/** directory, create a file called **smiley_view.php** and place this code in it:: <html> |