No need for a factory method any longer, use Horde_Url style parameters here
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 28 Jun 2010 22:35:10 +0000 (18:35 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 28 Jun 2010 22:35:10 +0000 (18:35 -0400)
jonah/lib/Driver.php
jonah/lib/Jonah.php

index 91bb1a8..ebda7d3 100644 (file)
@@ -516,41 +516,6 @@ class Jonah_Driver {
     }
 
     /**
-     * Attempts to return a concrete Jonah_Driver instance based on $driver.
-     *
-     * @param string $driver  The type of concrete Jonah_Driver subclass to
-     *                        return. The is based on the storage driver
-     *                        ($driver). The code is dynamically included.
-     *
-     * @param array $params   A hash containing any additional configuration or
-     *                        connection parameters a subclass might need.
-     *
-     * @return mixed  The newly created concrete Jonah_Driver instance, or false
-     *                on an error.
-     */
-    function factory($driver = null, $params = null)
-    {
-        if ($driver === null) {
-            $driver = $GLOBALS['conf']['news']['storage']['driver'];
-        }
-        $driver = basename($driver);
-
-        if ($params === null) {
-            $params = Horde::getDriverConfig(array('news', 'storage'), $driver);
-        }
-
-        $class = 'Jonah_Driver_' . $driver;
-        if (!class_exists($class, false)) {
-            include dirname(__FILE__) . '/Driver/' . $driver . '.php';
-        }
-        if (class_exists($class)) {
-            return new $class($params);
-        } else {
-            return PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver));
-        }
-    }
-
-    /**
      * Stubs for the tag functions. If supported by the backend, these need
      * to be implemented in the concrete Jonah_Driver_* class.
      */
index 3610fcc..db56770 100644 (file)
@@ -249,11 +249,11 @@ class Jonah
             }
         }
         if ($channel_id = Horde_Util::getFormData('channel_id')) {
-            $news = Jonah_News::factory();
+            $news = $GLOBALS['injector']->getInstance('Jonah_Driver');
             $channel = $news->getChannel($channel_id);
             if ($channel['channel_type'] == Jonah::INTERNAL_CHANNEL &&
                 Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::EDIT, $channel_id)) {
-                $menu->addArray(array('url' => Horde::applicationUrl('stories/edit.php?channel_id=' . (int)$channel_id), 'text' => _("_New Story"), 'icon' => 'new.png'));
+                $menu->addArray(array('url' => Horde::applicationUrl('stories/edit.php')->add('channel_id', (int)$channel_id), 'text' => _("_New Story"), 'icon' => 'new.png'));
             }
         }