Ignore:
Timestamp:
10/15/09 19:28:59 (3 years ago)
Author:
KennethLavrsen
Message:

Item2260: MailerContrib cannot find email templates based on skin or web
The checkin does the following

  • It makes a tiny little fix in MailerContrib.pm where I pushTopicContext before loading mail template and pop it again afterwards
  • Updates the the documentation to show by example how to tailor the mail message
  • Merge over the code from trunk. This introduces a bug fix from Item1603 which for some reason was only applied to trunk
  • And with this merge also merge over a lot of perl tinying.

It was too difficult to separate the two once I was this far. Look at next checkin in trunk to see only the actual code changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x00/MailerContrib/lib/Foswiki/Contrib/MailerContrib/Change.pm

    r1340 r5269  
    5353 
    5454    $this->{SESSION} = $session; 
    55     $this->{WEB} = $web; 
    56     $this->{TOPIC} = $topic; 
     55    $this->{WEB}     = $web; 
     56    $this->{TOPIC}   = $topic; 
    5757    my $user; 
     58 
    5859    # SMELL: call to unpublished core function 
    59     if (defined(&Foswiki::Users::findUser)) { 
     60    if ( defined(&Foswiki::Users::findUser) ) { 
    6061        $user = $session->{users}->findUser( $author, undef, 1 ); 
    6162        $this->{AUTHOR} = $user ? $user->wikiName() : $author; 
    62     } else { 
     63    } 
     64    else { 
    6365        $this->{AUTHOR} = Foswiki::Func::getWikiName($author); 
    6466    } 
    6567    $this->{TIME} = $time; 
    6668    ASSERT($rev) if DEBUG; 
     69 
    6770    # rev at this change 
    6871    $this->{CURR_REV} = $rev; 
     72 
    6973    # previous rev 
    7074    $this->{BASE_REV} = $rev - 1 || 1; 
     
    7680    my $this = shift; 
    7781 
    78     return "$this->{WEB}.$this->{TOPIC} by $this->{AUTHOR} at $this->{TIME} from r$this->{BASE_REV} to r$this->{CURR_REV}"; 
     82    return 
     83"$this->{WEB}.$this->{TOPIC} by $this->{AUTHOR} at $this->{TIME} from r$this->{BASE_REV} to r$this->{CURR_REV}"; 
    7984} 
    8085 
     
    8994 
    9095sub merge { 
    91     my( $this, $other ) = @_; 
    92     ASSERT($this->isa( 'Foswiki::Contrib::MailerContrib::Change' )) if DEBUG; 
    93     ASSERT($other->isa( 'Foswiki::Contrib::MailerContrib::Change' )) if DEBUG; 
    94  
    95     if( $other->{CURR_REV} > $this->{CURR_REV} ) { 
     96    my ( $this, $other ) = @_; 
     97    ASSERT( $this->isa('Foswiki::Contrib::MailerContrib::Change') ) if DEBUG; 
     98    ASSERT( $other->isa('Foswiki::Contrib::MailerContrib::Change') ) if DEBUG; 
     99 
     100    if ( $other->{CURR_REV} > $this->{CURR_REV} ) { 
    96101        $this->{CURR_REV} = $other->{CURR_REV}; 
    97         $this->{AUTHOR} = $other->{AUTHOR}; 
    98         $this->{TIME} = $other->{TIME}; 
     102        $this->{AUTHOR}   = $other->{AUTHOR}; 
     103        $this->{TIME}     = $other->{TIME}; 
    99104    } 
    100105 
    101106    $this->{BASE_REV} = $other->{BASE_REV} 
    102       if($other->{BASE_REV} < $this->{BASE_REV}); 
     107      if ( $other->{BASE_REV} < $this->{BASE_REV} ); 
    103108} 
    104109 
     
    118123    my ( $this, $html ) = @_; 
    119124 
    120     unless( defined $this->{HTML_SUMMARY} ) { 
    121         if( defined &Foswiki::Func::summariseChanges ) { 
     125    unless ( defined $this->{HTML_SUMMARY} ) { 
     126        if ( defined &Foswiki::Func::summariseChanges ) { 
    122127            $this->{HTML_SUMMARY} = 
    123               Foswiki::Func::summariseChanges( 
    124                   $this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, 
    125                   $this->{CURR_REV}, 1 ); 
    126         } else { 
     128              Foswiki::Func::summariseChanges( $this->{WEB}, $this->{TOPIC}, 
     129                $this->{BASE_REV}, $this->{CURR_REV}, 1 ); 
     130        } 
     131        else { 
    127132            $this->{HTML_SUMMARY} = 
    128               $this->{SESSION}->{renderer}->summariseChanges 
    129                 ( undef, $this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, 
    130                   $this->{CURR_REV}, 1 ); 
     133              $this->{SESSION}->{renderer} 
     134              ->summariseChanges( undef, $this->{WEB}, $this->{TOPIC}, 
     135                $this->{BASE_REV}, $this->{CURR_REV}, 1 ); 
    131136        } 
    132137    } 
     
    134139    $html =~ s/%TOPICNAME%/$this->{TOPIC}/g; 
    135140    $html =~ s/%AUTHOR%/$this->{AUTHOR}/g; 
    136     my $tim =  Foswiki::Time::formatTime( $this->{TIME} ); 
     141    my $tim = Foswiki::Time::formatTime( $this->{TIME} ); 
    137142    $html =~ s/%TIME%/$tim/go; 
    138143    $html =~ s/%CUR_REV%/$this->{CURR_REV}/g; 
    139144    $html =~ s/%BASE_REV%/$this->{BASE_REV}/g; 
    140145    my $frev = ''; 
    141     if( $this->{CURR_REV} ) { 
    142         if( $this->{CURR_REV} > 1 ) { 
    143             $frev = 'r'.$this->{BASE_REV}. 
    144               '-&gt;r'.$this->{CURR_REV}; 
    145         } else { 
     146    if ( $this->{CURR_REV} ) { 
     147        if ( $this->{CURR_REV} > 1 ) { 
     148            $frev = 'r' . $this->{BASE_REV} . '-&gt;r' . $this->{CURR_REV}; 
     149        } 
     150        else { 
     151 
    146152            # new _since the last notification_ 
    147             $frev = CGI::span( { class=>'foswikiNew' }, 'NEW' ); 
     153            $frev = CGI::span( { class => 'foswikiNew' }, 'NEW' ); 
    148154        } 
    149155    } 
    150156    $html =~ s/%REVISION%/$frev/g; 
    151     $html = Foswiki::Func::expandCommonVariables( 
    152         $html, $this->{TOPIC}, $this->{WEB} ); 
    153     $html = Foswiki::Func::renderText( $html ); 
     157    $html = 
     158      Foswiki::Func::expandCommonVariables( $html, $this->{TOPIC}, 
     159        $this->{WEB} ); 
     160    $html = Foswiki::Func::renderText($html); 
    154161    $html =~ s/%TEXTHEAD%/$this->{HTML_SUMMARY}/g; 
    155162 
     
    167174    my ( $this, $template ) = @_; 
    168175 
    169     unless( defined $this->{TEXT_SUMMARY} ) { 
     176    unless ( defined $this->{TEXT_SUMMARY} ) { 
    170177        my $s; 
    171         if( defined &Foswiki::Func::summariseChanges ) { 
    172             $s = Foswiki::Func::summariseChanges( 
    173                 $this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, 
    174                 $this->{CURR_REV}, 0 ); 
    175         } else { 
    176             $s = $this->{SESSION}->{renderer}->summariseChanges( 
    177                 undef, $this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, 
    178                 $this->{CURR_REV}, 0 ); 
     178        if ( defined &Foswiki::Func::summariseChanges ) { 
     179            $s = 
     180              Foswiki::Func::summariseChanges( $this->{WEB}, $this->{TOPIC}, 
     181                $this->{BASE_REV}, $this->{CURR_REV}, 0 ); 
     182        } 
     183        else { 
     184            $s = 
     185              $this->{SESSION}->{renderer} 
     186              ->summariseChanges( undef, $this->{WEB}, $this->{TOPIC}, 
     187                $this->{BASE_REV}, $this->{CURR_REV}, 0 ); 
    179188        } 
    180189        $s =~ s/\n/\n   /gs; 
     
    183192    } 
    184193 
    185     my $tim =  Foswiki::Time::formatTime( $this->{TIME} ); 
     194    my $tim = Foswiki::Time::formatTime( $this->{TIME} ); 
    186195 
    187196    # URL-encode topic names for use of I18N topic names in plain text 
     
    193202    $template =~ s/%CUR_REV%/$this->{CURR_REV}/g; 
    194203    $template =~ s/%BASE_REV%/$this->{BASE_REV}/g; 
    195     $template =~ s/%TOPICNAME%/$this->{TOPIC}/g; # deprecated DO NOT USE! 
     204    $template =~ s/%TOPICNAME%/$this->{TOPIC}/g;     # deprecated DO NOT USE! 
    196205    $template =~ s/%TOPIC%/$this->{TOPIC}/g; 
    197206    my $frev = ''; 
    198     if( $this->{CURR_REV} ) { 
    199         if( $this->{CURR_REV} > 1 ) { 
    200             $frev = 'r'.$this->{BASE_REV}. 
    201               '->r'.$this->{CURR_REV}; 
    202         } else { 
     207    if ( $this->{CURR_REV} ) { 
     208        if ( $this->{CURR_REV} > 1 ) { 
     209            $frev = 'r' . $this->{BASE_REV} . '->r' . $this->{CURR_REV}; 
     210        } 
     211        else { 
     212 
    203213            # new _since the last notification_ 
    204214            $frev = 'NEW'; 
Note: See TracChangeset for help on using the changeset viewer.