diff options
-rw-r--r-- | core/config/routes.php | 1 | ||||
-rw-r--r-- | core/models/item.php | 2 | ||||
-rw-r--r-- | modules/media_rss/controllers/media_rss.php | 70 | ||||
-rw-r--r-- | modules/media_rss/views/media.rss.php | 10 |
4 files changed, 19 insertions, 64 deletions
diff --git a/core/config/routes.php b/core/config/routes.php index 4da97654..0e2aa887 100644 --- a/core/config/routes.php +++ b/core/config/routes.php @@ -22,6 +22,7 @@ // The problem is that we're routing all requests to /{controllername} to Rest_Controller, // even requests to controllers that do not implement Rest_Controller. $config['^welcome$'] = 'welcome'; +$config['^media_rss/feed/(\d+)'] = 'media_rss/feed/$1'; // REST configuration // Any resource requests (eg: album/1 or comment/3) get dispatched to the REST diff --git a/core/models/item.php b/core/models/item.php index 0b576d2c..950be499 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -176,7 +176,7 @@ class Item_Model extends ORM_MPTT { return "<span class=\"gInPlaceEdit gEditField-{$this->id}-{$real_column}\">" . "{$this->$real_column}</span>"; } else if ($column == "mime_type") { - if ($this->is_album() || ($mime_type = file::mime()) === false) { + if ($this->is_album() || ($mime_type = file::mime($this->file_path())) === false) { $mime_type = "application/unknown"; } return $mime_type; diff --git a/modules/media_rss/controllers/media_rss.php b/modules/media_rss/controllers/media_rss.php index 7189987b..1275c7db 100644 --- a/modules/media_rss/controllers/media_rss.php +++ b/modules/media_rss/controllers/media_rss.php @@ -17,68 +17,22 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class Media_rss_Controller extends REST_Controller { - // @todo this should be retrieved from the slideshow configuration - public static $LIMIT = 10; - - protected $resource_type = "item"; - - /** - * @see Rest_Controller::_index() - */ - public function _index() { - throw new Exception("@todo Item_Controller::_index NOT IMPLEMENTED"); - } - - /** - * @see Rest_Controller::_create() - */ - public function _create($resource) { - throw new Exception("@todo Item_Controller::_create NOT IMPLEMENTED"); - } - - public function _show($parent, $output_format) { - if ($output_format != "mediarss") { - throw new Exception("@todo Unsupported output format: $output_format"); +class Media_RSS_Controller extends Controller { + public function feed($id) { + $item = ORM::factory("item", $id)->find(); + if (!$item->loaded) { + return Kohana::show_404(); } - $offset = $this->input->get("offset", 0); - $view = new View("media.rss"); - $view->item = $parent; + $view->item = $item; - // @todo create a descendent child method on ORM_MTPP to get all of the children -// $view->children = $parent->descendents(); - } + // This should probably be a method in ORM_MPTT + $view->children = ORM::factory("item") + ->where("parent_id", $item->id) + ->where("type", "photo") + ->find_all(); - /** - * @see Rest_Controller::_update() - */ - public function _update($resource) { - throw new Exception("@todo Item_Controller::_update NOT IMPLEMENTED"); - } - - /** - * @see Rest_Controller::_delete() - */ - public function _delete($resource) { - throw new Exception("@todo Item_Controller::_delete NOT IMPLEMENTED"); - } - - /** - * @see Rest_Controller::_form_add() - */ - public function _form_add($parameter) { - throw new Exception("@todo Item_Controller::_form_add NOT IMPLEMENTED"); - } - /** - * @see Rest_Controller::_form_edit() - */ - public function _form_edit($resource) { - throw new Exception("@todo Item_Controller::_form_edit NOT IMPLEMENTED"); - } - - protected function get_output_format() { - return "mediarss"; + print $view; } }
\ No newline at end of file diff --git a/modules/media_rss/views/media.rss.php b/modules/media_rss/views/media.rss.php index 26f6b1fe..4fa5c163 100644 --- a/modules/media_rss/views/media.rss.php +++ b/modules/media_rss/views/media.rss.php @@ -8,10 +8,10 @@ <description><?= $item->description ?></description> <language>en-us</language> <? if (isset($prevOffset)): ?> - <atom:link rel="previous" href="<?= url::site("media_rss/$item->id?offset=\"$prevOffset\"") ?>" /> + <atom:link rel="previous" href="<?= url::site("media_rss/feed/{$item->id}?offset={$prevOffset}") ?>" /> <? endif; ?> <? if (isset($nextOffset)): ?> - <atom:link rel="next" href="href="<?= url::site("media_rss/$item->id?offset=\"$nextOffset\"") ?>"/> + <atom:link rel="next" href="href="<?= url::site("media_rss/feed/{$item->id}?offset={$nextOffset}") ?>"/> <? endif; ?> <? // @todo do we want to add an upload date to the items table? @@ -25,13 +25,13 @@ <link></link> <guid><?= $child->id ?></guid> <description type="html"><?= $child->description ?></description> - <media:thumbnail url="<?= $child->thumbnail_url() ?>" - type="<?= $child->mine_type ?>" + <media:thumbnail url="<?= $child->thumbnail_url() ?>" + type="<?= $child->mime_type ?>" height="<?= $child->thumbnail_height ?>" width="<?= $child->thumbnail_width ?>" /> <media:content url="<?= $child->resize_url() ?>" - type="<?= $child->mine_type ?>" + type="<?= $child->mime_type ?>" height="<?= $child->resize_height ?>" width="<?= $child->resize_width ?>" /> |