Changeset - 26d68cb46254
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 15 years ago 2010-10-28 20:02:15
ohnobinki@ohnopublishing.net
Pager support, needs some nicer CSS and configurability.
2 files changed with 82 insertions and 6 deletions:
0 comments (0 inline, 0 general)
class.schedule.php
Show inline comments
 
@@ -175,48 +175,60 @@ class Schedule
 
		if($position == $this->nclasses)
 
		  {
 
		    $valid = true;
 
		  } else {
 
		  $cs[$position]++;
 
		}
 
	      } else {
 
	      $valid = true;
 
	      $position = 0;
 
	    }
 
	  }
 
            
 
	$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);
 

	
 
    $npages = ceil($this->nPermutations / SP_PERMUTATIONS_PER_PAGE);
 
    $page = 0;
 
    if (isset($_REQUEST['page']))
 
      $page = $_REQUEST['page'];
 
    if ($page >= $npages)
 
      Page::show_404('Unable to find page ' . $page . ', there are only ' . $this->nPermutations . ' non-conflicting permutations, for a total of ' . $npages . ' pages.');
 
    /* zero-based */
 
    $first_permutation = $page * SP_PERMUTATIONS_PER_PAGE;
 
    $last_permutation = min($this->nPermutations, $first_permutation + SP_PERMUTATIONS_PER_PAGE);
 

	
 
    $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'])){
 
 
 
     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();';
 
	}
 
@@ -244,61 +256,72 @@ class Schedule
 
';
 
      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 "\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><ul>\n";
 
	  . "<div id=\"the-tabs\"><ul>\n";
 
			
 
	for($nn = 1; $nn <= $this->nPermutations; $nn++)
 
	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"
 
	  . "  <div class=\"scroller\">\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";
 

	
 
	/* Next button */
 
	if ($page + 1 < $npages)
 
	  echo '      <div id="pager-next" class="pager right"><a href="' . $this->url($this->id, $page + 1) . '">Next &raquo;</a></div>' . "\n";
 
	echo "    </div> <!-- id=\"pagers\" -->\n";
 

	
 

	
 
	echo "  <div class=\"scroller\">\n"
 
	  . "    <div class=\"scontent\">\n";
 
		
 
	for($i = 0; $i < $this->nPermutations; $i++)
 
	for($i = $first_permutation; $i < $last_permutation; $i++)
 
	  {
 
	     echo  '      <div class="section" id="tabs-' . ($i+1) . "\">\n";
 
  
 
	    // Beginning of table
 
	    echo "        <table style=\"empty-cells:show;\" border=\"1\" cellspacing=\"0\">\n";
 
				
 
	    // Header row
 
	    echo "          <tr>\n"
 
	      . '            <td class="none permuteNum">' . ($i + 1) . "</td>\n"
 
	      . "            <td class=\"day\">Monday</td>\n"
 
	      . "            <td class=\"day\">Tuesday</td>\n"
 
	      . "            <td class=\"day\">Wednesday</td>\n"
 
	      . "            <td class=\"day\">Thursday</td>\n"
 
	      . "            <td class=\"day\">Friday</td>\n"
 
	      . "          </tr>\n";
 

	
 
	    $last_meeting = array();
 
	    $rowspan = array(0, 0, 0, 0, 0);
 
	    for($r = 0; $r < (count($time)-1); $r++)
 
	      {
 

	
 
		echo "          <tr>\n"
 
		  . "            <td class=\"time\">" . $this->prettyTime($time[$r]) . "</td>\n";
 

	
 
@@ -431,25 +454,58 @@ class Schedule
 
  function class_get($class_key)
 
  {
 
    return $this->classStorage[$class_key];
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Set my global ID.
 
   *
 
   * Only to be called by schedule_store_store().
 
   */
 
  function id_set($id)
 
  { 
 
    $this->id = $id;
 
  }
 

	
 
  /*
 
   * \brief
 
   *   Get my global ID.
 
   */
 
  function id_get()
 
  {
 
    return $this->id;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Write out a relative URL for a particular schedule.
 
   *
 
   * Takes into account the $clean_urls setting.
 
   *
 
   * \param $id
 
   *   The ID of the schedule to link to. Defaults to the current schedule object.
 
   * \param $page
 
   *   The page of the schedule to link to. Defaults to 0.
 
   */
 
  function url($id = NULL, $page = 0)
 
  {
 
    global $clean_urls;
 

	
 
    $url = '';
 
    if (!$clean_urls)
 
      $url .= 'process.php?s=';
 

	
 
    if (!$id)
 
      $id = $this->id;
 
    $url .= (int)$id;
 
    if ($clean_urls)
 
      $url .= '?';
 
    else
 
      $url .= '&';
 

	
 
    if ($page)
 
      $url .= 'page=' . (int)$page . '&amp;';
 

	
 
    return $url;
 
  }
 
}
styles/output.css
Show inline comments
 
@@ -131,24 +131,44 @@ margin-bottom: 2px;
 
        color: rgba(200,200,200,1);
 
}
 
#tabs {
 
  min-width: 400px;
 
  max-width: 650px;
 
  margin: auto;
 
}
 
#tabs li /* , .ui-corner-all, .ui-corner-top */ { background: none!important; }
 
#tabs li { border: none!important; }
 

	
 
.show-buttons {
 

	
 
  width: 99%;
 
  margin: auto;
 
  padding: 2px;
 
  background: #EEE;
 
  border: 1px solid #AAA;
 
  border-radius: 3px;
 
  -moz-border-radus: 3px;
 

	
 
}
 
.show-buttons label {
 
  padding-right: .5em;
 
}
 

	
 
.pager
 
{
 
  display: inline-block;
 

	
 
  clear: none;
 
}
 
.pager a
 
{
 
  text-decoration: none;
 
}
 

	
 
#pager-previous
 
{
 
  float: left;
 
}
 
#pager-next
 
{
 
  float: right;
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)