From: stekkel Date: Sat, 28 Jan 2006 16:00:54 +0000 (+0000) Subject: * template set selection support X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7442e064f52840d6142548c382112faeb94c713d;p=squirrelmail.git * template set selection support * added init section to validate.php (can be moved out at a later stage when we have sm_init) which takes care of starting the error handler and creation of the template object git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@10580 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/include/load_prefs.php b/include/load_prefs.php index 9b9b106a..73939210 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -13,9 +13,10 @@ */ /** SquirrelMail required files. */ -require_once(SM_PATH . 'include/validate.php'); -require_once(SM_PATH . 'functions/plugin.php'); -require_once(SM_PATH . 'functions/constants.php'); +include_once(SM_PATH . 'functions/constants.php'); +include_once(SM_PATH . 'include/validate.php'); +include_once(SM_PATH . 'functions/plugin.php'); + if( ! sqgetGlobalVar('username', $username, SQ_SESSION) ) { $username = ''; @@ -25,8 +26,33 @@ $custom_css = getPref($data_dir, $username, 'custom_css', 'none' ); $theme = ( !isset($theme) ? array() : $theme ); $color = ( !isset($color) ? array() : $color ); +$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet ); $chosen_theme = getPref($data_dir, $username, 'chosen_theme'); +$sTplDir = getPref($data_dir, $username, 'sTplDir'); + +$found_templateset = false; + +/* need to adjust $chosen_template path with SM_PATH */ +$sTplDir = preg_replace("/(\.\.\/){1,}/", SM_PATH, $sTplDir); + +for ($i = 0; $i < count($aTemplateSet); ++$i){ + if ($aTemplateSet[$i]['PATH'] == $sTplDir) { + $found_templateset = true; + break; + } +} +$sTplDir = ($found_templateset ? $sTplDir : ''); +if (!$found_templateset) { + if (isset($aTemplateSet) && isset($aTemlateSet[$templateset_default]) && file_exists($aTemplateSet[$templateset_default]['PATH'])) { + $sTplDir = $aTemplateSet[$templateset_default]['PATH']; + } else { + $sTplDir = SM_PATH.'templates/default/'; + } +} else if (!file_exists($sTplDir)) { + $sTplDir = SM_PATH.'templates/default/'; +} + $found_theme = false; /* need to adjust $chosen_theme path with SM_PATH */ @@ -40,6 +66,7 @@ for ($i = 0; $i < count($theme); ++$i){ } $chosen_theme = (!$found_theme ? '' : $chosen_theme); + /** * This theme as a failsafe if no themes were found. It makes * no sense to cause the whole thing to exit just because themes diff --git a/include/validate.php b/include/validate.php index 7e831bd5..9f47fb05 100644 --- a/include/validate.php +++ b/include/validate.php @@ -38,10 +38,9 @@ unset($theme); $theme=array(); /* SquirrelMail required files. */ -require_once(SM_PATH . 'class/mime.class.php'); -require_once(SM_PATH . 'functions/global.php'); -require_once(SM_PATH . 'functions/strings.php'); -require_once(SM_PATH . 'config/config.php'); +include_once(SM_PATH . 'class/mime.class.php'); +include_once(SM_PATH . 'functions/global.php'); +include_once(SM_PATH . 'functions/strings.php'); /* set the name of the session cookie */ if(isset($session_name) && $session_name) { @@ -52,8 +51,8 @@ if(isset($session_name) && $session_name) { sqsession_is_active(); -require_once(SM_PATH . 'functions/i18n.php'); -require_once(SM_PATH . 'functions/auth.php'); +include_once(SM_PATH . 'functions/i18n.php'); +include_once(SM_PATH . 'functions/auth.php'); is_logged_in(); @@ -79,9 +78,10 @@ if (isset($send) } } -require_once(SM_PATH . 'include/load_prefs.php'); -require_once(SM_PATH . 'functions/page_header.php'); -require_once(SM_PATH . 'functions/prefs.php'); +include_once(SM_PATH . 'functions/page_header.php'); +include_once(SM_PATH . 'functions/prefs.php'); +include_once(SM_PATH . 'config/config.php'); +include_once(SM_PATH . 'include/load_prefs.php'); /* Set up the language (i18n.php was included by auth.php). */ global $username, $data_dir; @@ -103,7 +103,7 @@ if ( $timeZone != SMPREF_NONE && ($timeZone != "") && $tzChangeAllowed ) { // get time zone key, if strict or custom strict timezones are used - if (isset($time_zone_type) && + if (isset($time_zone_type) && ($time_zone_type == 1 || $time_zone_type == 3)) { /* load time zone functions */ require_once(SM_PATH . 'include/timezones.php'); @@ -118,4 +118,27 @@ if ( $timeZone != SMPREF_NONE && ($timeZone != "") } } +/* temporary sm_init section */ + +include_once(SM_PATH . 'class/template/template.class.php'); +include_once(SM_PATH . 'class/error.class.php'); +/* + * Initialize the template object + */ +$oTemplate = new Template($sTplDir); + +/* + * Initialize our custom error handler object + */ +$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl'); + +/* + * Activate custom error handling + */ +if (version_compare(PHP_VERSION, "4.3.0", ">=")) { + $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler')); +} else { + $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler'); +} + ?> \ No newline at end of file