3 * StatusNet, the distributed open-source microblogging tool
5 * Public tag cloud for notices
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.
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.
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/>.
24 * @author Mike Cochrane <mikec@mikenz.geek.nz>
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2008 Mike Cochrane
27 * @copyright 2008-2009 StatusNet, Inc.
28 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
29 * @link http://status.net/
32 if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
34 define('TAGS_PER_PAGE', 100);
37 * Public tag cloud for notices
41 * @author Mike Cochrane <mikec@mikenz.geek.nz>
42 * @author Evan Prodromou <evan@status.net>
43 * @copyright 2008 Mike Cochrane
44 * @copyright 2008-2009 StatusNet, Inc.
45 * @link http://status.net/
47 class PublicpeopletagcloudAction extends Action
49 function isReadOnly($args)
56 // TRANS: Title for page with public list cloud.
57 return _('Public list cloud');
60 function showPageNotice()
62 $this->element('p', 'instructions',
63 // TRANS: Page notice for page with public list cloud.
64 // TRANS: %s is a StatusNet sitename.
65 sprintf(_('These are largest lists on %s'),
66 common_config('site', 'name')));
69 function showEmptyList()
71 // TRANS: Empty list message on page with public list cloud.
72 // TRANS: This message contains Markdown links in the form [description](link).
73 $message = _('No one has [listed](%%doc.tags%%) anyone yet.') . ' ';
75 if (common_logged_in()) {
76 // TRANS: Additional empty list message on page with public list cloud for logged in users.
77 $message .= _('Be the first to list someone!');
80 // TRANS: Additional empty list message on page with public list cloud for anonymous users.
81 // TRANS: This message contains Markdown links in the form [description](link).
82 $message .= _('Why not [register an account](%%action.register%%) and be the first to list someone!');
85 $this->elementStart('div', 'guide');
86 $this->raw(common_markup_to_html($message));
87 $this->elementEnd('div');
90 function showLocalNav()
92 $nav = new PublicGroupNav($this);
96 function handle($args)
98 parent::handle($args);
102 function showContent()
106 $tags = new Profile_tag();
107 $plist = new Profile_list();
108 $plist->private = false;
110 $tags->joinAdd($plist);
112 $tags->selectAdd('profile_tag.tag');
113 $tags->selectAdd('count(profile_tag.tag) as weight');
114 $tags->groupBy('profile_tag.tag');
115 $tags->orderBy('weight DESC');
117 $tags->limit(TAGS_PER_PAGE);
119 $cnt = $tags->find();
122 $this->elementStart('div', array('id' => 'tagcloud',
123 'class' => 'section'));
127 while ($tags->fetch()) {
128 $tw[$tags->tag] = $tags->weight;
129 $sum += $tags->weight;
134 $this->elementStart('dl');
135 // TRANS: DT element on on page with public list cloud.
136 $this->element('dt', null, _('List cloud'));
137 $this->elementStart('dd');
138 $this->elementStart('ul', 'tags xoxo tag-cloud');
139 foreach ($tw as $tag => $weight) {
141 $weightedSum = $weight/$sum;
145 $this->showTag($tag, $weight, $weightedSum);
147 $this->elementEnd('ul');
148 $this->elementEnd('dd');
149 $this->elementEnd('dl');
150 $this->elementEnd('div');
152 $this->showEmptyList();
156 function showTag($tag, $weight, $relative)
158 if ($relative > 0.1) {
159 $rel = 'tag-cloud-7';
160 } else if ($relative > 0.05) {
161 $rel = 'tag-cloud-6';
162 } else if ($relative > 0.02) {
163 $rel = 'tag-cloud-5';
164 } else if ($relative > 0.01) {
165 $rel = 'tag-cloud-4';
166 } else if ($relative > 0.005) {
167 $rel = 'tag-cloud-3';
168 } else if ($relative > 0.002) {
169 $rel = 'tag-cloud-2';
171 $rel = 'tag-cloud-1';
174 $this->elementStart('li', $rel);
176 // TRANS: Link title for number of listed people. %d is the number of listed people.
177 $title = sprintf(_m('1 person listed','%d people listed',$weight),$weight);
178 $this->element('a', array('href' => common_local_url('peopletag', array('tag' => $tag)),
179 'title' => $title), $tag);
180 $this->elementEnd('li');