Changeset - 7a6777d84d07
[Not reviewed]
default
0 11 0
Ethan Zonca (ethanzonca) - 15 years ago 2010-11-13 20:28:25
e@ethanzonca.com
General styling changes
11 files changed with 124 insertions and 137 deletions:
0 comments (0 inline, 0 general)
auto.php
Show inline comments
 
@@ -28,87 +28,96 @@
 
 *   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('class.class.php');
 

	
 
Page::session_start();
 

	
 
if (isset($_REQUEST['txt']))
 
if (isset($_REQUEST['txt'])) {
 
  header('Content-Type: text/plain; encoding=utf-8');
 
else
 
}
 
else {
 
  header('Content-Type: application/json; encoding=utf-8');
 
}
 

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

	
 
$getsections = FALSE;
 
if (isset($_REQUEST['getsections']))
 
if (isset($_REQUEST['getsections'])) {
 
  $getsections = TRUE;
 
}
 

	
 
$term = $_REQUEST['term'];
 
$term_parts = Classes::parse($term);
 
if (!count($term_parts))
 
if (!count($term_parts)) {
 
  clean_empty_exit();
 
}
 

	
 
$school = school_load_guess();
 
if (!$school['crawled'])
 
if (!$school['crawled']) {
 
  clean_empty_exit();
 
}
 

	
 
$cache_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'auto' . DIRECTORY_SEPARATOR . $school['id'] . DIRECTORY_SEPARATOR;
 

	
 
/*
 
 * autocomplete the list of departments. If the user has already
 
 * entered a valid department name _and_ delimitted it, however, go on
 
 * to the next autocompletion step.
 
 */
 
$term_strlen = strlen($term);
 
$dept_strlen = strlen($term_parts['department']);
 
$dept = $term_parts['department'];
 
if (!$getsections && count($term_parts) == 1 && $term_strlen == strlen($dept))
 
  {
 
    $dept_file = $cache_dir . '-depts';
 
    if (!file_exists($dept_file))
 
    if (!file_exists($dept_file)) {
 
      clean_empty_exit();
 
    }
 
    $departments = unserialize(file_get_contents($dept_file));
 
    $json_depts = array();
 
    foreach ($departments as $key => $department)
 
      if (!strncmp($department, $dept, $dept_strlen))
 
    foreach ($departments as $key => $department) {
 
      if (!strncmp($department, $dept, $dept_strlen)) {
 
	$json_depts[] = $department;
 
      }
 
    }
 

	
 
    echo json_encode($json_depts);
 
    exit(0);
 
  }
 

	
 
if ($getsections)
 
  {
 
    $section_file = $cache_dir . $dept . DIRECTORY_SEPARATOR . $term_parts['course'];
 
    if (file_exists($section_file))
 
      {
 
	readfile($section_file);
 
	exit(0);
 
      }
 
    /* section not found! */
 
    /* Section not found! */
 
    header('HTTP/1.1 404: Not found');
 
    header('Content-Type: text/plain; encoding=utf-8');
 
    echo 'Could not find course ' . implode('-', $term_parts) . "\n";
 
    exit(0);
 
  }
 

	
 
/*
 
 * if a department is fully entered, life gets slightly more
 
 * If a department is fully entered, life gets slightly more
 
 * complicated. I suppose I only want to autocomplete the first digit
 
 * of the course/class number. I.e., CS-2 for CS-262 for when the
 
 * student has entered CS- or 'CS'. But for now we can just dump the entire department at the user ;-).
 
 */
 
$classes_file = $cache_dir . $dept . '.sects';
 
if (file_exists($classes_file))
 
  {
 
    $classes = unserialize(file_get_contents($classes_file));
 
    $class_start = '';
 
    if (count($term_parts) > 1)
 
      $class_start = $term_parts['course'];
 
    $class_start_strlen = strlen($class_start);
 
@@ -117,25 +126,25 @@ if (file_exists($classes_file))
 
    $json_classes = array();
 
    foreach ($classes as $class)
 
      if (!strncmp($class, $class_start, $class_start_strlen))
 
	{
 
	  $json_classes[] = $dept . '-' . $class;
 
	}
 

	
 
    echo json_encode($json_classes);
 
    exit(0);
 
  }
 

	
 
/**
 
 * Nothing caught..
 
 * Nothing caught
 
 */
 
clean_empty_exit();
 

	
 
/**
 
 * \brief
 
 *   Send an empty JSON array and exit.
 
 */
 
function clean_empty_exit()
 
{
 
  echo '[]';
 
  exit(0);
 
}
class.class.php
Show inline comments
 
@@ -19,91 +19,84 @@
 
 */
 

	
 
//**************************************************
 
// class.class.php	Author: Nathan Gelderloos
 
//
 
// Represents a class.
 
//**************************************************
 

	
 
include_once 'class.section.php';
 

	
 
class Classes
 
{
 
  private $name;		// String
 
  private $name;	// String
 
  private $sections;	// Array of sections
 
  private $nsections;	// int
 
    
 
  //--------------------------------------------------
 
  // Creates a class with the given name.
 
  //--------------------------------------------------
 
  function __construct($n)
 
  {
 
    $this->sections = array();
 
    $this->name = $n;
 
    $this->nsections = 0;
 
  }
 
	
 
  /**
 
   * \brief
 
   *   Adds an already-instantiated section to this class.
 
   */
 
  public function section_add(Section $section)
 
  {
 
    $this->sections[$this->nsections] = $section;
 
    $this->nsections ++;
 
    $this->nsections++;
 
  }
 

	
 
  //--------------------------------------------------
 
  // Returns the number of sections in the class.
 
  //--------------------------------------------------
 
  function getnsections()
 
  {
 
    return $this->nsections;
 
  }
 
	
 
  //--------------------------------------------------
 
  // Returns the desired section for analysis.
 
  //--------------------------------------------------
 
  function getSection($i)
 
  {
 
    // Checks to make sure the desired section is part of the set.
 
    if(isset($this->sections[$i]))
 
      {
 
	//echo "Object sections[$i] was set<br />";
 
      } else {
 
      echo "Object sections[$i] was NOT set <br />";
 
    }
 

	
 
    $result = $this->sections[$i];
 
    return $result;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Retrieve a section of this class based on its letter.
 
   *
 
   * \todo Make this function replace completely the getSection()
 
   * function, have $this->sections be keyed by letter, and have a
 
   * __wakup() convert the old $this->sections format to the new one.
 
   *
 
   * \return
 
   *   The requested section or NULL if that section does not yet
 
   *   exist for this class.
 
   */
 
  public function section_get($letter)
 
  {
 
    foreach ($this->sections as $section)
 
      if ($section->getLetter() == $letter)
 
    foreach ($this->sections as $section) {
 
      if ($section->getLetter() == $letter) {
 
	return $section;
 

	
 
      }
 
    }
 
    return NULL;
 
  }
 

	
 
  //--------------------------------------------------
 
  // Returns the name of the class.
 
  //--------------------------------------------------
 
  public function getName()
 
  {
 
    return $this->name;
 
  }
 

	
 
  /**
 
@@ -117,26 +110,27 @@ class Classes
 
   * \see Section::parse()
 
   *
 
   * \param $course_spec
 
   *   A course specifier to parse, such as 'cs262' or 'MATH-156'.
 
   * \return
 
   *   An array with normalized output having keys of 'department' and
 
   *   'course'. If the user's input has less than these two keys of
 
   *   information, the returned array may have zero or one elements.
 
   */
 
  public static function parse($course_spec)
 
  {
 
    $section_parts = Section::parse($course_spec);
 
    if (isset($section_parts['section']))
 
    if (isset($section_parts['section'])) {
 
      unset($section_parts['section']);
 
    }
 

	
 
    return $section_parts;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Represent this class as a string.
 
   */
 
  public function __toString()
 
  {
 
    return $this->getName();
 
  }
class.schedule.php
Show inline comments
 
@@ -87,25 +87,25 @@ class Schedule
 
  //--------------------------------------------------
 
  // Adds a section to the desired class.
 
  //--------------------------------------------------
 
  function addSection($course_name, $letter, $time_start, $time_end, $days, $synonym = NULL, $faculty = NULL, $location = NULL)
 
  {
 
    $found = false;
 
    $counter = 0;
 
      
 
    while(!$found && ($counter < $this->nclasses))
 
      {
 
	$temp = $this->classStorage[$counter]->getName();
 
			
 
	if((strcmp($temp,$course_name)) == 0)
 
	if(strcmp($temp,$course_name) == 0)
 
	  {
 
	    $found = true;
 
	  } else {
 
	  $counter++;
 
	}
 
      }
 
		
 
    if($counter == $this->nclasses)
 
      {
 
	echo 'Could not find class: ' . $course_name . "<br />\n";
 
      } else {
 
      $section = $this->classStorage[$counter]->section_get($letter);
 
@@ -205,25 +205,25 @@ class Schedule
 
	$counter++;
 
      } while($counter < $this->possiblePermutations);
 
  }
 
    
 
  //--------------------------------------------------
 
  // Prints out the possible permutations in tables.
 
  //--------------------------------------------------
 
  function writeoutTables()
 
  {
 
    $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);
 

	
 
    define('SP_PERMUTATIONS_PER_PAGE', 256);
 
    define('SP_PERMUTATIONS_PER_PAGE', 256); /** @TODO: Define this in config.inc */
 

	
 
    $npages = ceil($this->nPermutations / SP_PERMUTATIONS_PER_PAGE);
 
    $page = 0;
 
    if (isset($_REQUEST['page']))
 
      $page = $_REQUEST['page'];
 
    /*
 
     * only display the ``this page doesn't exist'' 404 if there is at
 
     * least one permutation. Otherwise, we give an irrelevant 404 for
 
     * users with no permutations.
 
     */
 
    if ($this->nPermutations && $page >= $npages)
 
      Page::show_404('Unable to find page ' . $page . ', there are only ' . $this->nPermutations . ' non-conflicting permutations, for a total of ' . $npages . ' pages.');
 
@@ -234,82 +234,80 @@ class Schedule
 
    $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);
 

	
 

	
 

	
 
    if(isset($_REQUEST['print'])){
 
    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']);
 
	foreach($items as $item){
 
	  echo 'jQuery(\'#tabs-'.$item.'\').show();';
 
	}
 
      }
 
      echo '}); '; /* Close document.ready for jquery */
 
      echo '}); '; /* Close document.ready for jQuery */
 
      echo 'window.print(); </script>';
 

	
 
      echo '<p><a href="'.$_SERVER['SCRIPT_NAME'].'?s=' . $this->id_get() . '">&laquo; Return to normal view</a> </p>';
 

	
 
    }
 
    else {
 
      echo '<script type="text/javascript">';
 
      echo 'jQuery(document).ready( function() {';
 
      echo 'jQuery("#tabs").tabs();';
 
      echo 'jQuery("#sharedialog").dialog({ modal: true, width: 550, resizable: false, draggable: false, autoOpen: false });';
 
      echo 'jQuery("#share").click( function() {
 
              jQuery("#sharedialog").dialog("open");
 
            });';
 
      echo 'jQuery(\'#printItems\').click( function() {
 
		window.location = "'.$_SERVER['SCRIPT_NAME'].'?s='.$this->id_get().'&amp;print=" + (jQuery(\'#tabs\').tabs(\'option\',\'selected\') + 1);
 
	    });
 
	    jQuery(\'#cancelItems\').click( function() {
 
		jQuery(\'#selectItemsInput\').hide();
 
	    });
 
';
 
      echo '});</script>'; /* Close document.ready for jquery */
 
      echo '<div id="sharedialog" title="Share Schedule"><p>You can share your schedule with the URL below:</p><p><!--http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'].'-->'.$outputPage->gen_share_url($this->id_get()).'</p></div>';
 
      echo '<p><span id="printItems"><a href="#">Print</a></span> :: <span id="share"><a href="#">Share</a></span> :: <a href="input.php">Home</a></p><p class="centeredtext">Having problems? <a href="feedback.php">Let us know</a>.</p><p class="centeredtext graytext"><em>Keyboard Shortcut: Left and right arrow keys switch between schedules</em></p>';
 
      echo '  jQuery(document).ready( function() {';
 
      echo '    jQuery("#tabs").tabs();';
 
      echo '    jQuery("#sharedialog").dialog({ modal: true, width: 550, resizable: false, draggable: false, autoOpen: false });';
 
      echo '    jQuery("#share").click( function() {
 
                  jQuery("#sharedialog").dialog("open");
 
                });';
 
      echo '    jQuery(\'#printItems\').click( function() {
 
		  window.location = "'.$_SERVER['SCRIPT_NAME'].'?s='.$this->id_get().'&amp;print=" + (jQuery(\'#tabs\').tabs(\'option\',\'selected\') + 1);
 
	        });
 
	        jQuery(\'#cancelItems\').click( function() {
 
		  jQuery(\'#selectItemsInput\').hide();
 
	        });';
 
      echo '  });
 
            </script>';
 

	
 
      echo '<div id="sharedialog" title="Share Schedule"><p>You can share your schedule with the URL below:</p><p>'.$outputPage->gen_share_url($this->id_get()).'</p></div>';
 
      echo '<p><span id="printItems"><a href="#">Print</a></span> :: <span id="share"><a href="#">Share</a></span> :: <a href="input.php">Home</a></p>';
 
      echo '<p class="centeredtext">Having problems? <a href="feedback.php">Let us know</a>.</p>';
 
      echo '<p class="centeredtext graytext"><em>Keyboard Shortcut: Left and right arrow keys switch between schedules</em></p>';
 
    }		
 

	
 
    echo "\n";
 

	
 
    if($this->nPermutations > 0)
 
      {
 
	echo "<div id=\"tabs\">\n"
 

	
 

	
 
    . '  <div id="show-box" class="show-buttons">
 
    <form>
 
       <label><strong>Display:</strong></label>
 
       <input id="show-prof" name="show-prof" type="checkbox" checked="checked" /><label for="show-prof">Professor</label>
 
       <input id="show-location" name="show-location" type="checkbox" /><label for="show-location">Room</label>
 
       <input id="show-synonym" name="show-synonym" type="checkbox" /><label for="show-synonym">Synonym</label>
 
    </form>
 
  </div> <!-- id="show-box" -->'
 

	
 

	
 

	
 
	  . "<div id=\"the-tabs\"><ul>\n";
 
	echo '<div id="tabs">' . "\n" .
 
               '<div id="show-box" class="show-buttons">
 
                  <form>
 
                    <label><strong>Display:</strong></label>
 
                    <input id="show-prof" name="show-prof" type="checkbox" checked="checked" /><label for="show-prof">Professor</label>
 
                    <input id="show-location" name="show-location" type="checkbox" /><label for="show-location">Room</label>
 
                    <input id="show-synonym" name="show-synonym" type="checkbox" /><label for="show-synonym">Synonym</label>
 
                  </form>
 
                </div> <!-- id="show-box" -->'
 
	     . '<div id="the-tabs"><ul>' . "\n";
 
			
 
	for($nn = $first_permutation + 1; $nn <= $last_permutation; $nn++)
 
	  {
 
	    echo  "<li><a href=\"#tabs-" . $nn . "\">&nbsp;" . $nn . "&nbsp;</a></li>\n";
 
	  }
 
			
 
	echo "    </ul></div>\n  \n";
 

	
 
	echo "    <div id=\"pagers\">\n";
 
	/* Previous button */
 
	if ($page > 0)
 
	  echo '      <div id="pager-previous" class="pager left"><a href="' . $this->url($this->id, $page - 1) . '">&laquo; Previous</a></div>' . "\n";
 
@@ -440,25 +438,25 @@ class Schedule
 
    $outputPage->foot();
 
  }
 

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

	
 
  //--------------------------------------------------
 
  // Make the time "pretty."
 
  // Make the time "pretty"
 
  //--------------------------------------------------
 
  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";
 
    }
 
  }
 

	
 
  /**
feedback-submit.php
Show inline comments
 
@@ -8,33 +8,32 @@
 
 * 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/>.
 
 */
 
        include_once 'inc/class.page.php';
 
        $feedbackpage = new page('Feedback');
 

	
 
	$subject = '[SlatePermutate] - Feedback';
 
  include_once 'inc/class.page.php';
 
  $feedbackpage = new page('Feedback');
 
  $subject = '[SlatePermutate] - Feedback';
 
?>
 

	
 
<h3>Thanks!</h3>
 

	
 

	
 
<?php
 
Page::session_start();
 

	
 
$ip = $_POST['ip'];
 
$httpagent = $_POST['httpagent'];
 
$fromdom = $_POST['fromdom'];
 
$nameis = $_POST['nameis'];
 
$visitormail = $_POST['visitormail'];
 
$school = $_POST['school'];
 
$school_id = isset($_SESSION['school']) ? $_SESSION['school'] : '';
 
$feedback = $_POST['feedback'];
 
$rating = $_POST['rating'];
 
@@ -68,22 +67,16 @@ IP = $ip
 
Browser = $httpagent 
 
Deployment = $fromdom
 
";
 

	
 
    $from = "From: $visitormail\r\n";
 

	
 
    /* $feedback_emails has its default set in inc/class.page.inc, can be set in config.inc */
 
    foreach($feedback_emails as $toaddr)
 
      {
 
	mail($toaddr, $subject, $message, $from);
 
      }
 

	
 
?>
 

	
 
<p>Thanks for helping make SlatePermutate better. Your feedback is greatly appreciated.</p>
 
<p>We will attempt to respond via email if your feedback lends itself to a response.</p>
 
    echo '<p>Thanks for helping make SlatePermutate better. Your feedback is greatly appreciated.</pi>';
 
    echo '<p>We will attempt to respond via email if your feedback lends itself to a response.</p>';
 

	
 

	
 
<?php
 
  }
 

	
 
  $feedbackpage->foot();
 
    $feedbackpage->foot();
feedback.php
Show inline comments
 
@@ -9,46 +9,41 @@
 
 * 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'; 
 
	$mypage = new page('Feedback');
 
  include_once 'inc/class.page.php'; 
 
  $feedbackpage = new page('Feedback');
 
  $ipi = $_SERVER['REMOTE_ADDR'];
 
  $fromdom = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 
  $httpagenti = $_SERVER['HTTP_USER_AGENT'];
 
?>
 

	
 
	$ipi = $_SERVER['REMOTE_ADDR'];
 
	$fromdom = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
 
	$httpagenti = $_SERVER['HTTP_USER_AGENT'];
 
?>
 
<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 ?>" />
 

	
 
<h2>Feedback Form</h2>
 
<label for="nameis">Name: </label><input type="text" name="nameis" size="20" /><br />
 
<label for="visitormail">Email:&nbsp; </label><input type="text" name="visitormail" size="20" /> <span class="graytext">(if you want us to get back to you)</span><br />
 
<label for="school">School: </label><input type="text" name="school" size="20" /> <span class="graytext">(if relevant to your feedback)</span><br />
 

	
 

	
 
<br/> Overall Rating:<br/> <input checked="checked" name="rating" type="radio" value="Good" />Good <input name="rating" type="radio" value="Buggy" />Buggy  <input name="rating" type="radio" value="Needs more features" />Needs more features <input name="rating" type="radio" value="Don't know" />Don't Know
 

	
 
<br /><br />
 
<h3>General Comments</h3>
 
<p>
 
<textarea name="feedback" rows="6" cols="40"></textarea>
 
</p>
 
<input class="gray" type="submit" value="Submit Feedback" />
 
</form>
 

	
 

	
 

	
 

	
 

	
 

	
 
<?php
 
$mypage->foot();
 
$feedbackpage->foot();
inc/class.page.php
Show inline comments
 
@@ -17,44 +17,58 @@
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/**
 
 * 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('ethanzonca@gmail.com, ngelderloos7@gmail.com, ohnobinki@ohnopublishing.net');
 
$feedback_emails = array('ez@ethanzonca.com, ngelderloos7@gmail.com, ohnobinki@ohnopublishing.net');
 

	
 
$config_inc = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc';
 
if (file_exists($config_inc))
 
if (file_exists($config_inc)) {
 
  require_once($config_inc);
 
}
 

	
 
/* Class for general page generation */
 

	
 

	
 

	
 
//**************************************************
 
// 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';
 
  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 $bodyargs = '';
 

	
 

	
 
  public $lastJobTable = '';
 
  private $pageGenTime = 0;
 

	
 
  /* whether or not to output valid XHTML */
 
  /* Whether or not to output valid XHTML */
 
  private $xhtml = FALSE;
 

	
 
  // Scripts and styles
 
  /* Scripts and styles */
 
  private $headCode = array();
 

	
 
  /*
 
   * Google analytics ga.js tracking code. Expanded in __construct().
 
   */
 
  private $trackingcode = '';
 

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

	
 
  /* the current school. See get_school(). */
 
  private $school;
 
@@ -73,25 +87,25 @@ class page
 
    $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.5/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['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: */
 
   /* Compliant browsers which care, such as gecko, explicitly request xhtml: */
 
   if(!empty($_SERVER['HTTP_ACCEPT'])
 
      && strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== FALSE
 
      || !strlen($_SERVER['HTTP_ACCEPT']) /* then the browser doesn't care :-) */)
 
     {
 
       $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))
 
     {
 
@@ -136,26 +150,24 @@ class page
 
   * \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;
 
  }
 

	
 
// Public functions/vars
 

	
 
  /**
 
   * \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" ?>' . "\n";
 

	
 
    echo '<!DOCTYPE ' . $this->doctype . '>
 
@@ -165,73 +177,68 @@ class page
 
           <link rel="stylesheet" href="styles/general.css" type="text/css" media="screen" charset="utf-8" />
 
	   <link rel="stylesheet" type="text/css" media="print" href="styles/print.css" />';
 

	
 
    // Write out all passed scripts
 
    foreach ($this->scripts as $i)
 
      echo '            ' . $this->headCode["$i"] . "\n";
 

	
 
    echo '</head>
 
	  <body '.$this->bodyargs.' ><div id="page">';
 
    echo $this->top(); // Write out top
 
  }
 

	
 
  /** Write out the top of the page, including opening div tags, header title and images, etc */
 
  private function top(){
 
    echo '<div id="header">
 

	
 
	    <div id="title">
 
              <h1><a href="index.php"><img src="images/slatepermutate.png" alt="SlatePermutate" class="noborder" /></a><br /></h1>
 
              <p><span id="subtitle">'.$this->pagetitle.'</span>
 
  	      <span id="menu">Profile: '.$this->school['name'].' <a href="input.php?selectschool=1">(change)</a></span>
 

	
 
              <p>
 
                <span id="subtitle">'.$this->pagetitle.'</span>
 
  	        <span id="menu">Profile: '.$this->school['name'].' <a href="input.php?selectschool=1">(change)</a></span>
 
              </p>
 

	
 

	
 

	
 
            </div>
 

	
 
	  </div>
 
          <div id="content">';
 
  }
 

	
 

	
 

	
 
  /** Write out the foot of the page and closing divs */
 
  public function foot(){
 
    echo '</div> <!-- id="content" -->';
 
    $this->pageGenTime = round(microtime(), 3);
 
    echo '  <div id="footer">
 
  	    <div id="leftfoot" style="float:left; margin-top: 1em;">
 
		<a href="feedback.php">Submit Feedback</a>
 
            </div>
 
            <div id="rightfoot"><h5>&copy; '. 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>
 
	  </div>
 
        </div> <!-- id="footer" -->
 
      </div>';
 
  	      <div id="leftfoot" style="float:left; margin-top: 1em;">
 
	        <a href="feedback.php">Submit Feedback</a>
 
              </div>
 
              <div id="rightfoot">
 
                <h5>&copy; '. 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>
 
	      </div>
 
            </div> <!-- id="footer" -->
 
          </div>';
 
    echo $this->trackingcode;
 
    echo '</body></html>';
 
  }
 

	
 
  /** Takes a number in seconds, and outputs HH:MM:SS */
 
  public function secondsToCompound($seconds) {
 
      $ret = "";
 
      $hours = intval(intval($seconds) / 3600);
 
      $ret .= "$hours:";
 
      $minutes = bcmod((intval($seconds) / 60),60);
 
      $ret .= "$minutes:";
 
      $seconds = bcmod(intval($seconds),60);
 
      $ret .= "$seconds";
 
      return $ret;
 
  }
 

	
 
  /** Shows a box with recently processed schedules */
 
  public function showSavedScheds($session)
 
  {
 
    global $clean_urls;
 

	
 
    echo '<p>';
 
    if (isset($session['saved']) && count($session['saved']) > 0)
 
      {
 
	$process_php_s = 'process.php?s=';
 
	if ($clean_urls)
 
	  $process_php_s = '';
 

	
 
	echo '<div id="savedBox" ><h3>Saved Schedules:</h3>';
 
@@ -292,27 +299,27 @@ class page
 
   *   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')
 
    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
inc/class.section_meeting.inc
Show inline comments
 
@@ -28,27 +28,25 @@
 
 * Don't some of your classes have labs in addition to lecture? How do
 
 * you know that you have to go to both a lecture and lab -- and how
 
 * do you handle that some classes have different lecture times for
 
 * different days of the week?''. A Calvin section _is_ a unique
 
 * prof/time/location. At Cedarville, a Section refers to a prof and a
 
 * _set_ of time/location pairs. The generalization is to make each
 
 * Section support a list of meeting times/locations.
 
 */
 
class SectionMeeting
 
{
 
  private $time_start;
 
  private $time_end;
 

	
 
  private $days;
 

	
 
  private $location;
 

	
 
  /**
 
   * \brief
 
   *   Construct a SectionMeeting.
 
   *
 
   * \param $days
 
   *   A string of single-char day upon which a section meets. Monday
 
   *   is represented with 'm', Tuesday with 't', Wednesday with 'w',
 
   *   Thursday with 'h', and Friday with 'f'.
 
   * \param $time_start
 
   *   The time of day when the section meeting starts.
index.php
Show inline comments
 
@@ -8,22 +8,23 @@
 
 * 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/>.
 
 */
 
	include_once 'inc/class.page.php'; 
 
	$mypage = new page('Welcome');
 

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

	
 
<h3>Find the schedule that works for you!</h3>
 
<p>View <a href="schedulecreator.php">demo output</a> or <a href="input.php">get started on your own</a>. This program was created by <a href="http://www.calvin.edu" target="_blank">Calvin College</a> and <a href="http://cedarville.edu/" target="_blank">Cedarville University</a> students. SlatePermutate works with any college or university.</p>
 
<p class="righttext"><a href="input.php"><img class="noborder" src="images/get-started.png" alt="Get Started" /></a></p>
 

	
 
<?php
 
$mypage->foot();
 
$welcomepage->foot();
input.php
Show inline comments
 
@@ -73,45 +73,45 @@ else
 
 */
 
if ($school && (!empty($_REQUEST['school']) || $school['id'] != 'default'))
 
  $_SESSION['school_chosen'] = TRUE;
 
if (!empty($_REQUEST['selectschool'])
 
    || $school['id'] == 'default' && !isset($_SESSION['school_chosen']))
 
  {
 
    $next_page = 'input.php';
 
    if (isset($_GET['s']))
 
      $next_page .= '?s=' . (int)$_GET['s'];
 
?>
 
<h2>School Selection</h2>
 
<p>
 
  Choose the school you attend from the list below. <b>If you cannot
 
  find your school</b>, you may proceed using
 
  Choose the school you attend from the list below. <strong>If you cannot
 
  find your school</strong>, you may proceed using
 
  the <a href="<?php echo $next_page . (strpos($next_page, '?') === FALSE ? '?' : '&amp;'); ?>school=default">generic
 
  settings</a>.
 
</p>
 
<?php
 
    $inputPage->showSchools($next_page);
 
    $inputPage->foot();
 
    exit;
 
  }
 

	
 
$inputPage->showSavedScheds($_SESSION);
 
?>
 
<p>
 
  Welcome to SlatePermutate<?php $inputPage->addressStudent(', ', '',
 
  FALSE); ?>! To get started, enter in some of your
 
  class IDs, and click the autosuggestion to add available sections for each class.
 
</p>
 
<!--[if IE]>
 
<p>
 
  Note: The auto-complete function does not work in <b>Internet Explorer</b>.
 
  Note: The auto-complete function does not work in <strong>Internet Explorer</strong>.
 
</p>
 
<![endif]-->
 
<form method="post" action="process.php" id="scheduleForm">
 
<br />
 
<label>Schedule Name</label><br />
 
<input id="scheduleName" style="margin-bottom: 1em;" class="defText required" type="text" size="25" title="Spring 2011" name="postData[name]"
 
<?php if ($sch) echo 'value="' . htmlentities($sch->getName(), ENT_QUOTES) . '"'; /*"*/ ?>
 
/>
 

	
 
<table id="container">
 
  <tr><td>
 
    <table id="jsrows">
process.php
Show inline comments
 
@@ -15,25 +15,25 @@
 
 * 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/schedule_store.inc');
 
require_once('inc/class.page.php');
 
include_once 'class.schedule.php';
 
include_once 'class.class.php';
 
include_once 'class.section.php';
 

	
 
// Converts a 5-element array into a nice string.
 
// Converts a 5-element day array into a string.
 
// Supports multiple modes, prettiness, and searching for different indicators
 
function arrayToDays($array, $mode = 'num', $pretty = false, $key = 1) {
 
	$outString = '';
 
	switch($mode)
 
	  {
 
		case 'short':
 
			$days = array('Mon','Tue','Wed','Thur','Fri');
 
			break;
 
		case 'long':
 
			$days = array('Monday','Tuesday','Wednesday','Thursday','Friday');
 
			break;
 
		case 'num':
todo.php
Show inline comments
 
@@ -10,34 +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'; 
 
	$mypage = new page('TODO');
 
	$todopage = new page('TODO');
 
?>
 

	
 
<h3>Items to Consider:</h3>
 
<ul>
 
	<li>Add place to put prof name</li>
 
	<li>Autoincrement section num/letter/custom labels</li>
 
	<li>Make output and print output formatting look nicer</li>
 
	<li>Make printing work for saved jobs where jobkey != 0</li>
 

	
 
	<li>After selecting a start time, set the end time to one hour after the start time</li>
 
        <li><strong>Append</strong> sections</li>
 
        <li>Move the add class button to somewhere nicer, maybe a gray row at the bottom. Make the submit button more obvious.</li>
 
	<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" rel="external">this?</a></li>
 
</ul>
 

	
 

	
 
<?php
 
$mypage->foot();
 
$todopage->foot();
0 comments (0 inline, 0 general)