. */ /* * The @PACKAGE_*@-style defines. */ define('SP_PACKAGE_NAME', 'slate_permutate'); define('SP_PACKAGE_VERSION', '0.1_pre'); define('SP_PACKAGE_STRING', SP_PACKAGE_NAME . '-' . SP_PACKAGE_VERSION); /** * Not sure if there's a better place for this... it'd be a pita to * make a new include file like doconfig.inc but maybe that'll make * sense soon. */ /* defaults */ $clean_urls = FALSE; $ga_trackers = array(); $feedback_emails = array('ez@ethanzonca.com, ngelderloos7@gmail.com, ohnobinki@ohnopublishing.net'); $config_inc = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc'; if (file_exists($config_inc)) { require_once($config_inc); } //************************************************** // class.page.php Author: Ethan Zonca // // Provides an interface for generating a styled // XHTML page, supporting modular script inclusion // and other various features //************************************************** class page { /* Site-wide configuration options */ private $base_title = 'SlatePermutate'; private $doctype = 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"'; private $htmlargs = 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"'; private $bodyargs = ''; public $lastJobTable = ''; private $pageGenTime = 0; /* Whether or not to output valid XHTML */ private $xhtml = FALSE; /* Scripts and styles */ private $headCode = array(); /* * Google analytics ga.js tracking code. Expanded in __construct(). */ private $trackingcode = ''; private $pagetitle = ''; // Title of page private $scripts = array(); // Scripts to include on page /* the current school. See get_school(). */ private $school; /** * \param $ntitle * Must be a valid HTML string (i.e., escaped with htmlentities()). * \param $nscripts * An array of strings identifying the scripts to include for this page. */ public function __construct($ntitle, $nscripts = array(), $immediate = TRUE) { global $ga_trackers; require_once('school.inc'); // Scripts and styles available to include $this->headCode['jQuery'] = ''; $this->headCode['jQueryUI'] = ''; $this->headCode['jValidate'] = ''; $this->headCode['qTip'] = ''; $this->headCode['schedInput'] = ''; $this->headCode['outputPrintStyle'] = ''; $this->headCode['outputStyle'] = ''; $this->headCode['gliderHeadcode'] = ''; $this->headCode['uiTabsKeyboard'] = ''; $this->headCode['displayTables'] = ''; $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; charset=utf-8'); } else header('Content-Type: text/html; charset=utf-8'); if (count($ga_trackers)) { $ga_www = 'http://www.'; if ($_SERVER['SERVER_PORT'] != 80) $ga_www = 'https://ssl.'; $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 '; } 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; } }