From: <Cra...@nt...> - 2005-02-25 18:53:06
|
Author: CrawfordCurrie Date: 2005-02-25 10:50:38 -0800 (Fri, 25 Feb 2005) New Revision: 3709 Modified: twiki/branches/DEVELOP/lib/TWiki.pm Log: LocationLocationLocation: refactoring cleanups. handleCommonTags and getRenderedVersion had wierd parameter specs, and many calls were incomplete and in some cases relying on defaults which were wrong. Changed it so they always pass web and topic Modified: twiki/branches/DEVELOP/lib/TWiki.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki.pm 2005-02-25 18:50:13 UTC (rev 3708) +++ twiki/branches/DEVELOP/lib/TWiki.pm 2005-02-25 18:50:38 UTC (rev 3709) @@ -675,7 +675,8 @@ my $mirrorNote = $this->{templates}->readTemplate( "mirrornote" ); $mirrorNote =~ s/%MIRRORSITENAME%/$mirrorSiteName/g; $mirrorNote =~ s/%MIRRORVIEWURL%/$mirrorViewURL/g; - $mirrorNote = $this->{renderer}->getRenderedVersion( $mirrorNote, $theWeb ); + $mirrorNote = $this->{renderer}->getRenderedVersion + ( $mirrorNote, $theWeb, $TWiki::cfg{HomeTopic} ); $mirrorNote =~ s/\s*$//g; @mirrorInfo = ( $mirrorSiteName, $mirrorViewURL, $mirrorLink, $mirrorNote ); } @@ -1433,17 +1434,25 @@ =pod ---++ ObjectMethod expandVariablesOnTopicCreation ( $text, $user ) -> $text + * =$text= - text to expand + * =$user= - reference to user object Expand limited set of variables during topic creation. These are variables expected in templates that must be statically expanded in new content. The expanded variables are: | =%<nop>DATE%= | Signature-format date | +| =%<nop>TIME%= | Server time | +| =%<nop>SERVERTIME%= | Server time | +| =%<nop>GMTIME%= | GM time | | =%<nop>USERNAME%= | Base login name | | =%<nop>WIKINAME%= | Wiki name | | =%<nop>WIKIUSERNAME%= | Wiki name with prepended web | | =%<nop>URLPARAM%= | Parameters to the current CGI query | | =%<nop>NOP%= | No-op | +SMELL: This should really be done by _expandAllTags but with +a subset of the substitutions. + =cut sub expandVariablesOnTopicCreation { @@ -1453,11 +1462,13 @@ ASSERT(ref($user) eq "TWiki::User") if DEBUG; $text =~ s/%DATE%/$this->_DATE()/ge; - $text =~ s/%USERNAME%/$user->login()/geo; # "jdoe" - $text =~ s/%WIKINAME%/$user->wikiName()/geo; # "JonDoe" - $text =~ s/%WIKIUSERNAME%/$user->webDotWikiName()/geo;# Main.JonDoe - $text =~ s/%URLPARAM{(.*?)}%/$this->_URLPARAM(new TWiki::Attrs($1))/geo; + $text =~ s/%TIME%/%SERVERTIME%/g; + $text =~ s/%SERVERTIME(?:{(.*?)})?%/$this->_SERVERTIME(new TWiki::Attrs($1))/ge; + $text =~ s/%GMTIME(?:{(.*?)})?%/$this->_GMTIME(new TWiki::Attrs($1))/ge; + $text =~ s/%((USER|WIKI|WIKIUSER)NAME)%/$this->{SESSION_TAGS}{$1}/g; + $text =~ s/%URLPARAM{(.*?)}%/$this->_URLPARAM(new TWiki::Attrs($1))/ge; + # Remove filler: Use it to remove access control at time of # topic instantiation or to prevent search from hitting a template # SMELL: this expansion of %NOP{}% is different to the default @@ -1835,7 +1846,7 @@ =pod ----++ ObjectMethod handleCommonTags( $text, $topic, $web ) -> $text +---++ ObjectMethod handleCommonTags( $text, $web, $topic ) -> $text Processes %<nop>VARIABLE%, and %<nop>TOC% syntax; also includes "commonTagsHandler" plugin hook. @@ -1845,12 +1856,12 @@ =cut sub handleCommonTags { - my( $this, $text, $theTopic, $theWeb ) = @_; + my( $this, $text, $theWeb, $theTopic ) = @_; ASSERT(ref($this) eq "TWiki") if DEBUG; + ASSERT($theWeb); + ASSERT($theTopic); - $theWeb = $this->{webName} unless $theWeb; - # Plugin Hook (for cache Plugins only) $this->{plugins}->beforeCommonTagsHandler( $text, $theTopic, $theWeb ); |