Index: Store.pm =================================================================== RCS file: /cvsroot/twiki/twiki/lib/TWiki/Store.pm,v retrieving revision 1.77 diff -e -r1.77 Store.pm 1509c $text =~ s/%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/&_readTemplateFile( $1, $theSkin, $theWeb )/geo; . 1507c my $text = _readTemplateFile( $theName, $theSkin, $theWeb ); . 1505a if( ! defined( $theWeb ) ) { $theWeb = $TWiki::webName; } . 1500c my( $theName, $theSkin, $theWeb ) = @_; . 1494c WARNING! THIS IS A SIDE-EFFECTING FUNCTION PUBLIC Reads a template, constructing a candidate name for the template as described in _readTemplateFile. If template text is found, extracts include statements and fully expands them. Also extracts template definitions and adds them to the global templateVars hash, overwriting any previous definition. . 1492c ---++ sub readTemplate ( $theName, $theSkin, $theWeb ) Return value: expanded template text . 1468c If $theVar is the name of a previously defined template, returns the text of that template after recursive expansion of any TMPL:P tags it contains. . 1466a Return value: expanded text of the named template, as found from looking in the global register of template definitions. WARNING! THIS FUNCTION DEPENDS ON GLOBAL VARIABLES . 1455a # See if it is a user topic. Search first in current web # twiki web. Note that neither web nor topic may be variables when used in a template. if ( ! $tmplFile ) { if ( $theSkin ne "" ) { $theSkin = ucfirst( $theSkin ) . "Skin"; } my $theTopic; my $theWeb; if ( $theName =~ /^(\w+)\.(\w+)$/ ) { $theWeb = ucfirst( $1 ); $theTopic = ucfirst( $2 ); } else { $theWeb = $TWiki::webName; $theTopic = $theSkin . ucfirst( $theName ) . "Template"; if ( !TWiki::Store::topicExists( $theWeb, $theTopic )) { $theWeb = $TWiki::twikiWebname; } } if ( TWiki::Store::topicExists( $theWeb, $theTopic ) && TWiki::Access::checkAccessPermission( "view", $TWiki::wikiUserName, "", $theTopic, $theWeb )) { my ( $meta, $text ) = TWiki::Store::readTopic( $theWeb, $theTopic, 1 ); return $text; } } . 1422c my $tmplDir = "$TWiki::templateDir/$theWeb"; . 1409c my( $theName, $theSkin, $theWeb ) = @_; . 1403c WARNING! THIS FUNCTION DEPENDS ON GLOBAL VARIABLES PRIVATE Reads a template, constructing a candidate name for the template thus: $name.$skin.tmpl, and looking for a file of that name first in templates/$web and then if that fails in templates/. If a template is not found, tries to parse $name into a web name and a topic name, and read topic $Web.${Skin}Skin${Topic}Template. If $name does not contain a web specifier, $Web defaults to TWiki::twikiWebname. If no skin is specified, topic is ${Topic}Template. If the topic exists, checks access permissions and reads the topic without meta-data. In the event that the read fails (template not found, access permissions fail) returns the empty string "". skin, web and topic names are forced to an upper-case first character when composing user topic names. . 1401c ---++ _readTemplateFile ( $theName, $theSkin ) Return value: raw template text, or "" if read fails .