SEARCH{...}%" );= |
| Parameter: =$text= | Search variable |
| Return: =$text= | Search result in [[TWiki.FormattedSearch]] format |
---+++ formatTime( $time, $format, $timezone ) ==> $text
| Description: | Format the time in seconds into the desired time string |
| Parameter: =$time= | Time in epoc seconds |
| Parameter: =$format= | Format type, optional. Default e.g. =" TWiki::Plugins::VERSION 1.010 (31 Dec 2002) - 19:30"=, can be ="iso"= (e.g. ="2002-12-31T19:30Z"=), ="rcs"= (e.g. ="2001/12/31 23:59:59"=, ="http"= for HTTP header format (e.g. ="Thu, 23 Jul 1998 07:21:56 GMT"=) |
| Parameter: =$timezone= | either not defined (uses the displaytime setting), "gmtime", or "servertime" |
| Return: =$text= | Formatted time string |
| Note: | if you used the removed formatGmTime, add a third parameter "gmtime" |
| Since: | TWiki::Plugins::VERSION 1.020 (26 Feb 2004) |
---+++ formatGmTime( $time, $format ) ==> $text
| NOTE: | This function is deprecated and should not be used. Use formatTime() instead |
| Description: | Format the time to GM time |
| Parameter: =$time= | Time in epoc seconds |
| Parameter: =$format= | Format type, optional. Default e.g. ="31 Dec 2002 - 19:30"=, can be ="iso"= (e.g. ="2002-12-31T19:30Z"=), ="rcs"= (e.g. ="2001/12/31 23:59:59"=, ="http"= for HTTP header format (e.g. ="Thu, 23 Jul 1998 07:21:56 GMT"=) |
| Return: =$text= | Formatted time string |
| Since: | TWiki::Plugins::VERSION 1.000 (7 Dec 2002) |
---++ Functions: File I/O
---+++ getDataDir( ) ==> $dir
| Description: | Get data directory (topic file root) |
| Return: =$dir= | Data directory, e.g. ="/twiki/data"= |
| Since: | TWiki::Plugins::VERSION 1.000 (7 Dec 2002) |
---+++ getPubDir( ) ==> $dir
| Description: | Get pub directory (file attachment root). Attachments are in =$dir/Web/TopicName= |
| Return: =$dir= | Pub directory, e.g. ="/htdocs/twiki/pub"= |
| Since: | TWiki::Plugins::VERSION 1.000 (7 Dec 2002) |
---+++ readTopic( $web, $topic ) ==> ( $meta, $text )
| NOTE: | The following function is deprecated and should not be used. Use readTopicText() instead |
| Description: | Read topic text and meta data, regardless of access permissions. |
| Parameter: =$web= | Web name, required, e.g. ="Main"= |
| Parameter: =$topic= | Topic name, required, e.g. ="TokyoOffice"= |
| Return: =( $meta, $text )= | Meta data object and topic text |
| Since: | TWiki::Plugins::VERSION 1.000 (7 Dec 2002) |
---+++ readTemplate( $name, $skin ) ==> $text
| Description: | Read a template or skin file. Embedded [[TWiki.TWikiTemplates][template directives]] get expanded |
| Parameter: =$name= | Template name, e.g. ="view"= |
| Parameter: =$skin= | Skin name, optional, e.g. ="print"= |
| Return: =$text= | Template text |
| Since: | TWiki::Plugins::VERSION 1.000 (7 Dec 2002) |
---+++ readFile( $filename ) ==> $text
| Description: | Read text file, low level. NOTE: For topics use readTopicText() |
| Parameter: =$filename= | Full path name of file |
| Return: =$text= | Content of file |
| Since: | TWiki::Plugins::VERSION 1.000 (7 Dec 2002) |
---+++ saveFile( $filename, $text )
| Description: | Save text file, low level. NOTE: For topics use saveTopicText() |
| Parameter: =$filename= | Full path name of file |
| Parameter: =$text= | Text to save |
| Return: | none |
| Since: | TWiki::Plugins::VERSION 1.000 (7 Dec 2002) |
| TODO: | This should return an error for the different failure modes. |
---+++ writeWarning( $text )
| Description: | Log Warning that may require admin intervention to data/warning.txt |
| Parameter: =$text= | Text to write; timestamp gets added |
| Return: | none |
| Since: | TWiki::Plugins::VERSION 1.020 (16 Feb 2004) |
---+++ writeDebug( $text )
| Description: | Log debug message to data/debug.txt |
| Parameter: =$text= | Text to write; timestamp gets added |
| Return: | none |
| Since: | TWiki::Plugins::VERSION 1.020 (16 Feb 2004) |
---++ Functions: System and I18N related
---+++ getRegularExpression( $regexName ) ==> $pattern
| Description: | Retrieves a TWiki predefined regular expression |
| Parameter: =$regexName= | Name of the regular expression to retrieve. See notes below |
| Return: | String or precompiled regular expression matching as described below |
| Since: | TWiki::Plugins::VERSION 1.020 (9 Feb 2004) |
__Notes:__ TWiki internally precompiles several regular expressions to represent various string entities
in an I18N-compatible manner. Plugins are encouraged to use these in matching where appropriate.
The following are guaranteed to be present; others may exist, but their use is unsupported and
they may be removed in future TWiki versions. Those which are marked "CC" are for use within
character classes and may not produce the desired results outside of them.
| *Name* | *Matches* | *CC* |
| upperAlpha | Upper case characters | Y |
| lowerAlpha | Lower case characters | Y |
| mixedAlpha | Alphabetic characters | Y |
| mixedAlphaNum | Alphanumeric charactecs | Y |
| wikiWordRegex | WikiWords | N |
Example:
my $upper = TWiki::Func::getRegularExpression("upperAlpha");
my $alpha = TWiki::Func::getRegularExpression("mixedAlpha");
my $capitalized = qr/[$upper][$alpha]+/;
---+++ checkDependencies( $moduleName, $dependenciesRef ) ==> $error
| Description: | Checks a list of Perl dependencies at runtime |
| Parameter: =$moduleName= | Context description e.g. name of the module being checked |
| Parameter: =$dependenciesRef= | Reference of list of hashes containing dependency information; see notes below |
| Return: =$error= | undef if dependencies are OK, an error message otherwise |
| Since: | TWiki::Plugins::VERSION 1.025 (01 Aug 2004) |
The dependencies are expressed as a list of hashes. Each hash contains
the name of a package and (optionally) a boolean constraint on the VERSION
variable in that package. It is usually used from the =initPlugin= method
like this:
if( $TWiki::Plugins::VERSION >= 1.025 ) {
my @deps = (
{ package => 'TWiki::Plugins::CalendarPlugin', constraint => '>= 5.030' },
{ package => 'Time::ParseDate' },
{ package => 'Apache::VMonitor' }
);
my $err = TWiki::Func::checkDependencies( $pluginName, \@deps );
if( $err ) {
TWiki::Func::writeWarning( $err );
print STDERR $err; # print to webserver log file
return 0; # plugin initialisation failed
}
}
---++ Copyright and License
Copyright (C) 2000-2004 Peter Thoeny, Peter@Thoeny.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details, published at
http://www.gnu.org/copyleft/gpl.html