"Template", "tagline" => "A Tyzoid Production", "showbar" => true, "loginbar" => "" ); /** * Constructor * * @param string $title - the title of the page * @param mixed $scripts - the url (or array of urls) of the script(s) to include * @param mixed $stylesheets - the url (or array of urls) of the stylesheet(s) to include */ public function __construct($title = null, $scripts = null, $stylesheets = null){ // Page Title if (! empty($title)) $this->title = $title; if (! empty($scripts) && is_array($scripts)) $this->scripts = array_merge($scripts, $this->scripts); else if (! empty($scripts)) $this->addScript($scripts); if (! empty($stylesheets) && is_array($stylesheets)) $this->stylesheets = array_merge($stylesheets, $this->stylesheets); else if (! empty($stylesheets)) $this->addStyle($stylesheets); } public function setTitle($title){ $this->title = $title; } public function addScript($script){ if (empty($script) || strncmp($script, '/', 1) !== 0) return false; $this->scripts[] = $script; return true; } public function addStyle($stylesheet){ if (empty($stylesheet) || strncmp($stylesheet, '/', 1) !== 0) return false; $this->stylesheets[] = $stylesheet; return true; } public function setAttribute($attribute, $value){ $this->attributes[$attribute] = $value; } public function output($return = false){ global $user; // Doctype $html = "\n"; $html .= "\n"; $html .= "\t\n"; // Page Attributes/Head information $html .= "\t\t" . $this->title . ""; // Set mobile-friendly $html .= ''; // Stylesheet import foreach ($this->stylesheets as $style){ $html .= "\t\t\n"; } // Script import foreach ($this->scripts as $script){ $html .= "\t\t\n"; } // Start Body of the page $html .= "\t\n"; $html .= "\t\n"; // Page layout $html .= "\t\t
\n"; // Login/Statusbar $html .= "\t\t\t
\n"; if ($user->loggedin()) { $html .= "\t\t\t\t" . $user->name() . "\n"; $html .= "\t\t\t\t" . " Log Out\n"; if ($user->getRole() === "admin") { $html .= "\t\t\t\t" . " Volunteer\n"; $html .= "\t\t\t\t" . " Admin\n"; } $html .= "\t\t\t\tHome\n"; } else if (basename($_SERVER['PHP_SELF']) != 'login.php') { $html .= "\t\t\t\tLog In\n"; } else { $html .= "\t\t\t\tHome\n"; } $html .= "\t\t\t
\n"; $html .= "\t\t\t
\n"; $html .= "\t\t\t\t

{$this->attributes['title']}

\n"; $html .= "\t\t\t\t

{$this->attributes['tagline']}

\n"; $html .= "\t\t\t
\n"; $html .= "\t\t\t
\n"; $html .= "\t\t\t\t
\n"; //End divs should be closed in the footer template if($return === true) return $html; echo $html; } }