galleryaction.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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('STATUSNET') && !defined('LACONICA')) {
  20. exit(1);
  21. }
  22. require_once INSTALLDIR.'/lib/profilelist.php';
  23. // 10x8
  24. define('AVATARS_PER_PAGE', 80);
  25. // @todo FIXME: Class documentation missing.
  26. class GalleryAction extends ProfileAction
  27. {
  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. function showContent()
  37. {
  38. $this->showTagsDropdown();
  39. }
  40. 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('a',
  56. array('href' =>
  57. common_local_url($this->trimmed('action'),
  58. array('nickname' =>
  59. $this->target->getNickname()))),
  60. // TRANS: List element on gallery action page to show all tags.
  61. _m('TAGS','All'));
  62. $this->elementEnd('li');
  63. $this->elementStart('li', array('id'=>'filter_tags_item'));
  64. $this->elementStart('form', array('name' => 'bytag',
  65. 'id' => 'form_filter_bytag',
  66. 'action' => common_path('?action=' . $this->getActionName()),
  67. 'method' => 'post'));
  68. $this->elementStart('fieldset');
  69. // TRANS: Fieldset legend on gallery action page.
  70. $this->element('legend', null, _('Select tag to filter'));
  71. // TRANS: Dropdown field label on gallery action page for a list containing tags.
  72. $this->dropdown('tag', _('Tag'), $content,
  73. // TRANS: Dropdown field title on gallery action page for a list containing tags.
  74. _('Choose a tag to narrow list.'), false, $tag);
  75. $this->hidden('nickname', $this->target->getNickname());
  76. // TRANS: Submit button text on gallery action page.
  77. $this->submit('submit', _m('BUTTON','Go'));
  78. $this->elementEnd('fieldset');
  79. $this->elementEnd('form');
  80. $this->elementEnd('li');
  81. $this->elementEnd('ul');
  82. $this->elementEnd('dd');
  83. $this->elementEnd('dl');
  84. }
  85. }
  86. // Get list of tags we tagged other users with
  87. function getTags($lst, $usr)
  88. {
  89. $profile_tag = new Notice_tag();
  90. $profile_tag->query('SELECT DISTINCT(tag) ' .
  91. 'FROM profile_tag, subscription ' .
  92. 'WHERE tagger = ' . $this->target->id . ' ' .
  93. 'AND ' . $usr . ' = ' . $this->target->id . ' ' .
  94. 'AND ' . $lst . ' = tagged ' .
  95. 'AND tagger != tagged');
  96. $tags = array();
  97. while ($profile_tag->fetch()) {
  98. $tags[] = $profile_tag->tag;
  99. }
  100. $profile_tag->free();
  101. return $tags;
  102. }
  103. function getAllTags()
  104. {
  105. return array();
  106. }
  107. function showProfileBlock()
  108. {
  109. $block = new AccountProfileBlock($this, $this->target);
  110. $block->show();
  111. }
  112. }