diff --git a/inc/class.page.php b/inc/class.page.php --- a/inc/class.page.php +++ b/inc/class.page.php @@ -125,6 +125,7 @@ class page $this->headCode['jQueryUI'] = ''; $this->headCode['jValidate'] = ''; $this->headCode['jAddress'] = ''; + $this->headCode['jQuery.cuteTime'] = ''; $this->headCode['qTip'] = ''; $this->headCode['qTip2'] = ''; $this->headCode['schedInput'] = ''; @@ -258,14 +259,24 @@ class page ' '. PHP_EOL . ' ' . PHP_EOL - . $this->script_wrap('' - . 'var slate_permutate_school = ' . json_encode($this->school['id']) . ';' . PHP_EOL - . 'var slate_permutate_semester = ' . json_encode($this->semester['id']) . ';' . PHP_EOL); + . ' ' . PHP_EOL; // Write out all passed scripts foreach ($this->scripts as $i) echo ' ' . $this->headCode["$i"] . "\n"; + /* + * Perhaps we should have a separate array for javascript library + * initialization snippets. + */ + $javascript_init = ''; + if (in_array('jQuery.cuteTime', $this->scripts)) + $javascript_init .= 'jQuery.extend(jQuery.fn.cuteTime.settings, {refresh: 10000, use_html_attribute: false});' . PHP_EOL; + + echo $this->script_wrap('' + . 'var slate_permutate_school = ' . json_encode($this->school['id']) . ';' . PHP_EOL + . 'var slate_permutate_semester = ' . json_encode($this->semester['id']) . ';' . PHP_EOL + . $javascript_init); + $selectschool_query = '&school=' . $this->school['id']; /* kludge */ if (!empty($_REQUEST['s'])) diff --git a/inc/class.schedule.php b/inc/class.schedule.php --- a/inc/class.schedule.php +++ b/inc/class.schedule.php @@ -104,6 +104,12 @@ class Schedule /** * \brief + * When I was created, a unix timestamp. + */ + private $created; + + /** + * \brief * Create a schedule with the given name. * * \param $name @@ -142,6 +148,8 @@ class Schedule } $this->semester = $semester; + $this->created = time(); + /* mark this as an upgraded Schedule class. See __wakeup() */ $this->nclasses = -1; } @@ -431,22 +439,22 @@ class Schedule $footcloser = ''; - if(isset($_REQUEST['print']) && $_REQUEST['print'] != ''){ - $headcode = array('jQuery', 'jQueryUI', 'uiTabsKeyboard', 'outputStyle', 'outputPrintStyle', 'displayTables'); - } - else { - $headcode = array('outputStyle', 'jQuery', 'jQueryUI', 'jAddress', 'uiTabsKeyboard', 'qTip2','displayTables'); - } + $headcode = array('jQuery', 'jQueryUI', 'uiTabsKeyboard', 'displayTables', 'outputStyle', 'jQuery.cuteTime'); + if(!empty($_REQUEST['print'])) + array_push($headcode, 'outputPrintStyle'); + else + array_push($headcode, 'jAddress', 'qTip2'); + $outputPage = page::page_create(htmlentities($this->getName()), $headcode, array('school' => $this->school_get(), 'semester' => $this->semester_get())); $outputPage->head(); - if(isset($_REQUEST['print'])) { - - echo '' . PHP_EOL; @@ -757,7 +767,14 @@ class Schedule echo '

There are no possible schedules. Please try again.

'; } - echo "

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

"; + echo '

' . PHP_EOL + . ' There were a total of ' . $this->possiblePermutations . ' possible permutations. Only ' . $this->nPermutations . ' permutations had no class conflicts.' . PHP_EOL + . '

' . PHP_EOL; + if ($this->created) + echo '' + . '

' . PHP_EOL + . ' Created ' . date('c', $this->created) . '.' . PHP_EOL + . '

' . PHP_EOL; $outputPage->foot(); } @@ -902,6 +919,19 @@ class Schedule /** * \brief + * Get the unix timestamp of when this schedule was created + * (saved). + * + * \return + * A unix timestamp. 0 if the timestamp is unavailable. + */ + public function created_get() + { + return $this->created; + } + + /** + * \brief * A magic function which tries to upgrade old serialized sections * to the new format. */ @@ -945,5 +975,8 @@ class Schedule foreach ($this->courses as $course_i => $course) $this->course_slot_mappings[$course_i] = count($this->course_slot_mappings); } + + if (empty($this->created)) + $this->created = 0; } }