summaryrefslogtreecommitdiff
path: root/it_text.class
diff options
context:
space:
mode:
authorUrban Müller2008-05-06 12:28:00 +0000
committerUrban Müller2008-05-06 12:28:00 +0000
commitaaa330cc11e7eb161b913ff62476a9f4d51c1e27 (patch)
treec1a80be03ea056e0bdb056706c6f4d7dbe53c142 /it_text.class
parent4ea3e83bc27a94d23add12bf4ce38669456fd730 (diff)
downloaditools-aaa330cc11e7eb161b913ff62476a9f4d51c1e27.tar.gz
itools-aaa330cc11e7eb161b913ff62476a9f4d51c1e27.tar.bz2
itools-aaa330cc11e7eb161b913ff62476a9f4d51c1e27.zip
support nonglobal it_text for editor, remove lang cookie support
Diffstat (limited to 'it_text.class')
-rw-r--r--it_text.class33
1 files changed, 11 insertions, 22 deletions
diff --git a/it_text.class b/it_text.class
index 593659d..901f51a 100644
--- a/it_text.class
+++ b/it_text.class
@@ -35,11 +35,12 @@ class it_text
* @param $p['debug'] optional debug mode: display label of unknown texts, set to 'label' to always display labels instead of actual text
* @param $p['fallbacklanguage'] optional language to use for undefined texts (useful for partially translated projects)
* @param $p['forcelanguage'] optional language to use instead of user's preferred language
+ * @param $p['global'] store text object in global it_text for global functions (default: true)
* @param $p['phpfile'] optional texts file(s), default: all texts.php in include path
*/
-function it_text($p = null)
+function it_text($p = array())
{
- $this->p = (array)$p + array('cookiename' => 'LANGUAGE', 'debug' => (EDC('label') ? "label" : ""));
+ $this->p = $p + array('cookiename' => 'LANGUAGE', 'debug' => (EDC('label') ? "label" : ""), 'global' => true);
$phpfiles = array();
if ($p['phpfile'])
@@ -89,10 +90,12 @@ function it_text($p = null)
$this->initlang($this->p['forcelanguage'], "setting language from programmer override");
# Make this object available under $GLOBALS['it_text'], or add my texts to $GLOBALS['it_text'] if it exists
- if (!$GLOBALS['it_text'])
- $GLOBALS['it_text'] =& $this;
- else
- $GLOBALS['it_text']->statictext += $this->statictext;
+ if ($this->p['global']) {
+ if (!$GLOBALS['it_text'])
+ $GLOBALS['it_text'] =& $this;
+ else
+ $GLOBALS['it_text']->statictext += $this->statictext;
+ }
}
@@ -155,23 +158,9 @@ function etext($label, $values = null, $language = null)
/**
* INTERNAL function for T_set_language()
*/
-function set_language($language, $setcookie = true)
+function set_language($language)
{
- # If $language is unknown, delete the cookie
- if ($this->languages_available[$language])
- {
- if (!$this->languages[$language])
- debug('Selected an existing but currently disabled language!', 6);
- $this->actlanguage = $language;
- if ($setcookie)
- SetCookie($this->p['cookiename'], $this->actlanguage, time() + 31536000, '/'); # 1 year
- }
- else
- {
- $this->actlanguage = $this->defaultlanguage;
- if ($setcookie)
- SetCookie($this->p['cookiename'], '', time() + 31536000, '/');
- }
+ $this->actlanguage = $this->languages_available[$language] ? $language : $this->defaultlanguage;
}