galleryaction.php 4.5 KB

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