atomusernoticefeed.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Class for building an in-memory Atom feed for a particular user'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 user notice feeds. May contain a reference to the user.
  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 AtomUserNoticeFeed extends AtomNoticeFeed
  44. {
  45. protected $user;
  46. /**
  47. * Constructor
  48. *
  49. * @param User $user the user for the feed
  50. * @param User $cur the current authenticated user, if any
  51. * @param boolean $indent flag to turn indenting on or off
  52. *
  53. * @return void
  54. */
  55. function __construct($user, $cur = null, $indent = true) {
  56. parent::__construct($cur, $indent);
  57. $this->user = $user;
  58. if (!empty($user)) {
  59. $profile = $user->getProfile();
  60. $ao = $profile->asActivityObject();
  61. array_push($ao->extra, $profile->profileInfo($this->scoped));
  62. $this->addAuthorRaw($ao->asString('author'));
  63. }
  64. // TRANS: Title in atom user notice feed. %s is a user name.
  65. $title = sprintf(_("%s timeline"), $user->nickname);
  66. $this->setTitle($title);
  67. $sitename = common_config('site', 'name');
  68. $subtitle = sprintf(
  69. // TRANS: Message is used as a subtitle in atom user notice feed.
  70. // TRANS: %1$s is a user name, %2$s is a site name.
  71. _('Updates from %1$s on %2$s!'),
  72. $user->nickname, $sitename
  73. );
  74. $this->setSubtitle($subtitle);
  75. $this->setLogo($profile->avatarUrl(AVATAR_PROFILE_SIZE));
  76. $this->setUpdated('now');
  77. $this->addLink(
  78. common_local_url(
  79. 'showstream',
  80. array('nickname' => $user->nickname)
  81. )
  82. );
  83. $self = common_local_url('ApiTimelineUser',
  84. array('id' => $user->id,
  85. 'format' => 'atom'));
  86. $this->setId($self);
  87. $this->setSelfLink($self);
  88. $this->addLink(
  89. common_local_url('sup', null, null, $user->id),
  90. array(
  91. 'rel' => 'http://api.friendfeed.com/2008/03#sup',
  92. 'type' => 'application/json'
  93. )
  94. );
  95. }
  96. function getUser()
  97. {
  98. return $this->user;
  99. }
  100. function showSource()
  101. {
  102. return false;
  103. }
  104. function showAuthor()
  105. {
  106. return false;
  107. }
  108. }