From 0405634b4f18c0fe195a777b8b8706a2c865026f Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 12 Nov 2007 15:36:44 +0000 Subject: use first it_texts in path, remove third text() param --- it_text.class | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/it_text.class b/it_text.class index bab512e..2167f4e 100644 --- a/it_text.class +++ b/it_text.class @@ -29,15 +29,21 @@ class it_text /** * Constructor + * Example it_texts.php: array('en'=>"English", 'de'=>"Deutsch"), 'edit'=>array('en'=>"Edit", 'de'=>("Editieren"))); * @param $p['cookiename'] optional cookie name (default: 'LANGUAGE') * @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['phpfile'] optional texts file, defaults to service's phpinclude/texts.php + * @param $p['phpfile'] optional texts file, defaults to first it_texts.php in include path */ function it_text($p = null) { - $this->p = (array)$p + array('cookiename' => 'LANGUAGE', 'debug' => false, 'phpfile' => $GLOBALS['ULTRAHOME'] . '/phpinclude/texts.php'); + # Find it_texts.php in path (abs path in case we need to save) + foreach (explode(":", ini_get('include_path')) as $dir) + if (file_exists($phpfile = "$dir/it_texts.php") || file_exists($phpfile = "$dir/texts.php")) + break; + + $this->p = (array)$p + array('cookiename' => 'LANGUAGE', 'phpfile' => $phpfile, 'debug' => (EDC('label') ? "label" : "")); # Read $this->statictext from php file if it's not defined yet if (!$this->statictext) @@ -102,11 +108,8 @@ function init() /** * INTERNAL function for T(): : Return translated text in the selected language */ -function text($label, $language = null, $buggy = false) +function text($label, $language = null) { - if ($buggy || (isset($language) && !is_string($language))) - it::error('deprecated usage of it_text::text()'); - if ($this->p['debug'] === 'label') return $label; -- cgit v1.2.3