1
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
3
# Copyright (C) 2001-2007 Peter Thoeny, peter@thoeny.org
4
# Copyright (C) 2008-2009 Foswiki Contributors
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version. For
10
# more details read LICENSE in the root of this distribution.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details, published at
16
# http://www.gnu.org/copyleft/gpl.html
18
# As per the GPL, removal of this notice is prohibited.
20
# =========================
22
# This is Foswiki's Spreadsheet Plugin.
25
package Foswiki::Plugins::SpreadSheetPlugin;
28
# =========================
30
$web $topic $user $installWeb $debug $skipInclude $doInit
33
our $VERSION = '$Rev: 3890 (2009-05-11) $';
34
our $RELEASE = '11 May 2009';
35
our $NO_PREFS_IN_TOPIC = 1;
36
our $SHORTDESCRIPTION = 'Add spreadsheet calculations like "$SUM($ABOVE())" to Foswiki tables and other topic text';
40
# =========================
43
( $topic, $web, $user, $installWeb ) = @_;
45
# check for Plugins.pm versions
46
if( $Foswiki::Plugins::VERSION < 1 ) {
47
Foswiki::Func::writeWarning( "Version mismatch between SpreadSheetPlugin and Plugins.pm" );
51
# Get plugin debug flag
52
$debug = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_DEBUG" ) || 0;
54
# Flag to skip calc if in include
55
$skipInclude = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_SKIPINCLUDE" ) || 1;
57
# Plugin correctly initialized
58
Foswiki::Func::writeDebug( "- Foswiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" ) if $debug;
63
# =========================
66
### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead
68
Foswiki::Func::writeDebug( "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )" ) if $debug;
70
if( ( $_[3] ) && ( $skipInclude ) ) {
71
# bail out, handler called from an %INCLUDE{}%
74
unless( $_[0] =~ /%CALC\{.*?\}%/ ) {
79
require Foswiki::Plugins::SpreadSheetPlugin::Calc;
83
Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web, $topic, $debug );
85
Foswiki::Plugins::SpreadSheetPlugin::Calc::CALC( @_ );