From c387b9aa4626e45f273d8969a0070d88487019a0 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 13 Jan 2011 14:17:05 -0700 Subject: [PATCH] Bug #9455: Add ability to get full URL from Horde_Themes_Element object --- framework/Core/lib/Horde/Themes/Element.php | 61 +++++++++++++++++------------ 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/framework/Core/lib/Horde/Themes/Element.php b/framework/Core/lib/Horde/Themes/Element.php index b5444cf16..ae54a7465 100644 --- a/framework/Core/lib/Horde/Themes/Element.php +++ b/framework/Core/lib/Horde/Themes/Element.php @@ -86,7 +86,7 @@ class Horde_Themes_Element /** * String representation of this object. * - * @return string The URI. + * @return string The relative URI. */ public function __toString() { @@ -101,7 +101,12 @@ class Horde_Themes_Element /** * Retrieve URI/filesystem path values. * - * @param string $name Either 'fs' or 'uri'. + * @param string $name One of: + *
+     * 'fs' - (string) Filesystem location.
+     * 'fulluri' - (Horde_Url) Full URI.
+     * 'uri' - (string) Relative URI.
+     * 
* * @return string The requested value. */ @@ -109,32 +114,38 @@ class Horde_Themes_Element { global $prefs, $registry; - if (!empty($this->_data)) { - return isset($this->_data[$name]) - ? $this->_data[$name] - : null; + if (empty($this->_data)) { + $theme = array_key_exists('theme', $this->_opts) + ? $this->_opts['theme'] + : $prefs->getValue('theme'); + + if (is_null($this->_name)) { + /* Return directory only. */ + $this->_data = array( + 'fs' => $registry->get('themesfs', $this->app) . '/' . $theme . '/' . $this->_dirname, + 'uri' => $registry->get('themesuri', $this->app) . '/' . $theme . '/' . $this->_dirname + ); + } else { + $cache = $GLOBALS['injector']->getInstance('Horde_Core_Factory_ThemesCache')->create($this->app, $theme); + $mask = empty($this->_opts['nohorde']) + ? 0 + : Horde_Themes_Cache::APP_DEFAULT | Horde_Themes_Cache::APP_THEME; + + $this->_data = $cache->get($this->_dirname . '/' . $this->_name, $mask); + } } - $theme = array_key_exists('theme', $this->_opts) - ? $this->_opts['theme'] - : $prefs->getValue('theme'); - - if (is_null($this->_name)) { - /* Return directory only. */ - $this->_data = array( - 'fs' => $registry->get('themesfs', $this->app) . '/' . $theme . '/' . $this->_dirname, - 'uri' => $registry->get('themesuri', $this->app) . '/' . $theme . '/' . $this->_dirname - ); - } else { - $cache = $GLOBALS['injector']->getInstance('Horde_Core_Factory_ThemesCache')->create($this->app, $theme); - $mask = empty($this->_opts['nohorde']) - ? 0 - : Horde_Themes_Cache::APP_DEFAULT | Horde_Themes_Cache::APP_THEME; - - $this->_data = $cache->get($this->_dirname . '/' . $this->_name, $mask); - } + switch ($name) { + case 'fs': + case 'uri': + return $this->_data[$name]; - return $this->_data[$name]; + case 'fulluri': + return Horde::url($this->_data['uri'], true); + + default: + return null; + } } /** -- 2.11.0