Changeset - 34ccb1607711
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 14 years ago 2011-04-19 22:27:34
ohnobinki@ohnopublishing.net
Store timestamp of schedule creation in Schedule object. Use hacked up jQuery.cuteTime plugin to display the relative time of schedule creation to the user.
2 files changed with 59 insertions and 15 deletions:
0 comments (0 inline, 0 general)
inc/class.page.php
Show inline comments
 
@@ -125,6 +125,7 @@ class page
 
    $this->headCode['jQueryUI'] = '<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/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['jAddress'] = '<script type="text/javascript" src="http://ohnopub.net/js/jquery.address-1.3.2.min.js"></script>';
 
    $this->headCode['jQuery.cuteTime'] = '<script type="text/javascript" src="http://ohnopub.net/~ohnobinki/CuteTime/js/jquery.cuteTime.js"></script>';
 
    $this->headCode['qTip'] = '<script type="text/javascript" src="http://ohnopub.net/js/jquery.qtip-1.0.min.js"></script>';
 
    $this->headCode['qTip2'] = '<script type="text/javascript" src="http://ohnopub.net/js/2011.03.21/jquery.qtip.min.js"></script><link rel="stylesheet" href="http://ohnopub.net/js/2011.03.21/jquery.qtip.min.css" type="text/css" media="screen" />';
 
    $this->headCode['schedInput'] = '<script type="text/javascript" src="scripts/scheduleInput.js"></script>';
 
@@ -258,14 +259,24 @@ class page
 
          '    <link rel="shortcut icon" href="images/favicon.png" />'. PHP_EOL
 
      . '    <style type="text/css">' . PHP_EOL
 
      . $this->cdata_wrap(school_page_css($this->school))
 
      . '    </style>' . 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);
 
      . '    </style>' . 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 = '&amp;school=' . $this->school['id'];
 
    /* kludge */
 
    if (!empty($_REQUEST['s']))
inc/class.schedule.php
Show inline comments
 
@@ -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 '<script type="text/javascript">';
 
      echo 'jQuery(document).ready( function() {';
 
    if(!empty($_REQUEST['print']))
 
      {
 
	echo '<script type="text/javascript">';
 
	echo 'jQuery(document).ready( function() {';
 
 
 
      /* If user entered items to print */
 
      if($_REQUEST['print'] != 'all'){
 
@@ -484,6 +492,8 @@ class Schedule
 
	        jQuery(\'#cancelItems\').click( function() {
 
		  jQuery(\'#selectItemsInput\').hide();
 
	        });'
 
	. '    ' . PHP_EOL
 
	. '    jQuery(\'.cute-time\').cuteTime();' . PHP_EOL
 
	. '  });' . PHP_EOL
 
	. '        </script>' . PHP_EOL;
 

	
 
@@ -757,7 +767,14 @@ class Schedule
 
      echo '<html><body><p>There are no possible schedules. Please <a href="input.php?s='.$this->id.'">try again</a>.</p></body></html>';
 
    }
 

	
 
    echo "<p id=\"possiblestats\">There were a total of " . $this->possiblePermutations . " possible permutations. Only " . $this->nPermutations . " permutations had no class conflicts.</p>";
 
    echo '<p id="possiblestats">' . PHP_EOL
 
      . '  There were a total of ' . $this->possiblePermutations . ' possible permutations. Only ' . $this->nPermutations . ' permutations had no class conflicts.' . PHP_EOL
 
      . '</p>' . PHP_EOL;
 
    if ($this->created)
 
      echo ''
 
	. '<p id="created-time">' . PHP_EOL
 
	. '  Created <span class="cute-time">' . date('c', $this->created) . '</span>.' . PHP_EOL
 
	. '</p>' . 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;
 
  }
 
}
0 comments (0 inline, 0 general)