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
 
@@ -501,25 +501,25 @@ class Schedule
 
	. '          <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)
 
      {
 
	/*
 
@@ -603,29 +603,29 @@ class Schedule
 
	     . '<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
 
@@ -868,56 +868,71 @@ class Schedule
 
  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).
process.php
Show inline comments
 
@@ -251,25 +251,25 @@ if(!$DEBUG)
 

	
 
		    $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 ';
0 comments (0 inline, 0 general)