|
自作プラグイン 「comment3」
目次
プラグイン コード
##
# 一時書き込みエリアを設置する。
# :書式|
# #comment3
# PyukiWiki 一時コメント書き込みプラグイン
# 書き込みはテキストエリア内に保持され、修正時は編集も該エリア内で編集して再度「投稿」すればok
#
# 2007/01/15 スパム対策
# 2004/06/12 Nekyo(c) http://nekyo.hp.infoseek.co.jp/
# Based on OKAWARA,Satoshi's PukiWiki Plugin
# 2013/9/16 koala
use strict;
$comment3::cols = 70; # テキストエリアのカラム数
$comment3::rows = 5; # テキストエリアの行数
$comment3::no = 0;
my $mescom="";
my $_no_name = "";
my $_no_subject = "no subject";
sub plugin_comment3_action
{
return if ($::form{msg} =~ /^\s*$/); # msg なしで処理しない。
my $postdata = $::form{msg};
&::spam_filter($postdata, 1);
my $name = $_no_name;
$mescom = $::form{msg};
# $mescom =~ s/\r?\n/\~\r\n/g;
$mescom =~ s/\r?\n/<br>/g;
$postdata = '';
my @postdata_old = split(/\r?\n/, $::database{$::form{'mypage'}});
my $_comment3_no = 0;
foreach (@postdata_old) {
# $postdata .= $_ . "\n" ;
if (/^#comment3/ && (++$_comment3_no == $::form{comment3_no})) {
$postdata .= "#comment3\(" . $mescom . "\)\n";
} else {
$postdata .= $_ . "\n" ;
}
}
$::form{mymsg} = $postdata;
$::form{mytouch} = 'on';
&do_write("FrozenWrite");
&close_db;
exit;
}
sub plugin_comment3_convert
{
###
# my @argv = split(/,/, shift);
my $artic = shift;
# my $artic = $mescom;
$artic =~ s/<br>/\r\n/g;
###
$comment3::no++;
my $conflictchecker = &get_info($::form{mypage}, $::info_ConflictChecker);
return <<"EOD";
<form action="$::script" method="post">
<div>
<input type="hidden" name="comment3_no" value="$comment3::no" />
<input type="hidden" name="cmd" value="comment3" />
<input type="hidden" name="mypage" value="$::form{'mypage'}" />
<input type="hidden" name="myConflictChecker" value="$conflictchecker" />
<input type="hidden" name="mytouch" value="on" />
<!-- <textarea name="msg" rows="$comment3::rows" cols="$comment3::cols">$artic</textarea><br /> -->
<textarea name="msg" rows="$comment3::rows" cols="$comment3::cols">$artic</textarea>
<input type="submit" value="$::resource{article_btn}" />
</div>
</form>
EOD
}
1;
「comment」プラグインの修正
sub plugin_comment_action {
内の
if (/^#comment/ && (++$_comment_no == $::form{comment_no})) {
を
if (/^#comment(\(.*\))?$/ && (++$_comment_no == $::form{comment_no})) {
と書き換える
Counter: 3492,
today: 1,
yesterday: 1
|