atomlistnoticefeed.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Class for building an in-memory Atom feed for a particular list's
  6. * timeline.
  7. *
  8. * PHP version 5
  9. *
  10. * LICENCE: This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * @category Feed
  24. * @package StatusNet
  25. * @author Zach Copley <zach@status.net>
  26. * @copyright 2010 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('STATUSNET'))
  31. {
  32. exit(1);
  33. }
  34. /**
  35. * Class for list notice feeds. May contain a reference to the list.
  36. *
  37. * @category Feed
  38. * @package StatusNet
  39. * @author Zach Copley <zach@status.net>
  40. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  41. * @link http://status.net/
  42. */
  43. class AtomListNoticeFeed extends AtomNoticeFeed
  44. {
  45. private $list;
  46. private $tagger;
  47. /**
  48. * Constructor
  49. *
  50. * @param List $list the list for the feed
  51. * @param User $cur the current authenticated user, if any
  52. * @param boolean $indent flag to turn indenting on or off
  53. *
  54. * @return void
  55. */
  56. function __construct($list, $cur = null, $indent = true) {
  57. parent::__construct($cur, $indent);
  58. $this->list = $list;
  59. $this->tagger = Profile::getKV('id', $list->tagger);
  60. // TRANS: Title in atom list notice feed. %1$s is a list name, %2$s is a tagger's nickname.
  61. $title = sprintf(_('Timeline for people in list %1$s by %2$s'), $list->tag, $this->tagger->nickname);
  62. $this->setTitle($title);
  63. $sitename = common_config('site', 'name');
  64. $subtitle = sprintf(
  65. // TRANS: Message is used as a subtitle in atom list notice feed.
  66. // TRANS: %1$s is a tagger's nickname, %2$s is a list name, %3$s is a site name.
  67. _('Updates from %1$s\'s list %2$s on %3$s!'),
  68. $this->tagger->nickname,
  69. $list->tag,
  70. $sitename
  71. );
  72. $this->setSubtitle($subtitle);
  73. $avatar = $this->tagger->avatarUrl(AVATAR_PROFILE_SIZE);
  74. $this->setLogo($avatar);
  75. $this->setUpdated('now');
  76. $self = common_local_url('ApiTimelineList',
  77. array('user' => $this->tagger->nickname,
  78. 'id' => $list->tag,
  79. 'format' => 'atom'));
  80. $this->setId($self);
  81. $this->setSelfLink($self);
  82. $ao = ActivityObject::fromPeopletag($this->list);
  83. $this->addAuthorRaw($ao->asString('author'));
  84. $this->addLink($this->list->getUri());
  85. }
  86. function getList()
  87. {
  88. return $this->list;
  89. }
  90. }