Need to make these class constants.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 4 May 2010 16:17:28 +0000 (12:17 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 4 May 2010 16:17:28 +0000 (12:17 -0400)
I know some of this might get refactored, but these need to be class constants so
they can be autoloaded now.

18 files changed:
jonah/channels/aggregate.php
jonah/channels/delete.php
jonah/channels/edit.php
jonah/channels/index.php
jonah/lib/Api.php
jonah/lib/Application.php
jonah/lib/Block/delivery.php
jonah/lib/Block/latest.php
jonah/lib/Block/news_popular.php
jonah/lib/Block/story.php
jonah/lib/Driver.php
jonah/lib/Driver/sql.php
jonah/lib/Forms/Feed.php
jonah/lib/Jonah.php
jonah/lib/News.php
jonah/lib/News/sql.php
jonah/stories/index.php
jonah/stories/results.php

index a6468a2..97ca050 100644 (file)
@@ -13,9 +13,6 @@
 @define('JONAH_BASE', dirname(__FILE__) . '/..');
 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';
 
 function _getLinks($id, $subid, $name, $title)
 {
@@ -42,7 +39,7 @@ $ids = preg_split('/:/', $channel['channel_url'], -1, PREG_SPLIT_NO_EMPTY);
 
 /* Get the vars for channel type. */
 $channel_type = $channel['channel_type'];
-if ($channel_type != JONAH_AGGREGATED_CHANNEL) {
+if ($channel_type != Jonah::AGGREGATED_CHANNEL) {
     $notification->push(_("This is no aggregated channel."), 'horde.error');
     header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('channels/edit.php', true), 'channel_id', $channel_id));
     exit;
@@ -68,7 +65,7 @@ if ($form->validate($vars)) {
                         'channel_name' => $vars->get('channel_name'),
                         'channel_link' => $vars->get('channel_link'),
                         'channel_img' => $vars->get('channel_img'),
-                        'channel_type' => JONAH_EXTERNAL_CHANNEL);
+                        'channel_type' => Jonah::EXTERNAL_CHANNEL);
     if ($vars->get('subchannel_id')) {
         $subchannel['channel_id'] = $vars->get('subchannel_id');
     }
index 854e19e..4882e35 100644 (file)
@@ -51,7 +51,7 @@ $form->setButtons(array(_("Delete"), _("Do not delete")));
 $form->addHidden('', 'channel_id', 'int', true, true);
 
 $msg = _("Really delete this News Channel?");
-if ($vars->get('channel_type') == JONAH_INTERNAL_CHANNEL) {
+if ($vars->get('channel_type') == Jonah::INTERNAL_CHANNEL) {
     $msg .= ' ' . _("All stories created in this channel will be lost!");
 } else {
     $msg .= ' ' . _("Any cached stories for this channel will be lost!");
index 9b25602..d76050f 100644 (file)
@@ -67,7 +67,7 @@ if ($formname && !$changed_type) {
             $notification->push(sprintf(_("There was an error saving the feed: %s"), $save->getMessage()), 'horde.error');
         } else {
             $notification->push(sprintf(_("The feed \"%s\" has been saved."), $info['channel_name']), 'horde.success');
-            if ($channel_type == JONAH_AGGREGATED_CHANNEL) {
+            if ($channel_type == Jonah::AGGREGATED_CHANNEL) {
                 $notification->push(_("You can now edit the sub-feeds."), 'horde.message');
             } else {
                 header('Location: ' . Horde::applicationUrl('channels/index.php', true));
index eeefe1d..6121720 100644 (file)
@@ -40,7 +40,7 @@ if (is_a($channels, 'PEAR_Error')) {
         /* Edit channel link. */
         $url = Horde::applicationUrl('channels/edit.php');
         $url = Horde_Util::addParameter($url, 'channel_id', $channel['channel_id']);
-        $channels[$key]['edit_link'] = Horde::link($url, _("Edit channel"), '', '', '', _("Edit channel")) . Horde_Themes::img('edit.png') . '</a>';
+        $channels[$key]['edit_link'] = Horde::link($url, _("Edit channel"), '', '', '', _("Edit channel")) . Horde::img('edit.png') . '</a>';
 
         /* Delete channel link. */
         $url = Horde::applicationUrl('channels/delete.php');
@@ -57,15 +57,15 @@ if (is_a($channels, 'PEAR_Error')) {
         $channels[$key]['refresh_link'] = '';
 
         switch ($channel['channel_type']) {
-        case JONAH_INTERNAL_CHANNEL:
+        case Jonah::INTERNAL_CHANNEL:
             /* Add story link. */
             $url = Horde::applicationUrl('stories/edit.php');
             $url = Horde_Util::addParameter($url, 'channel_id', $channel['channel_id']);
             $channels[$key]['addstory_link'] = Horde::link($url, _("Add story"), '', '', '', _("Add story")) . Horde_Themes::img('new.png') . '</a>';
             break;
 
-        case JONAH_EXTERNAL_CHANNEL:
-        case JONAH_AGGREGATED_CHANNEL:
+        case Jonah::EXTERNAL_CHANNEL:
+        case Jonah::AGGREGATED_CHANNEL:
             /* Refresh cache link. */
             $url = Horde::applicationUrl('stories/index.php');
             $url = Horde_Util::addParameter($url, array('channel_id' => $channel['channel_id'], 'refresh' => '1', 'url' => Horde::selfUrl()));
index 67144bd..6a2aa6a 100644 (file)
@@ -15,9 +15,9 @@ class Jonah_Api extends Horde_Registry_Api
      * Get a list of stored channels.
      *
      * @param integer $type  The type of channel to filter for. Possible
-     *                       values are either JONAH_INTERNAL_CHANNEL
+     *                       values are either Jonah::INTERNAL_CHANNEL
      *                       to fetch only a list of internal channels,
-     *                       or JONAH_EXTERNAL_CHANNEL for only external.
+     *                       or Jonah::EXTERNAL_CHANNEL for only external.
      *                       If null both channel types are returned.
      *
      * @return mixed         An array of channels or PEAR_Error on error.
@@ -163,7 +163,7 @@ class Jonah_Api extends Horde_Registry_Api
      * @param integer $max       The maximum number of stories to return.
      * @param integer $from      The number of the story to start with.
      * @param array $channel_id  An array of channel_ids to limit the search to.
-     * @param integer $order     How to order the results (a JONAH_ORDER_* constant)
+     * @param integer $order     How to order the results (a Jonah::ORDER_* constant)
      * @param boolean $raw       Return the raw story data?
      *
      * @return mixed  An array of results | PEAR_Error
index 6804ac7..197da42 100644 (file)
@@ -46,7 +46,7 @@ class Jonah_Application extends Horde_Registry_Application
     public function perms()
     {
         $news = Jonah_News::factory();
-        $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+        $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
 
         /* Loop through internal channels and add their ids to the
          * perms. */
@@ -72,7 +72,7 @@ class Jonah_Application extends Horde_Registry_Application
             $perms['tree']['jonah']['news']['internal_channels'][$channel['channel_id']] = false;
         }
 
-        $channels = $news->getChannels(JONAH_EXTERNAL_CHANNEL);
+        $channels = $news->getChannels(Jonah::EXTERNAL_CHANNEL);
 
         /* Loop through external channels and add their ids to the
          * perms. */
index 0629004..f03c6ed 100644 (file)
@@ -30,7 +30,7 @@ class Horde_Block_Jonah_delivery extends Horde_Block {
         $news = Jonah_News::factory();
 
         $channels = array();
-        $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+        $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
         if (is_a($channels, 'PEAR_Error')) {
             $channels = array();
         }
index 2b92511..e917122 100644 (file)
@@ -31,7 +31,7 @@ class Horde_Block_Jonah_latest extends Horde_Block {
                                   'values' => array());
 
         $news = Jonah_News::factory();
-        $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+        $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
         foreach ($channels as $channel) {
             $params['source']['values'][$channel['channel_id']] = $channel['channel_name'];
         }
index 63ebf8d..28adc4f 100644 (file)
@@ -33,7 +33,7 @@ class Horde_Block_Jonah_news_popular extends Horde_Block {
         $news = Jonah_News::factory();
         $channels = $news->getChannels();
         foreach ($channels as  $channel) {
-            if ($channel['channel_type'] == JONAH_INTERNAL_CHANNEL) {
+            if ($channel['channel_type'] == Jonah::INTERNAL_CHANNEL) {
                 $params['source']['values'][$channel['channel_id']] = $channel['channel_name'];
             }
         }
@@ -90,7 +90,7 @@ class Horde_Block_Jonah_news_popular extends Horde_Block {
         }
 
 
-        return $news->renderChannel($this->_params['source'], $view, $this->_params['max'], 0, JONAH_ORDER_READ);
+        return $news->renderChannel($this->_params['source'], $view, $this->_params['max'], 0, Jonah::ORDER_READ);
     }
 
 }
index 217a033..c618b5b 100644 (file)
@@ -27,7 +27,7 @@ class Horde_Block_Jonah_story extends Horde_Block {
     function _params()
     {
         $news = Jonah_News::factory();
-        $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+        $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
         $channel_choices = array();
         foreach ($channels as $channel) {
             $channel_choices[$channel['channel_id']] = $channel['channel_name'];
index 0fa6263..ee4b0a1 100644 (file)
@@ -131,7 +131,7 @@ class Jonah_Driver {
      *
      * @param integer $order       How to order the results for internal
      *                             channels. Possible values are the
-     *                             JONAH_ORDER_* constants.
+     *                             Jonah::ORDER_* constants.
      *
      * @return array  The specified number (or less, if there are fewer) of
      *                stories from the given channel.
@@ -194,14 +194,14 @@ class Jonah_Driver {
      *                             Defaults to false - only published stories.
      * @param integer $order       How to order the results for internal
      *                             channels. Possible values are the
-     *                             JONAH_ORDER_* constants.
+     *                             Jonah::ORDER_* constants.
      *
      * @return array  The specified number (or less, if there are fewer) of
      *                stories from the given channel.
      */
     function legacyGetStories($channel, $max = 10, $from = 0, $refresh = false,
                         $date = null, $unreleased = false,
-                        $order = JONAH_ORDER_PUBLISHED)
+                        $order = Jonah::ORDER_PUBLISHED)
     {
         global $conf, $registry;
 
@@ -278,7 +278,7 @@ class Jonah_Driver {
             if (is_a($channel, 'PEAR_Error')) {
                 return $channel;
             }
-            if ($channel['channel_type'] == JONAH_EXTERNAL_CHANNEL) {
+            if ($channel['channel_type'] == Jonah::EXTERNAL_CHANNEL) {
                 return $this->_getExternalStory($channel, $story_id);
             }
         }
@@ -358,12 +358,12 @@ class Jonah_Driver {
      *                             null, all stories will be returned.
      * @param integer $from        The number of the story to start with.
      * @param integer $order       How to sort the results for internal channels
-     *                             Possible values are the JONAH_ORDER_*
+     *                             Possible values are the Jonah::ORDER_*
      *                             constants.
      *
      * @return string  The rendered story listing.
      */
-    function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = JONAH_ORDER_PUBLISHED)
+    function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = Jonah::ORDER_PUBLISHED)
     {
         $channel = $this->getChannel($channel_id);
         if (is_a($channel, 'PEAR_Error')) {
@@ -579,7 +579,7 @@ class Jonah_Driver {
     }
 
     function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
-                            $order = JONAH_ORDER_PUBLISHED)
+                            $order = Jonah::ORDER_PUBLISHED)
     {
         return PEAR::raiseError(_("Tag support not enabled in backend."));
     }
index 11024d1..caf7651 100644 (file)
@@ -176,7 +176,7 @@ class Jonah_Driver_sql extends Jonah_Driver {
         }
 
         $result['channel_name'] = Horde_String::convertCharset($result['channel_name'], $this->_params['charset']);
-        if ($result['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+        if ($result['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
             $channels = explode(':', $result['channel_url']);
             if (count($channels)) {
                 $sql = 'SELECT MAX(channel_updated) FROM jonah_channels WHERE channel_id IN (' . implode(',', $channels) . ')';
@@ -509,7 +509,7 @@ class Jonah_Driver_sql extends Jonah_Driver {
      *                stories from the given channel.
      */
     function _legacyGetStories($channel_id, $max, $from = 0, $date = null,
-                         $unreleased = false, $order = JONAH_ORDER_PUBLISHED)
+                         $unreleased = false, $order = Jonah::ORDER_PUBLISHED)
     {
         if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
             return $result;
@@ -534,13 +534,13 @@ class Jonah_Driver_sql extends Jonah_Driver {
         }
 
         switch ($order) {
-        case JONAH_ORDER_PUBLISHED:
+        case Jonah::ORDER_PUBLISHED:
             $sql .= ' ORDER BY story_published DESC';
             break;
-        case JONAH_ORDER_READ:
+        case Jonah::ORDER_READ:
             $sql .= ' ORDER BY story_read DESC';
             break;
-        case JONAH_ORDER_COMMENTS:
+        case Jonah::ORDER_COMMENTS:
             //@TODO
             break;
         }
@@ -827,7 +827,7 @@ class Jonah_Driver_sql extends Jonah_Driver {
             $channels = array();
             foreach ($channel_id as $cid) {
                 $c = $this->_getChannel($cid);
-                if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+                if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
                     $channels = array_merge($channels, explode(':', $c['channel_url']));
                 }
             }
@@ -857,7 +857,7 @@ class Jonah_Driver_sql extends Jonah_Driver {
      * @return mixed  Array of stories| PEAR_Error
      */
     function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
-                            $order = JONAH_ORDER_PUBLISHED)
+                            $order = Jonah::ORDER_PUBLISHED)
     {
         if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
             return $result;
@@ -883,7 +883,7 @@ class Jonah_Driver_sql extends Jonah_Driver {
                 $channels = array();
                 foreach ($channel_id as $cid) {
                     $c = $this->_getChannel($cid);
-                    if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+                    if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
                         $temp = explode(':', $c['channel_url']);
                         // Save a map of channels that are from composites.
                         foreach ($temp as $t) {
@@ -900,13 +900,13 @@ class Jonah_Driver_sql extends Jonah_Driver {
             }
 
             switch ($order) {
-            case JONAH_ORDER_PUBLISHED:
+            case Jonah::ORDER_PUBLISHED:
                 $sql .= ' ORDER BY story_published DESC';
                 break;
-            case JONAH_ORDER_READ:
+            case Jonah::ORDER_READ:
                 $sql .= ' ORDER BY story_read DESC';
                 break;
-            case JONAH_ORDER_COMMENTS:
+            case Jonah::ORDER_COMMENTS:
                 //@TODO
                 break;
             }
@@ -957,7 +957,7 @@ class Jonah_Driver_sql extends Jonah_Driver {
      * @see Jonah_Driver_sql::searchTagsById()
      */
     function searchTags($names, $max = 10, $from = 0, $channel_id = array(),
-                        $order = JONAH_ORDER_PUBLISHED)
+                        $order = Jonah::ORDER_PUBLISHED)
     {
         $ids = $this->getTagIds($names);
         if (is_a($ids, 'PEAR_Error')) {
index f3fd78b..fc30f52 100644 (file)
@@ -56,7 +56,7 @@ class FeedForm extends Horde_Form
     function getInfo(&$vars, &$info)
     {
         parent::getInfo($vars, $info);
-        if ($vars->get('channel_type') == JONAH_COMPOSITE_CHANNEL &&
+        if ($vars->get('channel_type') == Jonah::COMPOSITE_CHANNEL &&
             is_array($vars->get('subchannels'))) {
                 $info['channel_url'] = implode(':', $vars->get('subchannels'));
         }
@@ -71,7 +71,7 @@ class FeedForm extends Horde_Form
         }
 
         switch ($type) {
-        case JONAH_INTERNAL_CHANNEL:
+        case Jonah::INTERNAL_CHANNEL:
             $this->addVariable(_("Description"), 'channel_desc', 'text', false);
             $this->addVariable(
                 _("Channel Slug"), 'channel_slug', 'text', true, false,
@@ -85,7 +85,7 @@ class FeedForm extends Horde_Form
             $this->addVariable(_("Story URL if not the default one. %c gets replaced by the feed ID, %s by the story ID."), 'channel_story_url', 'text', false);
             break;
 
-        case JONAH_EXTERNAL_CHANNEL:
+        case Jonah::EXTERNAL_CHANNEL:
             $interval = Jonah_News::getIntervalLabel();
             $v = &$this->addVariable(_("Caching"), 'channel_interval', 'enum', false, false, _("The interval before stories in this feed are rechecked for updates. If none, then stories will always be refetched from the source."), array($interval));
             $v->setDefault('86400');
@@ -94,7 +94,7 @@ class FeedForm extends Horde_Form
             $this->addVariable(_("Image"), 'channel_img', 'text', false);
             break;
 
-        case JONAH_AGGREGATED_CHANNEL:
+        case Jonah::AGGREGATED_CHANNEL:
             $this->addHidden('', 'channel_url', 'text', false);
             $interval = Jonah_News::getIntervalLabel();
             $this->addVariable(_("Description"), 'channel_desc', 'text', false);
@@ -108,9 +108,9 @@ class FeedForm extends Horde_Form
             }
             break;
 
-        case JONAH_COMPOSITE_CHANNEL:
+        case Jonah::COMPOSITE_CHANNEL:
             global $news;
-            $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+            $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
             $enum = array();
             foreach ($channels as $channel) {
                 $enum[$channel['channel_id']] = $channel['channel_name'];
index cb619e6..8b56613 100644 (file)
@@ -4,33 +4,6 @@
  */
 
 /**
- * Internal Jonah channel.
- */
-define('JONAH_INTERNAL_CHANNEL', 0);
-
-/**
- * External channel.
- */
-define('JONAH_EXTERNAL_CHANNEL', 1);
-
-/**
- * Aggregated channel.
- */
-define('JONAH_AGGREGATED_CHANNEL', 2);
-
-/**
- * Composite channel.
- */
-define('JONAH_COMPOSITE_CHANNEL', 3);
-
-/**
- */
-define('JONAH_ORDER_PUBLISHED', 0);
-define('JONAH_ORDER_READ', 1);
-define('JONAH_ORDER_COMMENTS', 2);
-
-
-/**
  * Jonah Base Class.
  *
  * $Horde: jonah/lib/Jonah.php,v 1.141 2009/11/24 04:15:37 chuck Exp $
@@ -41,6 +14,33 @@ define('JONAH_ORDER_COMMENTS', 2);
  */
 class Jonah {
 
+
+    /**
+     * Internal Jonah channel.
+     */
+    const INTERNAL_CHANNEL = 0;
+
+    /**
+     * External channel.
+     */
+    const EXTERNAL_CHANNEL = 1;
+
+    /**
+     * Aggregated channel.
+     */
+    const AGGREGATED_CHANNEL = 2;
+
+    /**
+     * Composite channel.
+     */
+    const COMPOSITE_CHANNEL = 3;
+
+    /**
+     */
+    const ORDER_PUBLISHED = 0;
+    const ORDER_READ = 1;
+    const ORDER_COMMENTS = 2;
+
     /**
      */
     function _readURL($url)
@@ -103,16 +103,16 @@ class Jonah {
     function getChannelTypeLabel($type)
     {
         switch ($type) {
-        case JONAH_INTERNAL_CHANNEL:
+        case Jonah::INTERNAL_CHANNEL:
             return _("Local Feed");
 
-        case JONAH_EXTERNAL_CHANNEL:
+        case Jonah::EXTERNAL_CHANNEL:
             return _("External Feed");
 
-        case JONAH_AGGREGATED_CHANNEL:
+        case Jonah::AGGREGATED_CHANNEL:
             return _("Aggregated Feed");
 
-        case JONAH_COMPOSITE_CHANNEL:
+        case Jonah::COMPOSITE_CHANNEL:
             return _("Composite Feed");
         }
     }
@@ -174,9 +174,9 @@ class Jonah {
      */
     function typeToPermName($type)
     {
-        if ($type == JONAH_INTERNAL_CHANNEL) {
+        if ($type == Jonah::INTERNAL_CHANNEL) {
             return 'internal_channels';
-        } elseif ($type == JONAH_EXTERNAL_CHANNEL) {
+        } elseif ($type == Jonah::EXTERNAL_CHANNEL) {
             return 'external_channels';
         }
     }
@@ -249,7 +249,7 @@ class Jonah {
         if ($channel_id = Horde_Util::getFormData('channel_id')) {
             $news = Jonah_News::factory();
             $channel = $news->getChannel($channel_id);
-            if ($channel['channel_type'] == JONAH_INTERNAL_CHANNEL &&
+            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'));
             }
index de39706..5a39d8f 100644 (file)
@@ -84,7 +84,7 @@ class Jonah_News {
     /**
      * Checks if the channel is editable by first checking if the $channel_id
      * returns a valid channel array and then whether the channel type is
-     * JONAH_INTERNAL_CHANNEL, which is the only one to allow stories to be
+     * Jonah::INTERNAL_CHANNEL, which is the only one to allow stories to be
      * added.
      *
      * @param integer $channel_id  The channel id to check.
@@ -101,7 +101,7 @@ class Jonah_News {
         }
 
         /* Check if the channel type allows adding of stories. */
-        if ($channel['channel_type'] != JONAH_INTERNAL_CHANNEL) {
+        if ($channel['channel_type'] != Jonah::INTERNAL_CHANNEL) {
             return PEAR::raiseError(sprintf(_("Feed \"%s\" is not authored on this system."), $channel['channel_name']));
         }
 
@@ -123,14 +123,14 @@ class Jonah_News {
      *                             Defaults to false - only published stories.
      * @param integer $order       How to order the results for internal
      *                             channels. Possible values are the
-     *                             JONAH_ORDER_* constants.
+     *                             Jonah::ORDER_* constants.
      *
      * @return array  The specified number (or less, if there are fewer) of
      *                stories from the given channel.
      */
     function getStories($channel_id, $max = 10, $from = 0, $refresh = false,
                         $date = null, $unreleased = false,
-                        $order = JONAH_ORDER_PUBLISHED)
+                        $order = Jonah::ORDER_PUBLISHED)
     {
         $channel = $this->getChannel($channel_id);
         if (is_a($channel, 'PEAR_Error')) {
@@ -141,10 +141,10 @@ class Jonah_News {
         /* Fetch the stories according to channel type, using a
          * template method pattern for each type. */
         $funcs = array(
-            JONAH_INTERNAL_CHANNEL => '_getInternalStories',
-            JONAH_EXTERNAL_CHANNEL => '_getExternalStories',
-            JONAH_AGGREGATED_CHANNEL => '_getAggregatedStories',
-            JONAH_COMPOSITE_CHANNEL => '_getCompositeStories',
+            Jonah::INTERNAL_CHANNEL => '_getInternalStories',
+            Jonah::EXTERNAL_CHANNEL => '_getExternalStories',
+            Jonah::AGGREGATED_CHANNEL => '_getAggregatedStories',
+            Jonah::COMPOSITE_CHANNEL => '_getCompositeStories',
         );
 
         $func = $funcs[$channel['channel_type']];
@@ -155,7 +155,7 @@ class Jonah_News {
      */
     function _getInternalStories($channel, $max = 10, $from = 0, $refresh = false,
                                  $date = null, $unreleased = false,
-                                 $order = JONAH_ORDER_PUBLISHED)
+                                 $order = Jonah::ORDER_PUBLISHED)
     {
         return $GLOBALS['jonah_driver']->legacyGetStories($channel, $max, $from, $refresh, $date, $unreleased, $order);
     }
@@ -164,7 +164,7 @@ class Jonah_News {
      */
     function _getExternalStories($channel, $max = 10, $from = 0, $refresh = false,
                                  $date = null, $unreleased = false,
-                                 $order = JONAH_ORDER_PUBLISHED)
+                                 $order = Jonah::ORDER_PUBLISHED)
     {
         if ($refresh) {
             $channel['channel_interval'] = -1;
@@ -189,18 +189,18 @@ class Jonah_News {
      */
     function _getAggregatedStories($channel, $max = 10, $from = 0, $refresh = false,
                                    $date = null, $unreleased = false,
-                                   $order = JONAH_ORDER_PUBLISHED)
+                                   $order = Jonah::ORDER_PUBLISHED)
     {
         switch ($order) {
-        case JONAH_ORDER_PUBLISHED:
+        case Jonah::ORDER_PUBLISHED:
             $sort = 'story_published';
             break;
 
-        case JONAH_ORDER_READ:
+        case Jonah::ORDER_READ:
             $sort = 'story_read';
             break;
 
-        case JONAH_ORDER_COMMENTS:
+        case Jonah::ORDER_COMMENTS:
             //@TODO
             break;
         }
@@ -268,18 +268,18 @@ class Jonah_News {
      */
     function _getCompositeStories($channel, $max = 10, $from = 0, $refresh = false,
                                   $date = null, $unreleased = false,
-                                  $order = JONAH_ORDER_PUBLISHED)
+                                  $order = Jonah::ORDER_PUBLISHED)
     {
         switch ($order) {
-        case JONAH_ORDER_PUBLISHED:
+        case Jonah::ORDER_PUBLISHED:
             $sort = 'story_published';
             break;
 
-        case JONAH_ORDER_READ:
+        case Jonah::ORDER_READ:
             $sort = 'story_read';
             break;
 
-        case JONAH_ORDER_COMMENTS:
+        case Jonah::ORDER_COMMENTS:
             //@TODO
             break;
         }
@@ -341,7 +341,7 @@ class Jonah_News {
             if (is_a($channel, 'PEAR_Error')) {
                 return $channel;
             }
-            if ($channel['channel_type'] == JONAH_EXTERNAL_CHANNEL) {
+            if ($channel['channel_type'] == Jonah::EXTERNAL_CHANNEL) {
                 return $this->_getExternalStory($channel, $story_id);
             }
         }
@@ -468,16 +468,16 @@ class Jonah_News {
             return $types;
         }
         if (in_array('external', $GLOBALS['conf']['news']['enable'])) {
-            $types[JONAH_EXTERNAL_CHANNEL] = _("External Feed");
+            $types[Jonah::EXTERNAL_CHANNEL] = _("External Feed");
         }
         if (in_array('internal', $GLOBALS['conf']['news']['enable'])) {
-            $types[JONAH_INTERNAL_CHANNEL] = _("Local Feed");
+            $types[Jonah::INTERNAL_CHANNEL] = _("Local Feed");
         }
         if (in_array('aggregated', $GLOBALS['conf']['news']['enable'])) {
-            $types[JONAH_AGGREGATED_CHANNEL] = _("Aggregated Feed");
+            $types[Jonah::AGGREGATED_CHANNEL] = _("Aggregated Feed");
         }
         if (in_array('composite', $GLOBALS['conf']['news']['enable'])) {
-            $types[JONAH_COMPOSITE_CHANNEL] = _("Composite Feed");
+            $types[Jonah::COMPOSITE_CHANNEL] = _("Composite Feed");
         }
 
         return $types;
@@ -492,9 +492,9 @@ class Jonah_News {
     function getDefaultType()
     {
         if (in_array('external', $GLOBALS['conf']['news']['enable'])) {
-            return JONAH_EXTERNAL_CHANNEL;
+            return Jonah::EXTERNAL_CHANNEL;
         } else {
-            return JONAH_INTERNAL_CHANNEL;
+            return Jonah::INTERNAL_CHANNEL;
         }
     }
 
@@ -507,12 +507,12 @@ class Jonah_News {
      *                             null, all stories will be returned.
      * @param integer $from        The number of the story to start with.
      * @param integer $order       How to sort the results for internal channels
-     *                             Possible values are the JONAH_ORDER_*
+     *                             Possible values are the Jonah::ORDER_*
      *                             constants.
      *
      * @return string  The rendered story listing.
      */
-    function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = JONAH_ORDER_PUBLISHED)
+    function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = Jonah::ORDER_PUBLISHED)
     {
         $channel = $this->getChannel($channel_id);
         if (is_a($channel, 'PEAR_Error')) {
@@ -749,7 +749,6 @@ class Jonah_News {
         }
 
         /* Parse the feed. */
-        require_once JONAH_BASE . '/lib/FeedParser.php';
         $charset = empty($xml['charset']) ? 'utf-8' : $xml['charset'];
         $parser = new Jonah_FeedParser($charset);
         if (!$parser->parse($xml['body'])) {
@@ -825,7 +824,7 @@ class Jonah_News {
     }
 
     function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
-                            $order = JONAH_ORDER_PUBLISHED)
+                            $order = Jonah::ORDER_PUBLISHED)
     {
         return PEAR::raiseError(_("Tag support not enabled in backend."));
     }
index 79b681c..f0a2848 100644 (file)
@@ -118,9 +118,9 @@ class Jonah_News_sql extends Jonah_News {
      * Get a list of stored channels.
      *
      * @param integer $type  The type of channel to filter for. Possible
-     *                       values are either JONAH_INTERNAL_CHANNEL
+     *                       values are either Jonah::INTERNAL_CHANNEL
      *                       to fetch only a list of internal channels,
-     *                       or JONAH_EXTERNAL_CHANNEL for only external.
+     *                       or Jonah::EXTERNAL_CHANNEL for only external.
      *                       If null both channel types are returned.
      *
      * @return mixed         An array of channels or PEAR_Error on error.
@@ -177,7 +177,7 @@ class Jonah_News_sql extends Jonah_News {
         }
 
         $result['channel_name'] = Horde_String::convertCharset($result['channel_name'], $this->_params['charset']);
-        if ($result['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+        if ($result['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
             $channels = explode(':', $result['channel_url']);
             if (count($channels)) {
                 $sql = 'SELECT MAX(channel_updated) FROM jonah_channels WHERE channel_id IN (' . implode(',', $channels) . ')';
@@ -341,13 +341,13 @@ class Jonah_News_sql extends Jonah_News {
      * @param boolean $unreleased  Whether to return not yet released stories.
      * @param integer $order       How to order the results for internal
      *                             channels. Possible values are the
-     *                             JONAH_ORDER_* constants.
+     *                             Jonah::ORDER_* constants.
      *
      * @return array  The specified number (or less, if there are fewer) of
      *                stories from the given channel.
      */
     function _getStories($channel_id, $max, $from = 0, $date = null,
-                         $unreleased = false, $order = JONAH_ORDER_PUBLISHED)
+                         $unreleased = false, $order = Jonah::ORDER_PUBLISHED)
     {
         if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
             return $result;
@@ -372,13 +372,13 @@ class Jonah_News_sql extends Jonah_News {
         }
 
         switch ($order) {
-        case JONAH_ORDER_PUBLISHED:
+        case Jonah::ORDER_PUBLISHED:
             $sql .= ' ORDER BY story_published DESC';
             break;
-        case JONAH_ORDER_READ:
+        case Jonah::ORDER_READ:
             $sql .= ' ORDER BY story_read DESC';
             break;
-        case JONAH_ORDER_COMMENTS:
+        case Jonah::ORDER_COMMENTS:
             //@TODO
             break;
         }
@@ -665,7 +665,7 @@ class Jonah_News_sql extends Jonah_News {
             $channels = array();
             foreach ($channel_id as $cid) {
                 $c = $this->_getChannel($cid);
-                if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+                if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
                     $channels = array_merge($channels, explode(':', $c['channel_url']));
                 }
             }
@@ -690,12 +690,12 @@ class Jonah_News_sql extends Jonah_News {
      *                             present in these channels
      * @param integer $order       How to order the results for internal
      *                             channels. Possible values are the
-     *                             JONAH_ORDER_* constants.
+     *                             Jonah::ORDER_* constants.
      *
      * @return mixed  Array of stories| PEAR_Error
      */
     function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
-                            $order = JONAH_ORDER_PUBLISHED)
+                            $order = Jonah::ORDER_PUBLISHED)
     {
         if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
             return $result;
@@ -721,7 +721,7 @@ class Jonah_News_sql extends Jonah_News {
                 $channels = array();
                 foreach ($channel_id as $cid) {
                     $c = $this->_getChannel($cid);
-                    if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+                    if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
                         $temp = explode(':', $c['channel_url']);
                         // Save a map of channels that are from composites.
                         foreach ($temp as $t) {
@@ -738,13 +738,13 @@ class Jonah_News_sql extends Jonah_News {
             }
 
             switch ($order) {
-            case JONAH_ORDER_PUBLISHED:
+            case Jonah::ORDER_PUBLISHED:
                 $sql .= ' ORDER BY story_published DESC';
                 break;
-            case JONAH_ORDER_READ:
+            case Jonah::ORDER_READ:
                 $sql .= ' ORDER BY story_read DESC';
                 break;
-            case JONAH_ORDER_COMMENTS:
+            case Jonah::ORDER_COMMENTS:
                 //@TODO
                 break;
             }
@@ -795,7 +795,7 @@ class Jonah_News_sql extends Jonah_News {
      * @see Jonah_News_sql::searchTagsById()
      */
     function searchTags($names, $max = 10, $from = 0, $channel_id = array(),
-                        $order = JONAH_ORDER_PUBLISHED)
+                        $order = Jonah::ORDER_PUBLISHED)
     {
         $ids = $this->getTagIds($names);
         if (is_a($ids, 'PEAR_Error')) {
index fb3409c..0ec03ac 100644 (file)
@@ -77,8 +77,8 @@ foreach ($stories as $key => $story) {
     $stories[$key]['delete_link'] = '';
 
     /* These links only if internal channel. */
-    if ($channel['channel_type'] == JONAH_INTERNAL_CHANNEL ||
-        $channel['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+    if ($channel['channel_type'] == Jonah::INTERNAL_CHANNEL ||
+        $channel['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
         $stories[$key]['view_link'] = Horde::link(Horde::url($story['story_link']), $story['story_desc']) . htmlspecialchars($story['story_title']) . '</a>';
 
         /* PDF link. */
@@ -121,8 +121,8 @@ $template->set('header', htmlspecialchars($channel['channel_name']));
 $template->set('refresh', Horde::link(Horde_Util::addParameter(Horde::selfUrl(true), array('refresh' => 1)), _("Refresh Channel")) . Horde_Themes::img('reload.png') . '</a>');
 $template->set('listheaders', array(_("Story"), _("Date")));
 $template->set('stories', $stories, true);
-$template->set('read', $channel['channel_type'] == JONAH_INTERNAL_CHANNEL || $channel['channel_type'] == JONAH_COMPOSITE_CHANNEL, true);
-$template->set('comments', $conf['comments']['allow'] && $registry->hasMethod('forums/numMessages') && $channel['channel_type'] == JONAH_INTERNAL_CHANNEL, true);
+$template->set('read', $channel['channel_type'] == Jonah::INTERNAL_CHANNEL || $channel['channel_type'] == Jonah::COMPOSITE_CHANNEL, true);
+$template->set('comments', $conf['comments']['allow'] && $registry->hasMethod('forums/numMessages') && $channel['channel_type'] == Jonah::INTERNAL_CHANNEL, true);
 $template->set('menu', Jonah::getMenu('string'));
 
 // Buffer the notifications and send to the template
index b4c5398..83ef79c 100644 (file)
@@ -25,7 +25,7 @@ if (!is_null($channel_id)) {
     $channel_ids = array($channel_id);
 } else {
     $channel_ids = array();
-    $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+    $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
     foreach ($channels as $ch) {
         if (Jonah::checkPermissions(Jonah::typeToPermName($ch['channel_type']), Horde_Perms::SHOW, $ch['channel_id'])) {
             $channel_ids[] = $ch['channel_id'];
@@ -79,14 +79,14 @@ foreach ($stories as $key => $story) {
     $stories[$key]['pdf_link'] = Horde::link($url, _("PDF version")) . Horde_Themes::img('mime/pdf.png') . '</a>';
 
     /* Edit story link. */
-    if (Jonah::checkPermissions(Jonah::typeToPermName(JONAH_INTERNAL_CHANNEL), Horde_Perms::EDIT, $channel_id)) {
+    if (Jonah::checkPermissions(Jonah::typeToPermName(Jonah::INTERNAL_CHANNEL), Horde_Perms::EDIT, $channel_id)) {
         $url = Horde::applicationUrl('stories/edit.php');
         $url = Horde_Util::addParameter($url, array('story_id' => $story['story_id'], 'channel_id' => $channel_id));
         $stories[$key]['edit_link'] = Horde::link($url, _("Edit story")) . Horde_Themes::img('edit.png') . '</a>';
     }
 
     /* Delete story link. */
-    if (Jonah::checkPermissions(Jonah::typeToPermName(JONAH_INTERNAL_CHANNEL), Horde_Perms::DELETE, $channel_id)) {
+    if (Jonah::checkPermissions(Jonah::typeToPermName(Jonah::INTERNAL_CHANNEL), Horde_Perms::DELETE, $channel_id)) {
         $url = Horde::applicationUrl('stories/delete.php');
         $url = Horde_Util::addParameter($url, array('story_id' => $story['story_id'], 'channel_id' => $channel_id));
         $stories[$key]['delete_link'] = Horde::link($url, _("Delete story")) . Horde_Themes::img('delete.png') . '</a>';