Changeset - 71a43d0bf921
[Not reviewed]
Merge default
0 6 2
ethanzonca - 15 years ago 2010-10-10 17:10:04

Merge
8 files changed with 151 insertions and 15 deletions:
0 comments (0 inline, 0 general)
.hgignore
Show inline comments
 
@@ -5,5 +5,12 @@ style: regex
 
# ignore all of cache except for the .keep file
 
^cache/[^.]
 

	
 
# ignore .htaccess because we only want .htaccess.example in the repo
 
^\.htaccess$
 

	
 
# ignore inc/config.inc because we only want inc/config.inc.example in
 
# the repo
 
^inc/config\.inc$
 

	
 
# ignore common unwanted suffixes
 
(~|\.orig|\.rej)$
.htaccess.example
Show inline comments
 
new file 100644
 
# The following would be used to enable friendly pastebin-style
 
# URLs. To enable support for these URLs in slate_permutate, set
 
# $clean_urls = TRUE in inc/config.inc.
 

	
 
RewriteEngine on
 

	
 
# If you are serving this out of your home directory, there's a good chance you'll have to uncomment and edit one of the lines below:
 

	
 
# For http://csx.calvin.edu/slate_permutate:
 
# RewriteBase /slate_permutate
 

	
 
# For http://ohnopub.net/~ohnobinki/slate_permutate:
 
# RewriteBase /~ohnobinki/slate_permutate
 

	
 
RewriteCond %{QUERY_STRING} ^(.*)?$
 
RewriteRule ^([0-9]+)$ process.php?s=$1&%1 [L]
inc/class.page.php
Show inline comments
 
<?php
 

	
 
/**
 
 * Not sure if there's a better place for this... it'd be a pita to
 
 * make a new include file like doconfig.inc but maybe that'll make
 
 * sense soon.
 
 */
 
$clean_urls = FALSE;
 
$config_inc = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc';
 
if (file_exists($config_inc))
 
  require_once($config_inc);
 

	
 
/* Class for general page generation */
 
class page
 
{
 
@@ -63,7 +73,7 @@ class page
 
   $this->trackingcode = '<script type="text/javascript" src="' . $ga_www . 'google-analytics.com/ga.js" />' . "\n"
 
     . $this->trackingcode;
 

	
 
   page::session_start();
 
   self::session_start();
 
    if($immediate
 
       && $ntitle != "NOHEAD")
 
      $this->head();
 
@@ -161,13 +171,19 @@ class page
 

	
 
  public function showSavedScheds($session)
 
  {
 
    global $clean_urls;
 

	
 
    echo '<p>';
 
    if (isset($session['saved']) && count($session['saved']) > 0)
 
      {
 
	$process_php_s = 'process.php?s=';
 
	if ($clean_urls)
 
	  $process_php_s = '';
 

	
 
	echo '<div id="savedBox" ><h3>Saved Schedules:</h3>';
 
	foreach($session['saved'] as $key => $name)
 
	  {
 
	    echo '<a href="process.php?s=' . $key . '" title="View schedule #' . $key . '">#' . $key . "</a>:\n "
 
	    echo '<a href="' . $process_php_s . $key . '" title="View schedule #' . $key . '">#' . $key . "</a>:\n "
 
	      . htmlentities($name)
 
	      . ' <a href="input.php?s=' . $key . '">edit</a>'
 
	      . ' <a href="process.php?del=' . $key . '">delete</a>'
 
@@ -285,6 +301,58 @@ class page
 

	
 
  /**
 
   * \brief
 
   *   Perform a redirect.
 
   *
 
   * By consolidating all redirects here, we're hopefully able to do
 
   * it in a somewhat compliant and portablish way ;-).
 
   *
 
   * This function does not return. It calls exit().
 
   *
 
   * \param $dest
 
   *   A URL relative to the slate_permutate root. For example,
 
   *   'input.php' or '44' (for clean urls, for example).
 
   * \param $http_code
 
   *   The redirection code to use, if any. For example, this can be
 
   *   used to implement ``permanent'' redirects if necessary.
 
   */
 
  public static function redirect($dest, $http_code = NULL)
 
  {
 
    if ($http_code)
 
      header('HTTP/1.1 ' . $http_code);
 

	
 
    $uri = '';
 

	
 
    $host = '';
 
    if (isset($_SERVER['SERVER_NAME']))
 
      $host = $_SERVER['SERVER_NAME'];
 
    if (isset($_SERvER['HTTP_HOST']))
 
      $host = $_SERVER['HTTP_HOST'];
 

	
 
    if (strlen($host))
 
      {
 
	$proto = 'http';
 
	$port = NULL;
 
	if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80)
 
	  {
 
	    if ($_SERVER['SERVER_PORT'] == 443 || !empty($_SERVER['HTTPS']))
 
	      $proto .= 's';
 
	    if ($_SERVER['SERVER_PORT'] != 433)
 
	      $port = $_SERVER['SERVER_PORT'];
 
	  }
 

	
 
	$uri = $proto . '://' . $host;
 
	if ($port !== NULL)
 
	  $uri .= ':' . $port;
 
	$uri .= dirname($_SERVER['REQUEST_URI']) . '/';
 
      }
 

	
 
    header('Location: ' . $uri . $dest);
 

	
 
    exit();
 
  }
 

	
 
  /**
 
   * \brief
 
   *   Get the current school profile handle.
 
   */
 
  public function get_school()
inc/config.inc.example
Show inline comments
 
new file 100644
 
<?php
 
/*
 
 * Copyright 2010 Nathan Phillip Brink <ohnobinki@ohnopublishing.net>
 
 *
 
 * This file is a part of slate_permutate.
 
 *
 
 * slate_permutate is free software: you can redistribute it and/or modify
 
 * it under the terms of the GNU Affero General Public License as published by
 
 * the Free Software Foundation, either version 3 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * slate_permutate is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU Affero General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with slate_permutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/**
 
 * \brief
 
 *   Use clean URLs for saved schedules. Default: FALSE.
 
 *
 
 * Before setting this to TRUE, make sure that you have read and
 
 * understood ../.htaccess.example and copied it to ../.htaccess .
 
 */
 
/* $clean_urls = FALSE; */
inc/schedule_store.inc
Show inline comments
 
@@ -101,7 +101,11 @@ function schedule_store_retrieve($schedu
 
    return NULL;
 
  $schedule_id = (int)$schedule_id;
 

	
 
  $schedule_serialized = file_get_contents($schedule_store['dir'] . DIRECTORY_SEPARATOR . $schedule_id);
 
  $schedule_file_name = $schedule_store['dir'] . DIRECTORY_SEPARATOR . $schedule_id;
 
  if (!file_exists($schedule_file_name))
 
    return NULL;
 

	
 
  $schedule_serialized = file_get_contents($schedule_file_name);
 
  if ($schedule_serialized === FALSE)
 
    return NULL;
 

	
input.php
Show inline comments
 
@@ -48,7 +48,7 @@ var sectionsOfClass = Array();
 
$school = $inputPage->get_school();
 
if ($school && (!empty($_REQUEST['school']) || $school['id'] != 'default'))
 
  $_SESSION['school_chosen'] = TRUE;
 
if ($_REQUEST['selectschool'] == 1
 
if (!empty($_REQUEST['selectschool'])
 
    || $school['id'] == 'default' && !isset($_SESSION['school_chosen']))
 
  {
 
?>
process.php
Show inline comments
 
@@ -62,13 +62,17 @@ if (isset($_GET['debug']))
 

	
 
if(!$DEBUG)
 
  {
 
    if(isset($_GET['s']))
 
    $s = FALSE;
 
    if (isset($_GET['s']))
 
      $s = $_GET['s'];
 

	
 
    if($s !== FALSE)
 
      {
 
	$savedSched = schedule_store_retrieve($schedule_store, $_GET['s']);
 
	$savedSched = schedule_store_retrieve($schedule_store, $s);
 
	if ($savedSched)
 
	  $savedSched->writeoutTables();
 
	else
 
	  Page::show_404('Unable to find a saved schedule with an ID of ' . $_GET['s'] . '.');
 
	  page::show_404('Unable to find a saved schedule with an ID of ' . $s . '.');
 
      }
 
    elseif(isset($_GET['del']))
 
      {
 
@@ -80,11 +84,21 @@ if(!$DEBUG)
 
	    unset($_SESSION['saved'][(int)$_GET['del']]);
 
	  }
 

	
 
	header('Location: input.php');
 
	page::redirect('input.php');
 
	exit;
 
      }
 
    elseif (!isset($_POST['postData']))
 
      {
 
	page::redirect('input.php');
 
	exit;
 
      }
 
    else
 
      {
 
	/*
 
	 * we probably have input from the user and should interpret
 
	 * it as a schedule to permutate. Then we should redirect the
 
	 * user to the canonical URL for that schedule.
 
	 */
 
		$allClasses = new Schedule($_POST['postData']['name']);
 
	
 
		foreach($_POST['postData'] as $class)
 
@@ -114,12 +128,11 @@ if(!$DEBUG)
 
		if ($schedule_id != NULL)
 
		  $_SESSION['saved'][$schedule_id] = $allClasses->getName();
 

	
 
		/*
 
		 * writeoutTables() needs to know $schedule_id, so it
 
		 * has to be called after we save the schedule. See
 
		 * schedule_store_store().
 
		 */
 
		$allClasses->writeoutTables();
 
		$process_php_s = '';
 
		if (!$clean_urls)
 
		  $process_php_s = 'process.php?s=';
 
		page::redirect($process_php_s . $schedule_id);
 
		exit;
 
      }
 
  }
 
else
styles/general.css
Show inline comments
 
@@ -153,7 +153,7 @@ td.center {
 
  -webkit-border-radius: 5px;
 
  border: 1px solid #999;
 
  text-align: center!important;
 
//  background: #92a689!important;
 
/*  background: #92a689!important; */
 
  background: #EEE;
 

	
 
  cursor:default;
0 comments (0 inline, 0 general)