]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/bugs/IkiWiki::showform_can_not_be_injected__63__.mdwn
update for rename of recentchanges.mdwn to json.tl.ph.mdwn
[git.ikiwiki.info.git] / doc / bugs / IkiWiki::showform_can_not_be_injected__63__.mdwn
1 I want inject IkiWiki::showform and use replace submit button with translated button,
2 but it seem no effect in cgi, does IkiWiki::showfrom can not be injectd when run as cgi?
4 by the way, what about add a post-showform hook to ikiwiki?
6 the below is my code:
7     
8     #!/usr/bin/perl
9     package IkiWiki::Plugin::chinesize;
10     
11     use warnings;
12     use strict;
13     use IkiWiki 3.00;
14     
15     inject(name => 'IkiWiki::showform', call => \&myshowform);
16     
17     sub myshowform ($$$$;@) {
18                         my $form=prepform(@_);
19                         shift;
20                         my $buttons=shift;
21                         my $session=shift;
22                         my $cgi=shift;
23                     
24                     my $str=cgitemplate($cgi, $form->title,
25                                               $form->render(submit => $buttons), @_);
26                     
27                     my %names = ("Save Page" => "保存页面",
28                                  "Preview"   => "预览",
29                                  "Cancel"    => "取消",
30                                  "Diff"      => "差异比较",
31                                  "Rename"    => "重命名",
32                                  "Remove"    => "删除",
33                                  "Login"     => "登录",
34                                  "Register"  => "注册",
35                                  "Logout"    => "退出",
36                                  "Setup"     => "设置",
37                                  "Users"     => "所有用户",
38                                  "Name"      => "用户名",
39                                  "Password"  => "密码",
40                                  "Email"     => "电子邮件",
41                                  "Save Preferences"   => "保存选项",
42                                  "Confirm Password"   => "再次输入密码",
43                                  "Create Account"     => "创建帐户",
44                                  "Reset Password"     => "重置密码",
45                                  "Insert Links"       => "插入链接",
46                                  "Rename Attachment"  => "重命名附件",
47                                  "Remove Attachments" => "删除附件",
48                                  "FormattingHelp"     => "格式帮助",
49                                  "Reset"              => "重置",
50                                  "Save Setup"         => "保存设置",
51                                  "Advanced Mode"      => "高级模式",
52                                  "Account Creation Password" => "请输入帐户创建密码(管理员预设)"
53                                  );
54                     
55                     foreach my $old_name (keys(%names))
56                     {
57                     my $new_name = Encode::decode_utf8($names{$old_name});
58                     $str =~ s/<input +id="([_A-Za-z0-9]+)" +name="([_A-Za-z0-9]+)" +type="([_A-Za-z0-9]+)" +value="($old_name)" +\/>/<button id="$1" name="$2" type="$3" value="$4">$new_name<\/button>/g;
59                     $str =~ s/<input +name="([_A-Za-z0-9]+)" +type="([_A-Za-z0-9]+)" +value="($old_name)" +\/>/<button name="$1" type="$2" value="$3">$new_name<\/button>/g;
60                     $str =~ s/<input +class="([_A-Za-z0-9]+)" +id="([_A-Za-z0-9]+)" +name="([_A-Za-z0-9]+)" +type="([_A-Za-z0-9]+)" +value="($old_name)" +\/>/<button class="$1" id="$2" name="$3" type="$4" value="$5">$new_name<\/button>/g;
61                     $str =~ s/<div class="([_A-Za-z0-9]+)" id="([_A-Za-z0-9]+)">$old_name<\/div>/<div class="$1" id="$2">$new_name<\/div>/g;
62                     $str =~ s/<div class="([_A-Za-z0-9]+)" id="([_A-Za-z0-9]+)"><span class="([_A-Za-z0-9]+)">$old_name<\/span><\/div>/<div class="$1" id="$2"><span class="$3">$new_name<\/span><\/div>/g;
63                     $str =~ s/<a href="\.\/ikiwiki\/formatting\/">($old_name)<\/a>/<a href="\.\/ikiwiki\/formatting\/">$new_name<\/a>/g;
64                     };
65                     
66                         printheader($session);
67                         print $str
68                     
69                     }
70                     
71