- Timestamp:
- 11/19/08 16:05:12 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/TWikiCompatibilityPlugin/lib/TWiki/Plugins/TWikiCompatibilityPlugin.pm
r807 r812 25 25 use strict; 26 26 27 require TWiki::Func; # The plugins API28 require TWiki::Plugins; # For the API version27 require Foswiki::Func; # The plugins API 28 require Foswiki::Plugins; # For the API version 29 29 use vars qw( $VERSION $RELEASE $SHORTDESCRIPTION $debug $pluginName $NO_PREFS_IN_TOPIC ); 30 30 $VERSION = '$Rev$'; … … 46 46 sub initPlugin { 47 47 my( $topic, $web, $user, $installWeb ) = @_; 48 49 # check for Plugins.pm versions50 if( $TWiki::Plugins::VERSION < 1.026 ) {51 TWiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" );52 return 0;53 }54 55 my $setting = $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{ExampleSetting} || 0;56 $debug = $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{Debug} || 0;57 58 TWiki::Func::registerTagHandler( 'EXAMPLETAG', \&_EXAMPLETAG );59 TWiki::Func::registerRESTHandler('example', \&restExample);60 61 48 return 1; 62 }63 64 # The function used to handle the %EXAMPLETAG{...}% variable65 # You would have one of these for each variable you want to process.66 sub _EXAMPLETAG {67 my($session, $params, $theTopic, $theWeb) = @_;68 # $session - a reference to the TWiki session object (if you don't know69 # what this is, just ignore it)70 # $params= - a reference to a TWiki::Attrs object containing parameters.71 # This can be used as a simple hash that maps parameter names72 # to values, with _DEFAULT being the name for the default73 # parameter.74 # $theTopic - name of the topic in the query75 # $theWeb - name of the web in the query76 # Return: the result of processing the variable77 78 # For example, %EXAMPLETAG{'hamburger' sideorder="onions"}%79 # $params->{_DEFAULT} will be 'hamburger'80 # $params->{sideorder} will be 'onions'81 49 } 82 50 … … 87 55 If the TWiki web does not exist, change the request to the %SYSTEMWEB% 88 56 89 This may not be enough for Plugins that do have in topic preferences.57 This may not be enough for Plugins that do have in topic preferences. 90 58 91 59 =cut 92 60 93 61 sub earlyInitPlugin { 94 if (($TWiki::Plugins::SESSION->{webName} eq 'TWiki') && 95 (!TWiki::Func::webExists($TWiki::Plugins::SESSION->{webName}))) { 96 my $TWikiWebTopicNameConversion = $TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{TWikiWebTopicNameConversion}; 97 $TWiki::Plugins::SESSION->{webName} = $TWiki::cfg{SystemWebName}; 98 if (defined($TWikiWebTopicNameConversion->{$TWiki::Plugins::SESSION->{topicName}})) { 99 $TWiki::Plugins::SESSION->{topicName} = 100 $TWikiWebTopicNameConversion->{$TWiki::Plugins::SESSION->{topicName}}; 62 63 =pod 64 65 Commented out because it redirects requests to value plugin topics for TWiki plugins, which are still in TWiki web - CDot 66 67 if (($Foswiki::Plugins::SESSION->{webName} eq 'TWiki') && 68 (!Foswiki::Func::webExists($Foswiki::Plugins::SESSION->{webName}))) { 69 my $TWikiWebTopicNameConversion = $Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{TWikiWebTopicNameConversion}; 70 $Foswiki::Plugins::SESSION->{webName} = $Foswiki::cfg{SystemWebName}; 71 if (defined($TWikiWebTopicNameConversion->{$Foswiki::Plugins::SESSION->{topicName}})) { 72 $Foswiki::Plugins::SESSION->{topicName} = 73 $TWikiWebTopicNameConversion->{$Foswiki::Plugins::SESSION->{topicName}}; 101 74 } 102 75 } 103 my $MainWebTopicNameConversion = $ TWiki::cfg{Plugins}{TWikiCompatibilityPlugin}{MainWebTopicNameConversion};104 if (($ TWiki::Plugins::SESSION->{webName} eq 'Main') &&105 (defined($MainWebTopicNameConversion->{$ TWiki::Plugins::SESSION->{topicName}}))) {106 $ TWiki::Plugins::SESSION->{topicName} =107 $MainWebTopicNameConversion->{$ TWiki::Plugins::SESSION->{topicName}};76 my $MainWebTopicNameConversion = $Foswiki::cfg{Plugins}{TWikiCompatibilityPlugin}{MainWebTopicNameConversion}; 77 if (($Foswiki::Plugins::SESSION->{webName} eq 'Main') && 78 (defined($MainWebTopicNameConversion->{$Foswiki::Plugins::SESSION->{topicName}}))) { 79 $Foswiki::Plugins::SESSION->{topicName} = 80 $MainWebTopicNameConversion->{$Foswiki::Plugins::SESSION->{topicName}}; 108 81 } 109 82 110 83 #Map TWIKIWEB to SYSTEMWEB and MAINWEB to USERSWEB 111 84 #TODO: should we test for existance and other things? 112 TWiki::Func::setPreferencesValue('TWIKIWEB', 'SYSTEMWEB'); 113 TWiki::Func::setPreferencesValue('MAINWEB', 'USERSWEB'); 114 85 Foswiki::Func::setPreferencesValue('TWIKIWEB', 'SYSTEMWEB'); 86 Foswiki::Func::setPreferencesValue('MAINWEB', 'USERSWEB'); 87 88 =cut 89 115 90 return; 116 91 } 117 92 118 =pod119 120 ---++ initializeUserHandler( $loginName, $url, $pathInfo )121 * =$loginName= - login name recovered from $ENV{REMOTE_USER}122 * =$url= - request url123 * =$pathInfo= - pathinfo from the CGI query124 Allows a plugin to set the username. Normally TWiki gets the username125 from the login manager. This handler gives you a chance to override the126 login manager.127 128 Return the *login* name.129 130 This handler is called very early, immediately after =earlyInitPlugin=.131 132 *Since:* TWiki::Plugins::VERSION = '1.010'133 134 =cut135 136 sub DISABLE_initializeUserHandler {137 # do not uncomment, use $_[0], $_[1]... instead138 ### my ( $loginName, $url, $pathInfo ) = @_;139 140 TWiki::Func::writeDebug( "- ${pluginName}::initializeUserHandler( $_[0], $_[1] )" ) if $debug;141 }142 143 =pod144 145 ---++ registrationHandler($web, $wikiName, $loginName )146 * =$web= - the name of the web in the current CGI query147 * =$wikiName= - users wiki name148 * =$loginName= - users login name149 150 Called when a new user registers with this TWiki.151 152 *Since:* TWiki::Plugins::VERSION = '1.010'153 154 =cut155 156 sub DISABLE_registrationHandler {157 # do not uncomment, use $_[0], $_[1]... instead158 ### my ( $web, $wikiName, $loginName ) = @_;159 160 TWiki::Func::writeDebug( "- ${pluginName}::registrationHandler( $_[0], $_[1] )" ) if $debug;161 }162 163 =pod164 165 ---++ commonTagsHandler($text, $topic, $web, $included, $meta )166 * =$text= - text to be processed167 * =$topic= - the name of the topic in the current CGI query168 * =$web= - the name of the web in the current CGI query169 * =$included= - Boolean flag indicating whether the handler is invoked on an included topic170 * =$meta= - meta-data object for the topic MAY BE =undef=171 This handler is called by the code that expands %<nop>TAGS% syntax in172 the topic body and in form fields. It may be called many times while173 a topic is being rendered.174 175 For variables with trivial syntax it is far more efficient to use176 =TWiki::Func::registerTagHandler= (see =initPlugin=).177 178 Plugins that have to parse the entire topic content should implement179 this function. Internal TWiki180 variables (and any variables declared using =TWiki::Func::registerTagHandler=)181 are expanded _before_, and then again _after_, this function is called182 to ensure all %<nop>TAGS% are expanded.183 184 __NOTE:__ when this handler is called, <verbatim> blocks have been185 removed from the text (though all other blocks such as <pre> and186 <noautolink> are still present).187 188 __NOTE:__ meta-data is _not_ embedded in the text passed to this189 handler. Use the =$meta= object.190 191 *Since:* $TWiki::Plugins::VERSION 1.000192 193 =cut194 195 sub DISABLE_commonTagsHandler {196 # do not uncomment, use $_[0], $_[1]... instead197 ### my ( $text, $topic, $web, $included, $meta ) = @_;198 199 # If you don't want to be called from nested includes...200 # if( $_[3] ) {201 # # bail out, handler called from an %INCLUDE{}%202 # return;203 # }204 205 TWiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug;206 207 # do custom extension rule, like for example:208 # $_[0] =~ s/%XYZ%/&handleXyz()/ge;209 # $_[0] =~ s/%XYZ{(.*?)}%/&handleXyz($1)/ge;210 }211 212 =pod213 214 ---++ beforeCommonTagsHandler($text, $topic, $web, $meta )215 * =$text= - text to be processed216 * =$topic= - the name of the topic in the current CGI query217 * =$web= - the name of the web in the current CGI query218 * =$meta= - meta-data object for the topic MAY BE =undef=219 This handler is called before TWiki does any expansion of it's own220 internal variables. It is designed for use by cache plugins. Note that221 when this handler is called, <verbatim> blocks are still present222 in the text.223 224 __NOTE__: This handler is called once for each call to225 =commonTagsHandler= i.e. it may be called many times during the226 rendering of a topic.227 228 __NOTE:__ meta-data is _not_ embedded in the text passed to this229 handler.230 231 __NOTE:__ This handler is not separately called on included topics.232 233 =cut234 235 sub DISABLE_beforeCommonTagsHandler {236 # do not uncomment, use $_[0], $_[1]... instead237 ### my ( $text, $topic, $web, $meta ) = @_;238 239 TWiki::Func::writeDebug( "- ${pluginName}::beforeCommonTagsHandler( $_[2].$_[1] )" ) if $debug;240 }241 242 =pod243 244 ---++ afterCommonTagsHandler($text, $topic, $web, $meta )245 * =$text= - text to be processed246 * =$topic= - the name of the topic in the current CGI query247 * =$web= - the name of the web in the current CGI query248 * =$meta= - meta-data object for the topic MAY BE =undef=249 This handler is after TWiki has completed expansion of %TAGS%.250 It is designed for use by cache plugins. Note that when this handler251 is called, <verbatim> blocks are present in the text.252 253 __NOTE__: This handler is called once for each call to254 =commonTagsHandler= i.e. it may be called many times during the255 rendering of a topic.256 257 __NOTE:__ meta-data is _not_ embedded in the text passed to this258 handler.259 260 =cut261 262 sub DISABLE_afterCommonTagsHandler {263 # do not uncomment, use $_[0], $_[1]... instead264 ### my ( $text, $topic, $web, $meta ) = @_;265 266 TWiki::Func::writeDebug( "- ${pluginName}::afterCommonTagsHandler( $_[2].$_[1] )" ) if $debug;267 }268 269 =pod270 271 ---++ preRenderingHandler( $text, \%map )272 * =$text= - text, with the head, verbatim and pre blocks replaced with placeholders273 * =\%removed= - reference to a hash that maps the placeholders to the removed blocks.274 275 Handler called immediately before TWiki syntax structures (such as lists) are276 processed, but after all variables have been expanded. Use this handler to277 process special syntax only recognised by your plugin.278 279 Placeholders are text strings constructed using the tag name and a280 sequence number e.g. 'pre1', "verbatim6", "head1" etc. Placeholders are281 inserted into the text inside <!--!marker!--> characters so the282 text will contain <!--!pre1!--> for placeholder pre1.283 284 Each removed block is represented by the block text and the parameters285 passed to the tag (usually empty) e.g. for286 <verbatim>287 <pre class='slobadob'>288 XYZ289 </pre>290 the map will contain:291 <pre>292 $removed->{'pre1'}{text}: XYZ293 $removed->{'pre1'}{params}: class="slobadob"294 </pre>295 Iterating over blocks for a single tag is easy. For example, to prepend a296 line number to every line of every pre block you might use this code:297 <verbatim>298 foreach my $placeholder ( keys %$map ) {299 if( $placeholder =~ /^pre/i ) {300 my $n = 1;301 $map->{$placeholder}{text} =~ s/^/$n++/gem;302 }303 }304 </verbatim>305 306 __NOTE__: This handler is called once for each rendered block of text i.e.307 it may be called several times during the rendering of a topic.308 309 __NOTE:__ meta-data is _not_ embedded in the text passed to this310 handler.311 312 Since TWiki::Plugins::VERSION = '1.026'313 314 =cut315 316 sub DISABLE_preRenderingHandler {317 # do not uncomment, use $_[0], $_[1]... instead318 #my( $text, $pMap ) = @_;319 }320 321 =pod322 323 ---++ postRenderingHandler( $text )324 * =$text= - the text that has just been rendered. May be modified in place.325 326 __NOTE__: This handler is called once for each rendered block of text i.e.327 it may be called several times during the rendering of a topic.328 329 __NOTE:__ meta-data is _not_ embedded in the text passed to this330 handler.331 332 Since TWiki::Plugins::VERSION = '1.026'333 334 =cut335 336 sub DISABLE_postRenderingHandler {337 # do not uncomment, use $_[0], $_[1]... instead338 #my $text = shift;339 }340 341 =pod342 343 ---++ beforeEditHandler($text, $topic, $web )344 * =$text= - text that will be edited345 * =$topic= - the name of the topic in the current CGI query346 * =$web= - the name of the web in the current CGI query347 This handler is called by the edit script just before presenting the edit text348 in the edit box. It is called once when the =edit= script is run.349 350 __NOTE__: meta-data may be embedded in the text passed to this handler351 (using %META: tags)352 353 *Since:* TWiki::Plugins::VERSION = '1.010'354 355 =cut356 357 sub DISABLE_beforeEditHandler {358 # do not uncomment, use $_[0], $_[1]... instead359 ### my ( $text, $topic, $web ) = @_;360 361 TWiki::Func::writeDebug( "- ${pluginName}::beforeEditHandler( $_[2].$_[1] )" ) if $debug;362 }363 364 =pod365 366 ---++ afterEditHandler($text, $topic, $web, $meta )367 * =$text= - text that is being previewed368 * =$topic= - the name of the topic in the current CGI query369 * =$web= - the name of the web in the current CGI query370 * =$meta= - meta-data for the topic.371 This handler is called by the preview script just before presenting the text.372 It is called once when the =preview= script is run.373 374 __NOTE:__ this handler is _not_ called unless the text is previewed.375 376 __NOTE:__ meta-data is _not_ embedded in the text passed to this377 handler. Use the =$meta= object.378 379 *Since:* $TWiki::Plugins::VERSION 1.010380 381 =cut382 383 sub DISABLE_afterEditHandler {384 # do not uncomment, use $_[0], $_[1]... instead385 ### my ( $text, $topic, $web ) = @_;386 387 TWiki::Func::writeDebug( "- ${pluginName}::afterEditHandler( $_[2].$_[1] )" ) if $debug;388 }389 390 =pod391 392 ---++ beforeSaveHandler($text, $topic, $web, $meta )393 * =$text= - text _with embedded meta-data tags_394 * =$topic= - the name of the topic in the current CGI query395 * =$web= - the name of the web in the current CGI query396 * =$meta= - the metadata of the topic being saved, represented by a TWiki::Meta object.397 398 This handler is called each time a topic is saved.399 400 __NOTE:__ meta-data is embedded in =$text= (using %META: tags). If you modify401 the =$meta= object, then it will override any changes to the meta-data402 embedded in the text. Modify *either* the META in the text *or* the =$meta=403 object, never both. You are recommended to modify the =$meta= object rather404 than the text, as this approach is proof against changes in the embedded405 text format.406 407 *Since:* TWiki::Plugins::VERSION = '1.010'408 409 =cut410 411 sub DISABLE_beforeSaveHandler {412 # do not uncomment, use $_[0], $_[1]... instead413 ### my ( $text, $topic, $web ) = @_;414 415 TWiki::Func::writeDebug( "- ${pluginName}::beforeSaveHandler( $_[2].$_[1] )" ) if $debug;416 }417 418 =pod419 420 ---++ afterSaveHandler($text, $topic, $web, $error, $meta )421 * =$text= - the text of the topic _excluding meta-data tags_422 (see beforeSaveHandler)423 * =$topic= - the name of the topic in the current CGI query424 * =$web= - the name of the web in the current CGI query425 * =$error= - any error string returned by the save.426 * =$meta= - the metadata of the saved topic, represented by a TWiki::Meta object427 428 This handler is called each time a topic is saved.429 430 __NOTE:__ meta-data is embedded in $text (using %META: tags)431 432 *Since:* TWiki::Plugins::VERSION 1.025433 434 =cut435 436 sub DISABLE_afterSaveHandler {437 # do not uncomment, use $_[0], $_[1]... instead438 ### my ( $text, $topic, $web, $error, $meta ) = @_;439 440 TWiki::Func::writeDebug( "- ${pluginName}::afterSaveHandler( $_[2].$_[1] )" ) if $debug;441 }442 443 =pod444 445 ---++ afterRenameHandler( $oldWeb, $oldTopic, $oldAttachment, $newWeb, $newTopic, $newAttachment )446 447 * =$oldWeb= - name of old web448 * =$oldTopic= - name of old topic (empty string if web rename)449 * =$oldAttachment= - name of old attachment (empty string if web or topic rename)450 * =$newWeb= - name of new web451 * =$newTopic= - name of new topic (empty string if web rename)452 * =$newAttachment= - name of new attachment (empty string if web or topic rename)453 454 This handler is called just after the rename/move/delete action of a web, topic or attachment.455 456 *Since:* TWiki::Plugins::VERSION = '1.11'457 458 =cut459 460 sub DISABLE_afterRenameHandler {461 # do not uncomment, use $_[0], $_[1]... instead462 ### my ( $oldWeb, $oldTopic, $oldAttachment, $newWeb, $newTopic, $newAttachment ) = @_;463 464 TWiki::Func::writeDebug( "- ${pluginName}::afterRenameHandler( " .465 "$_[0].$_[1] $_[2] -> $_[3].$_[4] $_[5] )" ) if $debug;466 }467 468 =pod469 470 ---++ beforeAttachmentSaveHandler(\%attrHash, $topic, $web )471 * =\%attrHash= - reference to hash of attachment attribute values472 * =$topic= - the name of the topic in the current CGI query473 * =$web= - the name of the web in the current CGI query474 This handler is called once when an attachment is uploaded. When this475 handler is called, the attachment has *not* been recorded in the database.476 477 The attributes hash will include at least the following attributes:478 * =attachment= => the attachment name479 * =comment= - the comment480 * =user= - the user id481 * =tmpFilename= - name of a temporary file containing the attachment data482 483 *Since:* TWiki::Plugins::VERSION = 1.025484 485 =cut486 487 sub DISABLE_beforeAttachmentSaveHandler {488 # do not uncomment, use $_[0], $_[1]... instead489 ### my( $attrHashRef, $topic, $web ) = @_;490 TWiki::Func::writeDebug( "- ${pluginName}::beforeAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug;491 }492 493 =pod494 495 ---++ afterAttachmentSaveHandler(\%attrHash, $topic, $web, $error )496 * =\%attrHash= - reference to hash of attachment attribute values497 * =$topic= - the name of the topic in the current CGI query498 * =$web= - the name of the web in the current CGI query499 * =$error= - any error string generated during the save process500 This handler is called just after the save action. The attributes hash501 will include at least the following attributes:502 * =attachment= => the attachment name503 * =comment= - the comment504 * =user= - the user id505 506 *Since:* TWiki::Plugins::VERSION = 1.025507 508 =cut509 510 sub DISABLE_afterAttachmentSaveHandler {511 # do not uncomment, use $_[0], $_[1]... instead512 ### my( $attrHashRef, $topic, $web ) = @_;513 TWiki::Func::writeDebug( "- ${pluginName}::afterAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug;514 }515 516 =pod517 518 ---++ mergeHandler( $diff, $old, $new, \%info ) -> $text519 Try to resolve a difference encountered during merge. The =differences=520 array is an array of hash references, where each hash contains the521 following fields:522 * =$diff= => one of the characters '+', '-', 'c' or ' '.523 * '+' - =new= contains text inserted in the new version524 * '-' - =old= contains text deleted from the old version525 * 'c' - =old= contains text from the old version, and =new= text526 from the version being saved527 * ' ' - =new= contains text common to both versions, or the change528 only involved whitespace529 * =$old= => text from version currently saved530 * =$new= => text from version being saved531 * =\%info= is a reference to the form field description { name, title,532 type, size, value, tooltip, attributes, referenced }. It must _not_533 be wrtten to. This parameter will be undef when merging the body534 text of the topic.535 536 Plugins should try to resolve differences and return the merged text.537 For example, a radio button field where we have538 ={ diff=>'c', old=>'Leafy', new=>'Barky' }= might be resolved as539 ='Treelike'=. If the plugin cannot resolve a difference it should return540 undef.541 542 The merge handler will be called several times during a save; once for543 each difference that needs resolution.544 545 If any merges are left unresolved after all plugins have been given a546 chance to intercede, the following algorithm is used to decide how to547 merge the data:548 1 =new= is taken for all =radio=, =checkbox= and =select= fields to549 resolve 'c' conflicts550 1 '+' and '-' text is always included in the the body text and text551 fields552 1 =<del>conflict</del> <ins>markers</ins>= are used to553 mark 'c' merges in text fields554 555 The merge handler is called whenever a topic is saved, and a merge is556 required to resolve concurrent edits on a topic.557 558 *Since:* TWiki::Plugins::VERSION = 1.1559 560 =cut561 562 sub DISABLE_mergeHandler {563 }564 565 =pod566 567 ---++ modifyHeaderHandler( \%headers, $query )568 * =\%headers= - reference to a hash of existing header values569 * =$query= - reference to CGI query object570 Lets the plugin modify the HTTP headers that will be emitted when a571 page is written to the browser. \%headers= will contain the headers572 proposed by the core, plus any modifications made by other plugins that also573 implement this method that come earlier in the plugins list.574 <verbatim>575 $headers->{expires} = '+1h';576 </verbatim>577 578 Note that this is the HTTP header which is _not_ the same as the HTML579 <HEAD> tag. The contents of the <HEAD> tag may be manipulated580 using the =TWiki::Func::addToHEAD= method.581 582 *Since:* TWiki::Plugins::VERSION 1.1583 584 =cut585 586 sub DISABLE_modifyHeaderHandler {587 my ( $headers, $query ) = @_;588 589 TWiki::Func::writeDebug( "- ${pluginName}::modifyHeaderHandler()" ) if $debug;590 }591 592 =pod593 594 ---++ redirectCgiQueryHandler($query, $url )595 * =$query= - the CGI query596 * =$url= - the URL to redirect to597 598 This handler can be used to replace TWiki's internal redirect function.599 600 If this handler is defined in more than one plugin, only the handler601 in the earliest plugin in the INSTALLEDPLUGINS list will be called. All602 the others will be ignored.603 604 *Since:* TWiki::Plugins::VERSION 1.010605 606 =cut607 608 sub DISABLE_redirectCgiQueryHandler {609 # do not uncomment, use $_[0], $_[1] instead610 ### my ( $query, $url ) = @_;611 612 TWiki::Func::writeDebug( "- ${pluginName}::redirectCgiQueryHandler( query, $_[1] )" ) if $debug;613 }614 615 =pod616 617 ---++ renderFormFieldForEditHandler($name, $type, $size, $value, $attributes, $possibleValues) -> $html618 619 This handler is called before built-in types are considered. It generates620 the HTML text rendering this form field, or false, if the rendering621 should be done by the built-in type handlers.622 * =$name= - name of form field623 * =$type= - type of form field (checkbox, radio etc)624 * =$size= - size of form field625 * =$value= - value held in the form field626 * =$attributes= - attributes of form field627 * =$possibleValues= - the values defined as options for form field, if628 any. May be a scalar (one legal value) or a ref to an array629 (several legal values)630 631 Return HTML text that renders this field. If false, form rendering632 continues by considering the built-in types.633 634 *Since:* TWiki::Plugins::VERSION 1.1635 636 Note that since TWiki-4.2, you can also extend the range of available637 types by providing a subclass of =TWiki::Form::FieldDefinition= to implement638 the new type (see =TWiki::Plugins.JSCalendarContrib= and639 =TWiki::Plugins.RatingContrib= for examples). This is the preferred way to640 extend the form field types, but does not work for TWiki < 4.2.641 642 =cut643 644 sub DISABLE_renderFormFieldForEditHandler {645 }646 647 =pod648 649 ---++ renderWikiWordHandler($linkText, $hasExplicitLinkLabel, $web, $topic) -> $linkText650 * =$linkText= - the text for the link i.e. for =[<nop>[Link][blah blah]]=651 it's =blah blah=, for =BlahBlah= it's =BlahBlah=, and for [[Blah Blah]] it's =Blah Blah=.652 * =$hasExplicitLinkLabel= - true if the link is of the form =[<nop>[Link][blah blah]]= (false if it's ==<nop>[Blah]] or =BlahBlah=)653 * =$web=, =$topic= - specify the topic being rendered (only since TWiki 4.2)654 655 Called during rendering, this handler allows the plugin a chance to change656 the rendering of labels used for links.657 658 Return the new link text.659 660 *Since:* TWiki::Plugins::VERSION 1.1661 662 =cut663 664 sub DISABLE_renderWikiWordHandler {665 my( $linkText, $hasExplicitLinkLabel, $web, $topic ) = @_;666 return $linkText;667 }668 669 =pod670 671 ---++ completePageHandler($html, $httpHeaders)672 673 This handler is called on the ingredients of every page that is674 output by the standard TWiki scripts. It is designed primarily for use by675 cache and security plugins.676 * =$html= - the body of the page (normally <html>..$lt;/html>)677 * =$httpHeaders= - the HTTP headers. Note that the headers do not contain678 a =Content-length=. That will be computed and added immediately before679 the page is actually written. This is a string, which must end in \n\n.680 681 *Since:* TWiki::Plugins::VERSION 1.2682 683 =cut684 685 sub DISABLE_completePageHandler {686 #my($html, $httpHeaders) = @_;687 # modify $_[0] or $_[1] if you must change the HTML or headers688 }689 690 =pod691 692 ---++ restExample($session) -> $text693 694 This is an example of a sub to be called by the =rest= script. The parameter is:695 * =$session= - The TWiki object associated to this session.696 697 Additional parameters can be recovered via de query object in the $session.698 699 For more information, check %SYSTEMWEB%.CommandAndCGIScripts#rest700 701 *Since:* TWiki::Plugins::VERSION 1.1702 703 =cut704 705 sub restExample {706 #my ($session) = @_;707 return "This is an example of a REST invocation\n\n";708 }709 710 93 1;
Note: See TracChangeset
for help on using the changeset viewer.
