From: Michael M Slusarz Date: Thu, 6 Aug 2009 04:27:53 +0000 (-0600) Subject: Add Horde_Registry_Application X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fc0edf7cb9e0844936c97b28d78bf9f58b3ac069;p=horde.git Add Horde_Registry_Application --- diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index 43c7c1eb3..d2f1bc7f0 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -345,7 +345,7 @@ class Horde_Registry foreach (array_keys($this->applications) as $app) { if (in_array($this->applications[$app]['status'], $status)) { - $api = $this->_getApiOb($app); + $api = $this->_getOb($app, 'api'); $this->_cache['api'][$app] = array( 'api' => array_diff(get_class_methods($api), array('__construct'), $api->disabled), 'links' => $api->links, @@ -358,32 +358,35 @@ class Horde_Registry } /** - * Retrieve the API object for a given application. + * Retrieve an API object. * - * @param string $app The application to load. + * @param string $app The application to load. + * @param string $type Either 'application' or 'api'. * - * @return Horde_Registry_Api The API object. + * @return Horde_Registry_Api|Horde_Registry_Application The API object. * @throws Horde_Exception */ - protected function _getApiOb($app) + protected function _getOb($app, $type) { - if (isset($this->_cache['apiob'][$app])) { - return $this->_cache['apiob'][$app]; + if (isset($this->_cache['ob'][$app][$type])) { + return $this->_cache['ob'][$app][$type]; } + $cname = Horde_String::ucfirst($type); + /* Can't autoload here, since the application may not have been * initialized yet. */ - $classname = Horde_String::ucfirst($app) . '_Api'; - $path = $this->get('fileroot', $app) . '/lib/Api.php'; + $classname = Horde_String::ucfirst($app) . '_' . $cname; + $path = $this->get('fileroot', $app) . '/lib/' . $cname . '.php'; if (file_exists($path)) { include_once $path; } else { - $classname = 'Horde_Registry_Api'; + $classname = 'Horde_Registry_' . $cname; } - $this->_cache['apiob'][$app] = new $classname; + $this->_cache['ob'][$app][$type] = new $classname; - return $this->_cache['apiob'][$app]; + return $this->_cache['ob'][$app][$type]; } /** @@ -566,7 +569,7 @@ class Horde_Registry } /* Load the API now. */ - $api = $this->_getApiOb($app); + $api = $this->_getOb($app, 'api'); /* Make sure that the function actually exists. */ if (!method_exists($api, $call)) { @@ -1027,7 +1030,7 @@ class Horde_Registry } try { - $api = $this->_getApiOb($app); + $api = $this->_getOb($app, 'application'); return $api->version; } catch (Horde_Exception $e) { return 'unknown'; @@ -1048,7 +1051,7 @@ class Horde_Registry } try { - $api = $this->_getApiOb($app); + $api = $this->_getOb($app, 'application'); return $api->mobileView; } catch (Horde_Exception $e) { return false; diff --git a/framework/Core/lib/Horde/Registry/Api.php b/framework/Core/lib/Horde/Registry/Api.php index 5efd64d60..3c45c33f2 100644 --- a/framework/Core/lib/Horde/Registry/Api.php +++ b/framework/Core/lib/Horde/Registry/Api.php @@ -1,6 +1,6 @@ + * @package Core + */ +class Horde_Registry_Application +{ + /** + * Does this application support a mobile view? + * + * @var boolean + */ + public $mobileView = false; + + /** + * The application's version. + * + * @var string + */ + public $version = 'unknown'; + + /** + * The list of disabled API calls. + * + * @var array + */ + public $disabled = array(); + +} diff --git a/framework/Core/package.xml b/framework/Core/package.xml index cf47b343b..fade2bba1 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -37,7 +37,7 @@ Application Framework. beta LGPL - * Added Horde_Registry_Api:: template class. + * Added Horde_Registry_Api:: and Horde_Registry_Application:: classes. * Moved Horde_Exception to Exception package. * Renamed Menu:: as Horde_Menu::. * Renamed Help:: as Horde_Help::. @@ -58,6 +58,7 @@ Application Framework. + @@ -128,6 +129,7 @@ Application Framework. +