Changeset 397
- Timestamp:
- 11/02/08 00:57:59 (4 years ago)
- Location:
- branches/Release04x02/twikiplugins/EditTablePlugin
- Files:
-
- 6 edited
-
data/TWiki/EditTablePlugin.txt (modified) (3 diffs)
-
data/TWiki/VarEDITTABLE.txt (modified) (1 diff)
-
lib/TWiki/Plugins/EditTablePlugin.pm (modified) (3 diffs)
-
lib/TWiki/Plugins/EditTablePlugin/Core.pm (modified) (12 diffs)
-
pub/TWiki/EditTablePlugin/edittable.css (modified) (2 diffs)
-
test/unit/EditTablePlugin/EditTablePluginTests.pm (modified) (23 diffs)
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: 17 542$"}%1 %META:TOPICINFO{author="TWikiContributor" date="1191744279" format="1.1" version="$Rev: 17303 $"}% 2 2 ---+!! Edit Table Plugin 3 3 … … 211 211 ---++ Plugin Info 212 212 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 | 215 216 | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | 216 | Plugin Version: | 4. 8.7 (26 Sep2008) |217 | Plugin Version: | 4.9 (01 Nov 2008) | 217 218 | Change History: | <!-- specify latest version first --> | 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 | 223 225 | 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. | 224 226 | 25 Dec 2007: | 4.7.1: Arthur Clemens: Added warning if =include= parameter topic does not exist. | 225 227 | 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. | 229 231 | 07 Oct 2007: | 15182: PTh: Added %TWIKIWEB%.VarEDITTABLE to have it listed in %TWIKIWEB%.TWikiVariables | 230 232 | 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. | … … 259 261 | Dependencies: | %$DEPENDENCIES% | 260 262 | Perl Version: | 5.0 | 261 | TWiki:Plugins/Benchmark: | %TWIKIWEB%.GoodStyle 98%, %TWIKIWEB%.FormattedSearch 98%, %TOPIC% 95% |262 263 | Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% | 263 264 | Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | 264 265 | Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal | 265 266 __Related Topics:__ %TWIKIWEB%.VarEDITTABLE, %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins267 266 268 267 %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 16 16 | =headerislabel= | Table header cells are read-only (labels) if ="on"=; header cells can be edited if ="off"= or "0" | ="on"= | 17 17 | =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= | 18 19 | =javascriptinterface= | Use javascript to directly move and delete row without page refresh. Enable with ="on"=, disable with ="off"=. | =JAVASCRIPTINTERFACE= %BR% plugin setting | 19 20 %ENDSECTION{"edittable_attributes"}% -
branches/Release04x02/twikiplugins/EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin.pm
r11 r397 1 1 # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ 2 2 # 3 # Copyright (C) 2008 Arthur Clemens, arthur@visiblearea.com 3 4 # Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and TWiki 4 5 # Contributors. … … 28 29 ); 29 30 30 # This should always be $Rev: 17 542$ so that TWiki can determine the checked-in31 # This should always be $Rev: 17303 $ so that TWiki can determine the checked-in 31 32 # status of the plugin. It is used by the build automation tools, so 32 33 # you should leave it alone. 33 $VERSION = '$Rev: 17 542$';34 $VERSION = '$Rev: 17303 $'; 34 35 35 36 # This is a free-form string you can use to "name" your own plugin version. 36 37 # It is *not* used by the build automation tools, but is reported as part 37 38 # of the version number in PLUGINDESCRIPTIONS. 38 $RELEASE = '4. 8.7';39 $RELEASE = '4.9'; 39 40 40 41 $encodeStart = '--EditTableEncodeStart--'; … … 78 79 return unless $_[0] =~ /%EDIT(TABLE|CELL){(.*)}%/os; 79 80 require TWiki::Plugins::EditTablePlugin::Core; 80 TWiki::Plugins::EditTablePlugin::Core::pr eProcessSpreadsheetPluginTags(81 TWiki::Plugins::EditTablePlugin::Core::protectVariables( 81 82 $_[0] ); 82 83 } -
branches/Release04x02/twikiplugins/EditTablePlugin/lib/TWiki/Plugins/EditTablePlugin/Core.pm
r3 r397 1 1 # Plugin for TWiki Enterprise Collaboration Platform, http://TWiki.org/ 2 2 # 3 # Copyright (C) 2008 Arthur Clemens, arthur@visiblearea.com 3 4 # Copyright (C) 2002-2007 Peter Thoeny, peter@thoeny.org and 4 5 # TWiki Contributors. … … 32 33 ); 33 34 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 } 35 my $RENDER_HACK = "\n<nop>\n"; 36 my $DEFAULT_FIELD_SIZE = 16; 37 my $PLACEHOLDER_BUTTONROW_TOP = 'PLACEHOLDER_BUTTONROW_TOP'; 38 my $PLACEHOLDER_BUTTONROW_BOTTOM = 'PLACEHOLDER_BUTTONROW_BOTTOM'; 39 my $STUB_VARIABLE = 'E_T_P_NOP'; 40 41 my %regex = (); 42 $regex{edit_table_plugin} = '%EDITTABLE{(.*?)}%'; 43 $regex{table_plugin} = '%TABLE(?:{(.*?)})?%'; 44 $regex{table_row_full} = '^(\s*)\|.*\|\s*$'; 45 $regex{table_row} = '^(\s*)\|(.*)'; 44 46 45 47 sub init { … … 65 67 } 66 68 67 sub preProcessSpreadsheetPluginTags { 69 =pod 70 71 ---+++ protectVariables ($text) 72 73 Called during beforeCommonTagsHandler. 74 Escapes variables by placing $STUB_VARIABLE inside each variable. 75 This stub is removed later on (inside handleTableRow). 76 77 =cut 78 79 sub protectVariables { 80 81 #my $text = $_[0] 82 68 83 $query = TWiki::Func::getCgiQuery(); 69 84 if ( ( $query->param('etedit') ) && ( $query->param('ettablenr') ) ) { … … 72 87 my ( $tablesTakenOutText, @tableTextRefs ) = 73 88 $tmptable->parseText( $_[0] ); 74 my $tableNr = 1; 89 my $tableNr = 1; # starting point 75 90 my $tableDone = 0; 76 91 foreach my $tableTextRef (@tableTextRefs) { … … 79 94 if ( !$tableDone && $tableNr eq $paramTableNr ) { 80 95 81 # escape variables 82 $tableText =~ s/%(.*?\{*.*?\}*)%/%E_T_P_NOP$1%/go; 83 $tableText =~ s/%E_T_P_NOPBR%/ /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%/ /go 106 ; # replace escaped %BR% with newline 107 my $tag = 'verbatim'; 108 $tableText =~ 109 s/\<$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 85 112 } 86 113 $tableText = $editTableTag . "\n" . $tableText; … … 512 539 # START PUT PROCESSED TABLE BACK IN TEXT 513 540 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 514 557 if ( $doEdit && !$doSave && ( $paramTableNr == $tableNr ) ) { 515 558 insertTmpTagInTableTagLine( $editTableTag, … … 596 639 $$theHashRef{'javascriptinterface'} = $tmp if ($tmp); 597 640 641 $tmp = TWiki::Func::extractNameValuePair( $theArgs, 'buttonrow' ); 642 $$theHashRef{'buttonrow'} = $tmp if ($tmp); 643 598 644 return; 599 645 } … … 644 690 'editbutton' => '', 645 691 'javascriptinterface' => '', 692 'buttonrow' => '', 646 693 ); 647 694 $warningMessage = ''; … … 735 782 $text .= 736 783 "$preSp<form name=\"$formName\" action=\"$viewUrl\" method=\"post\">\n"; 784 785 $text .= $PLACEHOLDER_BUTTONROW_TOP; 786 737 787 $text .= hiddenField( $preSp, 'ettablenr', $theTableNr, "\n" ); 738 788 $text .= hiddenField( $preSp, 'etedit', 'on', "\n" ) … … 772 822 if $addedRowCount; 773 823 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 838 sub createButtonRow { 839 my ( $theWeb, $theTopic, $includingWeb, $includingTopic, $doEdit ) = @_; 840 841 my $text = ''; 774 842 if ( $doEdit && ( "$theWeb.$theTopic" eq "$includingWeb.$includingTopic" ) ) 775 843 { … … 837 905 } 838 906 } 839 $text .= "$preSp</form>\n";840 $text .= "</div><!-- /editTable -->";841 $text .= "</noautolink>" if $doEdit;842 843 # $text .= "\n";844 907 return $text; 845 908 } … … 1249 1312 1250 1313 $cell =~ 1251 s/ E_T_P_NOP//go;# remove escaping of variables inside cells1314 s/$STUB_VARIABLE//go; # remove escaping of variables inside cells 1252 1315 1253 1316 if ($isNewRowFromHeader) { -
branches/Release04x02/twikiplugins/EditTablePlugin/pub/TWiki/EditTablePlugin/edittable.css
r3 r397 2 2 .editTable { 3 3 padding-bottom:1em; 4 } 5 .editTableEdit .twikiTable { 6 margin:5px 0; 4 7 } 5 8 .editTableInnerTable table, … … 8 11 border:none; 9 12 padding-top:0; 10 margin-top:0; 13 } 14 .editTableEditImageButton { 15 margin:3px 0; 11 16 } 12 17 -
branches/Release04x02/twikiplugins/EditTablePlugin/test/unit/EditTablePlugin/EditTablePluginTests.pm
r21 r397 26 26 $TWiki::cfg{AntiSpam}{RobotsAreWelcome} = 1; 27 27 $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"'; 30 29 31 30 $ENV{SCRIPT_NAME} = ''; # required by fake sort URLs in expected text … … 48 47 } 49 48 49 50 50 # remove ever changing bgcolors from table cells 51 51 # as well as the rules property 52 52 # these are not important for these tests now 53 53 $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; 55 55 $expected =~ s/rules\=\"*(cols|rows|all)\"*//go; 56 $actual =~ s/rules\=\"*(cols|rows|all)\"*//go;56 $actual =~ s/rules\=\"*(cols|rows|all)\"*//go; 57 57 58 58 $this->assert_html_equals( $expected, $actual ); … … 271 271 </div><!-- /editTable --></noautolink> 272 272 EXPECTED 273 273 274 274 $this->do_testHtmlOutput( $expected, $result, 0 ); 275 275 … … 354 354 355 355 $twiki = new TWiki( undef, $query ); 356 my $response = new Unit::Response;356 my $response = new Unit::Response; 357 357 $TWiki::Plugins::SESSION = $twiki; 358 358 359 359 my ( $saveResult, $ecode ) = $this->capture( 360 360 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 ) ); 366 363 } 367 364 ); … … 661 658 662 659 $twiki = new TWiki( undef, $query ); 663 my $response = new Unit::Response;660 my $response = new Unit::Response; 664 661 $TWiki::Plugins::SESSION = $twiki; 665 662 666 663 my ( $saveResult, $ecode ) = $this->capture( 667 664 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 ) ); 673 667 } 674 668 ); … … 731 725 732 726 $twiki = new TWiki( undef, $query ); 733 my $response = new Unit::Response;727 my $response = new Unit::Response; 734 728 $TWiki::Plugins::SESSION = $twiki; 735 729 736 730 my ( $saveResult, $ecode ) = $this->capture( 737 731 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 ) ); 743 734 } 744 735 ); … … 768 759 769 760 sub test_keepSpacesInEmptyCellsWithTexts { 770 my $this = shift;761 my $this = shift; 771 762 my $topicName = $this->{test_topic}; 772 763 my $webName = $this->{test_web}; … … 790 781 my $twiki = new TWiki( undef, $query ); 791 782 $TWiki::Plugins::SESSION = $twiki; 792 $query = new Unit::Request(783 $query = new Unit::Request( 793 784 { 794 785 etsave => ['on'], … … 800 791 $input ); 801 792 $twiki = new TWiki( undef, $query ); 802 my $response = new Unit::Response;793 my $response = new Unit::Response; 803 794 $TWiki::Plugins::SESSION = $twiki; 804 795 my ( $saveResult, $ecode ) = $this->capture( 805 796 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 ) ); 811 799 } 812 800 ); … … 829 817 830 818 sub test_keepSpacesInEmptyCellsWithDates { 831 my $this = shift;819 my $this = shift; 832 820 my $topicName = $this->{test_topic}; 833 821 my $webName = $this->{test_web}; … … 852 840 my $twiki = new TWiki( undef, $query ); 853 841 $TWiki::Plugins::SESSION = $twiki; 854 $query = new Unit::Request(842 $query = new Unit::Request( 855 843 { 856 844 etsave => ['on'], … … 862 850 $input ); 863 851 $twiki = new TWiki( undef, $query ); 864 my $response = new Unit::Response;852 my $response = new Unit::Response; 865 853 $TWiki::Plugins::SESSION = $twiki; 866 854 my ( $saveResult, $ecode ) = $this->capture( 867 855 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 ) ); 873 858 } 874 859 ); … … 895 880 896 881 sub test_addSpacesToEmptyCells { 897 my $this = shift;882 my $this = shift; 898 883 my $topicName = $this->{test_topic}; 899 884 my $webName = $this->{test_web}; … … 916 901 my $twiki = new TWiki( undef, $query ); 917 902 $TWiki::Plugins::SESSION = $twiki; 918 $query = new Unit::Request(903 $query = new Unit::Request( 919 904 { 920 905 etsave => ['on'], … … 926 911 $input ); 927 912 $twiki = new TWiki( undef, $query ); 928 my $response = new Unit::Response;913 my $response = new Unit::Response; 929 914 $TWiki::Plugins::SESSION = $twiki; 930 915 my ( $saveResult, $ecode ) = $this->capture( 931 916 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 ) ); 937 919 } 938 920 ); … … 968 950 969 951 my $result = 970 TWiki::Func::expandCommonVariables( $input, $topicName, $webName, undef ); 971 952 TWiki::Func::expandCommonVariables( $input, $topicName, 953 $webName, undef ); 954 972 955 my $expected = <<NEWEXPECTED; 973 956 <a name="edittable1"></a> … … 992 975 993 976 sub test_keepStars { 994 my $this = shift;977 my $this = shift; 995 978 my $topicName = $this->{test_topic}; 996 979 my $webName = $this->{test_web}; … … 1012 995 my $twiki = new TWiki( undef, $query ); 1013 996 $TWiki::Plugins::SESSION = $twiki; 1014 $query = new Unit::Request(997 $query = new Unit::Request( 1015 998 { 1016 999 etsave => ['on'], … … 1022 1005 $input ); 1023 1006 $twiki = new TWiki( undef, $query ); 1024 my $response = new Unit::Response;1007 my $response = new Unit::Response; 1025 1008 $TWiki::Plugins::SESSION = $twiki; 1026 1009 my ( $saveResult, $ecode ) = $this->capture( 1027 1010 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 ) ); 1033 1013 } 1034 1014 ); … … 1049 1029 1050 1030 sub test_lineBreaksInsideInputField { 1051 my $this = shift;1031 my $this = shift; 1052 1032 my $topicName = $this->{test_topic}; 1053 1033 my $webName = $this->{test_web}; … … 1069 1049 my $twiki = new TWiki( undef, $query ); 1070 1050 $TWiki::Plugins::SESSION = $twiki; 1071 $query = new Unit::Request(1051 $query = new Unit::Request( 1072 1052 { 1073 1053 etsave => ['on'], … … 1079 1059 $input ); 1080 1060 $twiki = new TWiki( undef, $query ); 1081 my $response = new Unit::Response;1061 my $response = new Unit::Response; 1082 1062 $TWiki::Plugins::SESSION = $twiki; 1083 1063 my ( $saveResult, $ecode ) = $this->capture( 1084 1064 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 ) ); 1090 1067 } 1091 1068 ); … … 1099 1076 } 1100 1077 1078 =pod 1079 1080 =cut 1081 1082 sub 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 --> 1106 END 1107 my $result = 1108 $this->{twiki}->handleCommonTags( $raw_tag, $webName, $topicName ); 1109 $this->do_testHtmlOutput( $expected, $result, 0 ); 1110 } 1111 1112 sub 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; 1130 SOMETHING %EDITTABLE{buttonrow="top"}% 1131 INPUT 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; 1141 SOMETHING 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> 1156 EXPECTED 1157 1158 $this->do_testHtmlOutput( $expected, $result, 0 ); 1159 } 1160 1161 sub 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> | 1175 INPUT 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> | 1217 NEWEXPECTED 1218 $this->assert_str_equals( $expected, $newtext, 0 ); 1219 1220 $twiki->finish(); 1221 } 1222 1101 1223 1;
Note: See TracChangeset
for help on using the changeset viewer.
