Files
@ 9924f8d92ad6
Branch filter:
Location: SlatePermutate/process.php - annotation
9924f8d92ad6
2.9 KiB
text/x-php
attempted to add schedule name input but was unsuccessful
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 27edaecc0d90 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 8a7d392478a6 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 27edaecc0d90 8a7d392478a6 | <?php
session_start();
include_once 'errors.php';
include_once 'class.schedule.php';
include_once 'class.class.php';
include_once 'class.section.php';
function sortInputs($post){
// return array_filter($post['postData']); // Remove any null or unset items. Disabled as it kills day stuff, @FIXME and add day unset setting here (==0).
return $post['postData'];
}
// Converts a 5-element array into a nice string.
// Supports multiple modes, prettiness, and searching for different indicators
function arrayToDays($array, $mode = 'num', $pretty = false, $key = 1) {
$outString = '';
switch($mode){
case 'short':
$days = array('Mon','Tue','Wed','Thur','Fri');
break;
case 'long':
$days = array('Monday','Tuesday','Wednesday','Thursday','Friday');
break;
case 'num':
$days = array('1','2','3','4','5');
break;
default:
$outString = 'Invalid mode passed to arrayToDays()!';
return $outString;
}
if(count($array) > 1){
for($i=0; $i<=4; $i++) {
if(isset($array[$i]) && $array[$i] == $key){
$outString .= $days[$i];
if($pretty)
$outString .= ', ';
}
}
if($pretty){
$outString = substr($outString,0,strlen($outString) - 2); // Remove last comma and space
$outString = substr($outString,0, strrpos( $outString, ' ')) . ' and' . substr($outString, strrpos( $outString, ' '), strlen($outString));
}
}
else {
for($i=0; $i<=4; $i++)
if(isset($array[$i]))
$outString = $days[$i];
}
return $outString;
}
function prettyTime($time){
return substr($time,0,strlen($time)-2) . ":" . substr($time,strlen($time)-2, strlen($time));
}
$DEBUG = false;
if(isset($_GET['debug']))
$DEBUG = $_GET['debug'];
if(!$DEBUG){
if(isset($_GET['savedkey'])){
$savedSched = unserialize($_SESSION['saved'][$_GET['savedkey']]);
$savedSched->findPossibilities();
$savedSched->writeoutTables();
}
else{
$allClasses = new Schedule("Fall 2010");
foreach(sortInputs($_POST) as $class)
{
$allClasses->addClass($class['name']);
foreach($class as $section)
if(is_array($section)) // Skip the name, which isn't a section
{
$allClasses->addSection($class['name'], $section['letter'], $section['start'], $section['end'], arrayToDays($section['days']));
}
}
$allClasses->findPossibilities();
$allClasses->writeoutTables();
if(!isset($_SESSION['saved']))
$_SESSION['saved'] = array();
array_push ( $_SESSION['saved'], serialize($allClasses));
}
} else {
echo '<pre>DEBUG OUTPUT: <br /><br />';
foreach(sortInputs($_POST) 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>';
}
?>
|