############################################################################### # # MIMEタイプの設定を行うアクションハンドラ # ############################################################################### package plugin::attach::AdminMIMEHandler; 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; $wiki->set_title("MIMEタイプの設定"); if($cgi->param("ADD") ne ""){ return $self->add($wiki); } elsif($cgi->param("DELETE") ne ""){ return $self->delete($wiki); } else { return $self->form($wiki); } } #============================================================================== # 一覧画面 #============================================================================== sub form { my $self = shift; my $wiki = shift; my $buf = "

MIMEタイプの登録

\n". "
config('script_name')."\" method=\"POST\">\n". " 拡張子(ドットは不要) \n". " MIMEタイプ \n". " \n". " \n". "
\n". "

登録済のMIMEタイプ

\n". "
config('script_name')."\" method=\"POST\">\n". "\n". "\n"; my $mime = &Util::load_config_hash($wiki,$wiki->config('mime_file')); foreach my $key (sort(keys(%$mime))){ $buf .= "\n". " \n". " \n". " \n". "\n"; } $buf .= "
 拡張子MIMEタイプ
".&Util::escapeHTML($key)."".&Util::escapeHTML($mime->{$key})."
\n". "\n". "\n". "
\n"; return $buf; } #============================================================================== # 追加 #============================================================================== sub add { my $self = shift; my $wiki = shift; my $cgi = $wiki->get_CGI(); my $ext = $cgi->param("extention"); my $mime = $cgi->param("mimetype"); if($ext ne "" && $mime ne ""){ my $hash = &Util::load_config_hash($wiki,$wiki->config('mime_file')); $hash->{$ext} = $mime; &Util::save_config_hash($wiki,$wiki->config('mime_file'),$hash); $wiki->redirectURL($wiki->config('script_name')."?action=ADMINMIME"); #return $self->form($wiki); } else { return $wiki->error("拡張子とMIMEタイプを入力してください。"); } } #============================================================================== # 削除 #============================================================================== sub delete { my $self = shift; my $wiki = shift; my $cgi = $wiki->get_CGI(); my @ext_list = $cgi->param("extention"); my $hash = &Util::load_config_hash($wiki,$wiki->config('mime_file')); my $result = {}; foreach my $key (keys(%$hash)){ my $flag = 0; foreach my $ext (@ext_list){ if($ext eq $key){ $flag = 1; last; } } if($flag==0){ $result->{$key} = $hash->{$key}; } } &Util::save_config_hash($wiki,$wiki->config('mime_file'),$result); $wiki->redirectURL($wiki->config('script_name')."?action=ADMINMIME"); #return $self->form($wiki); } 1;