Ignore:
Timestamp:
01/24/12 21:16:27 (4 months ago)
Author:
GeorgeClark
Message:

Item9551: Some cleanup

And start to convert the twitter and irc code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin/Twitter.pm

    r13777 r13817  
    33=begin TML 
    44 
    5 ---+ package TweetOnSavePlugin 
     5---+ package ImmediateNotifyPlugin 
    66 
    77=cut 
    88 
    9 package Foswiki::Plugins::TweetOnSavePlugin; 
     9package Foswiki::Plugins::ImmediateNotifyPlugin::Twitter; 
    1010 
    1111use strict; 
    1212 
    1313require Foswiki::Func;    # The plugins API 
    14 require Foswiki::Plugins; # For the API version 
    1514 
    1615require Net::Twitter; 
    1716require WWW::Shorten::Bitly; 
    1817 
    19 # $VERSION is referred to by Foswiki, and is the only global variable that 
    20 # *must* exist in this package. 
    21 # This should always be $Rev: 3417 (2009-04-12) $ so that Foswiki can determine the checked-in 
    22 # status of the plugin. It is used by the build automation tools, so 
    23 # you should leave it alone. 
    24 our $VERSION = '$Rev: 3417 (2009-04-12) $'; 
    25  
    26 # This is a free-form string you can use to "name" your own plugin version. 
    27 # It is *not* used by the build automation tools, but is reported as part 
    28 # of the version number in PLUGINDESCRIPTIONS. 
    29 our $RELEASE = '$Date: 2008-12-14 18:49:56 +0100 (Sun, 14 Dec 2008) $'; 
    30  
    31 our $SHORTDESCRIPTION = 'Update status on twitter or compatible network on topic save'; 
    32  
    33 our $NO_PREFS_IN_TOPIC = 1; 
    34  
    35 our %isNewTopic = (); 
    36  
    37 our @excludeWebs = (); 
    38  
    39 =begin TML 
    40  
    41 ---++ initPlugin($topic, $web, $user) -> $boolean 
    42    * =$topic= - the name of the topic in the current CGI query 
    43    * =$web= - the name of the web in the current CGI query 
    44    * =$user= - the login name of the user 
    45    * =$installWeb= - the name of the web the plugin topic is in 
    46      (usually the same as =$Foswiki::cfg{SystemWebName}=) 
    47  
    48 =cut 
    49  
    50 sub initPlugin { 
    51     my( $topic, $web, $user, $installWeb ) = @_; 
    52  
    53     # check for Plugins.pm versions 
    54     if( $Foswiki::Plugins::VERSION < 2.0 ) { 
    55         Foswiki::Func::writeWarning( 'Version mismatch between ', 
    56                                      __PACKAGE__, ' and Plugins.pm' ); 
    57         return 0; 
    58     } 
    59  
    60     # $Foswiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} = 1; 
    61  
    62     # Optional: See %SYSTEMWEB%.DevelopingPlugins#ConfigSpec for information 
    63     # on integrating your plugin configuration with =configure=. 
    64  
    65     # Always provide a default in case the setting is not defined in 
    66     # my $setting = $Foswiki::cfg{Plugins}{EmptyPlugin}{ExampleSetting} || 0; 
    67  
    68     #Foswiki::Func::registerTagHandler( 'EXAMPLETAG', \&_EXAMPLETAG ); 
    69  
    70     #Foswiki::Func::registerRESTHandler('example', \&restExample); 
    71  
    72     if(defined($Foswiki::cfg{Plugins}{TweetOnSavePlugin}{ExcludeWebs})) { 
    73       @excludeWebs=split(/\s*,\s*/,$Foswiki::cfg{Plugins}{TweetOnSavePlugin}{ExcludeWebs}); 
    74     } 
    75  
    76     # Plugin correctly initialized 
    77     return 1; 
    78 } 
    79  
    80 # The function used to handle the %EXAMPLETAG{...}% macro 
    81 # You would have one of these for each macro you want to process. 
    82 #sub _EXAMPLETAG { 
    83 #    my($session, $params, $theTopic, $theWeb) = @_; 
    84 #    # $session  - a reference to the Foswiki session object (if you don't know 
    85 #    #             what this is, just ignore it) 
    86 #    # $params=  - a reference to a Foswiki::Attrs object containing 
    87 #    #             parameters. 
    88 #    #             This can be used as a simple hash that maps parameter names 
    89 #    #             to values, with _DEFAULT being the name for the default 
    90 #    #             (unnamed) parameter. 
    91 #    # $theTopic - name of the topic in the query 
    92 #    # $theWeb   - name of the web in the query 
    93 #    # Return: the result of processing the macro. This will replace the 
    94 #    # macro call in the final text. 
    95 # 
    96 #    # For example, %EXAMPLETAG{'hamburger' sideorder="onions"}% 
    97 #    # $params->{_DEFAULT} will be 'hamburger' 
    98 #    # $params->{sideorder} will be 'onions' 
    99 #} 
    100  
    101 =begin TML 
    102  
    103 ---++ earlyInitPlugin() 
    104  
    105 This handler is called before any other handler, and before it has been 
    106 determined if the plugin is enabled or not. Use it with great care! 
    107  
    108 If it returns a non-null error string, the plugin will be disabled. 
    109  
    110 =cut 
    111  
    112 #sub earlyInitPlugin { 
    113 #    return undef; 
    114 #} 
    115  
    116 =begin TML 
    117  
    118 ---++ initializeUserHandler( $loginName, $url, $pathInfo ) 
    119    * =$loginName= - login name recovered from $ENV{REMOTE_USER} 
    120    * =$url= - request url 
    121    * =$pathInfo= - pathinfo from the CGI query 
    122 Allows a plugin to set the username. Normally Foswiki gets the username 
    123 from the login manager. This handler gives you a chance to override the 
    124 login manager. 
    125  
    126 Return the *login* name. 
    127  
    128 This handler is called very early, immediately after =earlyInitPlugin=. 
    129  
    130 *Since:* Foswiki::Plugins::VERSION = '2.0' 
    131  
    132 =cut 
    133  
    134 #sub initializeUserHandler { 
    135 #    my ( $loginName, $url, $pathInfo ) = @_; 
    136 #} 
    137  
    138 =begin TML 
    139  
    140 ---++ registrationHandler($web, $wikiName, $loginName ) 
    141    * =$web= - the name of the web in the current CGI query 
    142    * =$wikiName= - users wiki name 
    143    * =$loginName= - users login name 
    144  
    145 Called when a new user registers with this Foswiki. 
    146  
    147 *Since:* Foswiki::Plugins::VERSION = '2.0' 
    148  
    149 =cut 
    150  
    151 #sub registrationHandler { 
    152 #    my ( $web, $wikiName, $loginName ) = @_; 
    153 #} 
    154  
    155 =begin TML 
    156  
    157 ---++ commonTagsHandler($text, $topic, $web, $included, $meta ) 
    158    * =$text= - text to be processed 
    159    * =$topic= - the name of the topic in the current CGI query 
    160    * =$web= - the name of the web in the current CGI query 
    161    * =$included= - Boolean flag indicating whether the handler is 
    162      invoked on an included topic 
    163    * =$meta= - meta-data object for the topic MAY BE =undef= 
    164 This handler is called by the code that expands %<nop>MACROS% syntax in 
    165 the topic body and in form fields. It may be called many times while 
    166 a topic is being rendered. 
    167  
    168 Only plugins that have to parse the entire topic content should implement 
    169 this function. For expanding macros with trivial syntax it is *far* more 
    170 efficient to use =Foswiki::Func::registerTagHandler= (see =initPlugin=). 
    171  
    172 Internal Foswiki macros, (and any macros declared using 
    173 =Foswiki::Func::registerTagHandler=) are expanded _before_, and then again 
    174 _after_, this function is called to ensure all %<nop>MACROS% are expanded. 
    175  
    176 *NOTE:* when this handler is called, &lt;verbatim> blocks have been 
    177 removed from the text (though all other blocks such as &lt;pre> and 
    178 &lt;noautolink> are still present). 
    179  
    180 *NOTE:* meta-data is _not_ embedded in the text passed to this 
    181 handler. Use the =$meta= object. 
    182  
    183 *Since:* $Foswiki::Plugins::VERSION 2.0 
    184  
    185 =cut 
    186  
    187 #sub commonTagsHandler { 
    188 #    my ( $text, $topic, $web, $included, $meta ) = @_; 
    189 # 
    190 #    # If you don't want to be called from nested includes... 
    191 #    #   if( $included ) { 
    192 #    #         # bail out, handler called from an %INCLUDE{}% 
    193 #    #         return; 
    194 #    #   } 
    195 # 
    196 #    # You can work on $text in place by using the special perl 
    197 #    # variable $_[0]. These allow you to operate on $text 
    198 #    # as if it was passed by reference; for example: 
    199 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    200 #} 
    201  
    202 =begin TML 
    203  
    204 ---++ beforeCommonTagsHandler($text, $topic, $web, $meta ) 
    205    * =$text= - text to be processed 
    206    * =$topic= - the name of the topic in the current CGI query 
    207    * =$web= - the name of the web in the current CGI query 
    208    * =$meta= - meta-data object for the topic MAY BE =undef= 
    209 This handler is called before Foswiki does any expansion of its own 
    210 internal variables. It is designed for use by cache plugins. Note that 
    211 when this handler is called, &lt;verbatim> blocks are still present 
    212 in the text. 
    213  
    214 *NOTE*: This handler is called once for each call to 
    215 =commonTagsHandler= i.e. it may be called many times during the 
    216 rendering of a topic. 
    217  
    218 *NOTE:* meta-data is _not_ embedded in the text passed to this 
    219 handler. 
    220  
    221 *NOTE:* This handler is not separately called on included topics. 
    222  
    223 =cut 
    224  
    225 #sub beforeCommonTagsHandler { 
    226 #    my ( $text, $topic, $web, $meta ) = @_; 
    227 # 
    228 #    # You can work on $text in place by using the special perl 
    229 #    # variable $_[0]. These allow you to operate on $text 
    230 #    # as if it was passed by reference; for example: 
    231 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    232 #} 
    233  
    234 =begin TML 
    235  
    236 ---++ afterCommonTagsHandler($text, $topic, $web, $meta ) 
    237    * =$text= - text to be processed 
    238    * =$topic= - the name of the topic in the current CGI query 
    239    * =$web= - the name of the web in the current CGI query 
    240    * =$meta= - meta-data object for the topic MAY BE =undef= 
    241 This handler is called after Foswiki has completed expansion of %MACROS%. 
    242 It is designed for use by cache plugins. Note that when this handler 
    243 is called, &lt;verbatim> blocks are present in the text. 
    244  
    245 *NOTE*: This handler is called once for each call to 
    246 =commonTagsHandler= i.e. it may be called many times during the 
    247 rendering of a topic. 
    248  
    249 *NOTE:* meta-data is _not_ embedded in the text passed to this 
    250 handler. 
    251  
    252 =cut 
    253  
    254 #sub afterCommonTagsHandler { 
    255 #    my ( $text, $topic, $web, $meta ) = @_; 
    256 # 
    257 #    # You can work on $text in place by using the special perl 
    258 #    # variable $_[0]. These allow you to operate on $text 
    259 #    # as if it was passed by reference; for example: 
    260 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    261 #} 
    262  
    263 =begin TML 
    264  
    265 ---++ preRenderingHandler( $text, \%map ) 
    266    * =$text= - text, with the head, verbatim and pre blocks replaced 
    267      with placeholders 
    268    * =\%removed= - reference to a hash that maps the placeholders to 
    269      the removed blocks. 
    270  
    271 Handler called immediately before Foswiki syntax structures (such as lists) are 
    272 processed, but after all variables have been expanded. Use this handler to 
    273 process special syntax only recognised by your plugin. 
    274  
    275 Placeholders are text strings constructed using the tag name and a 
    276 sequence number e.g. 'pre1', "verbatim6", "head1" etc. Placeholders are 
    277 inserted into the text inside &lt;!--!marker!--&gt; characters so the 
    278 text will contain &lt;!--!pre1!--&gt; for placeholder pre1. 
    279  
    280 Each removed block is represented by the block text and the parameters 
    281 passed to the tag (usually empty) e.g. for 
    282 <verbatim> 
    283 <pre class='slobadob'> 
    284 XYZ 
    285 </pre> 
    286 </verbatim> 
    287 the map will contain: 
    288 <pre> 
    289 $removed->{'pre1'}{text}:   XYZ 
    290 $removed->{'pre1'}{params}: class="slobadob" 
    291 </pre> 
    292 Iterating over blocks for a single tag is easy. For example, to prepend a 
    293 line number to every line of every pre block you might use this code: 
    294 <verbatim> 
    295 foreach my $placeholder ( keys %$map ) { 
    296     if( $placeholder =~ /^pre/i ) { 
    297         my $n = 1; 
    298         $map->{$placeholder}{text} =~ s/^/$n++/gem; 
    299     } 
    300 } 
    301 </verbatim> 
    302  
    303 __NOTE__: This handler is called once for each rendered block of text i.e. 
    304 it may be called several times during the rendering of a topic. 
    305  
    306 *NOTE:* meta-data is _not_ embedded in the text passed to this 
    307 handler. 
    308  
    309 Since Foswiki::Plugins::VERSION = '2.0' 
    310  
    311 =cut 
    312  
    313 #sub preRenderingHandler { 
    314 #    my( $text, $pMap ) = @_; 
    315 # 
    316 #    # You can work on $text in place by using the special perl 
    317 #    # variable $_[0]. These allow you to operate on $text 
    318 #    # as if it was passed by reference; for example: 
    319 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    320 #} 
    321  
    322 =begin TML 
    323  
    324 ---++ postRenderingHandler( $text ) 
    325    * =$text= - the text that has just been rendered. May be modified in place. 
    326  
    327 *NOTE*: This handler is called once for each rendered block of text i.e.  
    328 it may be called several times during the rendering of a topic. 
    329  
    330 *NOTE:* meta-data is _not_ embedded in the text passed to this 
    331 handler. 
    332  
    333 Since Foswiki::Plugins::VERSION = '2.0' 
    334  
    335 =cut 
    336  
    337 #sub postRenderingHandler { 
    338 #    my $text = shift; 
    339 #    # You can work on $text in place by using the special perl 
    340 #    # variable $_[0]. These allow you to operate on $text 
    341 #    # as if it was passed by reference; for example: 
    342 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    343 #} 
    344  
    345 =begin TML 
    346  
    347 ---++ beforeEditHandler($text, $topic, $web ) 
    348    * =$text= - text that will be edited 
    349    * =$topic= - the name of the topic in the current CGI query 
    350    * =$web= - the name of the web in the current CGI query 
    351 This handler is called by the edit script just before presenting the edit text 
    352 in the edit box. It is called once when the =edit= script is run. 
    353  
    354 *NOTE*: meta-data may be embedded in the text passed to this handler  
    355 (using %META: tags) 
    356  
    357 *Since:* Foswiki::Plugins::VERSION = '2.0' 
    358  
    359 =cut 
    360  
    361 #sub beforeEditHandler { 
    362 #    my ( $text, $topic, $web ) = @_; 
    363 # 
    364 #    # You can work on $text in place by using the special perl 
    365 #    # variable $_[0]. These allow you to operate on $text 
    366 #    # as if it was passed by reference; for example: 
    367 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    368 #} 
    369  
    370 =begin TML 
    371  
    372 ---++ afterEditHandler($text, $topic, $web, $meta ) 
    373    * =$text= - text that is being previewed 
    374    * =$topic= - the name of the topic in the current CGI query 
    375    * =$web= - the name of the web in the current CGI query 
    376    * =$meta= - meta-data for the topic. 
    377 This handler is called by the preview script just before presenting the text. 
    378 It is called once when the =preview= script is run. 
    379  
    380 *NOTE:* this handler is _not_ called unless the text is previewed. 
    381  
    382 *NOTE:* meta-data is _not_ embedded in the text passed to this 
    383 handler. Use the =$meta= object. 
    384  
    385 *Since:* $Foswiki::Plugins::VERSION 2.0 
    386  
    387 =cut 
    388  
    389 #sub afterEditHandler { 
    390 #    my ( $text, $topic, $web ) = @_; 
    391 # 
    392 #    # You can work on $text in place by using the special perl 
    393 #    # variable $_[0]. These allow you to operate on $text 
    394 #    # as if it was passed by reference; for example: 
    395 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    396 #} 
    397  
    398 =begin TML 
    399  
    400 ---++ beforeSaveHandler($text, $topic, $web, $meta ) 
    401    * =$text= - text _with embedded meta-data tags_ 
    402    * =$topic= - the name of the topic in the current CGI query 
    403    * =$web= - the name of the web in the current CGI query 
    404    * =$meta= - the metadata of the topic being saved, represented by a Foswiki::Meta object. 
    405  
    406 This handler is called each time a topic is saved. 
    407  
    408 *NOTE:* meta-data is embedded in =$text= (using %META: tags). If you modify 
    409 the =$meta= object, then it will override any changes to the meta-data 
    410 embedded in the text. Modify *either* the META in the text *or* the =$meta= 
    411 object, never both. You are recommended to modify the =$meta= object rather 
    412 than the text, as this approach is proof against changes in the embedded 
    413 text format. 
    414  
    415 *Since:* Foswiki::Plugins::VERSION = 2.0 
    416  
    417 =cut 
    418  
    419 sub beforeSaveHandler { 
    420     my ( $text, $topic, $web, $meta ) = @_; 
    421  
    422     if ( Foswiki::Func::topicExists($web, $topic) ) { 
    423       $isNewTopic{$$}=0; 
    424     } else { 
    425       $isNewTopic{$$}=1; 
    426     } 
    427     # You can work on $text in place by using the special perl 
    428     # variable $_[0]. These allow you to operate on $text 
    429     # as if it was passed by reference; for example: 
    430     # $_[0] =~ s/SpecialString/my alternative/ge; 
    431 } 
    43218 
    43319=begin TML 
     
    45945    return if(grep(/^$web$/,@excludeWebs)); 
    46046 
    461     my $tweet=$Foswiki::cfg{Plugins}{TweetOnSavePlugin}{Template} || '$user $action topic $web.$topic $url'; 
     47    my $tweet=$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Template} || '$user $action topic $web.$topic $url'; 
    46248 
    46349    my $action='saved'; 
     
    46854    # only shorten url if url is actually used 
    46955    my $url=Foswiki::Func::getViewUrl($web,$topic); 
    470     if( ($tweet=~/\$url/) and (defined($Foswiki::cfg{Plugins}{TweetOnSavePlugin}{BitlyUser})) ) { 
     56    if( ($tweet=~/\$url/) and (defined($Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{BitlyUser})) ) { 
    47157      $url=WWW::Shorten::Bitly::makeashorterlink( 
    47258        $url, 
    473         $Foswiki::cfg{Plugins}{TweetOnSavePlugin}{BitlyUser}, 
    474         $Foswiki::cfg{Plugins}{TweetOnSavePlugin}{BitlyKey} 
     59        $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{BitlyUser}, 
     60        $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{BitlyKey} 
    47561      ); 
    47662    } 
     
    48672    my $twitter = Net::Twitter->new( 
    48773      traits   => [qw/API::REST/], 
    488       username => $Foswiki::cfg{Plugins}{TweetOnSavePlugin}{StatusUser}, 
    489       password => $Foswiki::cfg{Plugins}{TweetOnSavePlugin}{StatusPassword} 
     74      username => $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{StatusUser}, 
     75      password => $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{StatusPassword} 
    49076    ); 
    49177 
     
    49682} 
    49783 
    498 =begin TML 
    499  
    500 ---++ afterRenameHandler( $oldWeb, $oldTopic, $oldAttachment, $newWeb, $newTopic, $newAttachment ) 
    501  
    502    * =$oldWeb= - name of old web 
    503    * =$oldTopic= - name of old topic (empty string if web rename) 
    504    * =$oldAttachment= - name of old attachment (empty string if web or topic rename) 
    505    * =$newWeb= - name of new web 
    506    * =$newTopic= - name of new topic (empty string if web rename) 
    507    * =$newAttachment= - name of new attachment (empty string if web or topic rename) 
    508  
    509 This handler is called just after the rename/move/delete action of a web, topic or attachment. 
    510  
    511 *Since:* Foswiki::Plugins::VERSION = '2.0' 
    512  
    513 =cut 
    514  
    515 #sub afterRenameHandler { 
    516 #    my ( $oldWeb, $oldTopic, $oldAttachment, 
    517 #         $newWeb, $newTopic, $newAttachment ) = @_; 
    518 #} 
    519  
    520 =begin TML 
    521  
    522 ---++ beforeAttachmentSaveHandler(\%attrHash, $topic, $web ) 
    523    * =\%attrHash= - reference to hash of attachment attribute values 
    524    * =$topic= - the name of the topic in the current CGI query 
    525    * =$web= - the name of the web in the current CGI query 
    526 This handler is called once when an attachment is uploaded. When this 
    527 handler is called, the attachment has *not* been recorded in the database. 
    528  
    529 The attributes hash will include at least the following attributes: 
    530    * =attachment= => the attachment name 
    531    * =comment= - the comment 
    532    * =user= - the user id 
    533    * =tmpFilename= - name of a temporary file containing the attachment data 
    534  
    535 *Since:* Foswiki::Plugins::VERSION = 2.0 
    536  
    537 =cut 
    538  
    539 #sub beforeAttachmentSaveHandler { 
    540 #    my( $attrHashRef, $topic, $web ) = @_; 
    541 #} 
    542  
    543 =begin TML 
    544  
    545 ---++ afterAttachmentSaveHandler(\%attrHash, $topic, $web, $error ) 
    546    * =\%attrHash= - reference to hash of attachment attribute values 
    547    * =$topic= - the name of the topic in the current CGI query 
    548    * =$web= - the name of the web in the current CGI query 
    549    * =$error= - any error string generated during the save process 
    550 This handler is called just after the save action. The attributes hash 
    551 will include at least the following attributes: 
    552    * =attachment= => the attachment name 
    553    * =comment= - the comment 
    554    * =user= - the user id 
    555  
    556 *Since:* Foswiki::Plugins::VERSION = 2.0 
    557  
    558 =cut 
    559  
    560 #sub afterAttachmentSaveHandler { 
    561 #    my( $attrHashRef, $topic, $web ) = @_; 
    562 #} 
    563  
    564 =begin TML 
    565  
    566 ---++ mergeHandler( $diff, $old, $new, \%info ) -> $text 
    567 Try to resolve a difference encountered during merge. The =differences=  
    568 array is an array of hash references, where each hash contains the  
    569 following fields: 
    570    * =$diff= => one of the characters '+', '-', 'c' or ' '. 
    571       * '+' - =new= contains text inserted in the new version 
    572       * '-' - =old= contains text deleted from the old version 
    573       * 'c' - =old= contains text from the old version, and =new= text 
    574         from the version being saved 
    575       * ' ' - =new= contains text common to both versions, or the change 
    576         only involved whitespace 
    577    * =$old= => text from version currently saved 
    578    * =$new= => text from version being saved 
    579    * =\%info= is a reference to the form field description { name, title, 
    580      type, size, value, tooltip, attributes, referenced }. It must _not_ 
    581      be wrtten to. This parameter will be undef when merging the body 
    582      text of the topic. 
    583  
    584 Plugins should try to resolve differences and return the merged text.  
    585 For example, a radio button field where we have  
    586 ={ diff=>'c', old=>'Leafy', new=>'Barky' }= might be resolved as  
    587 ='Treelike'=. If the plugin cannot resolve a difference it should return  
    588 undef. 
    589  
    590 The merge handler will be called several times during a save; once for  
    591 each difference that needs resolution. 
    592  
    593 If any merges are left unresolved after all plugins have been given a  
    594 chance to intercede, the following algorithm is used to decide how to  
    595 merge the data: 
    596    1 =new= is taken for all =radio=, =checkbox= and =select= fields to  
    597      resolve 'c' conflicts 
    598    1 '+' and '-' text is always included in the the body text and text 
    599      fields 
    600    1 =&lt;del>conflict&lt;/del> &lt;ins>markers&lt;/ins>= are used to  
    601      mark 'c' merges in text fields 
    602  
    603 The merge handler is called whenever a topic is saved, and a merge is  
    604 required to resolve concurrent edits on a topic. 
    605  
    606 *Since:* Foswiki::Plugins::VERSION = 2.0 
    607  
    608 =cut 
    609  
    610 #sub mergeHandler { 
    611 #    my ( $diff, $old, $new, $info ) = @_; 
    612 #} 
    613  
    614 =begin TML 
    615  
    616 ---++ modifyHeaderHandler( \%headers, $query ) 
    617    * =\%headers= - reference to a hash of existing header values 
    618    * =$query= - reference to CGI query object 
    619 Lets the plugin modify the HTTP headers that will be emitted when a 
    620 page is written to the browser. \%headers= will contain the headers 
    621 proposed by the core, plus any modifications made by other plugins that also 
    622 implement this method that come earlier in the plugins list. 
    623 <verbatim> 
    624 $headers->{expires} = '+1h'; 
    625 </verbatim> 
    626  
    627 Note that this is the HTTP header which is _not_ the same as the HTML 
    628 &lt;HEAD&gt; tag. The contents of the &lt;HEAD&gt; tag may be manipulated 
    629 using the =Foswiki::Func::addToHEAD= method. 
    630  
    631 *Since:* Foswiki::Plugins::VERSION 2.0 
    632  
    633 =cut 
    634  
    635 #sub modifyHeaderHandler { 
    636 #    my ( $headers, $query ) = @_; 
    637 #} 
    638  
    639 =begin TML 
    640  
    641 ---++ redirectCgiQueryHandler($query, $url ) 
    642    * =$query= - the CGI query 
    643    * =$url= - the URL to redirect to 
    644  
    645 This handler can be used to replace Foswiki's internal redirect function. 
    646  
    647 If this handler is defined in more than one plugin, only the handler 
    648 in the earliest plugin in the INSTALLEDPLUGINS list will be called. All 
    649 the others will be ignored. 
    650  
    651 *Since:* Foswiki::Plugins::VERSION 2.0 
    652  
    653 =cut 
    654  
    655 #sub redirectCgiQueryHandler { 
    656 #    my ( $query, $url ) = @_; 
    657 #} 
    658  
    659 =begin TML 
    660  
    661 ---++ renderFormFieldForEditHandler($name, $type, $size, $value, $attributes, $possibleValues) -> $html 
    662  
    663 This handler is called before built-in types are considered. It generates  
    664 the HTML text rendering this form field, or false, if the rendering  
    665 should be done by the built-in type handlers. 
    666    * =$name= - name of form field 
    667    * =$type= - type of form field (checkbox, radio etc) 
    668    * =$size= - size of form field 
    669    * =$value= - value held in the form field 
    670    * =$attributes= - attributes of form field  
    671    * =$possibleValues= - the values defined as options for form field, if 
    672      any. May be a scalar (one legal value) or a ref to an array 
    673      (several legal values) 
    674  
    675 Return HTML text that renders this field. If false, form rendering 
    676 continues by considering the built-in types. 
    677  
    678 *Since:* Foswiki::Plugins::VERSION 2.0 
    679  
    680 Note that you can also extend the range of available 
    681 types by providing a subclass of =Foswiki::Form::FieldDefinition= to implement 
    682 the new type (see =Foswiki::Extensions.JSCalendarContrib= and 
    683 =Foswiki::Extensions.RatingContrib= for examples). This is the preferred way to 
    684 extend the form field types. 
    685  
    686 =cut 
    687  
    688 #sub renderFormFieldForEditHandler { 
    689 #    my ( $name, $type, $size, $value, $attributes, $possibleValues) = @_; 
    690 #} 
    691  
    692 =begin TML 
    693  
    694 ---++ renderWikiWordHandler($linkText, $hasExplicitLinkLabel, $web, $topic) -> $linkText 
    695    * =$linkText= - the text for the link i.e. for =[<nop>[Link][blah blah]]= 
    696      it's =blah blah=, for =BlahBlah= it's =BlahBlah=, and for [[Blah Blah]] it's =Blah Blah=. 
    697    * =$hasExplicitLinkLabel= - true if the link is of the form =[<nop>[Link][blah blah]]= (false if it's ==<nop>[Blah]] or =BlahBlah=) 
    698    * =$web=, =$topic= - specify the topic being rendered 
    699  
    700 Called during rendering, this handler allows the plugin a chance to change 
    701 the rendering of labels used for links. 
    702  
    703 Return the new link text. 
    704  
    705 *Since:* Foswiki::Plugins::VERSION 2.0 
    706  
    707 =cut 
    708  
    709 #sub renderWikiWordHandler { 
    710 #    my( $linkText, $hasExplicitLinkLabel, $web, $topic ) = @_; 
    711 #    return $linkText; 
    712 #} 
    713  
    714 =begin TML 
    715  
    716 ---++ completePageHandler($html, $httpHeaders) 
    717  
    718 This handler is called on the ingredients of every page that is 
    719 output by the standard CGI scripts. It is designed primarily for use by 
    720 cache and security plugins. 
    721    * =$html= - the body of the page (normally &lt;html>..$lt;/html>) 
    722    * =$httpHeaders= - the HTTP headers. Note that the headers do not contain 
    723      a =Content-length=. That will be computed and added immediately before 
    724      the page is actually written. This is a string, which must end in \n\n. 
    725  
    726 *Since:* Foswiki::Plugins::VERSION 2.0 
    727  
    728 =cut 
    729  
    730 #sub completePageHandler { 
    731 #    my( $html, $httpHeaders ) = @_; 
    732 #    # modify $_[0] or $_[1] if you must change the HTML or headers 
    733 #    # You can work on $html and $httpHeaders in place by using the 
    734 #    # special perl variables $_[0] and $_[1]. These allow you to operate 
    735 #    # on parameters as if they were passed by reference; for example: 
    736 #    # $_[0] =~ s/SpecialString/my alternative/ge; 
    737 #} 
    738  
    739 =begin TML 
    740  
    741 ---++ restExample($session) -> $text 
    742  
    743 This is an example of a sub to be called by the =rest= script. The parameter is: 
    744    * =$session= - The Foswiki object associated to this session. 
    745  
    746 Additional parameters can be recovered via de query object in the $session. 
    747  
    748 For more information, check %SYSTEMWEB%.CommandAndCGIScripts#rest 
    749  
    750 For information about handling error returns from REST handlers, see 
    751 Foswiki::Support.Faq1 
    752  
    753 *Since:* Foswiki::Plugins::VERSION 2.0 
    754  
    755 =cut 
    756  
    757 #sub restExample { 
    758 #   my ($session) = @_; 
    759 #   return "This is an example of a REST invocation\n\n"; 
    760 #} 
    76184 
    762851; 
Note: See TracChangeset for help on using the changeset viewer.