2 /***************************************************************************
3 Copyright (c) 2005 - 2010 Marcus Campbell
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
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 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ***************************************************************************/
21 $tagservice =& ServiceFactory::getServiceInstance('TagService');
22 $userservice =& ServiceFactory::getServiceInstance('UserService');
24 $logged_on_userid = $userservice->getCurrentUserId();
26 $userPopularTags =& $tagservice->getPopularTags($logged_on_userid, 25, $logged_on_userid);
27 $userPopularTagsCloud =& $tagservice->tagCloud($userPopularTags, 5, 90, 175);
28 $userPopularTagsCount = count($userPopularTags);
30 if ($userPopularTagsCount > 0) {
33 <script type="text/javascript">
34 Array.prototype.contains = function (ele) {
35 for (var i = 0; i < this.length; i++) {
43 Array.prototype.remove = function (ele) {
44 var arr = new Array();
46 for (var i = 0; i < this.length; i++) {
55 function addonload(addition) {
56 var existing = window.onload;
57 window.onload = function () {
65 var taglist = document.getElementById('tags');
66 var tags = taglist.value.split(', ');
68 var populartags = document.getElementById('popularTags').getElementsByTagName('span');
70 for (var i = 0; i < populartags.length; i++) {
71 if (tags.contains(populartags[i].innerHTML)) {
72 populartags[i].className = 'selected';
78 function addTag(ele) {
79 var thisTag = ele.innerHTML;
80 var taglist = document.getElementById('tags');
81 var tags = taglist.value.split(', ');
83 // If tag is already listed, remove it
84 if (tags.contains(thisTag)) {
85 tags = tags.remove(thisTag);
86 ele.className = 'unselected';
90 tags.splice(0, 0, thisTag);
91 ele.className = 'selected';
94 taglist.value = tags.join(', ');
96 document.getElementById('tags').focus();
99 document.write('<div class="collapsible">');
100 document.write('<h3><?php echo T_('Popular Tags'); ?><\/h3>');
101 document.write('<p id="popularTags" class="tags">');
105 foreach(array_keys($userPopularTagsCloud) as $key) {
106 $row =& $userPopularTagsCloud[$key];
107 $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
108 $taglist .= '<span title="'. $row['bCount'] .' '. $entries .'" style="font-size:'. $row['size'] .'" onclick="addTag(this)">'. filter($row['tag']) .'<\/span> ';
112 document.write('<?php echo $taglist ?>');
113 document.write('<\/p>');
114 document.write('<\/div>');