1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
<?php
/**
* @package Content
*/
/**
* @package Content
*/
class TagController extends Content_ApplicationController
{
/**
*/
public function searchTags()
{
$this->results = $this->tagger->getTags(array(
'q' => $this->params->q,
'typeId' => $this->params->typeId,
'userId' => $this->params->userId,
'objectId' => $this->params->objectId,
));
$this->_render();
}
/**
*/
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()
{
// The route configuration enforces POST or PUT only, but double-check here.
}
/**
* Remove a tag
*/
public function untag()
{
// The route configuration enforces POST or DELETE only, but double-check here.
}
protected function _render()
{
switch ((string)$this->_request->getFormat()) {
case 'html':
$this->render();
break;
case 'atom':
case 'rss':
$method = '_' . $this->_action . 'Feed';
$this->$method();
break;
case 'json':
default:
$this->renderText(json_encode($this->results));
break;
}
}
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());
}
}
|