Jonah: Convert initialization to H4
authorBen Klang <ben@alkaloid.net>
Tue, 4 May 2010 00:42:06 +0000 (20:42 -0400)
committerBen Klang <ben@alkaloid.net>
Tue, 4 May 2010 00:42:06 +0000 (20:42 -0400)
26 files changed:
jonah/channels/aggregate.php
jonah/channels/delete.php
jonah/channels/edit.php
jonah/channels/index.php
jonah/delivery/html.php
jonah/delivery/index.php
jonah/delivery/rss.php
jonah/dispatcher.php
jonah/feed.php
jonah/lib/Api.php
jonah/lib/Application.php
jonah/lib/Block/cloud.php
jonah/lib/Block/delivery.php
jonah/lib/Block/latest.php
jonah/lib/Block/news.php
jonah/lib/Block/news_popular.php
jonah/lib/Block/story.php
jonah/lib/Block/tree_menu.php
jonah/lib/base.php [deleted file]
jonah/stories/delete.php
jonah/stories/edit.php
jonah/stories/index.php
jonah/stories/pdf.php
jonah/stories/results.php
jonah/stories/share.php
jonah/stories/view.php

index 5baa99f..4cd9811 100644 (file)
@@ -11,7 +11,8 @@
  */
 
 @define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once JONAH_BASE . '/lib/News.php';
 require_once 'Horde/Form.php';
 require_once 'Horde/Form/Renderer.php';
index ad55441..d24868e 100644 (file)
@@ -12,8 +12,8 @@
  */
 
 define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once 'Horde/Form.php';
 require_once 'Horde/Form/Renderer.php';
 
index 98e6b25..d39b694 100644 (file)
@@ -12,8 +12,8 @@
  */
 
 @define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once JONAH_BASE . '/lib/Forms/Feed.php';
 require_once 'Horde/Form/Renderer.php';
 
index 7d6dde3..96b71e3 100644 (file)
@@ -11,9 +11,8 @@
  * @author Marko Djukic <marko@oblo.com>
  */
 
-@define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 
 if (!Jonah::checkPermissions('jonah:news', Horde_Perms::EDIT)) {
     $notification->push(_("You are not authorised for this action."), 'horde.warning');
index f7ca048..262b2c6 100644 (file)
@@ -14,9 +14,8 @@
 
 $session_control = 'readonly';
 @define('AUTH_HANDLER', true);
-@define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require JONAH_BASE . '/config/templates.php';
 
 // TODO - check if a user, have button to add channel to their
index d0013a0..63e5c6c 100644 (file)
@@ -12,7 +12,7 @@
 
 $parts = explode('/', Horde_Util::getPathInfo());
 $lastpart = null;
-$deliverytype = null;
+$deliveryType = null;
 $criteria = array();
 foreach ($parts as $part) {
     if (empty($part)) {
@@ -20,6 +20,13 @@ foreach ($parts as $part) {
         continue;
     }
 
+    // Check for REST-style content type
+    if (strpos($part, '.') !== false) {
+        $deliveryType = substr($part, strrpos($part, '.') + 1);
+        $part = substr($part, 0, strrpos($part, '.'));
+        
+    }
+
     switch($part) {
     case 'html':
     case 'rss':
index 7d2f37f..031cf7f 100644 (file)
@@ -12,9 +12,8 @@
 
 $session_control = 'readonly';
 @define('AUTH_HANDLER', true);
-@define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once JONAH_BASE . '/lib/version.php';
 
 $news = Jonah_News::factory();
index 428c509..4773c6d 100644 (file)
@@ -1,8 +1,6 @@
 <?php
 /**
- * $Horde: jonah/dispatcher.php,v 1.9 2009/06/10 05:24:46 slusarz Exp $
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
  *
  * See the enclosed file LICENSE for license information (BSD). If you did
  * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
@@ -11,9 +9,8 @@
  */
 $session_control = 'readonly';
 @define('AUTH_HANDLER', true);
-@define('JONAH_BASE', dirname(__FILE__));
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require JONAH_BASE . '/config/templates.php';
 
 // Grab, and hopefully match, the URL
index 4811e33..382433d 100644 (file)
@@ -14,7 +14,8 @@
 
 $session_control = 'readonly';
 @define('AUTH_HANDLER', true);
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require JONAH_BASE . '/config/templates.php';
 
 /* Get the id and format of the feed to display. */
index 0901611..13bbc5c 100644 (file)
@@ -24,9 +24,6 @@ class Jonah_Api extends Horde_Registry_Api
      */
     public function listFeeds($type = null)
     {
-        require_once dirname(__FILE__) . '/base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         $channels = $news->getChannels($type);
 
@@ -46,8 +43,6 @@ class Jonah_Api extends Horde_Registry_Api
     public function stories($channel_id, $max_stories = 10, $start_at = 0,
                             $order = 0)
     {
-        require_once dirname(__FILE__) . '/base.php';
-        require_once JONAH_BASE . '/lib/News.php';
         $news = Jonah_News::factory();
         $stories = $news->getStories($channel_id, $max_stories, $start_at, false,
                                      time(), false, $order);
@@ -74,9 +69,6 @@ class Jonah_Api extends Horde_Registry_Api
      */
     public function story($channel_id, $story_id, $read = true)
     {
-        require_once dirname(__FILE__) . '/base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         $story = $news->getStory($channel_id, $story_id, $read);
         if (is_a($story, 'PEAR_Error')) {
@@ -105,9 +97,6 @@ class Jonah_Api extends Horde_Registry_Api
             return false;
         }
 
-        require_once dirname(__FILE__) . '/base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         $story = $news->getStory(null, $story_id);
         if (is_a($story, 'PEAR_Error')) {
@@ -140,9 +129,6 @@ class Jonah_Api extends Horde_Registry_Api
      */
     public function listTagInfo($tags = array(), $channel_id = null)
     {
-        require_once dirname(__FILE__) . '/base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         return $news->listTagInfo($tags, $channel_id);
     }
@@ -156,9 +142,6 @@ class Jonah_Api extends Horde_Registry_Api
      */
     public function getTagIds($names)
     {
-        require_once dirname(__FILE__) . '/base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         return $news->getTagIds($names);
     }
@@ -190,9 +173,6 @@ class Jonah_Api extends Horde_Registry_Api
     {
         global $registry;
 
-        require_once dirname(__FILE__) . '/base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         $results = $news->searchTags($names, $max, $from, $channel_id, $order);
         if (is_a($results, 'PEAR_Error')) {
@@ -243,8 +223,6 @@ class Jonah_Api extends Horde_Registry_Api
     {
         global $registry;
 
-        require_once dirname(__FILE__) . '/base.php';
-
         $results = $GLOBALS['jonah_driver']->getStoryCount($channel_id);
         if (is_a($results, 'PEAR_Error')) {
             return 0;
index d02ae0d..6804ac7 100644 (file)
@@ -2,11 +2,41 @@
 /**
  * Jonah application API.
  *
- * @package Kronolith
+ * @package Jonah
  */
+if (!defined('JONAH_BASE')) {
+    define('JONAH_BASE', dirname(__FILE__). '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+    /* If horde does not live directly under the app directory, the HORDE_BASE
+     * constant should be defined in config/horde.local.php. */
+    if (file_exists(JONAH_BASE. '/config/horde.local.php')) {
+        include JONAH_BASE . '/config/horde.local.php';
+    } else {
+        define('HORDE_BASE', JONAH_BASE . '/..');
+    }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
 class Jonah_Application extends Horde_Registry_Application
 {
-    public $version = 'H4 (1.0-cvs)';
+    public $version = 'H4 (1.0-git)';
+    
+    public $driver = null;
+
+    /**
+     * Initialization function.
+     *
+     * Global variables defined:
+     */
+    protected function _init()
+    {
+        $this->driver = Jonah_Driver::factory();
+    }
 
     /**
      * Returns a list of available permissions.
@@ -15,8 +45,6 @@ class Jonah_Application extends Horde_Registry_Application
      */
     public function perms()
     {
-        require_once dirname(__FILE__) . '/base.php';
-
         $news = Jonah_News::factory();
         $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
 
index 68319cb..178c16b 100644 (file)
@@ -37,9 +37,6 @@ class Horde_Block_jonah_cloud extends Horde_Block {
 
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
 
         /* Get the tags */
index 6b5c977..1d7b852 100644 (file)
@@ -27,10 +27,6 @@ class Horde_Block_Jonah_delivery extends Horde_Block {
 
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
 
         $channels = array();
index 5032805..2b92511 100644 (file)
@@ -26,10 +26,6 @@ class Horde_Block_Jonah_latest extends Horde_Block {
      */
     function _params()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $params['source'] = array('name' => _("News Source"),
                                   'type' => 'enum',
                                   'values' => array());
@@ -57,10 +53,6 @@ class Horde_Block_Jonah_latest extends Horde_Block {
      */
     function _title()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         if (empty($this->_params['source'])) {
             return _("Latest News");
         }
@@ -78,10 +70,6 @@ class Horde_Block_Jonah_latest extends Horde_Block {
      */
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         if (empty($this->_params['source'])) {
             return _("No channel specified.");
         }
index 4151221..085c2e3 100644 (file)
@@ -22,9 +22,6 @@ class Horde_Block_Jonah_news extends Horde_Block {
 
     function _params()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
         require JONAH_BASE . '/config/templates.php';
 
         $params['source'] = array('name' => _("Feed"),
@@ -61,10 +58,6 @@ class Horde_Block_Jonah_news extends Horde_Block {
 
     function _title()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         $channel = $news->getChannel($this->_params['source']);
         if (is_a($channel, 'PEAR_Error')) {
@@ -84,10 +77,6 @@ class Horde_Block_Jonah_news extends Horde_Block {
 
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         if (empty($this->_params['source'])) {
             return _("No feed specified.");
         }
index 06b2db8..63ebf8d 100644 (file)
@@ -24,9 +24,6 @@ class Horde_Block_Jonah_news_popular extends Horde_Block {
 
     function _params()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
         require JONAH_BASE . '/config/templates.php';
 
         $params['source'] = array('name' => _("Feed"),
@@ -59,10 +56,6 @@ class Horde_Block_Jonah_news_popular extends Horde_Block {
 
     function _title()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         $channel = $news->getChannel($this->_params['source']);
         if (is_a($channel, 'PEAR_Error')) {
@@ -83,10 +76,6 @@ class Horde_Block_Jonah_news_popular extends Horde_Block {
 
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         if (empty($this->_params['source'])) {
             return _("No feed specified.");
         }
index 9c750ec..217a033 100644 (file)
@@ -26,10 +26,6 @@ class Horde_Block_Jonah_story extends Horde_Block {
      */
     function _params()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         $news = Jonah_News::factory();
         $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
         $channel_choices = array();
@@ -56,10 +52,6 @@ class Horde_Block_Jonah_story extends Horde_Block {
      */
     function _title()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         if (empty($this->_params['source']) ||
             empty($this->_params['story'])) {
             return _("Story");
@@ -78,10 +70,6 @@ class Horde_Block_Jonah_story extends Horde_Block {
      */
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/Jonah.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         if (empty($this->_params['source']) || empty($this->_params['story'])) {
             return _("No story is selected.");
         }
index aa37959..83cd8ce 100644 (file)
@@ -14,9 +14,6 @@ class Horde_Block_jonah_tree_menu extends Horde_Block {
 
     function _buildTree(&$tree, $indent = 0, $parent = null)
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        require_once JONAH_BASE . '/lib/News.php';
-
         if (!Jonah::checkPermissions('jonah:news', Horde_Perms::EDIT) ||
             !in_array('internal', $GLOBALS['conf']['news']['enable'])) {
             return;
diff --git a/jonah/lib/base.php b/jonah/lib/base.php
deleted file mode 100644 (file)
index 79b7f66..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-/**
- * Jonah base inclusion file.
- *
- * $Horde: jonah/lib/base.php,v 1.63 2009/10/20 09:17:26 jan Exp $
- *
- * This file brings in all of the dependencies that every Jonah script
- * will need, and sets up objects that all scripts use.
- */
-
-// Check for a prior definition of HORDE_BASE (perhaps by an
-// auto_prepend_file definition for site customization).
-if (!defined('HORDE_BASE')) {
-    define('HORDE_BASE', dirname(__FILE__) . '/../..');
-}
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-if (Horde_Util::nonInputVar('session_control') == 'none') {
-    $registry = Horde_Registry::singleton(Horde_Registry::SESSION_NONE);
-} elseif (Horde_Util::nonInputVar('session_control') == 'readonly') {
-    $registry = Horde_Registry::singleton(Horde_Registry::SESSION_READONLY);
-} else {
-    $registry = Horde_Registry::singleton();
-}
-
-try {
-    $registry->pushApp('jonah', !defined('AUTH_HANDLER'));
-} catch (Horde_Exception $e) {
-    if ($e->getCode() == 'permission_denied') {
-        Horde::authenticationFailureRedirect();
-    }
-    Horde::fatal($e, __FILE__, __LINE__, false);
-}
-$conf = &$GLOBALS['conf'];
-define('JONAH_TEMPLATES', $registry->get('templates'));
-
-/* Notification system. */
-$notification = &Horde_Notification::singleton();
-$notification->attach('status');
-
-/* Find the base file path of Jonah. */
-if (!defined('JONAH_BASE')) {
-    define('JONAH_BASE', dirname(__FILE__) . '/..');
-}
-
-/* Jonah base library. */
-require_once JONAH_BASE . '/lib/Jonah.php';
-
-/* Instantiate Jonah storage */
-require_once JONAH_BASE . '/lib/Driver.php';
-$GLOBALS['jonah_driver'] = Jonah_Driver::factory();
-
-// Start compression.
-if (!Horde_Util::nonInputVar('no_compress')) {
-     Horde::compressOutput();
-}
index fdfd894..8a7d038 100644 (file)
@@ -11,9 +11,8 @@
  * @author Marko Djukic <marko@oblo.com>
  */
 
-define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once 'Horde/Form.php';
 require_once 'Horde/Form/Renderer.php';
 
index e19aee7..3539c6c 100644 (file)
@@ -13,8 +13,8 @@
  * @author Marko Djukic <marko@oblo.com>
  */
 
-require_once dirname(__FILE__) . '/../lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once JONAH_BASE . '/lib/Forms/Story.php';
 require_once 'Horde/Form/Action.php';
 require_once 'Horde/Form/Renderer.php';
index b0d2773..76cb744 100644 (file)
  * @author Marko Djukic <marko@oblo.com>
  */
 
-@define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
-
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 $news = Jonah_News::factory();
 
 /* Redirect to the news index if no channel_id is specified. */
index 7a5c0f3..e618441 100644 (file)
@@ -21,9 +21,8 @@ function _exit($message)
 
 $session_control = 'readonly';
 @define('AUTH_HANDLER', true);
-@define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once 'File/PDF.php';
 
 $news = Jonah_News::factory();
index df65ced..3626203 100644 (file)
@@ -5,10 +5,8 @@
  *
  * $Horde: jonah/stories/results.php,v 1.5 2009/11/24 04:15:38 chuck Exp $
  */
-
-@define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 
 $news = Jonah_News::factory();
 
index 110eafc..3ab91ed 100644 (file)
@@ -42,9 +42,8 @@ function _mail($story_part, $from, $recipients, $subject, $note)
 
 $session_control = 'readonly';
 @define('AUTH_HANDLER', true);
-@define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 require_once 'Horde/Form.php';
 require_once 'Horde/Form/Renderer.php';
 
index 454ebc8..bbdfefe 100644 (file)
@@ -12,8 +12,8 @@
 
 @define('AUTH_HANDLER', true);
 @define('JONAH_BASE', dirname(__FILE__) . '/..');
-require_once JONAH_BASE . '/lib/base.php';
-require_once JONAH_BASE . '/lib/News.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+$jonah = Horde_Registry::appInit('jonah');
 
 $news = Jonah_News::factory();