| Global variables are avoided wherever possible to avoid problems
with CGI accelerators such as mod_perl. |
|
> > | 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 |
|
< < | STATIC method. |
| Returns the full path of the directory containing TWiki.pm
|
|
< < | ObjectMethod *UTF82SiteCharSet ($utf8) -> $ascii |
> > | StaticMethod *UTF82SiteCharSet ($utf8) -> $ascii |
|
Auto-detect UTF-8 vs. site charset in string, and convert UTF-8 into site
charset. |
| |
|
< < | ObjectMethod *writePageHeader ($query,$pageType,$contentType,$contentLength) |
> > | ObjectMethod *generateHTTPHeaders ($query,$pageType,$contentType,$contentLength) -> $header |
|
All parameters are optional. |
| delimited. Filters any illegal headers. Plugin headers will override
core settings. |
|
> > | Does not add a Content-length header.
StaticMethod isRedirectSafe ($redirect)=>$ok |
| |
|
> > | tests if the $redirect is an external URL, returning false if AllowRedirectUrl is denied |
| |
|
< < | 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
- It is overridden by a plugin declaring a
redirectCgiQueryHandler .
|
|
- $query->param('noredirect') is set to a true value.
Thus a redirect is only generated when in a CGI context. |
|
< < | 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. |
| |
|
< < | 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. |
| |
| system web names are considered valid (names starting with _)
otherwise only user web names are valid |
|
> > | 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) |
| |
|
< < | ObjectMethod getOopsUrl ($template,@options) -> $absoluteOopsURL |
> > | ObjectMethod *normalizeWebTopicName ($theWeb,$theTopic) -> ($theWeb,$theTopic)
Normalize a Web.TopicName |
| |
|
< < | 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 '¶m1=' etc.
|
> > | See TWikiFuncDotPm for a full specification of the expansion (not duplicated
here) |
| |
|
< < | 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. |
| |
|
< < | Alternatively you can pass a reference to an OopsException in place of the template. All other parameters will be ignored. |
| |
|
< < | The returned URL ends up looking something like this:
"http://host/twiki/bin/oops/$web/$topic?template=$template¶m1=$scriptParams[0]..." |
| |
|
< < | Note: if {keep} is true in the params, then they will also be pushed into the
current query. |
> > | ClassMethod new ($loginName,$query,\%initialContext) |
| |
|
> > | Constructs a new TWiki object. Parameters are taken from the query object. |
| |
|
> > |
-
$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
|
| |
|
< < | ObjectMethod *normalizeWebTopicName ($theWeb,$theTopic) -> ($theWeb,$theTopic) |
| |
|
< < | Normalize a Web.TopicName |
| |
|
< < | See TWikiFuncDotPm for a full specification of the expansion (not duplicated here) |
> > |
Get a reference to the renderer object. Done lazily because not everyone
needs the renderer. |
| |
|
< < | 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. |
| |
|
> > |
Get a reference to the attach object. Done lazily because not everyone
needs the attach. |
| |
|
< < | ClassMethod new ($loginName,$query,\%initialContext) |
| |
|
< < | Constructs a new TWiki object. Parameters are taken from the query object. |
| |
|
< < |
-
$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
|
> > |
Get a reference to the templates object. Done lazily because not everyone
needs the templates. |
| |
|
> > |
Get a reference to the i18n object. Done lazily because not everyone
needs the i18ner. |
| |
|
< < | |
| |
|
< < | Complete processing after the client's HTTP request has been responded
to. Right now this does two things:
- calling TWiki::Client to flushing the user's session (if any) to disk,
- breaking circular references to allow garbage collection in persistent environments
|
> > |
Get a reference to the search object. Done lazily because not everyone
needs the searcher.
Get a reference to the security object. Done lazily because not everyone
needs the security.
Get a reference to the net object. Done lazily because not everyone
needs the net.
Break circular references. |
| |
|
-
$action - what happened, e.g. view, save, rename
-
$wbTopic - what it happened to
-
$extra - extra info, such as minor flag
|
|
< < |
-
$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 |
| |
|
< < | ObjectMethod *expandVariablesOnTopicCreation ($text,$user) -> $text |
> > | ObjectMethod *expandVariablesOnTopicCreation ($text,$user,$web,$topic) -> $text |
| |
|
< < |
-
$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. |
|
> > |
-
$web - name of web
-
$topic - name of topic
|
|
# SMELL: no plugin handler |
| |
|
> > | 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 |
| characters such as = and ?.
RFC 1738, Dec. '94: |
|
< < | > |
> > | |
| ...Only alphanumerics [0-9a-zA-Z], the special
characters $-_.+!*'(), and reserved characters used for their
reserved purposes may be used unencoded within a URL. |
| Reserved characters are $&+,/:;=?@ - these are also encoded by
this method. |
|
< < | 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. |
| |
| |
|
> > | 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:
- Tags are expanded left to right, in the order they are encountered.
- Tags are recursively expanded as soon as they are encountered - the algorithm is inherently single-pass
- A tag is not "encountered" until the matching }% has been seen, by which time all tags in parameters will have been expanded
- Tag expansions that create new tags recursively are limited to a set number of hierarchical levels of expansion
|
|
Add the context id $id into the set of active contexts. The $val |
| |
|
< < | ObjectMethod *handleCommonTags ($text,$web,$topic) -> $text |
> > | ObjectMethod *handleCommonTags ($text,$web,$topic,$meta) -> $text |
|
Processes %VARIABLE%, and %TOC% syntax; also includes
'commonTagsHandler' plugin hook. |
| Returns the text of the topic, after file inclusion, variable substitution,
table-of-contents generation, and any plugin changes from commonTagsHandler. |
|
> > | $meta may be undef when, for example, expanding templates, or one-off strings
at a time when meta isn't available. |
|
|