package TWiki::Plugins::EmptyPlugin;    # change the package name and $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}!!!
# Plugin for TWiki Collaboration Platform, http://TWiki.org/
#
# Copyright (C) 2000-2003 Andrea Sterbini, a.sterbini@flashnet.it
# Copyright (C) 2001-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
#
# =========================
#
# This is an empty TWiki plugin. Use it as a template
# for your own plugins; see TWiki.TWikiPlugins for details.
#
# Each plugin is a package that may contain these functions:        VERSION:
#
#   earlyInitPlugin         ( )                                     1.020
#   $config->{TWiki}->{Plugins}->{EmptyPlugin}->initPlugin ( $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{user}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{installWeb} )    1.000
#   initializeUserHandler   ( $loginName, $url, $pathInfo )         1.010
#   registrationHandler     ( $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}, $wikiName, $loginName )         1.010
#   beforeCommonTagsHandler ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} )                 1.024
#   commonTagsHandler       ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} )                 1.000
#   afterCommonTagsHandler  ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} )                 1.024
#   startRenderingHandler   ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} )                         1.000
#   outsidePREHandler       ( $text )                               1.000
#   insidePREHandler        ( $text )                               1.000
#   endRenderingHandler     ( $text )                               1.000
#   beforeEditHandler       ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} )                 1.010
#   afterEditHandler        ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} )                 1.010
#   beforeSaveHandler       ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} )                 1.010
#   afterSaveHandler        ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}, $errors )        1.020
#   writeHeaderHandler      ( $query )                              1.010  Use only in one Plugin
#   redirectCgiQueryHandler ( $query, $url )                        1.010  Use only in one Plugin
#   getSessionValueHandler  ( $key )                                1.010  Use only in one Plugin
#   setSessionValueHandler  ( $key, $value )                        1.010  Use only in one Plugin
#
# initPlugin is required, all other are optional. 
# For increased performance, all handlers except initPlugin are
# disabled. To enable a handler remove the leading DISABLE_ from
# the function name. Remove disabled handlers you do not need.
#
# NOTE: To interact with TWiki use the official TWiki functions 
# in the TWiki::Func module. Do not reference any functions or
# variables elsewhere in TWiki!!


# =========================

# =========================

sub new { 
	my $dummy = shift;
	my $config = shift;
	unshift @_,$dummy ;

   my ( $proto ) =@_ ;
   my $class = ref($proto) || $proto ;
   my $self;

	$self->{config}=$config;
   bless ( $self );

	$self->init_config();

   return $self ;
}



sub init_config { 

   my $self = shift;
	my $config = $self->{config} ;


$config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.021';
$config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName} = 'EmptyPlugin';  # Name of this Plugin

}# END of init_config

# =========================
sub initPlugin
{ 
   my $self = shift;
	my $config = $self->{config} ;


 
	 $config->{TWiki}->{Plugins}->{EmptyPlugin}->init_config () ;

    ( $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{user}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{installWeb} ) = @_;

    # check for Plugins.pm versions
    if( $config->{TWiki}->{Plugins}->{VERSION} < 1.021 ) {
        $config->{TWiki}->{Func}->writeWarning ( "Version mismatch between $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName} and Plugins.pm" );
        return 0;
    }

    # Get plugin debug flag
    $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug} = $config->{TWiki}->{Func}->getPluginPreferencesFlag ( "DEBUG" );

    # Get plugin preferences, the variable defined by:          * Set EXAMPLE = ...
    $config->{TWiki}->{Plugins}->{EmptyPlugin}->{exampleCfgVar} = $config->{TWiki}->{Func}->getPluginPreferencesValue ( "EXAMPLE" ) || "default";

    # Plugin correctly initialized
    $config->{TWiki}->{Func}->writeDebug ( "- TWiki::Plugins::$config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::initPlugin( $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}.$config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic} ) is OK" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};
    return 1;
}

# =========================
sub DISABLE_earlyInitPlugin
{ 
   my $self = shift;
	my $config = $self->{config} ;


### Remove DISABLE_ for a plugin that requires early initialization, that is expects to have
### initializeUserHandler called before initPlugin, giving the plugin a chance to set the user
### See SessionPlugin for an example of this.
    return 1;
}


# =========================
sub DISABLE_initializeUserHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $loginName, $url, $pathInfo ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::initializeUserHandler( $_[0], $_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # Allows a plugin to set the username based on cookies. Called by $config->{TWiki}->initialize .
    # Return the user name, or "guest" if not logged in.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_registrationHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}, $wikiName, $loginName ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::registrationHandler( $_[0], $_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # Allows a plugin to set a cookie at time of user registration.
    # Called by the register script.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_beforeCommonTagsHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::beforeCommonTagsHandler( $_[2].$_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # Called at the beginning of $config->{TWiki}->handleCommonTags  (for cache Plugins use only)
}

# =========================
sub DISABLE_commonTagsHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::commonTagsHandler( $_[2].$_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This is the place to define customized tags and variables
    # Called by $config->{TWiki}->handleCommonTags , after %INCLUDE:"..."%

    # do custom extension rule, like for example:
    # $_[0] =~ s/%XYZ%/&handleXyz()/ge;
    # $_[0] =~ s/%XYZ{(.*?)}%/&handleXyz($1)/ge;
}

# =========================
sub DISABLE_afterCommonTagsHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::afterCommonTagsHandler( $_[2].$_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # Called at the end of $config->{TWiki}->handleCommonTags  (for cache Plugins use only)
}

# =========================
sub DISABLE_startRenderingHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} ) = @_;   # do not uncomment, use $_[0], $_[1] instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::startRenderingHandler( $_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by getRenderedVersion just before the line loop

    # do custom extension rule, like for example:
    # $_[0] =~ s/old/new/g;
}

# =========================
sub DISABLE_outsidePREHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text ) = @_;   # do not uncomment, use $_[0] instead

    ##$config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::outsidePREHandler( $renderingWeb.$config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic} )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{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 $self = shift;
	my $config = $self->{config} ;


### my ( $text ) = @_;   # do not uncomment, use $_[0] instead

    ##$config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::insidePREHandler( $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}.$config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic} )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{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 $self = shift;
	my $config = $self->{config} ;


### my ( $text ) = @_;   # do not uncomment, use $_[0] instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::endRenderingHandler( $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}.$config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic} )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{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 $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::beforeEditHandler( $_[2].$_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{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 $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_afterEditHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::afterEditHandler( $_[2].$_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by the preview script just before presenting the text.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_beforeSaveHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web} ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::beforeSaveHandler( $_[2].$_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by $config->{TWiki}->{Store}->saveTopic  just before the save action.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_afterSaveHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $text, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{topic}, $config->{TWiki}->{Plugins}->{EmptyPlugin}->{web}, $error ) = @_;   # do not uncomment, use $_[0], $_[1]... instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::afterSaveHandler( $_[2].$_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by $config->{TWiki}->{Store}->saveTopic  just after the save action.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.020'

}

# =========================
sub DISABLE_writeHeaderHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $query ) = @_;   # do not uncomment, use $_[0] instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::writeHeaderHandler( query )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by $config->{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 $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_redirectCgiQueryHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $query, $url ) = @_;   # do not uncomment, use $_[0], $_[1] instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::redirectCgiQueryHandler( query, $_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by $config->{TWiki}->redirect . Use it to overload TWiki's internal redirect.
    # Use only in one Plugin.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_getSessionValueHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $key ) = @_;   # do not uncomment, use $_[0] instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::getSessionValueHandler( $_[0] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by $config->{TWiki}->getSessionValue . Return the value of a key.
    # Use only in one Plugin.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================
sub DISABLE_setSessionValueHandler
{ 
   my $self = shift;
	my $config = $self->{config} ;


### my ( $key, $value ) = @_;   # do not uncomment, use $_[0], $_[1] instead

    $config->{TWiki}->{Func}->writeDebug ( "- $config->{TWiki}->{Plugins}->{EmptyPlugin}->{pluginName}::setSessionValueHandler( $_[0], $_[1] )" ) if $config->{TWiki}->{Plugins}->{EmptyPlugin}->{debug};

    # This handler is called by $config->{TWiki}->setSessionValue . 
    # Use only in one Plugin.
    # New hook in TWiki::Plugins $config->{TWiki}->{Plugins}->{EmptyPlugin}->{VERSION} = '1.010'

}

# =========================

1;

1;
