diff options
author | Christian Schneider | 2007-10-11 00:39:30 +0000 |
---|---|---|
committer | Christian Schneider | 2007-10-11 00:39:30 +0000 |
commit | 35fe33f7364329dacf415c950bff01b6de9ef88e (patch) | |
tree | b0e6b018b50038ca20266723c53750268f508df5 /auto_prepend.php | |
parent | 1f95711ff3e9697cd85a54545ab42e5fd3611317 (diff) | |
download | itools-35fe33f7364329dacf415c950bff01b6de9ef88e.tar.gz itools-35fe33f7364329dacf415c950bff01b6de9ef88e.tar.bz2 itools-35fe33f7364329dacf415c950bff01b6de9ef88e.zip |
Populated release branch
Diffstat (limited to 'auto_prepend.php')
-rw-r--r-- | auto_prepend.php | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/auto_prepend.php b/auto_prepend.php new file mode 100644 index 0000000..b27d6e3 --- /dev/null +++ b/auto_prepend.php @@ -0,0 +1,152 @@ +<?php + +/** + * Print an error message and end page + */ +function fail($text) +{ + trigger_error($text, E_USER_ERROR); + it::fatal($text); +} + +/** + * Global shortcut for $it_debug::debug() + * @see it_debug + */ +function debug($text, $level=0) +{ + if (isset($GLOBALS['it_debug'])) + $GLOBALS['it_debug']->debug($text, $level); +} + +/** + * Convert a htmlentities-encoded string back to normal + */ +function it_htmlentities_decode($string) +{ + return strtr($string, array_flip(get_html_translation_table(HTML_ENTITIES))); +} + +/** + * Clone an object and return copy, works for all PHP versions + */ +function &it_clone(&$object) +{ + $result = (is_object($object) && version_compare(zend_version(), 2, '>=')) ? clone($object) : $object; + return $result; # PHP internals need a tmp var to return by ref +} + +/** + * Return string containing names and values of all arguments + */ +function D() +{ + $args = func_get_args(); + return it_debug::dump($args); +} + +/** + * Echo string containing names and values of all arguments + */ +function ED() +{ + $args = func_get_args(); + echo it_debug::dump($args); + return $args[0]; +} + +/** + * Same as ED(), but if first argument is foo then $GLOBALS['debug_foo'] must be set for output + * @return boolean indicating whether $GLOBALS['debug_foo'] was set + */ +function EDC() +{ + $args = func_get_args(); + $var = array_shift($args); + $GLOBALS['ULTRADEBUGVARS'][$var] = 1; + + if (($result = $GLOBALS["debug_$var"]) && $args) + echo it_debug::dump($args); + + if (!$result || $result === true) # Compatibility with old map relying on 0|1 + $result = intval($result); + + return $result; +} + +/** + * Echo string containing names and values of all arguments, then exit + */ +function EDX() +{ + $args = func_get_args(); + exit(it_debug::dump($args)); +} + +/** + * Return a text in the selected language + * @param $label Label of text to return + * @param $language Optional language to return text in + * @return Localized text string + */ +function T($label, $language = null, $dummy = false) +{ + it_text::init(); + return $GLOBALS['it_text']->text($label, $language, $dummy); +} + +/** + * Return a text in the selected language + * Replaces variables of the form {var} with value from argument $values + * @param $label Label of text to return + * @param $values Associative array containing values to fill in + * @param $language Optional language to return text in. + * @return Localized text string with variables replaced by their values + */ +function ET($label, $values = null, $language = null) +{ + it_text::init(); + return $GLOBALS['it_text']->etext($label, $values, $language); +} + +/** + * Change language + * @param $language New language to set + * @param $setcookie Optional flag if a cookie is to be set (default: true) + */ +function T_set_language($language, $setcookie = true) +{ + it_text::init(); + return $GLOBALS['it_text']->set_language($language, $setcookie); +} + +/** + * Get active language + * @return currently active language + */ +function T_lang() +{ + it_text::init(); + return $GLOBALS['it_text']->get_language(); +} + +/** + * Check if a text entry for a specific label exists + * @param $label Label to check + * @return true if text exists in actual (or supplied) language, false otherwise. + */ +function T_exists($label, $language = null) +{ + it_text::init(); + return $GLOBALS['it_text']->text_exists($label, $language); +} + +/** + * Return "db4" or "db2" depending on availability + */ +function db_version() +{ + return in_array("db4", dba_handlers()) ? "db4" : "db2"; +} + +?> |