photo.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * GNU Social
  4. * Copyright (C) 2010, Free Software Foundation, Inc.
  5. *
  6. * PHP version 5
  7. *
  8. * LICENCE:
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Widget
  23. * @package GNU Social
  24. * @author Ian Denhardt <ian@zenhack.net>
  25. * @author Sean Corbett <sean@gnu.org>
  26. * @author Max Shinn <trombonechamp@gmail.com>
  27. * @copyright 2010 Free Software Foundation, Inc.
  28. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  29. */
  30. if (!defined('GNUSOCIAL')) { exit(1); }
  31. class PhotoAction extends ManagedAction
  32. {
  33. var $user = null;
  34. var $conv = null; // Conversation dataobject
  35. protected function prepare(array $args=array())
  36. {
  37. parent::prepare($args);
  38. $args = $this->returnToArgs();
  39. $this->photoid = $args[1]['photoid'];
  40. $this->photo = GNUsocialPhoto::getKV('id', $this->photoid);
  41. $this->notice = Notice::getKV('id', $this->photo->notice_id);
  42. $this->user = Profile::getKV('id', $this->notice->profile_id);
  43. $this->conv = $this->notice->getConversation();
  44. return true;
  45. }
  46. function title()
  47. {
  48. if (empty($this->user)) {
  49. return _m('No such user.');
  50. } else if (empty($this->photo)) {
  51. return _m('No such photo.');
  52. } else if (!empty($this->photo->title)) {
  53. return $this->photo->title;
  54. } else {
  55. return sprintf(_m("%s's Photo."), $this->user->nickname);
  56. }
  57. }
  58. function showLocalNav()
  59. {
  60. $nav = new GNUsocialPhotoNav($this, $this->user->nickname);
  61. $nav->show();
  62. }
  63. function showContent()
  64. {
  65. if(empty($this->user)) {
  66. return;
  67. }
  68. $this->elementStart('a', array('href' => $this->photo->uri));
  69. $this->element('img', array('src' => $this->photo->uri));
  70. $this->elementEnd('a');
  71. //Image "toolbar"
  72. $cur = common_current_user();
  73. if($this->photo->profile_id == $cur->profile_id) {
  74. $this->elementStart('div', array('id' => 'image_toolbar'));
  75. $this->element('a', array('href' => '/editphoto/' . $this->photo->id), 'Edit');
  76. $this->elementEnd('div');
  77. }
  78. $this->element('p', array('class' => 'photodescription'), $this->photo->photo_description);
  79. //This is a hack to hide the top-level comment
  80. $this->element('style', array(), "#notice-{$this->photo->notice_id} div { display: none } #notice-{$this->photo->notice_id} ol li div { display: inline }");
  81. if (Event::handle('StartShowConversation', array($this, $this->conv, $this->scoped))) {
  82. $notices = $this->conv->getNotices();
  83. $nl = new FullThreadedNoticeList($notices, $this, $this->scoped);
  84. $cnt = $nl->show();
  85. }
  86. Event::handle('EndShowConversation', array($this, $this->conv, $this->scoped));
  87. }
  88. }