diff --git a/data/TWiki/TopicCreatePlugin.txt b/data/System/TopicCreatePlugin.txt similarity index 54% rename from data/TWiki/TopicCreatePlugin.txt rename to data/System/TopicCreatePlugin.txt index 817779d..00d879b 100644 --- a/data/TWiki/TopicCreatePlugin.txt +++ b/data/System/TopicCreatePlugin.txt @@ -1,26 +1,26 @@ -%META:TOPICINFO{author="StanleyKnutson" date="1132609510" format="1.0" version="1.3"}% +%META:TOPICINFO{author="ProjectContributor" date="1132609510" format="1.1" version="$Rev: 3036 $"}% ---+!! Topic Create Plugin -This Plugin allows you to automatically create topics or attach files at topic save time. This is typically used by TWiki applications to create a set of template based topics. +This Plugin allows you to automatically create topics or attach files at topic save time. This is typically used by Foswiki applications to create a set of template based topics. %TOC% ----++ TOPICCREATE - Automatically Create a Set of TWiki Topics +---++ TOPICCREATE - Automatically Create a Set of Foswiki Topics - * The =%TOPICCREATE{}%= TWikiVariable is useful for creating topics based on templates + * The =%TOPICCREATE{}%= Macro is useful for creating topics based on templates * Example scenario: You have a notebook application where users can create new notebooks based on a notebook template topic. Each time a user creates a new notebook you would like to create a set of child topics, each based on a separate template. * Syntax: =%TOPICCREATE{ <attributes> }%= * Attributes recognized | *Attribute* | *Meaning* | *Valid input* | *Default* | - | =template=""= | Name of TWiki topic to be used as template | Any valid TWiki topic | (required) | - | =topic=""= | Name of new TWiki topic to create | Any valid WikiWord | (required) | + | =template=""= | Name of Foswiki topic to be used as template | Any valid Foswiki topic | (required) | + | =topic=""= | Name of new Foswiki topic to create | Any valid WikiWord | (required) | | =disable=""= | Name of the template topic containing this use of TOPICCREATE | Any valid topic name (WikiWord) | _recommended_ | | =parameters=""= | List of parameters to pass to a child topic to initialize any urlparams.| Following syntax:%BR% =<parameter-name>=<parameter-value>= followed by any number of parameter name, value pairs separated by =&= | No Parameters | - * The action to create the TWiki topic will not occur until one hits the =Save Changes= button in preview + * The action to create the Foswiki topic will not occur until one hits the =Save Changes= button in preview * The =%TOPICCREATE{}%= variable will be removed upon saving of the topic * Any attachments that are in the =template= will also be copied to the new topic * =%TOPICCREATE%= is recursive - * Write =%TOPICCREATE{ template="MyTemplate" topic="%TOPIC%MyNewTopicName" parameters="MyParameterName=MyParameterValue&Hello=Goodbye" }%= to create a twiki topic based on another topic =MyTemplate= with the name =%TOPIC%MyNewTopicName=. Any =%URLPARAM{}%= with the name =MyParameterName= and =Hello= present in =MyTemplate= will be replaced with =MyParameterValue= and =Goodbye=. + * Write =%TOPICCREATE{ template="MyTemplate" topic="%TOPIC%MyNewTopicName" parameters="MyParameterName=MyParameterValue&Hello=Goodbye" }%= to create a foswiki topic based on another topic =MyTemplate= with the name =%TOPIC%MyNewTopicName=. Any =%URLPARAM{}%= with the name =MyParameterName= and =Hello= present in =MyTemplate= will be replaced with =MyParameterValue= and =Goodbye=. * To prevent the action from happening in your template topic you should either include the =disable= argument, or escape it: =%TOPICCRE%NOP%ATE{...}%=. The =%NOP%= gets removed when a topic gets instantiated based on a template. ---++ TOPICATTACH - Automatically Copy Attachments to a Topic @@ -29,42 +29,20 @@ This Plugin allows you to automatically create topics or attach files at topic s * Syntax: =%TOPICATTACH{ <attributes> }%= * Attributes recognized | *Attribute* | *Meaning* | *Valid input* | *Default* | - | =fromtopic=""= | Topic (or Web.Topic) that contains the attachment | Any valid TWiki topic | (required) | + | =fromtopic=""= | Topic (or Web.Topic) that contains the attachment | Any valid Foswiki topic | (required) | | =fromfile=""= | The attachment to copy from | Any attached file from =fromtopic= | (required) | | =disable=""= | Name of the template topic containing this use of TOPICATTACH | Any valid topic name (WikiWord) | (required) | | =comment=""= | Comment to appear for the attachment within this topic, replacing the comment that was in the =fromtopic= | a one line string | {omit parameter if no change desired} | * Write =%TOPICATTACH{ fromtopic="SourceTopic" fromfile="Sample.jpg" name="Snoopy.jpg" disable="..."}%= to attach =Sample.jpg= from topic =SourceTopic= as =Snoopy.jpg= * The parameter value comment is used to change the comment (description) that shows for the topic in the table of attachments * The "hidden" attribute of the topic is removed: the attachment can be hidden in the =fromtopic= if desired - * The =fromtopic= can specify a different web if desired. For example =TWiki.SomeTemplate= would be valid as a =fromtopic= + * The =fromtopic= can specify a different web if desired. For example =Foswiki.SomeTemplate= would be valid as a =fromtopic= * To prevent the action from happening in your template topic you *must* provide the =disable= parameter with the topic name containing the =%TOPICATTACH%=. Limitations/TODO: * There should be a =name= argument to rename the topic as it is copied * The =TOPICATTACH= must be in the 'top level' topic being saved by a =TOPICCREATE=. It can not be in a recursive/subordinate topic invoked by the TOPICCREATE. - - ---++ Plugin Settings Plugin settings are stored as preferences variables. To reference a plugin setting write ==%<plugin>_<setting>%==, i.e. ==%TOPICCREATEPLUGIN_SHORTDESCRIPTION%== @@ -79,51 +57,36 @@ Plugin settings are stored as preferences variables. To reference a plugin setti * This Plugin is Unix specific and depends on the Unix utilities =cp= and =mkdir=. * For safety reasons, the path to the utilities is hardcoded in the Plugin module. The path might need to be changed depending on your environment. - * Precautions have been taken to make this Plugin safe. It does not have ANY WARRANTY, does not even have the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is up to the administrator to decide if this Plugin is safe for a public TWiki site. - ----++ Plugin Installation Instructions - -__Note:__ You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running. - - * Download the ZIP file from the Plugin web (see below) - * Unzip ==%TOPIC%.zip== in your twiki installation directory. Content: - | *File:* | *Description:* | - | ==data/System/%TOPIC%.txt== | Plugin topic | - | ==data/System/%TOPIC%.txt,v== | Plugin topic repository | - | ==lib/Foswiki/Plugins/%TOPIC%.pm== | Plugin Perl module | - | ==lib/Foswiki/Plugins/%TOPIC%/Func.pm== | Perl utilities | - * Test if the installation was successful (Option A) - pollutes you sandbox, but easiest to try - * Unzip the 'sandbox test' attachment in your twiki installation directory - * Go to the topic =Sandbox.CreateClientNotebook= - * Enter a name like "MyTest" and press 'create topics' - * Press "save" on the page that appears - * This will perform these operations: - * Create three topics =MyTest= =MyTestEnvironment= and =MyTestTripLog= - * Copy an attachment from the =CreateClientNotebook= topic to the created trip log - * Test if the installation was successful (Option B) - * Create a test topic called =TestTopicCreate= with this content: %BR% - =%TOPICCREATE{ template="%SYSTEMWEB%.WikiWord" topic="%TOPIC%Child" }%= - * After saving =TestTopicCreate= you should get a new topic =TestTopicCreateChild= with the content of %SYSTEMWEB%.WikiWord. + * Precautions have been taken to make this Plugin safe. It does not have ANY WARRANTY, does not even have the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is up to the administrator to decide if this Plugin is safe for a public Foswiki site. + +---++ Installation Instructions + +%$INSTALL_INSTRUCTIONS% + +---++ Plugin Files + + | *File:* | *Description:* | +%$MANIFEST% ---++ Plugin Info -| Plugin Author: | TWiki:Main.StanleyKnutson, TWiki:Main.PeterThoeny, TWiki:Main.PaulineCheung | -| Plugin Version: | 21 Nov 2005 (V1.01) | +| Plugin Author(s): | Foswiki:Main.AndrewJones | +| Previous Author(s): | TWiki:Main.StanleyKnutson, TWiki:Main.PeterThoeny, TWiki:Main.PaulineCheung | +| Copyright: | © 2009, Andrew Jones, © 2005 - 2006, Peter Thoeny | +| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | +| Plugin Release: | %$RELEASE% | +| Plugin Version: | %$VERSION% | | Change History: |   | -| 11686 | TWikibug:Item2956 - Freeze TWikiRelease04x00 and copy it to new branch MAIN | +| 11686 | TWikibug:Item2956 - Freeze !TWikiRelease04x00 and copy it to new branch MAIN | | 10613 | TWikibug:Item2473 - files in pub and data directories shouldn't be marked executable in svn (Ordnung muss sein) | | 7960 | TWikibug:Item1238 - plugins cleanup: added BuildContrib support/infrastructure | | 7585 | TWikibug:Item1016 - initial import of TopicCreatePlugin (thanks TWiki:Main.StanleyKnutson and others) | | 21 Nov 2005: | Initial TOPICCATTACH | | 30 Apr 2005: | Initial version | -| TWiki Dependency: | $TWiki::Plugins::VERSION 1.024 | -| CPAN Dependencies: | none | +| Dependencies: | %$DEPENDENCIES% | | Other Dependencies: | Unix utilities =cp= and =mkdir= | -| Perl Version: | 5.005 | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | | Plugin Home: | http://foswiki.org/Extensions/%TOPIC% | -| Feedback: | http://foswiki.org/Extensions/%TOPIC%Dev | +| Support: | http://foswiki.org/Support/%TOPIC% | __Related Topics:__ %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences, [[%SYSTEMWEB%.Plugins][Plugins]] - --- TWiki:Main.StanleyKnutson - 21 Nov 2005 diff --git a/lib/TWiki/Plugins/TopicCreatePlugin.pm b/lib/Foswiki/Plugins/TopicCreatePlugin.pm similarity index 54% rename from lib/TWiki/Plugins/TopicCreatePlugin.pm rename to lib/Foswiki/Plugins/TopicCreatePlugin.pm index 1d0e026..3e57604 100644 --- a/lib/TWiki/Plugins/TopicCreatePlugin.pm +++ b/lib/Foswiki/Plugins/TopicCreatePlugin.pm @@ -1,8 +1,9 @@ # Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ # +# Copyright (C) 2009 Andrew Jones, andrewjones86@gmail.com # Copyright (C) 2005-2006 Peter Thoeny, peter@thoeny.org # -# For licensing info read LICENSE file in the TWiki root. +# For licensing info read LICENSE file in the Foswiki root. # 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 @@ -16,35 +17,34 @@ # # As per the GPL, removal of this notice is prohibited. -package TWiki::Plugins::TopicCreatePlugin; +package Foswiki::Plugins::TopicCreatePlugin; # ========================= use vars qw( - $web $topic $user $installWeb $VERSION $debug $doInit + $web $topic $user $installWeb $debug $doInit $VERSION $RELEASE $SHORTDESCRIPTION $pluginName $NO_PREFS_IN_TOPIC ); -$VERSION = '1.000'; # 30 Apr 2005 -$doInit = 0; +our $VERSION = '$Rev$'; +our $RELEASE = '1.0'; +our $SHORTDESCRIPTION = 'Displays the hostname of the server serving Foswiki.'; +our $NO_PREFS_IN_TOPIC = 0; +our $pluginName = 'TopicCreatePlugin'; + +our $doInit = 0; # ========================= sub initPlugin { ( $topic, $web, $user, $installWeb ) = @_; - # check for Plugins.pm versions - if( $TWiki::Plugins::VERSION < 1 ) { - TWiki::Func::writeWarning( "Version mismatch between TopicCreatePlugin and Plugins.pm" ); - return 0; - } - # Get plugin debug flag - $debug = TWiki::Func::getPreferencesFlag( "TOPICCREATEPLUGIN_DEBUG" ); + $debug = Foswiki::Func::getPreferencesFlag( "TOPICCREATEPLUGIN_DEBUG" ); #REMOVE THIS: ##$debug=1; # Plugin correctly initialized - TWiki::Func::writeDebug( "- TWiki::Plugins::TopicCreatePlugin::initPlugin( $web.$topic ) is OK" ) if $debug; + Foswiki::Func::writeDebug( "- Foswiki::Plugins::TopicCreatePlugin::initPlugin( $web.$topic ) is OK" ) if $debug; $doInit = 1; return 1; } @@ -54,37 +54,37 @@ sub beforeSaveHandler { ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead - TWiki::Func::writeDebug( "- TopicCreatePlugin::beforeSaveHandler( $_[2].$_[1] )" ) if $debug; + Foswiki::Func::writeDebug( "- TopicCreatePlugin::beforeSaveHandler( $_[2].$_[1] )" ) if $debug; unless( $_[0] =~ /%TOPIC(CREATE|ATTACH)\{.*?\}%/ ) { # nothing to do return; } - require TWiki::Plugins::TopicCreatePlugin::Func; + require Foswiki::Plugins::TopicCreatePlugin::Func; if( $doInit ) { $doInit = 0; - TWiki::Plugins::TopicCreatePlugin::Func::init( $web, $topic, $user, $debug ); + Foswiki::Plugins::TopicCreatePlugin::Func::init( $web, $topic, $user, $debug ); } - $_[0] =~ s/%TOPICCREATE{(.*)}%[\n\r]*/TWiki::Plugins::TopicCreatePlugin::Func::handleTopicCreate($1, $_[2], $_[1], $_[0] )/geo; + $_[0] =~ s/%TOPICCREATE{(.*)}%[\n\r]*/Foswiki::Plugins::TopicCreatePlugin::Func::handleTopicCreate($1, $_[2], $_[1], $_[0] )/geo; # To be tested and documented - # $_[0] =~ s/%TOPICPATCH{(.*)}%[\n\r]*/TWiki::Plugins::TopicCreatePlugin::Func::handleTopicPatch($1, $_[2], $_[1], $_[0] )/geo; + # $_[0] =~ s/%TOPICPATCH{(.*)}%[\n\r]*/Foswiki::Plugins::TopicCreatePlugin::Func::handleTopicPatch($1, $_[2], $_[1], $_[0] )/geo; if ($_[0] =~ /%TOPICATTACH/){ my @attachMetaData = (); - $_[0] =~ s/%TOPICATTACH{(.*)}%[\n\r]*/TWiki::Plugins::TopicCreatePlugin::Func::handleTopicAttach($1, \@attachMetaData)/geo; + $_[0] =~ s/%TOPICATTACH{(.*)}%[\n\r]*/Foswiki::Plugins::TopicCreatePlugin::Func::handleTopicAttach($1, \@attachMetaData)/geo; my $fileName = ""; foreach my $fileMeta ( @attachMetaData ) { $fileMeta =~ m/META:FILEATTACHMENT\{name\=\"(.*?)\"/; $fileName = $1; unless ($_[0] =~ m/META:FILEATTACHMENT\{name\=\"$fileName/ ) { - &TWiki::Func::writeDebug( "handleTopicAttach:: in unless $fileMeta") if $debug; + &Foswiki::Func::writeDebug( "handleTopicAttach:: in unless $fileMeta") if $debug; $_[0] .= "\n$fileMeta"; } else { - &TWiki::Func::writeDebug( "handleTopicAttach:: in else $fileMeta") if $debug; + &Foswiki::Func::writeDebug( "handleTopicAttach:: in else $fileMeta") if $debug; $_[0] =~ s/(%META:FILEATTACHMENT\{name=\"$fileName.*?\}%)/$fileMeta/; } } diff --git a/lib/Foswiki/Plugins/TopicCreatePlugin/DEPENDENCIES b/lib/Foswiki/Plugins/TopicCreatePlugin/DEPENDENCIES new file mode 100644 index 0000000..8fc6f12 --- /dev/null +++ b/lib/Foswiki/Plugins/TopicCreatePlugin/DEPENDENCIES @@ -0,0 +1,3 @@ +# Dependecies for TopicCreatePlugin +cp,>=0,unix,Required Unix utility +mkdir,>=0,unix,Required Unix utility diff --git a/lib/TWiki/Plugins/TopicCreatePlugin/Func.pm b/lib/Foswiki/Plugins/TopicCreatePlugin/Func.pm similarity index 73% rename from lib/TWiki/Plugins/TopicCreatePlugin/Func.pm rename to lib/Foswiki/Plugins/TopicCreatePlugin/Func.pm index 6c123da..c2d6c2f 100644 --- a/lib/TWiki/Plugins/TopicCreatePlugin/Func.pm +++ b/lib/Foswiki/Plugins/TopicCreatePlugin/Func.pm @@ -1,8 +1,9 @@ # Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/ # +# Copyright (C) 2009 Andrew Jones, andrewjones86@gmail.com # Copyright (C) 2005-2006 Peter Thoeny, peter@thoeny.org # -# For licensing info read LICENSE file in the TWiki root. +# For licensing info read LICENSE file in the Foswiki root. # 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 @@ -22,7 +23,7 @@ # performance reasons, so it doesn't get compiled until it # is actually used. -package TWiki::Plugins::TopicCreatePlugin::Func; +package Foswiki::Plugins::TopicCreatePlugin::Func; use strict; @@ -48,7 +49,7 @@ sub init # initialize variables, once per page view # Module initialized - TWiki::Func::writeDebug( "- TWiki::Plugins::TopicCreatePlugin::Func::init( $web.$topic )" ) if $debug; + Foswiki::Func::writeDebug( "- Foswiki::Plugins::TopicCreatePlugin::Func::init( $web.$topic )" ) if $debug; return 1; } @@ -62,13 +63,13 @@ sub handleTopicCreate } my $errVar = "%TOPICCREATE{$theArgs}%"; - my $template = TWiki::Func::extractNameValuePair( $theArgs, "template" ) || + my $template = Foswiki::Func::extractNameValuePair( $theArgs, "template" ) || return _errorMsg( $errVar, "Parameter =templatete= is missing or empty." ); - my $parameters = TWiki::Func::extractNameValuePair( $theArgs, "parameters" ) || ""; - my $topicName = TWiki::Func::extractNameValuePair( $theArgs, "topic" ) || - TWiki::Func::extractNameValuePair( $theArgs, "name" ) || + my $parameters = Foswiki::Func::extractNameValuePair( $theArgs, "parameters" ) || ""; + my $topicName = Foswiki::Func::extractNameValuePair( $theArgs, "topic" ) || + Foswiki::Func::extractNameValuePair( $theArgs, "name" ) || return _errorMsg( $errVar, "Parameter =topic= is missing or empty." ); - my $disable = TWiki::Func::extractNameValuePair( $theArgs, "disable" ) || ""; + my $disable = Foswiki::Func::extractNameValuePair( $theArgs, "disable" ) || ""; if($disable eq $topic) { # saving the outer template itself should not invoke the create @@ -78,9 +79,9 @@ sub handleTopicCreate # SMELL: shouldn't this expand all variables? (eg, if you using something like Web.%NEWTOPIC%?) # should i just expand the loaded topic or continue expanded the variables in these variables # (i'm concerned about the implications of expanding the topic because this can be called recursively) - $topicName = TWiki::Func::expandCommonVariables( $topicName, $theTopic, $theWeb ); - $template = TWiki::Func::expandCommonVariables( $template, $theTopic, $theWeb ); - # expand relevant twikiVariables + $topicName = Foswiki::Func::expandCommonVariables( $topicName, $theTopic, $theWeb ); + $template = Foswiki::Func::expandCommonVariables( $template, $theTopic, $theWeb ); + # expand relevant Foswiki Macros # $topicName =~ s/%TOPIC%/$theTopic/go; # $topicName =~ s/%WEB%/$theWeb/go; # $template =~ s/%TOPIC%/$theTopic/go; @@ -92,7 +93,7 @@ sub handleTopicCreate $topicName = $2; } - if( TWiki::Func::topicExists( $topicWeb, $topicName ) ) { + if( Foswiki::Func::topicExists( $topicWeb, $topicName ) ) { # Silently fail return ""; } @@ -105,21 +106,21 @@ sub handleTopicCreate } # Error, Warn user - unless( &TWiki::Func::topicExists( $templateWeb, $template ) ) { + unless( &Foswiki::Func::topicExists( $templateWeb, $template ) ) { return _errorMsg( $errVar, "Template $templateWeb.$template does not exist."); } - my $text = &TWiki::Func::readTopicText( $templateWeb, $template, "", 1 ); + my $text = &Foswiki::Func::readTopicText( $templateWeb, $template, "", 1 ); # Set topic parent # SMELL: should use $meta object $text = _setMetaData( $text, "TOPICPARENT", $theTopic ); - # SMELL: replace 'gmtime' with twiki preferences variable (i think there's one defined for this...) - my $localDate = &TWiki::Func::formatTime( time(), "\$day \$month \$year", "gmtime" ); + # SMELL: replace 'gmtime' with foswiki preferences variable (i think there's one defined for this...) + my $localDate = &Foswiki::Func::formatTime( time(), "\$day \$month \$year", "gmtime" ); # SMELL: replace with expandVariablesOnTopicCreation( $text ); - my $wikiUserName = &TWiki::Func::userToWikiName( $user ); + my $wikiUserName = &Foswiki::Func::userToWikiName( $user ); $text =~ s/%NOP{.*?}%//gos; # Remove filler: Use it to remove access control at time of $text =~ s/%NOP%//go; # topic instantiation or to prevent search from hitting a template $text =~ s/%DATE%/$localDate/go; @@ -136,7 +137,7 @@ sub handleTopicCreate } my $ptemp = join ", ", @param; - &TWiki::Func::writeDebug( "- TWiki::Plugins::TopicCreatePlugin::topicCreate " + &Foswiki::Func::writeDebug( "- Foswiki::Plugins::TopicCreatePlugin::topicCreate " . "$topicName $ptemp $parameters") if $debug; my $passedPar = ""; @@ -148,7 +149,7 @@ sub handleTopicCreate # END SMELL # Copy Attachments over - my $pubDir = &TWiki::Func::getPubDir(); + my $pubDir = &Foswiki::Func::getPubDir(); if( -e "$pubDir/$templateWeb/$template" ) { # Right now if topic already exists, it silently fails above, # need to fix this if something else happens @@ -157,10 +158,10 @@ sub handleTopicCreate } # Recursively handle TOPICCREATE and TOPICATTCH - $text =~ s/%TOPICCREATE{(.*)}%[\n\r]*/handleTopicCreate( $1, $topicName )/geo; - $text =~ s/%TOPICATTCH{(.*)}%[\n\r]*/handleTopicAttach( $1, $topicName )/geo; + $text =~ s/%TOPICCREATE{(.*)}%[\n\r]*/handleTopicCreate( $1, $theWeb, $topicName )/geo; + $text =~ s/%TOPICATTCH{(.*)}%[\n\r]*/handleTopicAttach( $1, $theWeb, $topicName )/geo; - my $error = &TWiki::Func::saveTopicText( $topicWeb, $topicName, $text, 1, "dont notify" ); + my $error = &Foswiki::Func::saveTopicText( $topicWeb, $topicName, $text, 1, "dont notify" ); if( $error ) { return "%RED%Error saving $topicName%ENDCOLOR%$error"; @@ -175,23 +176,23 @@ sub handleTopicPatch my( $theArgs, $theWeb, $theTopic, $theTopicText ) = @_; my $errVar = "%TOPICPATCH{$theArgs}%"; - my $topicName = TWiki::Func::extractNameValuePair( $theArgs, "topic" ) || + my $topicName = Foswiki::Func::extractNameValuePair( $theArgs, "topic" ) || return ""; # Silently fail if not specified - my $action = TWiki::Func::extractNameValuePair( $theArgs, "action" ) || + my $action = Foswiki::Func::extractNameValuePair( $theArgs, "action" ) || return _errorMsg( $errVar, "Missing =action= parameter" ); unless( $action =~ /^(append|replace)$/ ) { return _errorMsg( $errVar, "Unsupported =action= parameter" ); } - my $formfield = TWiki::Func::extractNameValuePair( $theArgs, "formfield" ) || + my $formfield = Foswiki::Func::extractNameValuePair( $theArgs, "formfield" ) || return _errorMsg( $errVar, "Missing =formfield= parameter" ); - my $value = TWiki::Func::extractNameValuePair( $theArgs, "value" ) || ""; + my $value = Foswiki::Func::extractNameValuePair( $theArgs, "value" ) || ""; - # expand relevant TWiki Variables + # expand relevant Foswiki Variables $topicName =~ s/%TOPIC%/$theTopic/go; $topicName =~ s/%WEB%/$theWeb/go; $topicName =~ s/.*\.//go; # cut web for security (only current web) - my $text = TWiki::Func::readTopicText( $theWeb, $topicName ); + my $text = Foswiki::Func::readTopicText( $theWeb, $topicName ); if( $text =~ /^http/ ) { return _errorMsg( $errVar, "No permission to update '$topicName'" ); @@ -201,7 +202,7 @@ sub handleTopicPatch $text = _setMetaData( $text, "FIELD", $value, $formfield ); - my $error = TWiki::Func::saveTopicText( $theWeb, $topicName, $text, "", "dont notify" ); + my $error = Foswiki::Func::saveTopicText( $theWeb, $topicName, $text, "", "dont notify" ); if( $error ) { return _errorMsg( $errVar, "Can't update '$topicName' due to permissions" ); @@ -217,15 +218,15 @@ sub handleTopicAttach my( $theArgs, $attachMetaDataRef ) = @_; my $errVar = "%TOPICATTACH{$theArgs}%"; - my $fromTopic = TWiki::Func::extractNameValuePair( $theArgs, "fromtopic" ) || + my $fromTopic = Foswiki::Func::extractNameValuePair( $theArgs, "fromtopic" ) || return _errorMsg( $errVar, "Missing =fromtopic= parameter" ); - my $fromFile = TWiki::Func::extractNameValuePair( $theArgs, "fromfile" ) || + my $fromFile = Foswiki::Func::extractNameValuePair( $theArgs, "fromfile" ) || return _errorMsg( $errVar, "Missing =fromfile= parameter" ); - my $attachComment = TWiki::Func::extractNameValuePair( $theArgs, "comment" ); - my $disable = TWiki::Func::extractNameValuePair( $theArgs, "disable" ) || ""; + my $attachComment = Foswiki::Func::extractNameValuePair( $theArgs, "comment" ); + my $disable = Foswiki::Func::extractNameValuePair( $theArgs, "disable" ) || ""; ## 11/18/05: override of attachment name not yet supported, requires messing with meta info - ## my $name = TWiki::Func::extractNameValuePair( $theArgs, "name" ) || $fromFile; + ## my $name = Foswiki::Func::extractNameValuePair( $theArgs, "name" ) || $fromFile; my $name = $fromFile; if($disable eq $topic) { @@ -249,7 +250,7 @@ sub handleTopicAttach # Copy attachment over if( _existAttachment( $fromTopicWeb, $fromTopic, $fromFile ) ) { _copyAttachment( $fromTopicWeb, $fromTopic, $fromFile, $web, $topic, $name ); - my $fromTopicText = &TWiki::Func::readTopicText( $fromTopicWeb, $fromTopic, "", 1 ); + my $fromTopicText = &Foswiki::Func::readTopicText( $fromTopicWeb, $fromTopic, "", 1 ); $fromTopicText =~ m/(%META:FILEATTACHMENT\{name=\"$fromFile.*?\}%)/; my $attachInfo = $1; $attachInfo =~ s/attr="h"/attr=""/; @@ -259,7 +260,7 @@ sub handleTopicAttach } push @$attachMetaDataRef, ($attachInfo); } else { - &TWiki::Func::writeDebug( "- TWiki::Plugins::TopicCreatePlugin::handleTopicAttach:: $fromFile does not exist in $fromTopicWeb/$fromTopic" ) if $debug; + &Foswiki::Func::writeDebug( "- Foswiki::Plugins::TopicCreatePlugin::handleTopicAttach:: $fromFile does not exist in $fromTopicWeb/$fromTopic" ) if $debug; return _errorMsg( $errVar, "Attachment =$fromFile= does not exist in source topic $fromTopicWeb.$fromTopic" ); } return ""; @@ -326,9 +327,9 @@ sub _existAttachment { my ( $theWeb, $theTopic, $theFile ) = @_; - my $pubDir = &TWiki::Func::getPubDir(); + my $pubDir = &Foswiki::Func::getPubDir(); - &TWiki::Func::writeDebug( "- TWiki::Plugins::TopicCreatePlugin::checking $pubDir/$theWeb/$theTopic/$theFile"); + &Foswiki::Func::writeDebug( "- Foswiki::Plugins::TopicCreatePlugin::checking $pubDir/$theWeb/$theTopic/$theFile"); return( -e "$pubDir/$theWeb/$theTopic/$theFile" ); } @@ -338,14 +339,14 @@ sub _copyAttachment { my ( $fromWeb, $fromTopic, $fromFile, $toWeb, $toTopic, $toFile ) = @_; - my $pubDir = &TWiki::Func::getPubDir(); + my $pubDir = &Foswiki::Func::getPubDir(); unless( -e "$pubDir/$toWeb/$toTopic") { `$mkdirCmd $pubDir/$toWeb/$toTopic`; } # IMPLICIT ASSUMPTION of RCS backend storage, should really use storage api `$cpCmd $pubDir/$fromWeb/$fromTopic/$fromFile $pubDir/$toWeb/$toTopic/$toFile`; `$cpCmd $pubDir/$fromWeb/$fromTopic/$fromFile,v $pubDir/$toWeb/$toTopic/$toFile,v`; - &TWiki::Func::writeDebug( "- TWiki::Plugins::TopicCreatePlugin::copyAttachment from $fromWeb/$fromTopic/$fromFile to $toWeb/$toTopic/$toFile -- $cpCmd $pubDir/$fromWeb/$fromTopic/$fromFile,v $pubDir/$toWeb/$toTopic/$toFile,v") if $debug; + &Foswiki::Func::writeDebug( "- Foswiki::Plugins::TopicCreatePlugin::copyAttachment from $fromWeb/$fromTopic/$fromFile to $toWeb/$toTopic/$toFile -- $cpCmd $pubDir/$fromWeb/$fromTopic/$fromFile,v $pubDir/$toWeb/$toTopic/$toFile,v") if $debug; } diff --git a/lib/Foswiki/Plugins/TopicCreatePlugin/MANIFEST b/lib/Foswiki/Plugins/TopicCreatePlugin/MANIFEST new file mode 100644 index 0000000..333d2be --- /dev/null +++ b/lib/Foswiki/Plugins/TopicCreatePlugin/MANIFEST @@ -0,0 +1,3 @@ +lib/Foswiki/Plugins/TopicCreatePlugin.pm +lib/Foswiki/Plugins/TopicCreatePlugin/Func.pm +data/System/TopicCreatePlugin.txt diff --git a/lib/TWiki/Plugins/TopicCreatePlugin/build.pl b/lib/Foswiki/Plugins/TopicCreatePlugin/build.pl similarity index 72% rename from lib/TWiki/Plugins/TopicCreatePlugin/build.pl rename to lib/Foswiki/Plugins/TopicCreatePlugin/build.pl index 1b851f6..8bfd5b0 100755 --- a/lib/TWiki/Plugins/TopicCreatePlugin/build.pl +++ b/lib/Foswiki/Plugins/TopicCreatePlugin/build.pl @@ -6,10 +6,10 @@ BEGIN unshift @INC, split(/:/, $ENV{FOSWIKI_LIBS}); } -use TWiki::Contrib::Build; +use Foswiki::Contrib::Build; # Create the build object -$build = new TWiki::Contrib::Build( 'TopicCreatePlugin' ); +$build = new Foswiki::Contrib::Build( 'TopicCreatePlugin' ); # Build the target on the command line, or the default target $build->build($build->{target}); diff --git a/lib/TWiki/Plugins/TopicCreatePlugin/DEPENDENCIES b/lib/TWiki/Plugins/TopicCreatePlugin/DEPENDENCIES deleted file mode 100644 index e69de29..0000000 diff --git a/lib/TWiki/Plugins/TopicCreatePlugin/MANIFEST b/lib/TWiki/Plugins/TopicCreatePlugin/MANIFEST deleted file mode 100644 index 163d9e7..0000000 --- a/lib/TWiki/Plugins/TopicCreatePlugin/MANIFEST +++ /dev/null @@ -1,3 +0,0 @@ -lib/TWiki/Plugins/TopicCreatePlugin.pm -lib/TWiki/Plugins/TopicCreatePlugin/Func.pm -data/TWiki/TopicCreatePlugin.txt