headCode['jQuery'] = ''; $this->headCode['jQueryUI'] = ''; $this->headCode['jValidate'] = ''; $this->headCode['schedInput'] = ''; $this->headCode['outputPrintStyle'] = ''; $this->headCode['outputStyle'] = ''; $this->headCode['gliderHeadcode'] = ''; $this->headCode['uiTabsKeyboard'] = ''; $this->pagetitle = $ntitle; $this->scripts = $nscripts; /* compliant browsers which care, such as gecko, explicitly request xhtml: */ if(!empty($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== FALSE || !strlen($_SERVER['HTTP_ACCEPT']) /* then the browser doesn't care :-) */) { $this->xhtml = TRUE; header('Content-type: application/xhtml+xml'); } if (count($ga_trackers)) { $ga_www = 'http://www.'; if ($_SERVER['SERVER_PORT'] != 80) $ga_www = 'https://ssl.'; $this->trackingcode = '' . "\n" . $this->trackingcode . ' \n"; } self::session_start(); /* everything that needs sessions started to work: */ $this->school = school_load_guess(); if($immediate && $ntitle != "NOHEAD") $this->head(); } /** * \brief * Adds some headcode to this page. * * \param $key * The key to register this headcode under. * \param $code * The actual code, such as a . * \param $enable * Whether or not to enable this code while adding it. */ public function headcode_add($key, $code, $enable = FALSE) { $this->headCode[$key] = $code; if ($enable) $this->scripts[] = $key; } // Public functions/vars public function head(){ $this->pageGenTime = round(microtime(), 3); if ($this->xhtml) echo '' . "\n"; echo 'doctype . '> htmlargs . '>
'; if (isset($session['saved']) && count($session['saved']) > 0) { $process_php_s = 'process.php?s='; if ($clean_urls) $process_php_s = ''; echo '
\n"; echo "
\n" . ' ' . $message . "\n" . "
\n"; $page_404->foot(); exit(); } /** * \brief * Start the PHP session by calling session_start(). * * Used to make sure that different areas of our code don't call * session_start() multiple times and to make it easier to ensure * that session_start() is called at least before it's needed. */ public static function session_start() { static $session_started = FALSE; if (!$session_started) { session_name('slate_permutate'); session_start(); $session_started = TRUE; } } /** * \brief * Perform a redirect. * * By consolidating all redirects here, we're hopefully able to do * it in a somewhat compliant and portablish way ;-). * * This function does not return. It calls exit(). * * \param $dest * A URL relative to the slate_permutate root. For example, * 'input.php' or '44' (for clean urls, for example). * \param $http_code * The redirection code to use, if any. For example, this can be * used to implement ``permanent'' redirects if necessary. */ public static function redirect($dest, $http_code = NULL) { if ($http_code) header('HTTP/1.1 ' . $http_code); $uri = ''; $host = ''; if (isset($_SERVER['SERVER_NAME'])) $host = $_SERVER['SERVER_NAME']; if (isset($_SERvER['HTTP_HOST'])) $host = $_SERVER['HTTP_HOST']; if (strlen($host)) { $proto = 'http'; $port = NULL; if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) { if ($_SERVER['SERVER_PORT'] == 443 || !empty($_SERVER['HTTPS'])) $proto .= 's'; if ($_SERVER['SERVER_PORT'] != 433) $port = $_SERVER['SERVER_PORT']; } $uri = $proto . '://' . $host; if ($port !== NULL) $uri .= ':' . $port; $uri .= dirname($_SERVER['REQUEST_URI']) . '/'; } header('Location: ' . $uri . $dest); exit(); } /** * \brief * Get the current school profile handle. */ public function get_school() { return $this->school; } /** * \brief * Format a chunk of javascript suitable for adding to headcode. * * Takes into account whether or not the code should be wrapped in * CDATA or not. * * \param $js * The javascript to wrap up. * \param $type * The type="" attribute of the element */ public function script_wrap($js, $type = 'text/javascript') { return ''; } private function add_trailing_slash($path){ if($path[strlen($path)-1] != '/') { return $path . "/"; } else { return $path; } } /** * \brief * Generate a URL to a given schedule. */ public function gen_share_url($id) { global $clean_urls, $short_url_base; if ($clean_urls && isset($short_url_base)) return $this->add_trailing_slash($short_url_base) . $id; elseif ($clean_urls) return 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/' . $id; else return 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']) . '/process.php?s=' . $id; } }