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
 
@@ -14,25 +14,25 @@
 
 * 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/>.
 
 */
 

	
 
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();
 

	
 
  if(!isset($admin_pass) || !isset($admin_enable) || $admin_enable !== true) {
 
    echo "<p>The administration interface is not enabled or is improperly configured. See config.inc for more information.</p>";
 
    $adminpage->foot();
 
    exit;
 
  }
auto.php
Show inline comments
 
@@ -26,25 +26,25 @@
 
 *   names.
 
 *
 
 *   Since we output JSON, no special Page classes and stuff
 
 *   :-p. Except we still call the Page class's session_start()
 
 *   function because we apparently need sessions.... oh yeah, for
 
 *   school profile supports ;-).
 
 */
 

	
 
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');
 
}
 

	
 
if (!isset($_REQUEST['term'])) {
 
  clean_empty_exit();
 
}
 

	
feedback-submit.php
Show inline comments
 
@@ -17,25 +17,26 @@
 
 * 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';
 

	
 
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
 
Page::session_start();
 

	
 
$ip = $_POST['ip'];
 
$httpagent = $_POST['httpagent'];
 
$fromdom = $_POST['fromdom'];
 
$nameis = $_POST['nameis'];
feedback.php
Show inline comments
 
@@ -11,25 +11,26 @@
 
 *
 
 * 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/>.
 
 */
 

	
 
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";
 

	
 
?>
 

	
 
<form action="feedback-submit.php" method="post">
 
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
 
<input type="hidden" name="fromdom" value="<?php echo $fromdom ?>" />
 
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
inc/class.page.php
Show inline comments
 
@@ -155,24 +155,45 @@ class page
 
    self::session_start();
 
    /* everything that needs sessions started to work: */
 

	
 
    $this->school = school_load_guess();
 

	
 
    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;
 
@@ -180,25 +201,25 @@ class page
 
      $this->scripts[] = $key;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Output the HTML header for a page, including the <!DOCTYPE> and <head />
 
   */
 
  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 .
 
	  '    <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";
 
@@ -352,25 +373,26 @@ class page
 
   *   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 = '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";
 

	
 
    $page_404->foot();
 

	
 
    exit();
 
  }
 

	
 
  /**
inc/class.schedule.php
Show inline comments
 
@@ -236,25 +236,26 @@ class Schedule
 
    /* zero-based */
 
    $first_permutation = $page * SP_PERMUTATIONS_PER_PAGE;
 
    $last_permutation = min($this->nPermutations, $first_permutation + SP_PERMUTATIONS_PER_PAGE);
 

	
 
    $footcloser = '';
 

	
 
    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">';
 
      echo 'jQuery(document).ready( function() {';
 
 
 
      /* If user entered items to print */
 
      if($_REQUEST['print'] != 'all'){
 
	echo 'jQuery(\'.section\').hide();';
 
	$items = explode(',', $_REQUEST['print']);
index.php
Show inline comments
 
@@ -9,26 +9,28 @@
 
 * 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/>.
 
 */
 

	
 
  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> 
 

	
 

	
 
<p class="righttext"><a href="input.php"><img class="noborder" src="images/get-started.png" alt="Get Started" /></a></p>
 
<!-- <p style="color: #777; font-size: .7em;">This program was created by <a href="http://www.calvin.edu" rel="external">Calvin College</a> and <a href="http://cedarville.edu/" rel="external">Cedarville University</a> students. SlatePermutate works with any college or university.</p>
 
-->
 
<?php
 
$welcomepage->foot();
input.php
Show inline comments
 
@@ -16,27 +16,25 @@
 
 *
 
 * 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.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']))
 
  {
 
    $schedule_store = schedule_store_init();
 
    $schedule_id = (int)$_REQUEST['s'];
 
    $sch = schedule_store_retrieve($schedule_store, $schedule_id);
 
  }
 

	
project.php
Show inline comments
 
@@ -10,25 +10,26 @@
 
 * (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/>.
 
 */
 

	
 
  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>
 

	
 
<h3>Licensing</h3>
 
<p>SlatePermutate is licensed under the terms of the GNU Affero General Public License, version 3. SlatePermutate is distributed without any warranty. See the <a href="http://www.gnu.org/licenses/" rel="external">GNU Affero General Public License</a> for more details.</p>
 

	
 
<h3>Bug/Issue Tracking</h3>
 
<p>To view or file bugs for SlatePermutate, visit the <a href="http://protofusion.org/bugzilla/buglist.cgi?product=SlatePermutate" rel="external">Bugzilla tracker</a> for the project. All issues will be addressed as soon as is reasonably possible.</p>
 

	
0 comments (0 inline, 0 general)