From 8f61176da8e3f215cec70b3320c956d3e3ace73f Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 18 Jul 2007 11:58:42 +0000 Subject: compatibility with auto-startup, some cleanups --- text.class | 61 ++++++++++++++----------------------------------------------- 1 file changed, 14 insertions(+), 47 deletions(-) (limited to 'text.class') diff --git a/text.class b/text.class index de5e906..d96fb74 100644 --- a/text.class +++ b/text.class @@ -104,9 +104,23 @@ function it_text($p = null) # And finally, record the name of our active language. $this->actlanguagename = $this->languages[$this->actlanguage]; + # 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; + debug("Used language is {$this->actlanguagename}, default language is {$this->defaultlanguage}.", 6); } +/** + * Instanciate singleton if necessary + */ +function init() +{ + if (!$GLOBALS['it_text']) + new it_text; +} /** * Return a text in the selected language. @@ -361,51 +375,4 @@ function dump_php() } } /* End class it_text */ - - -/* - * Globally available functions without need for object - */ - - -/* - * Shortcut to $it_text->Text() - */ -function T($label, $raw = null, $language = null) -{ - return $GLOBALS['it_text']->text($label, $raw, $language); -} - - -/* - * Shortcut to $it_text->etext() - */ -function ET($label, $values = null, $language = null) -{ - return $GLOBALS['it_text']->etext($label, $values, $language); -} - -/** - * Shortcut to $it_text->get_language() - */ -function T_lang() -{ - return isset($GLOBALS['it_text']) ? $GLOBALS['it_text']->get_language() : "de"; -} - -/** - * Shortcut to $it_text->get_language() - */ -function T_set_language($language, $setcookie = true) -{ - return $GLOBALS['it_text']->set_language($language, $setcookie); -} - -/** - * Shortcut to $it_text->text_exists() - */ -function T_exists($label, $language = null) -{ - return $GLOBALS['it_text']->text_exists($label, $language); -} ?> -- cgit v1.2.3