<?
/*
################################################################################
# Servlet Class
#-------------------------------------------------------------------------------
# FileName: class.servlet.php
# Author: Ryan Petrain
# Credits: Steve Horsburgh
# (made a perl implementation that inspired this class)
# Description: This class creates neat "boxes" that have a header
# and a place to display content. All that is needed
# to create most of the boxes is a title and conent.
################################################################################
*/
class Servlet
{
var $Message;
var $Title;
var $DivID = 0;
var $DTtile;
//Class Constructor
function Servlet()
{
$this->Message = "Instantiated the servlet class!<br>\n";
}
// Get/Set default message
function SetMessage($Message)
{
$this->Message = $Message;
}
function GetMessage()
{
print $this->Message;
}
// A simple box with a colored titlebar
function SimpleBox($Title,$SubTitle="",$Body="",$Width="100%")
{
//Declare local variables
$DefWidth = "100%";
// Call subroutines that are involved in the display of the box
if ($Width){
Servlet::SimpleBoxInit($Title, $Width);
}else{
Servlet::SimpleBoxInit($Title, $DefWidth);
}
Servlet::SimpleBoxSubBox($SubTitle, $Body);
Servlet::SimpleBoxClose();
}//End SimpleBox
//Initialization function for SimpleBox
function SimpleBoxInit($Title,$Width)
{
//Declare local variables
$HTML = "";
$HTML = "<!-- Start ColorBox -->\n";
$HTML .= "<table summary='ColorBox Opening' width='" . $Width . "' border='0' cellspacing='0' cellpading='0' class='ColorBox'>\n";
$HTML .= "<tr>\n";
$HTML .= " <td>\n";
$HTML .= " <table summary='ColorBox Contents' border='0' width='100%' cellspacing='0' cellpadding='4' class='ColorBoxInner'>\n";
$HTML .= " <tr>\n";
$HTML .= " <td class='ColorBoxTH'><font class='servlet-b_mediumtext'>" . $Title . "</font></td>\n";
$HTML .= " </tr>\n";
print $HTML;
}//End SimpleBoxInit
// Sub titles function for SimpleBox
function SimpleBoxSubBox($SubTitle, $Body)
{
//Declare local variables
$HTML = '';
if ($SubTitle){
$HTML .= " <tr>\n";
$HTML .= " <td class='servlet-b_mediumtext'>" . $SubTitle . "</td>\n";
$HTML .= " </tr>\n";
}
$HTML .= " <tr>\n";
$HTML .= " <td class='servlet_smalltext'>" . $Body . "<br></td>\n";
$HTML .= " </tr>\n";
print $HTML;
}//End SimpleBoxSubBox
//Close function of the SimpleBox
function SimpleBoxClose()
{
//Declare local variables
$HTML = '';
$HTML .= " </table>\n";
$HTML .= " </td>\n";
$HTML .= "</tr>\n";
$HTML .= "</table>\n";
$HTML .= "<!-- End ColorBox -->\n";
//$HTML .= "<table summary='ColorBox Closing' border='1' cellspacing='0' cellpadding'0'>\n";
//$HTML .= "<tr>\n";
//$HTML .= " <td> </td>\n";
//$HTML .= "</tr>\n";
//$HTML .= "</table>\n";
print $HTML;
}//End SimpleBoxSubBox
//DivID Generator/Incrementor
function NextDivID()
{
$this->DivID++;
return $this->DivID;
}// End NextDivID
//Deluxe box with minimize restore and close buttons (IE only)
function DeluxeBox($Title,$Body,$BodyBg,$EditURL,$QuestionURL,$UpURL,$DownURL,$CloseURL)
{
//Declare local variables
$HTML = '';
$DTitle = $Title;
$BoxDivID = "FancyBox" . Servlet::NextDivID();
$ContentDivID = "FancyBoxCon" . Servlet::NextDivID();
$UpClick = '';
$DownClick = '';
$CloseClick = '';
//Determine if the arrow buttons have been given values
if ($UpURL == "auto") {
$UpClick = "onClick = \"document.all." . $ContentDivID . ".style.display = 'none'; return false\"";
$UpURL = "#";
}
if ($DownURL == "auto") {
$DownClick = "onClick = \"document.all." . $ContentDivID . ".style.display = 'block'; return false\"";
$DownURL = "#";
}
if ($CloseURL == "auto") {
$CloseClick = "onClick = \"document.all." . $BoxDivID . ".style.display = 'none'; return false\"";
$CloseURL = "#";
}
// format html output
$HTML = "<!-- Start FancyBox -->\n";
$HTML .= "<div id='" . $BoxDivID . "'>\n";
$HTML .= "<table width='100%' border='0' cellspacing='0' cellpadding='1' class='FancyBoxInner'>\n";
$HTML .= "<tr>\n";
$HTML .= " <td>\n";
$HTML .= " <table width='100%' border='0' cellspacing='0' cellpadding='4' class='FancyBoxTH'>\n";
$HTML .= " <tr>\n";
$HTML .= " <td><b>" . $DTitle . "</b></td>\n";
$HTML .= " <td valign='middle' align='right' nowrap>\n";
if ($EditURL){
$HTML .= " <a href='". $EditURL . "'><img src='edit.gif' width='15' height='15' border='0' alt='edit'></a>\n";
}
if ($QuestionURL){
$HTML .= " <a href='". $QuestionURL . "'><img src='question.gif' width='15' height='15' border='0' alt='?'></a>\n";
}
if ($UpURL){
$HTML .= " <a href='". $UpURL . "' " . $UpClick . "><img src='up.gif' width='15' height='15' border='0' alt='up'></a>\n";
}
if ($DownURL){
$HTML .= " <a href='". $DownURL . "' " . $DownClick . "><img src='down.gif' width='15' height='15' border='0' alt='down'></a>\n";
}
if ($CloseURL){
$HTML .= " <a href='". $CloseURL . "' " . $CloseClick . "><img src='close.gif' width='15' height='15' border='0' alt='close'></a>\n";
}
$HTML .= " </td>\n";
$HTML .= " </tr>\n";
$HTML .= " <tr>\n";
$HTML .= " <td colspan='2' class='FancyBoxContent'><div id='" . $ContentDivID . "'> " . $Body . "</div></td>\n";
$HTML .= " </tr>\n";
$HTML .= " </table>\n";
$HTML .= " </td>\n";
$HTML .= " </tr>\n";
$HTML .= " </table>\n";
//$HTML .= "<table border='0' cellspacing='0' cellpadding='0'><tr><td height='10'><img src='blank.gif' height='10'></td></tr></table>\n";
$HTML .= " </div>\n";
$HTML .= "<!-- End Fancy Box -->\n";
print $HTML;
}//End DeluxeBox
//Site Banner Generation
function SiteBanner($Cell1,$Cell2="NULL",$Cell3="NULL",$Cell4="NULL")
{
//Declare local variables
$BannerTD1 = $Cell1;
$BannerTD2 = $Cell2;
$BannerTD3 = $Cell3;
$BannerTD4 = $Cell4;
$HTML = '';
// Format HTML output
$HTML .= "<table width='100%'cellpadding='6' cellspacing='0' border='0' class='SiteBanner'>\n";
$HTML .= "<tr>\n";
$HTML .= " <td valign='top'>" . $Cell1 . "</td>\n";
if ($BannerTD2 != "NULL"){$HTML .= " <td valign='top'>" . $Cell2 . "</td>\n";}
if ($BannerTD3 != "NULL"){$HTML .= " <td valign='top'>" . $Cell3 . "</td>\n";}
if ($BannerTD4 != "NULL"){$HTML .= " <td valign='top'>" . $Cell4 . "</td>\n";}
$HTML .= "</tr>\n";
$HTML .= "</table>\n";
print $HTML;
}//End SiteBanner
//Footer Generation
function SiteFooter()
{
//Declare local variables
$HTML = '';
//Format HTML ouput
$HTML .= "<table width='100%'cellpadding='4' cellspacing='0' border='0'>\n";
$HTML .= "<tr>\n";
$HTML .= "<td align='right'><hr width='100%'class='SiteFooter'>\n";
$HTML .= "<font class='servlet_smalltext'>copyright ©2001 Ryan Petrain</font></td>\n";
$HTML .= "</tr>\n";
$HTML .= "</table>\n";
print $HTML;
}//End SiteFooter
}//End Servlet Class
?>
|