From: Michael M Slusarz Date: Fri, 3 Sep 2010 23:01:31 +0000 (-0600) Subject: Some Horde:: -> self:: conversions. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ed1c71b8e5182f034c7888036125aa46ea7b1a7e;p=horde.git Some Horde:: -> self:: conversions. --- diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 2519b0a57..9763fd10c 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -743,11 +743,11 @@ HTML; /* If we are not exporting variables located in the configuration * file, or we are not capturing the output, then there is no * need to load the configuration file more than once. */ - Horde::startBuffer(); + self::startBuffer(); $success = (is_null($var_names) && !$show_output) ? include_once $file : include $file; - $output = Horde::endBuffer(); + $output = self::endBuffer(); if (!empty($output) && !$show_output) { /* Horde 3 -> 4 conversion checking. This is the only place @@ -1182,7 +1182,7 @@ HTML; $title = '<pre>' . preg_replace(array('/\n/', '/((?))/em', '/

/', '/
/'), array('', 'str_repeat(" ", strlen("$1"))', '<br /> <br />', '<br />'), nl2br(htmlspecialchars(htmlspecialchars($title, ENT_QUOTES, $charset), ENT_QUOTES, $charset))) . '</pre>'; error_reporting($old_error); - Horde::addScriptFile('tooltips.js', 'horde'); + self::addScriptFile('tooltips.js', 'horde'); } return self::link($url, $title, $class, $target, $onclick, null, $accesskey, $attributes, false); @@ -1312,11 +1312,11 @@ HTML; } /** - * Same as Horde::img(), but returns a full source url for the image. + * Same as self::img(), but returns a full source url for the image. * Useful for when the image may be part of embedded Horde content on an * external site. Basically a stop-gap measure until Horde_View etc... * - * @see Horde::img() + * @see self::img() */ static public function fullSrcImg($src, $options = array()) { @@ -1766,6 +1766,31 @@ HTML; } /** + * Add inline javascript variable definitions to the output buffer. + * + * @param array $data Keys are the variable names, values are the data to + * JSON encode. If the key begins with a '-', the + * data will be added to the output as-is. + */ + static public function addInlineJsVars($data) + { + $charset = $GLOBALS['registry']->getCharset(); + $out = array(); + + foreach ($data as $key => $val) { + if ($key[0] == '-') { + $key = substr($key, 1); + } else { + $val = Horde_Serialize::serialize($val, Horde_Serialize::JSON, $charset); + } + + $out[] = $key . '=' . $val; + } + + self::addInlineScript($out); + } + + /** * Print pending inline javascript to the output buffer. * * @param boolean $nowrap Don't wrap inline script. @@ -1783,12 +1808,12 @@ HTML; switch ($key) { case 'dom': - Horde::addScriptFile('prototype.js', 'horde'); + self::addScriptFile('prototype.js', 'horde'); $val = 'document.observe("dom:loaded", function() {' . $val . '});'; break; case 'load': - Horde::addScriptFile('prototype.js', 'horde'); + self::addScriptFile('prototype.js', 'horde'); $val = 'Event.observe(window, "load", function() {' . $val . '});'; break; }