From 1417d92fd13c06439ac411edc9d6f35414ca5cbb Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Tue, 14 Apr 2009 17:25:20 -0400 Subject: [PATCH] simplify factory and ucfirst driver names so that jonah works with the editor again --- framework/Editor/lib/Horde/Editor.php | 38 +++++++++-------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/framework/Editor/lib/Horde/Editor.php b/framework/Editor/lib/Horde/Editor.php index f10598b89..135073746 100644 --- a/framework/Editor/lib/Horde/Editor.php +++ b/framework/Editor/lib/Horde/Editor.php @@ -24,10 +24,8 @@ class Horde_Editor /** * Attempts to return a concrete Horde_Editor instance based on $driver. * - * @param mixed $driver The type of concrete Horde_Editor subclass to - * return. If $driver is an array, then we will look - * in $driver[0]/lib/Editor/ for the subclass - * implementation named $driver[1].php. + * @param string $driver The type of concrete Horde_Editor subclass to + * return. * @param array $params A hash containing any additional configuration or * connection parameters a subclass might need. * @@ -36,38 +34,20 @@ class Horde_Editor */ static public function factory($driver, $params = null) { - if (is_array($driver)) { - list($app, $driv_name) = $driver; - $driver = basename($driv_name); - } else { - $driver = basename($driver); - } - - if (empty($driver) || (strcmp($driver, 'none') == 0)) { - return $editor = new Horde_Editor(); + $driver = ucfirst(basename($driver)); + if (empty($driver) || (strcmp($driver, 'None') == 0)) { + return new Horde_Editor(); } $class = 'Horde_Editor_' . $driver; - if (!empty($app)) { - $class = $app . '_' . $class; - } - if (!class_exists($class)) { - if (empty($app)) { - include_once dirname(__FILE__) . '/Editor/' . $driver . '.php'; - } else { - include_once $GLOBALS['registry']->get('fileroot', $app) . '/lib/Editor/' . $driver . '.php'; - } + throw new Exception('Driver ' . $driver . ' not found'); } - if (class_exists($class)) { - if (is_null($params) && class_exists('Horde')) { - $params = Horde::getDriverConfig('editor', $driver); - } - return new $class($params); + if (is_null($params) && class_exists('Horde')) { + $params = Horde::getDriverConfig('editor', $driver); } - - return PEAR::raiseError('Class definition of ' . $class . ' not found.'); + return new $class($params); } /** -- 2.11.0