2 /***************************************************************************
3 Copyright (c) 2005 - 2010 Marcus Campbell
4 http://sourceforge.net/projects/scuttle/
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ***************************************************************************/
22 $tagservice =& ServiceFactory::getServiceInstance('TagService');
23 $userservice =& ServiceFactory::getServiceInstance('UserService');
25 $logged_on_userid = $userservice->getCurrentUserId();
27 $userPopularTags =& $tagservice->getPopularTags($logged_on_userid, 25, $logged_on_userid);
28 $userPopularTagsCloud =& $tagservice->tagCloud($userPopularTags, 5, 90, 175);
29 $userPopularTagsCount = count($userPopularTags);
31 if ($userPopularTagsCount > 0) {
34 <script type="text/javascript">
35 Array.prototype.contains = function (ele) {
36 for (var i = 0; i < this.length; i++) {
44 Array.prototype.remove = function (ele) {
45 var arr = new Array();
47 for (var i = 0; i < this.length; i++) {
56 function addonload(addition) {
57 var existing = window.onload;
58 window.onload = function () {
66 var taglist = document.getElementById('tags');
67 var tags = taglist.value.split(', ');
69 var populartags = document.getElementById('popularTags').getElementsByTagName('span');
71 for (var i = 0; i < populartags.length; i++) {
72 if (tags.contains(populartags[i].innerHTML)) {
73 populartags[i].className = 'selected';
79 function addTag(ele) {
80 var thisTag = ele.innerHTML;
81 var taglist = document.getElementById('tags');
82 var tags = taglist.value.split(', ');
84 // If tag is already listed, remove it
85 if (tags.contains(thisTag)) {
86 tags = tags.remove(thisTag);
87 ele.className = 'unselected';
91 tags.splice(0, 0, thisTag);
92 ele.className = 'selected';
95 taglist.value = tags.join(', ');
97 document.getElementById('tags').focus();
100 document.write('<div class="collapsible">');
101 document.write('<h3><?php echo T_('Popular Tags'); ?><\/h3>');
102 document.write('<p id="popularTags" class="tags">');
106 foreach(array_keys($userPopularTagsCloud) as $key) {
107 $row =& $userPopularTagsCloud[$key];
108 $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']);
109 $taglist .= '<span title="'. $row['bCount'] .' '. $entries .'" style="font-size:'. $row['size'] .'" onclick="addTag(this)">'. filter($row['tag']) .'<\/span> ';
113 document.write('<?php echo $taglist ?>');
114 document.write('<\/p>');
115 document.write('<\/div>');