--- suikawiki/script/wiki.cgi 2002/12/03 09:34:43 1.33 +++ suikawiki/script/wiki.cgi 2002/12/04 12:00:42 1.34 @@ -97,7 +97,7 @@ my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) my %embed_command = ( searched => '^\[\[#searched:([^\]]+)\]\]$', - form => qw/\[\[\#form:'((?:[^'\\]|\\.)+)':'((?:[^'\\]|\\.)+)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, + form => qw/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, ); ############################## my $info_LastModified = 'LastModified'; @@ -578,8 +578,8 @@ my $epage = &encode ($page); $walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : ''; # Walrus add (debug) # Walrus mod (1) start - my $cvslog1 = q$Revision: 1.33 $; - my $cvslog2 = q$Date: 2002/12/03 09:34:43 $; + my $cvslog1 = q$Revision: 1.34 $; + my $cvslog2 = q$Date: 2002/12/04 12:00:42 $; print_navigate_links ($page); print <<"EOD"; @{[ $lm ? qq(
Last modified: $lm
) : '' ]} @@ -765,7 +765,7 @@ sub inline { my ($line) = @_; $line = &escape($line); - $line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3)}ge; + $line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge; $line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3}g; $line =~ s:\[(WEAK)\[(.+?)\]\]:$2:g; $line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:$1:g; @@ -849,26 +849,42 @@ my $FormIndex = 0; sub make_custom_form ($$$) { - my ($definition, $template, $option) = @_; - $definition =~ s/\\(.)/$1/g; + my ($wfname, $definition, $template, $option) = @_; ## $template and $option is currently not used in this procedure. unless ($main::_EMBEDED) { $FormIndex++; - my $param = bless {}, 'SuikaWiki::Plugin'; - my $lastmodified = &get_info($form{mypage}, $info_LastModified); - my $r = <new; + for (@{$SuikaWiki::Plugin::List{wikiform_option}||[]}) { + $_->load_formatter ($fmt{form_option}, type => 'wikiform_option'); + } + } + $option = &unescape ($option); + $option =~ s/\\(.)/$1/g; + $fmt{form_option}->replace ($option, $param); + my $target_form = $param->{output}->{id}; + my $r = < - + EOH - $r .= qq() if $UA =~ m#Mozilla/[12]\.#; - $r .= $fmt{form_input}->replace (&unescape ($definition), $param); - $r .= <) if $UA =~ m#Mozilla/[12]\.#; + $r .= $fmt{form_input}->replace (&unescape ($definition), $param); + $r .= < EOH + $r; + } else { ## No input-interface WikiForm + qq(); + } } else { q(Warning: form in embeded page is currently not supported.); } @@ -1341,9 +1357,6 @@ $namestr = qq( ''[[$namestr]]'': ); } my $anchor = &get_new_anchor_index ($content); - -# $content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge; - # $anchor++; my $i = 1; my $o = 0; $content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ my $embed = $1; @@ -1456,28 +1469,38 @@ my $write = 0; my $i = 1; $content =~ s{$embed_command{form}}{ - my ($embed, $template, $option) = ($&, $2, $3); - $template =~ s/\\(.)/$1/g; - $option =~ s/\\(.)/$1/g; - if ($i == $form{wikiform_index}) { + my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4); + if (($wfname && $wfname eq $form{wikiform_targetform}) + || $i == $form{wikiform_index}) { + $template =~ s/\\(.)/$1/g; + $option =~ s/\\(.)/$1/g; my $param = bless {}, 'SuikaWiki::Plugin'; $param->{page} = $form{mypage}; $param->{form_index} = $i; + $param->{form_name} = $wfname; $param->{anchor_index} = $anchor; $param->{argv} = \%form; $param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; + $param->{default_name} ||= $DEFAULT_embed_comment_name; $fmt{form_option}->replace ($option, $param); - my $t = $fmt{form_template}->replace ($template, $param); + my $t = 1; + for (@{$param->{require}||[]}) { + (undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; + } + $t = $fmt{form_template}->replace ($template, $param) if $t; if (length $t) { if ($param->{output}->{reverse}) { - $embed = $t . "\n" . $embed; - } else { $embed .= "\n" . $t; + } else { + $embed = $t . "\n" . $embed; } $write = 1; $form{__comment_anchor_index} = $anchor - unless $param->{anchor_index}; ## $anchor is used! + if $param->{anchor_index_}; ## $anchor is used! } + $form{__wikiform_anchor_index} = $i; + undef $form{wikiform_targetform}; ## make sure never to match + undef $form{wikiform_index}; ## with WikiForm in rest of page } $i++; $embed; }ge; @@ -1486,7 +1509,6 @@ #$content .= "\n" unless $content =~ /\n$/s; # } - $form{__wikiform_anchor_index} = $form{wikiform_index}; if ($write) { $form{mymsg} = $content; $form{mytouch} = 'on';