Changeset 811 for trunk/EmptyPlugin/lib/Foswiki/Plugins/EmptyPlugin.pm
- Timestamp:
- 11/19/08 15:00:00 (4 years ago)
- Location:
- trunk/EmptyPlugin/lib/Foswiki
- Files:
-
- 1 edited
- 1 moved
-
. (moved) (moved from trunk/EmptyPlugin/lib/TWiki)
-
Plugins/EmptyPlugin.pm (modified) (45 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/EmptyPlugin/lib/Foswiki/Plugins/EmptyPlugin.pm
r781 r811 3 3 # Copyright (C) 2000-2003 Andrea Sterbini, a.sterbini@flashnet.it 4 4 # Copyright (C) 2001-2006 Peter Thoeny, peter@thoeny.org 5 # and TWiki Contributors. All Rights Reserved. TWiki Contributors5 # and Foswiki Contributors. All Rights Reserved. Foswiki Contributors 6 6 # are listed in the AUTHORS file in the root of this distribution. 7 7 # NOTE: Please extend that file, not this notice. … … 28 28 29 29 This version of the !EmptyPlugin documents the handlers supported 30 by revision 1.2 of the Plugins API. See the documentation of = TWiki::Func=30 by revision 1.2 of the Plugins API. See the documentation of =Foswiki::Func= 31 31 for more information about what this revision number means, and how a 32 32 plugin can check it. 33 33 34 34 __NOTE:__ To interact with TWiki use ONLY the official API functions 35 in the TWiki::Func module. Do not reference any functions or35 in the Foswiki::Func module. Do not reference any functions or 36 36 variables elsewhere in TWiki, as these are subject to change 37 37 without prior warning, and your plugin may suddenly stop … … 64 64 65 65 # change the package name and $pluginName!!! 66 package TWiki::Plugins::EmptyPlugin;66 package Foswiki::Plugins::EmptyPlugin; 67 67 68 68 # Always use strict to enforce variable scoping 69 69 use strict; 70 70 71 require TWiki::Func; # The plugins API72 require TWiki::Plugins; # For the API version71 require Foswiki::Func; # The plugins API 72 require Foswiki::Plugins; # For the API version 73 73 74 74 # $VERSION is referred to by TWiki, and is the only global variable that … … 93 93 # stored in the plugin topic. This default is required for compatibility with 94 94 # older plugins, but imposes a significant performance penalty, and 95 # is not recommended. Instead, use $ TWiki::cfg entries set in LocalSite.cfg, or95 # is not recommended. Instead, use $Foswiki::cfg entries set in LocalSite.cfg, or 96 96 # if you want the users to be able to change settings, then use standard TWiki 97 97 # preferences that can be defined in your %USERSWEB%.SitePreferences and overridden … … 114 114 Called to initialise the plugin. If everything is OK, should return 115 115 a non-zero value. On non-fatal failure, should write a message 116 using TWiki::Func::writeWarning and return 0. In this case116 using Foswiki::Func::writeWarning and return 0. In this case 117 117 %FAILEDPLUGINS% will indicate which plugins failed. 118 118 … … 121 121 will be trapped and reported in the browser. 122 122 123 You may also call = TWiki::Func::registerTagHandler= here to register123 You may also call =Foswiki::Func::registerTagHandler= here to register 124 124 a function to handle variables that have standard TWiki syntax - for example, 125 125 =%MYTAG{"my param" myarg="My Arg"}%. You can also override internal … … 138 138 139 139 # check for Plugins.pm versions 140 if( $ TWiki::Plugins::VERSION < 1.026 ) {141 TWiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" );140 if( $Foswiki::Plugins::VERSION < 1.026 ) { 141 Foswiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" ); 142 142 return 0; 143 143 } … … 147 147 148 148 # Set plugin preferences in LocalSite.cfg, like this: 149 # $ TWiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} = 1;149 # $Foswiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} = 1; 150 150 # Always provide a default in case the setting is not defined in 151 151 # LocalSite.cfg. See %SYSTEMWEB%.Plugins for help in adding your plugin 152 152 # configuration to the =configure= interface. 153 my $setting = $ TWiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} || 0;154 $debug = $ TWiki::cfg{Plugins}{EmptyPlugin}{Debug} || 0;153 my $setting = $Foswiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} || 0; 154 $debug = $Foswiki::cfg{Plugins}{EmptyPlugin}{Debug} || 0; 155 155 156 156 # register the _EXAMPLETAG function to handle %EXAMPLETAG{...}% 157 157 # This will be called whenever %EXAMPLETAG% or %EXAMPLETAG{...}% is 158 158 # seen in the topic text. 159 TWiki::Func::registerTagHandler( 'EXAMPLETAG', \&_EXAMPLETAG );159 Foswiki::Func::registerTagHandler( 'EXAMPLETAG', \&_EXAMPLETAG ); 160 160 161 161 # Allow a sub to be called from the REST interface 162 162 # using the provided alias 163 TWiki::Func::registerRESTHandler('example', \&restExample);163 Foswiki::Func::registerRESTHandler('example', \&restExample); 164 164 165 165 # Plugin correctly initialized … … 173 173 # $session - a reference to the TWiki session object (if you don't know 174 174 # what this is, just ignore it) 175 # $params= - a reference to a TWiki::Attrs object containing parameters.175 # $params= - a reference to a Foswiki::Attrs object containing parameters. 176 176 # This can be used as a simple hash that maps parameter names 177 177 # to values, with _DEFAULT being the name for the default … … 215 215 This handler is called very early, immediately after =earlyInitPlugin=. 216 216 217 *Since:* TWiki::Plugins::VERSION = '1.010'217 *Since:* Foswiki::Plugins::VERSION = '1.010' 218 218 219 219 =cut … … 223 223 ### my ( $loginName, $url, $pathInfo ) = @_; 224 224 225 TWiki::Func::writeDebug( "- ${pluginName}::initializeUserHandler( $_[0], $_[1] )" ) if $debug;225 Foswiki::Func::writeDebug( "- ${pluginName}::initializeUserHandler( $_[0], $_[1] )" ) if $debug; 226 226 } 227 227 … … 235 235 Called when a new user registers with this TWiki. 236 236 237 *Since:* TWiki::Plugins::VERSION = '1.010'237 *Since:* Foswiki::Plugins::VERSION = '1.010' 238 238 239 239 =cut … … 243 243 ### my ( $web, $wikiName, $loginName ) = @_; 244 244 245 TWiki::Func::writeDebug( "- ${pluginName}::registrationHandler( $_[0], $_[1] )" ) if $debug;245 Foswiki::Func::writeDebug( "- ${pluginName}::registrationHandler( $_[0], $_[1] )" ) if $debug; 246 246 } 247 247 … … 259 259 260 260 For variables with trivial syntax it is far more efficient to use 261 = TWiki::Func::registerTagHandler= (see =initPlugin=).261 =Foswiki::Func::registerTagHandler= (see =initPlugin=). 262 262 263 263 Plugins that have to parse the entire topic content should implement 264 264 this function. Internal TWiki 265 variables (and any variables declared using = TWiki::Func::registerTagHandler=)265 variables (and any variables declared using =Foswiki::Func::registerTagHandler=) 266 266 are expanded _before_, and then again _after_, this function is called 267 267 to ensure all %<nop>TAGS% are expanded. … … 274 274 handler. Use the =$meta= object. 275 275 276 *Since:* $ TWiki::Plugins::VERSION 1.000276 *Since:* $Foswiki::Plugins::VERSION 1.000 277 277 278 278 =cut … … 288 288 # } 289 289 290 TWiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug;290 Foswiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug; 291 291 292 292 # do custom extension rule, like for example: … … 322 322 ### my ( $text, $topic, $web, $meta ) = @_; 323 323 324 TWiki::Func::writeDebug( "- ${pluginName}::beforeCommonTagsHandler( $_[2].$_[1] )" ) if $debug;324 Foswiki::Func::writeDebug( "- ${pluginName}::beforeCommonTagsHandler( $_[2].$_[1] )" ) if $debug; 325 325 } 326 326 … … 349 349 ### my ( $text, $topic, $web, $meta ) = @_; 350 350 351 TWiki::Func::writeDebug( "- ${pluginName}::afterCommonTagsHandler( $_[2].$_[1] )" ) if $debug;351 Foswiki::Func::writeDebug( "- ${pluginName}::afterCommonTagsHandler( $_[2].$_[1] )" ) if $debug; 352 352 } 353 353 … … 395 395 handler. 396 396 397 Since TWiki::Plugins::VERSION = '1.026'397 Since Foswiki::Plugins::VERSION = '1.026' 398 398 399 399 =cut … … 415 415 handler. 416 416 417 Since TWiki::Plugins::VERSION = '1.026'417 Since Foswiki::Plugins::VERSION = '1.026' 418 418 419 419 =cut … … 436 436 (using %META: tags) 437 437 438 *Since:* TWiki::Plugins::VERSION = '1.010'438 *Since:* Foswiki::Plugins::VERSION = '1.010' 439 439 440 440 =cut … … 444 444 ### my ( $text, $topic, $web ) = @_; 445 445 446 TWiki::Func::writeDebug( "- ${pluginName}::beforeEditHandler( $_[2].$_[1] )" ) if $debug;446 Foswiki::Func::writeDebug( "- ${pluginName}::beforeEditHandler( $_[2].$_[1] )" ) if $debug; 447 447 } 448 448 … … 462 462 handler. Use the =$meta= object. 463 463 464 *Since:* $ TWiki::Plugins::VERSION 1.010464 *Since:* $Foswiki::Plugins::VERSION 1.010 465 465 466 466 =cut … … 470 470 ### my ( $text, $topic, $web ) = @_; 471 471 472 TWiki::Func::writeDebug( "- ${pluginName}::afterEditHandler( $_[2].$_[1] )" ) if $debug;472 Foswiki::Func::writeDebug( "- ${pluginName}::afterEditHandler( $_[2].$_[1] )" ) if $debug; 473 473 } 474 474 … … 479 479 * =$topic= - the name of the topic in the current CGI query 480 480 * =$web= - the name of the web in the current CGI query 481 * =$meta= - the metadata of the topic being saved, represented by a TWiki::Meta object.481 * =$meta= - the metadata of the topic being saved, represented by a Foswiki::Meta object. 482 482 483 483 This handler is called each time a topic is saved. … … 490 490 text format. 491 491 492 *Since:* TWiki::Plugins::VERSION = '1.010'492 *Since:* Foswiki::Plugins::VERSION = '1.010' 493 493 494 494 =cut … … 498 498 ### my ( $text, $topic, $web ) = @_; 499 499 500 TWiki::Func::writeDebug( "- ${pluginName}::beforeSaveHandler( $_[2].$_[1] )" ) if $debug;500 Foswiki::Func::writeDebug( "- ${pluginName}::beforeSaveHandler( $_[2].$_[1] )" ) if $debug; 501 501 } 502 502 … … 509 509 * =$web= - the name of the web in the current CGI query 510 510 * =$error= - any error string returned by the save. 511 * =$meta= - the metadata of the saved topic, represented by a TWiki::Meta object511 * =$meta= - the metadata of the saved topic, represented by a Foswiki::Meta object 512 512 513 513 This handler is called each time a topic is saved. … … 515 515 __NOTE:__ meta-data is embedded in $text (using %META: tags) 516 516 517 *Since:* TWiki::Plugins::VERSION 1.025517 *Since:* Foswiki::Plugins::VERSION 1.025 518 518 519 519 =cut … … 523 523 ### my ( $text, $topic, $web, $error, $meta ) = @_; 524 524 525 TWiki::Func::writeDebug( "- ${pluginName}::afterSaveHandler( $_[2].$_[1] )" ) if $debug;525 Foswiki::Func::writeDebug( "- ${pluginName}::afterSaveHandler( $_[2].$_[1] )" ) if $debug; 526 526 } 527 527 … … 539 539 This handler is called just after the rename/move/delete action of a web, topic or attachment. 540 540 541 *Since:* TWiki::Plugins::VERSION = '1.11'541 *Since:* Foswiki::Plugins::VERSION = '1.11' 542 542 543 543 =cut … … 547 547 ### my ( $oldWeb, $oldTopic, $oldAttachment, $newWeb, $newTopic, $newAttachment ) = @_; 548 548 549 TWiki::Func::writeDebug( "- ${pluginName}::afterRenameHandler( " .549 Foswiki::Func::writeDebug( "- ${pluginName}::afterRenameHandler( " . 550 550 "$_[0].$_[1] $_[2] -> $_[3].$_[4] $_[5] )" ) if $debug; 551 551 } … … 566 566 * =tmpFilename= - name of a temporary file containing the attachment data 567 567 568 *Since:* TWiki::Plugins::VERSION = 1.025568 *Since:* Foswiki::Plugins::VERSION = 1.025 569 569 570 570 =cut … … 573 573 # do not uncomment, use $_[0], $_[1]... instead 574 574 ### my( $attrHashRef, $topic, $web ) = @_; 575 TWiki::Func::writeDebug( "- ${pluginName}::beforeAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug;575 Foswiki::Func::writeDebug( "- ${pluginName}::beforeAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug; 576 576 } 577 577 … … 589 589 * =user= - the user id 590 590 591 *Since:* TWiki::Plugins::VERSION = 1.025591 *Since:* Foswiki::Plugins::VERSION = 1.025 592 592 593 593 =cut … … 596 596 # do not uncomment, use $_[0], $_[1]... instead 597 597 ### my( $attrHashRef, $topic, $web ) = @_; 598 TWiki::Func::writeDebug( "- ${pluginName}::afterAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug;598 Foswiki::Func::writeDebug( "- ${pluginName}::afterAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug; 599 599 } 600 600 … … 641 641 required to resolve concurrent edits on a topic. 642 642 643 *Since:* TWiki::Plugins::VERSION = 1.1643 *Since:* Foswiki::Plugins::VERSION = 1.1 644 644 645 645 =cut … … 663 663 Note that this is the HTTP header which is _not_ the same as the HTML 664 664 <HEAD> tag. The contents of the <HEAD> tag may be manipulated 665 using the = TWiki::Func::addToHEAD= method.666 667 *Since:* TWiki::Plugins::VERSION 1.1665 using the =Foswiki::Func::addToHEAD= method. 666 667 *Since:* Foswiki::Plugins::VERSION 1.1 668 668 669 669 =cut … … 672 672 my ( $headers, $query ) = @_; 673 673 674 TWiki::Func::writeDebug( "- ${pluginName}::modifyHeaderHandler()" ) if $debug;674 Foswiki::Func::writeDebug( "- ${pluginName}::modifyHeaderHandler()" ) if $debug; 675 675 } 676 676 … … 687 687 the others will be ignored. 688 688 689 *Since:* TWiki::Plugins::VERSION 1.010689 *Since:* Foswiki::Plugins::VERSION 1.010 690 690 691 691 =cut … … 695 695 ### my ( $query, $url ) = @_; 696 696 697 TWiki::Func::writeDebug( "- ${pluginName}::redirectCgiQueryHandler( query, $_[1] )" ) if $debug;697 Foswiki::Func::writeDebug( "- ${pluginName}::redirectCgiQueryHandler( query, $_[1] )" ) if $debug; 698 698 } 699 699 … … 717 717 continues by considering the built-in types. 718 718 719 *Since:* TWiki::Plugins::VERSION 1.1719 *Since:* Foswiki::Plugins::VERSION 1.1 720 720 721 721 Note that since TWiki-4.2, you can also extend the range of available 722 types by providing a subclass of = TWiki::Form::FieldDefinition= to implement723 the new type (see = TWiki::Plugins.JSCalendarContrib= and724 = TWiki::Plugins.RatingContrib= for examples). This is the preferred way to722 types by providing a subclass of =Foswiki::Form::FieldDefinition= to implement 723 the new type (see =Foswiki::Plugins.JSCalendarContrib= and 724 =Foswiki::Plugins.RatingContrib= for examples). This is the preferred way to 725 725 extend the form field types, but does not work for TWiki < 4.2. 726 726 … … 743 743 Return the new link text. 744 744 745 *Since:* TWiki::Plugins::VERSION 1.1745 *Since:* Foswiki::Plugins::VERSION 1.1 746 746 747 747 =cut … … 764 764 the page is actually written. This is a string, which must end in \n\n. 765 765 766 *Since:* TWiki::Plugins::VERSION 1.2766 *Since:* Foswiki::Plugins::VERSION 1.2 767 767 768 768 =cut … … 784 784 For more information, check %SYSTEMWEB%.CommandAndCGIScripts#rest 785 785 786 *Since:* TWiki::Plugins::VERSION 1.1786 *Since:* Foswiki::Plugins::VERSION 1.1 787 787 788 788 =cut
Note: See TracChangeset
for help on using the changeset viewer.
