From: Chuck Hagenbuch Date: Tue, 20 Jan 2009 04:09:45 +0000 (-0500) Subject: add recent tags action X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=604bf1e6b4285797d439ee7a1fc789373b7416ac;p=horde.git add recent tags action --- diff --git a/content/app/controllers/TagController.php b/content/app/controllers/TagController.php index 0e14c1ef3..ce4764cd7 100644 --- a/content/app/controllers/TagController.php +++ b/content/app/controllers/TagController.php @@ -12,39 +12,51 @@ class TagController extends Content_ApplicationController */ public function searchTags() { - $this->tags = $this->tagger->getTags(array( + $this->results = $this->tagger->getTags(array( 'q' => $this->params->q, 'typeId' => $this->params->typeId, 'userId' => $this->params->userId, 'objectId' => $this->params->objectId, )); - switch ((string)$this->_request->getFormat()) { - case 'html': - $this->render(); - break; + $this->_render(); + } - case 'json': - default: - $this->renderText(json_encode($this->tags)); - break; - } + /** + */ + public function recentTags() + { + $this->results = $this->tagger->getRecentTags(array( + 'limit' => 10, + 'typeId' => $this->params->typeId, + 'objectId' => $this->params->objectId, + )); + + $this->_render(); } public function searchUsers() { } + public function recentUsers() + { + } + public function searchObjects() { } + public function recentObjects() + { + } + /** * Add a tag */ public function tag() { - // Enforce POST only + // Routes enforce POST or PUT only, but double-check here. } /** @@ -52,7 +64,22 @@ class TagController extends Content_ApplicationController */ public function untag() { - // Enforce POST only + // Routes enforce POST or DELETE only, but double-check here. + } + + + protected function _render() + { + switch ((string)$this->_request->getFormat()) { + case 'html': + $this->render(); + break; + + case 'json': + default: + $this->renderText(json_encode($this->results)); + break; + } } } diff --git a/content/app/views/Tag/recentTags.html.php b/content/app/views/Tag/recentTags.html.php new file mode 100644 index 000000000..d069cec3e --- /dev/null +++ b/content/app/views/Tag/recentTags.html.php @@ -0,0 +1,5 @@ + diff --git a/content/app/views/Tag/searchTags.html.php b/content/app/views/Tag/searchTags.html.php index 1fa37e010..5aeaf2e81 100644 --- a/content/app/views/Tag/searchTags.html.php +++ b/content/app/views/Tag/searchTags.html.php @@ -1,5 +1,5 @@ diff --git a/content/config/routes.php b/content/config/routes.php index 5d08243cd..1356835cb 100644 --- a/content/config/routes.php +++ b/content/config/routes.php @@ -13,6 +13,12 @@ $mapper->connect('tags', array('controller' => 'tag', 'action' => 'searchTags')); $mapper->connect('tags.:(format)', array('controller' => 'tag', 'action' => 'searchTags')); +// Most recent tags. Available query parameters: +// typeId: restrict matches to tags that have been applied to objects with type $typeId +// userId: restrict matches to tags that have been applied by $userId +$mapper->connect('tags/recent', array('controller' => 'tag', 'action' => 'recentTags')); +$mapper->connect('tags/recent.:(format)', array('controller' => 'tag', 'action' => 'recentTags')); + // List objects. At least a content type, or more specific parameters, are // required; listing all objects is not allowed. $mapper->connect('objects', array('controller' => 'tag', 'action' => 'searchObjects'));