# HG changeset patch
# User Nathan Phillip Brink 
# Date 2011-01-31 23:21:38
# Node ID ae8cada84fa20777d794f3de392610c350aa2e21
# Parent  02327021cfa6568cc2d38e9a4e2e6e39a4ec0b37
Create pages with an object factory (start solving bug 75 -- allowing overriding the page class will now be just a few more lines of code ;-)).
diff --git a/admin.php b/admin.php
--- a/admin.php
+++ b/admin.php
@@ -23,7 +23,7 @@ require_once('inc/admin.inc');
 
 
   $scripts = array('jQuery','jQueryUI'); 
-  $adminpage = new page('Administration',$scripts,FALSE);
+$adminpage = page::page_create('Administration', $scripts);
   $datepicker = '$(function() {
                    $( "#datepicker" ).datepicker();
                    $( "#datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
diff --git a/auto.php b/auto.php
--- a/auto.php
+++ b/auto.php
@@ -35,7 +35,7 @@ require_once('inc/school.inc');
 require_once('inc/class.page.php');
 require_once('inc/class.course.inc');
 
-Page::session_start();
+page::session_start();
 
 if (isset($_REQUEST['txt'])) {
   header('Content-Type: text/plain; encoding=utf-8');
diff --git a/feedback-submit.php b/feedback-submit.php
--- a/feedback-submit.php
+++ b/feedback-submit.php
@@ -26,7 +26,8 @@ if ($use_captcha)
     $securimage = new Securimage();
   }
 
-$feedbackpage = new page('Feedback');
+$feedbackpage = page::page_create('Feedback');
+$feedbackpage->head();
 $subject = '[SlatePermutate] - Feedback';
 ?>
 
diff --git a/feedback.php b/feedback.php
--- a/feedback.php
+++ b/feedback.php
@@ -20,7 +20,8 @@
 
 include_once 'inc/class.page.php'; 
 
-$feedbackpage = new page('Feedback');
+$feedbackpage = page::page_create('Feedback');
+$feedbackpage->head();
 $ipi = $_SERVER['REMOTE_ADDR'];
 $fromdom = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 $httpagenti = $_SERVER['HTTP_USER_AGENT'];
diff --git a/inc/class.page.php b/inc/class.page.php
--- a/inc/class.page.php
+++ b/inc/class.page.php
@@ -164,6 +164,27 @@ class page
 
   /**
    * \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
+   *    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
@@ -189,7 +210,7 @@ class page
     $this->pageGenTime = round(microtime(), 3);
 
     if ($this->xhtml)
-       echo '' . PHP_EOL;
+      echo '' . PHP_EOL;
 
     echo 'doctype . '>'. PHP_EOL .
 	  'htmlargs . '>'. PHP_EOL .
@@ -361,7 +382,8 @@ class page
    */
   public static function show_404($message = 'I couldn\'t find what you were looking for :-/.')
   {
-    $page_404 = new Page('404: Content Not Found');
+    $page_404 = page::page_create('404: Content Not Found');
+    $page_404->head();
 
     echo "
404: Content Not Found
\n"
       . "\n"
diff --git a/inc/class.schedule.php b/inc/class.schedule.php
--- a/inc/class.schedule.php
+++ b/inc/class.schedule.php
@@ -245,7 +245,8 @@ class Schedule
     else {
       $headcode = array('outputStyle',  'jQuery', 'jQueryUI', 'uiTabsKeyboard', 'displayTables');
     }
-    $outputPage = new Page(htmlentities($this->getName()), $headcode);
+    $outputPage = page::page_create(htmlentities($this->getName()), $headcode);
+    $outputPage->head();
 
 
 
diff --git a/index.php b/index.php
--- a/index.php
+++ b/index.php
@@ -18,8 +18,10 @@
  * along with SlatePermutate.  If not, see .
  */
 
-  include_once 'inc/class.page.php'; 
-  $welcomepage = new page('Welcome');
+require_once 'inc/class.page.php'; 
+
+$welcomepage = page::page_create('Welcome');
+$welcomepage->head();
 ?>
 
 
Find the schedule that works for you!
diff --git a/input.php b/input.php
--- a/input.php
+++ b/input.php
@@ -25,9 +25,7 @@ include_once 'inc/class.page.php';
 require_once('inc/schedule_store.inc');
 
 $scripts = array('jQuery', 'jQueryUI', 'jValidate','qTip','schedInput');
-$inputPage = new page('Scheduler', $scripts, FALSE);
-
-
+$inputPage = page::page_create('Scheduler', $scripts, FALSE);
 
 $schedule_store = FALSE;
 $sch = FALSE;
diff --git a/project.php b/project.php
--- a/project.php
+++ b/project.php
@@ -19,7 +19,8 @@
  */
 
   include_once 'inc/class.page.php'; 
-  $projectpage = new page('Project');
+$projectpage = page::page_create('Project');
+$projectpage->head();
 ?>
 
 The SlatePermutate Project