aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2007-10-08 23:46:09 +0000
committerrvelices <rv-github@modusoptimus.com>2007-10-08 23:46:09 +0000
commit98b07a4a7fa1baff52800f70066f311768904430 (patch)
tree4bc89e8017f5fced16a6de6d4c8b37639caccff8 /include
parent5132cc1f87025bd17d6bd90e5ac8ad73288bf482 (diff)
- some code refactoring before upgrade to utf (only cosmetic at this point...)
git-svn-id: http://piwigo.org/svn/trunk@2126 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/common.inc.php6
-rw-r--r--include/functions.inc.php45
-rw-r--r--include/functions_mail.inc.php20
-rw-r--r--include/page_header.php4
-rw-r--r--include/ws_functions.inc.php5
-rw-r--r--include/ws_protocols/rest_encoder.php2
6 files changed, 59 insertions, 23 deletions
diff --git a/include/common.inc.php b/include/common.inc.php
index ee043642c..18053e3ae 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -155,13 +155,13 @@ include(PHPWG_ROOT_PATH.'include/user.inc.php');
// language files
-include_once(get_language_filepath('common.lang.php'));
+load_language('common.lang');
if (defined('IN_ADMIN') and IN_ADMIN)
{
- include_once(get_language_filepath('admin.lang.php'));
+ load_language('admin.lang');
}
trigger_action('loading_lang');
-@include_once(get_language_filepath('local.lang.php'));
+load_language('local.lang');
// only now we can set the localized username of the guest user (and not in
// include/user.inc.php)
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 50bb81757..4e6b97b02 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -729,9 +729,9 @@ function redirect_html( $url , $msg = '', $refresh_time = 0)
if (!isset($lang_info))
{
$user = build_user( $conf['guest_id'], true);
- include_once(get_language_filepath('common.lang.php'));
+ load_language('common.lang');
trigger_action('loading_lang');
- @include_once(get_language_filepath('local.lang.php'));
+ load_language('local.lang');
list($tmpl, $thm) = explode('/', get_default_template());
$template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
}
@@ -1424,4 +1424,43 @@ function get_filter_page_value($value_name)
}
}
-?>
+/**
+ * returns the character set of data sent to browsers / received from forms
+ */
+function get_pwg_charset()
+{
+ //TEMP CODE
+ global $lang_info;return $lang_info['charset'];
+}
+
+/**
+ * includes a language file or returns the content of a language file
+ * availability of the file
+ *
+ * in descending order of preference:
+ * param language, user language, default language
+ * PhpWebGallery default language.
+ *
+ * @param string filename
+ * @param string dirname
+ * @param string language
+ * @param bool return_content - if true the file content is returned otherwise
+ * the file is evaluated as php
+ * @return boolean success status or a string if return_content is true
+ */
+function load_language($filename, $dirname = '', $language = '',
+ $return_content=false)
+{
+ //TEMP CODE
+ if (!$return_content) $filename.='.php';
+ $f = get_language_filepath($filename, $dirname, $language);
+ if ($f === false)
+ return false;
+ if ($return_content)
+ return @file_get_contents($f);
+ global $lang, $lang_info;
+ @include($f);
+ return true;
+}
+
+?> \ No newline at end of file
diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php
index a20a32797..a0e3110ae 100644
--- a/include/functions_mail.inc.php
+++ b/include/functions_mail.inc.php
@@ -48,7 +48,7 @@ function encode_mime_header($str)
$str = str_replace(" ", "_", $str);
global $lang_info;
- return '=?'.$lang_info['charset'].'?Q?'.$str.'?=';
+ return '=?'.get_pwg_charset().'?Q?'.$str.'?=';
}
/*
@@ -226,12 +226,12 @@ function switch_lang_to($language)
$lang = array();
// language files
- include(get_language_filepath('common.lang.php', '', $language));
+ load_language('common.lang', '', $language);
// No test admin because script is checked admin (user selected no)
// Translations are in admin file too
- include(get_language_filepath('admin.lang.php', '', $language));
+ load_language('admin.lang', '', $language);
trigger_action('loading_lang');
- @include(get_language_filepath('local.lang.php', '', $language));
+ load_language('local.lang', '', $language);
$switch_lang[$language]['lang_info'] = $lang_info;
$switch_lang[$language]['lang'] = $lang;
@@ -588,7 +588,7 @@ function pwg_mail($to, $args = array())
$content = '';
- if (!isset($conf_mail[$args['email_format']][$lang_info['charset']][$args['template']][$args['theme']]))
+ if (!isset($conf_mail[$args['email_format']][get_pwg_charset()][$args['template']][$args['theme']]))
{
if (!isset($mail_template))
{
@@ -603,7 +603,7 @@ function pwg_mail($to, $args = array())
//Header
'BOUNDARY_KEY' => $conf_mail['boundary_key'],
'CONTENT_TYPE' => $args['email_format'],
- 'CONTENT_ENCODING' => $lang_info['charset'],
+ 'CONTENT_ENCODING' => get_pwg_charset(),
'LANG' => $lang_info['code'],
'DIR' => $lang_info['direction'],
@@ -650,20 +650,20 @@ function pwg_mail($to, $args = array())
// what are displayed on the header of each mail ?
$conf_mail[$args['email_format']]
- [$lang_info['charset']]
+ [get_pwg_charset()]
[$args['template']][$args['theme']]['header'] =
$mail_template->parse('mail_header', true);
// what are displayed on the footer of each mail ?
$conf_mail[$args['email_format']]
- [$lang_info['charset']]
+ [get_pwg_charset()]
[$args['template']][$args['theme']]['footer'] =
$mail_template->parse('mail_footer', true);
}
// Header
$content.= $conf_mail[$args['email_format']]
- [$lang_info['charset']]
+ [get_pwg_charset()]
[$args['template']][$args['theme']]['header'];
// Content
@@ -683,7 +683,7 @@ function pwg_mail($to, $args = array())
// Footer
$content.= $conf_mail[$args['email_format']]
- [$lang_info['charset']]
+ [get_pwg_charset()]
[$args['template']][$args['theme']]['footer'];
// Close boundary
diff --git a/include/page_header.php b/include/page_header.php
index 0dea51a33..0ce9281e2 100644
--- a/include/page_header.php
+++ b/include/page_header.php
@@ -46,7 +46,7 @@ $template->assign_vars(
isset($page['body_id']) ?
$page['body_id'] : '',
- 'CONTENT_ENCODING' => $lang_info['charset'],
+ 'CONTENT_ENCODING' => get_pwg_charset(),
'PAGE_TITLE' => strip_tags($title),
'LANG'=>$lang_info['code'],
'DIR'=>$lang_info['direction'],
@@ -99,7 +99,7 @@ if ( isset( $refresh ) and intval($refresh) >= 0
trigger_action('loc_end_page_header');
-header('Content-Type: text/html; charset='.$lang_info['charset']);
+header('Content-Type: text/html; charset='.get_pwg_charset());
$template->parse('header');
trigger_action('loc_after_page_header');
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index c0b3585db..808f45644 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -910,10 +910,7 @@ function ws_session_getStatus($params, &$service)
{
$res[$k] = $user[$k];
}
- foreach ( array('charset') as $k )
- {
- $res[$k] = $lang_info[$k];
- }
+ $res['charset'] = get_pwg_charset();
return $res;
}
diff --git a/include/ws_protocols/rest_encoder.php b/include/ws_protocols/rest_encoder.php
index 9352e5644..e02af55bb 100644
--- a/include/ws_protocols/rest_encoder.php
+++ b/include/ws_protocols/rest_encoder.php
@@ -168,7 +168,7 @@ class PwgRestEncoder extends PwgResponseEncoder
$this->_writer = new PwgXmlWriter();
$this->encode($response);
$ret = $this->_writer->getOutput();
- $ret = '<?xml version="1.0" encoding="'.$lang_info['charset'].'" ?>
+ $ret = '<?xml version="1.0" encoding="'.get_pwg_charset().'" ?>
<rsp stat="ok">
'.$ret.'
</rsp>';