#============================================================
# MyHTMLApplication
#============================================================
package MyHTMLApplication;
use MyApplication;
@ISA = qw(MyApplication);
use strict;
use English;
use File::Path;
use File::Basename;
use File::Find;
use CGI;
use Cwd;
#use UTF8Code;
use Deps;
use Utils;
use JFile;
use IniFile;
use GetArg;
use Template;
#==========================================
# 大域変数
#==========================================
my $DefaultSendmail = '/usr/sbin/sendmail';
my $SourceCharCode = Jcode::getcode('月火水木金土日 ');
#============================================================
# 静的関数
#============================================================
#============================================================
# 変数等取得関数
#============================================================
sub CSSPath { return shift->{CSSPath}; }
sub WebRoot { return shift->{WebRoot}; }
sub CGIPath { return shift->{CGIPath}; }
#============================================================
# コンストラクタ、デストラクタ
#============================================================
BEGIN { }
sub new
{
my ($module, $app) = @_;
my $this = {};
bless $this;
# $this->SUPER::new(@_);
return $this;
}
sub DESTROY
{
my $this = shift;
# $this->SUPER::DESTROY(@_);
}
#============================================================
# 継承クラスで定義しなおす関数
#============================================================
#============================================================
# 一般関数
#============================================================
sub MenuMode { return shift->{MenuMode}; }
sub SetMenuMode { my ($this, $mode) = @_; return $this->{MenuMode} = $mode; }
sub ConvertToHTML
{
my ($this, $s) = @_;
$s =~ s/[\r\n\s]*$//;
$s =~ s/\r//g;
$s =~ s/^[ \n\s]+/ /g;
# $s =~ s/^[ \n\s]+/ /g;
$s =~ s/[\n][\n\s]*\[/
[/g;
$s =~ s/[\n][\n\s]*\[/
[/g;
$s =~ s/[\n][\n\s]*/
/g;
# $s =~ s/[\n][\n\s]*/
/g;
return $s;
}
sub GetCSSKeys
{
my ($App, $pParams, $SpanID, $SpanClass) = @_;
if($App->MenuMode() eq 'css') {
if($SpanID !~ /=/) {
$SpanID = "class=\"$SpanID\"";
}
if($SpanClass !~ /=/) {
$SpanClass = "class=\"$SpanClass\"";
}
return ("", "", "", "");
}
return ('', '', '', '');
}
sub GetMainMenuKeys
{
my ($App, $pParams) = @_;
my ($MainPre, $MainPos, $pre, $pos) = $App->GetCSSKeys($pParams, "id=\"MainMenu\"", "class=\"MenuItem\"");
return ($MainPre, "$MainPos
", $pre, $pos) if($MainPre ne '');
return ($MainPre, $MainPos, $pre, $pos);
}
sub GetSubMenuKeys
{
my ($App, $pParams) = @_;
my ($MainPre, $MainPos, $pre, $pos) = $App->GetCSSKeys($pParams, "class=\"SubMenu\"", "class=\"MenuItem\"");
return ($MainPre, "$MainPos
", $pre, $pos) if($MainPre ne '');
return ($MainPre, $MainPos, $pre, $pos);
}
sub SetHTMLHeader
{
my ($this, $Title, $WebCharSet, $LinkTarget, $CSS, %args) = @_;
$this->{Title} = $Title;
$this->{WebCharSet} = $WebCharSet;
$this->{LinkTarget} = $LinkTarget;
$this->{CSS} = $CSS;
$this->{pHeaderFiles} = $args{-pHeaderFiles};
$this->{pHeaderFiles} = $args{pHeaderFiles} if(!defined $args{-pHeaderFiles});
}
sub SetHTMLInitialized
{
my ($this, $f) = @_;
$f = 1 if(!defined $f);
return $this->{HTMLInitialized} = $f;
}
sub ShowBlankPage
{
my ($this, $title, $charset) = @_;
$title = 'Blank page' if(!defined $title);
$charset = 'iso-8859-1' if(!defined $charset);
$this->InitHTML($title, $charset, '_self');
$this->EndHTML();
}
sub IsFrameMode { return (shift->{pFrameModeHash})? 1 : 0; }
sub GetFrameMode
{
my ($this) = @_;
return $this->pParams()->{FrameMode} if($this->pParams()->{FrameMode});
my $FrameMode = '';
if($this->{pFrameModeHash}) {
if($this->{pFrameModeHash}->{FrameMode} =~ /cols/i) {
$FrameMode = 'cols';
}
elsif($this->{pFrameModeHash}->{FrameMode} =~ /rows/i) {
$FrameMode = 'rows';
}
}
return $FrameMode;
}
sub SetFrameMode
{
my ($this, %args) = @_;
$this->SetOutputMode('HTML');
$this->{HTMLInitialized} = 0;
$this->{pFrameModeHash} = \%args;
$this->pParams()->{FrameMode} = $this->GetFrameMode();
}
sub InitHTMLFramePage
{
my ($this, $WebCharSet, $PrintHTMLHeader, $pHash, %args) = @_;
$WebCharSet = 'iso-8859-1' if(!defined $WebCharSet);
$PrintHTMLHeader = 1 if(!defined $PrintHTMLHeader);
$pHash = $this->{pFrameModeHash} if(!defined $pHash);
$pHash->{Title} = 'No title' if(!defined $pHash->{Title});
$pHash->{FrameMode} = "rows='64,*'" if(!defined $pHash->{FrameMode});
$pHash->{Content} = '
This page uses Frame, but your browser does not support it.
\n' if(!defined $pHash->{Content}); Utils::PrintHTMLHeader($WebCharSet) if($PrintHTMLHeader); my $FrameSetOption = ''; $FrameSetOption .= " framespacing=\"$pHash->{framespacing}\"" if(defined $pHash->{framespacing}); $FrameSetOption .= " border=\"$pHash->{border}\"" if(defined $pHash->{border}); $FrameSetOption .= " frameborder=\"$pHash->{frameborder}\"" if(defined $pHash->{frameborder}); my $Frame1Option = ''; $Frame1Option .= " scrolling='$pHash->{Frame1}->{scrolling}'" if(defined $pHash->{Frame1}->{scrolling}); $Frame1Option .= " resize='$pHash->{Frame1}->{resize}'" if(defined $pHash->{Frame1}->{resize}); $Frame1Option .= " target='$pHash->{Frame1}->{target}'" if(defined $pHash->{Frame1}->{target}); my $Frame2Option = ''; $Frame2Option .= " scrolling='$pHash->{Frame2}->{scrolling}'" if(defined $pHash->{Frame2}->{scrolling}); $Frame2Option .= " resize='$pHash->{Frame2}->{resize}'" if(defined $pHash->{Frame2}->{resize}); $Frame2Option .= " target='$pHash->{Frame2}->{target}'" if(defined $pHash->{Frame2}->{target}); my $Frame1Str = "{Frame1}->{name}\" $Frame1Option src=\"$pHash->{Frame1}->{src}\">"; my $Frame2Str = "{Frame2}->{name}\" $Frame2Option src=\"$pHash->{Frame2}->{src}\">"; my $DOCTYPEStr = Utils::GetDOCTYPEStr($args{DOCTYPEKey}); $DOCTYPEStr = '' if($DOCTYPEStr eq ''); print <