-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0ch_ruby.pl
More file actions
152 lines (126 loc) · 5.18 KB
/
0ch_ruby.pl
File metadata and controls
152 lines (126 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#============================================================================================================
#
# 拡張機能 - 文字にルビを!
# 0ch_ruby.pl
#
#============================================================================================================
package ZPL_ruby;
#------------------------------------------------------------------------------------------------------------
# 拡張機能名称取得
#------------------------------------------------------------------------------------------------------------
sub getName
{
return '<ruby>文字<rp>(</rp><rt>もじ</rt><rp>)</rp></ruby>に<ruby>ルビ<rp>(</rp><rt>よみがな</rt><rp>)</rp></ruby>を!';
}
#------------------------------------------------------------------------------------------------------------
# 拡張機能説明取得
#------------------------------------------------------------------------------------------------------------
sub getExplanation
{
my $description = 'この<ruby>プラグイン<rp>(</rp><rt>拡張機能</rt><rp>)</rp></ruby>を<ruby>導入<rp>(</rp><rt>どうにゅう</rt><rp>)</rp></ruby>した<ruby>状態<rp>(</rp><rt>じょうたい</rt><rp>)</rp></ruby>で$[ruby|ruby>漢字<rp>(</rp><rt>かんじ</rt><rp>)</rp></ruby>|<ruby>ルビ<rp>(</rp><rt>よみがな</rt><rp>)</rp></ruby>]と<ruby>本文<rp>(</rp><rt>ほんぶん</rt><rp>)</rp></ruby>に<ruby>書<rp>(</rp><rt>か</rt><rp>)</rp></ruby>くと<ruby>漢字<rp>(</rp><rt>かんじ</rt><rp>)</rp></ruby>に<ruby>ルビ<rp>(</rp><rt>よみがな</rt><rp>)</rp></ruby>をつけることができます。';
$description = $description.'<br><ruby>非対応<rp>(</rp><rt>ひたいおう</rt><rp>)</rp></ruby>ブラウザでも「漢字(かんじ)」と<ruby>表示<rp>(</rp><rt>ひょうじ</rt><rp>)</rp></ruby>されます。';
return $description;
}
#------------------------------------------------------------------------------------------------------------
# 拡張機能タイプ取得
#------------------------------------------------------------------------------------------------------------
sub getType
{
return (1|2);
}
#------------------------------------------------------------------------------------------------------------
# 設定リスト取得 (0ch+ Only)
#------------------------------------------------------------------------------------------------------------
sub getConfig
{
return {};
}
#------------------------------------------------------------------------------------------------------------
# 拡張機能実行インタフェイス
#------------------------------------------------------------------------------------------------------------
sub execute
{
my $this = shift;
my ($Sys, $Form, $type) = @_;
# 0ch本家では実行しない
return 0 if (!$this->{'is0ch+'});
my $MESSAGE = $Form->Get('MESSAGE');
# $[ruby|(漢字)|(ルビ)] 処理部
$MESSAGE =~ s{\$\[ruby\|(.+?)\|(.+?)\]}{do {
my $target = $1; # ルビ対象
my $ruby = $2; # ルビ
"<ruby>$target<rp>(</rp><rt>$ruby</rt><rp>)</rp></ruby>"; # 置き換え!
# $&; # 置換しない場合はこれをコメント解除
}}egi;
$Form->Set('MESSAGE', $MESSAGE);
return 0;
}
#------------------------------------------------------------------------------------------------------------
# なんちゃってbbs.cgiエラーページ表示
#------------------------------------------------------------------------------------------------------------
sub PrintBBSError
{
my ($Sys, $err) = @_;
require './module/orald.pl';
my $CGI = $Sys->Get('MainCGI');
my $Page = $CGI->{'PAGE'};
my $Error = ORALD->new;
$Error->Load($Sys);
$Error->Print($CGI, $Page, $err, $Sys->Get('AGENT'));
$Page->Flush('', 0, 0);
exit($err);
}
#------------------------------------------------------------------------------------------------------------
# コンストラクタ
#------------------------------------------------------------------------------------------------------------
sub new
{
my $class = shift;
my ($Config) = @_;
my $this = {};
bless $this, $class;
if (defined $Config) {
$this->{'PLUGINCONF'} = $Config;
$this->{'is0ch+'} = 1;
}
else {
$this->{'CONFIG'} = $class->getConfig();
$this->{'is0ch+'} = 0;
}
return $this;
}
#------------------------------------------------------------------------------------------------------------
# 設定値取得 (0ch+ Only)
#------------------------------------------------------------------------------------------------------------
sub GetConf
{
my $this = shift;
my ($key) = @_;
if ($this->{'is0ch+'}) {
return $this->{'PLUGINCONF'}->GetConfig($key);
}
elsif (defined $this->{'CONFIG'}->{$key}) {
return $this->{'CONFIG'}->{$key}->{'default'};
}
}
#------------------------------------------------------------------------------------------------------------
# 設定値設定 (0ch+ Only)
#------------------------------------------------------------------------------------------------------------
sub SetConf
{
my $this = shift;
my ($key, $val) = @_;
if ($this->{'is0ch+'}) {
$this->{'PLUGINCONF'}->SetConfig($key, $val);
}
elsif (defined $this->{'CONFIG'}->{$key}) {
$this->{'CONFIG'}->{$key}->{'default'} = $val;
}
else {
$this->{'CONFIG'}->{$key} = { 'default' => $val };
}
}
#============================================================================================================
# Module END
#============================================================================================================
1;