Ignore:
Timestamp:
11/19/08 16:05:12 (4 years ago)
Author:
CrawfordCurrie
Message:

Item175: corrected references to TWiki in comments and error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/TWikiCompatibilityPlugin/lib/TWiki/Plugins/TWikiCompatibilityPlugin.pm

    r807 r812  
    2525use strict; 
    2626 
    27 require TWiki::Func;    # The plugins API 
    28 require TWiki::Plugins; # For the API version 
     27require Foswiki::Func;    # The plugins API 
     28require Foswiki::Plugins; # For the API version 
    2929use vars qw( $VERSION $RELEASE $SHORTDESCRIPTION $debug $pluginName $NO_PREFS_IN_TOPIC ); 
    3030$VERSION = '$Rev$'; 
     
    4646sub initPlugin { 
    4747    my( $topic, $web, $user, $installWeb ) = @_; 
    48  
    49     # check for Plugins.pm versions 
    50     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  
    6148    return 1; 
    62 } 
    63  
    64 # The function used to handle the %EXAMPLETAG{...}% variable 
    65 # 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 know 
    69     #             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 names 
    72     #             to values, with _DEFAULT being the name for the default 
    73     #             parameter. 
    74     # $theTopic - name of the topic in the query 
    75     # $theWeb   - name of the web in the query 
    76     # Return: the result of processing the variable 
    77  
    78     # For example, %EXAMPLETAG{'hamburger' sideorder="onions"}% 
    79     # $params->{_DEFAULT} will be 'hamburger' 
    80     # $params->{sideorder} will be 'onions' 
    8149} 
    8250 
     
    8755If the TWiki web does not exist, change the request to the %SYSTEMWEB% 
    8856 
    89 This may not be enough for Plugins that do have intopic preferences. 
     57This may not be enough for Plugins that do have in topic preferences. 
    9058 
    9159=cut 
    9260 
    9361sub 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 
     65Commented 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}}; 
    10174        } 
    10275    } 
    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}}; 
    10881    } 
    10982     
    11083    #Map TWIKIWEB to SYSTEMWEB and MAINWEB to USERSWEB 
    11184    #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 
    11590    return; 
    11691} 
    11792 
    118 =pod 
    119  
    120 ---++ initializeUserHandler( $loginName, $url, $pathInfo ) 
    121    * =$loginName= - login name recovered from $ENV{REMOTE_USER} 
    122    * =$url= - request url 
    123    * =$pathInfo= - pathinfo from the CGI query 
    124 Allows a plugin to set the username. Normally TWiki gets the username 
    125 from the login manager. This handler gives you a chance to override the 
    126 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 =cut 
    135  
    136 sub DISABLE_initializeUserHandler { 
    137     # do not uncomment, use $_[0], $_[1]... instead 
    138     ### my ( $loginName, $url, $pathInfo ) = @_; 
    139  
    140     TWiki::Func::writeDebug( "- ${pluginName}::initializeUserHandler( $_[0], $_[1] )" ) if $debug; 
    141 } 
    142  
    143 =pod 
    144  
    145 ---++ registrationHandler($web, $wikiName, $loginName ) 
    146    * =$web= - the name of the web in the current CGI query 
    147    * =$wikiName= - users wiki name 
    148    * =$loginName= - users login name 
    149  
    150 Called when a new user registers with this TWiki. 
    151  
    152 *Since:* TWiki::Plugins::VERSION = '1.010' 
    153  
    154 =cut 
    155  
    156 sub DISABLE_registrationHandler { 
    157     # do not uncomment, use $_[0], $_[1]... instead 
    158     ### my ( $web, $wikiName, $loginName ) = @_; 
    159  
    160     TWiki::Func::writeDebug( "- ${pluginName}::registrationHandler( $_[0], $_[1] )" ) if $debug; 
    161 } 
    162  
    163 =pod 
    164  
    165 ---++ commonTagsHandler($text, $topic, $web, $included, $meta ) 
    166    * =$text= - text to be processed 
    167    * =$topic= - the name of the topic in the current CGI query 
    168    * =$web= - the name of the web in the current CGI query 
    169    * =$included= - Boolean flag indicating whether the handler is invoked on an included topic 
    170    * =$meta= - meta-data object for the topic MAY BE =undef= 
    171 This handler is called by the code that expands %<nop>TAGS% syntax in 
    172 the topic body and in form fields. It may be called many times while 
    173 a topic is being rendered. 
    174  
    175 For variables with trivial syntax it is far more efficient to use 
    176 =TWiki::Func::registerTagHandler= (see =initPlugin=). 
    177  
    178 Plugins that have to parse the entire topic content should implement 
    179 this function. Internal TWiki 
    180 variables (and any variables declared using =TWiki::Func::registerTagHandler=) 
    181 are expanded _before_, and then again _after_, this function is called 
    182 to ensure all %<nop>TAGS% are expanded. 
    183  
    184 __NOTE:__ when this handler is called, &lt;verbatim> blocks have been 
    185 removed from the text (though all other blocks such as &lt;pre> and 
    186 &lt;noautolink> are still present). 
    187  
    188 __NOTE:__ meta-data is _not_ embedded in the text passed to this 
    189 handler. Use the =$meta= object. 
    190  
    191 *Since:* $TWiki::Plugins::VERSION 1.000 
    192  
    193 =cut 
    194  
    195 sub DISABLE_commonTagsHandler { 
    196     # do not uncomment, use $_[0], $_[1]... instead 
    197     ### 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 =pod 
    213  
    214 ---++ beforeCommonTagsHandler($text, $topic, $web, $meta ) 
    215    * =$text= - text to be processed 
    216    * =$topic= - the name of the topic in the current CGI query 
    217    * =$web= - the name of the web in the current CGI query 
    218    * =$meta= - meta-data object for the topic MAY BE =undef= 
    219 This handler is called before TWiki does any expansion of it's own 
    220 internal variables. It is designed for use by cache plugins. Note that 
    221 when this handler is called, &lt;verbatim> blocks are still present 
    222 in the text. 
    223  
    224 __NOTE__: This handler is called once for each call to 
    225 =commonTagsHandler= i.e. it may be called many times during the 
    226 rendering of a topic. 
    227  
    228 __NOTE:__ meta-data is _not_ embedded in the text passed to this 
    229 handler. 
    230  
    231 __NOTE:__ This handler is not separately called on included topics. 
    232  
    233 =cut 
    234  
    235 sub DISABLE_beforeCommonTagsHandler { 
    236     # do not uncomment, use $_[0], $_[1]... instead 
    237     ### my ( $text, $topic, $web, $meta ) = @_; 
    238  
    239     TWiki::Func::writeDebug( "- ${pluginName}::beforeCommonTagsHandler( $_[2].$_[1] )" ) if $debug; 
    240 } 
    241  
    242 =pod 
    243  
    244 ---++ afterCommonTagsHandler($text, $topic, $web, $meta ) 
    245    * =$text= - text to be processed 
    246    * =$topic= - the name of the topic in the current CGI query 
    247    * =$web= - the name of the web in the current CGI query 
    248    * =$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 handler 
    251 is called, &lt;verbatim> blocks are present in the text. 
    252  
    253 __NOTE__: This handler is called once for each call to 
    254 =commonTagsHandler= i.e. it may be called many times during the 
    255 rendering of a topic. 
    256  
    257 __NOTE:__ meta-data is _not_ embedded in the text passed to this 
    258 handler. 
    259  
    260 =cut 
    261  
    262 sub DISABLE_afterCommonTagsHandler { 
    263     # do not uncomment, use $_[0], $_[1]... instead 
    264     ### my ( $text, $topic, $web, $meta ) = @_; 
    265  
    266     TWiki::Func::writeDebug( "- ${pluginName}::afterCommonTagsHandler( $_[2].$_[1] )" ) if $debug; 
    267 } 
    268  
    269 =pod 
    270  
    271 ---++ preRenderingHandler( $text, \%map ) 
    272    * =$text= - text, with the head, verbatim and pre blocks replaced with placeholders 
    273    * =\%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) are 
    276 processed, but after all variables have been expanded. Use this handler to  
    277 process special syntax only recognised by your plugin. 
    278  
    279 Placeholders are text strings constructed using the tag name and a  
    280 sequence number e.g. 'pre1', "verbatim6", "head1" etc. Placeholders are  
    281 inserted into the text inside &lt;!--!marker!--&gt; characters so the  
    282 text will contain &lt;!--!pre1!--&gt; for placeholder pre1. 
    283  
    284 Each removed block is represented by the block text and the parameters  
    285 passed to the tag (usually empty) e.g. for 
    286 <verbatim> 
    287 <pre class='slobadob'> 
    288 XYZ 
    289 </pre> 
    290 the map will contain: 
    291 <pre> 
    292 $removed->{'pre1'}{text}:   XYZ 
    293 $removed->{'pre1'}{params}: class="slobadob" 
    294 </pre> 
    295 Iterating over blocks for a single tag is easy. For example, to prepend a  
    296 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 this 
    310 handler. 
    311  
    312 Since TWiki::Plugins::VERSION = '1.026' 
    313  
    314 =cut 
    315  
    316 sub DISABLE_preRenderingHandler { 
    317     # do not uncomment, use $_[0], $_[1]... instead 
    318     #my( $text, $pMap ) = @_; 
    319 } 
    320  
    321 =pod 
    322  
    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 this 
    330 handler. 
    331  
    332 Since TWiki::Plugins::VERSION = '1.026' 
    333  
    334 =cut 
    335  
    336 sub DISABLE_postRenderingHandler { 
    337     # do not uncomment, use $_[0], $_[1]... instead 
    338     #my $text = shift; 
    339 } 
    340  
    341 =pod 
    342  
    343 ---++ beforeEditHandler($text, $topic, $web ) 
    344    * =$text= - text that will be edited 
    345    * =$topic= - the name of the topic in the current CGI query 
    346    * =$web= - the name of the web in the current CGI query 
    347 This handler is called by the edit script just before presenting the edit text 
    348 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 handler  
    351 (using %META: tags) 
    352  
    353 *Since:* TWiki::Plugins::VERSION = '1.010' 
    354  
    355 =cut 
    356  
    357 sub DISABLE_beforeEditHandler { 
    358     # do not uncomment, use $_[0], $_[1]... instead 
    359     ### my ( $text, $topic, $web ) = @_; 
    360  
    361     TWiki::Func::writeDebug( "- ${pluginName}::beforeEditHandler( $_[2].$_[1] )" ) if $debug; 
    362 } 
    363  
    364 =pod 
    365  
    366 ---++ afterEditHandler($text, $topic, $web, $meta ) 
    367    * =$text= - text that is being previewed 
    368    * =$topic= - the name of the topic in the current CGI query 
    369    * =$web= - the name of the web in the current CGI query 
    370    * =$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 this 
    377 handler. Use the =$meta= object. 
    378  
    379 *Since:* $TWiki::Plugins::VERSION 1.010 
    380  
    381 =cut 
    382  
    383 sub DISABLE_afterEditHandler { 
    384     # do not uncomment, use $_[0], $_[1]... instead 
    385     ### my ( $text, $topic, $web ) = @_; 
    386  
    387     TWiki::Func::writeDebug( "- ${pluginName}::afterEditHandler( $_[2].$_[1] )" ) if $debug; 
    388 } 
    389  
    390 =pod 
    391  
    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 query 
    395    * =$web= - the name of the web in the current CGI query 
    396    * =$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 modify 
    401 the =$meta= object, then it will override any changes to the meta-data 
    402 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 rather 
    404 than the text, as this approach is proof against changes in the embedded 
    405 text format. 
    406  
    407 *Since:* TWiki::Plugins::VERSION = '1.010' 
    408  
    409 =cut 
    410  
    411 sub DISABLE_beforeSaveHandler { 
    412     # do not uncomment, use $_[0], $_[1]... instead 
    413     ### my ( $text, $topic, $web ) = @_; 
    414  
    415     TWiki::Func::writeDebug( "- ${pluginName}::beforeSaveHandler( $_[2].$_[1] )" ) if $debug; 
    416 } 
    417  
    418 =pod 
    419  
    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 query 
    424    * =$web= - the name of the web in the current CGI query 
    425    * =$error= - any error string returned by the save. 
    426    * =$meta= - the metadata of the saved topic, represented by a TWiki::Meta object  
    427  
    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.025 
    433  
    434 =cut 
    435  
    436 sub DISABLE_afterSaveHandler { 
    437     # do not uncomment, use $_[0], $_[1]... instead 
    438     ### my ( $text, $topic, $web, $error, $meta ) = @_; 
    439  
    440     TWiki::Func::writeDebug( "- ${pluginName}::afterSaveHandler( $_[2].$_[1] )" ) if $debug; 
    441 } 
    442  
    443 =pod 
    444  
    445 ---++ afterRenameHandler( $oldWeb, $oldTopic, $oldAttachment, $newWeb, $newTopic, $newAttachment ) 
    446  
    447    * =$oldWeb= - name of old web 
    448    * =$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 web 
    451    * =$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 =cut 
    459  
    460 sub DISABLE_afterRenameHandler { 
    461     # do not uncomment, use $_[0], $_[1]... instead 
    462     ### 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 =pod 
    469  
    470 ---++ beforeAttachmentSaveHandler(\%attrHash, $topic, $web ) 
    471    * =\%attrHash= - reference to hash of attachment attribute values 
    472    * =$topic= - the name of the topic in the current CGI query 
    473    * =$web= - the name of the web in the current CGI query 
    474 This handler is called once when an attachment is uploaded. When this 
    475 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 name 
    479    * =comment= - the comment 
    480    * =user= - the user id 
    481    * =tmpFilename= - name of a temporary file containing the attachment data 
    482  
    483 *Since:* TWiki::Plugins::VERSION = 1.025 
    484  
    485 =cut 
    486  
    487 sub DISABLE_beforeAttachmentSaveHandler { 
    488     # do not uncomment, use $_[0], $_[1]... instead 
    489     ###   my( $attrHashRef, $topic, $web ) = @_; 
    490     TWiki::Func::writeDebug( "- ${pluginName}::beforeAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug; 
    491 } 
    492  
    493 =pod 
    494  
    495 ---++ afterAttachmentSaveHandler(\%attrHash, $topic, $web, $error ) 
    496    * =\%attrHash= - reference to hash of attachment attribute values 
    497    * =$topic= - the name of the topic in the current CGI query 
    498    * =$web= - the name of the web in the current CGI query 
    499    * =$error= - any error string generated during the save process 
    500 This handler is called just after the save action. The attributes hash 
    501 will include at least the following attributes: 
    502    * =attachment= => the attachment name 
    503    * =comment= - the comment 
    504    * =user= - the user id 
    505  
    506 *Since:* TWiki::Plugins::VERSION = 1.025 
    507  
    508 =cut 
    509  
    510 sub DISABLE_afterAttachmentSaveHandler { 
    511     # do not uncomment, use $_[0], $_[1]... instead 
    512     ###   my( $attrHashRef, $topic, $web ) = @_; 
    513     TWiki::Func::writeDebug( "- ${pluginName}::afterAttachmentSaveHandler( $_[2].$_[1] )" ) if $debug; 
    514 } 
    515  
    516 =pod 
    517  
    518 ---++ mergeHandler( $diff, $old, $new, \%info ) -> $text 
    519 Try to resolve a difference encountered during merge. The =differences=  
    520 array is an array of hash references, where each hash contains the  
    521 following fields: 
    522    * =$diff= => one of the characters '+', '-', 'c' or ' '. 
    523       * '+' - =new= contains text inserted in the new version 
    524       * '-' - =old= contains text deleted from the old version 
    525       * 'c' - =old= contains text from the old version, and =new= text 
    526         from the version being saved 
    527       * ' ' - =new= contains text common to both versions, or the change 
    528         only involved whitespace 
    529    * =$old= => text from version currently saved 
    530    * =$new= => text from version being saved 
    531    * =\%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 body 
    534      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 have  
    538 ={ diff=>'c', old=>'Leafy', new=>'Barky' }= might be resolved as  
    539 ='Treelike'=. If the plugin cannot resolve a difference it should return  
    540 undef. 
    541  
    542 The merge handler will be called several times during a save; once for  
    543 each difference that needs resolution. 
    544  
    545 If any merges are left unresolved after all plugins have been given a  
    546 chance to intercede, the following algorithm is used to decide how to  
    547 merge the data: 
    548    1 =new= is taken for all =radio=, =checkbox= and =select= fields to  
    549      resolve 'c' conflicts 
    550    1 '+' and '-' text is always included in the the body text and text 
    551      fields 
    552    1 =&lt;del>conflict&lt;/del> &lt;ins>markers&lt;/ins>= are used to  
    553      mark 'c' merges in text fields 
    554  
    555 The merge handler is called whenever a topic is saved, and a merge is  
    556 required to resolve concurrent edits on a topic. 
    557  
    558 *Since:* TWiki::Plugins::VERSION = 1.1 
    559  
    560 =cut 
    561  
    562 sub DISABLE_mergeHandler { 
    563 } 
    564  
    565 =pod 
    566  
    567 ---++ modifyHeaderHandler( \%headers, $query ) 
    568    * =\%headers= - reference to a hash of existing header values 
    569    * =$query= - reference to CGI query object 
    570 Lets the plugin modify the HTTP headers that will be emitted when a 
    571 page is written to the browser. \%headers= will contain the headers 
    572 proposed by the core, plus any modifications made by other plugins that also 
    573 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 HTML 
    579 &lt;HEAD&gt; tag. The contents of the &lt;HEAD&gt; tag may be manipulated 
    580 using the =TWiki::Func::addToHEAD= method. 
    581  
    582 *Since:* TWiki::Plugins::VERSION 1.1 
    583  
    584 =cut 
    585  
    586 sub DISABLE_modifyHeaderHandler { 
    587     my ( $headers, $query ) = @_; 
    588  
    589     TWiki::Func::writeDebug( "- ${pluginName}::modifyHeaderHandler()" ) if $debug; 
    590 } 
    591  
    592 =pod 
    593  
    594 ---++ redirectCgiQueryHandler($query, $url ) 
    595    * =$query= - the CGI query 
    596    * =$url= - the URL to redirect to 
    597  
    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 handler 
    601 in the earliest plugin in the INSTALLEDPLUGINS list will be called. All 
    602 the others will be ignored. 
    603  
    604 *Since:* TWiki::Plugins::VERSION 1.010 
    605  
    606 =cut 
    607  
    608 sub DISABLE_redirectCgiQueryHandler { 
    609     # do not uncomment, use $_[0], $_[1] instead 
    610     ### my ( $query, $url ) = @_; 
    611  
    612     TWiki::Func::writeDebug( "- ${pluginName}::redirectCgiQueryHandler( query, $_[1] )" ) if $debug; 
    613 } 
    614  
    615 =pod 
    616  
    617 ---++ renderFormFieldForEditHandler($name, $type, $size, $value, $attributes, $possibleValues) -> $html 
    618  
    619 This handler is called before built-in types are considered. It generates  
    620 the HTML text rendering this form field, or false, if the rendering  
    621 should be done by the built-in type handlers. 
    622    * =$name= - name of form field 
    623    * =$type= - type of form field (checkbox, radio etc) 
    624    * =$size= - size of form field 
    625    * =$value= - value held in the form field 
    626    * =$attributes= - attributes of form field  
    627    * =$possibleValues= - the values defined as options for form field, if 
    628      any. May be a scalar (one legal value) or a ref to an array 
    629      (several legal values) 
    630  
    631 Return HTML text that renders this field. If false, form rendering 
    632 continues by considering the built-in types. 
    633  
    634 *Since:* TWiki::Plugins::VERSION 1.1 
    635  
    636 Note that since TWiki-4.2, you can also extend the range of available 
    637 types by providing a subclass of =TWiki::Form::FieldDefinition= to implement 
    638 the new type (see =TWiki::Plugins.JSCalendarContrib= and 
    639 =TWiki::Plugins.RatingContrib= for examples). This is the preferred way to 
    640 extend the form field types, but does not work for TWiki < 4.2. 
    641  
    642 =cut 
    643  
    644 sub DISABLE_renderFormFieldForEditHandler { 
    645 } 
    646  
    647 =pod 
    648  
    649 ---++ renderWikiWordHandler($linkText, $hasExplicitLinkLabel, $web, $topic) -> $linkText 
    650    * =$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 change 
    656 the rendering of labels used for links. 
    657  
    658 Return the new link text. 
    659  
    660 *Since:* TWiki::Plugins::VERSION 1.1 
    661  
    662 =cut 
    663  
    664 sub DISABLE_renderWikiWordHandler { 
    665     my( $linkText, $hasExplicitLinkLabel, $web, $topic ) = @_; 
    666     return $linkText; 
    667 } 
    668  
    669 =pod 
    670  
    671 ---++ completePageHandler($html, $httpHeaders) 
    672  
    673 This handler is called on the ingredients of every page that is 
    674 output by the standard TWiki scripts. It is designed primarily for use by 
    675 cache and security plugins. 
    676    * =$html= - the body of the page (normally &lt;html>..$lt;/html>) 
    677    * =$httpHeaders= - the HTTP headers. Note that the headers do not contain 
    678      a =Content-length=. That will be computed and added immediately before 
    679      the page is actually written. This is a string, which must end in \n\n. 
    680  
    681 *Since:* TWiki::Plugins::VERSION 1.2 
    682  
    683 =cut 
    684  
    685 sub DISABLE_completePageHandler { 
    686     #my($html, $httpHeaders) = @_; 
    687     # modify $_[0] or $_[1] if you must change the HTML or headers 
    688 } 
    689  
    690 =pod 
    691  
    692 ---++ restExample($session) -> $text 
    693  
    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#rest 
    700  
    701 *Since:* TWiki::Plugins::VERSION 1.1 
    702  
    703 =cut 
    704  
    705 sub restExample { 
    706    #my ($session) = @_; 
    707    return "This is an example of a REST invocation\n\n"; 
    708 } 
    709  
    710931; 
Note: See TracChangeset for help on using the changeset viewer.