\n";
print $query->endform();
print $query->end_html();
}
###############################################################################
##---------------------------------------------------------------------------##
## print_mha_mesg() outputs the message data part of a message
## page in an archive.
##
sub print_mha_mesg {
my $arch = shift;
my $msgnum = shift;
my $filename = shift;
if (!open(MHAMESG, $filename)) {
my $errstr = qq/Unable to open "$filename"\n/;
carp $errstr;
print html_error($errstr);
return 0;
}
## Get URL to archive
my $base = $Rc->{archive}{$arch}[1];
## Read header comments and print them.
my %field = (); my @field = (); my $field;
while () {
last if /^/;
if (/^/) {
push(@field, $1);
push(@{$field{$1}}, mhonarc::entify(mhonarc::uncommentize($2)));
}
}
my $atitle = $Rc->{archive}{$arch}[0];
print <
$atitle: $msgnum
EOT
my %printed = ();
foreach $field (@field) {
next if $printed{$field};
$printed{$field} = 1;
print qq(
\n),
qq(
$field
\n),
qq(
);
print join(", ", @{$field{$field}});
print qq(
\n);
}
print "\n";
## Just extract the message header and body part of the page. Adjust
## relative URLs so links to derived files will work.
my $replsub = sub {
my $url = shift;
unless ($url =~ /^[\w]+:/ or $url =~ /^\// or $url =~ /^#/) {
return $base . $url;
}
$url;
};
while () {
next unless /^/i;
while () {
last if /^/i;
s/(href\s*=\s*["'])([^"']+)(["'])
/join("",$1,&$replsub($2),$3)
/xgei;
s/(src\s*=\s*["'])([^"']+)(["'])
/join("",$1,&$replsub($2),$3)
/xgei;
print;
}
last;
}
close MHAMESG;
## Done
1;
}
##---------------------------------------------------------------------------##
sub set_resources {
my $cgiurl = $query->url() . "?archive=$archive";
$mhonarc::NOTE =<<'EOT';
Message not available
EOT
$mhonarc::TLINONEEND =<<'EOT';
EOT
$mhonarc::TINDENTBEG =<<'EOT';
EOT
$mhonarc::TINDENTEND =<<'EOT';
EOT
$mhonarc::TCONTBEG =<<'EOT';
$SUBJECTNA$(continued)
EOT
$mhonarc::TCONTEND =<<'EOT';
EOT
}
##---------------------------------------------------------------------------##
sub print_main_menus {
print <
EOT
}
##---------------------------------------------------------------------------##
sub html_error {
print <<'EOT';
Note
EOT;
print $query->p(@_);
print <<'EOT';
EOT
}
##---------------------------------------------------------------------------##
## JavaScript Code
##---------------------------------------------------------------------------##
sub jscript_define {
## JavaScript for main index page
##-----------------------------------------------------------------------##
$JSMenuBar =<<'EOJS';
// Set the selection of all messages
function checkAll (form, val) {
var i;
for (i=0; i < form.elements.length; ++i) {
if (form.elements[i].name == 'msgnum') {
form.elements[i].checked = val;
}
}
}
// Process Archive menu selection
function process_file_menu (menu) {
var choice = menu.options[menu.selectedIndex].value;
var text = menu.options[menu.selectedIndex].text;
var list_form = parent.mhaWorkArea.document.listForm;
var type = choice.substr(0,4);
var val = choice.substr(5);
if (choice != "title") {
list_form.archive.value = val;
parent.defaultStatus = text;
parent.status = text;
list_form.action.value = 'index';
list_form.submit();
}
menu.options[menu.selectedIndex].selected = false;
menu.options[0].selected = true;
}
// Process Edit menu selection
function process_edit_menu (menu) {
var choice = menu.options[menu.selectedIndex].value;
var list_form = parent.mhaWorkArea.document.listForm;
menu.options[menu.selectedIndex].selected = false;
menu.options[0].selected = true;
if (choice == "selectAll") {
checkAll(list_form, true);
} else if (choice == "unselectAll") {
checkAll(list_form, false);
} else if (choice == "reset") {
list_form.reset();
} else if (choice == "show") {
list_form.action.value = 'show';
window.open('javascript:void(0)',
'mhaMesgView',
'menubar=0,resizable=1,toolbar=0,scrollbars=1');
list_form.submit();
} else if (choice == "delete") {
if (window.confirm("Delete selected messages?")) {
list_form.action.value = 'delete';
list_form.submit();
}
}
}
// Process View menu selection
function process_view_menu (menu) {
var choice = menu.options[menu.selectedIndex].value;
var list_form = parent.mhaWorkArea.document.listForm;
var type = choice.substr(0,4);
var val = choice.substr(5);
var n;
menu.options[menu.selectedIndex].selected = false;
menu.options[0].selected = true;
if (type == "sort") {
list_form.sort.value = val;
list_form.action.value = 'index';
list_form.submit();
} else if (type == "rfsh") {
list_form.action.value = 'index';
list_form.submit();
} else if (type == "pgsz") {
n = parseInt(
window.prompt(
"Maximum number of message listed per page:",
list_form.pagesize.value));
if ((!isNaN(n)) && (n >= 0) && (n != list_form.pagesize.value)) {
list_form.pagesize.value = n;
list_form.action.value = 'index';
list_form.submit();
}
} else if (type == "page") {
list_form.page.value = val;
list_form.action.value = 'index';
list_form.submit();
}
}
EOJS
## JavaScript for main index page
##-----------------------------------------------------------------------##
$JSIndexPage =<<'EOJS';
// Handle button navigation
function changePage (f, val) {
f.page.value = val;
f.action.value = 'index';
f.submit();
}
// Set the selection of all messages in a group
function checkGroup (topmesg) {
var val = topmesg.checked;
var i;
for (i=0; i < topmesg.form.elements.length; ++i) {
if (topmesg.form.elements[i] == topmesg) {
break;
}
}
++i;
if (i >= topmesg.form.elements.length) {
return;
}
while (topmesg.form.elements[i].name == 'msgnum') {
topmesg.form.elements[i].checked = val;
++i;
}
}
// Open a message view window for a message
function open_mesg_view (cgiurl) {
window.open(cgiurl,
'mhaMesgView',
'menubar=0,resizable=1,toolbar=0,scrollbars=1');
}
EOJS
}