Changeset - 1a11bfb5181e
[Not reviewed]
default
0 4 0
ethanzonca - 15 years ago 2010-09-23 21:17:08

Made output use the page class
4 files changed with 40 insertions and 16 deletions:
0 comments (0 inline, 0 general)
class.schedule.php
Show inline comments
 
@@ -2,24 +2,25 @@
 

	
 
//**************************************************
 
// class.schedule.php	Author: Nathan Gelderloos
 
//
 
// Represents a schedule of a week. Stores the
 
// classes that are part of that week and calculates
 
// all the possible permutations.
 
//**************************************************
 

	
 
include_once 'errors.php';
 
include_once 'class.class.php';
 
include_once 'class.section.php';
 
include_once 'inc/class.page.php';
 

	
 
class Schedule
 
{
 
    private $classStorage;			// Classes array of classes
 
    private $nclasses;				// Integer number of classes
 
    private $nPermutations = 0;		// Integer number of real permutations
 
    private $possiblePermutations;	// Integer number of possible permutations
 
    private $scheduleName;			// String name of schedule
 
    private $storage;				// Integer array of valid schedules
 
    private $title = "SlatePermutate - Scheduler";
 

	
 
	//--------------------------------------------------
 
@@ -200,27 +201,28 @@ class Schedule
 
	{
 
		$table = "";
 
		$header = "";
 
		$footer = "";
 
		$M = -1;
 
		$Tu = -1;
 
		$W = -1;
 
		$Th = -1;
 
		$F = -1;
 
		$filled = false;
 
		$time = array(700,730,800,830,900,930,1000,1030,1100,1130,1200,1230,1300,1330,1400,1430,1500,1530,1600,1630,1700,1730,1800,1830,1900,1930,2000,2030,2100,2130, 2200);
 

	
 

	
 
		// Reminder:
 
		// border-style:top right bottom left
 
		$header .= "<html><head><title>" . $this->getName() . " :: " . $this->title . "</title>\n\n<style type=\"text/css\">".
 
		/* $header .= "<html><head><title>" . $this->getName() . " :: " . $this->title . "</title>\n\n<style type=\"text/css\">".
 
				"\n.top{\n\tborder-style:solid solid none solid;\nbackground-color:#dddddd;\n}".
 
				"\n.mid{\n\tborder-style:none solid none solid;\nbackground-color:#dddddd;\n}".
 
				"\n.end{\n\tborder-style:none solid solid solid;\nbackground-color:#dddddd;\n}".
 
				"\n.none{\n\tborder-style:none;\n}".
 
				"\n.single{\n\tborder-style:solid;\n\tbackground-color:#dddddd;\n}".
 
				"\ntd{\n\ttext-align:center;\nwidth:7em;\n}".
 
				"\n.time{\n\tborder-style:none none solid none;\n}".
 
				"\n.day{\n\tborder-style:none none solid solid;\n}".
 
				
 
			"\n</style>".
 

	
 
			"\n<script src=\"http://www.google.com/jsapi\"></script>".
 
@@ -229,34 +231,51 @@ class Schedule
 
			"\n\tgoogle.load(\"jqueryui\", \"1.7.2\");".
 
			"\n</script>".
 

	
 
			"\n<link rel=\"stylesheet\" href=\"styles/general.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\">".
 

	
 
			"\n<link rel=\"stylesheet\" href=\"styles/glider.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\">".
 
			"\n<script src=\"scripts/prototype.js\" type=\"text/javascript\" charset=\"utf-8\"></script>". 
 
			"\n<script src=\"scripts/effects.js\" type=\"text/javascript\" charset=\"utf-8\"></script>".
 
			"\n<script src=\"scripts/glider.js\" type=\"text/javascript\" charset=\"utf-8\"></script>".
 
			
 
			"\n</head><body>".
 

	
 
			"<p>There were a total of " . $this->possiblePermutations . " possible permutations. Only " . $this->nPermutations . " permutations had no class conflicts.</p>".
 

	
 
			"\n\n<div id=\"header\">\n<h1><em>SlatePermutate</em> - Scheduler</h1><h3>Schedule name: " . $this->getName() . "</h3>\n</div><div id=\"content\">";
 
			
 
		$footer .="</div></div><script type=\"text/javascript\" charset=\"utf-8\">". 
 

	
 
			"\n\n<div id=\"header\">\n<h1><em>SlatePermutate</em> - Scheduler</h1><h3>Schedule name: " . $this->getName() . "</h3>\n</div><div id=\"content\">".
 

	
 
			*/
 
		$headcode = array('outputStyle', 'gliderHeadcode');
 
		$outputPage = new page($this->getName(), $headcode);
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
		echo "<p>There were a total of " . $this->possiblePermutations . " possible permutations. Only " . $this->nPermutations . " permutations had no class conflicts.</p>";
 
			
 
		$footcloser .="</div></div><script type=\"text/javascript\" charset=\"utf-8\">". 
 
			"\n\tvar my_glider = new Glider('my-glider', {duration:0});".
 
			"\n</script>\n\n</div><div id=\"footer\">\n<h5>&copy; " . Date("Y") . " <a href=\"http://protofusion.org/~nathang/\">Nathan Gelderloos</a><br />".
 
			"\nwith special thanks to <a href=\"http://ethanzonca.com\">Ethan Zonca</a></h5>\n</div>";
 
			"\n</script>";
 

	
 
		$footer .="\n\n</body></html>";
 

	
 
		if($this->nPermutations > 0)
 
		{
 
			$table .= "<div id=\"my-glider\"><div class=\"controls\">";
 
			
 
			for($nn = 1; $nn <= $this->nPermutations; $nn++)
 
			{
 
			$table .= "<a href=\"#section" . $nn . "\">&nbsp;" . $nn . "&nbsp;</a>";
 
			}
 
			
 
			$table .= "</div><div class=\"scroller\"><div class=\"scontent\">";
 
		
 
@@ -495,28 +514,29 @@ class Schedule
 
						$table .= "\n\t\t<td class=\"none\">&nbsp;</td>";
 
					}
 
					$filled = false;
 

	
 
					// End of row
 
					$table .= "\n\t</tr>";
 
				}
 

	
 
				// End of table
 
				$table .= "</table></div>";
 
			}
 

	
 
			echo $header . $table . $footer;   
 
			echo $table . $footcloser;   
 
		} else {
 
			echo '<html><body><p>There are no possible schedules. Please try again.</p></body></html>';
 
		}
 
		$outputPage->foot();
 
	}
 

	
 
	//--------------------------------------------------
 
	// Changes the title of the page.
 
	//--------------------------------------------------
 
	function changeTitle($t)
 
	{
 
		$this->title = $t;
 
	}
 

	
 
	//--------------------------------------------------
 
	// Make the time "pretty."
 
@@ -524,13 +544,13 @@ class Schedule
 
	function prettyTime($t){
 
		if($t > 1259)
 
		{
 
			$t = ($t-1200);
 
			return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " PM";
 
		} else {
 
			return substr($t, 0, strlen($t)-2) . ":" . substr($t, strlen($t)-2, strlen($t)) . " AM";
 
		}
 
	}
 

	
 
}
 

	
 
?>
 
\ No newline at end of file
 
?>
inc/class.page.php
Show inline comments
 
@@ -16,57 +16,59 @@ class page {
 

	
 
  private $trackingcode = '<script type="text/javascript">
 
				  var _gaq = _gaq || [];
 
				  _gaq.push([\'_setAccount\', \'UA-17441156-1\']);
 
				  _gaq.push([\'_trackPageview\']);
 
				  (function() {
 
				    var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
 
				    ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
 
				    var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
 
				  })();
 
				</script>'; // Google analytics ga.js tracking code
 

	
 
  private $title = ''; // Title of page
 
  private $pagetitle = ''; // Title of page
 
  private $scripts = array(); // Scripts to include on page
 

	
 
  public function __construct($ntitle, $nscripts = array() ){
 
    // Scripts and styles available to include
 
    $this->headCode['jQuery'] = '<script src="http://www.google.com/jsapi"></script><script type="text/javascript" charset="utf-8"> google.load("jquery", "1.3.2"); google.load("jqueryui", "1.7.2");</script>';
 
    $this->headCode['jValidate'] = '<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.pack.js"></script>';
 
    $this->headCode['schedInput'] = '<script type="text/javascript" src="scripts/scheduleInput.js"></script>';
 
  
 
   $this->title = $ntitle;
 
    $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"><script src="scripts/prototype.js" type="text/javascript" charset="utf-8"></script><script src="scripts/effects.js" type="text/javascript" charset="utf-8"></script><script src="scripts/glider.js" type="text/javascript" charset="utf-8"></script>'; 
 

	
 
   $this->pagetitle = $ntitle;
 
    $this->scripts = $nscripts;
 
    if($ntitle != "NOHEAD")
 
      $this->head();
 

	
 
 }
 

	
 
  private function top(){
 
    echo '<div id="header">
 
          <h1><em>SlatePermutate</em> -  Scheduler</h1>
 
          <h1><em>SlatePermutate</em> - '.$this->pagetitle.'</h1>
 
          </div>
 
          <div id="content">';
 
  }
 

	
 
// Public functions/vars
 

	
 
  private function head(){
 
    session_start();
 
    $this->pageGenTime = round(microtime(), 3);
 

	
 
    echo '<!DOCTYPE ' . $this->doctype . '>
 
	  <html ' . $this->htmlargs . '>
 
	  <head>
 
	    <title>' . $this->title . ' :: ' . $this->base_title . '</title>
 
	    <title>' . $this->pagetitle . ' :: ' . $this->base_title . '</title>
 
           <link rel="stylesheet" href="styles/general.css" type="text/css" media="screen" charset="utf-8">';
 

	
 
    // Write out all passed scripts
 
    foreach ($this->scripts as $i){
 
    	echo $this->headCode["$i"];
 
    }
 

	
 
    echo '</head>
 
	  <body '.$this->bodyargs.' >';
 
    echo $this->top(); // Write out top
 
  }
 

	
 
@@ -95,13 +97,13 @@ class page {
 
		echo '<div id="savedBox" ><h3>Saved Schedules:</h3>';
 
		foreach($session['saved'] as $key => $schedule){
 
			$sch = unserialize($schedule);
 
			echo "<a href=\"process.php?savedkey=$key\">#" . ($key + 1) . " - " . $sch->getName() . "</a> <em><a href=\"process.php?delsaved=$key\"><img src=\"images/close.png\" style=\"border:0;\" /></a></em><br />";
 
		}
 
		echo '</div>';
 
	}
 
       echo '</p>';
 
}
 

	
 
}
 

	
 
?>
 
\ No newline at end of file
 
?>
input.php
Show inline comments
 
@@ -41,16 +41,17 @@ include_once 'inc/class.page.php';
 
<div class="paddingtop" id="classage"><input type="button" value="Add class" /></div>
 
<div class="paddingtop"><input style="float:left;" type="submit" value="Submit" /></div>
 

	
 
</form>
 

	
 
<p>&nbsp;<br /></p>
 

	
 
<h3>TODO:</h3>
 

	
 
<ul>
 
	<li>Form validation to ensure endtime is after starttime, at least one day is checked.</li>
 
	<li>Auto-populate form based on saved schedule?</li>
 
        <li>Grab data from school sites such as <a href="http://www.cedarville.edu/courses/schedule/2010fa_be_bebl.htm" target="_blank">this?</a></li>
 
</ul>
 

	
 
<?php
 
$inputPage->foot();
styles/general.css
Show inline comments
 
@@ -45,12 +45,13 @@
 
		background: #fff;
 
	}
 
	.class {
 
		background: #99FF99;
 
	}
 
	#classage {
 
		float:left;
 
	}
 
	.paddingtop {
 
		padding: .5em;
 
		padding-top: .8em;
 
	}
 

	
0 comments (0 inline, 0 general)