summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2007-05-14 02:04:58 +0000
committerxue <>2007-05-14 02:04:58 +0000
commit0e12d563f7adbcbb063131a32d813608e08fdf80 (patch)
tree65d4e5ac3fd83c30916c7f5717f9210d14bdd129 /framework
parentc418f46c7525a6b06242298203553bf6066d630b (diff)
cleaned up TFeedService.
Diffstat (limited to 'framework')
-rw-r--r--framework/Exceptions/messages.txt5
-rw-r--r--framework/Web/Services/IFeedContentProvider.php7
-rw-r--r--framework/Web/Services/TFeedService.php76
-rw-r--r--framework/Web/Services/TSoapService.php2
4 files changed, 34 insertions, 56 deletions
diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt
index bd54d1cf..528b5c62 100644
--- a/framework/Exceptions/messages.txt
+++ b/framework/Exceptions/messages.txt
@@ -396,3 +396,8 @@ dbusermanager_userclass_required = TDbUserManager.UserClass is required.
dbusermanager_userclass_invalid = TDbUserManager.UserClass '{0}' is not a valid user class. The class must extend TDbUser.
dbusermanager_connectionid_invalid = TDbUserManager.ConnectionID '{0}' does not point to a valid TDataSourceConfig module.
dbusermanager_connectionid_required = TDbUserManager.ConnectionID is required.
+
+feedservice_id_required = TFeedService requires 'id' attribute in its feed elements.
+feedservice_feedtype_invalid = The class feed '{0}' must implement IFeedContentProvider interface.
+feedservice_class_required = TFeedService requires 'class' attribute in its feed elements.
+feedservice_feed_unknown = Unknown feed '{0}' requested.
diff --git a/framework/Web/Services/IFeedContentProvider.php b/framework/Web/Services/IFeedContentProvider.php
deleted file mode 100644
index 0ba972f6..00000000
--- a/framework/Web/Services/IFeedContentProvider.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-interface IFeedContentProvider {
- public function getFeedContent();
-}
-
-?> \ No newline at end of file
diff --git a/framework/Web/Services/TFeedService.php b/framework/Web/Services/TFeedService.php
index e1f38f04..00a251a7 100644
--- a/framework/Web/Services/TFeedService.php
+++ b/framework/Web/Services/TFeedService.php
@@ -5,8 +5,9 @@
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Knut Urdalen <knut.urdalen@gmail.com>
* @link http://www.pradosoft.com
- * @copyright Copyright &copy; 2006 PradoSoft
+ * @copyright Copyright &copy; 2006-2007 PradoSoft
* @license http://www.pradosoft.com/license/
+ * @version $Id$
* @package System.Web.Services
*/
@@ -15,23 +16,25 @@
*
* TFeedService provides to end-users feed content.
*
- * TFeedService manages a set of {@link TFeed}, each representing specific feed content.
- * The service parameter, referring to the ID of the feed, specifies
- * which feed content to be provided to end-users.
+ * TFeedService manages a set of feeds. The service parameter, referring
+ * to the ID of the feed, specifies which feed content to be provided to end-users.
*
* To use TFeedService, configure it in application configuration as follows,
* <code>
- * <service id="feed" class="System.Services.TFeedService">
+ * <service id="feed" class="System.Web.Services.TFeedService">
* <feed id="ch1" class="Path.To.FeedClass1" .../>
* <feed id="ch2" class="Path.To.FeedClass2" .../>
* <feed id="ch3" class="Path.To.FeedClass3" .../>
* </service>
* </code>
- * where each feed is specified via a &lt;feed&gt; element. Initial property
- * values can be configured in a &lt;feed&gt; element.
+ * where each &lt;feed&gt; element specifies a feed identified by its "id" value (case-sensitive).
+ * The class attribute indicates which PHP class will provide the actual feed
+ * content. Note, the class must implement {@link IFeedContentProvider} interface.
+ * Other initial properties for the feed class may also be specified in the
+ * corresponding &lt;feed&gt; element.
*
- * To retrieve the feed content provided by "ch2", use the URL
- * <code>index.php?feed=ch2</code>
+ * To retrieve the feed content identified by "ch2", use the URL
+ * <code>/path/to/index.php?feed=ch2</code>
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Knut Urdalen <knut.urdalen@gmail.com>
@@ -51,7 +54,7 @@ class TFeedService extends TService
{
foreach($config->getElementsByTagName('feed') as $feed)
{
- if(($id=$feed->getAttribute('id'))!==null)
+ if(($id=$feed->getAttributes()->removeAttribute('id'))!==null)
$this->_feeds[$id]=$feed;
else
throw new TConfigurationException('feedservice_id_required');
@@ -80,7 +83,7 @@ class TFeedService extends TService
if(($class=$properties->remove('class'))!==null)
{
$feed=Prado::createComponent($class);
- if($feed instanceof TFeed)
+ if($feed instanceof IFeedContentProvider)
{
// init feed properties
foreach($properties as $name=>$value)
@@ -104,53 +107,30 @@ class TFeedService extends TService
}
/**
- * TFeed class.
- *
- * TFeed is the base class for all feed provider classes.
+ * IFeedContentProvider interface.
*
- * Derived classes should override {@link getFeedContent()} to return
- * an XML string that represents the feed content.
+ * IFeedContentProvider interface must be implemented by a feed class who
+ * provides feed content.
*
* @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id$
- * @package System.Services
+ * @author Knut Urdalen <knut.urdalen@gmail.com>
+ * @package System.Web.Services
* @since 3.1
*/
-abstract class TFeed extends TApplicationComponent
+interface IFeedContentProvider
{
- private $_id='';
-
- /**
- * Initializes the feed.
- * @param TXmlElement configurations specified in {@link TFeedService}.
- */
- public function init($config)
- {
- }
-
/**
- * @return string ID of this feed
+ * Initializes the feed content provider.
+ * This method is invoked (before {@link getFeedContent})
+ * when the feed provider is requested by a user.
+ * @param TXmlElement configurations specified within the &lt;feed&gt; element
+ * corresponding to this feed provider when configuring {@link TFeedService}.
*/
- public function getID()
- {
- return $this->_id;
- }
-
+ public function init($config);
/**
- * @param string ID of this feed
+ * @return string feed content in proper XML format
*/
- public function setID($value)
- {
- $this->_id=$value;
- }
-
- /**
- * @return string an XML string representing the feed content
- */
- public function getFeedContent()
- {
- return '';
- }
+ public function getFeedContent();
}
?> \ No newline at end of file
diff --git a/framework/Web/Services/TSoapService.php b/framework/Web/Services/TSoapService.php
index e598d796..e2f91df2 100644
--- a/framework/Web/Services/TSoapService.php
+++ b/framework/Web/Services/TSoapService.php
@@ -5,7 +5,7 @@
* @author Knut Urdalen <knut.urdalen@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2006 PradoSoft
+ * @copyright Copyright &copy; 2006-2007 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.Services