Difference: TWikiDotPm (3 vs. 4)

Revision 422 Jan 2008 - Main.TWikiContributor

Line: 9 to 9
 Global variables are avoided wherever possible to avoid problems with CGI accelerators such as mod_perl.
Added:
>
>

Public Data members

  • cgiQuery Pointer to the CGI::
  • context Hash of context ids
  • moved: loginManager TWiki::LoginManager singleton (moved to TWiki::Users)
  • plugins TWiki::Plugins singleton
  • prefs TWiki::Prefs singleton
  • remoteUser Login ID when using ApacheLogin? . Maintained for compatibility only, do not use.
  • requestedWebName Name of web found in URL path or web URL parameter
  • sandbox TWiki::Sandbox singleton
  • scriptUrlPath URL path to the current script. May be dynamically extracted from the URL path if {GetScriptUrlFromCgi}. Only required to support {GetScriptUrlFromCgi} and not consistently used. Avoid.
  • security TWiki::Access singleton
  • SESSION_TAGS Hash of TWiki variables whose value is specific to the current CGI request.
  • store TWiki::Store singleton
  • topicName Name of topic found in URL path or topic URL parameter
  • urlHost Host part of the URL (including the protocol) determined during intialisation and defaulting to {DefaultUrlHost}
  • user Unique user ID of logged-in user
  • users TWiki::Users singleton
  • webName Name of web found in URL path, or web URL parameter, or {UsersWebName}
 

StaticMethod getTWikiLibDir () -> $path

Deleted:
<
<
STATIC method.
 Returns the full path of the directory containing TWiki.pm

Changed:
<
<

ObjectMethod UTF82SiteCharSet ($utf8) -> $ascii

>
>

StaticMethod UTF82SiteCharSet ($utf8) -> $ascii

  Auto-detect UTF-8 vs. site charset in string, and convert UTF-8 into site charset.
Line: 41 to 67
 
Changed:
<
<

ObjectMethod writePageHeader ($query,$pageType,$contentType,$contentLength)

>
>

ObjectMethod generateHTTPHeaders ($query,$pageType,$contentType,$contentLength) -> $header

  All parameters are optional.
Line: 55 to 81
 delimited. Filters any illegal headers. Plugin headers will override core settings.
Added:
>
>
Does not add a Content-length header.

StaticMethod isRedirectSafe ($redirect)=>$ok

 
Added:
>
>
tests if the $redirect is an external URL, returning false if AllowRedirectUrl? is denied
 
Changed:
<
<

ObjectMethod redirect ($url,$passthrough)

>
>

ObjectMethod redirect ($url,$passthrough,$action_redirectto)

  • $url - url or twikitopic to redirect to
  • $passthrough - (optional) parameter to *FILLMEIN*
  • $action_redirectto - (optional) redirect to where ?redirectto= points to (if it's valid)
  Redirects the request to $url, unless
  1. It is overridden by a plugin declaring a redirectCgiQueryHandler.
Line: 65 to 104
 
  1. $query->param('noredirect') is set to a true value.
Thus a redirect is only generated when in a CGI context.
Changed:
<
<
Normally this method will ignore parameters to the current query. If $passthrough is set, then it will pass all parameters that were passed to the current query on to the redirect target. If the request_method was GET, then all parameters can be passed in the URL. If the request_method was POST then it caches the form data and passes over a cache reference in the redirect GET.
>
>
Normally this method will ignore parameters to the current query. Sometimes, for example when redirecting to a login page during authentication (and then again from the login page to the original requested URL), you want to make sure all parameters are passed on, and for this $passthrough should be set to true. In this case it will pass all parameters that were passed to the current query on to the redirect target. If the request_method for the current query was GET, then all parameters will be passed by encoding them in the URL (after ?). If the request_method was POST, then there is a risk the URL would be too big for the receiver, so it caches the form data and passes over a cache reference in the redirect GET.
 
Changed:
<
<
Passthrough is only meaningful if the redirect target is on the same server.
>
>
NOTE: Passthrough is only meaningful if the redirect target is on the same server.
 
Line: 112 to 156
 system web names are considered valid (names starting with _) otherwise only user web names are valid
Added:
>
>
If $TWiki::cfg{EnableHierarchicalWebs} is off, it will also return false when a nested web name is passed to it.
 

ObjectMethod readOnlyMirrorWeb ($theWeb) -> ($mirrorSiteName,$mirrorViewURL,$mirrorLink,$mirrorNote)

Line: 177 to 224
 
Changed:
<
<

ObjectMethod getOopsUrl ($template,@options) -> $absoluteOopsURL

>
>

ObjectMethod normalizeWebTopicName ($theWeb,$theTopic) -> ($theWeb,$theTopic)

Normalize a Web.TopicName

 
Changed:
<
<
Composes a URL for an "oops" error page. The @options consists of a list of key => value pairs. The following keys are used:
  • -web - web name
  • -topic - topic name
  • -def - optional template def within the main template file
  • -params - a single parameter, or a reference to an array of parameters These are passed in the URL as '&param1=' etc.
>
>
See TWikiFuncDotPm for a full specification of the expansion (not duplicated here)
 
Changed:
<
<
Do not include the "oops" part in front of the template name.
>
>
WARNING if there is no web specification (in the web or topic parameters) the web defaults to $TWiki::cfg{UsersWebName}. If there is no topic specification, or the topic is '0', the topic defaults to the web home topic name.
 
Deleted:
<
<
Alternatively you can pass a reference to an OopsException? in place of the template. All other parameters will be ignored.
 
Deleted:
<
<
The returned URL ends up looking something like this: "http://host/twiki/bin/oops/$web/$topic?template=$template&param1=$scriptParams[0]..."
 
Changed:
<
<
Note: if {keep} is true in the params, then they will also be pushed into the current query.
>
>

ClassMethod new ($loginName,$query,\%initialContext)

 
Added:
>
>
Constructs a new TWiki object. Parameters are taken from the query object.
 
Added:
>
>
  • $loginName is the login username (not the wikiname) of the user you want to be logged-in if none is available from a session or browser. Used mainly for side scripts and debugging.
  • $query the CGI query (may be undef, in which case an empty query is used)
  • \%initialContext - reference to a hash containing context name=value pairs to be pre-installed in the context hash
 
Deleted:
<
<

ObjectMethod normalizeWebTopicName ($theWeb,$theTopic) -> ($theWeb,$theTopic)

 
Deleted:
<
<
Normalize a Web.TopicName
 
Changed:
<
<
See TWikiFuncDotPm for a full specification of the expansion (not duplicated here)
>
>

ObjectMethod renderer ()

Get a reference to the renderer object. Done lazily because not everyone needs the renderer.
 
Deleted:
<
<
WARNING if there is no web specification (in the web or topic parameters) the web defaults to $TWiki::cfg{UsersWebName}. If there is no topic specification, or the topic is '0', the topic defaults to the web home topic name.
 
Added:
>
>

ObjectMethod attach ()

Get a reference to the attach object. Done lazily because not everyone needs the attach.
 
Deleted:
<
<

ClassMethod new ($loginName,$query,\%initialContext)

 
Deleted:
<
<
Constructs a new TWiki object. Parameters are taken from the query object.
 
Changed:
<
<
  • $loginName is the username of the user you want to be logged-in if none is available from a session or browser. Used mainly for side scripts and debugging.
  • $query the CGI query (may be undef, in which case an empty query is used)
  • \%initialContext - reference to a hash containing context name=value pairs to be pre-installed in the context hash
>
>

ObjectMethod templates ()

Get a reference to the templates object. Done lazily because not everyone needs the templates.
 
Added:
>
>

ObjectMethod i18n ()

Get a reference to the i18n object. Done lazily because not everyone needs the i18ner.
 
Deleted:
<
<

ObjectMethod finish

 
Changed:
<
<
Complete processing after the client's HTTP request has been responded to. Right now this does two things:
  1. calling TWiki::Client to flushing the user's session (if any) to disk,
  2. breaking circular references to allow garbage collection in persistent environments
>
>

ObjectMethod search ()

Get a reference to the search object. Done lazily because not everyone needs the searcher.

ObjectMethod security ()

Get a reference to the security object. Done lazily because not everyone needs the security.

ObjectMethod net ()

Get a reference to the net object. Done lazily because not everyone needs the net.

ObjectMethod finish ()

Break circular references.
 
Line: 237 to 304
 
  • $action - what happened, e.g. view, save, rename
  • $wbTopic - what it happened to
  • $extra - extra info, such as minor flag
Changed:
<
<
  • $user - user who did the saving (user object or string user name)
>
>
  • $user - user who did the saving (user id)
 Write the log for an event to the logfile
Line: 292 to 359
 
Changed:
<
<

ObjectMethod expandVariablesOnTopicCreation ($text,$user) -> $text

>
>

ObjectMethod expandVariablesOnTopicCreation ($text,$user,$web,$topic) -> $text

 
  • $text - text to expand
Changed:
<
<
  • $user - reference to user object. This is the user expanded in e.g. %USERNAME. Optional, defaults to logged-in user.
>
>
  • $user - This is the user expanded in e.g. %USERNAME. Optional, defaults to logged-in user.
 Expand limited set of variables during topic creation. These are variables expected in templates that must be statically expanded in new content.
Added:
>
>
  • $web - name of web
  • $topic - name of topic
  # SMELL: no plugin handler
Line: 339 to 408
 
Added:
>
>

StaticMethod urlEncodeAttachment ($text)

For attachments, URL-encode specially to 'freeze' any characters >127 in the site charset (e.g. ISO-8859-1 or KOI8-R), by doing URL encoding into native charset ($siteCharset) - used when generating attachment URLs, to enable the web server to serve attachments, including images, directly.

This encoding is required to handle the cases of:

- browsers that generate UTF-8 URLs automatically from site charset URLs - now quite common - web servers that directly serve attachments, using the site charset for filenames, and cannot convert UTF-8 URLs into site charset filenames

The aim is to prevent the browser from converting a site charset URL in the web page to a UTF-8 URL, which is the default. Hence we 'freeze' the URL into the site character set through URL encoding.

In two cases, no URL encoding is needed: For EBCDIC mainframes, we assume that site charset URLs will be translated (outbound and inbound) by the web server to/from an EBCDIC character set. For sites running in UTF-8, there's no need for TWiki to do anything since all URLs and attachment filenames are already in UTF-8.

 

StaticMethod urlEncode ($string) -> encodedstring

Encode by converting characters that are illegal in URLs to

Line: 348 to 441
 characters such as = and ?.

RFC 1738, Dec. '94:

Changed:
<
<
>
>
>
 ...Only alphanumerics [0-9a-zA-Z], the special characters $-_.+!*'(), and reserved characters used for their reserved purposes may be used unencoded within a URL.
Line: 356 to 450
 Reserved characters are $&+,/:;=?@ - these are also encoded by this method.
Changed:
<
<
SMELL: For non-ISO-8859-1 $TWiki::cfg{Site}{CharSet}, need to convert to UTF-8 before URL encoding. This encoding only supports 8-bit character codes.
>
>
This URL-encoding handles all character encodings including ISO-8859-*, KOI8-R, EUC-* and UTF-8.

This may not handle EBCDIC properly, as it generates an EBCDIC URL-encoded URL, but mainframe web servers seem to translate this outbound before it hits browser - see CGI::Util::escape for another approach.

 
Line: 387 to 484
 
Added:
>
>

ObjectMethod expandAllTags (\$text,$topic,$web,$meta)

Expands variables by replacing the variables with their values. Some example variables: %TOPIC%, %SCRIPTURL%, %WIKINAME%, etc. $web and $incs are passed in for recursive include expansion. They can safely be undef. The rules for tag expansion are:
  1. Tags are expanded left to right, in the order they are encountered.
  2. Tags are recursively expanded as soon as they are encountered - the algorithm is inherently single-pass
  3. A tag is not "encountered" until the matching }% has been seen, by which time all tags in parameters will have been expanded
  4. Tag expansions that create new tags recursively are limited to a set number of hierarchical levels of expansion

 

ObjectMethod enterContext ($id,$val)

Add the context id $id into the set of active contexts. The $val

Line: 461 to 575
 
Changed:
<
<

ObjectMethod handleCommonTags ($text,$web,$topic) -> $text

>
>

ObjectMethod handleCommonTags ($text,$web,$topic,$meta) -> $text

  Processes %VARIABLE%, and %TOC% syntax; also includes 'commonTagsHandler' plugin hook.
Line: 469 to 583
 Returns the text of the topic, after file inclusion, variable substitution, table-of-contents generation, and any plugin changes from commonTagsHandler.
Added:
>
>
$meta may be undef when, for example, expanding templates, or one-off strings at a time when meta isn't available.
 

ObjectMethod addToHEAD ($id,$html)

 
This site is powered by the TWiki collaboration platformCopyright � by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiDotPm