Skip to content

Commit

Permalink
Item1918: added TAGSEARCH, made TAGCLOUD optional, added tagsplugin2 …
Browse files Browse the repository at this point in the history
…skin

git-svn-id: http://svn.foswiki.org/trunk/TagsPlugin@4686 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OliverKrueger authored and OliverKrueger committed Aug 20, 2009
1 parent d935864 commit 5b74ebd
Show file tree
Hide file tree
Showing 12 changed files with 394 additions and 26 deletions.
7 changes: 7 additions & 0 deletions data/System/TagsPluginTagEntrySearch.txt
@@ -0,0 +1,7 @@
%META:TOPICINFO{author="BaseUserMapping_333" date="1250720173" format="1.1" reprev="1.1" version="1.1"}%
%TAGSEARCH{
query="tag"
tag="%URLPARAM{"q"}%%"
format="$tag"
sep="$n"
}%
26 changes: 26 additions & 0 deletions data/System/TagsPluginViewsTagSearch.txt
@@ -0,0 +1,26 @@
%META:TOPICINFO{author="BaseUserMapping_333" date="1250703240" format="1.1" reprev="1.4" version="1.4"}%
<noautolink>

---+++ list of everyone's tags on the current topic
%TAGSEARCH{ web="%BASEWEB%" topic="%BASETOPIC%" }%

---+++ list of %NOP%%WIKINAME%'s tags on the current topic
%TAGSEARCH{ web="%BASEWEB%" topic="%BASETOPIC%" user="%WIKINAME%" }%

---+++ tag cloud of everyone's tags
%TAGCLOUD{ terms="$percntTAGSEARCH{ query=\"tag\" format=\"$tag:$count\" sep=\", \" }$percnt" }%

---+++ tag cloud of everyone's tags on topic ?mytopic=%URLPARAM{"mytopic" default="undef"}%
%TAGCLOUD{ terms="$percntTAGSEARCH{ query=\"tag\" topic=\"$percntURLPARAM{mytopic}$percnt\" format=\"$tag:$count\" sep=\", \" }$percnt" }%

---+++ List of topics tagged with ?tag=%URLPARAM{tag}% (inverse tag lookup)
%TAGSEARCH{ query="topic" tag="%URLPARAM{tag}%" }%

---+++ Complete list by topics
%TAGSEARCH{
query="topic"
header="|*Tag*|*Topic*|*User*|$n"
format="| $tag | [[$item][$item]] | $user |"
sep="$n"
}%
</noautolink>
49 changes: 38 additions & 11 deletions lib/Foswiki/Plugins/TagsPlugin.pm
Expand Up @@ -21,7 +21,7 @@ use vars
qw( $VERSION $RELEASE $SHORTDESCRIPTION $debug $pluginName $NO_PREFS_IN_TOPIC $doneLoadTemplate );
$VERSION = '$Rev$';
$RELEASE = 'Foswiki-1.0.0';
$SHORTDESCRIPTION = ' Full strength Tagging system ';
$SHORTDESCRIPTION = 'Full strength Tagging system ';
$NO_PREFS_IN_TOPIC = 1;
$pluginName = 'TagsPlugin';

Expand All @@ -45,12 +45,12 @@ sub initPlugin {
return 0;
}

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

Foswiki::Func::registerTagHandler( 'TAGLIST', \&_TAGLIST );
Foswiki::Func::registerTagHandler( 'TAGENTRY', \&_TAGENTRY );
Foswiki::Func::registerTagHandler( 'TAGCLOUD', \&_TAGCLOUD );
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::registerRESTHandler( 'tag', \&tagCall );
Foswiki::Func::registerRESTHandler( 'untag', \&untagCall );
Expand Down Expand Up @@ -99,6 +99,26 @@ sub afterSaveHandler {
return;
}

sub afterRenameHandler {
my ( $oldWeb, $oldTopic, $oldAttachment,
$newWeb, $newTopic, $newAttachment ) = @_;

# ignore attachment renamings
# TODO: we should not ignore web renamings
if ( $oldTopic && $newTopic ) {
my $oldLocation = "$oldWeb.$oldTopic";
my $newLocation = "$newWeb.$newTopic";

my $db = new Foswiki::Contrib::DbiContrib;
my $statement = sprintf( 'UPDATE %s SET %s = ? WHERE %s = ? AND %s = ?', qw(Items item_name item_name item_type) );
my $rowCount = $db->dbInsert( $statement, $newLocation, $oldLocation, "topic" );
$db->disconnect();
Foswiki::Func::writeDebug("- ${pluginName}::afterSaveHandler( SQL: $statement, $newLocation, $oldLocation, topic -> $rowCount )");
}

return "";
}

sub _loadTemplate {
return if $doneLoadTemplate;
$doneLoadTemplate = 1;
Expand Down Expand Up @@ -267,6 +287,11 @@ sub _TAGCLOUD {
return _TAGLIST( $session, $params, $theTopic, $theWeb );
}

sub _TAGSEARCH {
use Foswiki::Plugins::TagsPlugin::TAGSEARCH;
return Foswiki::Plugins::TagsPlugin::TAGSEARCH::do( @_ );
}

=pod
---++ tagCall($session) -> $text
Expand Down Expand Up @@ -313,9 +338,9 @@ sub mergeCall {

sub getUserId {
my $session = $_[0];
my $user = $_[1];
my $user_id = $_[1];

my $FoswikiCuid = $user || $session->{user};
my $FoswikiCuid = $user_id || $session->{user};

# if ($session->{users}->isAdmin($FoswikiCuid)) {
# $FoswikiCuid = '333';
Expand Down Expand Up @@ -358,10 +383,12 @@ update the tags for this topic

sub updateTopicTags {
my ( $item_type, $web, $topic, $user_id ) = @_;
my $session = $Foswiki::Plugins::SESSION;


use Foswiki::Plugins::TagsPlugin::Tag;
Foswiki::Plugins::TagsPlugin::Tag::do( $item_type, "$web.$topic", $web, $user_id );

if ( defined($Foswiki::cfg{TagsPlugin}{EnableWebTags}) && $Foswiki::cfg{TagsPlugin}{EnableWebTags} ) {
Foswiki::Plugins::TagsPlugin::Tag::do( $item_type, "$web.$topic", $web, Foswiki::Func::getCanonicalUserID("AdminUser") );
}

my ( $meta, $text );
if ( $Foswiki::cfg{TagsPlugin}{EnableDataForms} || $Foswiki::cfg{TagsPlugin}{EnableCategories} ) {
Expand Down
8 changes: 8 additions & 0 deletions lib/Foswiki/Plugins/TagsPlugin/Config.spec
Expand Up @@ -4,6 +4,10 @@
# setting use to allow you to replace Webs with Tags
$Foswiki::cfg{TagsStore}{FilterByTags} = 0;

# **BOOLEAN**
# automatically create a "web" tag on each topic
$Foswiki::cfg{TagsPlugin}{EnableWebTags} = 1;

# **BOOLEAN**
# automatically create tags for links to topics ending in Category
$Foswiki::cfg{TagsPlugin}{EnableCategories} = 1;
Expand All @@ -12,6 +16,10 @@ $Foswiki::cfg{TagsPlugin}{EnableCategories} = 1;
# automatically create tags for attached DataForms
$Foswiki::cfg{TagsPlugin}{EnableDataForms} = 1;

# **BOOLEAN**
# enable the built-in TAGCLOUD macro
$Foswiki::cfg{TagsPlugin}{EnableTagCloud} = 1;

# **STRING**
# Name of the TagAdminGroup (which is allowed to delete, rename and merge tags)
$Foswiki::cfg{TagsPlugin}{TagAdminGroup} = "AdminGroup";
3 changes: 3 additions & 0 deletions lib/Foswiki/Plugins/TagsPlugin/DEPENDENCIES
@@ -1,3 +1,6 @@
# Dependencies for TagsPlugin
Geo::GeoNames,,cpan,Optional
Foswiki::Contrib::DbiContrib,,perl,Required
Foswiki::Contrib::FamFamFamContrib,,perl,Optional
Foswiki::Plugin::JQueryPlugin,,perl,Optional
Foswiki::Plugin::TagCloudPlugin,,perl,Optional
8 changes: 8 additions & 0 deletions lib/Foswiki/Plugins/TagsPlugin/MANIFEST
@@ -1,7 +1,15 @@
# Release manifest for TagsPlugin
data/System/TagsPlugin.txt 0644 Documentation
data/System/TagsPluginViews.txt 0644 Documentation
data/System/TagsPluginTagEntrySearch.txt 0644 Topic
data/System/TagsPluginViewsTagSearch.txt 0644 Topic
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
templates/tagsplugin.tmpl
templates/view.tagsplugin.tmpl

Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/TagsPlugin/Merge.pm
Expand Up @@ -122,7 +122,7 @@ sub do {
my $tag_id2;
$statement = sprintf( 'SELECT %s from %s WHERE %s = ? AND %s = ?',
qw( item_id Items item_name item_type) );
my $arrayRef = $db->dbSelect( $statement, $tag2, 'tag' );
$arrayRef = $db->dbSelect( $statement, $tag2, 'tag' );
if ( defined( $arrayRef->[0][0] ) ) {
$tag_id2 = $arrayRef->[0][0];
}
Expand Down

0 comments on commit 5b74ebd

Please sign in to comment.