Changeset - 63da13bd33d5
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 14 years ago 2011-10-18 20:02:54
ohnobinki@ohnopublishing.net
Fix PHP strict warnings due to using Schedule::url() as both static and object method.

Introduce Schedule::my_url() as an object method and convert Schedule::url() into a static method.
2 files changed with 27 insertions and 12 deletions:
0 comments (0 inline, 0 general)
inc/class.schedule.php
Show inline comments
 
@@ -489,49 +489,49 @@ class Schedule
 
      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();
 
	        });'
 
	. '    ' . PHP_EOL
 
	. '    jQuery(\'.cute-time\').cuteTime();' . PHP_EOL
 
	. '  });' . PHP_EOL
 
	. '        </script>' . PHP_EOL;
 

	
 
      echo '        <div id="sharedialog" title="Share Schedule">' . PHP_EOL
 
	. '          <p class="indent"><img alt="[fb]" class="noborder" src="http://facebook.com/favicon.ico" /> <a href="http://www.facebook.com/sharer.php?u=' . urlencode(htmlentities($outputPage->gen_share_url($this->id_get()))) .'&amp;t=My%20Schedule">Share on Facebook</a></p>
 
		     <p class="indent"><img alt="[sp]" class="noborder" src="images/favicon.png" style="margin-right: 5px;"/><span class="clicktoclipboard"><a href="#">Share with URL</a><span class="toclipboard hidden"><p>Copy the share URL below:<br /><em class="centeredtext smallurl">' . htmlentities($outputPage->gen_share_url($this->id_get())) . '</em></p></span></span></p>' . PHP_EOL
 
	. '        </div>' . PHP_EOL
 
	. '        <p>' . PHP_EOL
 
	. '          <a href="input.php?s='.$this->id.'" class="button">Edit</a>' . PHP_EOL
 
	. '          <span id="printItems"><a href="#" class="button">Print</a></span>' . PHP_EOL
 
	. '          <span id="share"><a href="#" class="button">Share</a></span>' . PHP_EOL;
 

	
 

	
 
      if ($schedule_store !== NULL
 
	  && $this->parent_get() !== NULL
 
	  && ($parent_schedule = schedule_store_retrieve($schedule_store, $this->parent_get())) !== NULL)
 
	echo '          <a class="button" href="' . htmlentities($parent_schedule->url()) . '" title="Parent schedule: ' . htmlentities($parent_schedule->getName()) . '">Parent</a>' . PHP_EOL;
 
	echo '          <a class="button" href="' . htmlentities($parent_schedule->my_url()) . '" title="Parent schedule: ' . htmlentities($parent_schedule->getName()) . '">Parent</a>' . PHP_EOL;
 

	
 
      echo '          <a class="button" href="input.php">Home</a>' . PHP_EOL
 
	. '        </p>'. PHP_EOL
 
	. '        <p class="centeredtext">Having problems? <a href="feedback.php">Let us know</a>.</p>' . PHP_EOL
 
	. '        <p class="centeredtext graytext"><em>Keyboard Shortcut: Left and right arrow keys switch between schedules</em></p>' . PHP_EOL;
 
    }		
 

	
 
    echo "\n";
 

	
 
    if($this->nPermutations > 0)
 
      {
 
	/*
 
	 * Figure out if we have to deal with Saturday and then deal
 
	 * with it.
 
	 *
 
	 * Also, ensure that our $time array is big enough for all of
 
	 * these courses.
 
	 */
 
	$max_day_plusone = 5;
 
	$have_saturday = FALSE;
 

	
 
	$max_time = (int)max($time);
 
	$min_time = (int)min($time);
 
	$sort_time = FALSE;
 
@@ -591,53 +591,53 @@ class Schedule
 
	  . '    </div>' . PHP_EOL;
 
	echo '<div id="tabs">' . "\n" .
 
               '<div id="show-box" class="show-buttons">
 
                  <form action="#"><p class="nospace">
 
                    <label><strong>Display:</strong></label>
 
                    <input id="show-course-title" name="show-course-title" type="checkbox" /><label for="show-course-title">Course Title</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>
 
                    <span id="regCodes"><label><a href="#"><strong>Register for Classes</strong></a></label></span></p>
 
                  </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="' . htmlentities($this->url($this->id, $page - 1)) . '">&laquo; Previous</a></div>' . "\n";
 
	  echo '      <div id="pager-previous" class="pager left"><a href="' . htmlentities($this->my_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="' . htmlentities($this->url($this->id, $page + 1)) . '">Next &raquo;</a></div>' . "\n";
 
	  echo '      <div id="pager-next" class="pager right"><a href="' . htmlentities($this->my_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 = $first_permutation; $i < $last_permutation; $i++)
 
	  {
 
	    /*
 
	     * Store a JSON list of courses, each with only the one
 
	     * section rendered in this permutation. This is used for
 
	     * the ``Registration Numbers'' dialog which noramlly
 
	     * shows users course synonyms.
 
	     */
 
	    $permutation_courses = array();
 

	
 
	     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"
 
@@ -856,80 +856,95 @@ class Schedule
 
   *
 
   * 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.
 
   *   The ID of the schedule to link to.
 
   * \param $page
 
   *   The page of the schedule to link to. Defaults to 0.
 
   *   The page/tab of the schedule to link to. Defaults to 0.
 
   * \return
 
   *   A string, the URL used to access this schedule. Remember that
 
   *   if this string is inserted into an XHTML document,
 
   *   htmlentities() must be called on it.
 
   *   A string, the URL used to access the specified
 
   *   schedule. Remember that if this string is inserted into an
 
   *   XHTML document, htmlentities() must be called on it.
 
   */
 
  function url($id = NULL, $page = 0)
 
  public static function url($id, $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 . '&';
 

	
 
    return $url;
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Return the URL used to access this schedule.
 
   *
 
   * Convenience wrapper around Schedule::url().
 
   *
 
   * \param $page
 
   *   Which page (tab) of the schedule to link to.
 
   * \return
 
   *   A raw URL (one that must be htmlentities()ized before putting
 
   *   into HTML).
 
   */
 
  public function my_url($page = 0)
 
  {
 
    return Schedule::url($this->id, $page);
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Get the ID of the schedule from which this schedule was
 
   *   derived.
 
   */
 
  public function parent_get()
 
  {
 
    return $this->parent_id;
 
  }
 

	
 
  /**
 
   * \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
process.php
Show inline comments
 
@@ -239,45 +239,45 @@ if(!$DEBUG)
 
		      . '          <li>Most importantly, click the <em>Fix</em> button below to return to the schedule editing page to resolve these errors. Hitting your browser\'s <em>Back</em> button will cause your input to be lost.</li>' . PHP_EOL
 
		      . '          <li>Ensure that no section\'s start or end times are left blank. Any blank start or end times are shown as <tt>none</tt> in the above error output.</li>' . PHP_EOL
 
		      . '          <li>Ensure that a section\'s end time is later in the day than its start time.</li>' . PHP_EOL
 
		      . '          <li>If you are having trouble resolving these issues, please feel free to <a href="feedback.php">leave us feedback</a>. Be sure to describe your problem with as much detail as possible; otherwise we may only be able to make conjectures about the errors instead of finding and fixing any bugs. Thanks! <em>(To provide us with the most reliable data, save this webpage onto disk and paste the entire (X)HTML source into the feedback form.)</em></li>' . PHP_EOL
 
		      . '        </ul>' . PHP_EOL;
 

	
 
		    /* Regurgitate the postData into a <form /> */
 
		    echo '        <form action="input.php" method="post">' . PHP_EOL
 
		      . '          <input name="e" value="1" type="hidden" />' . PHP_EOL;
 
		    array_to_form($postData, 'postData', '          ');
 
		    echo '          <button type="submit" class="gray">Fix Errors!</button>' . PHP_EOL
 
		      . '        </form>' . PHP_EOL;
 

	
 
		    $error_page->foot();
 
		    exit;
 
		  }
 

	
 
		$allClasses->findPossibilities();
 
		if (!isset($_SESSION['saved']))
 
		  $_SESSION['saved'] = array();
 
		$schedule_id = schedule_store_store($schedule_store, $allClasses);
 
		if ($schedule_id != NULL)
 
		  $_SESSION['saved'][$schedule_id] = $allClasses->getName();
 

	
 
		page::redirect($allClasses->url());
 
		page::redirect($allClasses->my_url());
 
		exit;
 
      }
 
  }
 
else
 
  {
 
	echo '<pre>DEBUG OUTPUT: <br /><br />';
 
	foreach($_POST['postData'] as $class) {
 
		echo 'Class: ' . $class['name'] . '<br />';
 
		foreach($class as $section)
 
			if(is_array($section))
 
			{
 
				echo '---- Section that starts at ' . prettyTime($section['start']) . ' and ends at ' . prettyTime($section['end']) . '. This class meets on ';
 
				echo arrayToDays($section['days'],'long',true) . '.<br />';
 
			}
 
		echo '<br />';
 
	}
 
	echo '</pre>';
 

	
 

	
 
}
0 comments (0 inline, 0 general)