/[pub]/suikawiki/script/lib/suikawiki.pl
Suika

Diff of /suikawiki/script/lib/suikawiki.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by wakaba, Sun May 25 10:56:24 2003 UTC revision 1.8 by wakaba, Sat May 31 07:01:46 2003 UTC
# Line 5  package main; Line 5  package main;
5  our $VERSION = '2.'.do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};  our $VERSION = '2.'.do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
6  binmode STDOUT; binmode STDIN;  binmode STDOUT; binmode STDIN;
7  use Fcntl;  use Fcntl;
 require Yuki::YukiWikiCache;  
 require SuikaWiki::Name::Space;  
 require SuikaWiki::View;  
8  require SuikaWiki::Plugin;  require SuikaWiki::Plugin;
9  our %fmt;       ## formatter objects  our %fmt;       ## formatter objects
10  our %embed_command = (  our %embed_command = (
# Line 31  my %command_do = ( Line 28  my %command_do = (
28  );  );
29  our $UA = '';  ## User agent name  our $UA = '';  ## User agent name
30  $| = 1;  $| = 1;
31  my $HAS_XML = SuikaWiki::Plugin->feature ('SuikaWiki::Markup::XML');  SuikaWiki::Plugin->feature ('SuikaWiki::View');
32    SuikaWiki::Plugin->feature ('SuikaWiki::Name::Space');
33    SuikaWiki::Plugin->feature ('SuikaWiki::Markup::XML');
34    SuikaWiki::Plugin->feature ('Yuki::YukiWikiCache');
35  my $NS_XHTML1 = 'http://www.w3.org/1999/xhtml';  my $NS_XHTML1 = 'http://www.w3.org/1999/xhtml';
36    
37  sub main {  sub main {
# Line 50  sub main { Line 50  sub main {
50  }  }
51    
52  sub do_view {  sub do_view {
53    my $content = $database{$form{mypage}};    my $content = $main::database{$main::form{mypage}};
54    my $lm = $database->mtime ($form{mypage});    my $lm = SuikaWiki::Plugin->_database->mtime ($main::form{mypage});
   &load_formatter ('view');  
55      my $view = $form{mycmd};      my $view = $form{mycmd};
56      if ($view eq 'edit') {      $view = 'default' if $view =~ /[^0-9A-Za-z_]/;
       $view = 'adminedit' if $form{admin};  
     } elsif ($view =~ /[^0-9A-Za-z_]/) {  
       $view = 'default'  
     }  
57      if ($view eq 'default' || !$view) {      if ($view eq 'default' || !$view) {
58        ## BUG: this code is not strict        ## BUG: this code is not strict
59        if ($main::ENV{HTTP_COOKIE} =~ /SelectedMode=([0-9A-Za-z]+)/) {        if ($main::ENV{HTTP_COOKIE} =~ /SelectedMode=([0-9A-Za-z]+)/) {
# Line 67  sub do_view { Line 62  sub do_view {
62          $view = 'read';          $view = 'read';
63        }        }
64      }      }
65    my ($magic, $content) = &SuikaWiki::Plugin::magic_and_content (undef, $content);    my ($magic, $content) = SuikaWiki::Plugin->magic_and_content ($content);
66    $magic ||= '#?SuikaWiki/0.9';    $magic ||= '#?SuikaWiki/0.9';
67    my $o = bless {param => \%form, page => $form{mypage}, toc => [],    my $o = bless {param => \%main::form, page => $main::form{mypage}, toc => [],
68                   magic => $magic, content => $content,                   magic => $magic, content => $content,
69                   formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin';                   formatter => $fmt{view}, &main::_compatible_options ()}, 'SuikaWiki::Plugin';
70    my $view_def = SuikaWiki::View->definition ($view);    my $view_def = SuikaWiki::View->definition ($view);
71    if (!$view_def->check ($o)) {    if (!$view_def->check ($o)) {
72      print "Status: 406 Unsupported Media Type\n";      print "Status: 406 Unsupported Media Type\n";
# Line 82  sub do_view { Line 77  sub do_view {
77    if ($view_def->properties->{xmedia} && $UA =~ /Gecko/) {    if ($view_def->properties->{xmedia} && $UA =~ /Gecko/) {
78      $media = $view_def->properties->{xmedia};      $media = $view_def->properties->{xmedia};
79      $o->{media} = $media;      $o->{media} = $media;
80    } elsif ($UA =~ m#Mozilla/0\..+Windows#) {    } elsif ($main::UA =~ m#Mozilla/0\..+Windows#) {
81      $kanjicode = 'shift_jis';      $main::kanjicode = 'shift_jis';
82    }    }
83      if ($magic =~ m!^\#\?SuikaWiki/0.9!) {      if ($magic =~ m!^\#\?SuikaWiki/0.9!) {
84        &print_header ($form{mypage}, -last_modified => ($magic =~ /interactive="yes"/ ? time : $lm),        &main::print_header ($main::form{mypage}, -last_modified => ($magic =~ /interactive="yes"/ ? time : $lm),
85          -expires => ($magic =~ /interactive="yes"/ ? 1 : undef), o => $o,          -expires => ($magic =~ /interactive="yes"/ ? 1 : undef), o => $o,
86          -media => $media, -magic => $magic,  content => $content);          -media => $media, -magic => $magic,  content => $content);
87      } else {      } else {
88        &print_header($form{mypage}, -media => $media,        &main::print_header($main::form{mypage}, -media => $media,
89                                     -magic => $magic, -last_modified => $lm, o => $o);                                     -magic => $magic, -last_modified => $lm, o => $o);
90      }      }
91    if ($kanjicode ne 'euc') {    my $fmt = SuikaWiki::Plugin->formatter ('view');
92      my $s = $fmt{view}->replace ($view_def->as_string => $o, {formatter => $fmt{view}});    if ($main::kanjicode ne 'euc') {
93      print &code_convert (\$s => $kanjicode);      my $s = $fmt->replace ($view_def->as_string => $o, {formatter => $fmt});
94        print &main::code_convert (\$s => $main::kanjicode);
95    } else {    } else {
96      print $fmt{view}->replace ($view_def->as_string => $o, {formatter => $fmt{view}});      print $fmt->replace ($view_def->as_string => $o, {formatter => $fmt});
97    }    }
98  }  }
99    
# Line 192  sub _compatible_options () { Line 188  sub _compatible_options () {
188    (use_anchor_name => ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer# ? 1 : 0));    (use_anchor_name => ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer# ? 1 : 0));
189  }  }
190    
 sub get_search_result ($;%) {  
   my $word = lc shift;  
   my $SearchResult = SuikaWiki::Plugin->cache ('search');  
   my %option = @_;  
   my @r;  
   unless (defined $SearchResult->{$word}) {  
     for my $page (keys %database) {  
       next if !$option{-match_myself} && ($page eq $word);  
       my $content = lc $database{$page};  
       $content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s;  
       if (index (lc $page, $word) > -1) {  
         my $c = $content =~ s/\Q$word\E//g;  
         push @r, [$page, $c+20];  
       } elsif (index ($word, lc $page) > -1) {  
         my $c = $content =~ s/\Q$word\E//g;  
         push @r, [$page, $c+10];  
       } elsif (my $c = $content =~ s/\Q$word\E//g) {  
         push @r, [$page, $c];  
       }  
     }  
     @r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;  
     $SearchResult->{$word} = join "\x1E", map {$_->[0]."\x1F".$_->[1]} @r;  
   } else {  
     @r = map {[split /\x1F/, $_, 2]} split /\x1E/, $SearchResult->{$word};  
   }  
   #my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s };  
   my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&escape($_->[0])]}</a> <span class="wikipage-summary">@{[&escape(&get_subjectline($_->[0]))]}</span></li>)} @r;  
   $r = qq|<ul class="search-result">$r</ul>| if $r;  
   wantarray? ($r, scalar @r): $r;  
 }  
   
191  sub do_random_jump {  sub do_random_jump {
192    my @list = keys %database;    my @list = keys %main::database;
193    my $name = &encode ($list[rand @list]);    print "Location: ".SuikaWiki::Plugin->_uri_wiki_page ($list[rand @list])."\n";
   print "Location: $uri{wiki}?$name\n";  
194    print "\n";    print "\n";
195  }  }
196    
197  sub print_header ($;%) {  sub print_header ($;%) {
198      my ($page, %option) = @_;      my ($page, %option) = @_;
199      my @head;      my $UA = SuikaWiki::Plugin->user_agent_names;
200      $option{o}->{-header}->{class} = &is_frozen($page) ? 'frozen' : '';      $option{o}->{-header}->{class}->{frozen} = 1 if &main::is_frozen ($page);
201      $option{o}->{-header}->{class} .= " wiki-page-obsoleted" if $option{-magic} =~ /obsoleted="yes"/;      $option{o}->{-header}->{class}->{'wiki-page-obsoleted'} if $option{-magic} =~ /obsoleted="yes"/;
202        $option{o}->{-header}->{additional_html_element} ||= SuikaWiki::Markup::XML->new (type => '#fragment');
203      if ($option{-goto}) {      if ($option{-goto}) {
204        if ($UA =~ m#Opera|MSIE 2\.#) {        if ($UA =~ m#Opera|MSIE 2\.#) {
205            ## WARNING: This code may output unsafe HTML document if          ## WARNING: This code may output unsafe HTML document if $option{-goto} is unclean.
206            ##          $option{-goto} is not clean.          $option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#;
207            $option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#;          print qq{Refresh: 0; url=$option{-goto}\n};
208            print qq{Refresh: 0; url=$option{-goto}\n};          for ($option{o}->{-header}->{additional_html_element}->append_new_node
209            push @head, qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">);                  (namespace_uri => $NS_XHTML1, local_name => 'meta')) {
210        } elsif ($UA =~ /Gecko/) {            $_->set_attribute ('http-equiv' => 'refresh');
211            print qq{Refresh: 0; url="$option{-goto}"\n};            $_->set_attribute (content => "0; url=$option{-goto}");
212            push @head, qq(<meta http-equiv="refresh" content="0; url=&quot;@{[&escape($option{-goto})]}&quot;" />);          }
213        } else {        } else {
214            $option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#;          $option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#;
215            print qq{Refresh: 0; url="$option{-goto}"\n};          print qq{Refresh: 0; url="$option{-goto}"\n};
216            push @head, qq(<meta http-equiv="refresh" content="0; url=&quot;@{[&escape($option{-goto})]}&quot;">);          for ($option{o}->{-header}->{additional_html_element}->append_new_node
217                    (namespace_uri => $NS_XHTML1, local_name => 'meta')) {
218              $_->set_attribute ('http-equiv' => 'refresh');
219              $_->set_attribute (content => qq(0; url="$option{-goto}"));
220            }
221        }        }
222      }      }
223      print qq{Last-Modified: @{[scalar gmtime $option{-last_modified}]}\n} if $option{-last_modified};      print qq{Last-Modified: @{[scalar gmtime $option{-last_modified}]}\n}
224          if $option{-last_modified};
225      if ($option{-expires} != -1) {      if ($option{-expires} != -1) {
226        if (defined $option{-expires}) {  ## TODO: Don't use asctime        if (defined $option{-expires}) {  ## TODO: Don't use asctime
227          print qq{Expires: @{[scalar gmtime (time + $option{-expires})]}\n};          print qq{Expires: @{[scalar gmtime (time + $option{-expires})]}\n};
# Line 260  sub print_header ($;%) { Line 230  sub print_header ($;%) {
230        }        }
231      }      }
232      if ($option{-media}->{charset} && $UA =~ m#Mozilla/[12]\.#) {      if ($option{-media}->{charset} && $UA =~ m#Mozilla/[12]\.#) {
233          my $ct = qq{$option{-media}->{type}; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}};      ## UAs don't support official charset names but do non-official names
234          print qq{Content-Type: $ct\n};        my $ct = qq{$option{-media}->{type}; charset=@{[ &main::get_charset_name ($main::kanjicode, compatible => 1) ]}};
235          $option{o}->{-header}->{meta_ct} = qq{<meta http-equiv="content-type" content="$ct">\n};        print qq{Content-Type: $ct\n};
236          for ($option{o}->{-header}->{additional_html_element}->append_new_node
237                    (namespace_uri => $NS_XHTML1, local_name => 'meta')) {
238            $_->set_attribute ('http-equiv' => 'content-type');
239            $_->set_attribute (content => $ct);
240          }
241      } elsif (!$option{-media}->{charset} || $UA =~ m#Infomosaic|Mozilla/0\.#) {      } elsif (!$option{-media}->{charset} || $UA =~ m#Infomosaic|Mozilla/0\.#) {
242          print qq{Content-Type: $option{-media}->{type}\n};      ## Media types or UAs don't support charset parameter in HTTP header
243          $option{o}->{-header}->{meta_ct} = qq{<meta http-equiv="content-type" content="$option{-media}->{type}; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}">\n};        print qq{Content-Type: $option{-media}->{type}\n};
244          if ($option{-media}->{charset}) {
245            for ($option{o}->{-header}->{additional_html_element}->append_new_node
246                      (namespace_uri => $NS_XHTML1, local_name => 'meta')) {
247              $_->set_attribute ('http-equiv' => 'content-type');
248              $_->set_attribute (content => qq($option{-media}->{type}; charset=).main::get_charset_name ($main::kanjicode, compatible => 1));
249            }
250          }
251      } else {      } else {
252          my $type = $option{-media}->{type};      ## Modern UAs and Media types with charset parameter
253          $type = 'application/xml' if ($type =~ m!^application/(?:rdf|rss)\+xml$!) && ($UA =~ m#Gecko#);        my $type = $option{-media}->{type};
254          print qq{Content-Type: $type; charset=@{[&get_charset_name($kanjicode)]}\n};        $type = 'application/xml' if ($type =~ m!^application/(?:rdf|rss)\+xml$!) && ($UA =~ m#Gecko#);
255          print qq{Content-Type: $type; charset=@{[&main::get_charset_name ($main::kanjicode)]}\n};
256          ## meta element is not needed
257      }      }
258      #if ($main::ENV{HTTP_IF_MODIFIED_SINCE}) {      #if ($main::ENV{HTTP_IF_MODIFIED_SINCE}) {
259        ## TODO: IMS support        ## TODO: IMS support
# Line 277  sub print_header ($;%) { Line 261  sub print_header ($;%) {
261            
262      ## TODO: more Vary: support      ## TODO: more Vary: support
263      print <<"EOD";      print <<"EOD";
264  Vary: Negotiate,User-Agent,Accept-Language  Vary: Negotiate,User-Agent,Accept-Language,Accept-Type
265  Content-Style-Type: text/css  Content-Style-Type: text/css
266    
267  EOD  EOD
   $option{o}->{-header}->{links} = join "\n", (@head);  
268  }  }
269    
270  sub get_charset_name ($;%) {  sub get_charset_name ($;%) {
# Line 302  sub escape { Line 285  sub escape {
285      $s =~ s|<|&lt;|g;      $s =~ s|<|&lt;|g;
286      $s =~ s|>|&gt;|g;      $s =~ s|>|&gt;|g;
287      $s =~ s|"|&quot;|g;      $s =~ s|"|&quot;|g;
288        $s =~ s/([\x00-\x08\x0B\x0C\x0E-\x1F])/sprintf '&amp;#%d;', ord $1/ge;
289            ## XML unsafe control chars
290      return $s;      return $s;
291  }  }
292    
# Line 325  sub convert_format ($$$;%) { Line 310  sub convert_format ($$$;%) {
310    } elsif ($option{-error_no_return}) {    } elsif ($option{-error_no_return}) {
311      return undef;      return undef;
312    } elsif ($t =~ /HTML|xml/) {    } elsif ($t =~ /HTML|xml/) {
313      length $content ? '<pre>'.&escape($content).'</pre>' : '';      if (length $content) {
314          my $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'pre');
315          return $r->append_text ($content);
316        } else {
317          return '';
318        }
319    } else {    } else {
320      $content;      $content;
321    }    }
322  }  }
323    
 {my %FormIndex;  
 sub make_custom_form ($$$$%) {  
     my ($wfname, $definition, $template, $foption, $option) = @_;  
     ## $template is currently not used in this procedure.  
     #unless ($main::_EMBEDED) {  
         $FormIndex{$option->{page}}++;  
         if (length $definition) {  
             my $param = bless {depth=>10}, 'SuikaWiki::Plugin';  
             $param->{page} = $option->{page};  
             my $lastmodified = $database->mtime ($option->{page});  
             &load_formatter (qw/form_input form_option/);  
             $definition = &unescape ($definition);  
             $definition =~ s/\\(['\\])/$1/g;  
             $foption = &unescape ($foption);  
             $foption =~ s/\\(['\\])/$1/g;  
             $fmt{form_option}->replace ($foption, $param);  
             $param->{output}->{form} = 1 unless defined $param->{output}->{form};  
             $param->{output}->{form} = 0 if $main::_EMBEDED;  
             $definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form};  
             $param->{output}->{page} ||= $option->{page};  
             $param->{form_disabled} = 1 if $database->meta (IsFrozen => $option->{page});  
             my $target_form = $param->{output}->{id};  
             my $r = '';  
             $r = <<EOH if $param->{output}->{form};  
 <form method="post" action="$url_cgi" id="wikiform-$FormIndex{$option->{page}}" class="wikiform">  
   <input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'default':'wikiform']}" />  
   <input type="hidden" name="mypage" value="@{[&escape($param->{output}->{page})]}" />  
   <input type="hidden" name="myLastModified" value="$lastmodified" />  
   <input type="hidden" name="mytouch" value="on" />  
   <input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex{$option->{page}})]}" />  
 EOH  
             $r .= qq(<a name="wikiform-$FormIndex{$option->{page}}"></a>) if $UA =~ m#Mozilla/[12]\.#;  
             $r .= $fmt{form_input}->replace ($definition, $param);  
             $r .= "</form>\n" if $param->{output}->{form};  
             $r;  
        } else {  ## No input-interface WikiForm  
          qq(<a id="wikiform-$FormIndex{$option->{page}}" name="wikiform-$FormIndex{$option->{page}}"><!-- #form --></a>);  
        }  
     #} else {  
     #    qq(<ins class="wiki-error">@{[&Resource('Error:WikiForm:EmbedIsNotSupported',escape=>1)]}</ins>);  
     #}  
 }}  
324    
325  sub init_form {  sub init_form {
326      ## TODO: Support multipart/form-data      ## TODO: Support multipart/form-data
# Line 433  sub init_form { Line 381  sub init_form {
381      $form{myname} = &code_convert(\$form{myname}, $kanjicode);      $form{myname} = &code_convert(\$form{myname}, $kanjicode);
382  }  }
383    
 sub get_subjectline {  
     my ($page, %option) = @_;  
     my $SubjectLine = SuikaWiki::Plugin->cache ('headline');  
     unless (defined $SubjectLine->{$page}) {  
       if (not &is_editable($page)) {  
         $SubjectLine->{$page} = "";  
       } else {  
         $SubjectLine->{$page} = do {  
           my $s=$database{$page};  
           $s =~ tr/\x0D//d;  
           $s =~ s!^\#\?[^\x0A\x0D]+[\x0A\x0D]*!!s;  
           $s =~ s/\x0A\x0A.*//s;  
           if (length ($s) > 500) {  
             $s = substr ($s, 0, 500);  
             $s =~ s/[^\x09\x0A\x20-\x7E]+$//s;  
             $s .= '...';  
           }  
           #if ($s =~ /^([^\x0A]*(?:\x0A+[^\x0A]+){0,9})/s) {  
           #  $s = $1;  
           #}  
           $s =~ s/[\x09\x0A\x20]+/\x20/gs;  
           $s =~ s/^[-=*>,:]+//;  
           $s =~ s/'''?//g;  
           $s =~ s/\[\[([^]]+)\]\]/$1/g;  
           $s =~ s/__&&([^&]+)&&__/$1/g;  
           $s =~ s/\[[A-Z]+(?:\([^)]+\))?\[([^]]+)\](?:\s\[([^]]+)\])?\]/$1$2/g;  
           $s =~ s/\([^\(\)]+\)//g;  
           $s =~ s/\[[^\[\]]+\]//g;  
           $s =~ s/>>[0-9]+//g;  
           $s =~ s/<[^<>]+>//g;  
           $s =~ s/20[0-9][0-9]-[01][0-9]-[0-3][0-9]\x20*[0-2][0-9]:[0-5][0-9]//g;  
           $s =~ s/ [Aa]n? / /g;  
           $s =~ s/ [Aa]t / @ /g;  
           $s =~ s/ [Tt]he / /g;  
           $s =~ s/,? and / & /g;  
           $s =~ s!,? or ! / !g;  
           $s =~ s! not !n't !g;  
           $s =~ s! (?:i|ha)s !'s !g;  
           $s =~ s! are !'re !g;  
           $s =~ s! [Ww]ith(in|out)? !' w/'.substr ($1,0,1).' '!ge;  
           $s =~ s!です。!。!g;  
           $s =~ s!ました。!た。!g;  
           $s =~ s!ありません!ない!g;  
           $s =~ s!します!する!g;  
           $s =~ s!(?:り)?ます!る!g;  
           $s =~ s!いよいよ|とうとう|ようやく!!g;  
           $s =~ s!とりあえず!!g;  
           $s =~ s!(?:、|。|[.,])\x20?$!!g;  
           $s =~ s/\x20+/\x20/g;  
           if (length ($s) > 400) {  
             $s = substr ($s, 0, 400);  
             $s =~ s/[^\x20-\x7E]+$//s;  
             $s .= '...';  
           }  
         $s};  
       }  
     }  
     if (length $SubjectLine->{$page}) {  
       $option{delimiter} = defined $option{delimiter} ? $option{delimiter} : &Resource('Title-Summary Delimiter');  
       $option{delimiter}.$SubjectLine->{$page}.$option{tail};  
     } else {  
       '';  
     }  
 }  
384    
385  sub open_db {  sub open_db {
386      if ($modifier_dbtype eq 'dbmopen') {      if ($modifier_dbtype eq 'dbmopen') {
# Line 527  sub editform (@) { Line 411  sub editform (@) {
411    $option{content} = $database{$option{page}} unless defined $option{content};    $option{content} = $database{$option{page}} unless defined $option{content};
412    $option{content} = $database{NewPageTemplate} unless length $option{content};    $option{content} = $database{NewPageTemplate} unless length $option{content};
413    $option{last_modified} = $database->mtime ($option{page}) unless defined $option{last_modified};    $option{last_modified} = $database->mtime ($option{page}) unless defined $option{last_modified};
   my $f = '';  
414    my $magic = '';    my $magic = '';
415    $magic = $1 if $option{content} =~ m/^([^\x0A\x0D]+)/s;    $magic = $1 if $option{content} =~ m/^([^\x0A\x0D]+)/s;
416        
# Line 544  sub editform (@) { Line 427  sub editform (@) {
427  <option value="edit" label="@{[&Resource('Edit:SaveAndEdit',escape=>1)]}"@{[$selected eq 'edit' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndEdit',escape=>1)]}</option>  <option value="edit" label="@{[&Resource('Edit:SaveAndEdit',escape=>1)]}"@{[$selected eq 'edit' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndEdit',escape=>1)]}</option>
428  </select>  </select>
429  EOH  EOH
430    $f .= <<"EOD";  
431    =pod
432    
433      my $f = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'form');
434        $f->set_attribute (action => SuikaWiki::Plugin->uri ('wiki');
435        $f->set_attribute (method => 'post');
436        if (!$option{confloct}) {
437          for ($f->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'label')) {
438            for ($_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'input')) {
439              $f->set_attribute (type => 'submit');
440              $f->set_attribute (name => 'mypreview_write');
441              $f->set_attribute (value => SuikaWiki::Plugin->resource ('Edit:Save'));
442            }
443            $_->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'kbd', value => 'S');
444          }
445        }
446    
447    =cut
448    
449      my $f = <<"EOD";
450  <form action="$uri{wiki}" method="post">  <form action="$uri{wiki}" method="post">
451      @{[ $option{conflict} ? '' : qq(<label><input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}" /><kbd>S</kbd></label>) ]}      @{[ $option{conflict} ? '' : qq(<label><input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}" /><kbd>S</kbd></label>) ]}
452      @{[ $option{admin} ? qq(<label>@{[&Resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10" /></label>) : "" ]} [@{[&get_new_anchor_index($option{content})]}]<br />      @{[ $option{admin} ? qq(<label>@{[&Resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10" /></label>) : "" ]} [@{[&get_new_anchor_index($option{content})]}]<br />
# Line 614  sub frozen_reject { Line 516  sub frozen_reject {
516          return 0;          return 0;
517      } else {      } else {
518          &_do_view_msg (-view => '-error', -page => $form{mypage},          &_do_view_msg (-view => '-error', -page => $form{mypage},
519                         error_message => &Resource ('Error:PasswordIsIncorrect'));                         error_message => SuikaWiki::Plugin->resource ('Error:PasswordIsIncorrect'));
520          exit;          exit;
521      }      }
522  }  }
523    
524  sub is_frozen ($) { $database->meta (IsFrozen => $_[0]) ? 1 : 0 }  sub is_frozen ($) { SuikaWiki::Plugin->_database->meta (IsFrozen => $_[0]) ? 1 : 0 }
525    
526  sub do_comment {  sub do_comment {
527      my ($content) = $database{$form{mypage}};      my ($content) = $database{$form{mypage}};
# Line 677  sub load_formatter (@) { Line 579  sub load_formatter (@) {
579              for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) {              for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) {
580                  $_->load_formatter ($fmt{$t}, type => 'wiki'.$t);                  $_->load_formatter ($fmt{$t}, type => 'wiki'.$t);
581              }              }
582              $fmt{$t}->option (return_class => 'SuikaWiki::Markup::XML') if $HAS_XML;              $fmt{$t}->option (return_class => 'SuikaWiki::Markup::XML');
583          }          }
584      }      }
585  }  }

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24