git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

galleryaction.php 4.44 KB
Newer Older
1 2
<?php
/**
3
 * StatusNet - the distributed open-source microblogging tool
4
 * Copyright (C) 2008, 2009, StatusNet, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

20
if (!defined('GNUSOCIAL')) { exit(1); }
21 22 23 24 25

// 10x8

define('AVATARS_PER_PAGE', 80);

Siebrand Mazeland's avatar
Siebrand Mazeland committed
26
// @todo FIXME: Class documentation missing.
27
class GalleryAction extends ProfileAction
28
{
29
    protected function handle()
30
    {
31 32 33
        // Post from the tag dropdown; redirect to a GET
        if ($this->isPost()) {
            common_redirect($this->selfUrl(), 303);
34 35
        }

36
        parent::handle();
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    }

    function showContent()
    {
        $this->showTagsDropdown();
    }

    function showTagsDropdown()
    {
        $tag = $this->trimmed('tag');

        $tags = $this->getAllTags();

        $content = array();

        foreach ($tags as $t) {
            $content[$t] = $t;
        }
        if ($tags) {
56 57 58
            $this->elementStart('dl', array('id' => 'filter_tags'));
            $this->element('dt', null, _('Tags'));
            $this->elementStart('dd');
59 60 61 62 63 64 65
            $this->elementStart('ul');
            $this->elementStart('li', array('id' => 'filter_tags_all',
                                             'class' => 'child_1'));
            $this->element('a',
                           array('href' =>
                                 common_local_url($this->trimmed('action'),
                                                  array('nickname' =>
66
                                                        $this->target->getNickname()))),
Siebrand Mazeland's avatar
Siebrand Mazeland committed
67 68
                           // TRANS: List element on gallery action page to show all tags.
                           _m('TAGS','All'));
69 70 71
            $this->elementEnd('li');
            $this->elementStart('li', array('id'=>'filter_tags_item'));
            $this->elementStart('form', array('name' => 'bytag',
72
                                               'id' => 'form_filter_bytag',
73
                                              'action' => common_path('?action=' . $this->getActionName()),
74
                                               'method' => 'post'));
75
            $this->elementStart('fieldset');
Siebrand Mazeland's avatar
Siebrand Mazeland committed
76
            // TRANS: Fieldset legend on gallery action page.
77
            $this->element('legend', null, _('Select tag to filter'));
Siebrand Mazeland's avatar
Siebrand Mazeland committed
78
            // TRANS: Dropdown field label on gallery action page for a list containing tags.
79
            $this->dropdown('tag', _('Tag'), $content,
Siebrand Mazeland's avatar
Siebrand Mazeland committed
80 81
                            // TRANS: Dropdown field title on gallery action page for a list containing tags.
                            _('Choose a tag to narrow list.'), false, $tag);
82
            $this->hidden('nickname', $this->target->getNickname());
Siebrand Mazeland's avatar
Siebrand Mazeland committed
83 84
            // TRANS: Submit button text on gallery action page.
            $this->submit('submit', _m('BUTTON','Go'));
85
            $this->elementEnd('fieldset');
86 87 88
            $this->elementEnd('form');
            $this->elementEnd('li');
            $this->elementEnd('ul');
89 90
            $this->elementEnd('dd');
            $this->elementEnd('dl');
91 92 93 94 95 96 97 98 99
        }
    }

    // Get list of tags we tagged other users with
    function getTags($lst, $usr)
    {
        $profile_tag = new Notice_tag();
        $profile_tag->query('SELECT DISTINCT(tag) ' .
                            'FROM profile_tag, subscription ' .
100 101
                            'WHERE tagger = ' . $this->target->id . ' ' .
                            'AND ' . $usr . ' = ' . $this->target->id . ' ' .
102 103 104 105 106 107 108 109 110 111 112 113 114 115
                            'AND ' . $lst . ' = tagged ' .
                            'AND tagger != tagged');
        $tags = array();
        while ($profile_tag->fetch()) {
            $tags[] = $profile_tag->tag;
        }
        $profile_tag->free();
        return $tags;
    }

    function getAllTags()
    {
        return array();
    }
116 117 118

    function showProfileBlock()
    {
119
        $block = new AccountProfileBlock($this, $this->target);
120 121
        $block->show();
    }
122
}