perlquestion
grashoper
working on a larger problem broke down into smaller parts
here is whats working as well as whats not.
1) succesfully setup a hash with structure of topics as key and values are the relevant html files, reading in the topic value from the query string and matching it to my %hash verified this part is working by writing out to my browser forced an error to capture the write now I need to pass the target which I called $nightmare to my help subroutine..
Help subroutine--> passes startpoint into mLeftIndex, which sets which helpfile and provides content to you guessed it the leftIndex of a frameset.(I know I hate Iframes but thats what I am stuck with).
I cannot use strict as I have a problem with it that I have not been able to figure out as of yet.
<code>
<% @Language="PerlScript" %>
<!--#Include File="base/base.asp"-->
<!--#Include File="base/core.asp"-->
<!--#Include File="base/helper.asp"-->
<!--#Include File="base/modules.asp"-->
<%
my $User = $Request->item("Login")->item();
my $Site = $Request->item("Site")->item();
$topic= $Request->item("Topic")->item();
my $Referer = $Request->ServerVariables("HTTP_REFERER")->item();
use CGI;
use ASP;
use OLE;
$query= new CGI;
my %ttopics = (
home => 'TEMPO%205%20Help%20Topics-01-1.html',
listingmgr => 'TEMPO%205%20Help%20Topics-06-1.html',
);
if (!defined($topic)) {
# ...handle error...
}
$nightmare = $ttopics{$topic};
if (!defined($target)) {
# ...handle error...
}
$Response->Write("Topic is $topic\n");
$Response->Write("my target is $nightmare\n");
}
</code>
Sub tHelp-> sets startpoint.
<code>
sub tHelp
{
my $str = "";
my $startpoint=$nightmare=@_;
# Are We Tempo?
if ($Session->{'usrType'} eq 'Std')
{
if ($Request->ServerVariables("SERVER_NAME")->item()=~/tempohelp/i)
{
my $target='Tempo%20help_frame';
$str .= shadowBox("Tempo Help", qq^<help_iframe name="$target" startpoint="$startpoint"/>^ , ($g_docWidth/5*4-(2*$g_docSpace)));
return $str;
}
}
}
</code>
Here is main which calls thelp.
<code>
sub pMain
{
my ($dWidth) = @_;
my $str = "";
my $xmlFSO = CreateObject OLE "Scripting.FileSystemObject";
if ($Request->item("xURL")->item())
{
lg("ACTIVITY","REFERRAL:".$Request->item("xURL")->item());
$str .= "<xURL href=\"".$Request->item("xURL")->item()."\"/>";
}
if ($Request->item("xResource")->item())
{
lg("ACTIVITY","Resource:".$Request->item("xResource")->item());
$str .= "<xResource href=\"".$Request->item("xResource")->item()."\" height=\"".$Request->item("xRh")->item()."\" width=\"".$Request->item("xRw")->item()."\"/>";
}
SWITCH:
{
if ($Request->item("View")->item() eq "Logout"){ $str .= mLogout(); last SWITCH; }
if ($Request->item("Tab")->item() eq "Help"){ $str .= &tHelp($nightmare); last SWITCH; }
if ($Request->item("Tab")->item() eq "Support"){ $str .= tSupport(); last SWITCH; }
if ($Request->item("Tab")->item() eq "Admin"){ $str .= tAdmin(); last SWITCH; }
}
return $str;
}
</code>
Sub document that outputs doc.
<code>
$xmlPage = "<document here=\
queryString=\"$queryString\"
docWidth=\"$dWidth\"
scWidth=\"".$Session->{'screenX'}."\"
scHeight=\"".$Session->{'screenY'}."\"
docSpace=\"$g_docSpace\"
uClass=\"".$uClass."\"
uTitle=\"".$1."\"
uDesc=\"".$2."\"";
$xmlPage .= $Session->{'statsRights'} ? " statsRights=\"".$Session->{'statsRights'}."\"" : "";
$xmlPage .= $Session->{'adminRights'} ? " adminRights=\"".$Session->{'adminRights'}."\"" : "";
$xmlPage .= " date=\"$year".pad($mon,2).pad($mday,2)."\"
wDay=\"$wday\"
time=\"".pad($hour,2).pad($min,2)."\"
cBackground=\"$c_Background\"
cElement=\"$c_Element\"
cFrame=\"$c_Frame\"
cShadow=\"$c_Shadow\"
cLink=\"$c_Link\"
cText=\"$c_Text\">\n";
$xmlPage .= css();
$xmlPage .= admin();
$xmlPage .= config();
$xmlPage .= jscripts();
$xmlPage .= adverts();
$xmlPage .= header();
$xmlPage .= body($dWidth);
$xmlPage .= footer();
$xmlPage .= "\n</document>";
return $xmlPage;
}
</code>
Here is mLeftIndex();
<code>
sub mLeftIndex
{
my $str = "";
my $logoutLink = "<link tab=\"\" view=\"Logout\" title=\"Logout\"/>";
my $content = '<leftIndex>';
if ( $Request->ServerVariables("SERVER_NAME")->item() =~ /mlxhelp/ ) {
my $toc_file = ( $Session->{'usrType'} eq 'Pro' ) ? 'e:\SupportWeb\Content\HELP\PRO\TOC.html' : 'e:\SupportWeb\Content\HELP\STD\TOC.html';
my $user_type = uc $Session->{'usrType'};
open TOC, $toc_file;
my @toc_lines = <TOC>;
close TOC;
foreach my $line ( @toc_lines ) {
$content .= qq^<rlink tab="Help" script="frames['help_iframe'].location.href='Content/HELP/$user_type/$1'" title="$3">
</rlink>^ if ( $line =~ /<p class="pTOC1"><a href="(.*?)"\s+target="(.*?)">(.*?)<\/a>/ );
}
$content .= '</leftIndex>';
}
if ( $Request->ServerVariables("SERVER_NAME")->item() =~ /tempohelp/ ) {
my $toc_file = ( $Session->{'usrType'} eq 'Pro' ) ? 'e:\SupportWeb\Content\HELP\PRO\TOC.html' : 'e:\SupportWeb\Content\help\tpo\default\TOC.html';
my $user_type = uc $Session->{'usrType'};
if ($user_type='STD')
{$user_type='TPO\/default\/'}
open TOC, $toc_file;
my @toc_lines = <TOC>;
close TOC;
foreach my $line ( @toc_lines ) {
$content .= qq^<rlink tab="Help" script="frames['help_iframe'].location.href='Content/HELP/$user_type/$1'" title="$3">
</rlink>^ if ( $line =~ /<p class="pTOC\d"><a href="(.*?)"\s+target="(.*?)">(.*?)<\/a>/ );
}
$content .= '</leftIndex>';
}
</code>
function that calls transforms
<code>
sub transform
{
my $trns = $Server->MapPath("Transforms/pLogin.xsl");
if ($Session->{'isAuthenticated'})
{
getMOTD();
SWITCH:
{
if ($Request->item("View")->item() eq "Resources")
{
$trns = $Server->MapPath("Transforms/tResources.xsl");
last SWITCH;
}
if ($Request->item("Tab")->item() eq "Support")
{
$trns = $Server->MapPath("Transforms/tSupport.xsl");
last SWITCH;
}
if ($Request->item("Tab")->item() eq "Help")
{
$trns = $Server->MapPath("Transforms/tHelp.xsl");
last SWITCH;
}
if ($Request->item("Tab")->item() eq "Training")
{
$trns = $Server->MapPath("Transforms/tTraining.xsl");
last SWITCH;
}
if ($Request->item("Tab")->item() eq "Trainers")
{
$trns = $Server->MapPath("Transforms/tTrainers.xsl");
last SWITCH;
}
if ($Request->item("Tab")->item() eq "Admin")
{
$trns = $Server->MapPath("Transforms/tAdmin.xsl");
last SWITCH;
}
$trns = $Server->MapPath("Transforms/pMain.xsl");
}
}
return $trns;
}
</code>