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,
}
/**
- * 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];
}
/**
}
/* 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)) {
}
try {
- $api = $this->_getApiOb($app);
+ $api = $this->_getOb($app, 'application');
return $api->version;
} catch (Horde_Exception $e) {
return 'unknown';
}
try {
- $api = $this->_getApiOb($app);
+ $api = $this->_getOb($app, 'application');
return $api->mobileView;
} catch (Horde_Exception $e) {
return false;
--- /dev/null
+<?php
+/**
+ * Default class for the Horde Application API.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Michael Slusarz <slusarz@horde.org>
+ * @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();
+
+}
<api>beta</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Added Horde_Registry_Api:: template class.
+ <notes>* 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::.
<file name="Registry.php" role="php" />
<dir name="Registry">
<file name="Api.php" role="php" />
+ <file name="Application.php" role="php" />
<file name="Caller.php" role="php" />
</dir> <!-- /lib/Horde/Registry -->
<dir name="Script">
<install name="lib/Horde/Menu.php" as="Horde/Menu.php" />
<install name="lib/Horde/Registry.php" as="Horde/Registry.php" />
<install name="lib/Horde/Registry/Api.php" as="Horde/Registry/Api.php" />
+ <install name="lib/Horde/Registry/Application.php" as="Horde/Registry/Application.php" />
<install name="lib/Horde/Registry/Caller.php" as="Horde/Registry/Caller.php" />
<install name="lib/Horde/Script/Files.php" as="Horde/Script/Files.php" />
<install name="lib/Horde.php" as="Horde.php" />