$1<\/blockquote>/mig; $text =~ s/^----\s*?\
/
/mig; $text =~ s/^\/\/.*?\
//mig; $text =~ s/^\s(.*\S.*?)\
/\n$1\n<\/pre>/mig; $text =~ s/\n<\/pre\>\n\//mig; $text =~ s/^\*\*\*(.*?)\
/\n
\n
\n
- $1<\/li>\n<\/ul>\n<\/ul>\n<\/ul>/mig; $text =~ s/^\*\*(.*?)\
/\n
\n
- $1<\/li>\n<\/ul>\n<\/ul>/mig; $text =~ s/^\*(.*?)\
/\n
- $1<\/li>\n<\/ul>/mig; $text =~ s/^\<\/ul\>\n\
\n//mig; $text =~ s/^\<\/ul\>\n\
\n//mig; $text =~ s/^\<\/ul\>\n\
\n//mig; $text =~ s/^\+\+\+(.*?)\
/\n
\n
\n
- $1<\/li>\n<\/ol>\n<\/ol>\n<\/ol>/mig; $text =~ s/^\+\+(.*?)\
/\n
\n
- $1<\/li>\n<\/ol>\n<\/ol>/mig; $text =~ s/^\+(.*?)\
/\n
- $1<\/li>\n<\/ol>/mig; $text =~ s/^\<\/ol\>\n\
\n//mig; $text =~ s/^\<\/ol\>\n\
\n//mig; $text =~ s/^\<\/ol\>\n\
\n//mig; $text =~ s/\
(.*?)\<\/red\>/$1<\/font>/sig; $text =~ s/\ (.*?)\<\/green\>/$1<\/font>/sig; $text =~ s/\ (.*?)\<\/blue\>/$1<\/font>/sig; $text =~ s/\ (.*?)\<\/cyan\>/$1<\/font>/sig; $text =~ s/\ (.*?)\<\/magenta\>/$1<\/font>/sig; $text =~ s/\ (.*?)\<\/yellow\>/$1<\/font>/sig; my @a = split(/\n/, $text); my $TableWriting = 0; $text = ''; for(my $i = 0 ; $i < @a ; $i++) { my $line = $a[$i]; if($line =~ /^,/) { if(!$TableWriting) { $text .= " \n"; $TableWriting = 1; } $line =~ s/^,//; my @b = split(/,/, $line); $text .= "
\n"; $TableWriting = 0; } $text .= $line; } $text .= "\n"; } $text =~ s/\[(.*?)\|(.*?)\]/$1<\/a>/mig; $text = $this->ConvertURLLinks($App, $pParams, $text); $text =~ s/^(\<\/ol\>\n)\\n"; for(my $j = 0 ; $j < @b ; $j++) { $text .= " \n"; } else { if($TableWriting) { $text .= "$b[$j] \n"; } $text .= "
\n/$1/mig; $text =~ s/^(\<\/ul\>\n)\
\n/$1/mig; $text =~ s/^(\(.*?)\<\/h\d\>\n)\
\n/$1/mig; $text =~ s/^(\<\/table\>\n)\
\n/$1/mig; $text =~ s/^(\<\/pre\>\n)\
\n/$1/mig; $text =~ s/^(\
\n)\
\n/$1/mig; # $text =~ s//<//mg; $text =~ s/⊃/^/mg; $text =~ s/⊂/_/mg; $text =~ s/&kakubra;/[/mg; $text =~ s/&kakuket;/]/mg; $text =~ s/([^\\])\\([^\\])/$1$2/mg; # $text =~ s/([^\\])\\([^\\])/$1$2/mg; no strict; $text =~ s/\{\{(.*?::.*?)\((.*?)\)\}\}/eval("$1(" . '$this,$App,$pParams,' . "$2);");/emg; # $text =~ s/\{\{(.*?\-\>.*?)\((.*?)\)\}\}/eval("$1(" . '$App,$pParams,' . "$2)");/emg; # $text =~ s/\{\{(.*?\-\>.*?)\((.*?)\)\}\}/eval("&ExecuteSubroutine($App,$pParams,$1,$2)");/emg; $text =~ s/\{\{(.*?\-\>.*?)\((.*?)\)\}\}/&ExecuteSubroutine($App,$pParams,$1,$2);/emg; $text =~ s/\{\{(.*?::.*?)\}\}/eval("$1(" . '$this,$App,$pParams);');/emg; $text =~ s/\{\{(.*?\-\>.*?)\}\}/eval("$1(" . '$App,$pParams);');/emg; use strict; $text =~ s/\n$//; $charcode = $OriginalCode if(!defined $charcode); #Jcode::convert(\$text, $charcode, "euc-jp") if($charcode ne ''); Jcode::convert(\$text, $charcode, $OriginalCode) if($charcode ne '' and $charcode ne $OriginalCode); return $text; } sub ExecuteSubroutine { my ($App, $pParams, $s1, $s2) = @_; my $cmd = "$s1(" . '$App,$pParams,' . "$s2)"; #print "1: [$cmd]
\n"; my $ret = eval($cmd); $ret = '' if($ret =~ /^-?\d$/); return $ret; } sub UpdatePage { my ($this, $App, $pParams, $path) = @_; $pParams->{CurDir} = Utils::URLDecode($pParams->{CurDir}); $pParams->{FileName} = Utils::URLDecode($pParams->{FileName}); if(!defined $path) { $path = $pParams->{FileName}; # $path = Utils::URLDecode($pParams->{FileName}); #Jcode::convert(\$path, $pParams->{FileSystemCharCode}); $path = $this->GetWikiPath($App, $pParams, $path); #Jcode::convert(\$path, $pParams->{FileSystemCharCode}); #print "f: $path
\n"; } return if(!defined $pParams->{FormText}); my $LocalPath = $path; $App->PrintRawHTML("FileName: $LocalPath
\n"); #Jcode::convert(\$LocalPath, $pParams->{FileSystemCharCode}); Utils::ConvertHTMLSpecialCharacters($pParams->{FormText}); #my $SourceCharCode = Jcode::getcode($pParams->{FormText}); my $SourceCharCode = ($pParams->{WebCharCode} eq 'utf8')? 'utf-8' : $pParams->{WebCharCode}; #$App->print("S: $SourceCharCode\n"); Jcode::convert(\$pParams->{FormText}, $pParams->{FileSystemCharCode});#, $SourceCharCode); $pParams->{FormText} =~ s/\r\n/\n/mg; $pParams->{FormText} =~ s/\r/\n/mg; #Sourceがutf8でasciiのみの時、なぜか半角スペースが??に化けるのでその対策 $pParams->{FormText} =~ s/\?\?/ /mg; #$App->print($pParams->{FormText}); #return; my $out = new JFile($LocalPath, "w"); if($out) { $out->print($pParams->{FormText}); $out->Close(); $App->H3("[$LocalPath] has been updated\n"); } else { $App->H3("Error: Can not write to [$LocalPath]\n"); } } sub EditPage { my ($this, $App, $pParams, $path, $Action) = @_; # $pParams->{CurDir} = $this->{WikiDir} if(!defined $pParams->{CurDir}); $pParams->{CurDir} = Utils::URLDecode($pParams->{CurDir}); $pParams->{FileName} = Utils::URLDecode($pParams->{FileName}); if(!defined $path) { $path = $this->GetWikiPath($App, $pParams, $pParams->{FileName}); } $Action = "$this->{ModuleName}::UpdatePage" if(!defined $Action); $pParams->{WikiTextBoxWidth} = 30 if(!defined $pParams->{WikiTextBoxWidth} or $pParams->{WikiTextBoxWidth} <= 10); $pParams->{WikiTextBoxHeight} = 80 if(!defined $pParams->{WikiTextBoxHeight} or $pParams->{WikiTextBoxHeight} <= 5); my $LocalPath = $path; Jcode::convert(\$LocalPath, $pParams->{FileSystemCharCode}); $App->H3("Edit [$LocalPath]"); my $FormText; $FormText = JFile->new()->ReadFile($LocalPath) if(-e $LocalPath); if(!defined $FormText) { if($FormText =~ /\.html?$/i) { $App->print("Template [$this->{HTMLTemplatePath}]\n"); $FormText = JFile->new()->ReadFile($this->{HTMLTemplatePath}); } else { $App->print("Template [$this->{WikiTemplatePath}]\n"); $FormText = JFile->new()->ReadFile($this->{WikiTemplatePath}); } } Jcode::convert(\$FormText, $pParams->{WebCharCode}); my $JS = new JSParams; my $Debug = 0; if($path !~ /\.html?$/i) { $App->print("not html\n") if($Debug); my $s = $JS->GetJSResizableString('.TextAreaText'); $App->PrintRawHTML("$s\n"); Utils::InvalidateHTMLTags($FormText, 1, 1); } elsif($FormText =~ /\