Difference: TWikiFuncDotPm (11 vs. 12)

Revision 122011-08-21 - TWikiContributor

Line: 697 to 697
 Since: TWiki::Plugins::VERSION 1.000 (14 Jul 2001)
Added:
>
>

isValidWebName( $name, $templateWeb ) -> $boolean

Check for a valid web name.

  • $name - web name
  • $templateWeb - flag, optional. If true, then template web names (starting with _) are considered valid, otherwise only user web names are valid.
Return: true if web name is valid

If $TWiki::cfg{EnableHierarchicalWebs} is off, it will also return false when a nested web name is passed to it.

Since: TWiki::Plugins::VERSION 1.4

 

createWeb( $newWeb, $baseWeb, $opts )

Line: 794 to 808
 

topicExists( $web, $topic ) -> $boolean

Changed:
<
<
Test if topic exists
>
>
Test if topic exists.
 
  • $web - Web name, optional, e.g. 'Main'.
  • $topic - Topic name, required, e.g. 'TokyoOffice', or "Main.TokyoOffice"
Line: 805 to 819
 Since: TWiki::Plugins::VERSION 1.000 (14 Jul 2001)
Added:
>
>

isValidTopicName( $name ) -> $boolean

Check for a valid topic name. Names considerd valid for autolinking are WikiWords (such as 'SanFrancisco') and acronym (such as 'SWMBO').

  • $name - topic name
Return: true if topic name is valid

Since: TWiki::Plugins::VERSION 1.4

 

checkTopicEditLock( $web, $topic, $script ) -> ( $oopsUrl, $loginName, $unlockTime )

Line: 851 to 875
  Since: TWiki::Plugins::VERSION 1.000 (29 Jul 2001)
Changed:
<
<
For example,
>
>
Example:
 
Changed:
<
<
my( $meta, $text ) = TWiki::Func::readTopic( $web, $topic ) $text =~ s/APPLE/ORANGE/g; TWiki::Func::saveTopic( $web, $topic, $meta, $text, { forcenewrevision => 1 } );
>
>
# read topic: my( $topicMeta, $topicText ) = TWiki::Func::readTopic( $web, $topic ) # example to change topic text: $topicText =~ s/APPLE/ORANGE/g; # example to change TWiki form field: my $field = $topicMeta->get( 'FIELD', 'Title' ); if( $field ) { $field->{value} = $newTitle; $topicMeta->putKeyed( 'FIELD', $field ); } # save updated topic: TWiki::Func::saveTopic( $web, $topic, $topicMeta, $topicText, { forcenewrevision => 1 } );
 

Note: Plugins handlers ( e.g. beforeSaveHandler ) will be called as

Line: 978 to 1011
 checkAccessPermission to ensure the current user has read access to the topic.
Added:
>
>
See usage example at TWiki::Func::saveTopic.
 Since: TWiki::Plugins::VERSION 1.000 (7 Dec 2002)
Line: 1369 to 1404
 
  • \%params - a reference to a TWiki::Attrs object containing parameters. This can be used as a simple hash that maps parameter names to values, with _DEFAULT being the name for the default parameter.
  • $topic - name of the topic in the query
  • $web - name of the web in the query
Added:
>
>
  • $meta - topic meta-data to use while expanding, can be undef (Since TWiki::Plugins::VERSION 1.4)
  • $textRef - reference to unexpanded topic text, can be undef (Since TWiki::Plugins::VERSION 1.4)
 for example, to execute an arbitrary command on the server, you might do this:
sub initPlugin{
Line: 1384 to 1421
  my $result = `$cmd 2>&1`; return $params->{silent} ? '' : $result; }
Deleted:
<
<
}
  would let you do this: %EXEC{"ps -Af" silent="on"}%
Line: 1677 to 1713
 Since: TWiki::Plugins::VERSION 1.020 (16 Feb 2004)
Added:
>
>

writeLog( $action, $extra, $web, $topic, $user )

Write the log for an event to the logfile.

  • $action - name of the event, such as 'blacklist'.
  • $extra - arbitrary extra information to add to the event.
  • $web - web name, optional. Base web is taken if empty. Ignored if web is specified in $topic.
  • $topic - topic name, optional. Can be Topic or Web.Topic. Base topic is taken if empty.
  • $user - WikiName of user, optional. Name of logged-in user is taken if not specified.
Return: none

Since: TWiki::Plugins::VERSION 1.4

Example: Calling TWiki::Func::writeLog( 'blacklist', 'Magic number is missing' ) will add a log entry like this:

| 2011-01-19 - 01:13 | guest | blacklist | TWiki.TWikiRegistration | Magic number is missing | 1.2.3.4 |

Note: Older plugins that use $TWiki::cfg{LogFileName} or call the internal TWiki function directly should be fixed to use writeLog.

To maintain compatibility with older TWiki releases, you can write conditional code as follows:

  if( defined &TWiki::Func::writeLog ) {
    # use writeLog
    TWiki::Func::writeLog( $web, $topic, 'myevent', $extra );
  } else {
    # deprecated code if plugin is used in older TWiki releases
    $TWiki::Plugins::VERSION > 1.1
      ? $TWiki::Plugins::SESSION->writeLog( 'myevent', "$web.$topic", $extra )
      : TWiki::Store::writeLog( 'myevent', "$web.$topic", $extra );
  }
 

formatTime( $time, $format, $timezone ) -> $text

Line: 1701 to 1772
 If the value is undef, then $default is returned. If $default is not specified it is taken as 0.
Changed:
<
<
Since: $TWiki::Plugins::VERSION 1.2
>
>
Since: TWiki::Plugins::VERSION 1.2
 

Line: 1990 to 2061
 
  • beforeCommonTagsHandler($text, $topic, $web)
  • earlyInitPlugin()

Func.pm

Changed:
<
<
  • afterAttachmentSaveHandler(\%attrHash, $topic, $web, $error)
  • beforeAttachmentSaveHandler(\%attrHash, $topic, $web)
>
>
  • afterAttachmentSaveHandler(\%attrHash, $topic, $web, $error, $meta)
  • beforeAttachmentSaveHandler(\%attrHash, $topic, $web, $meta)
 
  • checkDependencies($moduleName, $dependenciesRef) -> $error
  • extractParameters($attr) -> %params
  • formatTime($time, $format, $timezone) -> $text
Line: 2107 to 2178
 

Func.pm

  • buildWikiWord( $text ) -> $text
Added:
>
>

TWiki-5.1 (Istanbul Release)

$TWiki::Plugins::VERSION 1.4

EmptyPlugin.pm

  • Callback function registered by registerTagHandler has two new parameters $meta and $textRef

Func.pm

  • afterAttachmentSaveHandler(\%attrHash, $topic, $web, $error, $meta) -- added $meta
  • beforeAttachmentSaveHandler(\%attrHash, $topic, $web, $meta) = added =$meta
  • writeLog( $action, $extra, $web, $topic, $user )
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 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.TWikiFuncDotPm.