make dynamictags (tagcloud) work again

This commit is contained in:
Christian Weiske 2011-03-30 19:20:26 +02:00
parent c7c702f544
commit 28c8cdaf58
2 changed files with 37 additions and 28 deletions

View file

@ -36,22 +36,34 @@ $allPopularTagsCount = count($allPopularTags);
// function printing the cloud // function printing the cloud
function writeTagsProposition($tagsCloud, $title) { function writeTagsProposition($tagsCloud, $title)
echo 'document.write(\'<div class="collapsible">\');'; {
echo 'document.write(\'<h3>'. $title .'<\/h3>\');'; static $id = 0;
echo 'document.write(\'<p id="popularTags" class="tags">\');'; ++$id;
echo <<<JS
$('.edit-tagclouds')
.append(
'<div class="collapsible" id="edit-tagcloud-$id">'
+ ' <h3>$title</h3>'
+ ' <p class="popularTags tags"></p>'
+ '</div>');
JS;
$taglist = ''; $taglist = '';
foreach (array_keys($tagsCloud) as $key) { foreach (array_keys($tagsCloud) as $key) {
$row =& $tagsCloud[$key]; $row = $tagsCloud[$key];
$entries = T_ngettext('bookmark', 'bookmarks', $row['bCount']); $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> '; $taglist .= '<span'
. ' title="'. $row['bCount'] . ' ' . $entries . '"'
. ' style="font-size:' . $row['size'] . '"'
. ' onclick="addTag(this)">'
. filter($row['tag'])
. '</span> ';
} }
echo '$(\'#edit-tagcloud-' . $id . ' p\').append('
echo 'document.write(\''. $taglist .'\');'; . json_encode($taglist)
echo 'document.write(\'<\/p>\');'; . ");\n";
echo 'document.write(\'<\/div>\');';
} }
@ -88,10 +100,18 @@ function addonload(addition) {
} }
jQuery(function($) { jQuery(function($) {
var taglist = document.getElementById('tags'); <?php
var tags = taglist.value.split(', '); if ($userPopularTagsCount > 0) {
writeTagsProposition($userPopularTagsCloud, T_('Popular Tags'));
}
if ($allPopularTagsCount > 0) {
writeTagsProposition($allPopularTagsCloud, T_('Popular Tags From All Users'));
}
?>
var taglist = $('#tags');
var tags = taglist.val().split(', ');
var populartags = document.getElementById('popularTags').getElementsByTagName('span'); var populartags = $('.edit-tagclouds span');
for (var i = 0; i < populartags.length; i++) { for (var i = 0; i < populartags.length; i++) {
if (tags.contains(populartags[i].innerHTML)) { if (tags.contains(populartags[i].innerHTML)) {
@ -120,20 +140,9 @@ function addTag(ele) {
document.getElementById('tags').focus(); document.getElementById('tags').focus();
} }
<?php
if( $userPopularTagsCount > 0) {
writeTagsProposition($userPopularTagsCloud, T_('Popular Tags'));
}
if( $allPopularTagsCount > 0) {
writeTagsProposition($allPopularTagsCloud, T_('Popular Tags From All Users'));
}
?>
//]]> //]]>
</script> </script>
<div class="edit-tagclouds"></div>
<?php <?php
} }
?> ?>

View file

@ -194,7 +194,7 @@ jQuery(document).ready(function() {
<?php <?php
// Dynamic tag selection // Dynamic tag selection
//FIXME$this->includeTemplate('dynamictags.inc'); $this->includeTemplate('dynamictags.inc');
// Bookmarklets and import links // Bookmarklets and import links
if (empty($_REQUEST['popup']) && (!isset($showdelete) || !$showdelete)) { if (empty($_REQUEST['popup']) && (!isset($showdelete) || !$showdelete)) {