tagrss.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * StatusNet - the distributed open-source microblogging tool
  4. * Copyright (C) 2008, 2009, StatusNet, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. if (!defined('GNUSOCIAL')) { exit(1); }
  20. // Formatting of RSS handled by Rss10Action
  21. class TagrssAction extends Rss10Action
  22. {
  23. protected $tag;
  24. protected function doStreamPreparation()
  25. {
  26. $tag = common_canonical_tag($this->trimmed('tag'));
  27. $this->tag = Notice_tag::getKV('tag', $tag);
  28. if (!$this->tag instanceof Notice_tag) {
  29. // TRANS: Client error when requesting a tag feed for a non-existing tag.
  30. $this->clientError(_('No such tag.'));
  31. }
  32. }
  33. protected function getNotices()
  34. {
  35. $stream = Notice_tag::getStream($this->tag->tag)->getNotices(0, $this->limit);
  36. return $stream->fetchAll();
  37. }
  38. function getChannel()
  39. {
  40. $tagname = $this->tag->tag;
  41. $c = array('url' => common_local_url('tagrss', array('tag' => $tagname)),
  42. 'title' => $tagname,
  43. 'link' => common_local_url('tagrss', array('tag' => $tagname)),
  44. // TRANS: Tag feed description.
  45. // TRANS: %1$s is the tag name, %2$s is the StatusNet sitename.
  46. 'description' => sprintf(_('Updates tagged with %1$s on %2$s!'),
  47. $tagname, common_config('site', 'name')));
  48. return $c;
  49. }
  50. function isReadOnly($args)
  51. {
  52. return true;
  53. }
  54. }