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