1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
# Plugin for TWiki Collaboration Platform, http://TWiki.org/
#
# Copyright (C) 2000-2003 Andrea Sterbini, a.sterbini@flashnet.it
# Copyright (C) 2001-2003 Peter Thoeny, peter@thoeny.com
# Copyright (C) 2005-2018 OpenLink Software
#
# 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
#
# =========================
#
# This is based on an empty TWiki plugin. Use it as a template
# for your own plugins; see TWiki.TWikiPlugins for details.
#
# =========================
package TWiki::Plugins::VirtDocPlugin;
# =========================
use vars qw(
$web $topic $user $installWeb $VERSION $pluginName
$debug $exampleCfgVar
);
$VERSION = '1.010';
$pluginName = 'VirtDocPlugin'; # Name of this Plugin
# =========================
sub initPlugin
{
( $topic, $web, $user, $installWeb ) = @_;
# check for Plugins.pm versions
if( $TWiki::Plugins::VERSION < 1 ) {
TWiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" );
return 0;
}
# Get plugin debug flag
$debug = TWiki::Func::getPreferencesFlag( "\U$pluginName\E_DEBUG" );
# Get plugin preferences, the variable defined by: * Set EXAMPLE = ...
$exampleCfgVar = &TWiki::Prefs::getPreferencesValue( "VirtDocPlugin_EXAMPLE" ) || "default";
# Plugin correctly initialized
TWiki::Func::writeDebug( "- TWiki::Plugins::${pluginName}::initPlugin( $web.$topic ) is OK" ) if $debug;
return 1;
}
# =========================
sub DISABLE_initializeUserHandler
{
### my ( $loginName, $url, $pathInfo ) = @_; # do not uncomment, use $_[0], $_[1]... instead
TWiki::Func::writeDebug( "- ${pluginName}::initializeUserHandler( $_[0], $_[1] )" ) if $debug;
# Allows a plugin to set the username based on cookies. Called by TWiki::initialize.
# Return the user name, or "guest" if not logged in.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub DISABLE_registrationHandler
{
### my ( $web, $wikiName, $loginName ) = @_; # do not uncomment, use $_[0], $_[1]... instead
TWiki::Func::writeDebug( "- ${pluginName}::registrationHandler( $_[0], $_[1] )" ) if $debug;
# Allows a plugin to set a cookie at time of user registration.
# Called by the register script.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub funname2wikiword
{
my $nm = lc($_[0]);
$nm =~ s/[_.-]([^_.-])/"\u$1"/ge;
substr ($nm, 0, 1) = uc (substr ($nm, 0, 1));
# $_[0] =~ s/[_.-]([^_.-])/$_[0]/ge
return "{" . $nm . "}";
}
sub commonTagsHandler
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead
TWiki::Func::writeDebug( "- ${pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $debug;
# This is the place to define customized tags and variables
# Called by sub handleCommonTags, after %INCLUDE:"..."%
# do custom extension rule, like for example:
# $_[0] =~ s/%XYZ%/&handleXyz()/ge;
# $_[0] =~ s/%XYZ{(.*?)}%/&handleXyz($1)/ge;
$_[0] =~ s/%SF{[""]([^""\s()]+)([\s()]*)[""]}%/ "[[Fn" . funname2wikiword($1) . "][" . $1 . $2 . "]]" /ge;
$_[0] =~ s/%SF{[""]([^""\s()]+)([\s()]*)[""]\s+linkend=[""]([A-Za-z0-9-_]+)[""]}%/[[$3][$1$2]]/g;
$_[0] =~ s/%XF{[""]([^""\s()]+)([\s()]*)[""]}%/ "[[Xpf" . funname2wikiword($1) . "][" . $1 . $2 . "]]" /ge;
$_[0] =~ s/%XF{[""]([^""\s()]+)([\s()]*)[""]\s+linkend=[""]([A-Za-z0-9-_]+)[""]}%/[[$3][$1$2]]/g;
}
# =========================
sub DISABLE_startRenderingHandler
{
### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead
TWiki::Func::writeDebug( "- ${pluginName}::startRenderingHandler( $_[1] )" ) if $debug;
# This handler is called by getRenderedVersion just before the line loop
# do custom extension rule, like for example:
# $_[0] =~ s/%XYZ%/&handleXyz()/ge;
# $_[0] =~ s/%XYZ{(.*?)}%/&handleXyz($1)/ge;
}
# =========================
sub DISABLE_outsidePREHandler
{
### my ( $text ) = @_; # do not uncomment, use $_[0] instead
##TWiki::Func::writeDebug( "- ${pluginName}::outsidePREHandler( $renderingWeb.$topic )" ) if $debug;
# This handler is called by getRenderedVersion, once per line, before any changes,
# for lines outside <pre> and <verbatim> tags.
# Use it to define customized rendering rules.
# Note: This is an expensive function to comment out.
# Consider startRenderingHandler instead
# do custom extension rule, like for example:
# $_[0] =~ s/old/new/g;
}
# =========================
sub DISABLE_insidePREHandler
{
### my ( $text ) = @_; # do not uncomment, use $_[0] instead
##TWiki::Func::writeDebug( "- ${pluginName}::insidePREHandler( $web.$topic )" ) if $debug;
# This handler is called by getRenderedVersion, once per line, before any changes,
# for lines inside <pre> and <verbatim> tags.
# Use it to define customized rendering rules.
# Note: This is an expensive function to comment out.
# Consider startRenderingHandler instead
# do custom extension rule, like for example:
# $_[0] =~ s/old/new/g;
}
# =========================
sub DISABLE_endRenderingHandler
{
### my ( $text ) = @_; # do not uncomment, use $_[0] instead
TWiki::Func::writeDebug( "- ${pluginName}::endRenderingHandler( $web.$topic )" ) if $debug;
# This handler is called by getRenderedVersion just after the line loop, that is,
# after almost all XHTML rendering of a topic. <nop> tags are removed after this.
}
# =========================
sub DISABLE_beforeEditHandler
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead
TWiki::Func::writeDebug( "- ${pluginName}::beforeEditHandler( $_[2].$_[1] )" ) if $debug;
# This handler is called by the edit script just before presenting the edit text
# in the edit box. Use it to process the text before editing.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub DISABLE_afterEditHandler
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead
TWiki::Func::writeDebug( "- ${pluginName}::afterEditHandler( $_[2].$_[1] )" ) if $debug;
# This handler is called by the preview script just before presenting the text.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub DISABLE_beforeSaveHandler
{
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead
TWiki::Func::writeDebug( "- ${pluginName}::beforeSaveHandler( $_[2].$_[1] )" ) if $debug;
# This handler is called by TWiki::Store::saveTopic just before the save action.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub DISABLE_writeHeaderHandler
{
### my ( $query ) = @_; # do not uncomment, use $_[0] instead
TWiki::Func::writeDebug( "- ${pluginName}::writeHeaderHandler( query )" ) if $debug;
# This handler is called by TWiki::writeHeader, just prior to writing header.
# Return a single result: A string containing HTTP headers, delimited by CR/LF
# and with no blank lines. Plugin generated headers may be modified by core
# code before they are output, to fix bugs or manage caching. Plugins should no
# longer write headers to standard output.
# Use only in one Plugin.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub DISABLE_redirectCgiQueryHandler
{
### my ( $query, $url ) = @_; # do not uncomment, use $_[0], $_[1] instead
TWiki::Func::writeDebug( "- ${pluginName}::redirectCgiQueryHandler( query, $_[1] )" ) if $debug;
# This handler is called by TWiki::redirect. Use it to overload TWiki's internal redirect.
# Use only in one Plugin.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub DISABLE_getSessionValueHandler
{
### my ( $key ) = @_; # do not uncomment, use $_[0] instead
TWiki::Func::writeDebug( "- ${pluginName}::getSessionValueHandler( $_[0] )" ) if $debug;
# This handler is called by TWiki::getSessionValue. Return the value of a key.
# Use only in one Plugin.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
sub DISABLE_setSessionValueHandler
{
### my ( $key, $value ) = @_; # do not uncomment, use $_[0], $_[1] instead
TWiki::Func::writeDebug( "- ${pluginName}::setSessionValueHandler( $_[0], $_[1] )" ) if $debug;
# This handler is called by TWiki::setSessionValue.
# Use only in one Plugin.
# New hook in TWiki::Plugins $VERSION = '1.010'
}
# =========================
1;
|