]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/peopletagsection.php
Merge branch 'master' into social-master
[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 class PeopletagSection extends Section
50 {
51     protected $avatarSize = AVATAR_MINI_SIZE;
52
53     function showContent()
54     {
55         $tags = $this->getPeopletags();
56
57         if (!$tags) {
58             return false;
59         }
60
61         $cnt = 0;
62
63         $this->out->elementStart('table', 'peopletag_section');
64
65         while ($tags->fetch() && ++$cnt <= PEOPLETAGS_PER_SECTION) {
66             $this->showPeopletag($tags);
67         }
68
69         $this->out->elementEnd('table');
70
71         return ($cnt > PEOPLETAGS_PER_SECTION);
72     }
73
74     function getPeopletags()
75     {
76         return null;
77     }
78
79     function showPeopletag($peopletag)
80     {
81         $tag = new PeopletagSectionItem($peopletag, null, $this->out);
82         $tag->show();
83     }
84 }
85
86 class PeopletagSectionItem extends PeopletagListItem
87 {
88     function showStart()
89     {
90     }
91
92     function showEnd()
93     {
94     }
95
96     function showPeopletag()
97     {
98         $this->showCreator();
99         $this->showTag();
100         $this->showPrivacy();
101     }
102
103     function show()
104     {
105         if (empty($this->peopletag)) {
106             common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
107             return;
108         }
109         $mode = ($this->peopletag->private) ? 'private' : 'public';
110
111         $this->out->elementStart('tr');
112
113         $this->out->elementStart('td', 'peopletag mode-' . $mode);
114         $this->showPeopletag();
115         $this->out->elementEnd('td');
116
117         if (isset($this->peopletag->value)) {
118             $this->out->element('td', 'value', $this->peopletag->value);
119         }
120         $this->out->elementEnd('tr');
121     }
122
123     function showTag()
124     {
125         // TRANS: List summary. %1$d is the number of users in the list,
126         // TRANS: %2$d is the number of subscribers to the list.
127         $title = sprintf(_('Listed: %1$d Subscribers: %2$d'),
128                          $this->peopletag->taggedCount(),
129                          $this->peopletag->subscriberCount());
130
131         $this->out->elementStart('span', 'entry-title tag');
132
133         $this->out->element('a',
134             array('rel'   => 'bookmark',
135                   'href'  => $this->url(),
136                   'title' => $title),
137             htmlspecialchars($this->peopletag->tag));
138         $this->out->elementEnd('span');
139     }
140 }