meta = $meta scripts = $scripts linked_style=$linked_style inline_style=$inline_style bg_color=$BG_COLOR fg_color=$FG_COLOR opaque = $OPAQUE ";
global $template_config;
$template_config['homePageUrl'] = $this_file;
// overwrite the postUmnCssScriptLinks with the values gathered by looking at
// the page to be templated
$template_config['postUmnCssScriptLinks'] = $linked_style . $inline_style . $meta . $scripts;
$template_config['postUmnCssScriptLinks'] .= '';
$template_config['postUmnCssScriptLinks'] .= get_additional_cosats_styles($OPAQUE, $BG_COLOR, $FG_COLOR);
$template = new twoColumnCollegeTemplate($template_config);
echo $template->getHeader($page_title, $left_nav_content);
return $template;
}
function get_additional_cosats_styles($OPAQUE, $BG_COLOR, $FG_COLOR) {
$style = '';
if ($BG_COLOR[0] === '#') {
$backColorRGB = html2rgb($BG_COLOR);
$backColorHEX = substr($BG_COLOR, 1);
} elseif ($BG_COLOR[0] == 'r' && $BG_COLOR[1] == 'g') {
$BG_COLOR = substr($BG_COLOR, 4);
$BG_COLOR = strrev(substr(strrev($BG_COLOR), 1));
$color = explode(',', $BG_COLOR);
$backColorHEX = rgb2html($color);
$backColorRGB = html2rgb($backColorHEX);
} else {
switch ($BG_COLOR) {
case 'red':
$backColorHEX = 'FF0000';
$backColorRGB = array(255, 0, 0);
break;
case 'orange':
$backColorHEX = 'FF9900';
$backColorRGB = array(255, 153, 0);
break;
case 'yellow':
$backColorHEX = 'FFFF00';
$backColorRGB = array(255, 255, 0);
break;
case 'gold':
$backColorHEX = 'FFCC00';
$backColorRGB = array(255, 204, 0);
break;
case 'green':
$backColorHEX = '00FF00';
$backColorRGB = array(0, 255, 0);
break;
case 'blue':
$backColorHEX = '0000FF';
$backColorRGB = array(0, 0, 255);
break;
case 'purple':
$backColorHEX = '9900FF';
$backColorRGB = array(153, 0, 255);
break;
case 'white':
$backColorHEX = 'FFFFFF';
$backColorRGB = array(255, 255, 255);
break;
case 'pink':
$backColorHEX = 'FF00FF';
$backColorRGB = array(255, 0, 255);
break;
default:
$backColorHEX = '000000';
$backColorRGB = array(0, 0, 0);
}
}
if ($OPAQUE) {
$opaqueRGB = '0.5';
$opaqueHEX = '7F';
}
else {
$opaqueRGB = '1.0';
$opaqueHEX = 'FF';
}
$style .= '
';
return $style;
}
/**
* get_last_modified_date determines the last modified
* time for the page being displayed. We used to display
* the last modification date for the index.php file, which
* was sad.
*
* @param $filename the filename and path to the file the user is trying to access
* @param $path the path to the file the user is trying to access (needed in the case of a directory)
* @param $page the name of the page the user is trying access (needed in the case of a directory)
*
* @return $last_modified_date The date that the directory or file was last modified.
*/
function get_last_modified_date($filename, $path, $page){
// if the filename is empty, this must be a directory listing
// in this case, pass in the path/page to the filemtime to
// determine the last modified date
if($filename === '') {
$last_modified_date = date('F j, Y', filemtime($path . $page));
} else {
$last_modified_date = date('F j, Y', filemtime($filename));
}
return $last_modified_date;
}
/**
* html2rgb takes in a HEX color code, converts its values to RGB values, and
* returns them as an array
*
* @param $color the color in hex to convert to RGB
*
* @return array($r, $g, $b) an array of the rgb values
*/
function html2rgb($color)
{
if ($color[0] == '#')
$color = substr($color, 1);
if (strlen($color) == 6)
list($r, $g, $b) = array($color[0].$color[1],
$color[2].$color[3],
$color[4].$color[5]);
elseif (strlen($color) == 3)
list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
else
return false;
$r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
return array($r, $g, $b);
}
/**
* rgb2html takes in the RGB values of a color, converts them into the HEX code
* and then returns the HEX
*
* @param $r can either be an array of three rgb values or just an r value
* @param $g the g value for rgb if called with 3 parameters
* @param $b the b value for rgb if called with 3 parameters
*
* @return $color corresponding hex code
*/
function rgb2html($r, $g=-1, $b=-1)
{
if (is_array($r) && sizeof($r) == 3)
list($r, $g, $b) = $r;
$r = intval($r); $g = intval($g);
$b = intval($b);
$r = dechex($r<0?0:($r>255?255:$r));
$g = dechex($g<0?0:($g>255?255:$g));
$b = dechex($b<0?0:($b>255?255:$b));
$color = (strlen($r) < 2?'0':'').$r;
$color .= (strlen($g) < 2?'0':'').$g;
$color .= (strlen($b) < 2?'0':'').$b;
return $color;
}
?>