############################################################ # # 検索フォームを表示します。 #
# {{search}}
# 
# サイドバーに表示する場合はvオプションをつけてください。 #
# {{search v}}
# 
# ############################################################ package plugin::search::SearchHandler; use strict; #=========================================================== # コンストラクタ #=========================================================== sub new { my $class = shift; my $self = {}; return bless $self,$class; } #=========================================================== # アクションの実行 #=========================================================== sub do_action { my $self = shift; my $wiki = shift; my $cgi = $wiki->get_CGI; my $word = Util::trim($cgi->param("word")); my $buf = ""; $wiki->set_title("検索"); $buf .= "
config('script_name')."\">\n". "キーワード escapeHTML($word)."\"> "; $buf .= "param("t") ne "or"); $buf .= ">\n"; $buf .= "param("t") eq "or"); $buf .= ">\n"; $buf .= "param("c") eq "true"); $buf .= ">\n"; $buf .= "". "". "
\n"; #--------------------------------------------------------------------------- # 検索実行 if($word ne ""){ my @list = $wiki->get_page_list({-permit=>'show'}); my @words = split(/ +| +/,$word); my $name; $buf = $buf."\n"; } return $buf; } #=========================================================== # 検索にマッチした行を取り出す関数 #=========================================================== sub get_match_content { my $wiki = shift; my $name = shift; my $content = shift; my $index = shift; unless($wiki->can_show($name)){ return "参照権限がありません。"; } my $pre = substr($content,0,$index); my $post = substr($content,$index,length($content)-$index); my $pre_index = rindex($pre,"\n"); if($pre_index==-1){ $pre_index = 0; } my $post_index = index($post,"\n"); if($post_index==-1){ $post_index = length($post); } $post_index += $index; return substr($content,$pre_index,$post_index-$pre_index); } 1;