Skip to content

Commit

Permalink
Item1918: add "rendering" parameter to TAGSEARCH as a shortcut to TAG…
Browse files Browse the repository at this point in the history
…CLOUD, apply click behaviour to custom tagclouds

git-svn-id: http://svn.foswiki.org/trunk/TagsPlugin@7548 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OliverKrueger authored and OliverKrueger committed May 26, 2010
1 parent 5b3c1ba commit a7ab231
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
1 change: 1 addition & 0 deletions data/System/VarTAGSEARCH.txt
Expand Up @@ -19,6 +19,7 @@
| =order="tag"= <br /> =order="topic"= <br /> =order="user"= | This affects the sorting. | =none= |
| =limit="..."= | Numerical value. Limits the number of hits. | =not set= |
| =offset="..."= | Numerical value. May only be used in conjunction with =limit=. Number of hits to be skipped. | =not set= |
| =rendering="cloud"= | This is a shortcut which nests the output of =%<nop>TAGSEARCH%= into a =<nop>TAGCLOUD%= call. (This will override the =format=, =query= and =sep= parameter.) | =not set= |
* If two hits only differ in (tag|topic|user) and the =format= does not contain a (tag|topic|user) variable, the (two) hits clash into a single hit.
* Supported variables in custom formatting:
| *Name:* | *Expands To:* |
Expand Down
42 changes: 28 additions & 14 deletions lib/Foswiki/Plugins/TagsPlugin/TAGSEARCH.pm
Expand Up @@ -35,20 +35,21 @@ Return:
sub do {
my ( $session, $params, $topic, $web ) = @_;

my $theHeader = $params->{header} || '';
my $theSep = $params->{separator} || $params->{sep} || ', ';
my $theFooter = $params->{footer} || '';
my $theUser = $params->{user} || 'all';
my $theWeb = $params->{web} || 'all';
my $theTag = $params->{tag} || 'all';
my $theTopic = $params->{topic} || '';
my $theQuery = $params->{query} || 'tag';
my $theOrder = $params->{order} || '';
my $thePublic = $params->{visibility} || 'all';
my $theAlt = $params->{alt} || '';
my $theLimit = $params->{limit} || 0;
my $theOffset = $params->{offset} || 0;
my $theFormat = $params->{format};
my $theHeader = $params->{header} || '';
my $theSep = $params->{separator} || $params->{sep} || ', ';
my $theFooter = $params->{footer} || '';
my $theUser = $params->{user} || 'all';
my $theWeb = $params->{web} || 'all';
my $theTag = $params->{tag} || 'all';
my $theTopic = $params->{topic} || '';
my $theQuery = $params->{query} || 'tag';
my $theOrder = $params->{order} || '';
my $thePublic = $params->{visibility} || 'all';
my $theAlt = $params->{alt} || '';
my $theLimit = $params->{limit} || 0;
my $theOffset = $params->{offset} || 0;
my $theFormat = $params->{format};
my $theRendering = $params->{rendering} || '';

use Foswiki::Plugins::TagsPlugin::Func;
$theTag = Foswiki::Plugins::TagsPlugin::Func::normalizeTagname($theTag);
Expand All @@ -66,6 +67,12 @@ sub do {
}
}

if ( $theRendering =~ /^cloud$/i ) {
$theFormat = '$tag:1:$web:$topic:$user';
$theQuery = "tag";
$theSep = ",";
}

my $isTagAdmin =
Foswiki::Func::isGroupMember( $Foswiki::cfg{TagsPlugin}{TagAdminGroup}
|| "AdminGroup" ) ? 1 : 0;
Expand Down Expand Up @@ -322,6 +329,13 @@ $limit";
$output =~ s/\$quot/"/g;
$output =~ s/\$dollar/\$/g;

# handle special renderings (ie. cloud)
if ( $theRendering =~ /^cloud$/i ) {
my $tml = "%TAGCLOUD{ terms=\"$output\" format=\"<a style='font-size:\$weightpx;' class='tagsplugin_tagcloud_tag' href='%SCRIPTURL{view}%/%SYSTEMWEB%/TagsPluginTagDetails?tag=\$term' item='\$3.\$4' topic='\$4' web='\$3' tag='\$term' user='\$5'>\$term</a>\" warn=\"off\" split=\"[,]+\" }%";
$output = Foswiki::Func::expandCommonVariables( $tml, $topic, $web );
}


return $output;
}

Expand Down
4 changes: 2 additions & 2 deletions pub/System/TagsPlugin/tagsplugin-base.js
Expand Up @@ -218,8 +218,8 @@
}

jQuery.tagsplugin.redirect_tagdetails = function() {
$("div#tagsplugin .tagsplugin_tag")
.add("div#tagsplugin .tagsplugin_tagcloud_tag")
$(".tagsplugin_tag")
.add(".tagsplugin_tagcloud_tag")
.bind(
'click',
function(event) {
Expand Down

0 comments on commit a7ab231

Please sign in to comment.