Files
@ aad2525d04c8
Branch filter:
Location: SlatePermutate/inc/class.page.php - annotation
aad2525d04c8
19.1 KiB
text/x-php
Fix another PHP notice/warning.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | 7e40416a7213 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 1cb6f6105b45 7e40416a7213 f89a5b995978 f89a5b995978 f89a5b995978 f89a5b995978 f89a5b995978 f89a5b995978 f89a5b995978 f847b2da1a6a f847b2da1a6a 7b489f5ccba0 7b489f5ccba0 f847b2da1a6a f847b2da1a6a f847b2da1a6a f847b2da1a6a f847b2da1a6a f847b2da1a6a a23c8e3ebe9e a23c8e3ebe9e a23c8e3ebe9e a23c8e3ebe9e a23c8e3ebe9e d6ed1e1daa85 a23c8e3ebe9e d6ed1e1daa85 7a6777d84d07 7b489f5ccba0 896a269a2822 e890665419df d6ed1e1daa85 a23c8e3ebe9e 7a6777d84d07 a23c8e3ebe9e 7a6777d84d07 a23c8e3ebe9e 7a6777d84d07 7a6777d84d07 7a6777d84d07 7a6777d84d07 7a6777d84d07 7a6777d84d07 7a6777d84d07 7a6777d84d07 6b24e9820611 6b24e9820611 7a6777d84d07 7a6777d84d07 c772d532c74a 7e40416a7213 7e40416a7213 7a6777d84d07 aa34ac34003f 9032b77926d8 f66d93bb8748 7e40416a7213 7a6777d84d07 aa34ac34003f 7e40416a7213 c772d532c74a 1a11bfb5181e 7c7e7468078f 7e40416a7213 d903bd3d579e d903bd3d579e d903bd3d579e c772d532c74a 936c42a99c1e 936c42a99c1e 936c42a99c1e 2092dc6f2774 2092dc6f2774 936c42a99c1e cebfe2251d8c cebfe2251d8c c772d532c74a c772d532c74a c772d532c74a d6ed1e1daa85 d6ed1e1daa85 d903bd3d579e d903bd3d579e c772d532c74a 5ebdcdb092e0 35dea6dd6a2f 7c7e7468078f 512e75d3f5be 446d6af1b5ce 7c7e7468078f bbc0c3b4c101 bbc0c3b4c101 a20b78145ef5 2fab65ba20aa 2fab65ba20aa c772d532c74a 711d3e94b78e 711d3e94b78e 0137ddfb7b22 7a6777d84d07 7e1be644afac 7e1be644afac 42656e88bc44 42656e88bc44 4e1fd8bb6784 42656e88bc44 4e1fd8bb6784 4e1fd8bb6784 42656e88bc44 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 d6ed1e1daa85 42656e88bc44 4f47ac8570ac 4f47ac8570ac 4f47ac8570ac 4f47ac8570ac 3b78fdf04ce4 4f47ac8570ac cebfe2251d8c cebfe2251d8c 7e40416a7213 7c7e7468078f 7e40416a7213 cebfe2251d8c cebfe2251d8c ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 ae8cada84fa2 cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c cebfe2251d8c 90e0061811e1 cebfe2251d8c cebfe2251d8c cebfe2251d8c 0137ddfb7b22 cebfe2251d8c cebfe2251d8c c772d532c74a cebfe2251d8c c772d532c74a cebfe2251d8c cebfe2251d8c 4e1fd8bb6784 4e1fd8bb6784 c772d532c74a 4e1fd8bb6784 4e1fd8bb6784 4e1fd8bb6784 7e40416a7213 c772d532c74a ae8cada84fa2 c772d532c74a 42656e88bc44 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 c772d532c74a 3b98a9a5aee8 43a5241e9e74 c772d532c74a 7e40416a7213 aa34ac34003f 4e1fd8bb6784 3b98a9a5aee8 aa34ac34003f 3b98a9a5aee8 c772d532c74a c772d532c74a c772d532c74a 3b98a9a5aee8 46b0cd850b52 3b98a9a5aee8 3b98a9a5aee8 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 90e0061811e1 90e0061811e1 c772d532c74a c772d532c74a c772d532c74a c772d532c74a 7e40416a7213 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 3b98a9a5aee8 7e40416a7213 3b98a9a5aee8 c772d532c74a c772d532c74a c772d532c74a 7e40416a7213 7e40416a7213 c772d532c74a c772d532c74a c772d532c74a c772d532c74a c772d532c74a a23c8e3ebe9e a23c8e3ebe9e c772d532c74a c772d532c74a a23c8e3ebe9e c772d532c74a c772d532c74a c772d532c74a c772d532c74a 46b0cd850b52 c772d532c74a c772d532c74a f046223bfea8 f046223bfea8 91e09a37c85b c772d532c74a 46b0cd850b52 91e09a37c85b 91e09a37c85b 91e09a37c85b 91e09a37c85b 91e09a37c85b c772d532c74a 91e09a37c85b 91e09a37c85b 91e09a37c85b 91e09a37c85b 91e09a37c85b 91e09a37c85b 91e09a37c85b 91e09a37c85b c772d532c74a 91e09a37c85b 91e09a37c85b f046223bfea8 91e09a37c85b 91e09a37c85b 91e09a37c85b 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 3b78fdf04ce4 d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e c772d532c74a c772d532c74a c772d532c74a d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e 7a6777d84d07 d903bd3d579e 7a6777d84d07 d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 c772d532c74a 6b24e9820611 ae8cada84fa2 ae8cada84fa2 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 6b24e9820611 d903bd3d579e d903bd3d579e d903bd3d579e 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 58eeb176287a 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 864e30313107 d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e d903bd3d579e 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 0741fde6e765 c772d532c74a c772d532c74a c772d532c74a c772d532c74a c772d532c74a 0741fde6e765 8d06f349e7ff c772d532c74a c772d532c74a c772d532c74a c772d532c74a 44a2235fb378 44a2235fb378 44a2235fb378 44a2235fb378 44a2235fb378 44a2235fb378 44a2235fb378 44a2235fb378 44a2235fb378 426f676ddbb4 426f676ddbb4 426f676ddbb4 4ebd39f3f679 4ebd39f3f679 4ebd39f3f679 4ebd39f3f679 4ebd39f3f679 426f676ddbb4 426f676ddbb4 426f676ddbb4 426f676ddbb4 426f676ddbb4 c772d532c74a 44a2235fb378 c772d532c74a c772d532c74a 426f676ddbb4 c772d532c74a c772d532c74a 426f676ddbb4 c772d532c74a 44a2235fb378 c772d532c74a b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d b5e0a0fe027d 7c7e7468078f | <?php
/*
* Copyright 2010 Nathan Gelderloos, Ethan Zonca, Nathan Phillip Brink
*
* This file is part of SlatePermutate.
*
* SlatePermutate is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SlatePermutate is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SlatePermutate. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* 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);
/*
* Set up include() path for user-supplied libs (in case if his system
* doesn't have libs, such as phpcaptcha
* (securimage/securimage.php)). Users would store such libs in /libs.
*
* Coding note: dirname(dirname('a/b/c')) returns 'a'. This is a
* similar effect to dirname('a/b/c') . DIRECTORY_SEPARATOR . '..'.
*/
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'libs');
/**
* 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');
$use_captcha = FALSE;
$admin_enable_purge = FALSE;
$qtips_always = FALSE;
$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 - Find the schedule that works for you!';
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 $pageGenTime = 0;
private $xhtml = FALSE;
/* Scripts and styles */
private $headCode = array();
private $trackingcode = ''; // Tracking code
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)
{
/* Begin tracking generation time */
$this->pageGenTime = round(microtime(),4);
global $ga_trackers;
require_once('school.inc');
/* Scripts and styles available for inclusion */
$this->headCode['jQuery'] = '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>';
$this->headCode['jQueryUI'] = '<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script><link rel="stylesheet" href="styles/jqueryui.css" type="text/css" media="screen" charset="utf-8" />';
$this->headCode['jValidate'] = '<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.pack.js"></script>';
$this->headCode['jAddress'] = '<script type="text/javascript" src="http://ohnopub.net/js/jquery.address-1.3.2.min.js"></script>';
$this->headCode['qTip'] = '<script type="text/javascript" src="http://ohnopub.net/js/jquery.qtip-1.0.min.js"></script>';
$this->headCode['schedInput'] = '<script type="text/javascript" src="scripts/scheduleInput.js"></script>';
$this->headCode['outputPrintStyle'] = '<link rel="stylesheet" href="styles/print.css" type="text/css" media="screen" charset="utf-8" />';
$this->headCode['outputStyle'] = '<link rel="stylesheet" href="styles/output.css" type="text/css" media="screen" charset="utf-8" />';
$this->headCode['gliderHeadcode'] = '<link rel="stylesheet" href="styles/glider.css" type="text/css" media="screen" charset="utf-8" />';
$this->headCode['uiTabsKeyboard'] = '<script type="text/javascript" src="scripts/uiTabsKeyboard.js"></script>';
$this->headCode['displayTables'] = '<script type="text/javascript" src="scripts/displayTables.js"></script>';
$this->pagetitle = $ntitle;
$this->scripts = $nscripts;
/* Compliant browsers which care, such as gecko, explicitly request xhtml: */
if(empty($_SERVER['HTTP_ACCEPT']) /* then the browser doesn't care :-) */
|| strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== FALSE)
{
$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 = '<script type="text/javascript" src="' . $ga_www . 'google-analytics.com/ga.js" />' . "\n"
. $this->trackingcode
. ' <script type="text/javascript">' . "\n"
. ' ' . ($this->xhtml ? '<![CDATA[' : '') . "\n"
. " var mytrackers = new Array();";
$i = 0;
foreach ($ga_trackers as $ga_tracker)
{
$this->trackingcode .= "\n"
. ' mytrackers[' . $i . '] = _gat._getTracker(\'' . $ga_tracker . "');\n"
. ' mytrackers[' . $i . "]._trackPageview();\n";
}
$this->trackingcode .= ' ' . ($this->xhtml ? ']]>' : '') . "\n"
. " </script>\n";
}
self::session_start();
/* everything that needs sessions started to work: */
$this->school = school_load_guess();
$this->semester = school_semester_guess($this->school);
if($immediate
&& $ntitle != "NOHEAD")
$this->head();
}
/**
* \brief
* Instantiate a new page for the caller.
*
* The caller must explicitly call the page::head() function upon
* the value that is returned. No implicit actions are supported
* anymore.
*
* \param $title
* The title of the page. Must be completely UTF-8 (will be
* escaped for you with htmlentitites()).
* \param $scripts
* A list of scripts which the page desires to be included in the
* <head /> of the page. Should this param just be moved to the
* page::head() function?
*/
public static function page_create($title, array $scripts = array())
{
return new page(htmlentities($title), $scripts, FALSE);
}
/**
* \brief
* Adds some headcode to this page.
*
* \param $key
* The key to register this headcode under.
* \param $code
* The actual code, such as a <script/>.
* \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;
}
}
/**
* \brief
* Output the HTML header for a page, including <!DOCTYPE>, <head />, and opening structure
*/
public function head()
{
if ($this->xhtml) {
echo '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL;
}
echo '<!DOCTYPE ' . $this->doctype . '>'. PHP_EOL .
'<html ' . $this->htmlargs . '>'. PHP_EOL .
' <head>'. PHP_EOL .
' <title>' . $this->pagetitle . ' - ' . $this->base_title . '</title>'. PHP_EOL .
' <link rel="stylesheet" href="styles/general.css" type="text/css" media="screen" charset="utf-8" />'. PHP_EOL .
' <link rel="stylesheet" type="text/css" media="print" href="styles/print.css" />'. PHP_EOL .
' <link rel="shortcut icon" href="images/favicon.png" />'. PHP_EOL;
// Write out all passed scripts
foreach ($this->scripts as $i)
echo ' ' . $this->headCode["$i"] . "\n";
echo ' </head>' . PHP_EOL .
' <body>'. PHP_EOL .
' <div id="page">'. PHP_EOL .
' <div id="header">'. PHP_EOL .
' <div id="title">'. PHP_EOL .
' <h1><a href="index.php"><img src="images/slatepermutate-alpha.png" alt="SlatePermutate" class="noborder" /></a><br /></h1>'. PHP_EOL .
' <p>'. PHP_EOL .
' <span id="subtitle">'.$this->pagetitle.'</span>'. PHP_EOL .
' <span id="menu">' . PHP_EOL
. ' Profile: '.$this->school['name'].' <a href="input.php?selectschool=1">(change)</a>' . PHP_EOL;
if ($this->semester !== NULL)
echo ' Semester: ' . $this->semester['name'] . '<a href="input.php?selectsemester=1">(change)</a>' . PHP_EOL;
echo ' </span>'. PHP_EOL .
' </p>'. PHP_EOL .
' </div>'. PHP_EOL .
' </div>'. PHP_EOL .
' <div id="content">'. PHP_EOL;
}
/**
* \brief
* Write out the foot of the page and closing divs
*/
public function foot(){
echo ' </div> <!-- id="content" -->'. PHP_EOL;
echo ' <div id="footer">'. PHP_EOL .
' <div id="leftfoot" style="float:left; margin-top: 1em;">'. PHP_EOL .
' <a href="feedback.php">Submit Feedback</a>'. PHP_EOL .
' </div>'. PHP_EOL .
' <div id="rightfoot">'. PHP_EOL .
' <h5>© '. date('Y').' <a href="http://protofusion.org/~nathang/">Nathan Gelderloos</a><br /><a href="http://ethanzonca.com">Ethan Zonca</a><br /><a href="http://ohnopub.net">Nathan Phillip Brink</a></h5>'. PHP_EOL .
' </div>'. PHP_EOL .
' </div> <!-- id="footer" -->'. PHP_EOL .
' </div> <!-- id="page" -->'. PHP_EOL;
echo $this->trackingcode;
echo ' </body>'. PHP_EOL .
'</html>' . PHP_EOL;
$this->pageGenTime = round(microtime() - $this->pageGenTime,4);
echo '<!-- Page generated in ' . $this->pageGenTime . ' seconds -->';
}
/**
* \brief
* Shows a box with recently processed schedules
*/
public function showSavedScheds($session) {
global $clean_urls;
if (isset($session['saved']) && count($session['saved']) > 0) {
echo '<div id="savedBox">' . PHP_EOL;
$process_php_s = 'process.php?s=';
if ($clean_urls) {
$process_php_s = '';
}
echo '<h3>Saved Schedules:</h3>';
$hidden = 'hidden';
$numsaved = count($session['saved']);
$count = $numsaved;
$output = '';
foreach($session['saved'] as $key => $name)
{
if($count <= 4)
$hidden = '';
$output = '<p class="' . $hidden . '">' . PHP_EOL
. ' <a href="' . $process_php_s . $key . '" title="View schedule #' . $key . '">#' . $key . "</a>:"
. htmlentities($name)
. ' <a href="input.php?s=' . $key . '">edit</a>'
. ' <a href="process.php?del=' . $key . '">delete</a>'
. ' <br /><br />' . PHP_EOL
. '</p>' . PHP_EOL . $output;
$count --;
}
echo $output;
if ($numsaved > 4)
echo '<div id="showLess"><a href="#">Less...</a></div>' . PHP_EOL
. '<div id="showMore"><a href="#">More...</a></div>' . PHP_EOL;
echo '</div>' . PHP_EOL;
}
}
/**
* \brief
* Display a list of schools the user might be from.
* \param $linkto
* The to which a &school= or ?school= query string should be
* appended.
*/
public function showSchools($linkto)
{
echo "<p>\n";
echo school_list_html($this->school['id'], $linkto);
echo "</p>\n";
}
/**
* \brief
* Display a list of semesters the user might be interested in.
* \param $linkto
* The link to which a &semester= or ?semester= query string
* should be appended.
*/
public function showSemesters($linkto = 'input.php')
{
if (strpos($linkto, '?'))
$linkto .= '&';
else
$linkto .= '?';
/*
* We can pre-htmlentities() $linkto because we're only appending
* a safe string.
*/
$linkto = htmlentities($linkto . 'semester=');
$time = time();
echo " <p>\n";
echo " <ul>\n";
foreach (school_semesters($this->school) as $semester)
{
$text_extra = array();
$class_extra = '';
if ($semester['id'] == $this->semester['id'])
{
$class_extra = ' highlight';
$text_extra[] = 'selected';
}
if ($semester['time_start'] < $time && $semester['time_end'] > $time)
$text_extra[] = 'current';
$text_extra = implode($text_extra, ', ');
if (strlen($text_extra))
$text_extra = ' (' . $text_extra . ')';
echo ' <li class="semester' . $class_extra . '"><a href="' . $linkto . $semester['id'] . '">' . htmlentities($semester['name']) . '</a>' . $text_extra . "</li>\n";
}
echo " </ul>\n";
echo " </p>\n";
}
/**
* \brief
* Display school-specific instructions for using slate_permutate.
*/
public function showSchoolInstructions()
{
echo '<div id="schoolInstructionsBox">' . PHP_EOL
. school_instructions_html($this->school) . PHP_EOL
. '</div> <!-- id="schoolInstructionsBox" -->' . PHP_EOL;
}
/**
* \brief
* Print out a vocative form of a student's identity. For example,
* Dearborn Christin Schoolers are called ``Knights'' as are
* Calvin College students.
*
* The third argument is used to determine whether or not this
* address _needs_ to be printed out. For example, in some sentences
* when addressing generic students, it makes no sense to say the
* standard ``Welcome, student'' or ``Dear generic person, how do
* you do today?''. If the third argument is false, we'll refrain
* from outputting anything at all.
*
* \param $prefix
* If the address is to be printed, output this beforehand. Useful
* if this prefix shouldn't be printed if the address itself isn't
* to be printed. See $necessary.
* \param $postfix
* Text to print after the address if it's printed.
* \param $necessary
* Whether or not we might ignore the request that an address be
* printed in certain cases. We default to always printing the
* address.
*/
public function addressStudent($prefix = '', $postfix = '', $necessary = TRUE)
{
if (!$necessary && $this->school['id'] == 'default') {
return;
}
echo $prefix . $this->school['student_address'] . $postfix;
}
/**
* \brief
* Display a 404 page and halt the PHP interpreter.
*
* This function does not return. It handles the creation of a Page
* class with 404-ish stuff and then calls exit() after flushing the
* page out to the user.
*
* \param $message
* A message consisting of valid XHTML to display to the user in
* the 404 page.
*/
public static function show_404($message = 'The page you were looking for cannot be found!.')
{
$page_404 = page::page_create('404: Content Not Found');
$page_404->head();
echo "<h2>404: Content Not Found</h2>\n"
. "<p>\n"
. ' ' . $message . "\n"
. "</p>\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 <script/> element
*/
public function script_wrap($js, $type = 'text/javascript')
{
return '<script type="' . $type . '">' . PHP_EOL
. ($this->xhtml ? '<![CDATA[' : '') . PHP_EOL
. $js . PHP_EOL
. ($this->xhtml ? ']]>' : '') . PHP_EOL
. '// </script>';
}
/**
* \brief
* Add a trailing slash to a path if one does not already exist
*/
private function add_trailing_slash($path){
if($path[strlen($path)-1] != '/') {
return $path . "/";
}
else {
return $path;
}
}
/**
* \brief
* Generate a URL to a given schedule.
*
* \return
* The URL used to access the schedule. You must call
* htmlentities() on this string if it is to be inserted into an
* XHTML document.
*/
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;
}
}
/**
* \brief
* Generate special code to close a self-closing XHTML/HTML
* element.
*
* \return
* A string containing the correct self-closing chars. For
* example, this would be ' /' for XHTML.
*/
public function element_self_close()
{
if ($this->xhtml)
return ' /';
return '';
}
}
|