97 |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
98 |
my %embed_command = ( |
my %embed_command = ( |
99 |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
100 |
form => qw/\[\[\#form:'((?:[^'\\]|\\.)+)':'((?:[^'\\]|\\.)+)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
form => qw/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
101 |
); |
); |
102 |
############################## |
############################## |
103 |
my $info_LastModified = 'LastModified'; |
my $info_LastModified = 'LastModified'; |
765 |
sub inline { |
sub inline { |
766 |
my ($line) = @_; |
my ($line) = @_; |
767 |
$line = &escape($line); |
$line = &escape($line); |
768 |
$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; |
769 |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
770 |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
771 |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
849 |
|
|
850 |
my $FormIndex = 0; |
my $FormIndex = 0; |
851 |
sub make_custom_form ($$$) { |
sub make_custom_form ($$$) { |
852 |
my ($definition, $template, $option) = @_; |
my ($wfname, $definition, $template, $option) = @_; |
|
$definition =~ s/\\(.)/$1/g; |
|
853 |
## $template and $option is currently not used in this procedure. |
## $template and $option is currently not used in this procedure. |
854 |
unless ($main::_EMBEDED) { |
unless ($main::_EMBEDED) { |
855 |
$FormIndex++; |
$FormIndex++; |
856 |
my $param = bless {}, 'SuikaWiki::Plugin'; |
if (length $definition) { |
857 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
my $param = bless {}, 'SuikaWiki::Plugin'; |
858 |
my $r = <<EOH; |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
859 |
|
$definition =~ s/\\(.)/$1/g; |
860 |
|
$definition .= ' %submit;' if $definition !~ /%submit/; |
861 |
|
unless ($fmt{form_option}) { |
862 |
|
$fmt{form_option} = Message::Util::Formatter->new; |
863 |
|
for (@{$SuikaWiki::Plugin::List{wikiform_option}||[]}) { |
864 |
|
$_->load_formatter ($fmt{form_option}, type => 'wikiform_option'); |
865 |
|
} |
866 |
|
} |
867 |
|
$option = &unescape ($option); |
868 |
|
$option =~ s/\\(.)/$1/g; |
869 |
|
$fmt{form_option}->replace ($option, $param); |
870 |
|
my $target_form = $param->{output}->{id}; |
871 |
|
my $r = <<EOH; |
872 |
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
873 |
<input type="hidden" name="mycmd" value="wikiform"> |
<input type="hidden" name="mycmd" value="wikiform"> |
874 |
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
875 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
876 |
<input type="hidden" name="mytouch" value="on"> |
<input type="hidden" name="mytouch" value="on"> |
877 |
<input type="hidden" name="wikiform_index" value="$FormIndex"> |
<input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}"> |
878 |
EOH |
EOH |
879 |
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
880 |
$r .= $fmt{form_input}->replace (&unescape ($definition), $param); |
$r .= $fmt{form_input}->replace (&unescape ($definition), $param); |
881 |
$r .= <<EOH; |
$r .= <<EOH; |
882 |
</form> |
</form> |
883 |
EOH |
EOH |
884 |
|
$r; |
885 |
|
} else { ## No input-interface WikiForm |
886 |
|
qq(<a id="wikiform-$FormIndex" name="wikiform-$FormIndex"><!-- #form --></a>); |
887 |
|
} |
888 |
} else { |
} else { |
889 |
q(<ins class="wiki-error"><strong>Warning</strong>: form in embeded page is currently not supported.</ins>); |
q(<ins class="wiki-error"><strong>Warning</strong>: form in embeded page is currently not supported.</ins>); |
890 |
} |
} |
1357 |
$namestr = qq( ''[[$namestr]]'': ); |
$namestr = qq( ''[[$namestr]]'': ); |
1358 |
} |
} |
1359 |
my $anchor = &get_new_anchor_index ($content); |
my $anchor = &get_new_anchor_index ($content); |
|
|
|
|
# $content =~ s/(?:-+\s)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge; |
|
|
# $anchor++; |
|
1360 |
my $i = 1; my $o = 0; |
my $i = 1; my $o = 0; |
1361 |
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
$content =~ s{(\Q$embed_comment\E|\Q$embed_rcomment\E)}{ |
1362 |
my $embed = $1; |
my $embed = $1; |
1469 |
my $write = 0; |
my $write = 0; |
1470 |
my $i = 1; |
my $i = 1; |
1471 |
$content =~ s{$embed_command{form}}{ |
$content =~ s{$embed_command{form}}{ |
1472 |
my ($embed, $template, $option) = ($&, $2, $3); |
my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4); |
1473 |
$template =~ s/\\(.)/$1/g; |
if (($wfname && $wfname eq $form{wikiform_targetform}) |
1474 |
$option =~ s/\\(.)/$1/g; |
|| $i == $form{wikiform_index}) { |
1475 |
if ($i == $form{wikiform_index}) { |
$template =~ s/\\(.)/$1/g; |
1476 |
|
$option =~ s/\\(.)/$1/g; |
1477 |
my $param = bless {}, 'SuikaWiki::Plugin'; |
my $param = bless {}, 'SuikaWiki::Plugin'; |
1478 |
$param->{page} = $form{mypage}; |
$param->{page} = $form{mypage}; |
1479 |
$param->{form_index} = $i; |
$param->{form_index} = $i; |
1480 |
|
$param->{form_name} = $wfname; |
1481 |
$param->{anchor_index} = $anchor; |
$param->{anchor_index} = $anchor; |
1482 |
$param->{argv} = \%form; |
$param->{argv} = \%form; |
1483 |
$param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; |
$param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; |
1484 |
|
$param->{default_name} ||= $DEFAULT_embed_comment_name; |
1485 |
$fmt{form_option}->replace ($option, $param); |
$fmt{form_option}->replace ($option, $param); |
1486 |
my $t = $fmt{form_template}->replace ($template, $param); |
my $t = 1; |
1487 |
|
for (@{$param->{require}||[]}) { |
1488 |
|
(undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; |
1489 |
|
} |
1490 |
|
$t = $fmt{form_template}->replace ($template, $param) if $t; |
1491 |
if (length $t) { |
if (length $t) { |
1492 |
if ($param->{output}->{reverse}) { |
if ($param->{output}->{reverse}) { |
|
$embed = $t . "\n" . $embed; |
|
|
} else { |
|
1493 |
$embed .= "\n" . $t; |
$embed .= "\n" . $t; |
1494 |
|
} else { |
1495 |
|
$embed = $t . "\n" . $embed; |
1496 |
} |
} |
1497 |
$write = 1; |
$write = 1; |
1498 |
$form{__comment_anchor_index} = $anchor |
$form{__comment_anchor_index} = $anchor |
1499 |
unless $param->{anchor_index}; ## $anchor is used! |
if $param->{anchor_index_}; ## $anchor is used! |
1500 |
} |
} |
1501 |
|
$form{__wikiform_anchor_index} = $i; |
1502 |
|
undef $form{wikiform_targetform}; ## make sure never to match |
1503 |
|
undef $form{wikiform_index}; ## with WikiForm in rest of page |
1504 |
} |
} |
1505 |
$i++; $embed; |
$i++; $embed; |
1506 |
}ge; |
}ge; |
1509 |
#$content .= "\n" unless $content =~ /\n$/s; |
#$content .= "\n" unless $content =~ /\n$/s; |
1510 |
# |
# |
1511 |
} |
} |
|
$form{__wikiform_anchor_index} = $form{wikiform_index}; |
|
1512 |
if ($write) { |
if ($write) { |
1513 |
$form{mymsg} = $content; |
$form{mymsg} = $content; |
1514 |
$form{mytouch} = 'on'; |
$form{mytouch} = 'on'; |