galleryaction.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. // 10x8
  21. define('AVATARS_PER_PAGE', 80);
  22. // @todo FIXME: Class documentation missing.
  23. class GalleryAction extends ProfileAction
  24. {
  25. protected function handle()
  26. {
  27. // Post from the tag dropdown; redirect to a GET
  28. if ($this->isPost()) {
  29. common_redirect($this->selfUrl(), 303);
  30. }
  31. parent::handle();
  32. }
  33. function showContent()
  34. {
  35. $this->showTagsDropdown();
  36. }
  37. function showTagsDropdown()
  38. {
  39. $tag = $this->trimmed('tag');
  40. $tags = $this->getAllTags();
  41. $content = array();
  42. foreach ($tags as $t) {
  43. $content[$t] = $t;
  44. }
  45. if ($tags) {
  46. $this->elementStart('dl', array('id' => 'filter_tags'));
  47. $this->element('dt', null, _('Tags'));
  48. $this->elementStart('dd');
  49. $this->elementStart('ul');
  50. $this->elementStart('li', array('id' => 'filter_tags_all',
  51. 'class' => 'child_1'));
  52. $this->element('a',
  53. array('href' =>
  54. common_local_url($this->trimmed('action'),
  55. array('nickname' =>
  56. $this->target->getNickname()))),
  57. // TRANS: List element on gallery action page to show all tags.
  58. _m('TAGS','All'));
  59. $this->elementEnd('li');
  60. $this->elementStart('li', array('id'=>'filter_tags_item'));
  61. $this->elementStart('form', array('name' => 'bytag',
  62. 'id' => 'form_filter_bytag',
  63. 'action' => common_path('?action=' . $this->getActionName()),
  64. 'method' => 'post'));
  65. $this->elementStart('fieldset');
  66. // TRANS: Fieldset legend on gallery action page.
  67. $this->element('legend', null, _('Select tag to filter'));
  68. // TRANS: Dropdown field label on gallery action page for a list containing tags.
  69. $this->dropdown('tag', _('Tag'), $content,
  70. // TRANS: Dropdown field title on gallery action page for a list containing tags.
  71. _('Choose a tag to narrow list.'), false, $tag);
  72. $this->hidden('nickname', $this->target->getNickname());
  73. // TRANS: Submit button text on gallery action page.
  74. $this->submit('submit', _m('BUTTON','Go'));
  75. $this->elementEnd('fieldset');
  76. $this->elementEnd('form');
  77. $this->elementEnd('li');
  78. $this->elementEnd('ul');
  79. $this->elementEnd('dd');
  80. $this->elementEnd('dl');
  81. }
  82. }
  83. // Get list of tags we tagged other users with
  84. function getTags($lst, $usr)
  85. {
  86. $profile_tag = new Notice_tag();
  87. $profile_tag->query('SELECT DISTINCT(tag) ' .
  88. 'FROM profile_tag, subscription ' .
  89. 'WHERE tagger = ' . $this->target->id . ' ' .
  90. 'AND ' . $usr . ' = ' . $this->target->id . ' ' .
  91. 'AND ' . $lst . ' = tagged ' .
  92. 'AND tagger != tagged');
  93. $tags = array();
  94. while ($profile_tag->fetch()) {
  95. $tags[] = $profile_tag->tag;
  96. }
  97. $profile_tag->free();
  98. return $tags;
  99. }
  100. function getAllTags()
  101. {
  102. return array();
  103. }
  104. function showProfileBlock()
  105. {
  106. $block = new AccountProfileBlock($this, $this->target);
  107. $block->show();
  108. }
  109. }