*/
var $template_engine = '';
+ /**
+ * The content type for this template set
+ */
+ var $content_type = '';
+
/**
* The fall-back template ID
*
= Template::calculate_template_file_directory($this->fallback_template_set_id);
+ // determine content type, defaulting to text/html
+ //
+ $this->content_type = Template::get_template_config($this->template_set_id,
+ 'content_type',
+ 'text/html');
+
+
// determine template engine
// FIXME: assuming PHP template engine may not necessarily be a good thing
//
}
+ /**
+ * Return the content-type for this template set.
+ *
+ * @return string The content-type.
+ *
+ */
+ function get_content_type() {
+
+ return $this->content_type;
+
+ }
+
/**
* Get template set config setting
*
* recommendations and switch to unicode.
*/
$header_tags .= "<!-- \xfd\xfe -->\n";
- $header_tags .= '<meta http-equiv="Content-type" content="text/html; charset=euc-jp" />' . "\n";
+ $header_tags .= '<meta http-equiv="Content-type" content="' . $oTemplate->get_content_type() . '; charset=euc-jp" />' . "\n";
}
if ($do_hook) {
// NOTE! plugins here MUST assign output to template
* the current user is NOT that user, turn them
* back on
*/
-sqgetGlobalVar('username',$username,SQ_SESSION);
+sqgetGlobalVar('username', $username, SQ_SESSION);
if ($disable_plugins && !empty($disable_plugins_user)
&& $username != $disable_plugins_user) {
$disable_plugins = false;
* Do something special for some pages. This is based on the PAGE_NAME constant
* set at the top of every page.
*/
+$set_up_langage_after_template_setup = FALSE;
switch (PAGE_NAME) {
case 'style':
}
// /dont understand
- /**
- * Set up the language.
- */
- $err=set_up_language(getPref($data_dir, $username, 'language'));
-
- // Japanese translation used without mbstring support
- if ($err==2) {
- $sError = "<p>Your administrator needs to have PHP installed with the multibyte string extension enabled (using configure option --enable-mbstring).</p>\n"
- . "<p>This system has assumed that you accidently switched to Japanese and has reverted your language preference to English.</p>\n"
- . "<p>Please refresh this page in order to continue using your webmail.</p>\n";
- error_box($sError);
- }
+ $set_up_langage_after_template_setup = TRUE;
$timeZone = getPref($data_dir, $username, 'timezone');
$nbsp = $oTemplate->fetch('non_breaking_space.tpl');
$br = $oTemplate->fetch('line_break.tpl');
+
+/**
+ * Set up the language.
+ *
+ * This code block corresponds to the *default* block of the switch
+ * statement above, but the language cannot be set up until after the
+ * template is instantiated, so we set $set_up_langage_after_template_setup
+ * above and do the linguistic stuff now.
+ */
+if ($set_up_langage_after_template_setup) {
+ $err=set_up_language(getPref($data_dir, $username, 'language'));
+
+ // Japanese translation used without mbstring support
+ if ($err==2) {
+ $sError = "<p>Your administrator needs to have PHP installed with the multibyte string extension enabled (using configure option --enable-mbstring).</p>\n"
+ . "<p>This system has assumed that you accidently switched to Japanese and has reverted your language preference to English.</p>\n"
+ . "<p>Please refresh this page in order to continue using your webmail.</p>\n";
+ error_box($sError);
+ }
+}
+
+
/**
* Initialize our custom error handler object
*/
$oErrorHandler = new ErrorHandler($oTemplate,'error_message.tpl');
+
/**
* Activate custom error handling
*/
* 1 = mbstring support is not present,
* 2 = mbstring support is not present, user's translation reverted to en_US.
*
- * @param string $sm_language translation used by user's interface
- * @param bool $do_search use browser's preferred language detection functions. Defaults to false.
- * @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false.
+ * @param string $sm_language Translation used by user's interface
+ * @param bool $do_search Use browser's preferred language detection functions.
+ * Defaults to false.
+ * @param bool $default Set $sm_language to $squirrelmail_default_language if
+ * language detection fails or language is not set.
+ * Defaults to false.
+ * @param string $content_type The content type being served currently (OPTIONAL;
+ * if not specified, defaults to whatever the template
+ * set that is in use has defined).
+ *
* @return int function execution error codes.
+ *
*/
-function set_up_language($sm_language, $do_search = false, $default = false) {
+function set_up_language($sm_language, $do_search=false,
+ $default=false, $content_type='') {
static $SetupAlready = 0;
- global $use_gettext, $languages,
+ global $use_gettext, $languages, $oTemplate,
$squirrelmail_language, $squirrelmail_default_language, $default_charset,
$sm_notAlias, $username, $data_dir;
$SetupAlready = TRUE;
sqgetGlobalVar('HTTP_ACCEPT_LANGUAGE', $accept_lang, SQ_SERVER);
+ // grab content type if needed
+ //
+ if (empty($content_type)) $content_type = $oTemplate->get_content_type();
+
/**
* If function is asked to detect preferred language
* OR squirrelmail default language is set to empty string
$squirrelmail_language = $sm_notAlias;
if ($squirrelmail_language == 'ja_JP') {
- header ('Content-Type: text/html; charset=EUC-JP');
+ $oTemplate->header ('Content-Type: ' . $content_type . '; charset=EUC-JP');
if (!function_exists('mb_internal_encoding')) {
// Error messages can't be displayed here
$error = 1;
mb_internal_encoding('EUC-JP');
mb_http_output('pass');
} elseif ($squirrelmail_language == 'en_US') {
- header( 'Content-Type: text/html; charset=' . $default_charset );
+ $oTemplate->header( 'Content-Type: ' . $content_type . '; charset=' . $default_charset );
} else {
- header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] );
+ $oTemplate->header( 'Content-Type: ' . $content_type . '; charset=' . $languages[$sm_notAlias]['CHARSET'] );
}
/**
* mbstring.func_overload fix (#929644).
$template_engine = SQ_PHP_TEMPLATE;
+/**
+ * Indicates what the content type is for this template set.
+ */
+$content_type = 'text/html';
+
+
/**
* If non-empty, indicates which template set this set is derived from.
*
$template_engine = SQ_PHP_TEMPLATE;
+/**
+ * Indicates what the content type is for this template set.
+ */
+$content_type = 'text/html';
+
+
/**
* If non-empty, indicates which template set this set is derived from.
*