From f85b1d20408bece77abc1c5d63b92f97a2762c2c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 30 May 2014 20:23:58 +1200 Subject: [PATCH] sample refactor CMS code out of core --- CRM/Core/Error.php | 14 +------------- CRM/Utils/System/Base.php | 8 ++++++++ CRM/Utils/System/Joomla.php | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index a1c196578d..f11d4ba618 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -385,19 +385,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { CRM_Core_Error::debug_var('Fatal Error Details', $vars); CRM_Core_Error::backtrace('backTrace', TRUE); - $content = $template->fetch($config->fatalErrorTemplate); - // JErrorPage exists only in 3.x and not 2.x - // CRM-13714 - if ($config->userFramework == 'Joomla' && class_exists('JErrorPage')) { - $error = new Exception($content); - JErrorPage::render($error); - } - else if ($config->userFramework == 'Joomla' && class_exists('JError')) { - JError::raiseError('CiviCRM-001', $content); - } - else { - echo CRM_Utils_System::theme($content); - } + $config->userSystem->outputError($template->fetch($config->fatalErrorTemplate)); self::abend(CRM_Core_Error::FATAL_ERROR); } diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 1aa78eb0bb..b6091a5cde 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -312,5 +312,13 @@ abstract class CRM_Utils_System_Base { function checkPermissionAddUser() { return FALSE; } + + /** + * output code from error function + * @param string $content + */ + function outputError($content) { + echo CRM_Utils_System::theme($content); + } } diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index e7d8a4765b..613cb5d5a9 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -826,5 +826,22 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { return TRUE; } } + + /** + * output code from error function + * @param string $content + */ + function outputError($content) { + if (class_exists('JErrorPage')) { + $error = new Exception($content); + JErrorPage::render($error); + } + else if (class_exists('JError')) { + JError::raiseError('CiviCRM-001', $content); + } + else { + parent::outputError($content); + } + } } -- 2.25.1