Summary: EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin.pm 15181 PeterThoeny # Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and TWiki 15181 PeterThoeny # Contributors. EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin/Core.pm 8154 PeterThoeny # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ 3823 CrawfordCurrie # 17719 PeterThoeny # Copyright (C) 2008 Arthur Clemens, arthur@visiblearea.com 15262 ArthurClemens # Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and 15181 PeterThoeny # TWiki Contributors. EditTablePlugin/data/TWiki/EditTablePlugin 17719 PeterThoeny | Plugin Author: | Arthur Clemens, TWiki:Main/PeterThoeny | 17719 PeterThoeny | Copyright: | © 2008 Arthur Clemens, 2002-2008 TWiki:Main.PeterThoeny ([[http://www.twiki.net/][TWIKI.NET]]) and TWiki Contributors | 11392 PeterThoeny | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | The svn that changed the copy right to including TWiki.net r15181 | PeterThoeny | 2007-10-07 11:07:59 +0200 (Sun, 07 Oct 2007) | 1 line Item4182: Add VarEDITTABLE variable documentation -| Plugin Author: | [[http://www.structuredwikis.com/][Peter Thoeny]] | -| Copyright: | © 2002-2006, TWiki:Main.PeterThoeny | +| Plugin Author: | TWiki:Main/PeterThoeny | +| Copyright: | © 2002-2007, TWiki:Main.PeterThoeny ([[http://www.twiki.net/][TWIKI.NET]]) and TWiki Contributors | It can be clearly seen in the information below. Besides the refactoring of text from EditTablePlugin.txt into VarEDITTABLE Peter Thoeny has not been the maintainer of EditTablePlugin for many years. Main contributors have been Arthur Clemens, Crawford Currie, Kenneth Lavrsen, and Byron Darrah. Hardly any of the original source code is left. Original copyright notice did not include linking to TWiki.net. It was added in 2007. Copyright notices in the actual code does not include TWiki.net. The TWiki.net linking was added by Peter Thoeny in 2007 to give higher Google ranking because the plugin is found 1000s of places in the Internet. He is not the only one that has used/abused this fact on twiki.org. When forking to Foswiki we follow the GPL and maintain the original copyright statements. If we fail to get it right we will correct it. In this case the original - from before main maintenance was done by the contributors that are now all in Foswiki - stated © 2002-2006, TWiki:Main.PeterThoeny. The source code says however 2002-2007 The correct is not clear but the most accurate seems to be: Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and TWiki Contributors for this plugin + the new Foswiki copyright. svn blame EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin.pm 8154 PeterThoeny # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ 4756 svenud # 17719 PeterThoeny # Copyright (C) 2008 Arthur Clemens, arthur@visiblearea.com 15181 PeterThoeny # Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and TWiki 15181 PeterThoeny # Contributors. 4756 svenud # 4756 svenud # This program is free software; you can redistribute it and/or 4756 svenud # modify it under the terms of the GNU General Public License 4756 svenud # as published by the Free Software Foundation; either version 2 8154 PeterThoeny # of the License, or (at your option) any later version. For 8154 PeterThoeny # more details read LICENSE in the root of this distribution. 4756 svenud # 4756 svenud # This program is distributed in the hope that it will be useful, 4756 svenud # but WITHOUT ANY WARRANTY; without even the implied warranty of 8154 PeterThoeny # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 4756 svenud # 8154 PeterThoeny # As per the GPL, removal of this notice is prohibited. 4756 svenud # 8154 PeterThoeny # This is the EditTablePlugin used to edit tables in place. 4756 svenud 4756 svenud package TWiki::Plugins::EditTablePlugin; 4756 svenud 15813 ArthurClemens use strict; 15813 ArthurClemens 4756 svenud use vars qw( 15301 ArthurClemens $web $topic $user $VERSION $RELEASE $debug 17530 ArthurClemens $query $usesJavascriptInterface $viewModeHeaderDone $editModeHeaderDone $encodeStart $encodeEnd $prefsInitialized 16544 ArthurClemens %editMode %saveMode $ASSET_URL 15301 ArthurClemens ); 4756 svenud 6827 CrawfordCurrie # This should always be $Rev$ so that TWiki can determine the checked-in 6827 CrawfordCurrie # status of the plugin. It is used by the build automation tools, so 6827 CrawfordCurrie # you should leave it alone. 6758 CrawfordCurrie $VERSION = '$Rev$'; 6827 CrawfordCurrie 6827 CrawfordCurrie # This is a free-form string you can use to "name" your own plugin version. 6827 CrawfordCurrie # It is *not* used by the build automation tools, but is reported as part 6827 CrawfordCurrie # of the version number in PLUGINDESCRIPTIONS. 17719 PeterThoeny $RELEASE = '4.9'; 6827 CrawfordCurrie 5876 CrawfordCurrie $encodeStart = '--EditTableEncodeStart--'; 5876 CrawfordCurrie $encodeEnd = '--EditTableEncodeEnd--'; 16087 ArthurClemens %editMode = ( 'NONE', 0, 'EDIT', 1 ); 16087 ArthurClemens %saveMode = ( 'NONE', 0, 'SAVE', 1, 'SAVEQUIET', 2 ); 16544 ArthurClemens $ASSET_URL = '%PUBURL%/%TWIKIWEB%/EditTablePlugin'; 4756 svenud 5876 CrawfordCurrie sub initPlugin { 11646 PeterThoeny ( $topic, $web, $user ) = @_; 4756 svenud 4756 svenud # check for Plugins.pm versions 15301 ArthurClemens if ( $TWiki::Plugins::VERSION < 1.026 ) { 15301 ArthurClemens TWiki::Func::writeWarning( 15301 ArthurClemens "Version mismatch between EditTablePlugin and Plugins.pm"); 4756 svenud return 0; 4756 svenud } 4756 svenud 5876 CrawfordCurrie $query = TWiki::Func::getCgiQuery(); 15301 ArthurClemens if ( !$query ) { 4756 svenud return 0; 4756 svenud } 4756 svenud 4756 svenud # Get plugin debug flag 15301 ArthurClemens $debug = TWiki::Func::getPreferencesFlag('EDITTABLEPLUGIN_DEBUG'); 15301 ArthurClemens $usesJavascriptInterface = 15301 ArthurClemens TWiki::Func::getPreferencesFlag('EDITTABLEPLUGIN_JAVASCRIPTINTERFACE'); 15262 ArthurClemens $viewModeHeaderDone = 0; 13149 ArthurClemens $editModeHeaderDone = 0; 15301 ArthurClemens $prefsInitialized = 0; 4756 svenud 4756 svenud # Plugin correctly initialized 15301 ArthurClemens TWiki::Func::writeDebug( 15301 ArthurClemens "- TWiki::Plugins::EditTablePlugin::initPlugin( $web.$topic ) is OK") 15301 ArthurClemens if $debug; 4756 svenud 4756 svenud return 1; 4756 svenud } 4756 svenud 16544 ArthurClemens sub beforeCommonTagsHandler { 16544 ArthurClemens return unless $_[0] =~ /%EDIT(TABLE|CELL){(.*)}%/os; 16544 ArthurClemens require TWiki::Plugins::EditTablePlugin::Core; 17719 PeterThoeny TWiki::Plugins::EditTablePlugin::Core::protectVariables( 16544 ArthurClemens $_[0] ); 15813 ArthurClemens } 4756 svenud 16544 ArthurClemens sub commonTagsHandler { 16544 ArthurClemens return unless $_[0] =~ /%EDIT(TABLE|CELL){(.*)}%/os; 15813 ArthurClemens 15813 ArthurClemens addViewModeHeadersToHead(); 5876 CrawfordCurrie require TWiki::Plugins::EditTablePlugin::Core; 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::Core::process( $_[0], $_[1], $_[2], $topic, 16544 ArthurClemens $web ); 4756 svenud } 4756 svenud 5876 CrawfordCurrie sub postRenderingHandler { 5876 CrawfordCurrie $_[0] =~ s/$encodeStart(.*?)$encodeEnd/decodeValue($1)/geos; 4756 svenud } 4756 svenud 5876 CrawfordCurrie sub encodeValue { 4756 svenud 4756 svenud # FIXME: *very* crude encoding to escape Wiki rendering inside form fields 15813 ArthurClemens # also prevents urls to get expanded to links 16544 ArthurClemens $_[0] =~ s/\./%dot%/gos; 16544 ArthurClemens $_[0] =~ s/(.)/\.$1/gos; 4920 maphew 4920 maphew # convert
markup to unicode linebreak character for text areas 16547 ArthurClemens $_[0] =~ s/.<.b.r. .\/.>/ /gos; 16544 ArthurClemens $_[0] = $encodeStart . $_[0] . $encodeEnd; 4756 svenud } 4756 svenud 5876 CrawfordCurrie sub decodeValue { 15301 ArthurClemens my ($theText) = @_; 4756 svenud 4756 svenud $theText =~ s/\.(.)/$1/gos; 4756 svenud $theText =~ s/%dot%/\./gos; 15301 ArthurClemens $theText =~ s/\&([^#a-z])/&$1/go; # escape non-entities 15301 ArthurClemens $theText =~ s//\>/go; # change > to entity 15301 ArthurClemens $theText =~ s/\"/\"/go; # change " to entity 4756 svenud return $theText; 4756 svenud } 4756 svenud 16087 ArthurClemens sub decodeFormatTokens { 16087 ArthurClemens return if ( !$_[0] ); 16523 ArthurClemens $_[0] =~ s/\$n\(\)/\n/gos; # expand '$n()' to new line 16087 ArthurClemens my $alpha = TWiki::Func::getRegularExpression('mixedAlpha'); 16087 ArthurClemens $_[0] =~ s/\$n([^$alpha]|$)/\n$1/gos; # expand '$n' to new line 16087 ArthurClemens $_[0] =~ s/\$nop(\(\))?//gos; # remove filler, useful for nested search 16087 ArthurClemens $_[0] =~ s/\$quot(\(\))?/\"/gos; # expand double quote 16087 ArthurClemens $_[0] =~ s/\$percnt(\(\))?/\%/gos; # expand percent 16087 ArthurClemens $_[0] =~ s/\$dollar(\(\))?/\$/gos; # expand dollar 16087 ArthurClemens } 16087 ArthurClemens 15813 ArthurClemens =pod 15813 ArthurClemens 15813 ArthurClemens Style sheet for table in view mode 15813 ArthurClemens 15813 ArthurClemens =cut 15813 ArthurClemens 15262 ArthurClemens sub addViewModeHeadersToHead { 15262 ArthurClemens return if $viewModeHeaderDone; 15301 ArthurClemens 15262 ArthurClemens $viewModeHeaderDone = 1; 15262 ArthurClemens 15301 ArthurClemens my $header = <<'EOF'; 15262 ArthurClemens 15262 ArthurClemens EOF 15301 ArthurClemens TWiki::Func::addToHEAD( 'EDITTABLEPLUGIN', $header ); 15262 ArthurClemens } 15262 ArthurClemens 15813 ArthurClemens =pod 15813 ArthurClemens 15813 ArthurClemens Style sheet and javascript for table in edit mode 15813 ArthurClemens 15813 ArthurClemens =cut 15813 ArthurClemens 13149 ArthurClemens sub addEditModeHeadersToHead { 16544 ArthurClemens my ( $tableNr, $paramJavascriptInterface ) = @_; 13149 ArthurClemens return if $editModeHeaderDone; 16523 ArthurClemens return 16523 ArthurClemens if !$usesJavascriptInterface && ( $paramJavascriptInterface ne 'on' ); 15301 ArthurClemens 15813 ArthurClemens require TWiki::Contrib::BehaviourContrib; 15813 ArthurClemens TWiki::Contrib::BehaviourContrib::addHEAD(); 15813 ArthurClemens 13149 ArthurClemens $editModeHeaderDone = 1; 13149 ArthurClemens 16544 ArthurClemens my $formName = "edittable$tableNr"; 16544 ArthurClemens my $header = ""; 15301 ArthurClemens $header .= 16544 ArthurClemens ''; 15301 ArthurClemens $header .= "\n" 15301 ArthurClemens . ''; 15301 ArthurClemens $header .= <<'EOF'; 13149 ArthurClemens 16240 KennethLavrsen 13149 ArthurClemens EOF 13149 ArthurClemens 15301 ArthurClemens TWiki::Func::addToHEAD( 'EDITTABLEPLUGIN', $header ); 13149 ArthurClemens } 13149 ArthurClemens 16523 ArthurClemens sub addJavaScriptInterfaceDisabledToHead { 16523 ArthurClemens my ($tableNr) = @_; 16523 ArthurClemens 16523 ArthurClemens my $tableId = "edittable$tableNr"; 16523 ArthurClemens my $header = ""; 16523 ArthurClemens $header .= 16523 ArthurClemens ''; 16544 ArthurClemens $header .= "\n"; 16523 ArthurClemens TWiki::Func::addToHEAD( 'EDITTABLEPLUGIN_NO_JAVASCRIPTINTERFACE', $header ); 16523 ArthurClemens } 16523 ArthurClemens 16544 ArthurClemens sub addHeaderAndFooterCountToHead { 16544 ArthurClemens my ( $headerCount, $footerCount ) = @_; 16544 ArthurClemens my $header = ""; 16544 ArthurClemens $header .= ''; 16544 ArthurClemens $header .= "\n"; 16544 ArthurClemens $header .= ''; 16544 ArthurClemens $header .= "\n"; 16544 ArthurClemens TWiki::Func::addToHEAD( 'EDITTABLEPLUGIN_HEADERFOOTERCOUNT', $header ); 16544 ArthurClemens } 16544 ArthurClemens 4756 svenud 1; svn blame EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin/Core.pm 8154 PeterThoeny # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ 3823 CrawfordCurrie # 17719 PeterThoeny # Copyright (C) 2008 Arthur Clemens, arthur@visiblearea.com 15262 ArthurClemens # Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and 15181 PeterThoeny # TWiki Contributors. 3823 CrawfordCurrie # 3823 CrawfordCurrie # This program is free software; you can redistribute it and/or 3823 CrawfordCurrie # modify it under the terms of the GNU General Public License 3823 CrawfordCurrie # as published by the Free Software Foundation; either version 2 8154 PeterThoeny # of the License, or (at your option) any later version. For 8154 PeterThoeny # more details read LICENSE in the root of this distribution. 3823 CrawfordCurrie # 3823 CrawfordCurrie # This program is distributed in the hope that it will be useful, 3823 CrawfordCurrie # but WITHOUT ANY WARRANTY; without even the implied warranty of 8154 PeterThoeny # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 3823 CrawfordCurrie # 8154 PeterThoeny # As per the GPL, removal of this notice is prohibited. 8154 PeterThoeny # 3823 CrawfordCurrie # This is the EditTablePlugin used to edit tables in place. 8154 PeterThoeny 3823 CrawfordCurrie package TWiki::Plugins::EditTablePlugin::Core; 3823 CrawfordCurrie 3823 CrawfordCurrie use strict; 4680 CrawfordCurrie use Assert; 4680 CrawfordCurrie 3823 CrawfordCurrie use vars qw( 15262 ArthurClemens $preSp %params @format @formatExpanded 16544 ArthurClemens $prefsInitialized $prefCHANGEROWS $prefEDIT_BUTTON $prefSAVE_BUTTON $prefQUIET_SAVE_BUTTON 16544 ArthurClemens $prefADD_ROW_BUTTON $prefDELETE_LAST_ROW_BUTTON $prefCANCEL_BUTTON 16544 ArthurClemens $prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST $prefQUIETSAVE 15262 ArthurClemens $nrCols $encodeStart $encodeEnd $table $query %regex 16098 ArthurClemens $warningMessage 15262 ArthurClemens ); 3823 CrawfordCurrie 17719 PeterThoeny my $RENDER_HACK = "\n\n"; 17719 PeterThoeny my $DEFAULT_FIELD_SIZE = 16; 17719 PeterThoeny my $PLACEHOLDER_BUTTONROW_TOP = 'PLACEHOLDER_BUTTONROW_TOP'; 17719 PeterThoeny my $PLACEHOLDER_BUTTONROW_BOTTOM = 'PLACEHOLDER_BUTTONROW_BOTTOM'; 17719 PeterThoeny my $STUB_VARIABLE = 'E_T_P_NOP'; 15301 ArthurClemens 17719 PeterThoeny my %regex = (); 17719 PeterThoeny $regex{edit_table_plugin} = '%EDITTABLE{(.*?)}%'; 17719 PeterThoeny $regex{table_plugin} = '%TABLE(?:{(.*?)})?%'; 17719 PeterThoeny $regex{table_row_full} = '^(\s*)\|.*\|\s*$'; 17719 PeterThoeny $regex{table_row} = '^(\s*)\|(.*)'; 15820 ArthurClemens 15820 ArthurClemens sub init { 15813 ArthurClemens $preSp = ''; 15813 ArthurClemens %params = (); 15813 ArthurClemens @format = (); 15813 ArthurClemens @formatExpanded = (); 15813 ArthurClemens $prefsInitialized = undef; 15813 ArthurClemens $prefCHANGEROWS = undef; 15813 ArthurClemens $prefEDIT_BUTTON = undef; 15813 ArthurClemens $prefSAVE_BUTTON = undef; 15813 ArthurClemens $prefQUIET_SAVE_BUTTON = undef; 15813 ArthurClemens $prefADD_ROW_BUTTON = undef; 15813 ArthurClemens $prefDELETE_LAST_ROW_BUTTON = undef; 15813 ArthurClemens $prefDELETE_LAST_ROW_BUTTON = undef; 15813 ArthurClemens $prefQUIETSAVE = undef; 15813 ArthurClemens $nrCols = undef; 15813 ArthurClemens $encodeStart = undef; 15813 ArthurClemens $encodeEnd = undef; 15813 ArthurClemens $table = undef; 15813 ArthurClemens $query = undef; 16098 ArthurClemens $warningMessage = ''; 15813 ArthurClemens } 15813 ArthurClemens 17719 PeterThoeny =pod 17719 PeterThoeny 17719 PeterThoeny ---+++ protectVariables ($text) 17719 PeterThoeny 17719 PeterThoeny Called during beforeCommonTagsHandler. 17719 PeterThoeny Escapes variables by placing $STUB_VARIABLE inside each variable. 17719 PeterThoeny This stub is removed later on (inside handleTableRow). 17719 PeterThoeny 17719 PeterThoeny =cut 17719 PeterThoeny 17719 PeterThoeny sub protectVariables { 17719 PeterThoeny 17719 PeterThoeny #my $text = $_[0] 17719 PeterThoeny 16544 ArthurClemens $query = TWiki::Func::getCgiQuery(); 16544 ArthurClemens if ( ( $query->param('etedit') ) && ( $query->param('ettablenr') ) ) { 16544 ArthurClemens my $paramTableNr = $query->param('ettablenr'); 16544 ArthurClemens my $tmptable = TWiki::Plugins::EditTable->new(); 16544 ArthurClemens my ( $tablesTakenOutText, @tableTextRefs ) = 16544 ArthurClemens $tmptable->parseText( $_[0] ); 17719 PeterThoeny my $tableNr = 1; # starting point 16544 ArthurClemens my $tableDone = 0; 16544 ArthurClemens foreach my $tableTextRef (@tableTextRefs) { 16544 ArthurClemens my $tableText = $tableTextRef->{'text'}; 16544 ArthurClemens my $editTableTag = $tableTextRef->{'tag'}; 16544 ArthurClemens if ( !$tableDone && $tableNr eq $paramTableNr ) { 16544 ArthurClemens 17719 PeterThoeny # only do the one table that is being edited 17719 PeterThoeny my $inRe = ' 17719 PeterThoeny % # start of variable 17719 PeterThoeny ( # group at index 1 17719 PeterThoeny .*? # variable name 17719 PeterThoeny \{*.*?\}* # variable contents inside braces, if any 17719 PeterThoeny ) # 17719 PeterThoeny % # end of variable'; 17719 PeterThoeny $tableText =~ s/$inRe/%$STUB_VARIABLE$1%/gox; 17719 PeterThoeny $tableText =~ s/%$STUB_VARIABLE\BR%/ /go 17719 PeterThoeny ; # replace escaped %BR% with newline 17719 PeterThoeny my $tag = 'verbatim'; 17719 PeterThoeny $tableText =~ 17719 PeterThoeny s/\<$tag\>(.*?)\<\/$tag\>/<$STUB_VARIABLE$tag>$1<\/$STUB_VARIABLE$tag>/go 17719 PeterThoeny ; # put stub inside verbatim to prevent the renderer to take out the verbatim block (which is unwanted in edit mode) 17719 PeterThoeny $tableDone = 1; # mark no longer necessary to find other tables 16544 ArthurClemens } 16544 ArthurClemens $tableText = $editTableTag . "\n" . $tableText; 16544 ArthurClemens $tablesTakenOutText =~ s//$tableText\n/; 16544 ArthurClemens $tableNr++; 16544 ArthurClemens } 16544 ArthurClemens $_[0] = $tablesTakenOutText; 16544 ArthurClemens } 16544 ArthurClemens } 16544 ArthurClemens 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens ---+++ process( $doSave, $saveTableNr, $doSaveQuiet, $text, $topic, $web ) 15301 ArthurClemens 15301 ArthurClemens Called from commonTagsHandler. Pass over to processText in 'no Save' mode. 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub process { 15979 ArthurClemens init(); 16087 ArthurClemens my $saveMode = $TWiki::Plugins::EditTablePlugin::saveMode{'NONE'}; 16087 ArthurClemens my $saveTableNr = 0; 16087 ArthurClemens my $saveQuietMode = $TWiki::Plugins::EditTablePlugin::saveMode{'SAVEQUIET'}; 16087 ArthurClemens processText( $saveMode, $saveTableNr, $saveQuietMode, @_ ); 15301 ArthurClemens } 15301 ArthurClemens 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens ---+++ processText( $doSave, $saveTableNr, $doSaveQuiet, $text, $topic, $web ) 15301 ArthurClemens 15301 ArthurClemens Process the text line by line. 15301 ArthurClemens When a EditTablePlugin table is encountered, its contents is rendered according to the view: 15301 ArthurClemens * View mode - default 15301 ArthurClemens * Edit mode - when an Edit button is clicked, renders the rest of the table in edit mode 15301 ArthurClemens * Save mode - when called from a Save button: calls processText again, only renders the selected table number, then saves the topic text 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 15301 ArthurClemens sub processText { 15301 ArthurClemens 16087 ArthurClemens my $doSave = ( shift == $TWiki::Plugins::EditTablePlugin::saveMode{'SAVE'} ) 16087 ArthurClemens || 0; 15301 ArthurClemens my $saveTableNr = shift; 16087 ArthurClemens my $doSaveQuiet = 16087 ArthurClemens ( shift == $TWiki::Plugins::EditTablePlugin::saveMode{'SAVEQUIET'} ) || 0; 15301 ArthurClemens 3823 CrawfordCurrie $query = TWiki::Func::getCgiQuery(); 15301 ArthurClemens 15262 ArthurClemens TWiki::Func::writeDebug( 15262 ArthurClemens "- EditTablePlugin::commonTagsHandler( $_[2].$_[1] )") 15262 ArthurClemens if $TWiki::Plugins::EditTablePlugin::debug; 15301 ArthurClemens 15262 ArthurClemens unless ($prefsInitialized) { 16523 ArthurClemens $prefCHANGEROWS = 16523 ArthurClemens TWiki::Func::getPreferencesValue('CHANGEROWS') 15262 ArthurClemens || TWiki::Func::getPreferencesValue('EDITTABLEPLUGIN_CHANGEROWS') 15262 ArthurClemens || 'on'; 16523 ArthurClemens $prefQUIETSAVE = 16523 ArthurClemens TWiki::Func::getPreferencesValue('QUIETSAVE') 15262 ArthurClemens || TWiki::Func::getPreferencesValue('EDITTABLEPLUGIN_QUIETSAVE') 15262 ArthurClemens || 'on'; 16523 ArthurClemens $prefEDIT_BUTTON = 16523 ArthurClemens TWiki::Func::getPreferencesValue('EDIT_BUTTON') 15340 ArthurClemens || TWiki::Func::getPreferencesValue('EDITTABLEPLUGIN_EDIT_BUTTON') 15262 ArthurClemens || 'Edit table'; 16523 ArthurClemens $prefSAVE_BUTTON = 16523 ArthurClemens TWiki::Func::getPreferencesValue('SAVE_BUTTON') 15340 ArthurClemens || TWiki::Func::getPreferencesValue('EDITTABLEPLUGIN_SAVE_BUTTON') 15340 ArthurClemens || 'Save table'; 15340 ArthurClemens $prefQUIET_SAVE_BUTTON = 15340 ArthurClemens TWiki::Func::getPreferencesValue('QUIET_SAVE_BUTTON') 15340 ArthurClemens || TWiki::Func::getPreferencesValue( 15340 ArthurClemens 'EDITTABLEPLUGIN_QUIET_SAVE_BUTTON') 15340 ArthurClemens || 'Quiet save'; 16523 ArthurClemens $prefADD_ROW_BUTTON = 16523 ArthurClemens TWiki::Func::getPreferencesValue('ADD_ROW_BUTTON') 15340 ArthurClemens || TWiki::Func::getPreferencesValue('EDITTABLEPLUGIN_ADD_ROW_BUTTON') 15340 ArthurClemens || 'Add row'; 15340 ArthurClemens $prefDELETE_LAST_ROW_BUTTON = 15340 ArthurClemens TWiki::Func::getPreferencesValue('DELETE_LAST_ROW_BUTTON') 15340 ArthurClemens || TWiki::Func::getPreferencesValue( 15340 ArthurClemens 'EDITTABLEPLUGIN_DELETE_LAST_ROW_BUTTON') 15340 ArthurClemens || 'Delete last row'; 16523 ArthurClemens $prefCANCEL_BUTTON = 16523 ArthurClemens TWiki::Func::getPreferencesValue('CANCEL_BUTTON') 15340 ArthurClemens || TWiki::Func::getPreferencesValue('EDITTABLEPLUGIN_CANCEL_BUTTON') 15340 ArthurClemens || 'Cancel'; 16098 ArthurClemens $prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST = 16098 ArthurClemens TWiki::Func::getPreferencesValue('INCLUDED_TOPIC_DOES_NOT_EXIST') 16098 ArthurClemens || TWiki::Func::getPreferencesValue( 16098 ArthurClemens 'EDITTABLEPLUGIN_INCLUDED_TOPIC_DOES_NOT_EXIST') 16098 ArthurClemens || 'Warning: \'include\' topic does not exist!'; 15340 ArthurClemens 3823 CrawfordCurrie $prefsInitialized = 1; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15813 ArthurClemens my $theTopic = $query->param('ettabletopic') || $_[1]; 15813 ArthurClemens my $theWeb = $query->param('ettableweb') || $_[2]; 15813 ArthurClemens 16544 ArthurClemens my $paramTableNr = 0; 16544 ArthurClemens my $tableNr = 0; # current EditTable table 16544 ArthurClemens my $isParamTable = 0; 16544 ArthurClemens my $rowNr = 0; # current row number; starting at 1 16544 ArthurClemens my $doEdit = 0; #$doSave; 16544 ArthurClemens my @rows = (); 16544 ArthurClemens my $etrows = -1 15813 ArthurClemens ; # the number of content rows as passed as form parameter: only available on edit or save; -1 if not rendered 15813 ArthurClemens my $etrowsParam; 15813 ArthurClemens my $addedRowCount = 0; 15813 ArthurClemens my $addedRowCountParam = 0; 16544 ArthurClemens my $headerRowCount = 0; 16544 ArthurClemens my $footerRowCount = 0; 15813 ArthurClemens 16544 ArthurClemens # performance: do nothing in view mode if the table is included 16544 ArthurClemens my $webTopic = $theWeb . '.' . $theTopic; 16544 ArthurClemens my $includingTopic = $_[3]; 16544 ArthurClemens my $includingWeb = $_[4]; 16544 ArthurClemens 16544 ArthurClemens my $topicText; 16544 ArthurClemens my $meta; 16544 ArthurClemens my $tablesTakenOutText; 16544 ArthurClemens my @tableTextRefs; 15813 ArthurClemens if ($doSave) { 16544 ArthurClemens ( $meta, $topicText ) = TWiki::Func::readTopic( $theWeb, $theTopic ); 16544 ArthurClemens $table = TWiki::Plugins::EditTable->new(); 16544 ArthurClemens ( $tablesTakenOutText, @tableTextRefs ) = $table->parseText($topicText); 15813 ArthurClemens } 15813 ArthurClemens else { 16544 ArthurClemens $topicText = $_[0]; 16544 ArthurClemens if ( !defined $table ) { 16544 ArthurClemens $table = TWiki::Plugins::EditTable->new(); 16544 ArthurClemens ( $tablesTakenOutText, @tableTextRefs ) = 16544 ArthurClemens $table->parseText($topicText); 16544 ArthurClemens } 15813 ArthurClemens } 15813 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # LOOP THROUGH EXISTING TABLES 16544 ArthurClemens foreach my $tableTextRef (@tableTextRefs) { 15262 ArthurClemens 16544 ArthurClemens my $tableText = $tableTextRef->{'text'}; 16544 ArthurClemens my $editTableTag = $tableTextRef->{'tag'}; 15815 ArthurClemens 16544 ArthurClemens # store processed lines of this tableText 16544 ArthurClemens my @result = (); 15301 ArthurClemens 16544 ArthurClemens $tableNr++; 15301 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # HANDLE EDITTABLE TAG 15301 ArthurClemens 16544 ArthurClemens if ( !$doSave ) { 15301 ArthurClemens 16544 ArthurClemens # process the tag contents 16544 ArthurClemens my $editTablePluginRE = "(.*?)$regex{edit_table_plugin}"; 16544 ArthurClemens $editTableTag =~ 16127 ArthurClemens s/$editTablePluginRE/&handleEditTableTag( $theWeb, $theTopic, $1, $2 )/geo; 16544 ArthurClemens } 15301 ArthurClemens 16544 ArthurClemens if ( $doSave && ( $tableNr != $saveTableNr ) ) { 15301 ArthurClemens 17530 ArthurClemens # nothing (TODO: rewrite this condition...) 16544 ArthurClemens } 16544 ArthurClemens else { 3823 CrawfordCurrie 16544 ArthurClemens $paramTableNr = $query->param('ettablenr') 15813 ArthurClemens || 0; # only on save and edit 15813 ArthurClemens $etrowsParam = $query->param('etrows'); 15813 ArthurClemens $etrows = 15813 ArthurClemens ( defined $etrowsParam ) 15813 ArthurClemens ? $etrowsParam 15813 ArthurClemens : -1; 16544 ArthurClemens 15813 ArthurClemens $addedRowCountParam = $query->param('etaddedrows') || 0; 15813 ArthurClemens $addedRowCount = $addedRowCountParam; 15301 ArthurClemens 16544 ArthurClemens $isParamTable = 0; 15262 ArthurClemens if ( 16544 ArthurClemens ( $paramTableNr == $tableNr ) 15262 ArthurClemens && ( $theWeb . '.' 15262 ArthurClemens . $theTopic eq 15262 ArthurClemens "$TWiki::Plugins::EditTablePlugin::web.$TWiki::Plugins::EditTablePlugin::topic" 15262 ArthurClemens ) 15262 ArthurClemens ) 15262 ArthurClemens { 16544 ArthurClemens $isParamTable = 1; 15301 ArthurClemens if ( !$doSave && $query->param('etsave') ) { 3823 CrawfordCurrie 15262 ArthurClemens # [Save table] button pressed 16087 ArthurClemens my $theSaveMode = 16087 ArthurClemens $TWiki::Plugins::EditTablePlugin::saveMode{'SAVE'}; 16087 ArthurClemens my $theSaveQuietMode = 16087 ArthurClemens $TWiki::Plugins::EditTablePlugin::saveMode{'NONE'}; 16087 ArthurClemens 16087 ArthurClemens return processText( $theSaveMode, $tableNr, 16087 ArthurClemens $theSaveQuietMode, @_ ); 15262 ArthurClemens } 15301 ArthurClemens elsif ( !$doSave && $query->param('etqsave') ) { 3823 CrawfordCurrie 15262 ArthurClemens # [Quiet save] button pressed 16087 ArthurClemens my $theSaveMode = 16087 ArthurClemens $TWiki::Plugins::EditTablePlugin::saveMode{'SAVE'}; 16087 ArthurClemens my $theSaveQuietMode = 16087 ArthurClemens $TWiki::Plugins::EditTablePlugin::saveMode{'SAVEQUIET'}; 16087 ArthurClemens return processText( $theSaveMode, $tableNr, 16087 ArthurClemens $theSaveQuietMode, @_ ); 15262 ArthurClemens } 15262 ArthurClemens elsif ( $query->param('etcancel') ) { 3823 CrawfordCurrie 15262 ArthurClemens # [Cancel] button pressed 15262 ArthurClemens doCancelEdit( $theWeb, $theTopic ); 15262 ArthurClemens ASSERT(0) if DEBUG; 15262 ArthurClemens return; # in case browser does not redirect 15262 ArthurClemens } 15262 ArthurClemens elsif ( $query->param('etaddrow') ) { 15262 ArthurClemens 15262 ArthurClemens # [Add row] button pressed 15813 ArthurClemens $etrows = ( $etrows == -1 ) ? 1 : $etrows + 1; 15813 ArthurClemens $addedRowCount++; 15262 ArthurClemens $doEdit = doEnableEdit( $theWeb, $theTopic, 0 ); 15262 ArthurClemens return unless ($doEdit); 15262 ArthurClemens } 15262 ArthurClemens elsif ( $query->param('etdelrow') ) { 15262 ArthurClemens 15262 ArthurClemens # [Delete row] button pressed 15813 ArthurClemens if ( $etrows > 0 ) { 15813 ArthurClemens $etrows--; 15813 ArthurClemens } 15813 ArthurClemens $addedRowCount--; 15262 ArthurClemens $doEdit = doEnableEdit( $theWeb, $theTopic, 0 ); 15262 ArthurClemens return unless ($doEdit); 15262 ArthurClemens } 15262 ArthurClemens elsif ( $query->param('etedit') ) { 15262 ArthurClemens 15262 ArthurClemens # [Edit table] button pressed 15262 ArthurClemens $doEdit = doEnableEdit( $theWeb, $theTopic, 1 ); 15262 ArthurClemens 15262 ArthurClemens # never return if locked or no permission 15262 ArthurClemens return unless ($doEdit); 15262 ArthurClemens } 3823 CrawfordCurrie } 16523 ArthurClemens } 15262 ArthurClemens 16544 ArthurClemens $doEdit = $isParamTable ? 1 : 0; 16544 ArthurClemens 16544 ArthurClemens # END HANDLE EDITTABLE TAG 16544 ArthurClemens # ======================================== 16544 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # START FOOTER AND HEADER ROW COUNT 16544 ArthurClemens 16544 ArthurClemens if ( $editTableTag =~ m/$regex{table_plugin}/ ) { 16544 ArthurClemens 16544 ArthurClemens # We want this info also when viewing, because the row count takes 16544 ArthurClemens # header and footer rows into account 16544 ArthurClemens 15262 ArthurClemens # match with a TablePlugin line 15813 ArthurClemens # works when TABLE tag is just above OR just below the EDITTABLE tag 15813 ArthurClemens my %tablePluginParams = TWiki::Func::extractParameters($1); 15909 ArthurClemens $headerRowCount = $tablePluginParams{'headerrows'} || 0; 15909 ArthurClemens $footerRowCount = $tablePluginParams{'footerrows'} || 0; 15262 ArthurClemens } 15813 ArthurClemens 16544 ArthurClemens # END FOOTER AND HEADER ROW COUNT 16544 ArthurClemens # ======================================== 16544 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # START FORM 16544 ArthurClemens if ( !$doSave ) { 16544 ArthurClemens my $tableStart = 16544 ArthurClemens handleTableStart( $theWeb, $theTopic, $includingWeb, 16544 ArthurClemens $includingTopic, $tableNr, $doEdit, $headerRowCount, 16544 ArthurClemens $footerRowCount ); 16544 ArthurClemens push( @result, $tableStart ); 15301 ArthurClemens } 15301 ArthurClemens 16544 ArthurClemens # END START FORM 16544 ArthurClemens # ======================================== 16087 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # LOOP THROUGH LINES 16544 ArthurClemens my @lines = split( /\n/, $tableText ); 15393 ArthurClemens 16544 ArthurClemens for (@lines) { 16544 ArthurClemens $rowNr++; 15262 ArthurClemens 15813 ArthurClemens if ( $doEdit || $doSave ) { 15813 ArthurClemens 15813 ArthurClemens # when adding new rows, previously entered values will be mapped onto the new table rows 15813 ArthurClemens # when the last row is not the newly added, as may happen with footer rows, we need to adjust the mapping 15813 ArthurClemens # we introduce a 'rowNr shift' for values 15813 ArthurClemens # we assume that new rows are added just before the footer 16544 ArthurClemens my $shift = 0; 16544 ArthurClemens if ( $footerRowCount > 0 ) { 16544 ArthurClemens my $bodyRowNr = $rowNr - $headerRowCount; 16544 ArthurClemens if ( $bodyRowNr > ( $etrows - $addedRowCount ) ) { 16544 ArthurClemens $shift = $addedRowCountParam; 15813 ArthurClemens } 16544 ArthurClemens } 16544 ArthurClemens my $theRowNr = $rowNr + $shift; 16544 ArthurClemens my $isNewRow = 0; 15813 ArthurClemens s/$regex{table_row}/handleTableRow( $1, $2, $tableNr, $isNewRow, $theRowNr, $doEdit, $doSave, $theWeb, $theTopic )/eo; 16544 ArthurClemens push @rows, $_; 15301 ArthurClemens 16544 ArthurClemens next; 16544 ArthurClemens } # if ( $doEdit || $doSave ) 16544 ArthurClemens # just render the row: EDITCELL and format tokens 16544 ArthurClemens my $isNewRow = 0; 16544 ArthurClemens s/^(\s*)\|(.*)/handleTableRow( $1, $2, $tableNr, $isNewRow, $rowNr, $doEdit, $doSave, $theWeb, $theTopic )/eo; 15301 ArthurClemens 16544 ArthurClemens push( @result, "$_\n" ); 15813 ArthurClemens 16544 ArthurClemens } # for (@lines) 16544 ArthurClemens # END LOOP THROUGH LINES 16544 ArthurClemens # ======================================== 15813 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # WRITE OUT PROCESSED ROWS 16544 ArthurClemens my @bodyRows; 16544 ArthurClemens if ( $doEdit || $doSave ) { 16544 ArthurClemens my @headerRows = (); 16544 ArthurClemens my @footerRows = (); 16544 ArthurClemens @bodyRows = @rows; #clone 15813 ArthurClemens 16544 ArthurClemens if ( $headerRowCount > 0 ) { 16544 ArthurClemens @headerRows = @rows; # clone 16544 ArthurClemens splice @headerRows, $headerRowCount; 15813 ArthurClemens 16544 ArthurClemens # remove the header rows from the body rows 16544 ArthurClemens splice @bodyRows, 0, $headerRowCount; 16544 ArthurClemens } 15813 ArthurClemens 16544 ArthurClemens if ( $footerRowCount > 0 ) { 16544 ArthurClemens @footerRows = @rows; # clone 16544 ArthurClemens splice @footerRows, 0, ( scalar @footerRows - $footerRowCount ); 15813 ArthurClemens 16544 ArthurClemens # remove the footer rows from the body rows 16544 ArthurClemens splice @bodyRows, 16544 ArthurClemens ( scalar @bodyRows - $footerRowCount ), 16544 ArthurClemens $footerRowCount; 16544 ArthurClemens } 15813 ArthurClemens 16544 ArthurClemens # delete rows? 16544 ArthurClemens if ( scalar @bodyRows > ( $etrows - $footerRowCount ) 16544 ArthurClemens && $etrows != -1 ) 16544 ArthurClemens { 16544 ArthurClemens splice( @bodyRows, $etrows ); 16544 ArthurClemens } 15813 ArthurClemens 16544 ArthurClemens # no table at all? 16544 ArthurClemens if ( !$doSave ) { 15813 ArthurClemens 16544 ArthurClemens # if we are starting with an empty table, we force 16544 ArthurClemens # create a row, with an optional header row 16544 ArthurClemens my $addHeader = 16544 ArthurClemens ( $params{'header'} && $headerRowCount == 0 ) 16544 ArthurClemens ? 1 16544 ArthurClemens : 0; 16544 ArthurClemens my $firstRowsCount = 1 + $addHeader; 15813 ArthurClemens 16544 ArthurClemens if ( scalar @bodyRows < $firstRowsCount 16544 ArthurClemens && !$query->param('etdelrow') ) 16544 ArthurClemens { 16544 ArthurClemens if ( $etrows < $firstRowsCount ) { 16544 ArthurClemens $etrows = $firstRowsCount; 15813 ArthurClemens } 16544 ArthurClemens } 16544 ArthurClemens } 15813 ArthurClemens 16544 ArthurClemens # add rows? 16544 ArthurClemens while ( scalar @bodyRows < $etrows ) { 15813 ArthurClemens 16544 ArthurClemens $rowNr++; 16544 ArthurClemens my $newBodyRowNr = scalar @bodyRows + 1; 16544 ArthurClemens my $theRowNr = $newBodyRowNr + $headerRowCount; 15813 ArthurClemens 16544 ArthurClemens my $isNewRow = 16544 ArthurClemens ( defined $etrowsParam && $newBodyRowNr > $etrowsParam ) 16544 ArthurClemens ? 1 16544 ArthurClemens : 0; 15813 ArthurClemens 16544 ArthurClemens my $newRow = handleTableRow( 16544 ArthurClemens '', '', $tableNr, $isNewRow, 16544 ArthurClemens $theRowNr, $doEdit, $doSave, $theWeb, 16544 ArthurClemens $theTopic 16544 ArthurClemens ); 16544 ArthurClemens push @bodyRows, $newRow; 16544 ArthurClemens } 16544 ArthurClemens 16544 ArthurClemens my @combinedRows = ( @headerRows, @bodyRows, @footerRows ); 16544 ArthurClemens 16544 ArthurClemens # after re-ordering, renumber the cells 16544 ArthurClemens my $rowCounter = 0; 16544 ArthurClemens for my $cellRow (@combinedRows) { 16544 ArthurClemens $rowCounter++; 16544 ArthurClemens $cellRow =~ s/(etcell)([0-9]+)(x)([0-9]+)/$1$rowCounter$3$4/go; 16544 ArthurClemens } 16544 ArthurClemens push( @result, join( "\n", @combinedRows ) ); 16544 ArthurClemens if ( $doEdit && !$doSave ) { 16544 ArthurClemens push( @result, "\n" ); # somewhere is a newline too few 16544 ArthurClemens } 15813 ArthurClemens } 15813 ArthurClemens 16544 ArthurClemens # END WRITE OUT PROCESSED ROWS 16544 ArthurClemens # ======================================== 15262 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # FORM END 16544 ArthurClemens my $rowCount = 0; 16544 ArthurClemens if ( !$doSave && !$doEdit ) { 16544 ArthurClemens $rowCount = $rowNr - $headerRowCount - $footerRowCount; 16544 ArthurClemens } 16544 ArthurClemens if ($doEdit) { 16544 ArthurClemens $rowCount = scalar @bodyRows; 16544 ArthurClemens } 16544 ArthurClemens if ( !$doSave ) { 16544 ArthurClemens my $tableEnd = handleTableEnd( 16544 ArthurClemens $theWeb, $theTopic, $includingWeb, 16544 ArthurClemens $includingTopic, $rowCount, $doEdit, 16544 ArthurClemens $headerRowCount, $footerRowCount, $addedRowCount 16544 ArthurClemens ); 16544 ArthurClemens push( @result, $tableEnd ); 16544 ArthurClemens } 16523 ArthurClemens 16544 ArthurClemens # END FORM END 16544 ArthurClemens # ======================================== 16148 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # START PUT PROCESSED TABLE BACK IN TEXT 16544 ArthurClemens my $resultText = join( "", @result ); 17719 PeterThoeny 17719 PeterThoeny # button row at top or bottom 17719 PeterThoeny if ( !$doSave ) { 17719 PeterThoeny my $pos = $params{'buttonrow'} || 'bottom'; 17719 PeterThoeny my $buttonRow = createButtonRow( $theWeb, $theTopic, $includingWeb, 17719 PeterThoeny $includingTopic, $doEdit ); 17719 PeterThoeny if ( $pos eq 'top' ) { 17719 PeterThoeny $resultText =~ s/$PLACEHOLDER_BUTTONROW_BOTTOM//go; # remove 17719 PeterThoeny $resultText =~ s/$PLACEHOLDER_BUTTONROW_TOP/$buttonRow/go; 17719 PeterThoeny } 17719 PeterThoeny else { 17719 PeterThoeny $resultText =~ s/$PLACEHOLDER_BUTTONROW_TOP//go; # remove 17719 PeterThoeny $resultText =~ s/$PLACEHOLDER_BUTTONROW_BOTTOM/$buttonRow/go; 17719 PeterThoeny } 17719 PeterThoeny } 17719 PeterThoeny 16544 ArthurClemens if ( $doEdit && !$doSave && ( $paramTableNr == $tableNr ) ) { 16544 ArthurClemens insertTmpTagInTableTagLine( $editTableTag, 16544 ArthurClemens ' disableallsort="on" ' ); 16544 ArthurClemens } 16544 ArthurClemens else { 16544 ArthurClemens removeTmpTagInTableTagLine($editTableTag); 16544 ArthurClemens } 16544 ArthurClemens $resultText = $editTableTag . "\n" . $resultText; 16544 ArthurClemens $tablesTakenOutText =~ s//$resultText\n/; 16544 ArthurClemens 16544 ArthurClemens # END PUT PROCESSED TABLE BACK IN TEXT 16544 ArthurClemens # ======================================== 16544 ArthurClemens 16544 ArthurClemens # ======================================== 16544 ArthurClemens # START RE-INIT VALUES 16544 ArthurClemens $rowNr = 0; 16544 ArthurClemens $etrows = -1; 16544 ArthurClemens @rows = (); 16544 ArthurClemens @result = (); 16544 ArthurClemens $isParamTable = 0; 16544 ArthurClemens $paramTableNr = 0; 16544 ArthurClemens $headerRowCount = 0; 16544 ArthurClemens $footerRowCount = 0; 16544 ArthurClemens 16544 ArthurClemens # END RE-INIT VALUES 16544 ArthurClemens # ======================================== 16544 ArthurClemens 16544 ArthurClemens } # foreach my $tableText (@tableTexts) { 16544 ArthurClemens 15301 ArthurClemens if ($doSave) { 16523 ArthurClemens my $error = 16544 ArthurClemens TWiki::Func::saveTopic( $theWeb, $theTopic, $meta, 16544 ArthurClemens $tablesTakenOutText, { dontlog => $doSaveQuiet } ); 16544 ArthurClemens 15301 ArthurClemens TWiki::Func::setTopicEditLock( $theWeb, $theTopic, 0 ); # unlock Topic 15301 ArthurClemens my $url = TWiki::Func::getViewUrl( $theWeb, $theTopic ); 15301 ArthurClemens if ($error) { 15301 ArthurClemens $url = TWiki::Func::getOopsUrl( $theWeb, $theTopic, 'oopssaveerr', 15301 ArthurClemens $error ); 15301 ArthurClemens } 15301 ArthurClemens TWiki::Func::redirectCgiQuery( $query, $url ); 15301 ArthurClemens return; 15301 ArthurClemens } 16544 ArthurClemens $_[0] = $tablesTakenOutText; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub extractParams { 15262 ArthurClemens my ( $theArgs, $theHashRef ) = @_; 3823 CrawfordCurrie 16544 ArthurClemens my $tmp; 16544 ArthurClemens 16544 ArthurClemens $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'header' ); 15262 ArthurClemens $$theHashRef{'header'} = $tmp if ($tmp); 3823 CrawfordCurrie 3823 CrawfordCurrie $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'footer' ); 15262 ArthurClemens $$theHashRef{'footer'} = $tmp if ($tmp); 3823 CrawfordCurrie 3823 CrawfordCurrie $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'headerislabel' ); 15262 ArthurClemens $$theHashRef{'headerislabel'} = $tmp if ($tmp); 3823 CrawfordCurrie 3823 CrawfordCurrie $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'format' ); 3823 CrawfordCurrie $tmp =~ s/^\s*\|*\s*//o; 3823 CrawfordCurrie $tmp =~ s/\s*\|*\s*$//o; 15262 ArthurClemens $$theHashRef{'format'} = $tmp if ($tmp); 3823 CrawfordCurrie 3823 CrawfordCurrie $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'changerows' ); 15262 ArthurClemens $$theHashRef{'changerows'} = $tmp if ($tmp); 3823 CrawfordCurrie 3823 CrawfordCurrie $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'quietsave' ); 15262 ArthurClemens $$theHashRef{'quietsave'} = $tmp if ($tmp); 3823 CrawfordCurrie 3823 CrawfordCurrie $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'helptopic' ); 15262 ArthurClemens $$theHashRef{'helptopic'} = $tmp if ($tmp); 3823 CrawfordCurrie 3823 CrawfordCurrie $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'editbutton' ); 15262 ArthurClemens $$theHashRef{'editbutton'} = $tmp if ($tmp); 3823 CrawfordCurrie 16523 ArthurClemens $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'javascriptinterface' ); 16523 ArthurClemens $$theHashRef{'javascriptinterface'} = $tmp if ($tmp); 16523 ArthurClemens 17719 PeterThoeny $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'buttonrow' ); 17719 PeterThoeny $$theHashRef{'buttonrow'} = $tmp if ($tmp); 17719 PeterThoeny 3823 CrawfordCurrie return; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub parseFormat { 15262 ArthurClemens my ( $theFormat, $theTopic, $theWeb, $doExpand ) = @_; 15354 ArthurClemens 16544 ArthurClemens $theFormat =~ s/\$nop(\(\))?//gos; # remove filler 16544 ArthurClemens $theFormat =~ s/\$quot(\(\))?/\"/gos; # expand double quote 16544 ArthurClemens $theFormat =~ s/\$percnt(\(\))?/\%/gos; # expand percent 16544 ArthurClemens $theFormat =~ s/\$dollar(\(\))?/\$/gos; # expand dollar 16087 ArthurClemens 15262 ArthurClemens if ($doExpand) { 3823 CrawfordCurrie 3823 CrawfordCurrie # expanded form to be able to use %-vars in format 3823 CrawfordCurrie $theFormat =~ s///gos; 15262 ArthurClemens $theFormat = 15262 ArthurClemens TWiki::Func::expandCommonVariables( $theFormat, $theTopic, $theWeb ); 3823 CrawfordCurrie } 16544 ArthurClemens 3823 CrawfordCurrie my @aFormat = split( /\s*\|\s*/, $theFormat ); 15354 ArthurClemens $aFormat[0] = "text,$DEFAULT_FIELD_SIZE" unless @aFormat; 15262 ArthurClemens 3823 CrawfordCurrie return @aFormat; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15354 ArthurClemens =pod 15354 ArthurClemens 15354 ArthurClemens =cut 15354 ArthurClemens 3823 CrawfordCurrie sub handleEditTableTag { 15262 ArthurClemens my ( $theWeb, $theTopic, $thePreSpace, $theArgs ) = @_; 3823 CrawfordCurrie 16544 ArthurClemens my $preSp = $thePreSpace || ''; 15301 ArthurClemens 3823 CrawfordCurrie %params = ( 16523 ArthurClemens 'header' => '', 16523 ArthurClemens 'footer' => '', 16523 ArthurClemens 'headerislabel' => "1", 16523 ArthurClemens 'format' => '', 16523 ArthurClemens 'changerows' => $prefCHANGEROWS, 16523 ArthurClemens 'quietsave' => $prefQUIETSAVE, 16523 ArthurClemens 'helptopic' => '', 16523 ArthurClemens 'editbutton' => '', 16523 ArthurClemens 'javascriptinterface' => '', 17719 PeterThoeny 'buttonrow' => '', 3823 CrawfordCurrie ); 16098 ArthurClemens $warningMessage = ''; 3823 CrawfordCurrie 16098 ArthurClemens # include topic to read definitions 3823 CrawfordCurrie my $iTopic = TWiki::Func::extractNameValuePair( $theArgs, 'include' ); 16098 ArthurClemens my $iTopicExists = 0; 15262 ArthurClemens if ($iTopic) { 15262 ArthurClemens if ( $iTopic =~ /^([^\.]+)\.(.*)$/o ) { 15262 ArthurClemens $theWeb = $1; 15262 ArthurClemens $iTopic = $2; 15262 ArthurClemens } 15262 ArthurClemens 16098 ArthurClemens $iTopicExists = TWiki::Func::topicExists( $theWeb, $iTopic ) 16098 ArthurClemens if $iTopic ne ''; 16098 ArthurClemens if ( $iTopic && !$iTopicExists ) { 16098 ArthurClemens $warningMessage = $prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST; 16098 ArthurClemens } 16098 ArthurClemens if ($iTopicExists) { 16098 ArthurClemens 16098 ArthurClemens my $text = TWiki::Func::readTopicText( $theWeb, $iTopic ); 16098 ArthurClemens $text =~ /$regex{edit_table_plugin}/os; 16098 ArthurClemens if ($1) { 16098 ArthurClemens my $args = $1; 16098 ArthurClemens if ( $theWeb ne $TWiki::Plugins::EditTablePlugin::web 16098 ArthurClemens || $iTopic ne $TWiki::Plugins::EditTablePlugin::topic ) 16098 ArthurClemens { 16098 ArthurClemens 16098 ArthurClemens # expand common vars, unless oneself to prevent recursion 16098 ArthurClemens $args = TWiki::Func::expandCommonVariables( $1, $iTopic, 16098 ArthurClemens $theWeb ); 16098 ArthurClemens } 16098 ArthurClemens extractParams( $args, \%params ); 15262 ArthurClemens } 15262 ArthurClemens } 3823 CrawfordCurrie } 3823 CrawfordCurrie 3823 CrawfordCurrie extractParams( $theArgs, \%params ); 3823 CrawfordCurrie 15813 ArthurClemens # FIXME: should use TWiki::Func::extractParameters 15262 ArthurClemens $params{'header'} = '' if ( $params{header} =~ /^(off|no)$/oi ); 3823 CrawfordCurrie $params{'header'} =~ s/^\s*\|//o; 3823 CrawfordCurrie $params{'header'} =~ s/\|\s*$//o; 15262 ArthurClemens $params{'headerislabel'} = '' 15262 ArthurClemens if ( $params{headerislabel} =~ /^(off|no)$/oi ); 15262 ArthurClemens $params{'footer'} = '' if ( $params{footer} =~ /^(off|no)$/oi ); 3823 CrawfordCurrie $params{'footer'} =~ s/^\s*\|//o; 3823 CrawfordCurrie $params{'footer'} =~ s/\|\s*$//o; 16544 ArthurClemens 15262 ArthurClemens $params{'changerows'} = '' if ( $params{changerows} =~ /^(off|no)$/oi ); 15262 ArthurClemens $params{'quietsave'} = '' if ( $params{quietsave} =~ /^(off|no)$/oi ); 16523 ArthurClemens $params{'javascriptinterface'} = 'off' 16523 ArthurClemens if ( $params{javascriptinterface} =~ /^(off|no)$/oi ); 3823 CrawfordCurrie 15262 ArthurClemens @format = parseFormat( $params{format}, $theTopic, $theWeb, 0 ); 3823 CrawfordCurrie @formatExpanded = parseFormat( $params{format}, $theTopic, $theWeb, 1 ); 15262 ArthurClemens $nrCols = @format; 3823 CrawfordCurrie 15301 ArthurClemens return "$preSp"; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub handleTableStart { 16544 ArthurClemens my ( $theWeb, $theTopic, $includingWeb, $includingTopic, $theTableNr, 16544 ArthurClemens $doEdit, $headerRowCount, $footerRowCount ) 16544 ArthurClemens = @_; 16544 ArthurClemens 15262 ArthurClemens my $viewUrl = TWiki::Func::getScriptUrl( $theWeb, $theTopic, 'viewauth' ) 15262 ArthurClemens . "\#edittable$theTableNr"; 3823 CrawfordCurrie my $text = ''; 15262 ArthurClemens if ($doEdit) { 6634 CrawfordCurrie require TWiki::Contrib::JSCalendarContrib; 15262 ArthurClemens unless ($@) { 15262 ArthurClemens TWiki::Contrib::JSCalendarContrib::addHEAD('twiki'); 6634 CrawfordCurrie } 3823 CrawfordCurrie } 3823 CrawfordCurrie $text .= "$preSp\n" if $doEdit; 16544 ArthurClemens $text .= "$preSp\n" 16544 ArthurClemens if ( "$theWeb.$theTopic" eq "$includingWeb.$includingTopic" ); 7829 ArthurClemens my $cssClass = 'editTable'; 15262 ArthurClemens if ($doEdit) { 15262 ArthurClemens $cssClass .= ' editTableEdit'; 7829 ArthurClemens } 15813 ArthurClemens $text .= "
\n"; 16544 ArthurClemens my $formName = "edittable$theTableNr"; 16544 ArthurClemens $formName .= "\_$includingWeb\_$includingTopic" 16544 ArthurClemens if ( "$theWeb\_$theTopic" ne "$includingWeb\_$includingTopic" ); 15262 ArthurClemens $text .= 16544 ArthurClemens "$preSp
\n"; 17719 PeterThoeny 17719 PeterThoeny $text .= $PLACEHOLDER_BUTTONROW_TOP; 17719 PeterThoeny 15813 ArthurClemens $text .= hiddenField( $preSp, 'ettablenr', $theTableNr, "\n" ); 16523 ArthurClemens $text .= hiddenField( $preSp, 'etedit', 'on', "\n" ) 15262 ArthurClemens unless $doEdit; 16544 ArthurClemens 16544 ArthurClemens # pass to javascript (through META tag vars) how many header rows 16544 ArthurClemens # and footer rows we have 16544 ArthurClemens &TWiki::Plugins::EditTablePlugin::addHeaderAndFooterCountToHead( 16544 ArthurClemens $headerRowCount, $footerRowCount ) 16544 ArthurClemens if ( $doEdit 16544 ArthurClemens && ( "$theWeb.$theTopic" eq "$includingWeb.$includingTopic" ) ); 16544 ArthurClemens 3823 CrawfordCurrie return $text; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15813 ArthurClemens sub hiddenField { 15813 ArthurClemens my ( $prefix, $name, $value, $suffix ) = @_; 15813 ArthurClemens $prefix = defined $prefix ? $prefix : ''; 15813 ArthurClemens $suffix = defined $suffix ? $suffix : ''; 15813 ArthurClemens return 15813 ArthurClemens "$prefix$suffix"; 15813 ArthurClemens } 15813 ArthurClemens 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub handleTableEnd { 16544 ArthurClemens my ( 16544 ArthurClemens $theWeb, $theTopic, $includingWeb, 16544 ArthurClemens $includingTopic, $rowCount, $doEdit, 16544 ArthurClemens $headerRowCount, $footerRowCount, $addedRowCount 16544 ArthurClemens ) = @_; 15813 ArthurClemens my $text = ''; 16544 ArthurClemens $text .= hiddenField( $preSp, 'etrows', $rowCount, "\n" ); 15813 ArthurClemens $text .= hiddenField( $preSp, 'etaddedrows', $addedRowCount, "\n" ) 15813 ArthurClemens if $addedRowCount; 15813 ArthurClemens 17719 PeterThoeny $text .= $PLACEHOLDER_BUTTONROW_BOTTOM; 17719 PeterThoeny 17719 PeterThoeny $text .= "$preSp
\n"; 17719 PeterThoeny $text .= "
"; 17719 PeterThoeny $text .= "
" if $doEdit; 17719 PeterThoeny 17719 PeterThoeny # $text .= "\n"; 17719 PeterThoeny return $text; 17719 PeterThoeny } 17719 PeterThoeny 17719 PeterThoeny =pod 17719 PeterThoeny 17719 PeterThoeny =cut 17719 PeterThoeny 17719 PeterThoeny sub createButtonRow { 17719 PeterThoeny my ( $theWeb, $theTopic, $includingWeb, $includingTopic, $doEdit ) = @_; 17719 PeterThoeny 17719 PeterThoeny my $text = ''; 16544 ArthurClemens if ( $doEdit && ( "$theWeb.$theTopic" eq "$includingWeb.$includingTopic" ) ) 16544 ArthurClemens { 16010 KennethLavrsen 3823 CrawfordCurrie # Edit mode 15262 ArthurClemens $text .= 15340 ArthurClemens "$preSp\n"; 15262 ArthurClemens if ( $params{'quietsave'} ) { 15262 ArthurClemens $text .= 15340 ArthurClemens "$preSp\n"; 3823 CrawfordCurrie } 15262 ArthurClemens if ( $params{'changerows'} ) { 15262 ArthurClemens $text .= 15340 ArthurClemens "$preSp\n"; 15262 ArthurClemens $text .= 15340 ArthurClemens "$preSp\n" 15262 ArthurClemens unless ( $params{'changerows'} =~ /^add$/oi ); 3823 CrawfordCurrie } 15262 ArthurClemens $text .= 15340 ArthurClemens "$preSp\n"; 3823 CrawfordCurrie 15262 ArthurClemens if ( $params{'helptopic'} ) { 15262 ArthurClemens 3823 CrawfordCurrie # read help topic and show below the table 15262 ArthurClemens if ( $params{'helptopic'} =~ /^([^\.]+)\.(.*)$/o ) { 3823 CrawfordCurrie $theWeb = $1; 3823 CrawfordCurrie $params{'helptopic'} = $2; 3823 CrawfordCurrie } 15262 ArthurClemens my $helpText = 15262 ArthurClemens TWiki::Func::readTopicText( $theWeb, $params{'helptopic'} ); 15262 ArthurClemens 15262 ArthurClemens #Strip out the meta data so it won't be displayed. 3823 CrawfordCurrie $helpText =~ s/%META:[A-Za-z0-9]+{.*?}%//g; 15262 ArthurClemens if ($helpText) { 3823 CrawfordCurrie $helpText =~ s/.*?%STARTINCLUDE%//os; 3823 CrawfordCurrie $helpText =~ s/%STOPINCLUDE%.*//os; 3823 CrawfordCurrie $text .= $helpText; 3823 CrawfordCurrie } 3823 CrawfordCurrie } 3823 CrawfordCurrie 15262 ArthurClemens # table specific script 15262 ArthurClemens my $tableNr = $query->param('ettablenr'); 15301 ArthurClemens &TWiki::Plugins::EditTablePlugin::addEditModeHeadersToHead( $tableNr, 16544 ArthurClemens $params{'javascriptinterface'} ); 16523 ArthurClemens &TWiki::Plugins::EditTablePlugin::addJavaScriptInterfaceDisabledToHead( 16523 ArthurClemens $tableNr) 16523 ArthurClemens if ( $params{'javascriptinterface'} eq 'off' ); 16544 ArthurClemens &TWiki::Plugins::EditTablePlugin::addJavaScriptInterfaceDisabledToHead( 16544 ArthurClemens $tableNr) 16544 ArthurClemens if ( $params{'changerows'} eq '' ); 15262 ArthurClemens } 15262 ArthurClemens else { 15301 ArthurClemens $params{editbutton} |= ''; 15262 ArthurClemens 3823 CrawfordCurrie # View mode 15262 ArthurClemens if ( $params{editbutton} eq "hide" ) { 15262 ArthurClemens 3823 CrawfordCurrie # do nothing, button assumed to be in a cell 15262 ArthurClemens } 15262 ArthurClemens else { 15262 ArthurClemens 3823 CrawfordCurrie # Add edit button to end of table 15262 ArthurClemens $text .= 15262 ArthurClemens $preSp . viewEditCell("editbutton, 1, $params{'editbutton'}"); 3823 CrawfordCurrie } 3823 CrawfordCurrie } 3823 CrawfordCurrie return $text; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub parseEditCellFormat { 3823 CrawfordCurrie $_[1] = TWiki::Func::extractNameValuePair( $_[0] ); 3823 CrawfordCurrie return ''; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub viewEditCell { 15262 ArthurClemens my ($theAttr) = @_; 15262 ArthurClemens $theAttr = TWiki::Func::extractNameValuePair($theAttr); 15262 ArthurClemens return '' unless ( $theAttr =~ /^editbutton/ ); 3823 CrawfordCurrie 15262 ArthurClemens $params{editbutton} = 'hide' 15262 ArthurClemens unless ( $params{editbutton} ); # Hide below table edit button 3823 CrawfordCurrie 15262 ArthurClemens my @bits = split( /,\s*/, $theAttr ); 15262 ArthurClemens my $value = ''; 15262 ArthurClemens $value = $bits[2] if ( @bits > 2 ); 15262 ArthurClemens my $img = ''; 15262 ArthurClemens $img = $bits[3] if ( @bits > 3 ); 3823 CrawfordCurrie 15262 ArthurClemens unless ($value) { 15340 ArthurClemens $value = $prefEDIT_BUTTON || ''; 15301 ArthurClemens $img = ''; 15262 ArthurClemens if ( $value =~ s/(.+),\s*(.+)/$1/o ) { 3823 CrawfordCurrie $img = $2; 15561 AndreUlrich $img =~ s|%ATTACHURL%|%PUBURL%/%TWIKIWEB%/EditTablePlugin|o; 15561 AndreUlrich $img =~ s|%WEB%|%TWIKIWEB%|o; 3823 CrawfordCurrie } 3823 CrawfordCurrie } 15262 ArthurClemens if ($img) { 15262 ArthurClemens return 16098 ArthurClemens " $warningMessage"; 3823 CrawfordCurrie } 15262 ArthurClemens else { 15262 ArthurClemens return 16098 ArthurClemens " $warningMessage"; 15262 ArthurClemens } 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub saveEditCellFormat { 3823 CrawfordCurrie my ( $theFormat, $theName ) = @_; 15262 ArthurClemens return '' unless ($theFormat); 3823 CrawfordCurrie $theName =~ s/cell/format/; 15813 ArthurClemens return hiddenField( '', $theName, $theFormat, '' ); 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 16544 ArthurClemens digestedCellValue: properly handle labels whose result may have been moved around by javascript, and therefore no longer correspond to the raw saved table text. 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub inputElement { 3823 CrawfordCurrie my ( $theTableNr, $theRowNr, $theCol, $theName, $theValue, 15262 ArthurClemens $digestedCellValue, $theWeb, $theTopic ) 15262 ArthurClemens = @_; 3823 CrawfordCurrie 14107 ByronDarrah my $rawValue = $theValue; 15262 ArthurClemens my $text = ''; 15262 ArthurClemens my $i = @format - 1; 15262 ArthurClemens $i = $theCol if ( $theCol < $i ); 16087 ArthurClemens 15262 ArthurClemens my @bits = split( /,\s*/, $format[$i] ); 3823 CrawfordCurrie my @bitsExpanded = split( /,\s*/, $formatExpanded[$i] ); 3823 CrawfordCurrie 3823 CrawfordCurrie my $cellFormat = ''; 15262 ArthurClemens $theValue =~ 15262 ArthurClemens s/\s*%EDITCELL{(.*?)}%/&parseEditCellFormat( $1, $cellFormat )/eo; 16165 ArthurClemens 16181 KennethLavrsen # If cell is empty we remove the space to not annoy the user when 16181 KennethLavrsen # he needs to add text to empty cell. 16181 KennethLavrsen $theValue = '' if ( $theValue eq ' ' ); 16523 ArthurClemens 15262 ArthurClemens if ($cellFormat) { 15262 ArthurClemens my @aFormat = parseFormat( $cellFormat, $theTopic, $theWeb, 0 ); 3823 CrawfordCurrie @bits = split( /,\s*/, $aFormat[0] ); 15262 ArthurClemens @aFormat = parseFormat( $cellFormat, $theTopic, $theWeb, 1 ); 3823 CrawfordCurrie @bitsExpanded = split( /,\s*/, $aFormat[0] ); 3823 CrawfordCurrie } 3823 CrawfordCurrie 3823 CrawfordCurrie my $type = 'text'; 3823 CrawfordCurrie $type = $bits[0] if @bits > 0; 15262 ArthurClemens 3823 CrawfordCurrie # a table header is considered a label if read only header flag set 15262 ArthurClemens $type = 'label' 15262 ArthurClemens if ( ( $params{'headerislabel'} ) && ( $theValue =~ /^\s*\*.*\*\s*$/ ) ); 15262 ArthurClemens $type = 'label' if ( $type eq 'editbutton' ); # Hide [Edit table] button 3823 CrawfordCurrie my $size = 0; 3823 CrawfordCurrie $size = $bits[1] if @bits > 1; 15262 ArthurClemens my $val = ''; 3823 CrawfordCurrie my $valExpanded = ''; 15262 ArthurClemens my $sel = ''; 16544 ArthurClemens 15262 ArthurClemens if ( $type eq 'select' ) { 15262 ArthurClemens my $expandedValue = 15262 ArthurClemens TWiki::Func::expandCommonVariables( $theValue, $theTopic, $theWeb ); 3823 CrawfordCurrie $size = 1 if $size < 1; 15301 ArthurClemens $text = 15301 ArthurClemens ""; 3823 CrawfordCurrie $text .= saveEditCellFormat( $cellFormat, $theName ); 3823 CrawfordCurrie 15262 ArthurClemens } 15262 ArthurClemens elsif ( $type eq "radio" ) { 15262 ArthurClemens my $expandedValue = 15262 ArthurClemens &TWiki::Func::expandCommonVariables( $theValue, $theTopic, $theWeb ); 8405 CrawfordCurrie $size = 1 if $size < 1; 8405 CrawfordCurrie my $elements = ( @bits - 2 ); 15262 ArthurClemens my $lines = $elements / $size; 15262 ArthurClemens $lines = ( $lines == int($lines) ) ? $lines : int( $lines + 1 ); 15301 ArthurClemens $text .= "
" 15301 ArthurClemens if ( $lines > 1 ); 8405 CrawfordCurrie $i = 2; 15262 ArthurClemens while ( $i < @bits ) { 15262 ArthurClemens $val = $bits[$i] || ""; 15262 ArthurClemens $valExpanded = $bitsExpanded[$i] || ""; 11392 PeterThoeny $expandedValue =~ s/^\s+//; 11392 PeterThoeny $expandedValue =~ s/\s+$//; 15340 ArthurClemens $valExpanded =~ s/^\s+//; 15340 ArthurClemens $valExpanded =~ s/\s+$//; 16150 ArthurClemens $text .= " 1 ) { 15262 ArthurClemens 15262 ArthurClemens if ( ( $i - 1 ) % $lines ) { 15333 ArthurClemens $text .= "
"; 15262 ArthurClemens } 15262 ArthurClemens elsif ( $i - 1 < $elements ) { 15333 ArthurClemens $text .= "
"; 8405 CrawfordCurrie } 8405 CrawfordCurrie } 8405 CrawfordCurrie $i++; 8405 CrawfordCurrie } 15262 ArthurClemens $text .= "
" if ( $lines > 1 ); 8405 CrawfordCurrie $text .= saveEditCellFormat( $cellFormat, $theName ); 8405 CrawfordCurrie 15262 ArthurClemens } 15262 ArthurClemens elsif ( $type eq "checkbox" ) { 15262 ArthurClemens my $expandedValue = 15262 ArthurClemens &TWiki::Func::expandCommonVariables( $theValue, $theTopic, $theWeb ); 8405 CrawfordCurrie $size = 1 if $size < 1; 8405 CrawfordCurrie my $elements = ( @bits - 2 ); 15262 ArthurClemens my $lines = $elements / $size; 15262 ArthurClemens my $names = "Chkbx:"; 15262 ArthurClemens $lines = ( $lines == int($lines) ) ? $lines : int( $lines + 1 ); 15301 ArthurClemens $text .= "
" 15301 ArthurClemens if ( $lines > 1 ); 8405 CrawfordCurrie $i = 2; 15262 ArthurClemens 15262 ArthurClemens while ( $i < @bits ) { 15262 ArthurClemens $val = $bits[$i] || ""; 15262 ArthurClemens $valExpanded = $bitsExpanded[$i] || ""; 11392 PeterThoeny $expandedValue =~ s/^\s+//; 11392 PeterThoeny $expandedValue =~ s/\s+$//; 15340 ArthurClemens $valExpanded =~ s/^\s+//; 15340 ArthurClemens $valExpanded =~ s/\s+$//; 8405 CrawfordCurrie $names .= " ${theName}x$i"; 15262 ArthurClemens $text .= 15262 ArthurClemens " 1 ) { 15262 ArthurClemens if ( ( $i - 1 ) % $lines ) { 15333 ArthurClemens $text .= "
"; 15262 ArthurClemens } 15262 ArthurClemens elsif ( $i - 1 < $elements ) { 15333 ArthurClemens $text .= "
"; 8405 CrawfordCurrie } 8405 CrawfordCurrie } 8405 CrawfordCurrie $i++; 8405 CrawfordCurrie } 15262 ArthurClemens $text .= "
" if ( $lines > 1 ); 15813 ArthurClemens $text .= hiddenField( $preSp, $theName, $names ); 15813 ArthurClemens $text .= saveEditCellFormat( $cellFormat, $theName, "\n" ); 8405 CrawfordCurrie 15262 ArthurClemens } 15262 ArthurClemens elsif ( $type eq 'row' ) { 3823 CrawfordCurrie $size = $size + $theRowNr; 15262 ArthurClemens $text = 15813 ArthurClemens "" 15813 ArthurClemens . hiddenField( $size, $theName, $size ) 15813 ArthurClemens . ""; 3823 CrawfordCurrie $text .= saveEditCellFormat( $cellFormat, $theName ); 3823 CrawfordCurrie 15262 ArthurClemens } 15262 ArthurClemens elsif ( $type eq 'label' ) { 15262 ArthurClemens 3823 CrawfordCurrie # show label text as is, and add a hidden field with value 3823 CrawfordCurrie my $isHeader = 0; 15262 ArthurClemens $isHeader = 1 if ( $theValue =~ s/^\s*\*(.*)\*\s*$/$1/o ); 3823 CrawfordCurrie $text = $theValue; 3823 CrawfordCurrie 3823 CrawfordCurrie # To optimize things, only in the case where a read-only column is 3823 CrawfordCurrie # being processed (inside of this unless() statement) do we actually 3823 CrawfordCurrie # go out and read the original topic. Thus the reason for the 3823 CrawfordCurrie # following unless() so we only read the topic the first time through. 16544 ArthurClemens 15262 ArthurClemens unless ( defined $table and $digestedCellValue ) { 15262 ArthurClemens 3823 CrawfordCurrie # To deal with the situation where TWiki variables, like 3823 CrawfordCurrie # %CALC%, have already been processed and end up getting saved 3823 CrawfordCurrie # in the table that way (processed), we need to read in the 3823 CrawfordCurrie # topic page in raw format 15262 ArthurClemens my $topicContents = TWiki::Func::readTopicText( 15262 ArthurClemens $TWiki::Plugins::EditTablePlugin::web, 15262 ArthurClemens $TWiki::Plugins::EditTablePlugin::topic 15262 ArthurClemens ); 16544 ArthurClemens $table = TWiki::Plugins::EditTable->new(); 16544 ArthurClemens $table->parseText($topicContents); 3823 CrawfordCurrie } 15262 ArthurClemens my $cell = 15262 ArthurClemens $digestedCellValue 15262 ArthurClemens ? $table->getCell( $theTableNr, $theRowNr - 1, $theCol ) 15262 ArthurClemens : $rawValue; 15262 ArthurClemens $theValue = $cell if ( defined $cell ); # original value from file 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::encodeValue($theValue) 15262 ArthurClemens unless ( $theValue eq '' ); 17542 ArthurClemens 17541 ArthurClemens #$theValue = "\*$theValue\*" if ( $isHeader and $digestedCellValue ); 17541 ArthurClemens $text = "\*$text\*" if ($isHeader); 17530 ArthurClemens $text .= ' ' . hiddenField( $preSp, $theName, $theValue ); 3823 CrawfordCurrie 15262 ArthurClemens } 15262 ArthurClemens elsif ( $type eq 'textarea' ) { 15262 ArthurClemens my ( $rows, $cols ) = split( /x/, $size ); 15340 ArthurClemens 15340 ArthurClemens $rows |= 3 if !defined $rows; 15338 ArthurClemens $cols |= 30 if !defined $cols; 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::encodeValue($theValue) 15262 ArthurClemens unless ( $theValue eq '' ); 15262 ArthurClemens $text .= 15301 ArthurClemens ""; 3823 CrawfordCurrie $text .= saveEditCellFormat( $cellFormat, $theName ); 3823 CrawfordCurrie 15262 ArthurClemens } 15262 ArthurClemens elsif ( $type eq 'date' ) { 3823 CrawfordCurrie my $ifFormat = ''; 15262 ArthurClemens $ifFormat = $bits[3] if ( @bits > 3 ); 11704 CrawfordCurrie $ifFormat ||= $TWiki::cfg{JSCalendarContrib}{format} || '%e %B %Y'; 15262 ArthurClemens $size = 10 if ( !$size || $size < 1 ); 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::encodeValue($theValue) 15262 ArthurClemens unless ( $theValue eq '' ); 6634 CrawfordCurrie $text .= CGI::textfield( 15262 ArthurClemens { 15262 ArthurClemens name => $theName, 15262 ArthurClemens class => 'twikiInputField editTableInput', 15262 ArthurClemens id => 'id' . $theName, 15262 ArthurClemens size => $size, 15262 ArthurClemens value => $theValue, 15262 ArthurClemens override => 1 15262 ArthurClemens } 15262 ArthurClemens ); 3823 CrawfordCurrie $text .= saveEditCellFormat( $cellFormat, $theName ); 6634 CrawfordCurrie eval 'use TWiki::Contrib::JSCalendarContrib'; 15262 ArthurClemens 15262 ArthurClemens unless ($@) { 15301 ArthurClemens $text .= ''; 6634 CrawfordCurrie $text .= CGI::image_button( 15262 ArthurClemens -class => 'editTableCalendarButton', 15262 ArthurClemens -name => 'calendar', 15262 ArthurClemens -onclick => "return showCalendar('id$theName','$ifFormat')", 15262 ArthurClemens -src => TWiki::Func::getPubUrlPath() . '/' 15262 ArthurClemens . TWiki::Func::getTwikiWebname() 15262 ArthurClemens . '/JSCalendarContrib/img.gif', 15262 ArthurClemens -alt => 'Calendar', 15317 ArthurClemens -align => 'middle' 15262 ArthurClemens ); 15301 ArthurClemens $text .= ''; 6634 CrawfordCurrie } 3823 CrawfordCurrie $query->{'jscalendar'} = 1; 15262 ArthurClemens } 15262 ArthurClemens else { # if( $type eq 'text') 15354 ArthurClemens $size = $DEFAULT_FIELD_SIZE if $size < 1; 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::encodeValue($theValue) 15262 ArthurClemens unless ( $theValue eq '' ); 15262 ArthurClemens $text = 15262 ArthurClemens ""; 3823 CrawfordCurrie $text .= saveEditCellFormat( $cellFormat, $theName ); 3823 CrawfordCurrie } 16155 ArthurClemens 16155 ArthurClemens if ( $type ne 'textarea' ) { 16155 ArthurClemens $text =~ 16155 ArthurClemens s/ /
/go; # change unicode linebreak character to
16155 ArthurClemens } 3823 CrawfordCurrie return $text; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub handleTableRow { 15262 ArthurClemens my ( 15301 ArthurClemens $thePre, $theRow, $theTableNr, $isNewRow, $theRowNr, 15262 ArthurClemens $doEdit, $doSave, $theWeb, $theTopic 15262 ArthurClemens ) = @_; 15301 ArthurClemens $thePre |= ''; 3823 CrawfordCurrie my $text = "$thePre\|"; 15262 ArthurClemens if ($doEdit) { 3823 CrawfordCurrie $theRow =~ s/\|\s*$//o; 13142 ByronDarrah my $rowID = $query->param("etrow_id$theRowNr"); 16087 ArthurClemens $rowID = $theRowNr if !defined $rowID; 17542 ArthurClemens my @cells; 17542 ArthurClemens my $isNewRowFromHeader = ( $theRowNr <= 1 ) && ( $params{'header'} ); 17542 ArthurClemens @cells = 17542 ArthurClemens $isNewRowFromHeader 17542 ArthurClemens ? split( /\|/, $params{'header'} ) 17542 ArthurClemens : split( /\|/, $theRow ); 3823 CrawfordCurrie my $tmp = @cells; 15262 ArthurClemens $nrCols = $tmp if ( $tmp > $nrCols ); # expand number of cols 15262 ArthurClemens my $val = ''; 15262 ArthurClemens my $cellFormat = ''; 15262 ArthurClemens my $cell = ''; 15262 ArthurClemens my $digested = 0; 3823 CrawfordCurrie my $cellDefined = 0; 15262 ArthurClemens my $col = 0; 16087 ArthurClemens 15262 ArthurClemens while ( $col < $nrCols ) { 3823 CrawfordCurrie $col += 1; 3823 CrawfordCurrie $cellDefined = 0; 15301 ArthurClemens $val = $isNewRow ? undef : $query->param("etcell${rowID}x$col"); 15262 ArthurClemens if ( $val && $val =~ /^Chkbx: (etcell.*)/ ) { 15262 ArthurClemens 15262 ArthurClemens # Multiple checkboxes, val has format "Chkbx: etcell4x2x2 etcell4x2x3 ..." 8405 CrawfordCurrie my $chkBoxeNames = $1; 15262 ArthurClemens my $chkBoxVals = ""; 15262 ArthurClemens foreach ( split( /\s/, $chkBoxeNames ) ) { 15262 ArthurClemens $val = $query->param($_); 15340 ArthurClemens 15338 ArthurClemens #$chkBoxVals .= "$val," if ( defined $val ); 15338 ArthurClemens if ( defined $val ) { 15340 ArthurClemens 15338 ArthurClemens # make space to expand variables 16150 ArthurClemens $val = addSpaceToBothSides($val); 15338 ArthurClemens $chkBoxVals .= $val . ','; 15338 ArthurClemens } 8405 CrawfordCurrie } 15338 ArthurClemens $chkBoxVals =~ s/,\s*$//; 8405 CrawfordCurrie $val = $chkBoxVals; 8405 CrawfordCurrie } 15262 ArthurClemens $cellFormat = $query->param("etformat${rowID}x$col"); 15262 ArthurClemens $val .= " %EDITCELL{$cellFormat}%" if ($cellFormat); 15262 ArthurClemens if ( defined $val ) { 15262 ArthurClemens 3823 CrawfordCurrie # change any new line character sequences to
16547 ArthurClemens $val =~ s/[\n\r]{2,}?/
/gos; 15262 ArthurClemens 8405 CrawfordCurrie # escape "|" to HTML entity 8405 CrawfordCurrie $val =~ s/\|/\&\#124;/gos; 3823 CrawfordCurrie $cellDefined = 1; 15262 ArthurClemens 3823 CrawfordCurrie # Expand %-vars 3823 CrawfordCurrie $cell = $val; 15262 ArthurClemens } 15262 ArthurClemens elsif ( $col <= @cells ) { 15262 ArthurClemens $cell = $cells[ $col - 1 ]; 15262 ArthurClemens $digested = 1; # Flag that we are using non-raw cell text. 15262 ArthurClemens $cellDefined = 1 if ( length($cell) > 0 ); 16165 ArthurClemens $cell =~ s/^\s*(.+?)\s*$/$1/o 16165 ArthurClemens ; # remove spaces around content, but do not void a cell with just spaces 15262 ArthurClemens } 15262 ArthurClemens else { 3823 CrawfordCurrie $cell = ''; 3823 CrawfordCurrie } 16148 ArthurClemens 16544 ArthurClemens $cell =~ 17719 PeterThoeny s/$STUB_VARIABLE//go; # remove escaping of variables inside cells 16544 ArthurClemens 17542 ArthurClemens if ($isNewRowFromHeader) { 15262 ArthurClemens unless ($cell) { 15262 ArthurClemens if ( $params{'header'} =~ /^on$/i ) { 15262 ArthurClemens if ( ( @format >= $col ) 15262 ArthurClemens && ( $format[ $col - 1 ] =~ /(.*?)\,/ ) ) 15262 ArthurClemens { 3823 CrawfordCurrie $cell = $1; 3823 CrawfordCurrie } 3823 CrawfordCurrie $cell = 'text' unless $cell; 3823 CrawfordCurrie $cell = "*$cell*"; 15262 ArthurClemens } 15262 ArthurClemens else { 3823 CrawfordCurrie my @hCells = split( /\|/, $params{'header'} ); 15262 ArthurClemens $cell = $hCells[ $col - 1 ] if ( @hCells >= $col ); 3823 CrawfordCurrie $cell = "*text*" unless $cell; 3823 CrawfordCurrie } 3823 CrawfordCurrie } 16150 ArthurClemens $cell = addSpaceToBothSides($cell); 3823 CrawfordCurrie $text .= "$cell\|"; 15262 ArthurClemens } 15262 ArthurClemens elsif ($doSave) { 16150 ArthurClemens $cell = addSpaceToBothSides($cell); 16523 ArthurClemens 16523 ArthurClemens # Item5217 Avoid that deleting content of cell creates unwanted span 16181 KennethLavrsen $cell = ' ' if $cell eq ''; 16523 ArthurClemens 16087 ArthurClemens $text .= "$cell\|"; 15262 ArthurClemens } 15262 ArthurClemens else { 15262 ArthurClemens if ( 15262 ArthurClemens ( !$cellDefined ) 15262 ArthurClemens && ( @format >= $col ) 15262 ArthurClemens && ( $format[ $col - 1 ] =~ 15262 ArthurClemens /^\s*(.*?)\,\s*(.*?)\,\s*(.*?)\s*$/ ) 15262 ArthurClemens ) 15262 ArthurClemens { 15262 ArthurClemens 15262 ArthurClemens # default value of "| text, 20, a, b, c |" cell is "a, b, c" 15262 ArthurClemens # default value of '| select, 1, a, b, c |' cell is "a" 15262 ArthurClemens $val = $1; # type 15262 ArthurClemens $cell = $3; 15262 ArthurClemens $cell = '' 15262 ArthurClemens unless ( defined $cell && $cell ne '' ) 15262 ArthurClemens ; # Proper handling of '0' 15262 ArthurClemens $cell =~ s/\,.*$//o 15262 ArthurClemens if ( $val eq 'select' || $val eq 'date' ); 3823 CrawfordCurrie } 16087 ArthurClemens my $element = ''; 16087 ArthurClemens $element = 15262 ArthurClemens inputElement( $theTableNr, $theRowNr, $col - 1, 15262 ArthurClemens "etcell${theRowNr}x$col", $cell, $digested, $theWeb, 16087 ArthurClemens $theTopic ); 16087 ArthurClemens $element = " $element \|"; 16087 ArthurClemens $text .= $element; 3823 CrawfordCurrie } 3823 CrawfordCurrie } 15262 ArthurClemens } 15262 ArthurClemens else { 3823 CrawfordCurrie $theRow =~ s/%EDITCELL{(.*?)}%/viewEditCell($1)/geo; 3823 CrawfordCurrie $text .= $theRow; 3823 CrawfordCurrie } 15354 ArthurClemens 15354 ArthurClemens # render final value in view mode (not edit or save) 16087 ArthurClemens TWiki::Plugins::EditTablePlugin::decodeFormatTokens($text) 16087 ArthurClemens if ( !$doSave && !$doEdit ); 16159 ArthurClemens 16159 ArthurClemens # put one space before linebreak (but not more than one) 16159 ArthurClemens # so TML can get expanded 16159 ArthurClemens $text =~ s/\s*
/
/go; 3823 CrawfordCurrie return $text; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 3823 CrawfordCurrie 16150 ArthurClemens Add one space to both sides of the text to allow TML expansion. 16150 ArthurClemens Convert multiple (existing) spaces to one space. 16150 ArthurClemens 15301 ArthurClemens =cut 3823 CrawfordCurrie 16150 ArthurClemens sub addSpaceToBothSides { 16150 ArthurClemens my ($text) = @_; 16150 ArthurClemens return $text if $text eq ''; 16150 ArthurClemens 16150 ArthurClemens $text = " $text "; 17530 ArthurClemens $text =~ s/^[[:space:]]+/ /; # remove extra spaces 17530 ArthurClemens $text =~ s/[[:space:]]+$/ /; 16150 ArthurClemens return $text; 16150 ArthurClemens } 16150 ArthurClemens 16150 ArthurClemens =pod 16150 ArthurClemens 16150 ArthurClemens =cut 16150 ArthurClemens 3823 CrawfordCurrie sub doCancelEdit { 3823 CrawfordCurrie my ( $theWeb, $theTopic ) = @_; 3823 CrawfordCurrie 15262 ArthurClemens TWiki::Func::writeDebug( 15262 ArthurClemens "- EditTablePlugin::doCancelEdit( $theWeb, $theTopic )") 15262 ArthurClemens if $TWiki::Plugins::EditTablePlugin::debug; 3823 CrawfordCurrie 3823 CrawfordCurrie TWiki::Func::setTopicEditLock( $theWeb, $theTopic, 0 ); 3823 CrawfordCurrie 15262 ArthurClemens TWiki::Func::redirectCgiQuery( $query, 15262 ArthurClemens TWiki::Func::getViewUrl( $theWeb, $theTopic ) ); 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub doEnableEdit { 3823 CrawfordCurrie my ( $theWeb, $theTopic, $doCheckIfLocked ) = @_; 3823 CrawfordCurrie 15262 ArthurClemens TWiki::Func::writeDebug( 15262 ArthurClemens "- EditTablePlugin::doEnableEdit( $theWeb, $theTopic )") 15262 ArthurClemens if $TWiki::Plugins::EditTablePlugin::debug; 3823 CrawfordCurrie 13263 HaraldJoerg my $wikiUserName = TWiki::Func::getWikiName(); 15262 ArthurClemens if ( 15262 ArthurClemens !TWiki::Func::checkAccessPermission( 15262 ArthurClemens 'change', $wikiUserName, undef, $theTopic, $theWeb 15262 ArthurClemens ) 15262 ArthurClemens ) 15262 ArthurClemens { 15262 ArthurClemens 3909 CrawfordCurrie # user has no permission to change the topic 6634 CrawfordCurrie throw TWiki::OopsException( 6634 CrawfordCurrie 'accessdenied', 15262 ArthurClemens def => 'topic_access', 15262 ArthurClemens web => $theWeb, 15262 ArthurClemens topic => $theTopic, 15262 ArthurClemens params => [ 'change', 'denied' ] 15262 ArthurClemens ); 3823 CrawfordCurrie } 3823 CrawfordCurrie 15262 ArthurClemens my $breakLock = $query->param('breaklock') || ''; 15262 ArthurClemens unless ($breakLock) { 15262 ArthurClemens my ( $oopsUrl, $lockUser ) = 15262 ArthurClemens TWiki::Func::checkTopicEditLock( $theWeb, $theTopic, 'view' ); 15262 ArthurClemens if ($oopsUrl) { 15262 ArthurClemens my $loginUser = TWiki::Func::wikiToUserName($wikiUserName); 15262 ArthurClemens if ( $lockUser ne $loginUser ) { 15262 ArthurClemens 15979 ArthurClemens # change the default oopsleaseconflict url 15979 ArthurClemens # use viewauth instead of view 15979 ArthurClemens $oopsUrl =~ s/param4=view/param4=viewauth/; 15979 ArthurClemens 15979 ArthurClemens # add info of the edited table 15979 ArthurClemens my $params = ''; 15979 ArthurClemens $query = TWiki::Func::getCgiQuery(); 15979 ArthurClemens $params .= ';ettablenr=' . $query->param('ettablenr'); 15979 ArthurClemens $params .= ';etedit=on'; 15979 ArthurClemens $oopsUrl =~ s/($|#\w*)/$params/; 15979 ArthurClemens 15262 ArthurClemens # warn user that other person is editing this topic 15262 ArthurClemens TWiki::Func::redirectCgiQuery( $query, $oopsUrl ); 15262 ArthurClemens return 0; 15262 ArthurClemens } 12327 HaraldJoerg } 3823 CrawfordCurrie } 15262 ArthurClemens 11918 ThomasWeigert # We are allowed to edit 3823 CrawfordCurrie TWiki::Func::setTopicEditLock( $theWeb, $theTopic, 1 ); 3823 CrawfordCurrie 3823 CrawfordCurrie return 1; 3823 CrawfordCurrie } 3823 CrawfordCurrie 16544 ArthurClemens sub putTmpTagInTableTagLine { 16544 ArthurClemens $_[0] =~ 16544 ArthurClemens s/(%TABLE{.*?)(}%)/$1 "START_EDITTABLEPLUGIN_TMP_TAG""END_EDITTABLEPLUGIN_TMP_TAG"$2/; 16544 ArthurClemens } 16544 ArthurClemens 16544 ArthurClemens sub insertTmpTagInTableTagLine { 16544 ArthurClemens $_[0] =~ 16544 ArthurClemens s/( "START_EDITTABLEPLUGIN_TMP_TAG")("END_EDITTABLEPLUGIN_TMP_TAG")/$1$_[1]$2/; 16544 ArthurClemens } 16544 ArthurClemens 16544 ArthurClemens sub removeTmpTagInTableTagLine { 16544 ArthurClemens $_[0] =~ 16544 ArthurClemens s/ "START_EDITTABLEPLUGIN_TMP_TAG"(.*?)"END_EDITTABLEPLUGIN_TMP_TAG"//go; 16544 ArthurClemens } 16544 ArthurClemens 16523 ArthurClemens =pod 16523 ArthurClemens 16544 ArthurClemens Helper class parses tables to take out table texts, and stores table cell data. 16523 ArthurClemens 16523 ArthurClemens =cut 16523 ArthurClemens 16544 ArthurClemens package TWiki::Plugins::EditTable; 16523 ArthurClemens 15301 ArthurClemens use vars qw( 15301 ArthurClemens %regex 15301 ArthurClemens ); 15301 ArthurClemens 16544 ArthurClemens BEGIN { 16544 ArthurClemens $regex{edit_table_plugin} = '%EDITTABLE{(.*?)}%'; 16544 ArthurClemens $regex{table_plugin} = '%TABLE(?:{(.*?)})?%'; 16544 ArthurClemens } 16544 ArthurClemens 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub new { 16544 ArthurClemens my ($class) = @_; 3823 CrawfordCurrie my $this = {}; 3823 CrawfordCurrie bless $this, $class; 3823 CrawfordCurrie return $this; 3823 CrawfordCurrie } 3823 CrawfordCurrie 16544 ArthurClemens sub parseText { 16544 ArthurClemens my ( $this, $text ) = @_; 16544 ArthurClemens return $this->_takeOutTables($text); 16544 ArthurClemens } 16544 ArthurClemens 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens TODO: this is currently only used for label tags, so this seams a lot of overhead for such a small thing 15301 ArthurClemens 15301 ArthurClemens The guts of this routine was initially copied from SpreadSheetPlugin.pm 15301 ArthurClemens and were used in the ChartPlugin Table object which this was copied from, 15301 ArthurClemens but this has been modified to support the functionality needed by the 15301 ArthurClemens EditTablePlugin. One major change is to only count and save tables 15301 ArthurClemens following an %EDITTABLE{.*}% tag. 15301 ArthurClemens 15301 ArthurClemens This routine basically returns an array of hashes where each hash 15301 ArthurClemens contains the information for a single table. Thus the first hash in the 15301 ArthurClemens array represents the first table found on the topic page, the second hash 15301 ArthurClemens in the array represents the second table found on the topic page, etc. 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 16544 ArthurClemens sub _takeOutTables { 16544 ArthurClemens my ( $this, $topicText ) = @_; 16544 ArthurClemens 15262 ArthurClemens my $tableNum = 1; # Table number (only count tables with EDITTABLE tag) 15262 ArthurClemens my @tableMatrix; # Currently parsed table. 3823 CrawfordCurrie 16544 ArthurClemens my $inEditTable = 0; # Flag to keep track if in an EDITTABLE table 16544 ArthurClemens my $insidePRE = 0; 16544 ArthurClemens my $insideTABLE = 0; 16544 ArthurClemens my $line = ''; 16544 ArthurClemens my @row = (); 16544 ArthurClemens my @tableLines = (); 16544 ArthurClemens my $editTableTag = ''; 16544 ArthurClemens my $storedTableRow = ''; 3823 CrawfordCurrie 16544 ArthurClemens my $tablesTakenOutText = ''; 16544 ArthurClemens my @tableTexts = (); 3823 CrawfordCurrie 16544 ArthurClemens $topicText =~ 16544 ArthurClemens s/\r//go; # strip out all \r chars (may be pasted into a table cell) 16544 ArthurClemens $topicText =~ s/\\\n//go; # Join lines ending in "\" 16544 ArthurClemens $topicText .= $RENDER_HACK 16544 ArthurClemens ; # appended stuff is a hack to handle EDITTABLE correctly if at end 16544 ArthurClemens 16544 ArthurClemens foreach ( split( /\n/, $topicText ) ) { 16544 ArthurClemens 16544 ArthurClemens my $doCopyLine = 1; 16544 ArthurClemens my $hasEditTableTag = 0; 16544 ArthurClemens 3823 CrawfordCurrie # change state: 4056 CrawfordCurrie m||i && ( $insidePRE = 0 ); 3823 CrawfordCurrie m||i && ( $insidePRE = 0 ); 3823 CrawfordCurrie 15262 ArthurClemens if ( !$insidePRE ) { 16544 ArthurClemens 16544 ArthurClemens if ( /$regex{edit_table_plugin}/ && /$regex{table_plugin}/ ) { 16544 ArthurClemens 16544 ArthurClemens # EDITTABLE and TABLE on one line (order does not matter) 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::Core::putTmpTagInTableTagLine( 16544 ArthurClemens $_); 16544 ArthurClemens $inEditTable = 1; 16544 ArthurClemens $tablesTakenOutText .= ""; 16544 ArthurClemens $doCopyLine = 0; 16544 ArthurClemens $editTableTag .= $_; 16544 ArthurClemens $hasEditTableTag = 1; 16544 ArthurClemens } 16544 ArthurClemens elsif (/$regex{edit_table_plugin}/) { 16544 ArthurClemens 16544 ArthurClemens # only EDITTABLE 16544 ArthurClemens if ( $storedTableRow ne '' ) { 16544 ArthurClemens 16544 ArthurClemens # store the TABLE tag from the previous line together with the current EDITTABLE tag 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::Core::putTmpTagInTableTagLine( 16544 ArthurClemens $storedTableRow); 16544 ArthurClemens $editTableTag .= $storedTableRow . "\n"; 16544 ArthurClemens $storedTableRow = ''; 16544 ArthurClemens } 16544 ArthurClemens $inEditTable = 1; 16544 ArthurClemens $tablesTakenOutText .= ""; 16544 ArthurClemens $doCopyLine = 0; 16544 ArthurClemens $editTableTag .= $_; 16544 ArthurClemens $hasEditTableTag = 1; 16544 ArthurClemens } 16544 ArthurClemens elsif ( $inEditTable && /$regex{table_plugin}/ ) { 16544 ArthurClemens 16544 ArthurClemens # TABLE on the line after EDITTABLE 16544 ArthurClemens # we will include it in the editTableTag 16544 ArthurClemens TWiki::Plugins::EditTablePlugin::Core::putTmpTagInTableTagLine( 16544 ArthurClemens $_); 16544 ArthurClemens $doCopyLine = 0; 16544 ArthurClemens $editTableTag .= "\n" . $_; 16544 ArthurClemens $hasEditTableTag = 1; 16544 ArthurClemens } 16544 ArthurClemens elsif ( !$inEditTable && /$regex{table_plugin}/ ) { 16544 ArthurClemens 16544 ArthurClemens # this might be TABLE on the line before EDITTABLE, but we are not sure 16544 ArthurClemens $storedTableRow = $_; 16544 ArthurClemens $doCopyLine = 0; 16544 ArthurClemens } 16544 ArthurClemens elsif ( $storedTableRow ne '' ) { 16544 ArthurClemens 16544 ArthurClemens # we had stored the TABLE tag, but no EDITTABLE tag was just below it; add it to the text and clear 16544 ArthurClemens $tablesTakenOutText .= $storedTableRow . "\n"; 16544 ArthurClemens $storedTableRow = ''; 16544 ArthurClemens } 16544 ArthurClemens if ( $inEditTable && !$hasEditTableTag ) { 17059 ArthurClemens 15262 ArthurClemens if (/^\s*\|.*\|\s*$/) { 17059 ArthurClemens 16544 ArthurClemens $doCopyLine = 0; 16544 ArthurClemens push( @tableLines, $_ ); 15262 ArthurClemens 3823 CrawfordCurrie # inside | table | 3823 CrawfordCurrie $insideTABLE = 1; 15262 ArthurClemens $line = $_; 15262 ArthurClemens $line =~ s/^(\s*\|)(.*)\|\s*$/$2/o; # Remove starting '|' 15262 ArthurClemens @row = split( /\|/o, $line, -1 ); 15262 ArthurClemens _trim( \@row ); 15262 ArthurClemens push( @tableMatrix, [@row] ); 3823 CrawfordCurrie 15262 ArthurClemens } 15262 ArthurClemens else { 15262 ArthurClemens 3823 CrawfordCurrie # outside | table | 15262 ArthurClemens if ($insideTABLE) { 15262 ArthurClemens 3823 CrawfordCurrie # We were inside a table and are now outside of it so 3823 CrawfordCurrie # save the table info into the Table object. 3823 CrawfordCurrie $insideTABLE = 0; 3823 CrawfordCurrie $inEditTable = 0; 16544 ArthurClemens 15262 ArthurClemens if ( @tableMatrix != 0 ) { 15262 ArthurClemens 3823 CrawfordCurrie # Save the table via its table number 3823 CrawfordCurrie $$this{"TABLE_$tableNum"} = [@tableMatrix]; 3823 CrawfordCurrie } 15262 ArthurClemens undef @tableMatrix; # reset table matrix 3823 CrawfordCurrie } 17059 ArthurClemens else { 17059 ArthurClemens 17059 ArthurClemens # not (or no longer) inside a table 17059 ArthurClemens $doCopyLine = 1; 17059 ArthurClemens $inEditTable = 0; 17059 ArthurClemens } 16544 ArthurClemens my $tableRef; 16544 ArthurClemens $tableRef->{'text'} = join( "\n", @tableLines ); 16544 ArthurClemens $tableRef->{'tag'} = $editTableTag; 16544 ArthurClemens push( @tableTexts, $tableRef ); 16544 ArthurClemens $tableNum++; 16544 ArthurClemens 16544 ArthurClemens @tableLines = (); 16544 ArthurClemens $editTableTag = ''; 3823 CrawfordCurrie } 3823 CrawfordCurrie } 16544 ArthurClemens } # if ( !$insidePRE ) 17059 ArthurClemens 16544 ArthurClemens $tablesTakenOutText .= $_ . "\n" if $doCopyLine; 16544 ArthurClemens } # foreach 16544 ArthurClemens 16544 ArthurClemens # clean up hack that handles EDITTABLE correctly if at end 16544 ArthurClemens $tablesTakenOutText =~ s/($RENDER_HACK)+$//go; 3823 CrawfordCurrie $$this{NUM_TABLES} = $tableNum; 16544 ArthurClemens return ( $tablesTakenOutText, @tableTexts ); 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens Trim any leading and trailing white space and/or '*'. 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub _trim { 3823 CrawfordCurrie my ($totrim) = @_; 3823 CrawfordCurrie for my $element (@$totrim) { 17530 ArthurClemens $element =~ s/^[[:space:]]+//; # Strip leading spaces 17530 ArthurClemens $element =~ s/[[:space:]]+$//; # Strip trailing spaces 3823 CrawfordCurrie } 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens Return the contents of the specified cell 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub getCell { 3823 CrawfordCurrie my ( $this, $tableNum, $row, $column ) = @_; 3823 CrawfordCurrie 15262 ArthurClemens my @selectedTable = $this->getTable($tableNum); 15262 ArthurClemens my $value = $selectedTable[$row][$column]; 3823 CrawfordCurrie return $value; 3823 CrawfordCurrie } 3823 CrawfordCurrie 15301 ArthurClemens =pod 15301 ArthurClemens 15301 ArthurClemens =cut 15301 ArthurClemens 3823 CrawfordCurrie sub getTable { 15262 ArthurClemens my ( $this, $tableNumber ) = @_; 3823 CrawfordCurrie my $table = $$this{"TABLE_$tableNumber"}; 15262 ArthurClemens return @$table if defined($table); 3823 CrawfordCurrie return (); 3823 CrawfordCurrie } 3823 CrawfordCurrie 3823 CrawfordCurrie 1; 17719 PeterThoeny svn blame of EditTablePlugin/data/TWiki/EditTablePlugin 15181 PeterThoeny %META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev$"}% 2895 PeterThoeny ---+!! Edit Table Plugin 2895 PeterThoeny 15813 ArthurClemens Edit TWiki tables in place, using edit fields and drop down boxes, without having to edit the complete topic. 2895 PeterThoeny 15813 ArthurClemens Simply add an *[ Edit table ]* button to an existing table by writing =%EDITTABLE{}%= directly above the table. This can be added to tables that are formatted with TablePlugin: add the =EDITTABLE= variable just above or below the =TABLE= tag. It can also be used without any =TABLE= tag. 15813 ArthurClemens 15813 ArthurClemens Customize entry fields by specifying the format: use a text field, a drop down box, a date field, radio buttons or checkboxes. 15813 ArthurClemens 15813 ArthurClemens Multiple tables per topic are editable, but only one at a time can be edited. 15813 ArthurClemens 2895 PeterThoeny %TOC% 2895 PeterThoeny 2895 PeterThoeny ---++ Per Table Settings 2895 PeterThoeny 15181 PeterThoeny Add a =%EDITTABLE{...}%= variable just before an existing table to make it editable, or add the variable anywhere in a topic to start a new table. 16240 KennethLavrsen %INCLUDE{"%TWIKIWEB%.VarEDITTABLE" section="edittable_attributes"}% 2895 PeterThoeny 16087 ArthurClemens ---+++ Using TWiki Variables in the Format Parameter 2895 PeterThoeny 16544 ArthurClemens By default, variables in =<initial value>= (of text input field) and =<label text>= (of fixed label) get expanded when a new row is added. This can be used for example to add a timestamp to a label. You can escape characters with format tokens if you do not want that. 2895 PeterThoeny 16547 ArthurClemens Any TWiki variable inside a table cell will be preserved. For instance, =%TOPIC%= will not get expanded to the current topic name. 16547 ArthurClemens 16544 ArthurClemens The format tokens are the same as with %TWIKIWEB%.FormattedSearch: 16087 ArthurClemens 16544 ArthurClemens | *Escape:* | *Expands To:* | 16544 ArthurClemens | =$n= or =$n()= | New line. Use =$n()= if followed by alphanumeric character, e.g. write =Foo$n()Bar= instead of =Foo$nBar= | 16544 ArthurClemens | =$nop= or =$nop()= | Is a "no operation". | 16544 ArthurClemens | =$quot= | Double quote (="=) | 16544 ArthurClemens | =$percnt= | Percent sign (=%=) | 16544 ArthurClemens | =$dollar= | Dollar sign (=$=) | 16087 ArthurClemens 16087 ArthurClemens 15813 ArthurClemens #DateField 2895 PeterThoeny ---+++ Date Field Type 2895 PeterThoeny 15813 ArthurClemens Edit Table Calendar Example 2895 PeterThoeny 15813 ArthurClemens The =date= field type allows one to choose a date with a popup calendar. Popup calendar works with all modern browsers. The date picker button is inactive if the browser cannot support the popup calendar or if javascript is disabled. 2895 PeterThoeny 15813 ArthurClemens 2895 PeterThoeny ---++ Per Cell Settings 2895 PeterThoeny 2895 PeterThoeny An individual edit field type can be defined for each table cell. Place an =%EDITCELL{ "type, ..." }%= variable at the end of the cell content. This is useful to override the per column =%EDITTABLE{ format="..." }%= settings, or to create tables with key/value rows. All edit field types of the =format="..."= parameter are supported. For example, to define a text field, type: =| cell content %EDITCELL{ "text, 20" }% |= 2895 PeterThoeny 2895 PeterThoeny It is also possible to place the edit button inside a cell instead of default location below the table. Type =| %EDITCELL{ "editbutton, 1, Edit this table" }% |= to show a button, or =| %EDITCELL{ "editbutton, 1, Edit table, Image-URL" }% |= to show a button image with alternate text. 2895 PeterThoeny 2895 PeterThoeny __Note:__ The =%EDITCELL{ }%=variable cannot be used by itself; place an =%EDITTABLE{ }%=variable at the beginning of a table where you want to use =%EDITCELL{ }%= variables. 2895 PeterThoeny 2895 PeterThoeny ---++ Table Buttons 2895 PeterThoeny 2895 PeterThoeny
13142 ByronDarrah * In page view mode: 15340 ArthurClemens * - turn the table into edit mode 13142 ByronDarrah * In edit mode: 15340 ArthurClemens * - save your changes 15340 ArthurClemens * - save your changes without alerting subscribed WebNotify users 15340 ArthurClemens * - add row to the table (if enabled) 15340 ArthurClemens * - remove last row from the table (if enabled) 15340 ArthurClemens * - cancel without saving and release edit lock 13166 ArthurClemens * - Move a row by clicking this button next to the row to 13142 ByronDarrah be moved, then at a destination. 13166 ArthurClemens * - Deletes the row next to this button. 2895 PeterThoeny
2895 PeterThoeny 2895 PeterThoeny ---++ Examples 2895 PeterThoeny 16087 ArthurClemens Line before table: =%EDITTABLE{ format="| row, -1 | text, 20, init | select, 1, one, two, three, four | radio, 3,:-),:-I,:-( | label, 0, %SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" }%= 16087 ArthurClemens %EDITTABLE{ format="| row, -1 | text, 20, init | select, 1, one, two, three, four | radio, 3,:-),:-I,:-( | label, 0, %SERVERTIME{"$day $mon $year $hour:$min"}% |" changerows="on" }% 8405 CrawfordCurrie |*Nr*|*Text field*|*Drop down*|*Mood*|*Timestamp*| 8405 CrawfordCurrie | 1 | hello table | one | :-) | 26 Jun 2002 12:30 | 8405 CrawfordCurrie | 2 | | two | :-( | 27 Jun 2002 12:40 | 2895 PeterThoeny 8405 CrawfordCurrie %RED% __Note:__ Please do not save this example table! Use TWiki:Sandbox.EditTablePluginTesting if you want to try out this Plugin %ENDCOLOR% 2895 PeterThoeny 2922 PeterThoeny If this plugin is installed you will see an *[ Edit table ]* button above; if you were to click on it (please don't, use TWiki:Sandbox.EditTablePluginTesting for testing) you get this form: 2895 PeterThoeny 15813 ArthurClemens 15813 ArthurClemens
15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 2895 PeterThoeny 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens
Nr Text field Drop down Mood Timestamp
1 smile indifferent frown 26 Jun 2002 12:30
2 smile indifferent frown 27 Jun 2002 12:40
15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens
15813 ArthurClemens 2895 PeterThoeny The following example shows a simple table with key/value rows. The default edit field type for the value column is a text field. This is overloaded by a selector for the Gender, and a date picker for the DOB. This is typically used by TWiki applications where new topics with tables are created based on a template topic. 2895 PeterThoeny 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens
2895 PeterThoeny You type: 15813 ArthurClemens 15813 ArthurClemens You get: 15813 ArthurClemens 15813 ArthurClemens Table in edit mode: 15813 ArthurClemens
15813 ArthurClemens 16544 ArthurClemens %TABLE{"headerrows="1"}% 15813 ArthurClemens %EDITTABLE{ format="| label | text, 40 |" changerows="off" }% 2895 PeterThoeny |*Key*|*Value*| 2895 PeterThoeny | Name: | John Smith | 15813 ArthurClemens | Gender: | M %EDITCELL{select, 1, , F, M}% | 15813 ArthurClemens | DOB: | 1999/12/31 %EDITCELL{date, 10}% | 2895 PeterThoeny | City: | New York | 15813 ArthurClemens 15813 ArthurClemens 15813 ArthurClemens EDITCELL Example in view mode 15813 ArthurClemens 15813 ArthurClemens EDITCELL Example in edit mode 15813 ArthurClemens
2895 PeterThoeny 2895 PeterThoeny ---++ Plugin Settings 2895 PeterThoeny 2895 PeterThoeny Plugin settings are stored as preferences variables. To reference 2895 PeterThoeny a plugin setting write ==%<plugin>_<setting>%==, for example, ==%EDITTABLEPLUGIN_SHORTDESCRIPTION%== 2895 PeterThoeny 16240 KennethLavrsen * One line description, shown in the %TWIKIWEB%.TextFormattingRules topic: 13142 ByronDarrah * Set SHORTDESCRIPTION = Edit TWiki tables using edit fields, date pickers and drop down boxes 2895 PeterThoeny 13142 ByronDarrah * Set DEBUG to 1 to get debug messages in =data/debug.txt=. Default: =0= 13142 ByronDarrah * Set DEBUG = 0 2895 PeterThoeny 16544 ArthurClemens * Set JAVASCRIPTINTERFACE to 1 to be able to directly move and delete row without page refresh. Can be overridden with parameter =javascriptinterface=. 13166 ArthurClemens * Set JAVASCRIPTINTERFACE = 1 13149 ArthurClemens 13142 ByronDarrah * Default for change rows flag: =on=, =off=, =add= 13142 ByronDarrah * Set CHANGEROWS = on 2895 PeterThoeny 13142 ByronDarrah * Default flag for quiet save option: =on= to show the Quiet Save button, =off= to hide 13142 ByronDarrah * Set QUIETSAVE = on 2895 PeterThoeny 15340 ArthurClemens * Default edit button: Specify =button text=, or specify =alternate text, image URL=. Note: Texts inside =%MAKETEXT{}%= are translated into other languages. 15340 ArthurClemens * #Set EDIT_BUTTON = %MAKETEXT{"Edit table"}% 15340 ArthurClemens * Set EDIT_BUTTON = %MAKETEXT{"Edit this table"}%, %ATTACHURL%/edittable.gif 15340 ArthurClemens * Set SAVE_BUTTON = %MAKETEXT{"Save table"}% 15340 ArthurClemens * Set QUIET_SAVE_BUTTON = %MAKETEXT{"Quiet save"}% 15340 ArthurClemens * Set ADD_ROW_BUTTON = %MAKETEXT{"Add row"}% 15340 ArthurClemens * Set DELETE_LAST_ROW_BUTTON = %MAKETEXT{"Delete last row"}% 15340 ArthurClemens * Set CANCEL_BUTTON = %MAKETEXT{"Cancel"}% 16544 ArthurClemens 16098 ArthurClemens * Default help texts 16098 ArthurClemens * Set INCLUDED_TOPIC_DOES_NOT_EXIST = %MAKETEXT{"Warning: 'include' topic does not exist!"}% 16098 ArthurClemens 11704 CrawfordCurrie __Note:__ The Plugin uses base settings like date format, language and style from the JSCalendarContrib. 8405 CrawfordCurrie 2895 PeterThoeny ---++ Limitations and Known Issues 2895 PeterThoeny 13142 ByronDarrah * This Plugin does not support TWiki table formatting like Multi-span cells (e.g. =| ... ||=) and cell justification (e.g. =| centered | right |=) 13142 ByronDarrah * There is a performance issue when editing a large table, say, with more then 50 rows 13142 ByronDarrah * You cannot put two =%EDITTABLE{}%= statements on the same line in the source 13142 ByronDarrah * You can include %-vars now in select values, by quoting them with <nop>, as in %<nop>X% for %X%, say for instance: 13142 ByronDarrah
=select,1,%<nop>X%,%<nop>Y%= 2895 PeterThoeny 8405 CrawfordCurrie 8405 CrawfordCurrie 13149 ArthurClemens ---++ Installation Instructions 13149 ArthurClemens 13142 ByronDarrah * Download the ZIP file from the Plugin web (see below) 13149 ArthurClemens * Unzip ==%TOPIC%.zip== in your ($TWIKI_ROOT) directory. 13149 ArthurClemens * Alternatively, 13149 ArthurClemens * Manually resolve the dependencies listed below. 13149 ArthurClemens %$DEPENDENCIES% 16240 KennethLavrsen * The Plugin depends on the =viewauth= script to authenticate the user. As described in %TWIKIWEB%.TWikiAccessControl, copy the =view= script to =viewauth= (or better, create a symbolic link) and add =viewauth= to the list of authenticated scripts in the =.htaccess= file. 13142 ByronDarrah * (Dakar) Visit =configure= in your TWiki installation, and enable the plugin in the {Plugins} section. 13142 ByronDarrah * Test if the Plugin is correctly installed: 13142 ByronDarrah * Check above example if there is an *[ Edit table ]* button below the table in above example 13142 ByronDarrah * Click on *[ Edit table ]*, make changes and save the table 2895 PeterThoeny 2895 PeterThoeny ---++ License 8405 CrawfordCurrie 13142 ByronDarrah * The Edit Table Plugin is released under the [[http://www.gnu.org/licenses/gpl.html][GPL]] 2895 PeterThoeny 8405 CrawfordCurrie 2895 PeterThoeny ---++ Plugin Info 2895 PeterThoeny 17719 PeterThoeny | Plugin Author: | Arthur Clemens, TWiki:Main/PeterThoeny | 17719 PeterThoeny | Copyright: | © 2008 Arthur Clemens, 2002-2008 TWiki:Main.PeterThoeny ([[http://www.twiki.net/][TWIKI.NET]]) and TWiki Contributors | 11392 PeterThoeny | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | 17719 PeterThoeny | Plugin Version: | 4.9 (01 Nov 2008) | 2895 PeterThoeny | Change History: |   | 17719 PeterThoeny | 01 Nov 2008: | 4.9: Arthur Clemens: Fixed rendering of =verbatim= blocks when editing. Added parameter =buttonrow="top"= to allow the buttons to be positioned at the top of the table. | 17719 PeterThoeny | 26 Sep 2008: | 4.8.7: Arthur Clemens: Let empty table initialize more than one column from =header= parameter | 17719 PeterThoeny | 24 Sep 2008: | 4.8.6: Arthur Clemens: Fix parsing of header labels | 17719 PeterThoeny | 21 Sep 2008: | 4.8.5: Arthur Clemens: Fix rendering of TML inside label | 17719 PeterThoeny | 03 Aug 2008: | 4.8.4: TWiki 4.2.1 release version | 17719 PeterThoeny | 19 Jul 2008: | 4.8.3: Bugfix release | 16544 ArthurClemens | 20 Mar 2008: | 4.8: Arthur Clemens: Code refactoring; disabled table sort when editing; removed usage of =$percnt= to prevent variable expansion (is now done automatically); made Javascript interface aware of headers and footers, and of =changerows="off"=; improved feedback on row move. | 16098 ArthurClemens | 25 Dec 2007: | 4.7.1: Arthur Clemens: Added warning if =include= parameter topic does not exist. | 16098 ArthurClemens | 22 Dec 2007: | 4.7: Arthur Clemens: Changed handling of escaped variables. To escape TWiki variable, use formatting tokens such as =$percnt=. | 17719 PeterThoeny | 16 Dec 2007: | 4.6: Kenneth Lavrsen: The plugin prevents TablePlugin from initsorting the table being edited. This is done by temporarily appending the attribute disableallsort="on" to the TABLE tag of a table being edited. Additionally all header sorting is disabled while editing a table by setting a hidden formfield =sort= to "off". Disabling sorting while editing is needed now that the EditTablePlugin supports moving rows up and down. | 17719 PeterThoeny | 01 Dec 2007: | 4.3: Arthur Clemens: added support for TablePlugin =headerrows= and =footerrows=; updated edit button | 17719 PeterThoeny | 16 Oct 2007: | 4.2: Arthur Clemens: refactoring, bug fixes. | 16240 KennethLavrsen | 07 Oct 2007: | 15182: PTh: Added %TWIKIWEB%.VarEDITTABLE to have it listed in %TWIKIWEB%.TWikiVariables | 13166 ArthurClemens | 15 Mar 2007: | Arthur Clemens: Fixed eating of double newlines; icons for javascript buttons and interface improvements. By default the javascript interface is turned off, set =JAVASCRIPTINTERFACE= to use it in edit mode. | 13149 ArthurClemens | 05 Mar 2007: | Byron Darrah: Added ability to dynamically move and delete rows. | 15813 ArthurClemens | 12 Oct 2006: | Item2982 Use default date format from JSCalendarContrib | 15813 ArthurClemens | 02 Oct 2006: | Item2884 Check also for access permission in meta data; proper fix to not warn if oneself has a lock on topic | 15813 ArthurClemens | 30 Aug 2006: | Item2829 Remove whitespace from select, radio and checkbox items; restored topic lock if $TWiki::Plugins::VERSION < 1.1 | 15813 ArthurClemens | 29 Jul 2006: | Item2684 - Quietly ignore topic edit locks on table edit | 8405 CrawfordCurrie | 21 Jan 2006: | TWiki:Main.CrawfordCurrie ported to TWiki-4.0.0, changed to use JSCalendarContrib | 13149 ArthurClemens | 16 Sep 2004: | Added radio buttons and checkbox controls; escaped "%VBAR%" pipe symbol found in input fields to preserve tables | 2922 PeterThoeny | 01 Aug 2004: | Fixed bug where edittable did not work if at the end of a topic | 2895 PeterThoeny | 07 Apr 2004: | Fixed bug where two tables got updated when you edit and save a table included into a topic containing other edit tables | 2895 PeterThoeny | 02 Mar 2004: | Default for =%EDITCELL{editbutton}%= is EDITBUTTON preference | 2895 PeterThoeny | 27 Feb 2004: | Added QUIETSAVE setting and =quietsave= parameter; image for Edit button | 2895 PeterThoeny | 18 Feb 2004: | Doc fixes; allow edit button anywhere in a cell not just at the end of a cell | 2895 PeterThoeny | 17 Feb 2004: | Added per cell definition of edit field types with =%EDITCELL{}%= variable; added =headerislabel= and =editbutton= parameters | 2895 PeterThoeny | 20 Dec 2003: | Fixed bug where calendar did not work after adding a row (TWiki:Main/PaulineCheung); added all language files of Mishoo DHTML calendar 0.9.5 | 2895 PeterThoeny | 13 Dec 2003: | Added CHANGEROWS, JSCALENDARDATEFORMAT, JSCALENDARLANGUAGE, JSCALENDAROPTIONS settings | 2895 PeterThoeny | 16 Oct 2003: | small typo fixed (garbled if ---+ header on top) | 2895 PeterThoeny | 15 Oct 2003: | new date field type with javascript calendar - CN | 2895 PeterThoeny | 14 Oct 2003: | docfix: the documentation page was an old one - CN | 2895 PeterThoeny | 13 Oct 2003: | bugfix: %-vars in select were resetted to first on add/del row - CN | 2895 PeterThoeny | 18 Sep 2003: | incompatibility: changed default of =changerows= to =on=; support for %-vars, Quiet save for saving without notification; all other fixes in Dev topic integrated - CN | 2895 PeterThoeny | 08 Nov 2002: | Prevent variable expansion in label text; added escape characters | 2895 PeterThoeny | 27 Jun 2002: | New =helptopic= parameter | 2895 PeterThoeny | 26 Jun 2002: | Support for variables in included EDITTABLE parameters; fixed problem with HTML in cells | 2895 PeterThoeny | 21 May 2002: | Added fixed label format; new =changerows="add"= parameter | 2895 PeterThoeny | 27 Apr 2002: | Fixed bug where text after a double quote in a cell disappeared | 2895 PeterThoeny | 18 Apr 2002: | Fixed bug where table was breaking when pasting multiple lines into an edit field using Netscape on Unix | 2895 PeterThoeny | 08 Apr 2002: | Check for change permission and edit lock of topic | 2895 PeterThoeny | 05 Apr 2002: | Initial version | 8405 CrawfordCurrie | Dependencies: | %$DEPENDENCIES% | 2895 PeterThoeny | Perl Version: | 5.0 | 16240 KennethLavrsen | TWiki:Plugins/Benchmark: | %TWIKIWEB%.GoodStyle 98%, %TWIKIWEB%.FormattedSearch 98%, %TOPIC% 95% | 2895 PeterThoeny | Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% | 2895 PeterThoeny | Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | 11392 PeterThoeny | Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal | 2895 PeterThoeny 16240 KennethLavrsen __Related Topics:__ %TWIKIWEB%.VarEDITTABLE, %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins 2895 PeterThoeny 13149 ArthurClemens %META:FILEATTACHMENT{name="EditTablePluginCalendarExample.gif" attr="h" comment="" date="1071283396" path="EditTablePluginCalendarExample.gif" size="7823" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="ScreenshotEditCell1.gif" attr="h" comment="Screenshot" date="1077050633" path="ScreenshotEditCell1.gif" size="2017" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="ScreenshotEditCell2.gif" attr="h" comment="Screenshot" date="1077050702" path="ScreenshotEditCell2.gif" size="3199" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="img.gif" attr="h" comment="Component of Mishoo DHTML calendar" date="1077813483" path="img.gif" size="145" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="menuarrow.gif" attr="h" comment="Component of Mishoo DHTML calendar" date="1077813470" path="menuarrow.gif" size="68" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="edittable.gif" attr="h" comment="Edit table image button" date="1077933805" path="edittable.gif" size="298" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="btn_move.gif" attr="h" comment="Javascript button: move row" date="1077933805" path="btn_move.gif" size="298" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="btn_target.gif" attr="h" comment="Javascript button: move target (animated)" date="1077933805" path="btn_target.gif" size="298" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="btn_delete.gif" attr="h" comment="Javascript button: delete row" date="1077933805" path="btn_delete.gif" size="298" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="btn_delete_disabled.gif" attr="h" comment="Javascript button: delete (disabled)" date="1077933805" path="btn_delete_disabled.gif" size="298" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="edittable.css" attr="h" comment="Plugin Style Sheet" date="1077933805" path="edittable.css" size="298" user="TWikiContributor" version="1.1"}% 13149 ArthurClemens %META:FILEATTACHMENT{name="edittable.js" attr="h" comment="Javascript for table editing without page refresh" date="1077933805" path="edittable.js" size="298" user="TWikiContributor" version="1.1"}% svn blame of /EditTablePlugin/data/TWiki/VarEditTable.txt 15181 PeterThoeny %META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev$"}% 15181 PeterThoeny %META:TOPICPARENT{name="TWikiVariables"}% 15181 PeterThoeny #VarEDITTABLE 15182 PeterThoeny ---+++ EDITTABLE{ _attributes_ } -- edit TWiki tables using edit fields and other input fields 15181 PeterThoeny * The =%EDITTABLE{}%= variable is handled by the EditTablePlugin 15181 PeterThoeny * Syntax: =%EDITTABLE{ _attributes_ }%= 15181 PeterThoeny %STARTSECTION{"edittable_attributes"}% 15181 PeterThoeny * Supported attributes: 15182 PeterThoeny | *Attribute* | *Comment* | *Default* | 15181 PeterThoeny | =header= | Specify the header format of a new table like ="%VBAR%*Food*%VBAR%*Drink*%VBAR%"=. Useful to start a table with only a button | (no header) | 15813 ArthurClemens | =format= | The format of one column when editing the table. A cell can be a text input field, or any of these edit field types:%BR% %BB% Text input field (1 line):%BR%   =%VBAR% text, <size>, <initial value> %VBAR%= %BR% %BB% Textarea input field:%BR%   =%VBAR% textarea, <rows>x<columns>, <initial value> %VBAR%= %BR% %BB% Drop down box: %BR%   =%VBAR% select, <size>, <option 1>, <option 2>, etc* %VBAR%= %BR%   =*= only one item can be selected %BR% %BB% Radio buttons: %BR%   =%VBAR% radio, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of buttons per line in edit mode %BR% %BB% Checkboxes: %BR%   =%VBAR% checkbox, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of checkboxes per line in edit mode %BR% %BB% Fixed label: %BR%   =%VBAR% label, 0, <label text> %VBAR%= %BR% %BB% Row number: %BR%   =%VBAR% row, <offset> %VBAR%= %BR% %BB% Date: %BR%   =%VBAR% date, <size>, <initial value>, <DHTML date format> %VBAR%= (see [[#DateField][Date Field Type]]) | ="text, 16"= %BR% for all cells | 16544 ArthurClemens | =changerows= | Rows can be added and removed if ="on"=
Rows can be added but not removed if ="add"=
Rows cannot be added or removed if ="off"= | =CHANGEROWS= %BR% plugin setting | 16544 ArthurClemens | =quietsave= | Quiet Save button is shown if ="on"=, hidden if ="off"= | =QUIETSAVE= %BR% plugin setting | 15181 PeterThoeny | =include= | Other topic defining the EDITTABLE parameters. The first %EDITTABLE% in the topic is used. This is useful if you have many topics with the same table format and you want to update the format in one place. | (none) | 15181 PeterThoeny | =helptopic= | Topic name containing help text shown below the table when editing a table. The %STARTINCLUDE% and %STOPINCLUDE% variables can be used in the topic to specify what is shown. | (no help text) | 15181 PeterThoeny | =headerislabel= | Table header cells are read-only (labels) if ="on"=; header cells can be edited if ="off"= or "0" | ="on"= | 16544 ArthurClemens | =editbutton= | Set edit button text, e.g. ="Edit this table"=; set button image with alt text, e.g. ="Edit table, %PUBURL%/%TWIKIWEB%/TWikiDocGraphics/edittopic.gif"=; hide edit button at the end of the table with ="hide"= (Note: Button is automatically hidden if an edit button is present in a cell) | =EDITBUTTON= %BR% plugin setting | 17719 PeterThoeny | =buttonrow= | Set to =top= to put the edit buttons above the table. | =bottom= | 16544 ArthurClemens | =javascriptinterface= | Use javascript to directly move and delete row without page refresh. Enable with ="on"=, disable with ="off"=. | =JAVASCRIPTINTERFACE= %BR% plugin setting | 15181 PeterThoeny %ENDSECTION{"edittable_attributes"}% 15181 PeterThoeny * Example:%BR% 15181 PeterThoeny =%EDITTABLE{ format="| text, 20 | select, 1, one, two, three |" changerows="on" }%= %BR% 15181 PeterThoeny =| *Name* | *Type* |= %BR% 15181 PeterThoeny =| Foo | two |= 15181 PeterThoeny * Related: See EditTablePlugin for more details svn blame of EditTablePlugin/pub/TWiki/EditTablePlugin/edittable.js 13149 ArthurClemens // sEditTable.js 13142 ByronDarrah // 13142 ByronDarrah // By Byron Darrah 13142 ByronDarrah // 13142 ByronDarrah // This code adds support to the TWiki EditTablesPlugin for dynamically 13142 ByronDarrah // manipulating rows within a table. 13149 ArthurClemens // 13149 ArthurClemens // Small refactoring by Arthur Clemens 15301 ArthurClemens // TODO: all functions should be moved from global space to a twiki.EditTable object 13142 ByronDarrah 13149 ArthurClemens /** 16544 ArthurClemens Code from TWiki 4.2 to make this plugin compatible with earlier versions. 16544 ArthurClemens */ 16544 ArthurClemens var twiki; 16544 ArthurClemens if (!twiki) twiki = {}; 16544 ArthurClemens twiki.getMetaTag = function(inKey) { 16544 ArthurClemens if (twiki.metaTags == null || twiki.metaTags.length == 0) { 16544 ArthurClemens var head = document.getElementsByTagName("META"); 16544 ArthurClemens head = head[0].parentNode.childNodes; 16544 ArthurClemens twiki.metaTags = new Array(); 16544 ArthurClemens for (var i = 0; i < head.length; i++) { 16544 ArthurClemens if (head[i].tagName != null && 16544 ArthurClemens head[i].tagName.toUpperCase() == 'META') { 16544 ArthurClemens twiki.metaTags[head[i].name] = head[i].content; 16544 ArthurClemens } 16544 ArthurClemens } 16544 ArthurClemens } 16544 ArthurClemens return twiki.metaTags[inKey]; 16544 ArthurClemens }; 13149 ArthurClemens 16544 ArthurClemens /** 16544 ArthurClemens 13149 ArthurClemens */ 13142 ByronDarrah // Global variables 13142 ByronDarrah 15314 ArthurClemens var sEditTable; 15314 ArthurClemens // array of edittables 13149 ArthurClemens var sRowSelection; 13165 ArthurClemens var sAlternatingColors = []; 13142 ByronDarrah 13149 ArthurClemens /** 13149 ArthurClemens 13149 ArthurClemens */ 13142 ByronDarrah // Here's a custom version of getElementByTagName. I find it easier 13142 ByronDarrah // to debug certain problems this way when a script doesn't seem to be 13142 ByronDarrah // finding the node we'd expect. 13142 ByronDarrah 13142 ByronDarrah function searchNodeTreeForTagName(node, tag_name) { 15314 ArthurClemens if (node.tagName == tag_name) { 15314 ArthurClemens return node; 15314 ArthurClemens } 15314 ArthurClemens for (var child = node.firstChild; child != null; child = child.nextSibling) { 15314 ArthurClemens var r = searchNodeTreeForTagName(child, tag_name); 15314 ArthurClemens if (r != null) { 15314 ArthurClemens return r; 15314 ArthurClemens } 15314 ArthurClemens } 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens function hasClass(el, className) { 15314 ArthurClemens if (!el || !className) 15314 ArthurClemens return; 15314 ArthurClemens var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); 15314 ArthurClemens return re.test(el['className']); 15314 ArthurClemens } 13149 ArthurClemens function addClass(el, className) { 15314 ArthurClemens if (!el || !className) 15314 ArthurClemens return; 15314 ArthurClemens if (hasClass(el, className)) { 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens // already present 15314 ArthurClemens el['className'] = [el['className'], className].join(' '); 13149 ArthurClemens } 13149 ArthurClemens function removeClass(el, className) { 15314 ArthurClemens if (!el || !className) 15314 ArthurClemens return; 15314 ArthurClemens if (!hasClass(el, className)) { 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens // not present 15314 ArthurClemens 15314 ArthurClemens var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g'); 15314 ArthurClemens var c = el['className']; 15314 ArthurClemens el['className'] = c.replace(re, ' '); 13149 ArthurClemens } 15314 ArthurClemens 13149 ArthurClemens /** 14104 ByronDarrah Create user control elements and initialize table manipulation objects. 13149 ArthurClemens */ 13149 ArthurClemens 13142 ByronDarrah // Build the list of edittables. 16544 ArthurClemens function edittableInit(form_name, asset_url, headerRows, footerRows) { 15314 ArthurClemens 15314 ArthurClemens // The form we want is actually the second thing in the 15314 ArthurClemens // document that has the form_name. 16544 ArthurClemens var forms = document.getElementsByName(form_name); 16544 ArthurClemens var tableform = forms[1]; 15314 ArthurClemens 15314 ArthurClemens if (tableform == null) { 16544 ArthurClemens alert("Something went wrong: EditTable javascript features cannot be enabled.\n"); 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens attachEvent(tableform, 'submit', submitHandler); 15314 ArthurClemens 15314 ArthurClemens var somerow = searchNodeTreeForTagName(tableform, "TR"); 15314 ArthurClemens 15314 ArthurClemens if (somerow != null) { 15314 ArthurClemens var row_container = somerow.parentNode; 15314 ArthurClemens sEditTable = new EditTableObject(tableform, row_container); 16544 ArthurClemens } 16544 ArthurClemens sEditTable.headerRows = headerRows; 16544 ArthurClemens sEditTable.footerRows = footerRows; 16544 ArthurClemens if (somerow != null) { 16544 ArthurClemens insertActionButtons(asset_url); 15314 ArthurClemens insertRowSeparators(); 15314 ArthurClemens } 15314 ArthurClemens sRowSelection = new RowSelectionObject(asset_url); 15314 ArthurClemens retrieveAlternatingRowColors(); 15314 ArthurClemens fixStyling(); 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13149 ArthurClemens 13149 ArthurClemens */ 13142 ByronDarrah // Create the etrow_id# inputs to tell the server about row changes we made. 13149 ArthurClemens function submitHandler(evt) { 16544 ArthurClemens if (!evt) var evt = window.event; 16544 ArthurClemens 16544 ArthurClemens var ilen = sEditTable.numrows; 16544 ArthurClemens 16544 ArthurClemens for (var rowpos = 0; rowpos < ilen; rowpos++) { 16544 ArthurClemens if (rowpos+1 == sEditTable.headerRows) { 16544 ArthurClemens //continue; 16544 ArthurClemens } 16544 ArthurClemens var inpname = 'etrow_id' + (rowpos + 1); 16544 ArthurClemens var row_id = sEditTable.revidx[rowpos] + 1; 16544 ArthurClemens var inp = document.createElement('INPUT'); 15314 ArthurClemens inp.setAttribute('type', 'hidden'); 15314 ArthurClemens inp.setAttribute('name', inpname); 15314 ArthurClemens inp.setAttribute('value', '' + row_id); 15314 ArthurClemens sEditTable.tableform.appendChild(inp); 15314 ArthurClemens } 16544 ArthurClemens 15314 ArthurClemens return true; 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13149 ArthurClemens 13149 ArthurClemens */ 13149 ArthurClemens function attachEvent(obj, evtype, handler) { 16544 ArthurClemens if (!handler) return; 16544 ArthurClemens if (window.addEventListener) { 15314 ArthurClemens // Mozilla, Netscape, Firefox 15314 ArthurClemens obj.addEventListener(evtype, handler, false); 15314 ArthurClemens } else { 15314 ArthurClemens // IE 15314 ArthurClemens obj.attachEvent('on' + evtype, handler); 15314 ArthurClemens } 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13149 ArthurClemens 13149 ArthurClemens */ 13149 ArthurClemens function detachEvent(obj, evtype, handler) { 15314 ArthurClemens if (window.addEventListener) { 15314 ArthurClemens // Mozilla, Netscape, Firefox 15314 ArthurClemens obj.removeEventListener(evtype, handler, false); 15314 ArthurClemens } else { 15314 ArthurClemens // IE 15314 ArthurClemens obj.detachEvent('on' + evtype, handler); 15314 ArthurClemens } 13149 ArthurClemens } 13149 ArthurClemens 13149 ArthurClemens /** 13149 ArthurClemens 13149 ArthurClemens */ 13149 ArthurClemens function getEventAttr(evt, pname) { 15314 ArthurClemens var e_out; 15314 ArthurClemens var ie_var = "srcElement"; 15314 ArthurClemens var moz_var = "target"; 15314 ArthurClemens // "target" for Mozilla, Netscape, Firefox et al. ; "srcElement" for IE 15314 ArthurClemens evt[moz_var] ? e_out = evt[moz_var][pname] : e_out = evt[ie_var][pname]; 15314 ArthurClemens return e_out; 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13142 ByronDarrah 13149 ArthurClemens */ 13149 ArthurClemens function insertActionButtons(asset_url) { 15314 ArthurClemens insertActionButtonsMove(asset_url); 15314 ArthurClemens insertActionButtonsDelete(asset_url); 15314 ArthurClemens } 13149 ArthurClemens 15314 ArthurClemens /** 14093 ByronDarrah 15314 ArthurClemens */ 15314 ArthurClemens function insertActionButtonsMove(asset_url) { 15314 ArthurClemens 15344 ArthurClemens // do not show a move button for just one row 15344 ArthurClemens if (sEditTable.numrows <= 1 ) return; 15314 ArthurClemens 16544 ArthurClemens var action_cell, action_butt; 15314 ArthurClemens 15314 ArthurClemens for (var rowpos = 0; rowpos < sEditTable.numrows; rowpos++) { 15314 ArthurClemens var rownr = sEditTable.revidx[rowpos]; 15314 ArthurClemens var child = sEditTable.rows[rownr]; 15314 ArthurClemens if (child.tagName == 'TR') { 16544 ArthurClemens var isHeaderRow = (rowpos < sEditTable.headerRows); 16544 ArthurClemens var isFooterRow = (rowpos < sEditTable.headerRows + sEditTable.footerRows); // footer rows are written just below the header, and before the body 16544 ArthurClemens if (isHeaderRow || isFooterRow) { 16544 ArthurClemens action_cell = document.createElement('TH'); 16544 ArthurClemens action_butt = document.createElement('SPAN'); 16544 ArthurClemens } else { 16544 ArthurClemens action_cell = document.createElement('TD'); 16544 ArthurClemens action_butt = createActionButtonMove(asset_url, rownr); 16544 ArthurClemens action_cell.moveButton = action_butt; 16544 ArthurClemens addClass(action_cell, 'editTableActionCell'); 16544 ArthurClemens } 16544 ArthurClemens action_cell.id = 'et_actioncell' + rownr; 16544 ArthurClemens action_cell.appendChild(action_butt); 15314 ArthurClemens child.insertBefore(action_cell, child.firstChild); 15314 ArthurClemens } 13149 ArthurClemens } 15314 ArthurClemens // set styling for the last action_cell to remove the bottom border 16544 ArthurClemens //addClass(action_cell, 'twikiLast'); 15314 ArthurClemens } 13142 ByronDarrah 16544 ArthurClemens function createActionButtonMove (asset_url, rownr) { 16544 ArthurClemens var action_butt = document.createElement('IMG'); 16544 ArthurClemens action_butt.setAttribute('title', 'Move row'); 16544 ArthurClemens action_butt.enableButtonSrc = asset_url + '/btn_move.gif'; 16544 ArthurClemens action_butt.disableButtonSrc = asset_url + '/btn_move_disabled.gif'; 16544 ArthurClemens action_butt.hoverButtonSrc = asset_url + '/btn_move_over.gif'; 16544 ArthurClemens action_butt.moveButtonSrc = asset_url + '/btn_move.gif'; 16544 ArthurClemens action_butt.setAttribute('src', action_butt.enableButtonSrc); 16544 ArthurClemens 16544 ArthurClemens action_butt.mohandler = mouseOverButtonHandler; 16544 ArthurClemens attachEvent(action_butt, 'mouseover', action_butt.mohandler); 16544 ArthurClemens action_butt.mouthandler = mouseOutButtonHandler; 16544 ArthurClemens attachEvent(action_butt, 'mouseout', action_butt.mouthandler); 16544 ArthurClemens 16544 ArthurClemens action_butt.handler = moveHandler; 16544 ArthurClemens attachEvent(action_butt, 'click', action_butt.handler); 16544 ArthurClemens addClass(action_butt, 'editTableActionButton'); 16544 ArthurClemens action_butt.rownr = rownr; 16544 ArthurClemens return action_butt; 16544 ArthurClemens } 16544 ArthurClemens 15314 ArthurClemens /** 15314 ArthurClemens 15314 ArthurClemens */ 15314 ArthurClemens function insertActionButtonsDelete(asset_url) { 15314 ArthurClemens 16544 ArthurClemens var action_cell, action_butt; 15314 ArthurClemens 15314 ArthurClemens for (var rowpos = 0; rowpos < sEditTable.numrows; rowpos++) { 15314 ArthurClemens var rownr = sEditTable.revidx[rowpos]; 15314 ArthurClemens var child = sEditTable.rows[rownr]; 15314 ArthurClemens if (child.tagName == 'TR') { 16544 ArthurClemens var isHeaderRow = (rowpos < sEditTable.headerRows); 16544 ArthurClemens var isFooterRow = (rowpos < sEditTable.headerRows + sEditTable.footerRows); // footer rows are written just below the header, and before the body 16544 ArthurClemens if (isHeaderRow || isFooterRow) { 16544 ArthurClemens action_cell = document.createElement('TH'); 16544 ArthurClemens action_butt = document.createElement('SPAN'); 16544 ArthurClemens } else { 16544 ArthurClemens action_cell = document.createElement('TD'); 16544 ArthurClemens action_butt = createActionButtonDelete(asset_url, rownr); 16544 ArthurClemens action_cell.moveButton = action_butt; 16544 ArthurClemens addClass(action_cell, 'editTableActionCell'); 16544 ArthurClemens } 16544 ArthurClemens action_cell.id = 'et_actioncell' + rownr; 16544 ArthurClemens action_cell.deleteButton = action_butt; 16544 ArthurClemens action_cell.appendChild(action_butt); 15314 ArthurClemens insertAfter(action_cell, child.lastChild); 15314 ArthurClemens } 15314 ArthurClemens } 15314 ArthurClemens // set styling for the last action_cell to remove the bottom border 15314 ArthurClemens addClass(action_cell, 'twikiLast'); 13149 ArthurClemens } 13142 ByronDarrah 16544 ArthurClemens function createActionButtonDelete (asset_url, rownr) { 16544 ArthurClemens 16544 ArthurClemens var action_butt = document.createElement('IMG'); 16544 ArthurClemens action_butt.setAttribute('title', 'Delete row'); 16544 ArthurClemens action_butt.enableButtonSrc = asset_url + '/btn_delete.gif'; 16544 ArthurClemens action_butt.disableButtonSrc = asset_url + '/btn_delete_disabled.gif'; 16544 ArthurClemens action_butt.hoverButtonSrc = asset_url + '/btn_delete_over.gif'; 16544 ArthurClemens action_butt.setAttribute('src', action_butt.enableButtonSrc); 16544 ArthurClemens 16544 ArthurClemens action_butt.mohandler = mouseOverButtonHandler; 16544 ArthurClemens attachEvent(action_butt, 'mouseover', action_butt.mohandler); 16544 ArthurClemens action_butt.mouthandler = mouseOutButtonHandler; 16544 ArthurClemens attachEvent(action_butt, 'mouseout', action_butt.mouthandler); 16544 ArthurClemens 16544 ArthurClemens action_butt.handler = deleteHandler; 16544 ArthurClemens attachEvent(action_butt, 'click', action_butt.handler); 16544 ArthurClemens 16544 ArthurClemens addClass(action_butt, 'editTableActionButton'); 16544 ArthurClemens action_butt.rownr = rownr; 16544 ArthurClemens return action_butt; 16544 ArthurClemens } 16544 ArthurClemens 16544 ArthurClemens 13149 ArthurClemens /** 13142 ByronDarrah 13149 ArthurClemens */ 13195 ByronDarrah function insertRowSeparators() { 15314 ArthurClemens 15314 ArthurClemens var child; 15314 ArthurClemens var sep_row, 15314 ArthurClemens columns; 15314 ArthurClemens 15314 ArthurClemens for (var rowpos = 0; rowpos < sEditTable.numrows; rowpos++) { 15314 ArthurClemens var rownr = sEditTable.revidx[rowpos]; 16544 ArthurClemens var isHeaderRow = (rowpos < sEditTable.headerRows); 16544 ArthurClemens var isFooterRow = (rowpos < sEditTable.headerRows + sEditTable.footerRows); // footer rows are written just below the header, and before the body 16544 ArthurClemens if (isHeaderRow || isFooterRow) { 16544 ArthurClemens // 16544 ArthurClemens } else { 16544 ArthurClemens child = sEditTable.rows[rownr]; 16544 ArthurClemens columns = countRowColumns(child); 16544 ArthurClemens sep_row = makeSeparatorRow(rownr, columns); 16544 ArthurClemens child.parentNode.insertBefore(sep_row, child); 16544 ArthurClemens } 15314 ArthurClemens } 15314 ArthurClemens sep_row = makeSeparatorRow(null, columns); 15314 ArthurClemens child.parentNode.appendChild(sep_row); 15314 ArthurClemens sEditTable.last_separator = sep_row; 13195 ByronDarrah } 13195 ByronDarrah 13195 ByronDarrah /** 13195 ByronDarrah 13195 ByronDarrah */ 13195 ByronDarrah function makeSeparatorRow(rownr, columns) { 15314 ArthurClemens var sep_row = document.createElement('TR'); 15314 ArthurClemens var sep_cell = document.createElement('TD'); 15314 ArthurClemens sep_cell.colSpan = columns; 15314 ArthurClemens sep_cell.colSpan = columns; 15314 ArthurClemens sep_cell.style.padding = '0px'; 15314 ArthurClemens sep_cell.style.spacing = '0px'; 15314 ArthurClemens sep_cell.style.border = '0px'; 15314 ArthurClemens sep_cell.style.height = '0px'; 15314 ArthurClemens sep_cell.rownr = rownr; 15314 ArthurClemens 15314 ArthurClemens sep_row.rownr = rownr; 15314 ArthurClemens sep_row.appendChild(sep_cell); 15314 ArthurClemens sep_row.cell = sep_cell; 15314 ArthurClemens addClass(sep_row, 'editTableRowSeparator'); 15314 ArthurClemens sep_row.id = 'et_rowseparator' + rownr; 15314 ArthurClemens sep_row.ckhandler = sepClickHandler; 15314 ArthurClemens sep_row.mohandler = sepMouseOverHandler; 15314 ArthurClemens sep_row.mouthandler = sepMouseOutHandler; 15314 ArthurClemens attachEvent(sep_row, 'click', sep_row.ckhandler); 15314 ArthurClemens attachEvent(sep_row, 'mouseover', sep_row.mohandler); 15314 ArthurClemens attachEvent(sep_row, 'mouseout', sep_row.mouthandler); 15314 ArthurClemens return sep_row; 13195 ByronDarrah } 13195 ByronDarrah 13195 ByronDarrah /** 13195 ByronDarrah 13195 ByronDarrah */ 13195 ByronDarrah function countRowColumns(row_el) { 15314 ArthurClemens var count = 0; 15314 ArthurClemens for (var tcell = row_el.firstChild; tcell != null; tcell = tcell.nextSibling) { 15314 ArthurClemens if (tcell.tagName == 'TD' || tcell.tagName == 'TH') { 15314 ArthurClemens count += tcell.colSpan; 15314 ArthurClemens } 15314 ArthurClemens } 15314 ArthurClemens return count; 13195 ByronDarrah } 13195 ByronDarrah 13195 ByronDarrah /** 13195 ByronDarrah 13195 ByronDarrah */ 13508 ByronDarrah function selectRow(rownr) { 15314 ArthurClemens if (rownr == null && sRowSelection.row == null) { 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens var top_image = "none"; 15314 ArthurClemens var bottom_image = "none"; 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens if (rownr != null) { 15314 ArthurClemens sRowSelection.row = sEditTable.rows[rownr]; 15314 ArthurClemens sRowSelection.rownum = rownr; 15314 ArthurClemens // top_image = "url(" + sRowSelection.topImage + ")"; 15314 ArthurClemens // bottom_image = "url(" + sRowSelection.bottomImage + ")"; 15314 ArthurClemens 15314 ArthurClemens var sep_row = sRowSelection.row.previousSibling; 15314 ArthurClemens sRowSelection.topSep = sep_row; 15314 ArthurClemens 15314 ArthurClemens var next_rowpos = sEditTable.positions[rownr] + 1; 15314 ArthurClemens if (next_rowpos < sEditTable.numrows) { 15314 ArthurClemens var next_rownr = sEditTable.revidx[next_rowpos]; 15314 ArthurClemens sep_row = sEditTable.rows[next_rownr].previousSibling; 15314 ArthurClemens } else { 15314 ArthurClemens sep_row = sEditTable.last_separator; 15314 ArthurClemens } 15314 ArthurClemens sRowSelection.bottomSep = sep_row; 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens /* Set the style class of data cell elements in the selected row */ 15314 ArthurClemens 15314 ArthurClemens var tableCells = sRowSelection.row.getElementsByTagName('TD'); 15314 ArthurClemens for (var i = 0; i < tableCells.length;++i) { 15314 ArthurClemens if (rownr != null) { 15314 ArthurClemens addClass(tableCells[i], 'editTableActionSelectedCell'); 15314 ArthurClemens } else { 15314 ArthurClemens removeClass(tableCells[i], 'editTableActionSelectedCell'); 15314 ArthurClemens } 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens /* Place images of moving dashes above and below the selected row */ 15314 ArthurClemens 15314 ArthurClemens if (sRowSelection.topSep != null) { 15314 ArthurClemens var sepCells = sRowSelection.topSep.getElementsByTagName('TD'); 15314 ArthurClemens sepCells[0].style.backgroundImage = top_image; 15314 ArthurClemens sepCells[0].style.backgroundRepeat = "repeat-x"; 15314 ArthurClemens } 15314 ArthurClemens if (sRowSelection.bottomSep != null) { 15314 ArthurClemens var sepCells = sRowSelection.bottomSep.getElementsByTagName('TD'); 15314 ArthurClemens sepCells[0].style.backgroundImage = bottom_image; 15314 ArthurClemens sepCells[0].style.backgroundRepeat = "repeat-x"; 15314 ArthurClemens } 15314 ArthurClemens if (rownr == null) { 15314 ArthurClemens sRowSelection.row = null; 15314 ArthurClemens sRowSelection.rownum = null; 15314 ArthurClemens sRowSelection.topSep = null; 15314 ArthurClemens sRowSelection.bottomSep = null; 15314 ArthurClemens } 13508 ByronDarrah } 13508 ByronDarrah 15342 ArthurClemens function mouseOverButtonHandler(evt) { 15342 ArthurClemens var target = evt.srcElement ? evt.srcElement: evt.target; 15342 ArthurClemens target.src = target['hoverButtonSrc']; 15342 ArthurClemens } 15342 ArthurClemens 15342 ArthurClemens function mouseOutButtonHandler(evt) { 15342 ArthurClemens var target = evt.srcElement ? evt.srcElement: evt.target; 15342 ArthurClemens target.src = target['enableButtonSrc']; 15342 ArthurClemens } 15342 ArthurClemens 13508 ByronDarrah /** 15314 ArthurClemens TODO: explorer fires twice, so nothing happens visually 13508 ByronDarrah */ 13149 ArthurClemens function moveHandler(evt) { 15314 ArthurClemens 15314 ArthurClemens if (sRowSelection.rownum != null) { 15314 ArthurClemens // switch back 15314 ArthurClemens sRowSelection.rownum = null; 15314 ArthurClemens selectRow(null); 15314 ArthurClemens switchDeleteButtons(evt); 15314 ArthurClemens switchMoveButtons(evt); 16544 ArthurClemens removeSeparatorAnimation(); 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens var rownr = getEventAttr(evt, 'rownr'); 15314 ArthurClemens selectRow(rownr); 15314 ArthurClemens switchDeleteButtons(evt); 15314 ArthurClemens switchMoveButtons(evt); 16544 ArthurClemens addSeparatorAnimation(); 13195 ByronDarrah } 13195 ByronDarrah 16544 ArthurClemens function addSeparatorAnimation() { 16544 ArthurClemens addClass(sEditTable.rows[0].parentNode.parentNode, 'editTableMoveMode'); 16544 ArthurClemens } 16544 ArthurClemens 16544 ArthurClemens function removeSeparatorAnimation() { 16544 ArthurClemens removeClass(sEditTable.rows[0].parentNode.parentNode, 'editTableMoveMode'); 16544 ArthurClemens } 16544 ArthurClemens 13195 ByronDarrah /** 13195 ByronDarrah 13195 ByronDarrah */ 16544 ArthurClemens function sepClickHandler(evt) { 15314 ArthurClemens var rownr = getEventAttr(evt, 'rownr'); 15314 ArthurClemens if (sRowSelection.rownum == null) { 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens moveRow(sRowSelection.rownum, rownr); 15314 ArthurClemens selectRow(null); 15314 ArthurClemens switchDeleteButtons(evt); 15314 ArthurClemens switchMoveButtons(evt); 16544 ArthurClemens removeSeparatorAnimation(); 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13142 ByronDarrah 13149 ArthurClemens */ 13195 ByronDarrah function sepMouseOverHandler(evt) { 15314 ArthurClemens var target = evt.srcElement ? evt.srcElement: evt.target; 15314 ArthurClemens if (sRowSelection.rownum == null) { 15314 ArthurClemens removeClass(target, 'editTableRowSeparatorHover'); 15314 ArthurClemens } else { 15314 ArthurClemens addClass(target, 'editTableRowSeparatorHover'); 15314 ArthurClemens } 13195 ByronDarrah } 13195 ByronDarrah 15314 ArthurClemens function sepMouseOutHandler(evt) { 15314 ArthurClemens var target = evt.srcElement ? evt.srcElement: evt.target; 15314 ArthurClemens removeClass(target, 'editTableRowSeparatorHover'); 15314 ArthurClemens } 15314 ArthurClemens 13195 ByronDarrah /** 13195 ByronDarrah 13195 ByronDarrah */ 15314 ArthurClemens function switchDeleteButtons(evt) { 15314 ArthurClemens var rownr = getEventAttr(evt, 'rownr'); 15314 ArthurClemens var mode = (sRowSelection.rownum == null) ? 'to_enable': 'to_disable'; 15314 ArthurClemens var ilen = sEditTable.rows.length; 15314 ArthurClemens for (var i = 0; i < ilen;++i) { 15314 ArthurClemens var row_elem = sEditTable.rows[i]; 15314 ArthurClemens var action_cell = row_elem.lastChild; 15314 ArthurClemens var deleteButton = action_cell.deleteButton; 16544 ArthurClemens if (!deleteButton) continue; 15314 ArthurClemens if (mode == 'to_enable') { 15314 ArthurClemens deleteButton.src = deleteButton['enableButtonSrc']; 15314 ArthurClemens attachEvent(deleteButton, 'click', deleteButton.handler); 15314 ArthurClemens } else { 15314 ArthurClemens deleteButton.src = deleteButton['disableButtonSrc']; 15314 ArthurClemens detachEvent(deleteButton, 'click', deleteButton.handler); 15314 ArthurClemens } 15314 ArthurClemens } 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 15314 ArthurClemens Enables/disabled the move buttons. 15314 ArthurClemens Disabling: except for the row that has been selected. 15314 ArthurClemens */ 15314 ArthurClemens function switchMoveButtons(evt) { 15314 ArthurClemens var rownr = getEventAttr(evt, 'rownr'); 15314 ArthurClemens var mode = (sRowSelection.rownum == null) ? 'to_enable': 'to_disable'; 15314 ArthurClemens var ilen = sEditTable.rows.length; 15314 ArthurClemens for (var i = 0; i < ilen;++i) { 15314 ArthurClemens var buttonMode = mode; 15314 ArthurClemens if (mode == 'to_disable' && i == sRowSelection.rownum) { 15314 ArthurClemens buttonMode = 'to_enable'; 15314 ArthurClemens } 15314 ArthurClemens var row_elem = sEditTable.rows[i]; 15314 ArthurClemens var action_cell = row_elem.firstChild; 15314 ArthurClemens var moveButton = action_cell.moveButton; 16544 ArthurClemens if (!moveButton) continue; 15314 ArthurClemens if (buttonMode == 'to_enable') { 15314 ArthurClemens moveButton.src = moveButton['enableButtonSrc']; 15314 ArthurClemens attachEvent(moveButton, 'click', moveButton.handler); 15314 ArthurClemens } else { 15314 ArthurClemens moveButton.src = moveButton['disableButtonSrc']; 15314 ArthurClemens detachEvent(moveButton, 'click', moveButton.handler); 15314 ArthurClemens } 15314 ArthurClemens } 15314 ArthurClemens } 13142 ByronDarrah 15314 ArthurClemens /** 15314 ArthurClemens 13149 ArthurClemens */ 13149 ArthurClemens function deleteHandler(evt) { 15314 ArthurClemens var rownr = getEventAttr(evt, 'rownr'); 15314 ArthurClemens var from_row_pos = sEditTable.positions[rownr]; 15314 ArthurClemens 15314 ArthurClemens // Remove the from_row from the table. 15314 ArthurClemens 15314 ArthurClemens var from_row_elem = sEditTable.rows[rownr]; 15314 ArthurClemens from_row_elem.parentNode.removeChild(from_row_elem.previousSibling); 15314 ArthurClemens from_row_elem.parentNode.removeChild(from_row_elem); 15314 ArthurClemens 15314 ArthurClemens // Update all rows after from_row. 15314 ArthurClemens 16544 ArthurClemens for (var rowpos = from_row_pos + 1; rowpos < sEditTable.numrows; rowpos++) { 16544 ArthurClemens var rownum = sEditTable.revidx[rowpos]; 16544 ArthurClemens var newpos = rowpos - 1; 15314 ArthurClemens sEditTable.positions[rownum] = newpos; 15314 ArthurClemens sEditTable.revidx[newpos] = rownum; 15314 ArthurClemens updateRowlabels(rownum, -1); 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens if (sRowSelection.rownum == rownr) { 15314 ArthurClemens selectRow(null); 15314 ArthurClemens } 16544 ArthurClemens 15314 ArthurClemens sEditTable.numrows--; 16544 ArthurClemens sEditTable.tableform.etrows.value = sEditTable.numrows - (sEditTable.headerRows + sEditTable.footerRows); 15314 ArthurClemens 15314 ArthurClemens fixStyling(); 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13161 ArthurClemens to write 13161 ArthurClemens */ 13161 ArthurClemens function addHandler() { 15314 ArthurClemens // 15314 ArthurClemens 13161 ArthurClemens } 13142 ByronDarrah 13161 ArthurClemens /** 13161 ArthurClemens 13149 ArthurClemens */ 15314 ArthurClemens function retrieveAlternatingRowColors() { 16544 ArthurClemens if (!sEditTable) return; 15314 ArthurClemens var ilen = sEditTable.numrows; 15314 ArthurClemens for (var i = 0; i < ilen;++i) { 15314 ArthurClemens var tr = sEditTable.rows[i]; 15314 ArthurClemens var tableCells = tr.getElementsByTagName('TD'); 15314 ArthurClemens var alternate = (i % 2 == 0) ? 0: 1; 15314 ArthurClemens for (var j = 0; j < tableCells.length;++j) { 15314 ArthurClemens if (sAlternatingColors[0] != null && sAlternatingColors[1] != null) 15314 ArthurClemens continue; 15314 ArthurClemens var color = tableCells[j].getAttribute('bgColor'); 15314 ArthurClemens if (color) 15314 ArthurClemens sAlternatingColors[alternate] = color; 15314 ArthurClemens } 15314 ArthurClemens if (sAlternatingColors[0] != null && sAlternatingColors[1] != null) { 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens } 13149 ArthurClemens } 13142 ByronDarrah 13149 ArthurClemens /** 13149 ArthurClemens Style the last row. 13149 ArthurClemens */ 15314 ArthurClemens function fixStyling() { 16544 ArthurClemens if (!sEditTable) return; 15314 ArthurClemens // style even/uneven rows 15314 ArthurClemens var ilen = sEditTable.numrows; 15314 ArthurClemens for (var i = 0; i < ilen; i++) { 15314 ArthurClemens var num = sEditTable.revidx[i]; 15314 ArthurClemens var tr = sEditTable.rows[num]; 15314 ArthurClemens var tableCells = tr.getElementsByTagName('TD'); 15314 ArthurClemens var alternate = (i % 2 == 0) ? 0: 1; 15314 ArthurClemens var className = (i % 2 == 0) ? 'twikiTableEven': 'twikiTableOdd'; 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens if (!sAlternatingColors[alternate]) { 15314 ArthurClemens continue; 15314 ArthurClemens } 15314 ArthurClemens removeClass(tr, 'twikiTableEven'); 15314 ArthurClemens removeClass(tr, 'twikiTableOdd'); 15314 ArthurClemens addClass(tr, className); 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens for (var j = 0; j < tableCells.length;++j) { 15314 ArthurClemens var cell = tableCells[j]; 15314 ArthurClemens removeClass(cell, 'twikiLast'); 15314 ArthurClemens addClass(cell, className); 15314 ArthurClemens cell.removeAttribute('bgColor'); 15314 ArthurClemens cell.setAttribute('bgColor', sAlternatingColors[alternate]); 15314 ArthurClemens } 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens // style last row 15314 ArthurClemens 15314 ArthurClemens var lastRowNum = sEditTable.revidx[sEditTable.numrows - 1]; 15314 ArthurClemens var lastRowElement = sEditTable.rows[lastRowNum]; 15314 ArthurClemens var tableCells = lastRowElement.getElementsByTagName('TD'); 15314 ArthurClemens for (var i = 0; i < tableCells.length;++i) { 15314 ArthurClemens addClass(tableCells[i], 'twikiLast'); 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens 13149 ArthurClemens } 13149 ArthurClemens 13149 ArthurClemens /** 13149 ArthurClemens 13149 ArthurClemens */ 13149 ArthurClemens function moveRow(from_row, to_row) { 16544 ArthurClemens if (!sEditTable) return; 15314 ArthurClemens var from_row_pos = sEditTable.positions[from_row]; 15314 ArthurClemens var to_row_pos; 16544 ArthurClemens 15314 ArthurClemens // If the end separator row was selected, use the last row. 15314 ArthurClemens 15314 ArthurClemens if (to_row == null) { 15314 ArthurClemens to_row_pos = sEditTable.numrows - 1; 15314 ArthurClemens to_row = sEditTable.revidx[to_row_pos]; 15314 ArthurClemens } else { 15314 ArthurClemens to_row_pos = sEditTable.positions[to_row]; 15314 ArthurClemens if (to_row_pos > from_row_pos) { 15314 ArthurClemens to_row_pos--; 15314 ArthurClemens to_row = sEditTable.revidx[to_row_pos]; 15314 ArthurClemens } 13195 ByronDarrah } 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens var inc = 1; 15314 ArthurClemens if (to_row_pos == -1 || from_row_pos > to_row_pos) { 15314 ArthurClemens inc = -1; 15314 ArthurClemens } 15314 ArthurClemens if (from_row == to_row) { 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens // Remove the from_row from the table. 15314 ArthurClemens 15314 ArthurClemens var from_row_elem = sEditTable.rows[from_row]; 15314 ArthurClemens var from_row_sep = from_row_elem.previousSibling; 15314 ArthurClemens workaroundIECheckboxBug(from_row_elem); 15314 ArthurClemens from_row_elem.parentNode.removeChild(from_row_sep); 15314 ArthurClemens from_row_elem.parentNode.removeChild(from_row_elem); 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens // Update all rows after from_row up to to_row. 15314 ArthurClemens 16544 ArthurClemens for (var rowpos = from_row_pos + inc; rowpos != to_row_pos + inc; rowpos += inc) { 16544 ArthurClemens var rownum = sEditTable.revidx[rowpos]; 16544 ArthurClemens var newpos = rowpos - inc; 15314 ArthurClemens sEditTable.positions[rownum] = newpos; 15314 ArthurClemens sEditTable.revidx[newpos] = rownum; 15314 ArthurClemens updateRowlabels(rownum, -inc); 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens var insertion_target; 15314 ArthurClemens if (inc == 1) { 15314 ArthurClemens insertion_target = sEditTable.rows[to_row] 15314 ArthurClemens insertAfter(from_row_elem, insertion_target); 15314 ArthurClemens insertAfter(from_row_sep, insertion_target); 15314 ArthurClemens } else { 15314 ArthurClemens insertion_target = sEditTable.rows[to_row].previousSibling; 15314 ArthurClemens insertBefore(from_row_sep, insertion_target); 15314 ArthurClemens insertBefore(from_row_elem, insertion_target); 15314 ArthurClemens } 15314 ArthurClemens sEditTable.positions[from_row] = to_row_pos; 15314 ArthurClemens sEditTable.revidx[to_row_pos] = from_row; 15314 ArthurClemens updateRowlabels(from_row, to_row_pos - from_row_pos); 15314 ArthurClemens fixStyling(); 14093 ByronDarrah } 13142 ByronDarrah 14093 ByronDarrah /** 14093 ByronDarrah 14093 ByronDarrah */ 14093 ByronDarrah function insertAfter(newnode, oldnode) { 15314 ArthurClemens var parent = oldnode.parentNode; 15314 ArthurClemens if (oldnode.nextSibling == null) { 15314 ArthurClemens parent.appendChild(newnode); 15314 ArthurClemens } else { 15314 ArthurClemens parent.insertBefore(newnode, oldnode.nextSibling); 15314 ArthurClemens } 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13149 ArthurClemens 13149 ArthurClemens */ 14093 ByronDarrah function insertBefore(newnode, oldnode) { 15314 ArthurClemens oldnode.parentNode.insertBefore(newnode, oldnode); 14093 ByronDarrah } 14093 ByronDarrah 14093 ByronDarrah /** 14093 ByronDarrah 14093 ByronDarrah */ 13142 ByronDarrah // IE will reset checkboxes to their default state when they are moved around 13142 ByronDarrah // in the DOM tree, so we have to override the default state. 13142 ByronDarrah 13149 ArthurClemens function workaroundIECheckboxBug(container) { 15314 ArthurClemens var elems = container.getElementsByTagName('INPUT'); 15314 ArthurClemens for (var i = 0; elems[i] != null; i++) { 15314 ArthurClemens var inp = elems[i]; 15314 ArthurClemens if (inp['type'] == 'radio') { 15314 ArthurClemens inp['defaultChecked'] = inp['checked']; 15314 ArthurClemens } 13142 ByronDarrah } 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13142 ByronDarrah 13149 ArthurClemens */ 13149 ArthurClemens 13508 ByronDarrah function RowSelectionObject(asset_url) { 15314 ArthurClemens this.row = null; 15314 ArthurClemens this.rownum = null; 15314 ArthurClemens this.topSep = null; 15314 ArthurClemens this.bottomSep = null; 15314 ArthurClemens return this; 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 14104 ByronDarrah Construct an EditTable object. This includes building an array of all the 14104 ByronDarrah rows in a table, and making a map of row numbers to row positions (and the 14104 ByronDarrah reverse). 13149 ArthurClemens */ 13149 ArthurClemens 13149 ArthurClemens function EditTableObject(tableform, row_container) { 15314 ArthurClemens this.tableform = tableform; 15314 ArthurClemens this.rows = new Array(); 15314 ArthurClemens this.positions = new Array(); 15314 ArthurClemens this.revidx = new Array(); 15314 ArthurClemens this.numrows = 0; 16544 ArthurClemens this.headerRows = 0; 16544 ArthurClemens this.footerRows = 0; 15314 ArthurClemens this.last_separator = null; 15314 ArthurClemens var got_thead = 0; 15314 ArthurClemens var first_head = 0; 15314 ArthurClemens 15314 ArthurClemens 15314 ArthurClemens // If rows are contained in and elements, then we must be 15314 ArthurClemens // sure to iterate over all of them. 15314 ArthurClemens 15314 ArthurClemens while (row_container != null) { 16544 ArthurClemens 15314 ArthurClemens // If there were any rows before the first thead, we'll have to correct 15314 ArthurClemens // our notion of the row positions, because browsers display the header 15314 ArthurClemens // above the body instead of in the order they appear in the DOM. 15314 ArthurClemens 15314 ArthurClemens if (row_container.tagName == "THEAD" && got_thead == 0) { 15314 ArthurClemens first_head = this.numrows; 15314 ArthurClemens got_thead = 1; 15314 ArthurClemens } 16544 ArthurClemens 15314 ArthurClemens var row_elem = row_container.firstChild; 15314 ArthurClemens while (row_elem != null) { 15314 ArthurClemens if (row_elem.tagName == "TR") { 15314 ArthurClemens this.rows[this.numrows] = row_elem; 15314 ArthurClemens this.positions[this.numrows] = this.numrows - first_head; 15314 ArthurClemens this.revidx[this.numrows - first_head] = this.numrows; 15314 ArthurClemens this.numrows++; 15314 ArthurClemens } 15314 ArthurClemens row_elem = row_elem.nextSibling; 15314 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens // Now make any necessary position adjustments to account for an 15314 ArthurClemens // out-of-order THEAD. 16544 ArthurClemens 15314 ArthurClemens if (first_head > 0) { 15314 ArthurClemens var num_headrows = this.numrows - first_head; 15314 ArthurClemens for (var body_rownum = 0; body_rownum < first_head; body_rownum++) { 15314 ArthurClemens this.positions[body_rownum] = body_rownum + num_headrows; 15314 ArthurClemens this.revidx[body_rownum + num_headrows] = body_rownum; 15314 ArthurClemens } 15314 ArthurClemens first_head = 0; 16544 ArthurClemens } 15314 ArthurClemens 15314 ArthurClemens row_container = row_container.nextSibling; 13142 ByronDarrah } 15314 ArthurClemens return this; 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 13142 ByronDarrah 13149 ArthurClemens */ 13142 ByronDarrah // Update all row labels in a row by adding a delta amount to each one. 13142 ByronDarrah 13149 ArthurClemens function updateRowlabels(rownum, delta) { 16544 ArthurClemens if (!sEditTable) return; 15314 ArthurClemens var row = sEditTable.rows[rownum]; 15314 ArthurClemens var label_nodes = row.getElementsByTagName('DIV'); 16544 ArthurClemens 15314 ArthurClemens for (var i = 0; label_nodes[i] != null; i++) { 15314 ArthurClemens var lnode = label_nodes[i]; 15314 ArthurClemens if (lnode.className == 'et_rowlabel') { 15314 ArthurClemens var input_node = lnode.getElementsByTagName('INPUT').item(0); 15314 ArthurClemens var new_val = parseInt(input_node.value); 15314 ArthurClemens if (isNaN(new_val)) { 15314 ArthurClemens new_val = '????'; 15314 ArthurClemens } else { 15314 ArthurClemens new_val = '' + (new_val + delta); 15314 ArthurClemens } 15314 ArthurClemens input_node.value = new_val; 15314 ArthurClemens while (lnode.firstChild != null) { 15314 ArthurClemens lnode.removeChild(lnode.firstChild); 15314 ArthurClemens } 15314 ArthurClemens // Create a new row label span to replace the old one. 15314 ArthurClemens 15314 ArthurClemens var new_text = document.createTextNode(new_val); 15314 ArthurClemens lnode.appendChild(new_text); 15314 ArthurClemens lnode.appendChild(input_node); 15314 ArthurClemens } 13142 ByronDarrah } 15314 ArthurClemens 15314 ArthurClemens 13142 ByronDarrah } 13142 ByronDarrah 13149 ArthurClemens /** 15301 ArthurClemens Grabs the values from tags and inits the table with the table id and topic url. 15301 ArthurClemens */ 15314 ArthurClemens function init() { 16544 ArthurClemens var noJavascript = twiki.getMetaTag('EDITTABLEPLUGIN_NO_JAVASCRIPTINTERFACE_EditTableId'); 16544 ArthurClemens if (noJavascript) return; 16544 ArthurClemens var currentFormName = twiki.getMetaTag('EDITTABLEPLUGIN_FormName'); 15314 ArthurClemens var url = twiki.getMetaTag('EDITTABLEPLUGIN_EditTableUrl'); 16544 ArthurClemens var headerRows = parseInt(twiki.getMetaTag('EDITTABLEPLUGIN_headerRows')); 16544 ArthurClemens var footerRows = parseInt(twiki.getMetaTag('EDITTABLEPLUGIN_footerRows')); 16544 ArthurClemens edittableInit(currentFormName, url, headerRows, footerRows); 15301 ArthurClemens } 13149 ArthurClemens 15301 ArthurClemens /** 15301 ArthurClemens Copied from twikiEvent.js. 13149 ArthurClemens */ 15314 ArthurClemens function addLoadEvent(inFunction, inDoPrepend) { 15314 ArthurClemens if (typeof(inFunction) != "function") { 15314 ArthurClemens return; 15314 ArthurClemens } 15314 ArthurClemens var oldonload = window.onload; 15314 ArthurClemens if (typeof window.onload != 'function') { 15314 ArthurClemens window.onload = function() { 15314 ArthurClemens inFunction(); 15314 ArthurClemens }; 15314 ArthurClemens } else { 15314 ArthurClemens var prependFunc = function() { 15314 ArthurClemens inFunction(); 15314 ArthurClemens oldonload(); 15314 ArthurClemens }; 15314 ArthurClemens var appendFunc = function() { 15314 ArthurClemens oldonload(); 15314 ArthurClemens inFunction(); 15314 ArthurClemens }; 15314 ArthurClemens window.onload = inDoPrepend ? prependFunc: appendFunc; 15314 ArthurClemens } 15301 ArthurClemens } 15301 ArthurClemens 15301 ArthurClemens addLoadEvent(init); 15301 ArthurClemens 15301 ArthurClemens /** 15301 ArthurClemens 15301 ArthurClemens */ 13149 ArthurClemens // EOF: sEditTable.js svn log of EditTablePlugin svn log ------------------------------------------------------------------------ r17719 | PeterThoeny | 2008-11-03 07:34:08 +0100 (Mon, 03 Nov 2008) | 1 line Item6062: Fixed rendering of verbatim blocks when editing. Added parameter buttonrow=top (Thanks ArthurClemens) ------------------------------------------------------------------------ r17542 | ArthurClemens | 2008-09-27 01:12:01 +0200 (Sat, 27 Sep 2008) | 1 line Item6026: Let empty table initialize more than one column from =header= parameter ------------------------------------------------------------------------ r17541 | ArthurClemens | 2008-09-24 18:58:59 +0200 (Wed, 24 Sep 2008) | 1 line Item6019: fix parsing of header labels ------------------------------------------------------------------------ r17530 | ArthurClemens | 2008-09-21 17:40:34 +0200 (Sun, 21 Sep 2008) | 1 line Item6005: fix rendering of TML inside label cell (add space between TML and hidden html field) ------------------------------------------------------------------------ r17528 | GilmarSantosJr | 2008-09-21 15:25:47 +0200 (Sun, 21 Sep 2008) | 1 line Item5911: unit test updates for the new trunk UnitTestContrib ------------------------------------------------------------------------ r17320 | GilmarSantosJr | 2008-08-04 05:33:45 +0200 (Mon, 04 Aug 2008) | 1 line Item4662: action is no longer part of path_info ------------------------------------------------------------------------ r17303 | KennethLavrsen | 2008-08-03 23:19:20 +0200 (Sun, 03 Aug 2008) | 3 lines Item5875: Updating all the plugins that had missing config management info or just needed to be released now. ------------------------------------------------------------------------ r17086 | GilmarSantosJr | 2008-07-21 04:18:38 +0200 (Mon, 21 Jul 2008) | 1 line Item4662: Merge TSA to trunk (updates to unit tests of default plugins) ------------------------------------------------------------------------ r17059 | ArthurClemens | 2008-07-19 16:34:17 +0200 (Sat, 19 Jul 2008) | 1 line Item5794: fix topic rendering when EDITTABLE is followed by an empty line ------------------------------------------------------------------------ r16620 | ArthurClemens | 2008-04-07 14:47:36 +0200 (Mon, 07 Apr 2008) | 1 line Item5505: missing animation image in MANIFEST ------------------------------------------------------------------------ r16617 | ArthurClemens | 2008-04-07 14:45:09 +0200 (Mon, 07 Apr 2008) | 1 line Item5505: missing animation image in MANIFEST ------------------------------------------------------------------------ r16554 | ArthurClemens | 2008-03-24 20:06:50 +0100 (Mon, 24 Mar 2008) | 1 line Item5283: fix failing test due to different TablePlugin attributes setting ------------------------------------------------------------------------ r16547 | ArthurClemens | 2008-03-20 10:05:34 +0100 (Thu, 20 Mar 2008) | 1 line Item5283: fix BR inside table cells ------------------------------------------------------------------------ r16544 | ArthurClemens | 2008-03-20 00:22:43 +0100 (Thu, 20 Mar 2008) | 2 lines Item5283: fix of "dollar percent expansion does not work well together with SpreadSheetPlugin". Release note: Code refactoring; disabled table sort when editing; removed usage of $percnt to prevent variable expansion (is now done automatically); made Javascript interface aware of headers and footers, and of changerows="off"; improved feedback on row move. ------------------------------------------------------------------------ r16525 | ArthurClemens | 2008-03-15 01:25:48 +0100 (Sat, 15 Mar 2008) | 1 line Item5135: fix unintialized variable ------------------------------------------------------------------------ r16523 | ArthurClemens | 2008-03-15 01:23:30 +0100 (Sat, 15 Mar 2008) | 1 line Item5135: disable initsort when editing table: add parameter disableallsort="on" to the preceding or trailing TABLE tag ------------------------------------------------------------------------ r16417 | SvenDowideit | 2008-02-17 02:40:34 +0100 (Sun, 17 Feb 2008) | 1 line Item5341: Simplify subversion organisation ------------------------------------------------------------------------ r16240 | KennethLavrsen | 2008-01-16 02:10:41 +0100 (Wed, 16 Jan 2008) | 2 lines Item4902: Merge changes to MAIN ------------------------------------------------------------------------ r16181 | KennethLavrsen | 2008-01-09 11:19:10 +0100 (Wed, 09 Jan 2008) | 3 lines Item5217: Was adding the space when saving in function that was used elsewhere. Also reinserted the removal the space when you edit an empty cell. ------------------------------------------------------------------------ r16173 | KennethLavrsen | 2008-01-08 20:52:46 +0100 (Tue, 08 Jan 2008) | 9 lines Item5217: EditTablePlugin does unwanted merging of cells because it no longer leaves space in empty cell Note that this reverts the feature added for Item4910 Problem with 4910 is that is it not obvious for users that deleting the content of a table means merging with cell to the left. Users expect to get an empty cell. Using the plugin with real users has revealed this. A merge feature with EditTable will have to be engineered in a different way maybe with a backwards compatible EDITCELL feature. ------------------------------------------------------------------------ r16165 | ArthurClemens | 2008-01-08 00:53:30 +0100 (Tue, 08 Jan 2008) | 1 line Item5217: do not void cells with just spaces ------------------------------------------------------------------------ r16159 | ArthurClemens | 2008-01-06 14:07:06 +0100 (Sun, 06 Jan 2008) | 1 line Item5211: add space before linebreak to allow TML expansion ------------------------------------------------------------------------ r16157 | ArthurClemens | 2008-01-06 13:54:37 +0100 (Sun, 06 Jan 2008) | 1 line Item5210: forgot a writeDebug ------------------------------------------------------------------------ r16155 | ArthurClemens | 2008-01-06 13:45:09 +0100 (Sun, 06 Jan 2008) | 1 line Item5210: decode unicode linebreak back to
, except for textareas ------------------------------------------------------------------------ r16153 | ArthurClemens | 2008-01-06 00:49:42 +0100 (Sun, 06 Jan 2008) | 1 line Item5210: decode unicode linebreak back to
------------------------------------------------------------------------ r16150 | ArthurClemens | 2008-01-06 00:26:11 +0100 (Sun, 06 Jan 2008) | 1 line Item5208: do not right align EDITCELL elements ------------------------------------------------------------------------ r16148 | ArthurClemens | 2008-01-05 23:51:06 +0100 (Sat, 05 Jan 2008) | 1 line Item5211: remove added space after %BR% during editing; add space before linebreak to enable TML expansion ------------------------------------------------------------------------ r16127 | ArthurClemens | 2008-01-03 00:40:51 +0100 (Thu, 03 Jan 2008) | 1 line Item5189: another try to have EDITTABLE and TABLE on one line ------------------------------------------------------------------------ r16125 | ArthurClemens | 2008-01-02 23:43:59 +0100 (Wed, 02 Jan 2008) | 1 line Item5189: fix EDITTABLE before TABLE on two lines ------------------------------------------------------------------------ r16113 | ArthurClemens | 2007-12-28 16:59:27 +0100 (Fri, 28 Dec 2007) | 1 line Item5174: allow TABLE and EDITTABLE on 1 line ------------------------------------------------------------------------ r16098 | ArthurClemens | 2007-12-25 22:45:02 +0100 (Tue, 25 Dec 2007) | 1 line Item3368: give warning if include topic does not exist ------------------------------------------------------------------------ r16087 | ArthurClemens | 2007-12-22 03:48:06 +0100 (Sat, 22 Dec 2007) | 1 line Item3890: escape TWiki variables with formatting tokens ------------------------------------------------------------------------ r16050 | ArthurClemens | 2007-12-19 00:42:50 +0100 (Wed, 19 Dec 2007) | 1 line Item5149: escape quotes in example ------------------------------------------------------------------------ r16044 | ArthurClemens | 2007-12-19 00:11:43 +0100 (Wed, 19 Dec 2007) | 1 line Item5147: expand variables in format ------------------------------------------------------------------------ r16010 | KennethLavrsen | 2007-12-17 01:22:19 +0100 (Mon, 17 Dec 2007) | 9 lines Item5135: Item2690:: EditTablePlugin shuffles row sequence when the table also has a TABLE tag with initsort and remove sort links from headers when editing the table EditTable now defines a hidden form field sort which is sets to off. TablePlugin sees this and disable all header sorting as a result. EditTable additionally appends a new attribute disableallsort=on to the TABLE tag of the table being edited. This makes TablePlugin not initsort the table being edited. In 4.1.2 and earlier this sorting was OK. But with the new feature in EditTable where you can move rows up and down the sorting disturbs this feature. The table sorting is disabled because the user looses all edited data if he clicks on the header. ------------------------------------------------------------------------ r15979 | ArthurClemens | 2007-12-12 23:10:13 +0100 (Wed, 12 Dec 2007) | 1 line Item5019: pass edit table parameters when breaking the lease ------------------------------------------------------------------------ r15909 | ArthurClemens | 2007-12-06 11:56:00 +0100 (Thu, 06 Dec 2007) | 1 line Item3805: fix warnings in error log when no headerrows or footerrows have been set ------------------------------------------------------------------------ r15850 | ArthurClemens | 2007-12-03 21:01:36 +0100 (Mon, 03 Dec 2007) | 1 line Item3805: update unit test ------------------------------------------------------------------------ r15820 | ArthurClemens | 2007-12-01 15:17:49 +0100 (Sat, 01 Dec 2007) | 1 line Item4944: re-init variables to prevent data corruption under mod_perl ------------------------------------------------------------------------ r15815 | ArthurClemens | 2007-12-01 01:05:19 +0100 (Sat, 01 Dec 2007) | 1 line Item3805: remove printline ------------------------------------------------------------------------ r15813 | ArthurClemens | 2007-12-01 00:34:18 +0100 (Sat, 01 Dec 2007) | 3 lines Item3805: recognize TablePlugin's headerrows and footerrows Item4944: fix data corruption under mod_perl (to be tested) Update edit button; update doc; update tests ------------------------------------------------------------------------ r15755 | PeterThoeny | 2007-11-25 11:01:10 +0100 (Sun, 25 Nov 2007) | 1 line Item5006: Fixing broken bug links to Interwiki TWikibug links ------------------------------------------------------------------------ r15749 | PeterThoeny | 2007-11-25 09:23:24 +0100 (Sun, 25 Nov 2007) | 1 line Item3729: Fixing unit test issue, introduced by r15692 ------------------------------------------------------------------------ r15561 | AndreUlrich | 2007-11-12 16:15:52 +0100 (Mon, 12 Nov 2007) | 1 line Item4902: revert SYSTEMWEB and USERSWEB back to TWIKIWEB and MAINWEB for twikiplugins in order to make them work for earlier revisions. ------------------------------------------------------------------------ r15393 | ArthurClemens | 2007-10-22 22:57:53 +0200 (Mon, 22 Oct 2007) | 1 line Item4876: fix destroying of content ------------------------------------------------------------------------ r15354 | ArthurClemens | 2007-10-20 01:52:03 +0200 (Sat, 20 Oct 2007) | 1 line Item3890: do not expand escaped variables on edit or save, only on view ------------------------------------------------------------------------ r15349 | ArthurClemens | 2007-10-19 13:02:56 +0200 (Fri, 19 Oct 2007) | 1 line Item4843: fix failing test ------------------------------------------------------------------------ r15344 | ArthurClemens | 2007-10-19 00:45:34 +0200 (Fri, 19 Oct 2007) | 1 line Item4858: do not show a move button with only 1 row ------------------------------------------------------------------------ r15342 | ArthurClemens | 2007-10-18 21:54:05 +0200 (Thu, 18 Oct 2007) | 1 line Item4857: cosmetic update to move and delete buttons ------------------------------------------------------------------------ r15340 | ArthurClemens | 2007-10-18 21:46:53 +0200 (Thu, 18 Oct 2007) | 1 line Item4856: make buttons customizable and translatable ------------------------------------------------------------------------ r15338 | ArthurClemens | 2007-10-18 21:01:59 +0200 (Thu, 18 Oct 2007) | 1 line Item4854: provide default size for textarea ------------------------------------------------------------------------ r15336 | ArthurClemens | 2007-10-18 20:53:25 +0200 (Thu, 18 Oct 2007) | 1 line Item4848: fix repeated adding of spaces in textareas ------------------------------------------------------------------------ r15333 | ArthurClemens | 2007-10-18 20:50:20 +0200 (Thu, 18 Oct 2007) | 1 line Item2975: fix rendering of smilies and other variables ------------------------------------------------------------------------ r15321 | ArthurClemens | 2007-10-18 00:52:15 +0200 (Thu, 18 Oct 2007) | 1 line Item3009: fix spaces in input element definitions ------------------------------------------------------------------------ r15317 | ArthurClemens | 2007-10-17 20:39:33 +0200 (Wed, 17 Oct 2007) | 1 line Item4843: align="MIDDLE" should be align="middle" ------------------------------------------------------------------------ r15314 | ArthurClemens | 2007-10-17 14:20:30 +0200 (Wed, 17 Oct 2007) | 1 line Item4244: make accidental deletion more difficult by placing the delete button to the right; remove depedency on BehaviourContrib (although a js rewrite using behaviour would be good); improve user feedback when moving ------------------------------------------------------------------------ r15312 | ArthurClemens | 2007-10-17 12:03:43 +0200 (Wed, 17 Oct 2007) | 1 line Item4806: add dependency on BehaviourContrib ------------------------------------------------------------------------ r15305 | ArthurClemens | 2007-10-16 21:23:31 +0200 (Tue, 16 Oct 2007) | 1 line Item4806: fix bug in unit test ------------------------------------------------------------------------ r15301 | ArthurClemens | 2007-10-16 10:16:54 +0200 (Tue, 16 Oct 2007) | 1 line Item4806: fix adding rows; code refactoring; adding unit tests ------------------------------------------------------------------------ r15262 | ArthurClemens | 2007-10-13 01:59:34 +0200 (Sat, 13 Oct 2007) | 1 line Item3367: show the Edit button even if there is no empty line below EDITTABLE; added unit test files contain only one test yet ------------------------------------------------------------------------ r15182 | PeterThoeny | 2007-10-07 11:18:36 +0200 (Sun, 07 Oct 2007) | 1 line Item4182: Add VarEDITTABLE variable documentation ------------------------------------------------------------------------ r15181 | PeterThoeny | 2007-10-07 11:07:59 +0200 (Sun, 07 Oct 2007) | 1 line Item4182: Add VarEDITTABLE variable documentation ------------------------------------------------------------------------ r14751 | AndreUlrich | 2007-09-06 11:04:10 +0200 (Thu, 06 Sep 2007) | 1 line Item4497: modernise references to SYSTEMWEB and USERSWEB for shipped Plugins and Contribs (listed in TWikiReleaseNotes04x02) ------------------------------------------------------------------------ r14113 | ByronDarrah | 2007-06-13 20:34:57 +0200 (Wed, 13 Jun 2007) | 4 lines Item4029: Moving rows around with javascript revealed that inputElement was not reliably setting the value of date input fields. Needed to add the "override" option to the call to CGI::textfield(). ------------------------------------------------------------------------ r14108 | ByronDarrah | 2007-06-13 10:47:53 +0200 (Wed, 13 Jun 2007) | 3 lines Item4029: One more fix -- forgot to updaate doSaveTable routine with modified arg for handleTableRow. ------------------------------------------------------------------------ r14107 | ByronDarrah | 2007-06-13 10:35:21 +0200 (Wed, 13 Jun 2007) | 6 lines Item4029: Fixed bug that was introduced along with javascript enhancements that caused row additions to re-initialize rows at the bottom of the table. Also enhanced the use of the inputElement routine to properly handle labels who's rows may have been moved around by javascript, and therefore no longer correspond to the raw saved table text. ------------------------------------------------------------------------ r14106 | ByronDarrah | 2007-06-13 07:04:40 +0200 (Wed, 13 Jun 2007) | 4 lines Item4029: A simple fix to prevent deleting a row then adding a row from restoring the content of the deleted row. (This bug was not related to javascript.) ------------------------------------------------------------------------ r14104 | ByronDarrah | 2007-06-13 00:15:39 +0200 (Wed, 13 Jun 2007) | 3 lines Item4029: Fixed a minor bug in the way row selections are highlighted if there are non-THEAD rows preceding the first THEAD section in a table. ------------------------------------------------------------------------ r14101 | ByronDarrah | 2007-06-12 20:10:18 +0200 (Tue, 12 Jun 2007) | 2 lines Item4029: Removed an alert that was accidentally left in for debugging purposes. ------------------------------------------------------------------------ r14093 | ByronDarrah | 2007-06-12 05:38:06 +0200 (Tue, 12 Jun 2007) | 3 lines Item4029: Updated the dynamic HTML code for the EditTable plugin to better support editable tables with THEAD's and TBODY's. ------------------------------------------------------------------------ r14014 | CrawfordCurrie | 2007-06-02 10:06:27 +0200 (Sat, 02 Jun 2007) | 1 line Item3766: commented out gif file that isn't in SVN, so breaks a release build ------------------------------------------------------------------------ r13689 | CrawfordCurrie | 2007-05-11 13:03:36 +0200 (Fri, 11 May 2007) | 1 line Item4032: incorrect use of passthrough was wiping out the url parameters ------------------------------------------------------------------------ r13645 | WillNorris | 2007-05-06 11:46:27 +0200 (Sun, 06 May 2007) | 1 line Item4025: some scripts don't have their executable bit set ------------------------------------------------------------------------ r13508 | ByronDarrah | 2007-04-24 03:27:17 +0200 (Tue, 24 Apr 2007) | 3 lines Item3766: Updated UI to display moving dashes above and below the current row selection. ------------------------------------------------------------------------ r13263 | HaraldJoerg | 2007-04-04 03:05:43 +0200 (Wed, 04 Apr 2007) | 1 line Item3838: Fix Func::wikiToUserName and its EditTable symptom ------------------------------------------------------------------------ r13195 | ByronDarrah | 2007-03-20 03:36:50 +0100 (Tue, 20 Mar 2007) | 5 lines Item3766: Changed the UI metaphore for moving a row. Users now click on a thin area between rows to select a destination, instead of on the move button of a row in the destination position. ------------------------------------------------------------------------ r13166 | ArthurClemens | 2007-03-17 16:14:49 +0100 (Sat, 17 Mar 2007) | 1 line Item3766: fix icon links ------------------------------------------------------------------------ r13165 | ArthurClemens | 2007-03-17 15:37:16 +0100 (Sat, 17 Mar 2007) | 1 line Item3766: no forcing of bg color; fix for Behaviour bug that has crept in ------------------------------------------------------------------------ r13164 | ArthurClemens | 2007-03-17 14:32:48 +0100 (Sat, 17 Mar 2007) | 1 line Item3779: fix for "table with backslash breaks EditTablePlugin" ------------------------------------------------------------------------ r13163 | ArthurClemens | 2007-03-17 14:19:20 +0100 (Sat, 17 Mar 2007) | 1 line Item3779: fix for "table with backslash breaks EditTablePlugin" ------------------------------------------------------------------------ r13161 | ArthurClemens | 2007-03-17 13:26:13 +0100 (Sat, 17 Mar 2007) | 1 line Item3766: fixed bug where clicking on move scrolled page to top (changed this by adding a style); added ids to buttons to be able to catch clicks with behaviour.js ------------------------------------------------------------------------ r13149 | ArthurClemens | 2007-03-15 22:45:55 +0100 (Thu, 15 Mar 2007) | 1 line Item3766: Fixed eating of double newlines; icons for javascript buttons and interface improvements. By default the javascript interface is turned off, set =JAVASCRIPTINTERFACE= to use it in edit mode. ------------------------------------------------------------------------ r13142 | ByronDarrah | 2007-03-14 23:56:23 +0100 (Wed, 14 Mar 2007) | 1 line Item3766: Added ability to move and delete rows dynamically with Javascript. ------------------------------------------------------------------------ r12373 | KennethLavrsen | 2006-12-30 02:08:13 +0100 (Sat, 30 Dec 2006) | 4 lines Item3280: Follow up setting more universal access rights. This time for all default plugins. With 4.1.0 RC2 we will test carefully that this new approach works ------------------------------------------------------------------------ r12327 | HaraldJoerg | 2006-12-22 03:18:23 +0100 (Fri, 22 Dec 2006) | 1 line Item3338: Compare lock user and login user in EditTablePlugin ------------------------------------------------------------------------ r12319 | MichaelDaum | 2006-12-19 17:44:24 +0100 (Tue, 19 Dec 2006) | 3 lines Item3333: fixed topic format ------------------------------------------------------------------------ r12258 | PeterThoeny | 2006-12-14 20:57:04 +0100 (Thu, 14 Dec 2006) | 1 line Item3304: Author fix ------------------------------------------------------------------------ r12249 | PeterThoeny | 2006-12-14 01:57:56 +0100 (Thu, 14 Dec 2006) | 1 line Item3304: Doc fix, twiki.org doc sync ------------------------------------------------------------------------ r11918 | ThomasWeigert | 2006-11-06 21:32:01 +0100 (Mon, 06 Nov 2006) | 1 line Item2614: Allow redirect on leaseconflict for other than Edit.pm ------------------------------------------------------------------------ r11704 | CrawfordCurrie | 2006-10-11 22:39:07 +0200 (Wed, 11 Oct 2006) | 1 line Item2982: Removed uncalled handler from JSCalendarContrib, and added use of the default calendar format to EditTable and DateField. Use of multiple defaults has been confusing users. ------------------------------------------------------------------------ r11702 | PeterThoeny | 2006-10-11 19:18:28 +0200 (Wed, 11 Oct 2006) | 1 line Item2884: This should fix the permission check issue ------------------------------------------------------------------------ r11686 | KennethLavrsen | 2006-10-08 01:10:00 +0200 (Sun, 08 Oct 2006) | 1 line Item2956: Freeze TWikiRelease04x00 and copy it to new branch MAIN ------------------------------------------------------------------------ r11646 | PeterThoeny | 2006-10-02 17:59:46 +0200 (Mon, 02 Oct 2006) | 1 line Item2884: Check also for access permission in meta data; proper fix to not warn if oneself has a lock on topic ------------------------------------------------------------------------ r11392 | PeterThoeny | 2006-08-31 01:15:44 +0200 (Thu, 31 Aug 2006) | 1 line Item2829: Remove whitespace from select, radio and checkbox items; restored topic lock if ::Plugins::VERSION < 1.1 ------------------------------------------------------------------------ r11226 | SteffenPoulsen | 2006-07-29 09:46:05 +0200 (Sat, 29 Jul 2006) | 1 line Item2684: BuildContrib doesn't like absolute/Windows style paths for attachments ------------------------------------------------------------------------ r11225 | SteffenPoulsen | 2006-07-29 09:40:49 +0200 (Sat, 29 Jul 2006) | 1 line Item2684: Quietly ignore topic edit locks on table edit ------------------------------------------------------------------------ r10614 | SteffenPoulsen | 2006-06-16 09:11:30 +0200 (Fri, 16 Jun 2006) | 1 line Item2473: Setting explicit permissions for files in default plugin set (fallback permission is -r-xr-xr--, data/pub topics should at least be writable to user) ------------------------------------------------------------------------ r9598 | WillNorris | 2006-03-29 14:23:23 +0200 (Wed, 29 Mar 2006) | 1 line Item1984: fixing TOPICINFO's (author and version) ------------------------------------------------------------------------ r9376 | AndreUlrich | 2006-03-20 01:30:18 +0100 (Mon, 20 Mar 2006) | 1 line Item1664: corrected documentation of date format setting ------------------------------------------------------------------------ r8711 | SvenDowideit | 2006-02-07 07:19:28 +0100 (Tue, 07 Feb 2006) | 1 line Item00: TWiki-4.0 release maintenance branch ------------------------------------------------------------------------ r8414 | CrawfordCurrie | 2006-01-21 16:46:00 +0100 (Sat, 21 Jan 2006) | 1 line Item1446: minor fix to suppress apache log warning ------------------------------------------------------------------------ r8405 | CrawfordCurrie | 2006-01-21 13:29:30 +0100 (Sat, 21 Jan 2006) | 1 line Item1446: merged updates from zip on twiki.org ------------------------------------------------------------------------ r8237 | PeterThoeny | 2006-01-12 07:50:55 +0100 (Thu, 12 Jan 2006) | 1 line Item0: to fix to make it browser friendly ------------------------------------------------------------------------ r8154 | PeterThoeny | 2006-01-07 06:41:07 +0100 (Sat, 07 Jan 2006) | 1 line Item1343: Fix copyright notice for 2006 (only comment changes, no code changes) ------------------------------------------------------------------------ r8033 | AndreUlrich | 2005-12-30 15:57:36 +0100 (Fri, 30 Dec 2005) | 1 line Item0: documented JSCalendarContrib outsourcing, removed missed files ------------------------------------------------------------------------ r7830 | ArthurClemens | 2005-12-10 23:11:14 +0100 (Sat, 10 Dec 2005) | 1 line Item1132: updated the change history of the plugin ------------------------------------------------------------------------ r7829 | ArthurClemens | 2005-12-10 23:03:36 +0100 (Sat, 10 Dec 2005) | 1 line Item1132: documentation for setting EditTablePlugin styles; added a few more css styles to make the buttons more conform TWiki buttons; minor other documentation updates ------------------------------------------------------------------------ r7826 | ArthurClemens | 2005-12-10 01:45:01 +0100 (Sat, 10 Dec 2005) | 1 line Item1132: a few css styles for edittable ------------------------------------------------------------------------ r6935 | CrawfordCurrie | 2005-10-09 21:07:16 +0200 (Sun, 09 Oct 2005) | 1 line Item622: reverted 3 specs to tabs in Set lines in plugins topics for kompatterbility with Kigh-roe ------------------------------------------------------------------------ r6905 | CrawfordCurrie | 2005-10-09 12:10:27 +0200 (Sun, 09 Oct 2005) | 1 line Item622: tabs -> 3 spacesto avoid confusing the users ------------------------------------------------------------------------ r6850 | CrawfordCurrie | 2005-10-08 13:43:12 +0200 (Sat, 08 Oct 2005) | 1 line Item638: added instruction to run configure to all install docs (I hope) ------------------------------------------------------------------------ r6827 | CrawfordCurrie | 2005-10-07 21:13:28 +0200 (Fri, 07 Oct 2005) | 1 line Item569: added default RELEASE to everything that had a version, and removed a load of dead code that was getting in the way ------------------------------------------------------------------------ r6758 | CrawfordCurrie | 2005-10-04 20:50:23 +0200 (Tue, 04 Oct 2005) | 1 line Item569: computed version numbers for plugins from the repository rev they were built from. ------------------------------------------------------------------------ r6634 | CrawfordCurrie | 2005-09-27 19:37:46 +0200 (Tue, 27 Sep 2005) | 1 line Item453: removed EditTablePlugins private copy of the Mishoo JS calendar, and made sure it works with JSCalendarContrib. Improved the documentation of the JSCalendar while I was there. ------------------------------------------------------------------------ r6426 | CrawfordCurrie | 2005-09-18 16:55:52 +0200 (Sun, 18 Sep 2005) | 1 line Item404: removed CHANGELOG from MANIFEST and added build scripts for all plugins and contribs, so they can be used with the main build. ------------------------------------------------------------------------ r6175 | CrawfordCurrie | 2005-08-27 04:02:41 +0200 (Sat, 27 Aug 2005) | 1 line Item134: removed debugging ------------------------------------------------------------------------ r5876 | CrawfordCurrie | 2005-07-23 04:59:29 +0200 (Sat, 23 Jul 2005) | 1 line Item134: removed duplicate plugins from the core tree, and moved or copied (as appropriate) the updates over into the new twikiplugins tree. This is the first of several large checkins in this area. ------------------------------------------------------------------------ r5872 | CrawfordCurrie | 2005-07-23 02:40:44 +0200 (Sat, 23 Jul 2005) | 1 line Item134: deleting imported version so I can svn mv the version from the core ------------------------------------------------------------------------ r5013 | aclemens | 2004-07-28 12:47:04 +0200 (Wed, 28 Jul 2004) | 2 lines Changed onClick to onclick ------------------------------------------------------------------------ r4975 | maphew | 2004-05-06 22:29:55 +0200 (Thu, 06 May 2004) | 4 lines *non-maintainer update* synchronized with released zip version, which was ahead of the cvs version Internal plugin version: 07 Apr 2004 Zip version: 1.20 (http://twiki.org/cgi-bin/viewfile/Plugins/EditTablePlugin?rev=1.20&filename=EditTablePlugin.zip) ------------------------------------------------------------------------ r4920 | maphew | 2004-04-03 00:27:31 +0200 (Sat, 03 Apr 2004) | 4 lines *non-maintainer update* synchronized with released zip version, which was ahead of the cvs version Internal plugin version: 02 Mar 2004 Zip version: 1.19 (http://twiki.org/cgi-bin/viewfile/Plugins/EditTablePlugin?rev=1.19&filename=EditTablePlugin.zip) ------------------------------------------------------------------------ r4756 | svenud | 2003-01-18 11:37:26 +0100 (Sat, 18 Jan 2003) | 2 lines The checkin 15181 that changed the copyright in the .txt document svn diff -r 15181:15182 Index: data/TWiki/VarEDITTABLE.txt =================================================================== --- data/TWiki/VarEDITTABLE.txt (revision 15181) +++ data/TWiki/VarEDITTABLE.txt (revision 15182) @@ -1,12 +1,12 @@ %META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev$"}% %META:TOPICPARENT{name="TWikiVariables"}% #VarEDITTABLE ----+++ TABLE{ _attributes_ } -- edit TWiki tables using edit fields and other input fields +---+++ EDITTABLE{ _attributes_ } -- edit TWiki tables using edit fields and other input fields * The =%EDITTABLE{}%= variable is handled by the EditTablePlugin * Syntax: =%EDITTABLE{ _attributes_ }%= %STARTSECTION{"edittable_attributes"}% * Supported attributes: - | *Atribute* | *Comment* | *Default* | + | *Attribute* | *Comment* | *Default* | | =header= | Specify the header format of a new table like ="%VBAR%*Food*%VBAR%*Drink*%VBAR%"=. Useful to start a table with only a button | (no header) | | =format= | The format of one column when editing the table. A cell can be a text input field, or any of these edit field types:%BR% %BB% Text input field (1 line):%BR%   =%VBAR% text, <size>, <initial value> %VBAR%= %BR% %BB% Textarea input field:%BR%   =%VBAR% textarea, <rows>x<columns>, <initial value> %VBAR%= %BR% %BB% Drop down box: %BR%   =%VBAR% select, <size>, <option 1>, <option 2>, etc* %VBAR%= %BR%   =*= only one item can be selected %BR% %BB% Radio buttons: %BR%   =%VBAR% radio, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of buttons per line in edit mode %BR% %BB% Checkboxes: %BR%   =%VBAR% checkbox, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of checkboxes per line in edit mode %BR% %BB% Fixed label: %BR%   =%VBAR% label, 0, <label text> %VBAR%= %BR% %BB% Row number: %BR%   =%VBAR% row, <offset> %VBAR%= %BR% %BB% Date: %BR%   =%VBAR% date, <size>, <initial value>, <DHTML date format> %VBAR%= | ="text, 16"= %BR% for all cells | | =changerows= | Rows can be added and removed if ="on"=;
Rows can be added but not removed if ="add"= | =CHANGEROWS= %BR% Plugin setting | Index: data/TWiki/EditTablePlugin.txt =================================================================== --- data/TWiki/EditTablePlugin.txt (revision 15181) +++ data/TWiki/EditTablePlugin.txt (revision 15182) @@ -154,9 +154,9 @@ | Plugin Author: | TWiki:Main/PeterThoeny | | Copyright: | © 2002-2007, TWiki:Main.PeterThoeny ([[http://www.twiki.net/][TWIKI.NET]]) and TWiki Contributors | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | -| Plugin Version: | 07 Oct 2007 (15181) | +| Plugin Version: | 07 Oct 2007 (15182) | | Change History: |   | -| 07 Oct 2007: | 15181: PTh: Added %SYSTEMWEB%.VarEDITTABLE to have it listed in %SYSTEMWEB%.TWikiVariables | +| 07 Oct 2007: | 15182: PTh: Added %SYSTEMWEB%.VarEDITTABLE to have it listed in %SYSTEMWEB%.TWikiVariables | | 15 Mar 2007: | Arthur Clemens: Fixed eating of double newlines; icons for javascript buttons and interface improvements. By default the javascript interface is turned off, set =JAVASCRIPTINTERFACE= to use it in edit mode. | | 05 Mar 2007: | Byron Darrah: Added ability to dynamically move and delete rows. | | 12 Oct 2006: | Item2982 Use default date format from JSCalendarContrib | @@ -193,7 +193,7 @@ | Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | | Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal | -__Related Topics:__ %SYSTEMWEB%.TWikiPreferences, %SYSTEMWEB%.TWikiPlugins +__Related Topics:__ %SYSTEMWEB%.VarEDITTABLE, %SYSTEMWEB%.TWikiPreferences, %SYSTEMWEB%.TWikiPlugins -- TWiki:Main/PeterThoeny - 07 Oct 2007 [root@merlin EditTablePlugin]# svn diff -r 15180:15181 Index: lib/TWiki/Plugins/EditTablePlugin.pm =================================================================== --- lib/TWiki/Plugins/EditTablePlugin.pm (revision 15180) +++ lib/TWiki/Plugins/EditTablePlugin.pm (revision 15181) @@ -1,6 +1,7 @@ # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ # -# Copyright (C) 2002-2006 Peter Thoeny, peter@thoeny.org +# Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and TWiki +# Contributors. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -31,7 +32,7 @@ # This is a free-form string you can use to "name" your own plugin version. # It is *not* used by the build automation tools, but is reported as part # of the version number in PLUGINDESCRIPTIONS. -$RELEASE = 'any TWiki'; +$RELEASE = 'TWiki'; $encodeStart = '--EditTableEncodeStart--'; $encodeEnd = '--EditTableEncodeEnd--'; Index: lib/TWiki/Plugins/EditTablePlugin/Core.pm =================================================================== --- lib/TWiki/Plugins/EditTablePlugin/Core.pm (revision 15180) +++ lib/TWiki/Plugins/EditTablePlugin/Core.pm (revision 15181) @@ -1,6 +1,7 @@ # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ # -# Copyright (C) 2002-2006 Peter Thoeny, peter@thoeny.org +# Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and +# TWiki Contributors. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License Index: lib/TWiki/Plugins/EditTablePlugin/MANIFEST =================================================================== --- lib/TWiki/Plugins/EditTablePlugin/MANIFEST (revision 15180) +++ lib/TWiki/Plugins/EditTablePlugin/MANIFEST (revision 15181) @@ -1,4 +1,5 @@ data/TWiki/EditTablePlugin.txt 0644 +data/TWiki/VarEDITTABLE.txt 0644 lib/TWiki/Plugins/EditTablePlugin.pm 0444 lib/TWiki/Plugins/EditTablePlugin/Core.pm 0444 pub/TWiki/EditTablePlugin/btn_delete_disabled.gif 0644 Index: data/TWiki/VarEDITTABLE.txt =================================================================== --- data/TWiki/VarEDITTABLE.txt (revision 0) +++ data/TWiki/VarEDITTABLE.txt (revision 15181) @@ -0,0 +1,23 @@ +%META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev$"}% +%META:TOPICPARENT{name="TWikiVariables"}% +#VarEDITTABLE +---+++ TABLE{ _attributes_ } -- edit TWiki tables using edit fields and other input fields + * The =%EDITTABLE{}%= variable is handled by the EditTablePlugin + * Syntax: =%EDITTABLE{ _attributes_ }%= +%STARTSECTION{"edittable_attributes"}% + * Supported attributes: + | *Atribute* | *Comment* | *Default* | + | =header= | Specify the header format of a new table like ="%VBAR%*Food*%VBAR%*Drink*%VBAR%"=. Useful to start a table with only a button | (no header) | + | =format= | The format of one column when editing the table. A cell can be a text input field, or any of these edit field types:%BR% %BB% Text input field (1 line):%BR%   =%VBAR% text, <size>, <initial value> %VBAR%= %BR% %BB% Textarea input field:%BR%   =%VBAR% textarea, <rows>x<columns>, <initial value> %VBAR%= %BR% %BB% Drop down box: %BR%   =%VBAR% select, <size>, <option 1>, <option 2>, etc* %VBAR%= %BR%   =*= only one item can be selected %BR% %BB% Radio buttons: %BR%   =%VBAR% radio, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of buttons per line in edit mode %BR% %BB% Checkboxes: %BR%   =%VBAR% checkbox, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of checkboxes per line in edit mode %BR% %BB% Fixed label: %BR%   =%VBAR% label, 0, <label text> %VBAR%= %BR% %BB% Row number: %BR%   =%VBAR% row, <offset> %VBAR%= %BR% %BB% Date: %BR%   =%VBAR% date, <size>, <initial value>, <DHTML date format> %VBAR%= | ="text, 16"= %BR% for all cells | + | =changerows= | Rows can be added and removed if ="on"=;
Rows can be added but not removed if ="add"= | =CHANGEROWS= %BR% Plugin setting | + | =quietsave= | Quiet Save button is shown if ="on"=, hidden if ="off"= | =QUIETSAVE= %BR% Plugin setting | + | =include= | Other topic defining the EDITTABLE parameters. The first %EDITTABLE% in the topic is used. This is useful if you have many topics with the same table format and you want to update the format in one place. | (none) | + | =helptopic= | Topic name containing help text shown below the table when editing a table. The %STARTINCLUDE% and %STOPINCLUDE% variables can be used in the topic to specify what is shown. | (no help text) | + | =headerislabel= | Table header cells are read-only (labels) if ="on"=; header cells can be edited if ="off"= or "0" | ="on"= | + | =editbutton= | Set edit button text, e.g. ="Edit this table"=; set button image with alt text, e.g. ="Edit table, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/edittopic.gif"=; hide edit button at the end of the table with ="hide"= (Note: Button is automatically hidden if an edit button is present in a cell) | =EDITBUTTON= %BR% Plugin setting | +%ENDSECTION{"edittable_attributes"}% + * Example:%BR% + =%EDITTABLE{ format="| text, 20 | select, 1, one, two, three |" changerows="on" }%= %BR% + =| *Name* | *Type* |= %BR% + =| Foo | two |= + * Related: See EditTablePlugin for more details Index: data/TWiki/EditTablePlugin.txt =================================================================== --- data/TWiki/EditTablePlugin.txt (revision 15180) +++ data/TWiki/EditTablePlugin.txt (revision 15181) @@ -1,4 +1,4 @@ -%META:TOPICINFO{author="TWikiContributor" date="1173153552" format="1.1" reprev="1.1" version="1.1"}% +%META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev$"}% ---+!! Edit Table Plugin This plugin allows you to edit TWiki tables using edit fields and drop down boxes. Tables have an *[ Edit table ]* button if preceeded by an =%EDITTABLE{...}%= variable. Each column can be a text field, a drop down box, a date field, etc. Multiple tables per topic are editable, but only one at a time can be edited. @@ -7,18 +7,9 @@ ---++ Per Table Settings -Add a =%EDITTABLE{...}%= variable just before an existing table to make it editable, or add the variable anywhere in a topic to start a new table. Parameters: +Add a =%EDITTABLE{...}%= variable just before an existing table to make it editable, or add the variable anywhere in a topic to start a new table. +%INCLUDE{"%SYSTEMWEB%.VarEDITTABLE" section="edittable_attributes"}% -| *Parameter* | *Comment* | *Default* | -| =header= | Specify the header format of a new table like ="%VBAR%*Food*%VBAR%*Drink*%VBAR%"=. Useful to start a table with only a button | (no header) | -| =format= | The format of one column when editing the table. A cell can be a text input field, or any of these edit field types:%BR% %BB% Text input field (1 line):%BR%   =%VBAR% text, <size>, <initial value> %VBAR%= %BR% %BB% Textarea input field:%BR%   =%VBAR% textarea, <rows>x<columns>, <initial value> %VBAR%= %BR% %BB% Drop down box: %BR%   =%VBAR% select, <size>, <option 1>, <option 2>, etc* %VBAR%= %BR%   =*= only one item can be selected %BR% %BB% Radio buttons: %BR%   =%VBAR% radio, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of buttons per line in edit mode %BR% %BB% Checkboxes: %BR%   =%VBAR% checkbox, <size*>, <option 1>, <option 2>, etc %VBAR%= %BR%   =*= size indicates the number of checkboxes per line in edit mode %BR% %BB% Fixed label: %BR%   =%VBAR% label, 0, <label text> %VBAR%= %BR% %BB% Row number: %BR%   =%VBAR% row, <offset> %VBAR%= %BR% %BB% Date: %BR%   =%VBAR% date, <size>, <initial value>, <DHTML date format> %VBAR%= | ="text, 16"= %BR% for all cells | -| =changerows= | Rows can be added and removed if ="on"=;
Rows can be added but not removed if ="add"= | =CHANGEROWS= %BR% Plugin setting | -| =quietsave= | Quiet Save button is shown if ="on"=, hidden if ="off"= | =QUIETSAVE= %BR% Plugin setting | -| =include= | Other topic defining the EDITTABLE parameters. The first %EDITTABLE% in the topic is used. This is useful if you have many topics with the same table format and you want to update the format in one place. | (none) | -| =helptopic= | Topic name containing help text shown below the table when editing a table. The %STARTINCLUDE% and %STOPINCLUDE% variables can be used in the topic to specify what is shown. | (no help text) | -| =headerislabel= | Table header cells are read-only (labels) if ="on"=; header cells can be edited if ="off"= or "0" | ="on"= | -| =editbutton= | Set edit button text, e.g. ="Edit this table"=; set button image with alt text, e.g. ="Edit table, %PUBURL%/%SYSTEMWEB%/TWikiDocGraphics/edittopic.gif"=; hide edit button at the end of the table with ="hide"= (Note: Button is automatically hidden if an edit button is present in a cell) | =EDITBUTTON= %BR% Plugin setting | - ---+++ Initial Values By default, variables in =<initial value>= (of text input field) and =<label text>= (of fixed label) get expanded when a new row is added. This can be used for example to add a timestamp to a label. You can escape characters if you do not want that: @@ -160,11 +151,12 @@ ---++ Plugin Info -| Plugin Author: | [[http://www.structuredwikis.com/][Peter Thoeny]] | -| Copyright: | © 2002-2006, TWiki:Main.PeterThoeny | +| Plugin Author: | TWiki:Main/PeterThoeny | +| Copyright: | © 2002-2007, TWiki:Main.PeterThoeny ([[http://www.twiki.net/][TWIKI.NET]]) and TWiki Contributors | | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | -| Plugin Version: | %$VERSION% | +| Plugin Version: | 07 Oct 2007 (15181) | | Change History: |   | +| 07 Oct 2007: | 15181: PTh: Added %SYSTEMWEB%.VarEDITTABLE to have it listed in %SYSTEMWEB%.TWikiVariables | | 15 Mar 2007: | Arthur Clemens: Fixed eating of double newlines; icons for javascript buttons and interface improvements. By default the javascript interface is turned off, set =JAVASCRIPTINTERFACE= to use it in edit mode. | | 05 Mar 2007: | Byron Darrah: Added ability to dynamically move and delete rows. | | 12 Oct 2006: | Item2982 Use default date format from JSCalendarContrib | @@ -203,7 +195,7 @@ __Related Topics:__ %SYSTEMWEB%.TWikiPreferences, %SYSTEMWEB%.TWikiPlugins --- TWiki:Main/PeterThoeny - 02 Oct 2006 +-- TWiki:Main/PeterThoeny - 07 Oct 2007 %META:FILEATTACHMENT{name="EditTablePluginCalendarExample.gif" attr="h" comment="" date="1071283396" path="EditTablePluginCalendarExample.gif" size="7823" user="TWikiContributor" version="1.1"}% %META:FILEATTACHMENT{name="ScreenshotEditCell1.gif" attr="h" comment="Screenshot" date="1077050633" path="ScreenshotEditCell1.gif" size="2017" user="TWikiContributor" version="1.1"}% [root@merlin EditTablePlugin]#