]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/peopletagsection.php
Merge remote-tracking branch 'mainline/1.0.x' into people_tags_rebase
[quix0rs-gnu-social.git] / lib / peopletagsection.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Base class for sections showing lists of peopletags
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Widget
23  * @package   StatusNet
24  * @author    Shashi Gowda <connect2shashi@gmail.com>
25  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
26  * @link      http://status.net/
27  */
28
29 if (!defined('STATUSNET') && !defined('LACONICA')) {
30     exit(1);
31 }
32
33 require_once INSTALLDIR . '/lib/peopletaglist.php';
34
35 define('PEOPLETAGS_PER_SECTION', 6);
36
37 /**
38  * Base class for sections
39  *
40  * These are the widgets that show interesting data about a person
41  * peopletag, or site.
42  *
43  * @category Widget
44  * @package  StatusNet
45  * @author   Shashi Gowda <connect2shashi@gmail.com>
46  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
47  * @link     http://status.net/
48  */
49
50 class PeopletagSection extends Section
51 {
52     function showContent()
53     {
54         $tags = $this->getPeopletags();
55
56         if (!$tags) {
57             return false;
58         }
59
60         $cnt = 0;
61
62         $this->out->elementStart('table', 'peopletag_section');
63
64         while ($tags->fetch() && ++$cnt <= PEOPLETAGS_PER_SECTION) {
65             $this->showPeopletag($tags);
66         }
67
68         $this->out->elementEnd('table');
69
70         return ($cnt > PEOPLETAGS_PER_SECTION);
71     }
72
73     function getPeopletags()
74     {
75         return null;
76     }
77
78     function showPeopletag($peopletag)
79     {
80         $tag = new PeopletagSectionItem($peopletag, null, $this->out);
81         $tag->show();
82     }
83 }
84
85 class PeopletagSectionItem extends PeopletagListItem
86 {
87     function showStart()
88     {
89     }
90
91     function showEnd()
92     {
93     }
94
95     function showPeopletag()
96     {
97         $this->showCreator();
98         $this->showTag();
99         $this->showPrivacy();
100     }
101
102     function show()
103     {
104         if (empty($this->peopletag)) {
105             common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
106             return;
107         }
108
109         $this->out->elementStart('tr');
110
111         $this->out->elementStart('td', 'peopletag');
112         $this->showPeopletag();
113         $this->out->elementEnd('td');
114
115         if (isset($this->peopletag->value)) {
116             $this->out->element('td', 'value', $this->peopletag->value);
117         }
118         $this->out->elementEnd('tr');
119     }
120
121     function showTag()
122     {
123         $title = _('Tagged: ') . $this->peopletag->taggedCount() .
124                  ' ' . _('Subscribers: ') . $this->peopletag->subscriberCount();
125
126         $this->out->elementStart('span', 'entry-title tag');
127         $this->out->element('a',
128             array('rel'   => 'bookmark',
129                   'href'  => $this->url(),
130                   'title' => $title),
131             htmlspecialchars($this->peopletag->tag));
132         $this->out->elementEnd('span');
133     }
134
135     function showAvatar()
136     {
137         parent::showAvatar(AVATAR_MINI_SIZE);
138     }
139 }