# HG changeset patch # User normaldotcom # Date 2010-11-13 20:28:25 # Node ID 7a6777d84d07014b5ff1df44ac27fc98d2ad8a3b # Parent 1cb6f6105b45e9a1bd70fff5a463b414290694fd General styling changes diff --git a/auto.php b/auto.php --- a/auto.php +++ b/auto.php @@ -37,26 +37,32 @@ 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; @@ -71,13 +77,16 @@ if (!$school['crawled']) 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); @@ -91,7 +100,7 @@ if ($getsections) 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"; @@ -99,7 +108,7 @@ if ($getsections) } /* - * 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 ;-). @@ -126,7 +135,7 @@ if (file_exists($classes_file)) } /** - * Nothing caught.. + * Nothing caught */ clean_empty_exit(); diff --git a/class.class.php b/class.class.php --- a/class.class.php +++ b/class.class.php @@ -28,7 +28,7 @@ include_once 'class.section.php'; class Classes { - private $name; // String + private $name; // String private $sections; // Array of sections private $nsections; // int @@ -49,7 +49,7 @@ class Classes public function section_add(Section $section) { $this->sections[$this->nsections] = $section; - $this->nsections ++; + $this->nsections++; } //-------------------------------------------------- @@ -65,14 +65,6 @@ class Classes //-------------------------------------------------- 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
"; - } else { - echo "Object sections[$i] was NOT set
"; - } - $result = $this->sections[$i]; return $result; } @@ -91,10 +83,11 @@ class Classes */ 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; } @@ -126,8 +119,9 @@ class Classes 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; } diff --git a/class.schedule.php b/class.schedule.php --- a/class.schedule.php +++ b/class.schedule.php @@ -96,7 +96,7 @@ class Schedule { $temp = $this->classStorage[$counter]->getName(); - if((strcmp($temp,$course_name)) == 0) + if(strcmp($temp,$course_name) == 0) { $found = true; } else { @@ -214,7 +214,7 @@ class Schedule $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; @@ -243,7 +243,7 @@ class Schedule - if(isset($_REQUEST['print'])){ + if(isset($_REQUEST['print'])) { echo ''; echo '

« Return to normal view

'; @@ -264,43 +264,41 @@ class Schedule } else { echo ''; /* Close document.ready for jquery */ - echo '

You can share your schedule with the URL below:

'.$outputPage->gen_share_url($this->id_get()).'

'; - echo '

Print :: Share :: Home

Having problems? Let us know.

Keyboard Shortcut: Left and right arrow keys switch between schedules

'; + 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().'&print=" + (jQuery(\'#tabs\').tabs(\'option\',\'selected\') + 1); + }); + jQuery(\'#cancelItems\').click( function() { + jQuery(\'#selectItemsInput\').hide(); + });'; + echo ' }); + '; + + echo '

You can share your schedule with the URL below:

'.$outputPage->gen_share_url($this->id_get()).'

'; + echo '

Print :: Share :: Home

'; + echo '

Having problems? Let us know.

'; + echo '

Keyboard Shortcut: Left and right arrow keys switch between schedules

'; } echo "\n"; if($this->nPermutations > 0) { - echo "
\n" - - - . '
-
- - - - -
-
' - - - - . "
    \n"; + echo '
    ' . "\n" . + '
    +
    + + + + +
    +
    ' + . '
      ' . "\n"; for($nn = $first_permutation + 1; $nn <= $last_permutation; $nn++) { @@ -449,7 +447,7 @@ class Schedule } //-------------------------------------------------- - // Make the time "pretty." + // Make the time "pretty" //-------------------------------------------------- function prettyTime($t){ if($t > 1259) diff --git a/feedback-submit.php b/feedback-submit.php --- a/feedback-submit.php +++ b/feedback-submit.php @@ -17,15 +17,14 @@ * You should have received a copy of the GNU Affero General Public License * along with SlatePermutate. If not, see . */ - 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'; ?>

      Thanks!

      - - -

      Thanks for helping make SlatePermutate better. Your feedback is greatly appreciated.

      -

      We will attempt to respond via email if your feedback lends itself to a response.

      + echo '

      Thanks for helping make SlatePermutate better. Your feedback is greatly appreciated.'; + echo '

      We will attempt to respond via email if your feedback lends itself to a response.

      '; - -foot(); + $feedbackpage->foot(); diff --git a/feedback.php b/feedback.php --- a/feedback.php +++ b/feedback.php @@ -18,23 +18,23 @@ * along with SlatePermutate. If not, see . */ - 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']; -?>
      +

      Feedback Form


      (if you want us to get back to you)
      (if relevant to your feedback)
      -
      Overall Rating:
      Good Buggy Needs more features Don't Know

      @@ -45,10 +45,5 @@
      - - - - - foot(); +$feedbackpage->foot(); diff --git a/inc/class.page.php b/inc/class.page.php --- a/inc/class.page.php +++ b/inc/class.page.php @@ -26,26 +26,40 @@ /* 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(); /* @@ -82,7 +96,7 @@ class page $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 :-) */) @@ -145,8 +159,6 @@ class page $this->scripts[] = $key; } -// Public functions/vars - /** * \brief * Output the HTML header for a page, including the and @@ -174,44 +186,38 @@ class 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 '
      '; } - - + /** Write out the foot of the page and closing divs */ public function foot(){ echo '
      '; $this->pageGenTime = round(microtime(), 3); echo ' -
    '; + + +
    +
'; echo $this->trackingcode; echo ''; } + /** Takes a number in seconds, and outputs HH:MM:SS */ public function secondsToCompound($seconds) { $ret = ""; $hours = intval(intval($seconds) / 3600); @@ -223,6 +229,7 @@ class page return $ret; } + /** Shows a box with recently processed schedules */ public function showSavedScheds($session) { global $clean_urls; @@ -301,9 +308,9 @@ class page */ 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; } diff --git a/inc/class.section_meeting.inc b/inc/class.section_meeting.inc --- a/inc/class.section_meeting.inc +++ b/inc/class.section_meeting.inc @@ -37,9 +37,7 @@ class SectionMeeting { private $time_start; private $time_end; - private $days; - private $location; /** diff --git a/index.php b/index.php --- a/index.php +++ b/index.php @@ -17,8 +17,9 @@ * You should have received a copy of the GNU Affero General Public License * along with SlatePermutate. If not, see . */ - include_once 'inc/class.page.php'; - $mypage = new page('Welcome'); + + include_once 'inc/class.page.php'; + $welcomepage = new page('Welcome'); ?>

Find the schedule that works for you!

@@ -26,4 +27,4 @@

Get Started

foot(); +$welcomepage->foot(); diff --git a/input.php b/input.php --- a/input.php +++ b/input.php @@ -82,8 +82,8 @@ if (!empty($_REQUEST['selectschool']) ?>

School Selection

- Choose the school you attend from the list below. If you cannot - find your school, you may proceed using + Choose the school you attend from the list below. If you cannot + find your school, you may proceed using the generic settings.

@@ -102,7 +102,7 @@ if (!empty($_REQUEST['selectschool'])

diff --git a/process.php b/process.php --- a/process.php +++ b/process.php @@ -24,7 +24,7 @@ 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 = ''; diff --git a/todo.php b/todo.php --- a/todo.php +++ b/todo.php @@ -19,25 +19,17 @@ */ include_once 'inc/class.page.php'; - $mypage = new page('TODO'); + $todopage = new page('TODO'); ?>

Items to Consider:

    -
  • Add place to put prof name
  • Autoincrement section num/letter/custom labels
  • -
  • Make output and print output formatting look nicer
  • -
  • Make printing work for saved jobs where jobkey != 0
  • -
  • After selecting a start time, set the end time to one hour after the start time
  • Append sections
  • -
  • Move the add class button to somewhere nicer, maybe a gray row at the bottom. Make the submit button more obvious.
  • Form validation to ensure endtime is after starttime, at least one day is checked.
  • -
  • Auto-populate form based on saved schedule?
  • - -
  • Grab data from school sites such as this?
foot(); +$todopage->foot();