package Common; use Exporter; @ISA = qw(Exporter); #公開したいサブルーチン #@EXPORT = qw(DelSpace Reduce01 MakePath RegExpQuote); use strict; my $PermitDebugPrint = 1; my %LanguageCodeHash = ( 'Japanese', 'jp', 'English', 'en', 'British', 'en', 'American', 'en', 'Korea', 'kr', 'Chinese', 'ch', ); sub new { my ($module, $path) = @_; my $this = {}; bless $this; return $this; } sub DESTROY { my $this = shift; } #=============================================== # Application, Document 共通関数 #=============================================== sub GetApplication { return shift->{Application}; } sub Application { return shift->{Application}; } sub App { return shift->{Application}; } sub SetApplication { my ($this,$app)=@_; return $this->{Application} = $app; } sub GetDocument { return shift->App()->Doc(); } sub Document { return shift->App()->Doc(); } sub Doc { return shift->App()->Doc(); } sub GetIniFile { return shift->App()->Ini(); } sub IniFile { return shift->App()->Ini(); } sub Ini { return shift->App()->Ini(); } sub Args { return shift->App()->Args(); } sub CGIForm { return shift->App()->CGIForm();} sub FilePath() { return shift->App()->Doc()->FilePath(); }; sub SetFilePath { my ($this,$p)=@_; return $this->Doc()->SetFilePath($p); }; sub WorkDir { return shift->App()->{'WorkDir'}; } sub SetWorkDir { my ($this,$path)=@_; return $this->App()->SetWorkDir($path); } sub ModuleName { my ($this) = @_; return $this->{ModuleName} if($this->{ModuleName}); return ref($this); } sub SetModuleName { my ($this,$name)=@_; return $this->{ModuleName} = $name; } sub Debug { my ($this) = @_; return $this->App()->{Debug} if($this->App());; return $this->{Debug}; } sub SetDebug { my ($this, $f) = @_; $f = 0 if(!defined $f); if($f == 1 or $f =~ /on/i) { $this->{Debug} = 1; } elsif($f =~ /\+/) { $this->{Debug}++; } elsif($f =~ /-/) { $this->{Debug}--; $this->{Debug} = 0 if($this->{Debug} < 0); } $this->App()->{Debug} = $this->{Deubg} if($this->App()); return $this->{Debug}; } sub DoConfirm { return shift->App()->DoConfirm(); } sub PrintLevel { return shift->App()->PrintLevel(); } #======================================================== # 言語設定関係 #======================================================== sub SetLanguage { my ($this, $l) = @_; $this->{Language} = 'English' if(!defined $this->{Language}); return $this->{Language} if(!defined $l or $l eq ''); return $this->{Language} = $l; } sub Language { my ($this) = @_; $this->{Language} = 'English' if(!defined $this->{Language} or $this->{Language} eq ''); return $this->{Language}; } sub LanguageCode { my ($this) = @_; my $l = $this->Language(); my $c = $LanguageCodeHash{$l}; return 'Invalid Language' if(!defined $c or $c eq ''); return $c; } sub pVariable { my ($this, $name, $val) = @_; if(defined $this->{$name}) { #print "exist: $name, $this->{$name}\n"; return \$this->{$name}; } $this->{$name} = $val; return \$this->{$name}; } sub stdio { return shift->App()->stdio(); } sub printf { my ($this, @args) =@_; return $this->App()->printf(@args) if($this->App()); return printf(@args); } sub print { my ($this, @args) =@_; return $this->App()->print(@args) if($this->App()); return print(@args); } sub DebugPrint { my ($this, @args) =@_; if($this->App()) { $PermitDebugPrint = $this->App()->PermitDebugPrint(); } return if(!$PermitDebugPrint); return $this->App()->DebugPrint(@args) if($this->App()); return print(@args) if($this->{'Debug'}); return 0; } sub set { my ($this,$key,$val) =@_; return shift->App()->set($key,$val); } sub get { my ($this,$key,$defval)=@_; return shift->App()->get($key,$defval); } sub GetGetArg { my ($this,$key,$val) =@_; return shift->App()->GetGetArg($key,$val); } sub ReadSetting { return shift->App()->ReadSetting(); } sub SaveSetting { return shift->App()->SaveSetting(); } sub LF { return shift->App()->LF(); } sub DirectorySeparator { return shift->App()->DirectorySeparator(); } sub OS { return shift->App()->OS(); } sub AppName { return shift->App()->AppName(); } sub Program { return shift->App()->Program(); } sub GetProgram { return shift->App()->Program(); } sub SetProgram { my($this,$p)=@_; return $this->App()->SetProgram($p); } sub ProgramPath { return shift->App()->ProgramPath(); } sub SetProgramPath { my ($this,$p) = @_; return $this->App()->SetProgramPath($p); } sub Version { return shift->App()->Version(); } sub SetVersion { my ($this,$v) = @_; return $this->App()->SetVersion($v); } sub AppTitle { return shift->App()->Title(); } sub GetTitle { return shift->App()->Title(); } sub Title { return shift->App()->Title(); } sub SetTitle { my ($this, $title) = @_; return $this->title($this->Title()) unless($title); return $this->title($this->App()->SetTitle($title)); } sub OSCharCode { return shift->App()->OSCharCode(); } sub FileSystemCharCode { return shift->App()->FileSystemCharCode(); } sub FileCharCode { return shift->App()->FileCharCode(); } sub PerlCharCode { return shift->App()->PerlCharCode(); } sub SQLCharCode { return shift->App()->SQLCharCoderCode(); } sub WebCharCode { return shift->App()->WebCharCode(); } sub WebCharSet { return shift->App()->WebCharSet(); } 1;