stubs for recent feeds. needs some work in Horde_Feed for RSS to work and to fix...
authorChuck Hagenbuch <chuck@horde.org>
Tue, 20 Jan 2009 05:16:36 +0000 (00:16 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Tue, 20 Jan 2009 05:20:39 +0000 (00:20 -0500)
content/app/controllers/TagController.php

index ce4764c..7fcc147 100644 (file)
@@ -56,7 +56,7 @@ class TagController extends Content_ApplicationController
      */
     public function tag()
     {
-        // Routes enforce POST or PUT only, but double-check here.
+        // The route configuration enforces POST or PUT only, but double-check here.
     }
 
     /**
@@ -64,7 +64,7 @@ class TagController extends Content_ApplicationController
      */
     public function untag()
     {
-        // Routes enforce POST or DELETE only, but double-check here.
+        // The route configuration enforces POST or DELETE only, but double-check here.
     }
 
 
@@ -75,6 +75,12 @@ class TagController extends Content_ApplicationController
             $this->render();
             break;
 
+        case 'atom':
+        case 'rss':
+            $method = '_' . $this->_action . 'Feed';
+            $this->$method();
+            break;
+
         case 'json':
         default:
             $this->renderText(json_encode($this->results));
@@ -82,4 +88,76 @@ class TagController extends Content_ApplicationController
         }
     }
 
+    protected function _recentTagsFeed()
+    {
+        $entries = array();
+        foreach ($this->results as $tag) {
+            $entries[] = array(
+                'id' => 'tag/' . $tag['tag_id'], /* @TODO use routes to get the full URI here */
+                'title' => $tag['tag_name'],
+                'updated' => $tag['created'],
+            );
+        }
+
+        $format = $this->_request->getFormat();
+        $class = 'Horde_Feed_' . ucfirst((string)$this->_request->getFormat());
+        $feed = new $class(array(
+            'id' => 'tags/recent', /* @TODO Use routes to get url to this search */
+            'title' => 'Recent tags',
+            'updated' => $this->_request->getTimestamp(),
+            'entry' => $entries,
+
+        ));
+        header('Content-type: ' . $format->string);
+        $this->renderText($feed->saveXml());
+    }
+
+    protected function _recentObjectsFeed()
+    {
+        $entries = array();
+        foreach ($this->results as $object) {
+            $entries[] = array(
+                'id' => 'object/' . $object['object_id'], /* @TODO use routes to get the full URI here */
+                'title' => $object['object_name'],
+                'updated' => $object['created'],
+            );
+        }
+
+        $format = $this->_request->getFormat();
+        $class = 'Horde_Feed_' . ucfirst((string)$this->_request->getFormat());
+        $feed = new $class(array(
+            'id' => 'objects/recent', /* @TODO Use routes to get url to this search */
+            'title' => 'Recent objects',
+            'updated' => $this->_request->getTimestamp(),
+            'entry' => $entries,
+
+        ));
+        header('Content-type: ' . $format->string);
+        $this->renderText($feed->saveXml());
+    }
+
+    protected function _recentUsersFeed()
+    {
+        $entries = array();
+        foreach ($this->results as $user) {
+            $entries[] = array(
+                'id' => 'user/' . $user['user_id'], /* @TODO use routes to get the full URI here */
+                'title' => $user['user_name'],
+                'updated' => $user['created'],
+            );
+        }
+
+        $format = $this->_request->getFormat();
+        $class = 'Horde_Feed_' . ucfirst((string)$this->_request->getFormat());
+        $feed = new $class(array(
+            'id' => 'users/recent', /* @TODO Use routes to get url to this search */
+            'title' => 'Recent users',
+            'updated' => $this->_request->getTimestamp(),
+            'entry' => $entries,
+
+        ));
+        header('Content-type: ' . $format->string);
+        $this->renderText($feed->saveXml());
+    }
+
 }