<?php
require_once("lw_sidebar.php");
class lw_html
{
var $LW;
/**
* Construcctor
*
* NAME: lw_takeCodingTest
*
* @param lw_class $master a reference to the instance of the lw_master calling class
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function lw_html(&$master)
{
$this->LW = $master;
}
function printURL($url)
{
$lwUtils = &$this->LW->UTILS;
if ($_SERVER["HTTPS"] == '')
{
return $lwUtils->buildSecureURL($url);
}
else
{
return $lwUtils->buildSecureURL($url);
}
}
/**
* Construcctor
*
* NAME: printTop
*
* @param string $title the title shown at the top left of the browser window
* @param bool $menu false - do not include menu, extend main content area across the screen; true = include menu
* @param bool $logout false - do not display the logout button; true - display the logout button
* @param string $css names of CSS files referenced
* @param string $js names of JS files referenced
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printTop($title, $menu, $logout, $css, $js){
$lwUtils = &$this->LW->UTILS;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>
<?php echo $title; ?>
</title>
<meta http-equiv="content-type" CONTENT="text/html; charset=iso-8859-1"/>
<meta http-equiv="content-language" content="en"/>
<?php
// include external javascript files
echo "\n".'<script type="text/javascript" src="'. $this->printURL('include/javascript/lw_master.js') .'"></script>';
echo "\n".'<script type="text/javascript" src="'. $this->printURL('include/javascript/cookies.js') .'"></script>';
if ($js != '')
{
foreach($js as $v)
{
echo "\n".'<script type="text/javascript" src="'. $this->printURL($v) .'"></script>';
}
}
// include external stylesheets
echo "\n".'<style type="text/css">';
echo "\n".'@import url("'. $this->printURL('include/css/lw_master.css') .'");';
if ($css != '')
{
foreach($css as $v)
{
echo "\n".'@import url("'. $this->printURL($v) .'");';
}
}
echo "\n".'</style>';
?>
</head>
<body>
<?php
// This php block checks to make sure that cookies are enabled.
echo "\n".'<script type="text/javascript">';
echo "\n".'Set_Cookie( \'lw_test\', \'' . $_SERVER[PHP_SELF] . '\', \'\', \'/\', \'\', \'\' );';
echo "\n".'if (Get_Cookie(\'lw_test\') != \'' . $_SERVER[PHP_SELF] . '\')';
echo "\n".'{';
echo "\n".' location.replace("' . $LW_BASE_URL . '/ludwig/common/lw_cookiesDisabled.php");';
echo "\n".'}';
echo "\n".'</script>';
?>
<table border="0" cellpadding="0" cellspacing="0" class="lw-stretch">
<tr>
<td id="lw-top">
<table border="0" cellpadding="0" cellspacing="0" class="lw-stretch">
<tr>
<td class="left">
<?php
print "<TABLE cellpadding=1 border=0><TR><TD>";
print "\n<img src=\"".$lwUtils->buildImageURL("images/witt.jpg") . "\" alt=\"Wittgenstein\"/>";
print "</TD><TD>";
echo " ".'<a href="'. $lwUtils->buildSecureURL('') .'"><img src="'. $lwUtils->buildImageURL('images/header_06.jpg') .'" alt="LUDWIG"/></a>';
print "</TD></TR></TABLE>";
?>
</td>
<td class="right">
<?php
if ($logout)
{
echo "\n".'<table border="0" cellpadding="0" cellspacing="0">';
echo "\n".' <tr>';
echo "\n".' <td class="leftTD">';
echo "\n".' You are logged in as<br/>';
echo "\n".' <b>'.htmlentities($_SESSION["username"]).'</b>';
echo "\n".' </td>';
echo "\n".' <td class="rightTD">';
echo "\n".' <a href="'. $lwUtils->buildSecureURL('common/lw_myProfile.php') .'">my profile</a> |';
echo "\n".' <a href="'. $lwUtils->buildSecureURL('common/lw_logout.php') .'">logout</a><br/>';
echo "\n".' </td>';
echo "\n".' </tr>';
echo "\n".'</table>';
}
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" class="lw-stretch">
<tr>
<td id="lw-farleft">
<?php
echo '<img id="lw-spacerImg" src="'. $lwUtils->buildImageURL('images/spacer.gif') .'" alt=""/>';
?>
</td>
<?php
if ($menu)
{
$this->printMenu();
}
?>
<td id="lw-content">
<?php
}
/**
* prints the footer for every page in the LUDWIG application
*
* NAME: printBottom
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printBottom()
{
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div id="lw-bottom">
<?php
echo '<span class="copyright">Copyright © 2004 Pennsylvania State University</span><br/>';
echo '<span class="version"><a href='. $this->printURL('common/viewCredits.php') .'>Acknowledgements</a><br /></span>';
echo '<span class="version">v'. htmlentities(LW_VERSION) .'</span><br/>';
?>
</div>
</td>
</tr>
</table>
</body>
</html>
<?php
}
/**
* prints the dynamicly driven left-hand menu as is called from printTop
*
* NAME: printMenu
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printMenu()
{
$lwUtils = &$this->LW->UTILS;
?>
<td id="lw-left">
<br/>
<div id="lw-menu">
<?php
$sidebarObject = new LWSidebar($this->LW);
echo $sidebarObject->GenerateMenu();
?>
</div>
<?php
if (LW_VALIDATE)
{
echo "\n".'<br/>';
echo "\n".'<div id="lw-validate">';
echo "\n".' <span class="text">validate:</span><br/>';
echo "\n".' <a href="http://validator.w3.org/check/referer"><img src="'. $lwUtils->buildImageURL('images/xhtml_1.1_strict.gif') .'" alt="validate xhtml 1.1 strict" /></a><br/>';
echo "\n".' <a href="http://jigsaw.w3.org/css-validator/check/referer?warning=no&profile=css2"><img src="'. $lwUtils->buildImageURL('images/css_2.gif') .'" alt="validate css2" /></a><br/>';
echo "\n".'</div>';
}
?>
<br/>
</td>
<?php
}
/**
* prints the dynamicly driven page header
*
* NAME: printPageHeader
*
* @param string $cat page category
* @param string $title page title
* @param $semesterSwitch deprecated
* @param string $url page url
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printPageHeader($cat, $title, $semesterSwitch, $url)
{
$lwUtils = &$this->LW->UTILS;
// capitalize the first letter of the semester name
$semester = ucfirst($_SESSION["semester"]);
echo "\n".'<table border="0" cellpadding="0" cellspacing="0" id="lw-pageHeader">';
echo "\n".' <tr>';
echo "\n".' <td class="left">';
echo "\n".' <span id="header">'.$lwUtils->toHTML($cat).' :: '.$lwUtils->toHTML($title).'</span><br/>';
echo "\n".' <br/>';
echo "\n".' </td>';
echo "\n".' <td class="right">';
echo "\n".' <span class="currentSemester">'.$lwUtils->toHTML($semester).' '.$lwUtils->toHTML($_SESSION["year"]).'</span>';
echo "\n".' </td>';
echo "\n".' </tr>';
echo "\n".'</table>';
}
/**
* prints tab bar that appears accross the screen
*
* NAME: printTabBar
*
* @param string $data informated used in the tab bar
* @param string $url url of file
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printTabBar($data, $url)
{
$lwUtils = &$this->LW->UTILS;
echo "\n".'<div class="lw-tabArea">';
for ($x=0; $x<sizeof($data); $x++)
{
if ($data[$x]['front'] == 1)
{
echo "\n".' <span class="tabActivated">'.str_replace(" ", " ", $data[$x]['name']).'</span>';
}
else
{
if (strstr($url, "?") === FALSE)
{
$workingURL = $lwUtils->buildSecureURL($url.'?class='.$data[$x]['link']);
}
else
{
$workingURL = $lwUtils->buildSecureURL($url.'&class='.$data[$x]['link']);
}
echo "\n".' <a href="'. $workingURL .'" class="tab">'.str_replace(" ", " ", $lwUtils->toHTML($data[$x]['name'])).'</a>';
}
}
echo "\n".' <span class="tabEnd"> </span>';
echo "\n".'</div>';
}
/**
* Prints a full-screen message, typically indicating a problem
*
* NAME: printFullScreenMessage
*
* @param string $header Header for top
* @param string $details Detailed info for message
* @param string $linkText Text for link
* @param string $url URL for link
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printFullScreenMessage($header, $details, $linkText, $url)
{
echo "\n".'<div class="lw-fullScreenMessage">';
echo "\n".' <span class="header4">'. $header .'</span><br/>';
echo "\n".' <br/>';
if ($details != ''){
echo "\n".' <span class="text1bold">'. $details .'</span><br/>';
echo "\n".' <br/>';
}
echo "\n".' <a href="'. $url .'" class="link1">'. $linkText .'</a><br/>';
echo "\n".' </div>';
}
/**
* Prints an HTML table containing the data
*
* NAME: printDataTable
*
* @param string $headers Information to appear at top
* @param string $aligns Alignment for HTML rows
* @param string $data Data for table
* @param string $total Value for 'total-value' cell
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printDataTable($headers, $aligns, $data, $total)
{
$lwUtils = &$this->LW->UTILS;
echo "\n".'<table border="0" cellpadding="0" cellspacing="0" class="lw-data">';
echo "\n".' <tr class="header">';
for ($x=0; $x<sizeof($headers); $x++){
if ($headers[$x] == ''){
$headers[$x] = ' ';
} else {
$headers[$x] = $this->LW->UTILS->toHTML($headers[$x]);
}
echo "\n".' <th>'.$headers[$x].'</th>';
}
echo "\n".' </tr>';
for ($x=0; $x<sizeof($data); $x++)
{
echo "\n".' <tr class="row'. $x%2 .'">';
for ($i=0; $i<sizeof($data[$x]); $i++)
{
echo "\n".' <td class="'.$aligns[$i].'">'.$data[$x][$i].'</td>';
}
echo "\n".' </tr>';
}
if ($total != '')
{
echo "\n".' <tr>';
echo "\n".' <td class="total-heading" colspan="'.(sizeof($headers)-1).'">Total:</td>';
echo "\n".' <td class="total-value">'.$total.'</td>';
echo "\n".' </tr>';
}
else
{
echo "\n".' <tr>';
echo "\n".' <td class="total-heading" colspan="'.sizeof($headers).'">';
echo "\n".' <img id="lw-spacerImg-1x1" src="'. $lwUtils->buildSecureURL('images/spacer.gif') .'" alt=""/><br/>';
echo "\n".' </td>';
echo "\n".' </tr>';
}
echo "\n".'</table>';
}
/**
* Prints a list of data formatted as a 2-column html table
*
* NAME: printDataList
*
* @param array $data 2xn array of data to print
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printDataList($data)
{
// check for invalid data array
if (sizeof($data) == 0)
{
reportError('printDataList received an empty data array.', __FILE__, __LINE__);
}
if (sizeof($data[0]) != 2)
{
reportError('printDataList received a data array that is not two columns wide', __FILE__, __LINE__);
}
// print list
echo "\n".'<table class="lw-dataList" border="0" cellpadding="0" cellspacing="0">';
for ($x=0; $x<sizeof($data); $x++)
{
echo "\n".' <tr>';
echo "\n".' <td class="left">'.$data[$x][0].'</td>';
echo "\n".' <td class="right">'. $data[$x][1] .'</td>';
echo "\n".' </tr>';
}
echo "\n".'</table>';
}
/**
* Prints tabs for a class
*
* NAME: printClassTabs
*
* @param int $ourClassID ID for class
* @param string $url url to include in HTML
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printClassTabs(&$curClassID, $url)
{
$retval = false;
$lwutils = &$this->LW->UTILS;
$tabData = array();
$curClassID = $_GET["class"];
if (!$lwutils->getClassTabData($tabData, $curClassID))
{
echo "You are not enrolled in any classes this semester.";
$retval = false;
}
else
{
$this->printTabBar($tabData, $url);
if ($lwutils->isInteger($curClassID))
{
if (!$lwutils->isEnrolledInClass($curClassID))
{
echo "\n<br />";
echo "\nYou are not enrolled in the requested class this semester. Please choose a class from one of the above tabs.";
$retval = false;
}
else
{
$retval = true;
}
}
else
{
echo "\n<br />\nPlease choose a class from one of the above tabs.";
$retval = false;
}
}
return $retval;
}
/**
* Prints tabs for instructor screen for a particular class
*
* NAME: printInstructorTabs
*
* @param int $ourClassID ID for class
* @param string $url url to include in HTML
*
* @author Joshua Ebersol
* @since 2/12/03
*/
function printInstructorTabs(&$curClassID, $url)
{
$retval = false;
$lwutils = &$this->LW->UTILS;
$tabData = array();
$curClassID = $_GET["class"];
if (!$lwutils->getInstructorTabData($tabData, $curClassID))
{
echo "You are not instructing any classes this semester.";
$retval = false;
}
else
{
$this->printTabBar($tabData, $url);
if ($lwutils->isInteger($curClassID))
{
if (!$lwutils->isClassInstructor($curClassID))
{
echo "\n<br />";
echo "\nYou are not the instructor of the requested class this semester. Please choose a class from one of the above tabs.";
$retval = false;
}
else
{
$retval = true;
}
}
else
{
echo "\n<br />\nPlease choose a class from one of the above tabs.";
$retval = false;
}
}
return $retval;
}
}
?>