summaryrefslogtreecommitdiff
path: root/text.class
diff options
context:
space:
mode:
authorChristian Weber2007-07-13 12:57:16 +0000
committerChristian Weber2007-07-13 12:57:16 +0000
commit638519c5a3d67c721613de3d31a9b4bad0d28a49 (patch)
treec0afbd466d71b759e3d8ff8317c54748ed5d0cc7 /text.class
parentc44032dc17cf20ecd20d92d354ab388e500934a5 (diff)
downloaditools-638519c5a3d67c721613de3d31a9b4bad0d28a49.tar.gz
itools-638519c5a3d67c721613de3d31a9b4bad0d28a49.tar.bz2
itools-638519c5a3d67c721613de3d31a9b4bad0d28a49.zip
Move static function it_text_transmogrify into object, call with it_text::transmogrify()
Diffstat (limited to 'text.class')
-rw-r--r--text.class61
1 files changed, 31 insertions, 30 deletions
diff --git a/text.class b/text.class
index dffe5de..de5e906 100644
--- a/text.class
+++ b/text.class
@@ -142,7 +142,7 @@ function text($label, $raw = null, $language = null)
*/
function etext($label, $values = null, $language = null)
{
- return it_text_transmogrify($this->text($label, null, $language), $values);
+ return $this->transmogrify($this->text($label, null, $language), $values);
}
@@ -218,6 +218,36 @@ function set($label, $text = null, $language = null)
/**
+ * Replaces variables of the form {obj.var} with value, e.g. {user.name}
+ * NOTE: Invalid object names or non-existing variables are simply deleted.
+ */
+function transmogrify($text, $values = null)
+{
+ while (preg_match('/{([\w.]+)}/', $text, $regs))
+ {
+ $path = explode('.', $regs[1]);
+ if ($values)
+ $value =& $values;
+ else
+ $value =& $GLOBALS;
+
+ # Recurse into nested arrays/object members
+ foreach ($path as $key)
+ {
+ if (is_object($value))
+ $value =& $value->$key;
+ else
+ $value =& $value[$key];
+ }
+
+ $text = str_replace($regs[0], $value, $text);
+ }
+
+ return $text;
+}
+
+
+/**
* when running it_text in debug mode, you can use this to die (internal_error)
* in case there were unknown labels with a list of all unknown labels
*/
@@ -337,35 +367,6 @@ function dump_php()
* Globally available functions without need for object
*/
-/**
- * Replaces variables of the form {obj.var} with value, e.g. {user.name}
- * NOTE: Invalid object names or non-existing variables are simply deleted.
- */
-function it_text_transmogrify($text, $values = null)
-{
- while (preg_match('/{([\w.]+)}/', $text, $regs))
- {
- $path = explode('.', $regs[1]);
- if ($values)
- $value =& $values;
- else
- $value =& $GLOBALS;
-
- /* Recurse into nested arrays/object members */
- foreach ($path as $key)
- {
- if (is_object($value))
- $value =& $value->$key;
- else
- $value =& $value[$key];
- }
-
- $text = str_replace($regs[0], $value, $text);
- }
-
- return $text;
-}
-
/*
* Shortcut to $it_text->Text()