Changeset - ae8cada84fa2
[Not reviewed]
default
0 9 0
Nathan Brink (binki) - 15 years ago 2011-01-31 23:21:38
ohnobinki@ohnopublishing.net
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 ;-)).
9 files changed with 39 insertions and 13 deletions:
0 comments (0 inline, 0 general)
admin.php
Show inline comments
 
@@ -20,13 +20,13 @@
 

	
 
require_once('inc/class.page.php');
 
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" );
 
                 });';
 
  $adminpage->headcode_add('datePicker', $adminpage->script_wrap($datepicker), TRUE);
 
  $adminpage->head();
auto.php
Show inline comments
 
@@ -32,13 +32,13 @@
 
 */
 

	
 
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');
 
}
 
else {
 
  header('Content-Type: application/json; encoding=utf-8');
feedback-submit.php
Show inline comments
 
@@ -23,13 +23,14 @@
 
if ($use_captcha)
 
  {
 
    require_once('securimage/securimage.php');
 
    $securimage = new Securimage();
 
  }
 

	
 
$feedbackpage = new page('Feedback');
 
$feedbackpage = page::page_create('Feedback');
 
$feedbackpage->head();
 
$subject = '[SlatePermutate] - Feedback';
 
?>
 

	
 
<h3>Thanks!</h3>
 

	
 
<?php
feedback.php
Show inline comments
 
@@ -17,13 +17,14 @@
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
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'];
 

	
 
$n = "\n";
 

	
inc/class.page.php
Show inline comments
 
@@ -161,12 +161,33 @@ class page
 
       && $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/>.
 
@@ -186,13 +207,13 @@ class page
 
   */
 
  public function head()
 
  {
 
    $this->pageGenTime = round(microtime(), 3);
 

	
 
    if ($this->xhtml)
 
       echo '<?xml version="1.0" encoding="utf-8" ?>' . PHP_EOL;
 
      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 .
 
@@ -358,13 +379,14 @@ class page
 
   * \param $message
 
   *   A message consisting of valid XHTML to display to the user in
 
   *   the 404 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 "<h2>404: Content Not Found</h2>\n"
 
      . "<p>\n"
 
      . '  ' . $message . "\n"
 
      . "</p>\n";
 

	
inc/class.schedule.php
Show inline comments
 
@@ -242,13 +242,14 @@ class Schedule
 
    if(isset($_REQUEST['print']) && $_REQUEST['print'] != ''){
 
      $headcode = array('jQuery', 'jQueryUI', 'uiTabsKeyboard', 'outputStyle', 'outputPrintStyle', 'displayTables');
 
    }
 
    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();
 

	
 

	
 

	
 
    if(isset($_REQUEST['print'])) {
 
 
 
     echo '<script type="text/javascript">';
index.php
Show inline comments
 
@@ -15,14 +15,16 @@
 
 * 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/>.
 
 */
 

	
 
  include_once 'inc/class.page.php'; 
 
  $welcomepage = new page('Welcome');
 
require_once 'inc/class.page.php'; 
 

	
 
$welcomepage = page::page_create('Welcome');
 
$welcomepage->head();
 
?>
 

	
 
<h3>Find the schedule that works for you!</h3>
 
<p>Plan your next semester with SlatePermutate! SlatePermutate generates every possible schedule with the courses you enter to let you pick the schedule that fits your life.</p>
 
<p><!-- View <a href="schedulecreator.php">demo output</a> or --><a href="input.php">Get started</a></p> 
 

	
input.php
Show inline comments
 
@@ -22,15 +22,13 @@ include_once 'inc/class.schedule.php';
 
include_once 'inc' . DIRECTORY_SEPARATOR . 'class.course.inc';
 
include_once 'inc/class.section.php';
 
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;
 
$school = $inputPage->get_school();
 

	
 
if (isset($_REQUEST['s']))
project.php
Show inline comments
 
@@ -16,13 +16,14 @@
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
  include_once 'inc/class.page.php'; 
 
  $projectpage = new page('Project');
 
$projectpage = page::page_create('Project');
 
$projectpage->head();
 
?>
 

	
 
<h3>The SlatePermutate Project</h3>
 

	
 
<p>Welcome to the SlatePermutate Project, by Nathan Gelderloos, Ethan Zonca, and Nathan Brink.</p>
 

	
0 comments (0 inline, 0 general)