galleryaction.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * @copyright 2008, 2009 StatusNet, Inc.
  18. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  19. */
  20. defined('GNUSOCIAL') || die();
  21. // 10x8
  22. define('AVATARS_PER_PAGE', 80);
  23. // @todo FIXME: Class documentation missing.
  24. class GalleryAction extends ProfileAction
  25. {
  26. protected function handle()
  27. {
  28. // Post from the tag dropdown; redirect to a GET
  29. if ($this->isPost()) {
  30. common_redirect($this->selfUrl(), 303);
  31. }
  32. parent::handle();
  33. }
  34. public function showContent()
  35. {
  36. $this->showTagsDropdown();
  37. }
  38. public function showTagsDropdown()
  39. {
  40. $tag = $this->trimmed('tag');
  41. $tags = $this->getAllTags();
  42. $content = array();
  43. foreach ($tags as $t) {
  44. $content[$t] = $t;
  45. }
  46. if ($tags) {
  47. $this->elementStart('dl', array('id' => 'filter_tags'));
  48. $this->element('dt', null, _('Tags'));
  49. $this->elementStart('dd');
  50. $this->elementStart('ul');
  51. $this->elementStart('li', array('id' => 'filter_tags_all',
  52. 'class' => 'child_1'));
  53. $this->element(
  54. 'a',
  55. [
  56. 'href' => common_local_url(
  57. $this->trimmed('action'),
  58. ['nickname' => $this->target->getNickname()]
  59. ),
  60. ],
  61. // TRANS: List element on gallery action page to show all tags.
  62. _m('TAGS', 'All')
  63. );
  64. $this->elementEnd('li');
  65. $this->elementStart('li', array('id'=>'filter_tags_item'));
  66. $this->elementStart('form', array('name' => 'bytag',
  67. 'id' => 'form_filter_bytag',
  68. 'action' => common_path('?action=' . $this->getActionName()),
  69. 'method' => 'post'));
  70. $this->elementStart('fieldset');
  71. // TRANS: Fieldset legend on gallery action page.
  72. $this->element('legend', null, _('Select tag to filter'));
  73. // TRANS: Dropdown field label on gallery action page for a list containing tags.
  74. $this->dropdown(
  75. 'tag',
  76. _('Tag'),
  77. $content,
  78. // TRANS: Dropdown field title on gallery action page for a list containing tags.
  79. _('Choose a tag to narrow list.'),
  80. false,
  81. $tag
  82. );
  83. $this->hidden('nickname', $this->target->getNickname());
  84. // TRANS: Submit button text on gallery action page.
  85. $this->submit('submit', _m('BUTTON', 'Go'));
  86. $this->elementEnd('fieldset');
  87. $this->elementEnd('form');
  88. $this->elementEnd('li');
  89. $this->elementEnd('ul');
  90. $this->elementEnd('dd');
  91. $this->elementEnd('dl');
  92. }
  93. }
  94. // Get list of tags we tagged other users with
  95. public function getTags($lst, $usr)
  96. {
  97. $profile_tag = new Notice_tag();
  98. $profile_tag->query(
  99. <<<END
  100. SELECT DISTINCT tag FROM profile_tag INNER JOIN subscription
  101. ON tagger = {$usr} AND {$lst} = tagged
  102. WHERE tagger = {$this->target->id} AND tagger <> tagged;
  103. END
  104. );
  105. $tags = [];
  106. while ($profile_tag->fetch()) {
  107. $tags[] = $profile_tag->tag;
  108. }
  109. $profile_tag->free();
  110. return $tags;
  111. }
  112. public function getAllTags()
  113. {
  114. return array();
  115. }
  116. public function showProfileBlock()
  117. {
  118. $block = new AccountProfileBlock($this, $this->target);
  119. $block->show();
  120. }
  121. }