Skip to content

Commit

Permalink
Item1918: added TAGGROUPS and ISTAGADMIN, css
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/TagsPlugin@4722 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OliverKrueger authored and OliverKrueger committed Aug 28, 2009
1 parent 12c5ec4 commit 574d15e
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 20 deletions.
4 changes: 4 additions & 0 deletions data/System/TagsPluginNoHeaderViewTemplate.txt
@@ -0,0 +1,4 @@
%META:TOPICINFO{author="BaseUserMapping_333" date="1251408056" format="1.1" version="1.1"}%
%TMPL:INCLUDE{view}%

%TMPL:DEF{"tagsplugin:header"}%%TMPL:END%
8 changes: 8 additions & 0 deletions data/System/TagsPluginTagCloud.txt
@@ -0,0 +1,8 @@
%META:TOPICINFO{author="BaseUserMapping_333" date="1251421038" format="1.1" reprev="1.6" version="1.6"}%
%TAGCLOUD{
terms="$percntTAGSEARCH{ query=\"tag\" format=\"$tag:1:$web:$topic:$user\" sep=\",\" web=\"$percntTAGWEB$percnt\" user=\"$percntTAGUSER$percnt\" }$percnt"
header="<div style=\"text-align:center; padding:15px;line-height:180%\">"
format="<span style='font-size:$weightpx;line-height:90%;text-decoration:none' title='$5' url='$percntSCRIPTURL{rest}$percnt/TagsPlugin/' class='tagsplugin_tagcloud_tag' item='$3.$4' topic='$4' web='$3' tag='$term' user='$5'>$term</span>"
footer="</div>"
warn="off"
}%
10 changes: 4 additions & 6 deletions data/System/TagsPluginTagList.txt
@@ -1,10 +1,8 @@
%META:TOPICINFO{author="BaseUserMapping_333" date="1251232495" format="1.1" version="1.2"}%
<noautolink>
%META:TOPICINFO{author="BaseUserMapping_333" date="1251400275" format="1.1" version="1.3"}%
%TAGSEARCH{
query="tag"
web="%URLPARAM{"tagweb" default="%SYSTEMWEB%"}%"
topic="%URLPARAM{"tagtopic" default="SomeTHiNg_verY-unLIKelY" }%"
format=" <span class='tagsplugin_tag $untaggable' tag='$tag' topic='$item' user='$user'>$tag</span>$n"
web="%URLPARAM{"tagweb" default="%BASEWEB%"}%"
topic="%URLPARAM{"tagtopic" default="%BASETOPIC%" }%"
format=" <span class='tagsplugin_tag $untaggable' tag='$tag' topic='$item' user='$user'><a class='tagsplugin_tag' href='%SCRIPTURL{view}%/%SYSTEMWEB%/TagsPluginTagDetails?tag=$tag'>$tag</a></span>"
sep=" "
}%
</noautolink>
26 changes: 22 additions & 4 deletions lib/Foswiki/Plugins/TagsPlugin.pm
Expand Up @@ -45,12 +45,16 @@ sub initPlugin {
return 0;
}

Foswiki::Func::addToHEAD('TAGSPLUGIN','<link rel="stylesheet" type="text/css" href="%PUBURL%/System/TagsPlugin/tagsplugin.css" media="all" />');

# $debug = $Foswiki::cfg{Plugins}{TagsPlugin}{Debug} || 0;

Foswiki::Func::registerTagHandler( 'TAGLIST', \&_TAGLIST );
Foswiki::Func::registerTagHandler( 'TAGENTRY', \&_TAGENTRY );
Foswiki::Func::registerTagHandler( 'TAGCLOUD', \&_TAGCLOUD ) if ( defined($Foswiki::cfg{TagsPlugin}{EnableTagCloud}) && $Foswiki::cfg{TagsPlugin}{EnableTagCloud} );
Foswiki::Func::registerTagHandler( 'TAGSEARCH', \&_TAGSEARCH );
Foswiki::Func::registerTagHandler( 'TAGLIST', \&_TAGLIST );
Foswiki::Func::registerTagHandler( 'TAGENTRY', \&_TAGENTRY );
Foswiki::Func::registerTagHandler( 'TAGCLOUD', \&_TAGCLOUD ) if ( defined($Foswiki::cfg{TagsPlugin}{EnableTagCloud}) && $Foswiki::cfg{TagsPlugin}{EnableTagCloud} );
Foswiki::Func::registerTagHandler( 'TAGSEARCH', \&_TAGSEARCH );
Foswiki::Func::registerTagHandler( 'TAGGROUPS', \&_TAGGROUPS );
Foswiki::Func::registerTagHandler( 'ISTAGADMIN', \&_ISTAGADMIN );

Foswiki::Func::registerRESTHandler( 'tag', \&tagCall );
Foswiki::Func::registerRESTHandler( 'untag', \&untagCall );
Expand Down Expand Up @@ -292,6 +296,20 @@ sub _TAGSEARCH {
return Foswiki::Plugins::TagsPlugin::TAGSEARCH::do( @_ );
}

sub _TAGGROUPS {
use Foswiki::Plugins::TagsPlugin::TAGGROUPS;
return Foswiki::Plugins::TagsPlugin::TAGGROUPS::do( @_ );
}

sub _ISTAGADMIN {
my $tagAdminGroup = $Foswiki::cfg{TagsPlugin}{TagAdminGroup} || "AdminGroup";
if ( !Foswiki::Func::isGroupMember( $tagAdminGroup, Foswiki::Func::getWikiName()) ) {
return "0";
} else {
return "1";
}
}

=pod
---++ tagCall($session) -> $text
Expand Down
4 changes: 4 additions & 0 deletions lib/Foswiki/Plugins/TagsPlugin/MANIFEST
Expand Up @@ -3,15 +3,19 @@ data/System/TagsPlugin.txt 0644 Documentation
data/System/TagsPluginViews.txt 0644 Documentation
data/System/TagsPluginTagEntrySearch.txt 0644 Topic
data/System/TagsPluginViewsTagSearch.txt 0644 Topic
data/System/TagsPluginNoHeaderViewTemplate.txt 0644 Topic
data/System/TagsPluginTagList.txt 0644 Topic
data/System/TagsPluginTagCloud.txt 0644 Topic
data/System/VarTAGSEARCH.txt 0644 Documentation
pub/System/TagsPlugin/tagsplugin.css 0644 Stylesheets
lib/Foswiki/Plugins/TagsPlugin.pm 0644 Perl module
lib/Foswiki/Plugins/TagsPlugin/Tag.pm 0644 Perl module
lib/Foswiki/Plugins/TagsPlugin/Untag.pm 0644 Perl module
lib/Foswiki/Plugins/TagsPlugin/Delete.pm 0644 Perl module
lib/Foswiki/Plugins/TagsPlugin/Rename.pm 0644 Perl module
lib/Foswiki/Plugins/TagsPlugin/Merge.pm 0644 Perl module
lib/Foswiki/Plugins/TagsPlugin/TAGSEARCH.pm 0644 Perl module
lib/Foswiki/Plugins/TagsPlugin/TAGGROUPS.pm 0644 Perl module
templates/tagsplugin.tmpl
templates/view.tagsplugin.tmpl

Expand Down
72 changes: 72 additions & 0 deletions lib/Foswiki/Plugins/TagsPlugin/TAGGROUPS.pm
@@ -0,0 +1,72 @@
# This script Copyright
# (c) 2009 Oliver Krueger, (wiki-one.net)
# and distributed under the GPL (see below)
#
# 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, published at
# http://www.gnu.org/copyleft/gpl.html
#
# Author(s): Oliver Krueger

package Foswiki::Plugins::TagsPlugin::TAGGROUPS;

use strict;
use warnings;
use Error qw(:try);

=begin TML
---++ do( $session, $params, $topic, $web )
Taghandler for TAGGROUPS.
Return:
Formatted list of current users groups.
=cut

sub do {
my ( $session, $params, $topic, $web ) = @_;

my $theHeader = $params->{header} || '';
my $theSep = $params->{separator} || $params->{sep} || ',';
my $theFooter = $params->{footer} || '';
my $theFormat = $params->{format} || '$group';

my $output = '';
my @groups = ();

# get the groups and rotate through it
my $it = Foswiki::Func::eachGroup();
while ($it->hasNext()) {
my $group = $it->next();
if ( !Foswiki::Func::isGroupMember( $group ) ) { next; };
my $entry = $theFormat;

$entry =~ s/\$group/$group/g;

# insert seperator only if needed
if ( $output ne '' ) {
$output .= $theSep . $entry;
} else {
$output = $entry;
}
}

$output = $theHeader . $output . $theFooter if ($output);

# expand standard escapes
$output =~ s/\$n/\n/g;
$output =~ s/\$percnt/\%/g;
$output =~ s/\$quot/"/g;
$output =~ s/\$dollar/\$/g;

return $output;
}

1;
26 changes: 17 additions & 9 deletions lib/Foswiki/Plugins/TagsPlugin/TAGSEARCH.pm
Expand Up @@ -65,15 +65,23 @@ sub do {
# resolve the cUID from the database and exit with "" if it does not exist
#
if ( lc($theUser) ne 'all' ) {
my $cuid;
my $statement =
sprintf( 'SELECT %s from %s WHERE %s = ? ', qw( CUID Users FoswikicUID) );
my $arrayRef = $db->dbSelect( $statement, Foswiki::Func::getCanonicalUserID( $theUser ) );
if ( defined( $arrayRef->[0][0] ) ) {
$cuid = $arrayRef->[0][0];
my @users = split( /,/, $theUser );
my @clauses;
foreach my $u (@users) {
$u =~ s/^\s*//g;
$u =~ s/\s*$//g;
my $cuid;
my $statement =
sprintf( 'SELECT %s from %s WHERE %s = ? ', qw( CUID Users FoswikicUID) );
my $arrayRef = $db->dbSelect( $statement, Foswiki::Func::getCanonicalUserID( $u ) );
if ( defined( $arrayRef->[0][0] ) ) {
$cuid = $arrayRef->[0][0];
}
next unless ( defined($cuid) );
push @clauses, " i2t.user_id = '$cuid' ";
}
return '' unless ( defined($cuid) );
push @whereClauses, " i2t.user_id = '$cuid' ";
if ( !defined(@clauses) ) { return ''; };
push @whereClauses, "(" . join( ' OR ', @clauses ) . ")";
}

# filter for webs
Expand All @@ -86,7 +94,7 @@ sub do {
$w =~ s/\s*$//g;
push @clauses, " i.item_name like '$w%' ";
}
push @whereClauses, join( ' OR ', @clauses );
push @whereClauses, "(" . join( ' OR ', @clauses ) . ")";
}

# filter for topics
Expand Down
3 changes: 2 additions & 1 deletion lib/Foswiki/Plugins/TagsPlugin/Tag.pm
Expand Up @@ -104,6 +104,7 @@ sub rest {

# returning nothing of interest
my $user_id = Foswiki::Plugins::TagsPlugin::getUserId($session, Foswiki::Func::getCanonicalUserID( $user ) );
Foswiki::Func::writeDebug("ID: $user_id");
my $retval = Foswiki::Plugins::TagsPlugin::Tag::do( $item_type, $item_name, $tag_text, $user_id );

# redirect on request
Expand Down Expand Up @@ -218,4 +219,4 @@ sub do {
return $rowCount;
}

1;
1;
44 changes: 44 additions & 0 deletions pub/System/TagsPlugin/tagsplugin.css
@@ -0,0 +1,44 @@
.tagsplugin_container {
border-style:dashed;
border-width:thin;
padding: 10px;
}
.tagsplugin_web {
background-color:#EEEEEE;
display:inline;
margin:2px;
padding:2px;
text-decoration:none;
color:black;
cursor:pointer;
}
.tagsplugin_web_active {
background-color:#B9DAFF;
}
.tagsplugin_tag {
background-color:#EEEEEE;
display:inline;
margin:2px;
padding:2px;
text-decoration:none;
color:black;
}
.tagsplugin_tagcloud {
}
.tagsplugin_tagcloud_tag {
cursor:pointer;
}
.tagsplugin_tagcloud_tag_tagged {
background-color:#B9DAFF;
}
.tagsplugin_tag_remove {
color:red;
cursor:pointer;
padding-left:5px;
}
.tagsplugin_clickable {
cursor:pointer;
}
.tagsplugin_hidden {
display:none;
}

0 comments on commit 574d15e

Please sign in to comment.