\n");
my $text;
#$App->print("nParts=$nParts\n");
if($nParts <= 1) {
my $header = substr($DecodedContent, 0, 100);
$header =~ s/[\s\r\n]+/ /sg;
Utils::DelSpace($header);
$header = 'Content' if($header eq '');
$App->PrintRawHTML("
\n");
}
else {
for(my $i = 0 ; $i < $nParts ; $i++) {
my $p = $psp->[$i];
$text = '';
if(defined $p->{Subject}) {
$text = $p->{Subject};
$text = $mf->DecodeSubject($text);
}
elsif($p->{ContentType} =~ /text\//i) {
$p->ReadHeader("sjis", 0, $p->{Content});
# $p->GetMultipartInfoFromString("sjis", $p->{Content});
my $s = ($p->{Subject})? $p->{Subject} : $this->{pMail}->{Subject};
$s = $mf->DecodeSubject($s);
my $f = ($p->{From})? $p->{From} : $this->{pMail}->{From};
$f = $mf->DecodeSubject($f);
my $CT = $p->{ContentType};
$CT = (defined $CT)? $CT : '';
$text = "$s: $f [$CT]";
}
elsif(defined $p->{ContentType}) {
$text = $p->{ContentType};
$text =~ s/\s*;\s*name=.*$//i;
$text =~ s/\s*;\s*file=.*$//i;
if(defined $p->{FileName}) {
my $f = $p->{FileName};
Jcode::convert(\$f, "sjis");
$text = "$text [$f]";
}
if(defined $p->{ContentTransferEncoding}) {
$text = "$text [$p->{ContentTransferEncoding}]";
}
}
#$App->print("$i: [$text]\n");
my ($pHeader, $pContent) = $mf->SplitHeaderFromString($p->{Content});
my $Header = join('', @$pHeader);
my $content = join('', @$pContent);
my $ContentTransferEncoding = $p->GetHeaderFromString("Content-Transfer-Encoding", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content});
if($ContentTransferEncoding) {
$content = $mf->DecodeContent($pParams->{WebCharCode}, 1, undef, $content, $ContentTransferEncoding);
}
my $From = $p->GetHeaderFromString("From", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content});
$From = $mf->DecodeSubject($From, $pParams->{WebCharCode});
my $To = $p->GetHeaderFromString("To", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content});
$To = $mf->DecodeSubject($To, $pParams->{WebCharCode});
my $Date = $p->GetHeaderFromString("Date", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content});
my $Subject = $p->GetHeaderFromString("Subject", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content});
$Subject = $mf->DecodeSubject($Subject, $pParams->{WebCharCode});
my $ContentType = $p->GetHeaderFromString("Content-Type", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content});
my $ContentDisposition = $p->GetHeaderFromString("Content-Disposition", $pParams->{WebCharCode}, 0, $pHeader);
$App->PrintRawHTML("
\n");
if($ContentType =~ /application/i or $ContentType =~ /stream/i) {
my $filename = $mf->GetAttachedFileName($pHeader, $pParams->{WebCharCode});
my $header = "Attached file [$filename]";
$App->PrintRawHTML("
\n");
$header .= " ({DownloadFileLink}&iAttachedFile=$i&Path=$Path\" target=\"_blank\">download)\n";
$App->PrintRawHTML("$header\n");
}
else {
if($ContentType =~ /html/i) {
my $header = $content;
$header =~ s/\<[^\>]+\>//sg;
$header = substr($header, 0, 100);
$header =~ s/ / /sig;
Utils::DelSpace($header);
$header = 'Content' if($header eq '');
#$App->print("h[$header]\n");
$App->PrintRawHTML("
\n");
$App->PrintRawHTML("
\n");
# $content =~ /\<[^\>]*\>.*?\<\/[^\>]*\>/sig;
# $content =~ /\
]*\>.*?\<\/img[^\>]*\>/sig;
if($pParams->{Mode} eq 'HTML') {
$App->PrintRawHTML("$content\n");
}
else {
$App->PrintRawHTML("{ViewHTMLBaseLink}&iAttachedFile=$i&Path=$Path\" target=\"_blank\">View HTML
\n");
$App->print("$content\n");
}
}
elsif($ContentType =~ /text/i) {
my $header = substr($content, 0, 100);
$header =~ s/[\s\r\n]+/ /sg;
Utils::DelSpace($header);
$header = 'Content' if($header eq '');
#$App->print("h[$header]\n");
$App->PrintRawHTML("
\n");
$App->PrintRawHTML("
\n");
$App->print("$content\n");
}
else {
# $App->print("$content\n");
}
}
$App->PrintRawHTML("
\n");
# Content => $Parts[$i],
# From => $From,
# To => $To,
# Cc => $Cc,
# Bcc => $Bcc,
# ContentType => $ContentType,
# ContentTransferEncoding => $ContentTransferEncoding,
# ContentDisposition => $ContentDisposition,
# CharSet => $CharSet,
# Boundary => $Boundary2,
# FileName => $AttachFileName,
}
}
$App->PrintRawHTML("
\n");
}
sub ViewTextFile
{
my ($this, $App, $pParams, $Path) = @_;
$Path = $pParams->{Path} if($Path eq '');
$App->H3("Information for [$Path] (TEXT)");
my $content = JFile->new()->ReadFile($Path);
if($content) {
$App->print($content);
}
return 1;
}
sub ViewALMailAddressBookByTable
{
my ($this, $App, $pParams, $Path) = @_;
$Path = $pParams->{Path} if($Path eq '');
if($Path !~ /\.adr$/i) {
$App->H3("Invalid ALMail AddressBook file: [$Path]");
return 0;
}
$App->H3("Information for [$Path] (CSV)");
my $MultiFunctionTableJScript = JSParams->new()->GetMultiFunctionalTableString('.TableTest3'); #, sortList => '[[1,1]]', excludeColumns => '[2,3]');
my %MultiFunctionTableConfigByClass = (
class => 'tablesorter'
);
# $App->print($MultiFunctionTableJScript);
$App->PrintRawHTML($MultiFunctionTableJScript);
my $in = new JFile;
if(!$in->Open($Path, 'r')) {
$App->H2("Error: Can not read [$Path]: $!.\n");
return 0;
}
$App->BeginTable(1, undef, %MultiFunctionTableConfigByClass);
$App->BeginTableHeader();
$App->BeginTableRow();
$App->TableCell('
Group', undef, undef, undef, undef, 0);
$App->TableCell('
Name', undef, undef, undef, undef, 0);
$App->TableCell('
EMailName', undef, undef, undef, undef, 0);
$App->EndTableRow();
$App->EndTableHeader();
$App->BeginTableBody();
my $Group = '';
while(1) {
my $line = $in->ReadLine();
last if(!defined $line);
Utils::DelSpace($line);
#$App->print("l[$line]\n");
if($line =~ /^Group\s+(.*)$/i) {
$Group = $1;
next;
}
elsif($line =~ /^End\s+Group/i) {
next;
}
elsif($line eq '') {
next;
}
my ($name, $addr) = ($line =~ /^(.*?)\s*:\s*(.*)$/);
# next if(!defined $addr);
$App->BeginTableRow();
$App->TableCell($Group, undef, undef, undef, undef, 1);
$App->TableCell($name, undef, undef, undef, undef, 1);
$App->TableCell($addr, undef, undef, undef, undef, 1);
$App->EndTableRow();
}
$App->EndTableBody();
$App->EndTable();
return 1;
}
sub ViewCSVFileByTable
{
my ($this, $App, $pParams, $Path) = @_;
$Path = $pParams->{Path} if($Path eq '');
if($Path !~ /\.csv$/i) {
$App->H3("Invalid CSV file: [$Path]");
return 0;
}
$App->H3("Information for [$Path] (CSV)");
my $MultiFunctionTableJScript = JSParams->new()->GetMultiFunctionalTableString('.TableTest3'); #, sortList => '[[1,1]]', excludeColumns => '[2,3]');
my %MultiFunctionTableConfigByClass = (
class => 'tablesorter'
);
# $App->print($MultiFunctionTableJScript);
$App->PrintRawHTML($MultiFunctionTableJScript);
my $csv = new CSV;
$csv->Read($Path, 0);
my $pLabelArray = $csv->LabelArray();
my $nData = $csv->nData();
my $pDataArray = $csv->DataArray();
$App->BeginTable(1, undef, %MultiFunctionTableConfigByClass);
$App->BeginTableHeader();
$App->BeginTableRow();
for(my $i = 0 ; ; $i++) {
last if(!defined $pDataArray->[$i]);
$App->TableCell("Data $i", undef, undef, undef, undef, 0);
}
$App->EndTableRow();
$App->EndTableHeader();
$App->BeginTableBody();
for(my $i = 0 ; ; $i++) {
last if(!defined $pDataArray->[$i]);
$App->TableCell($pLabelArray->[$i], undef, undef, undef, undef, 1);
}
for(my $il = 0 ; ; $il++) {
last if(!defined $pDataArray->[0]->[$il]);
$App->BeginTableRow();
for(my $i = 0 ; ; $i++) {
#$App->print("$il: i=$i\n");
last if(!defined $pDataArray->[$i]->[$il]);
last if(!defined $pDataArray->[$i]);
$App->TableCell($pDataArray->[$i]->[$il], undef, undef, undef, undef, $il+1);
}
$App->EndTableRow();
}
$App->EndTableBody();
$App->EndTable();
return 1;
}
sub ViewImageFile
{
my ($this, $App, $pParams, $Path) = @_;
$Path = $pParams->{Path} if($Path eq '');
$App->H3("Information for [$Path] (IMAGE)");
if($Path =~ /\.pdf$/i) {
my ($drive, $directory, $filename, $ext1, $lastdir, $filebody) = Deps::SplitFilePath($Path);
$directory =~ s/\\/\//g;
$App->MakePDFFirstPageImage($pParams, $Path);
# $this->MakePDFFirstPageImage( $App, $pParams, $Path, %args, pFiles => \@files);
my $PDFPath = $Path;
$PDFPath =~ s/\.pdf$/\.jpg/i;
#$App->print("path[$Path]\n");
return if(!-f $PDFPath);
$Path = $PDFPath;
}
my ($url, $label) = $App->MakeInlineImageLinkURL($pParams, $Path, undef, $this->{ModuleName});
my $link = $App->MakeImageLinkString($pParams, $url, 0, 300);
# $App->print("$link\n");
$App->PrintRawHTML("$link\n");
return 1;
}
1;