diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/dynamictags.inc.php | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/templates/dynamictags.inc.php b/templates/dynamictags.inc.php index 4bc0421..b317e9f 100644 --- a/templates/dynamictags.inc.php +++ b/templates/dynamictags.inc.php @@ -1,35 +1,61 @@ <?php /*************************************************************************** -Copyright (C) 2005 - 2006 Scuttle project -http://sourceforge.net/projects/scuttle/ -http://scuttle.org/ + Copyright (C) 2005 - 2006 Scuttle project + http://sourceforge.net/projects/scuttle/ + http://scuttle.org/ -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -***************************************************************************/ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ***************************************************************************/ $b2tservice = & ServiceFactory :: getServiceInstance('Bookmark2TagService'); $userservice = & ServiceFactory :: getServiceInstance('UserService'); $logged_on_userid = $userservice->getCurrentUserId(); +//tags from current user $userPopularTags =& $b2tservice->getPopularTags($logged_on_userid, 25, $logged_on_userid); -$userPopularTagsCloud =& $b2tservice->tagCloud($userPopularTags, 5, 90, 175); +$userPopularTagsCloud =& $b2tservice->tagCloud($userPopularTags, 5, 90, 175); $userPopularTagsCount = count($userPopularTags); -if ($userPopularTagsCount > 0) { -?> +//tags from all users +$allPopularTags =& $b2tservice->getPopularTags(null, 5, $logged_on_userid); +$allPopularTagsCloud =& $b2tservice->tagCloud($allPopularTags, 5, 90, 175); +$allPopularTagsCount = count($allPopularTags); + + +// function printing the cloud +function writeTagsProposition($tagsCloud, $title) { + echo 'document.write(\'<div class="collapsible">\');'; + echo 'document.write(\'<h3>'. $title .'<\/h3>\');'; + echo 'document.write(\'<p id="popularTags" class="tags">\');'; + + $taglist = ''; + foreach(array_keys($tagsCloud) as $key) { + $row =& $tagsCloud[$key]; + $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']); + $taglist .= '<span title="'. $row['bCount'] .' '. $entries .'" style="font-size:'. $row['size'] .'" onclick="addTag(this)">'. filter($row['tag']) .'<\/span> '; + } + + echo 'document.write(\''. $taglist .'\');'; + echo 'document.write(\'<\/p>\');'; + echo 'document.write(\'<\/div>\');'; + +} + + +if ($allPopularTagsCount > 0 || $userPopularTagsCount > 0 ) { ?> <script type="text/javascript"> Array.prototype.contains = function (ele) { @@ -97,22 +123,17 @@ function addTag(ele) { document.getElementById('tags').focus(); } -document.write('<div class="collapsible">'); -document.write('<h3><?php echo T_('Popular Tags'); ?><\/h3>'); -document.write('<p id="popularTags" class="tags">'); - <?php -$taglist = ''; -foreach(array_keys($userPopularTagsCloud) as $key) { - $row =& $userPopularTagsCloud[$key]; - $entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']); - $taglist .= '<span title="'. $row['bCount'] .' '. $entries .'" style="font-size:'. $row['size'] .'" onclick="addTag(this)">'. filter($row['tag']) .'<\/span> '; +if( $userPopularTagsCount > 0) { + writeTagsProposition($userPopularTagsCloud, T_('Popular Tags')); +} +if( $allPopularTagsCount > 0) { + writeTagsProposition($allPopularTagsCloud, T_('Popular Tags From All Users')); } + + ?> -document.write('<?php echo $taglist ?>'); -document.write('<\/p>'); -document.write('<\/div>'); </script> <?php |