Changeset 397


Ignore:
Timestamp:
11/02/08 00:57:59 (4 years ago)
Author:
ArthurClemens
Message:

Item6062: Fixed rendering of =verbatim= blocks when editing. Added parameter =buttonrow="top"= to allow the buttons to be positioned at the top of the table.

Location:
branches/Release04x02/twikiplugins/EditTablePlugin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/Release04x02/twikiplugins/EditTablePlugin/data/TWiki/EditTablePlugin.txt

    r11 r397  
    1 %META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev: 17542 $"}% 
     1%META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev: 17303 $"}% 
    22---+!! Edit Table Plugin 
    33 
     
    211211---++ Plugin Info 
    212212 
    213 |  Plugin Author: | TWiki:Main/PeterThoeny | 
    214 |  Copyright: | © 2002-2008, TWiki:Main.PeterThoeny ([[http://www.twiki.net/][TWIKI.NET]]) and TWiki Contributors | 
     213|  Plugin Author: | Arthur Clemens | 
     214|  Copyright: | © 2008, Arthur Clemens |  
     215|  Based on: | TWiki:Plugins.EditTablePlugin © 2002-2008, TWiki:Main.PeterThoeny and TWiki Contributors | 
    215216|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | 
    216 |  Plugin Version: | 4.8.7 (26 Sep 2008) | 
     217|  Plugin Version: | 4.9 (01 Nov 2008) | 
    217218|  Change History: | <!-- specify latest version first -->&nbsp; | 
    218 |  26 Sep 2008: | 4.8.7 Let empty table initialize more than one column from =header= parameter | 
    219 |  24 Sep 2008: | 4.8.6 Fix parsing of header labels | 
    220 |  21 Sep 2008: | 4.8.5 Fix rendering of TML inside label | 
    221 |  03 Aug 2008: | 4.8.4 TWiki 4.2.1 release version | 
    222 |  19 Jul 2008: | 4.8.3 Bugfix release | 
     219|  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. | 
     220|  26 Sep 2008: | 4.8.7: Arthur Clemens: Let empty table initialize more than one column from =header= parameter | 
     221|  24 Sep 2008: | 4.8.6: Arthur Clemens: Fix parsing of header labels | 
     222|  21 Sep 2008: | 4.8.5: Arthur Clemens: Fix rendering of TML inside label | 
     223|  03 Aug 2008: | 4.8.4: TWiki 4.2.1 release version | 
     224|  19 Jul 2008: | 4.8.3: Bugfix release | 
    223225|  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. | 
    224226|  25 Dec 2007: | 4.7.1: Arthur Clemens: Added warning if =include= parameter topic does not exist. | 
    225227|  22 Dec 2007: | 4.7: Arthur Clemens: Changed handling of escaped variables. To escape TWiki variable, use formatting tokens such as =$percnt=. | 
    226 |  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. | 
    227 |  01 Dec 2007: | 4.3:  Arthur Clemens: added support for TablePlugin =headerrows= and =footerrows=; updated edit button | 
    228 |  16 Oct 2007: | 4.2:  Arthur Clemens: refactoring, bug fixes. | 
     228|  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. | 
     229|  01 Dec 2007: | 4.3: Arthur Clemens: added support for TablePlugin =headerrows= and =footerrows=; updated edit button | 
     230|  16 Oct 2007: | 4.2: Arthur Clemens: refactoring, bug fixes. | 
    229231|  07 Oct 2007: | 15182: PTh: Added %TWIKIWEB%.VarEDITTABLE to have it listed in %TWIKIWEB%.TWikiVariables | 
    230232|  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. | 
     
    259261|  Dependencies: | %$DEPENDENCIES% | 
    260262|  Perl Version: | 5.0 | 
    261 |  TWiki:Plugins/Benchmark: | %TWIKIWEB%.GoodStyle 98%, %TWIKIWEB%.FormattedSearch 98%, %TOPIC% 95% | 
    262263|  Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% | 
    263264|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | 
    264265|  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal | 
    265  
    266 __Related Topics:__  %TWIKIWEB%.VarEDITTABLE, %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins 
    267266 
    268267%META:FILEATTACHMENT{name="EditTablePluginCalendarExample.gif" attr="h" comment="" date="1071283396" path="EditTablePluginCalendarExample.gif" size="7823" user="TWikiContributor" version="1.1"}% 
  • branches/Release04x02/twikiplugins/EditTablePlugin/data/TWiki/VarEDITTABLE.txt

    r3 r397  
    1616     | =headerislabel= | Table header cells are read-only (labels) if ="on"=; header cells can be edited if ="off"= or "0" | ="on"= | 
    1717     | =editbutton= | Set edit button text, e.g. ="Edit this table"=; set button image with alt text, e.g. ="Edit table, %<nop>PUBURL%/%<nop>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 | 
     18     | =buttonrow= | Set to =top= to put the edit buttons above the table. | =bottom= | 
    1819     | =javascriptinterface= | Use javascript to directly move and delete row without page refresh. Enable with ="on"=, disable with ="off"=. | =JAVASCRIPTINTERFACE= %BR% plugin setting | 
    1920%ENDSECTION{"edittable_attributes"}% 
  • branches/Release04x02/twikiplugins/EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin.pm

    r11 r397  
    11# Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ 
    22# 
     3# Copyright (C) 2008 Arthur Clemens, arthur@visiblearea.com 
    34# Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and TWiki 
    45# Contributors. 
     
    2829); 
    2930 
    30 # This should always be $Rev: 17542 $ so that TWiki can determine the checked-in 
     31# This should always be $Rev: 17303 $ so that TWiki can determine the checked-in 
    3132# status of the plugin. It is used by the build automation tools, so 
    3233# you should leave it alone. 
    33 $VERSION = '$Rev: 17542 $'; 
     34$VERSION = '$Rev: 17303 $'; 
    3435 
    3536# This is a free-form string you can use to "name" your own plugin version. 
    3637# It is *not* used by the build automation tools, but is reported as part 
    3738# of the version number in PLUGINDESCRIPTIONS. 
    38 $RELEASE = '4.8.7'; 
     39$RELEASE = '4.9'; 
    3940 
    4041$encodeStart = '--EditTableEncodeStart--'; 
     
    7879    return unless $_[0] =~ /%EDIT(TABLE|CELL){(.*)}%/os; 
    7980    require TWiki::Plugins::EditTablePlugin::Core; 
    80     TWiki::Plugins::EditTablePlugin::Core::preProcessSpreadsheetPluginTags( 
     81    TWiki::Plugins::EditTablePlugin::Core::protectVariables( 
    8182        $_[0] ); 
    8283} 
  • branches/Release04x02/twikiplugins/EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin/Core.pm

    r3 r397  
    11# Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ 
    22# 
     3# Copyright (C) 2008 Arthur Clemens, arthur@visiblearea.com 
    34# Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and 
    45# TWiki Contributors. 
     
    3233); 
    3334 
    34 my $RENDER_HACK        = "\n<nop>\n"; 
    35 my $DEFAULT_FIELD_SIZE = 16; 
    36  
    37 BEGIN { 
    38     %regex                    = (); 
    39     $regex{edit_table_plugin} = '%EDITTABLE{(.*?)}%'; 
    40     $regex{table_plugin}      = '%TABLE(?:{(.*?)})?%'; 
    41     $regex{table_row_full}    = '^(\s*)\|.*\|\s*$'; 
    42     $regex{table_row}         = '^(\s*)\|(.*)'; 
    43 } 
     35my $RENDER_HACK                  = "\n<nop>\n"; 
     36my $DEFAULT_FIELD_SIZE           = 16; 
     37my $PLACEHOLDER_BUTTONROW_TOP    = 'PLACEHOLDER_BUTTONROW_TOP'; 
     38my $PLACEHOLDER_BUTTONROW_BOTTOM = 'PLACEHOLDER_BUTTONROW_BOTTOM'; 
     39my $STUB_VARIABLE                = 'E_T_P_NOP'; 
     40 
     41my %regex                    = (); 
     42$regex{edit_table_plugin} = '%EDITTABLE{(.*?)}%'; 
     43$regex{table_plugin}      = '%TABLE(?:{(.*?)})?%'; 
     44$regex{table_row_full}    = '^(\s*)\|.*\|\s*$'; 
     45$regex{table_row}         = '^(\s*)\|(.*)'; 
    4446 
    4547sub init { 
     
    6567} 
    6668 
    67 sub preProcessSpreadsheetPluginTags { 
     69=pod 
     70 
     71---+++ protectVariables ($text) 
     72 
     73Called during beforeCommonTagsHandler. 
     74Escapes variables by placing $STUB_VARIABLE inside each variable. 
     75This stub is removed later on (inside handleTableRow). 
     76 
     77=cut 
     78 
     79sub protectVariables { 
     80 
     81    #my $text = $_[0] 
     82 
    6883    $query = TWiki::Func::getCgiQuery(); 
    6984    if ( ( $query->param('etedit') ) && ( $query->param('ettablenr') ) ) { 
     
    7287        my ( $tablesTakenOutText, @tableTextRefs ) = 
    7388          $tmptable->parseText( $_[0] ); 
    74         my $tableNr   = 1; 
     89        my $tableNr   = 1;    # starting point 
    7590        my $tableDone = 0; 
    7691        foreach my $tableTextRef (@tableTextRefs) { 
     
    7994            if ( !$tableDone && $tableNr eq $paramTableNr ) { 
    8095 
    81                 # escape variables 
    82                 $tableText =~ s/%(.*?\{*.*?\}*)%/%E_T_P_NOP$1%/go; 
    83                 $tableText =~ s/%E_T_P_NOPBR%/&#10;/go; 
    84                 $tableDone = 1; 
     96                # only do the one table that is being edited 
     97                my $inRe = ' 
     98                %                               # start of variable 
     99                (                               # group at index 1 
     100                .*?                             # variable name 
     101                \{*.*?\}*               # variable contents inside braces, if any 
     102                )                               # 
     103                %                               # end of variable'; 
     104                $tableText =~ s/$inRe/%$STUB_VARIABLE$1%/gox; 
     105                $tableText =~ s/%$STUB_VARIABLE\BR%/&#10;/go 
     106                  ;    # replace escaped %BR% with newline 
     107                my $tag = 'verbatim'; 
     108                $tableText =~ 
     109s/\<$tag\>(.*?)\<\/$tag\>/<$STUB_VARIABLE$tag>$1<\/$STUB_VARIABLE$tag>/go 
     110                  ; # put stub inside verbatim to prevent the renderer to take out the verbatim block (which is unwanted in edit mode) 
     111                $tableDone = 1;  # mark no longer necessary to find other tables 
    85112            } 
    86113            $tableText = $editTableTag . "\n" . $tableText; 
     
    512539        # START PUT PROCESSED TABLE BACK IN TEXT 
    513540        my $resultText = join( "", @result ); 
     541 
     542        # button row at top or bottom 
     543        if ( !$doSave ) { 
     544            my $pos = $params{'buttonrow'} || 'bottom'; 
     545            my $buttonRow = createButtonRow( $theWeb, $theTopic, $includingWeb, 
     546                $includingTopic, $doEdit ); 
     547            if ( $pos eq 'top' ) { 
     548                $resultText =~ s/$PLACEHOLDER_BUTTONROW_BOTTOM//go;    # remove 
     549                $resultText =~ s/$PLACEHOLDER_BUTTONROW_TOP/$buttonRow/go; 
     550            } 
     551            else { 
     552                $resultText =~ s/$PLACEHOLDER_BUTTONROW_TOP//go;       # remove 
     553                $resultText =~ s/$PLACEHOLDER_BUTTONROW_BOTTOM/$buttonRow/go; 
     554            } 
     555        } 
     556 
    514557        if ( $doEdit && !$doSave && ( $paramTableNr == $tableNr ) ) { 
    515558            insertTmpTagInTableTagLine( $editTableTag, 
     
    596639    $$theHashRef{'javascriptinterface'} = $tmp if ($tmp); 
    597640 
     641    $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'buttonrow' ); 
     642    $$theHashRef{'buttonrow'} = $tmp if ($tmp); 
     643 
    598644    return; 
    599645} 
     
    644690        'editbutton'          => '', 
    645691        'javascriptinterface' => '', 
     692        'buttonrow'           => '', 
    646693    ); 
    647694    $warningMessage = ''; 
     
    735782    $text .= 
    736783      "$preSp<form name=\"$formName\" action=\"$viewUrl\" method=\"post\">\n"; 
     784 
     785    $text .= $PLACEHOLDER_BUTTONROW_TOP; 
     786 
    737787    $text .= hiddenField( $preSp, 'ettablenr', $theTableNr, "\n" ); 
    738788    $text .= hiddenField( $preSp, 'etedit',    'on',        "\n" ) 
     
    772822      if $addedRowCount; 
    773823 
     824    $text .= $PLACEHOLDER_BUTTONROW_BOTTOM; 
     825 
     826    $text .= "$preSp</form>\n"; 
     827    $text .= "</div><!-- /editTable -->"; 
     828    $text .= "</noautolink>" if $doEdit; 
     829 
     830    #    $text .= "\n"; 
     831    return $text; 
     832} 
     833 
     834=pod 
     835 
     836=cut 
     837 
     838sub createButtonRow { 
     839    my ( $theWeb, $theTopic, $includingWeb, $includingTopic, $doEdit ) = @_; 
     840 
     841    my $text = ''; 
    774842    if ( $doEdit && ( "$theWeb.$theTopic" eq "$includingWeb.$includingTopic" ) ) 
    775843    { 
     
    837905        } 
    838906    } 
    839     $text .= "$preSp</form>\n"; 
    840     $text .= "</div><!-- /editTable -->"; 
    841     $text .= "</noautolink>" if $doEdit; 
    842  
    843     #    $text .= "\n"; 
    844907    return $text; 
    845908} 
     
    12491312 
    12501313            $cell =~ 
    1251               s/E_T_P_NOP//go;    # remove escaping of variables inside cells 
     1314              s/$STUB_VARIABLE//go;  # remove escaping of variables inside cells 
    12521315 
    12531316            if ($isNewRowFromHeader) { 
  • branches/Release04x02/twikiplugins/EditTablePlugin/pub/TWiki/EditTablePlugin/edittable.css

    r3 r397  
    22.editTable { 
    33        padding-bottom:1em; 
     4} 
     5.editTableEdit .twikiTable { 
     6        margin:5px 0; 
    47} 
    58.editTableInnerTable table, 
     
    811        border:none; 
    912        padding-top:0; 
    10         margin-top:0; 
     13} 
     14.editTableEditImageButton { 
     15        margin:3px 0; 
    1116} 
    1217 
  • branches/Release04x02/twikiplugins/EditTablePlugin/test/unit/EditTablePlugin/EditTablePluginTests.pm

    r21 r397  
    2626    $TWiki::cfg{AntiSpam}{RobotsAreWelcome} = 1; 
    2727    $TWiki::cfg{AllowInlineScript} = 0; 
    28  
    29 #$TWiki::cfg{TablePlugin}{Attributes} = 'tableborder="1" cellpadding="0" cellspacing="0" valign="top" headercolor="#252b37" headerbg="#d8dde4" headerbgsorted="#ced4dd" headercolor="#252b37" databg="#ffffff,#f2f3f6" databgsorted="#f3f5f7,#e7e9ee" tablerules="cols"'; 
     28    $TWiki::cfg{TablePlugin}{Attributes} = 'tableborder="1" cellpadding="0" cellspacing="0" valign="top" headercolor="#252b37" headerbg="#d8dde4" headerbgsorted="#ced4dd" headercolor="#252b37" databg="#ffffff,#f2f3f6" databgsorted="#f3f5f7,#e7e9ee" tablerules="cols"'; 
    3029 
    3130    $ENV{SCRIPT_NAME} = '';    #  required by fake sort URLs in expected text 
     
    4847    } 
    4948 
     49 
    5050    # remove ever changing bgcolors from table cells 
    5151    # as well as the rules property 
    5252    # these are not important for these tests now 
    5353    $expected =~ s/bgcolor\=\"*\#[a-z0-9]{6}\"*//go; 
    54     $actual   =~ s/bgcolor\=\"*\#[a-z0-9]{6}\"*//go; 
     54    $actual =~ s/bgcolor\=\"*\#[a-z0-9]{6}\"*//go; 
    5555    $expected =~ s/rules\=\"*(cols|rows|all)\"*//go; 
    56     $actual   =~ s/rules\=\"*(cols|rows|all)\"*//go; 
     56    $actual =~ s/rules\=\"*(cols|rows|all)\"*//go; 
    5757 
    5858    $this->assert_html_equals( $expected, $actual ); 
     
    271271</div><!-- /editTable --></noautolink> 
    272272EXPECTED 
    273  
     273     
    274274    $this->do_testHtmlOutput( $expected, $result, 0 ); 
    275275 
     
    354354 
    355355    $twiki = new TWiki( undef, $query ); 
    356     my $response = new Unit::Response; 
     356        my $response = new Unit::Response; 
    357357    $TWiki::Plugins::SESSION = $twiki; 
    358358 
    359359    my ( $saveResult, $ecode ) = $this->capture( 
    360360        sub { 
    361             $response->body( 
    362                 TWiki::Func::expandCommonVariables( 
    363                     $input, $this->{test_topic}, $this->{test_web}, undef 
    364                 ) 
    365             ); 
     361            $response->body(TWiki::Func::expandCommonVariables( $input, 
     362                $this->{test_topic}, $this->{test_web}, undef ) ); 
    366363        } 
    367364    ); 
     
    661658 
    662659    $twiki = new TWiki( undef, $query ); 
    663     my $response = new Unit::Response; 
     660        my $response = new Unit::Response; 
    664661    $TWiki::Plugins::SESSION = $twiki; 
    665662 
    666663    my ( $saveResult, $ecode ) = $this->capture( 
    667664        sub { 
    668             $response->body( 
    669                 TWiki::Func::expandCommonVariables( 
    670                     $input, $this->{test_topic}, $this->{test_web}, undef 
    671                 ) 
    672             ); 
     665            $response->body( TWiki::Func::expandCommonVariables( $input, 
     666                $this->{test_topic}, $this->{test_web}, undef ) ); 
    673667        } 
    674668    ); 
     
    731725 
    732726    $twiki = new TWiki( undef, $query ); 
    733     my $response = new Unit::Response; 
     727        my $response = new Unit::Response; 
    734728    $TWiki::Plugins::SESSION = $twiki; 
    735729 
    736730    my ( $saveResult, $ecode ) = $this->capture( 
    737731        sub { 
    738             $response->body( 
    739                 TWiki::Func::expandCommonVariables( 
    740                     $input, $this->{test_topic}, $this->{test_web}, undef 
    741                 ) 
    742             ); 
     732            $response->body( TWiki::Func::expandCommonVariables( $input, 
     733                $this->{test_topic}, $this->{test_web}, undef ) ); 
    743734        } 
    744735    ); 
     
    768759 
    769760sub test_keepSpacesInEmptyCellsWithTexts { 
    770     my $this      = shift; 
     761    my $this = shift; 
    771762    my $topicName = $this->{test_topic}; 
    772763    my $webName   = $this->{test_web}; 
     
    790781    my $twiki = new TWiki( undef, $query ); 
    791782    $TWiki::Plugins::SESSION = $twiki; 
    792     $query                   = new Unit::Request( 
     783    $query = new Unit::Request( 
    793784        { 
    794785            etsave    => ['on'], 
     
    800791        $input ); 
    801792    $twiki = new TWiki( undef, $query ); 
    802     my $response = new Unit::Response; 
     793        my $response = new Unit::Response; 
    803794    $TWiki::Plugins::SESSION = $twiki; 
    804795    my ( $saveResult, $ecode ) = $this->capture( 
    805796        sub { 
    806             $response->body( 
    807                 TWiki::Func::expandCommonVariables( 
    808                     $input, $this->{test_topic}, $this->{test_web}, undef 
    809                 ) 
    810             ); 
     797            $response->body(TWiki::Func::expandCommonVariables( $input, 
     798                $this->{test_topic}, $this->{test_web}, undef ) ); 
    811799        } 
    812800    ); 
     
    829817 
    830818sub test_keepSpacesInEmptyCellsWithDates { 
    831     my $this      = shift; 
     819    my $this = shift; 
    832820    my $topicName = $this->{test_topic}; 
    833821    my $webName   = $this->{test_web}; 
     
    852840    my $twiki = new TWiki( undef, $query ); 
    853841    $TWiki::Plugins::SESSION = $twiki; 
    854     $query                   = new Unit::Request( 
     842    $query = new Unit::Request( 
    855843        { 
    856844            etsave    => ['on'], 
     
    862850        $input ); 
    863851    $twiki = new TWiki( undef, $query ); 
    864     my $response = new Unit::Response; 
     852        my $response = new Unit::Response; 
    865853    $TWiki::Plugins::SESSION = $twiki; 
    866854    my ( $saveResult, $ecode ) = $this->capture( 
    867855        sub { 
    868             $response->body( 
    869                 TWiki::Func::expandCommonVariables( 
    870                     $input, $this->{test_topic}, $this->{test_web}, undef 
    871                 ) 
    872             ); 
     856            $response->body(TWiki::Func::expandCommonVariables( $input, 
     857                $this->{test_topic}, $this->{test_web}, undef ) ); 
    873858        } 
    874859    ); 
     
    895880 
    896881sub test_addSpacesToEmptyCells { 
    897     my $this      = shift; 
     882    my $this = shift; 
    898883    my $topicName = $this->{test_topic}; 
    899884    my $webName   = $this->{test_web}; 
     
    916901    my $twiki = new TWiki( undef, $query ); 
    917902    $TWiki::Plugins::SESSION = $twiki; 
    918     $query                   = new Unit::Request( 
     903    $query = new Unit::Request( 
    919904        { 
    920905            etsave    => ['on'], 
     
    926911        $input ); 
    927912    $twiki = new TWiki( undef, $query ); 
    928     my $response = new Unit::Response; 
     913        my $response = new Unit::Response; 
    929914    $TWiki::Plugins::SESSION = $twiki; 
    930915    my ( $saveResult, $ecode ) = $this->capture( 
    931916        sub { 
    932             $response->body( 
    933                 TWiki::Func::expandCommonVariables( 
    934                     $input, $this->{test_topic}, $this->{test_web}, undef 
    935                 ) 
    936             ); 
     917            $response->body(TWiki::Func::expandCommonVariables( $input, 
     918                $this->{test_topic}, $this->{test_web}, undef ) ); 
    937919        } 
    938920    ); 
     
    968950 
    969951    my $result = 
    970       TWiki::Func::expandCommonVariables( $input, $topicName, $webName, undef ); 
    971  
     952      TWiki::Func::expandCommonVariables( $input, $topicName, 
     953        $webName, undef ); 
     954         
    972955    my $expected = <<NEWEXPECTED; 
    973956<a name="edittable1"></a> 
     
    992975 
    993976sub test_keepStars { 
    994     my $this      = shift; 
     977    my $this = shift; 
    995978    my $topicName = $this->{test_topic}; 
    996979    my $webName   = $this->{test_web}; 
     
    1012995    my $twiki = new TWiki( undef, $query ); 
    1013996    $TWiki::Plugins::SESSION = $twiki; 
    1014     $query                   = new Unit::Request( 
     997    $query = new Unit::Request( 
    1015998        { 
    1016999            etsave    => ['on'], 
     
    10221005        $input ); 
    10231006    $twiki = new TWiki( undef, $query ); 
    1024     my $response = new Unit::Response; 
     1007        my $response = new Unit::Response; 
    10251008    $TWiki::Plugins::SESSION = $twiki; 
    10261009    my ( $saveResult, $ecode ) = $this->capture( 
    10271010        sub { 
    1028             $response->body( 
    1029                 TWiki::Func::expandCommonVariables( 
    1030                     $input, $this->{test_topic}, $this->{test_web}, undef 
    1031                 ) 
    1032             ); 
     1011            $response->body(TWiki::Func::expandCommonVariables( $input, 
     1012                $this->{test_topic}, $this->{test_web}, undef ) ); 
    10331013        } 
    10341014    ); 
     
    10491029 
    10501030sub test_lineBreaksInsideInputField { 
    1051     my $this      = shift; 
     1031    my $this = shift; 
    10521032    my $topicName = $this->{test_topic}; 
    10531033    my $webName   = $this->{test_web}; 
     
    10691049    my $twiki = new TWiki( undef, $query ); 
    10701050    $TWiki::Plugins::SESSION = $twiki; 
    1071     $query                   = new Unit::Request( 
     1051    $query = new Unit::Request( 
    10721052        { 
    10731053            etsave    => ['on'], 
     
    10791059        $input ); 
    10801060    $twiki = new TWiki( undef, $query ); 
    1081     my $response = new Unit::Response; 
     1061        my $response = new Unit::Response; 
    10821062    $TWiki::Plugins::SESSION = $twiki; 
    10831063    my ( $saveResult, $ecode ) = $this->capture( 
    10841064        sub { 
    1085             $response->body( 
    1086                 TWiki::Func::expandCommonVariables( 
    1087                     $input, $this->{test_topic}, $this->{test_web}, undef 
    1088                 ) 
    1089             ); 
     1065            $response->body(TWiki::Func::expandCommonVariables( $input, 
     1066                $this->{test_topic}, $this->{test_web}, undef ) ); 
    10901067        } 
    10911068    ); 
     
    10991076} 
    11001077 
     1078=pod 
     1079 
     1080=cut 
     1081 
     1082sub test_buttonRowAtTop { 
     1083    my $this = shift; 
     1084 
     1085    my $topicName = $this->{test_topic}; 
     1086    my $webName   = $this->{test_web}; 
     1087    my $viewUrlAuth = 
     1088      TWiki::Func::getScriptUrl( $webName, $topicName, 'viewauth' ); 
     1089    my $pubUrlTWikiWeb = 
     1090      TWiki::Func::getUrlHost() . TWiki::Func::getPubUrlPath() . '/TWiki'; 
     1091 
     1092    $this->{twiki}->{store} 
     1093      ->saveTopic( $this->{twiki}->{user}, $webName, $topicName, "XXX" ); 
     1094 
     1095    my $raw_tag  = '%EDITTABLE{buttonrow="top"}%'; 
     1096    my $expected = <<END; 
     1097<a name="edittable1"></a> 
     1098<div class="editTable"> 
     1099<form name="edittable1" action="$viewUrlAuth#edittable1" method="post"> 
     1100<input class="editTableEditImageButton" type="image" src="$pubUrlTWikiWeb/EditTablePlugin/edittable.gif" alt="Edit this table" /> 
     1101<input type="hidden" name="ettablenr" value="1" /> 
     1102<input type="hidden" name="etedit" value="on" /> 
     1103<input type="hidden" name="etrows" value="0" /> 
     1104</form> 
     1105</div><!-- /editTable --> 
     1106END 
     1107    my $result = 
     1108      $this->{twiki}->handleCommonTags( $raw_tag, $webName, $topicName ); 
     1109    $this->do_testHtmlOutput( $expected, $result, 0 ); 
     1110} 
     1111 
     1112sub test_buttonRowAtTop_edit { 
     1113    my $this = shift; 
     1114 
     1115    my $topicName = $this->{test_topic}; 
     1116    my $webName   = $this->{test_web}; 
     1117    my $viewUrlAuth = 
     1118      TWiki::Func::getScriptUrl( $webName, $topicName, 'viewauth' ); 
     1119    my $pubUrlTWikiWeb = 
     1120      TWiki::Func::getUrlHost() . TWiki::Func::getPubUrlPath() . '/TWiki'; 
     1121 
     1122    my $query = new Unit::Request( 
     1123        { 
     1124            etedit    => ['on'], 
     1125            ettablenr => ['1'], 
     1126        } 
     1127    ); 
     1128 
     1129    my $text = <<INPUT; 
     1130SOMETHING %EDITTABLE{buttonrow="top"}% 
     1131INPUT 
     1132 
     1133        $query->path_info("/$webName/$topicName"); 
     1134 
     1135    my $twiki = new TWiki( undef, $query ); 
     1136    $TWiki::Plugins::SESSION = $twiki; 
     1137    my $result = 
     1138      TWiki::Func::expandCommonVariables( $text, $topicName, $webName, undef ); 
     1139 
     1140    my $expected = <<EXPECTED; 
     1141SOMETHING  
     1142<noautolink> 
     1143<a name="edittable1"></a> 
     1144<div class="editTable editTableEdit"> 
     1145<form name="edittable1" action="$viewUrlAuth#edittable1" method="post"> 
     1146<input type="submit" name="etsave" id="etsave" value="Save table" class="twikiSubmit" /> 
     1147<input type="submit" name="etqsave" id="etqsave" value="Quiet save" class="twikiButton" /> 
     1148<input type="submit" name="etaddrow" id="etaddrow" value="Add row" class="twikiButton" /> 
     1149<input type="submit" name="etdelrow" id="etdelrow" value="Delete last row" class="twikiButton" /> 
     1150<input type="submit" name="etcancel" id="etcancel" value="Cancel" class="twikiButton twikiButtonCancel" /> 
     1151<input type="hidden" name="ettablenr" value="1" /> 
     1152| <input class="twikiInputField editTableInput" type="text" name="etcell1x1" size="16" value="" /> | 
     1153<input type="hidden" name="etrows" value="1" /> 
     1154</form> 
     1155</div><!-- /editTable --></noautolink> 
     1156EXPECTED 
     1157 
     1158    $this->do_testHtmlOutput( $expected, $result, 0 ); 
     1159} 
     1160 
     1161sub test_save_with_verbatim { 
     1162    my $this = shift; 
     1163 
     1164    my $topicName = $this->{test_topic}; 
     1165    my $webName   = $this->{test_web}; 
     1166    my $viewUrlAuth = 
     1167      TWiki::Func::getScriptUrl( $webName, $topicName, 'viewauth' ); 
     1168    my $pubUrlTWikiWeb = 
     1169      TWiki::Func::getUrlHost() . TWiki::Func::getPubUrlPath() . '/TWiki'; 
     1170 
     1171    my $input = <<INPUT; 
     1172%EDITTABLE{}% 
     1173| *text* | 
     1174| <verbatim>inside verbatim</verbatim> | 
     1175INPUT 
     1176    my $query = new Unit::Request( 
     1177        { 
     1178            etedit    => ['on'], 
     1179            ettablenr => ['1'], 
     1180        } 
     1181    ); 
     1182 
     1183    $query->path_info("/$webName/$topicName"); 
     1184 
     1185    my $twiki = new TWiki( undef, $query ); 
     1186    $TWiki::Plugins::SESSION = $twiki; 
     1187 
     1188    $query = new Unit::Request( 
     1189        { 
     1190            etsave    => ['on'], 
     1191            ettablenr => ['1'], 
     1192        } 
     1193    ); 
     1194 
     1195    $query->path_info("/$webName/$topicName"); 
     1196 
     1197    TWiki::Func::saveTopic( $this->{test_web}, $this->{test_topic}, undef, 
     1198        $input ); 
     1199 
     1200    $twiki = new TWiki( undef, $query ); 
     1201        my $response = new Unit::Response; 
     1202    $TWiki::Plugins::SESSION = $twiki; 
     1203 
     1204    my ( $saveResult, $ecode ) = $this->capture( 
     1205        sub { 
     1206            $response->body( TWiki::Func::expandCommonVariables( $input, 
     1207                $this->{test_topic}, $this->{test_web}, undef ) ); 
     1208        } 
     1209    ); 
     1210 
     1211    my ( $meta, $newtext ) = TWiki::Func::readTopic( $webName, $topicName ); 
     1212 
     1213    my $expected = <<NEWEXPECTED; 
     1214%EDITTABLE{}% 
     1215| *text* | 
     1216| <verbatim>inside verbatim</verbatim> | 
     1217NEWEXPECTED 
     1218    $this->assert_str_equals( $expected, $newtext, 0 ); 
     1219 
     1220    $twiki->finish(); 
     1221} 
     1222 
    110112231; 
Note: See TracChangeset for help on using the changeset viewer.