From: Ben Klang Date: Tue, 4 May 2010 00:42:06 +0000 (-0400) Subject: Jonah: Convert initialization to H4 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=52fe3b1a1a50a851a9c23d2499cf4b8e65df1c76;p=horde.git Jonah: Convert initialization to H4 --- diff --git a/jonah/channels/aggregate.php b/jonah/channels/aggregate.php index 5baa99fe1..4cd9811a5 100644 --- a/jonah/channels/aggregate.php +++ b/jonah/channels/aggregate.php @@ -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'; diff --git a/jonah/channels/delete.php b/jonah/channels/delete.php index ad55441a1..d24868e95 100644 --- a/jonah/channels/delete.php +++ b/jonah/channels/delete.php @@ -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'; diff --git a/jonah/channels/edit.php b/jonah/channels/edit.php index 98e6b2549..d39b69419 100644 --- a/jonah/channels/edit.php +++ b/jonah/channels/edit.php @@ -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'; diff --git a/jonah/channels/index.php b/jonah/channels/index.php index 7d6dde326..96b71e3af 100644 --- a/jonah/channels/index.php +++ b/jonah/channels/index.php @@ -11,9 +11,8 @@ * @author Marko Djukic */ -@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'); diff --git a/jonah/delivery/html.php b/jonah/delivery/html.php index f7ca0486b..262b2c66f 100644 --- a/jonah/delivery/html.php +++ b/jonah/delivery/html.php @@ -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 diff --git a/jonah/delivery/index.php b/jonah/delivery/index.php index d0013a054..63e5c6c9d 100644 --- a/jonah/delivery/index.php +++ b/jonah/delivery/index.php @@ -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': diff --git a/jonah/delivery/rss.php b/jonah/delivery/rss.php index 7d2f37fe6..031cf7f85 100644 --- a/jonah/delivery/rss.php +++ b/jonah/delivery/rss.php @@ -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(); diff --git a/jonah/dispatcher.php b/jonah/dispatcher.php index 428c5090b..4773c6dfe 100644 --- a/jonah/dispatcher.php +++ b/jonah/dispatcher.php @@ -1,8 +1,6 @@ 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; diff --git a/jonah/lib/Application.php b/jonah/lib/Application.php index d02ae0d46..6804ac7b2 100644 --- a/jonah/lib/Application.php +++ b/jonah/lib/Application.php @@ -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); diff --git a/jonah/lib/Block/cloud.php b/jonah/lib/Block/cloud.php index 68319cbb5..178c16b71 100644 --- a/jonah/lib/Block/cloud.php +++ b/jonah/lib/Block/cloud.php @@ -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 */ diff --git a/jonah/lib/Block/delivery.php b/jonah/lib/Block/delivery.php index 6b5c97720..1d7b85231 100644 --- a/jonah/lib/Block/delivery.php +++ b/jonah/lib/Block/delivery.php @@ -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(); diff --git a/jonah/lib/Block/latest.php b/jonah/lib/Block/latest.php index 5032805c9..2b92511fe 100644 --- a/jonah/lib/Block/latest.php +++ b/jonah/lib/Block/latest.php @@ -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."); } diff --git a/jonah/lib/Block/news.php b/jonah/lib/Block/news.php index 415122131..085c2e31d 100644 --- a/jonah/lib/Block/news.php +++ b/jonah/lib/Block/news.php @@ -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."); } diff --git a/jonah/lib/Block/news_popular.php b/jonah/lib/Block/news_popular.php index 06b2db832..63ebf8d36 100644 --- a/jonah/lib/Block/news_popular.php +++ b/jonah/lib/Block/news_popular.php @@ -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."); } diff --git a/jonah/lib/Block/story.php b/jonah/lib/Block/story.php index 9c750ec9d..217a0330c 100644 --- a/jonah/lib/Block/story.php +++ b/jonah/lib/Block/story.php @@ -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."); } diff --git a/jonah/lib/Block/tree_menu.php b/jonah/lib/Block/tree_menu.php index aa3795904..83cd8ce2e 100644 --- a/jonah/lib/Block/tree_menu.php +++ b/jonah/lib/Block/tree_menu.php @@ -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 index 79b7f6670..000000000 --- a/jonah/lib/base.php +++ /dev/null @@ -1,59 +0,0 @@ -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(); -} diff --git a/jonah/stories/delete.php b/jonah/stories/delete.php index fdfd89423..8a7d038dd 100644 --- a/jonah/stories/delete.php +++ b/jonah/stories/delete.php @@ -11,9 +11,8 @@ * @author Marko Djukic */ -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'; diff --git a/jonah/stories/edit.php b/jonah/stories/edit.php index e19aee723..3539c6c5b 100644 --- a/jonah/stories/edit.php +++ b/jonah/stories/edit.php @@ -13,8 +13,8 @@ * @author Marko Djukic */ -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'; diff --git a/jonah/stories/index.php b/jonah/stories/index.php index b0d2773e9..76cb7445e 100644 --- a/jonah/stories/index.php +++ b/jonah/stories/index.php @@ -11,10 +11,8 @@ * @author Marko Djukic */ -@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. */ diff --git a/jonah/stories/pdf.php b/jonah/stories/pdf.php index 7a5c0f3f7..e61844133 100644 --- a/jonah/stories/pdf.php +++ b/jonah/stories/pdf.php @@ -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(); diff --git a/jonah/stories/results.php b/jonah/stories/results.php index df65ced22..36262030f 100644 --- a/jonah/stories/results.php +++ b/jonah/stories/results.php @@ -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(); diff --git a/jonah/stories/share.php b/jonah/stories/share.php index 110eafc51..3ab91edd3 100644 --- a/jonah/stories/share.php +++ b/jonah/stories/share.php @@ -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'; diff --git a/jonah/stories/view.php b/jonah/stories/view.php index 454ebc86d..bbdfefe32 100644 --- a/jonah/stories/view.php +++ b/jonah/stories/view.php @@ -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();