initial commit

This commit is contained in:
2017-10-10 14:30:28 +01:00
commit e1f112083d
49 changed files with 2710 additions and 0 deletions

2
.htaccess Normal file
View File

@@ -0,0 +1,2 @@
RewriteEngine on
RewriteRule ^style.css$ style.php [nc]

141
cache.php Normal file
View File

@@ -0,0 +1,141 @@
<?php
require_once 'config.php';
require_once 'rooster.php';
class Cache {
var $oRooster;
function Cache($oRooster) {
$this->oRooster = $oRooster;
}
function getWeek(&$iYear, &$iWeek) {
if (!isset($iYear)) {
$iYear = $this->oRooster->iYear;
}
if (!isset($iWeek)) {
$iWeek = $this->oRooster->iWeek;
}
}
function getCached($aFiles) {
global $aConfig;
$sContents = null;
if (count($aFiles) > 0) {
krsort($aFiles);
$iTime = key($aFiles);
$sFile = current($aFiles);
if (time() / 3600 - $iTime <= $aConfig['cache']) {
$sContents = file_get_contents($sFile);
array_shift($aFiles);
}
foreach ($aFiles as $sFile) {
unlink($sFile);
}
}
return $sContents;
}
function getContents($sDirectory, $sExtension, $sGroup, $iYear = null, $iWeek = null) {
$this->getWeek($iYear, $iWeek);
$sGlob = sprintf('%s/%s-%d-%02d-*.%s', $sDirectory, md5($sGroup), $iYear, $iWeek, $sExtension);
$sRegex = sprintf('~%s/[\da-f]+-[0-9]+-[0-9]+-([0-9]+).%s$~', $sDirectory, $sExtension);
$aFiles = array();
if (($aGlob = glob($sGlob)) === false) {
return null;
}
foreach ($aGlob as $sFile) {
if (preg_match($sRegex, $sFile, $aMatch)) {
$aFiles[$aMatch[1]] = $sFile;
}
}
return $this->getCached($aFiles);
}
function getGroups($aFilters) {
$aGroups = $aTodo = array();
foreach ($aFilters as $sFilter) {
$sGlob = sprintf('group/%s-*.base64', md5($sFilter));
$aFiles = array();
$sContents = null;
if (($aGlob = glob($sGlob)) !== false) {
foreach ($aGlob as $sFile) {
if (preg_match('~group/[\da-f]+-([0-9]+).base64$~', $sFile, $aMatch)) {
$aFiles[$aMatch[1]] = $sFile;
}
}
$sContents = $this->getCached($aFiles);
}
if (isset($sContents)) {
$aFilterGroups = unserialize(base64_decode($sContents));
} else {
$aFilterGroups = $this->oRooster->getGroups(array($sFilter));
$sFile = sprintf('group/%s-%d.base64', md5($sFilter), time() / 3600);
file_put_contents($sFile, base64_encode(serialize($aFilterGroups)));
}
$aGroups = array_merge($aGroups, $aFilterGroups);
}
return $aGroups;
}
function getRooster($sGroup, $iYear = null, $iWeek = null) {
$this->getWeek($iYear, $iWeek);
$sRooster = $this->getContents('rooster', 'html', $sGroup, $iYear, $iWeek);
if (!isset($sRooster)) {
$this->oRooster->setWeek($iYear, $iWeek);
$sRooster = $this->oRooster->getPage($sGroup);
$sFile = sprintf('rooster/%s-%d-%02d-%d.html', md5($sGroup), $iYear, $iWeek, time() / 3600);
file_put_contents($sFile, $sRooster);
}
return $sRooster;
}
function getData($sGroup, $iYear = null, $iWeek = null) {
$this->getWeek($iYear, $iWeek);
$sData = $this->getContents('data', 'base64', $sGroup, $iYear, $iWeek);
if (isset($sData)) {
return unserialize(base64_decode($sData));
} else {
$sRooster = $this->getContents('rooster', 'html', $sGroup, $iYear, $iWeek);
if (isset($sRooster)) {
$aData = $this->oRooster->getData($sRooster);
} else {
$this->oRooster->setWeek($iYear, $iWeek);
$sRooster = $this->oRooster->getPage($sGroup);
$sFile = sprintf('rooster/%s-%d-%02d-%d.html', md5($sGroup), $iYear, $iWeek, time() / 3600);
file_put_contents($sFile, $sRooster);
$aData = $this->oRooster->getData();
}
$sFile = sprintf('data/%s-%d-%02d-%d.base64', md5($sGroup), $iYear, $iWeek, time() / 3600);
file_put_contents($sFile, base64_encode(serialize($aData)));
return $aData;
}
}
function clean($bAll = false) {
global $aConfig;
$aGroupGlob = glob('group/*-*.base64');
$aRoosterGlob = glob('rooster/*-*-*-*.html');
$aDataGlob = glob('data/*-*-*-*.base64');
$aFiles = array_merge(
$aGroupGlob === false ? array() : $aGroupGlob,
$aRoosterGlob === false ? array() : $aRoosterGlob,
$aDataGlob === false ? array() : $aDataGlob);
foreach ($aFiles as $sFile) {
$bDelete = true;
if (!$bAll) {
$aFile = explode('.', $sFile);
if (count($aFile) == 2) {
$aFile = explode('-', current($aFile));
$iTime = array_pop($aFile);
if (time() / 3600 - $iTime <= $aConfig['cache']) {
$bDelete = false;
}
}
}
if ($bDelete) {
unlink($sFile);
}
}
}
}

88
config.php Normal file
View File

@@ -0,0 +1,88 @@
<?php
set_time_limit(0);
$aConfig = array(
'cache' => 6,
'start' => array('hour' => 8, 'minute' => 45),
'end' => array('hour' => 17, 'minute' => 45),
'steps' => 4,
'weeks' => 10,
'year' => 2011,
'week' => 36
);
$aConfig['step'] = 60 / $aConfig['steps'];
$aConfig['filters'] = array(
'S' => '([\d]S) \(FEW\)',
'1S' => '(1S) \(FEW\)',
'2S' => '(2S) \(FEW\)',
'3S' => '(3S) \(FEW\)',
'F' => '([\d]F) \(FEW\)',
'1F' => '(1F) \(FEW\)',
'2F' => '(2F) \(FEW\)',
'3F' => '(3F) \(FEW\)',
'mCh' => '(mCh-[a-z]+) \(FEW\)',
'mCh-AS' => '(mCh-AS) \(FEW\)',
'mCh-MDSC' => '(mCh-MDSC) \(FEW\)',
'mCh-MSP' => '(mCh-MSP) \(FEW\)',
'mDDS' => '(mDDS-[a-z]+) \(FEW\)',
'mDDS-BCCA' => '(mDDS-BCCA) \(FEW\)',
'mDDS-BDA' => '(mDDS-BDA) \(FEW\)',
'mDDS-CMCT' => '(mDDS-CMCT) \(FEW\)',
'mDDS-DDS' => '(mDDS-DDS) \(FEW\)',
'mDDS-DDSA' => '(mDDS-DDSA) \(FEW\)',
'mDDS-DDTF' => '(mDDS-DDTF) \(FEW\)');
$aConfig['colors'] = array(
'wc' => array('Werkcollege', '#8064a2'), /* purple */
'te' => array('Tentamen', '#c0504d'), /* red */
'ht' => array('Hertentamen', '#f79646'), /* orange */
'hc' => array('Hoorcollege', '#4f81bd'), /* blue */
'pr' => array('Practicum', '#9bbb59'), /* green */
'bij' => array('Bijeenkomst', '#4bacc6'), /* aqua */
);
$aConfig['types'] = array(
'wc' => array(),
'te' => array('tent'),
'ht' => array(),
'hc' => array('h', 'h/w'),
'pr' => array('prac'),
'bij' => array('pres', 'tutor'),
);
$aConfig['uva'] = array(
'1S' => 'BSc SK_1',
'2S' => 'BSc SK_2',
'3S' => 'BSc SK_3',
'mCh-AS' => 'MSc CH-AS',
'mCh-MDSC' => 'MSc CH-MDSC'
);
$aConfig['groups'] = array(
'S' => array('Bachelor Scheikunde', array(
'1S' => '1e jaar',
'2S' => '2e jaar',
'3S' => '3e jaar')),
'F' => array('Bachelor Farmaceutische wetenschappen', array(
'1F' => '1e jaar',
'2F' => '2e jaar',
'3F' => '3e jaar')),
'mCh' => array('Master Chemistry', array(
'mCh-AS' => 'Analytical Sciences',
'mCh-MDSC' => 'Molecular Design, Synthesis and Catalysis',
'mCh-MSP' => 'Molecular Simulation & Photonics')),
'mDDS' => array('Drug Discovery & Safety', array(
'mDDS-BCCA' => 'Biomarkers and Clinical Chemical Analysis',
'mDDS-BDA' => 'Biomolecular Drug Analysis',
'mDDS-CMCT' => 'Computational Medicinal Chemistry & Toxicology',
'mDDS-DDS' => 'Drug Design & Synthesis',
'mDDS-DDSA' => 'Drug Disposition & Safety Assessment',
'mDDS-DDTF' => 'Drug Discovery & Target Finding')));
$aDirectories = array('group', 'rooster', 'data');
foreach ($aDirectories as $sDirectory) {
if (!file_exists($sDirectory)) {
mkdir($sDirectory);
}
}

84
css/default.css Normal file
View File

@@ -0,0 +1,84 @@
* {
font-family: "Trebuchet MS";
}
body {
background: #cccccc;
text-align: center;
}
table {
border: 3px solid #e5eff8;
margin: 0 auto 20px auto;
border-collapse: collapse;
background: #f4f9fe;
}
table caption {
font-style: italic;
}
thead th.week {
padding-left: 5px;
font-size: 1.2em;
text-align: left;
color: #555555;
}
thead th.corner {
background: #e5eff8;
}
thead th.bar {
background: #e5eff8;
font-size: 0.6em;
}
thead th.bar a {
font-weight: bold;
color: #66a3d3;
text-decoration: none;
}
tbody th {
color: #678197;
border: 1px solid #e5eff8;
padding: 0 0.2em;
text-align: center;
}
tbody th.hour {
vertical-align: text-top;
font-weight: bold;
font-size: 1.2em;
}
tbody th.minute {
padding: 0 10px;
font-size: 0.5em;
}
table tbody td {
border-left: 1px solid #cccccc;
font-size: 0;
}
tbody td.border {
border-right: 2px solid #999999;
}
thead th, table tbody td.strong {
font-size: inherit;
background: #f4f9fe;
text-align: center;
font-weight: bold;
color: #66a3d3;
}
a {
color: inherit;
}
small {
font-size: 0.7em;
}
fieldset {
width: 60%;
margin: 0 auto 0 auto;
}
div.ui-slider {
margin: 0 auto 50px auto;
}
a.multiSelect {
margin-top: 50px;
}
div.multiSelectOptions {
text-align: left;
}

View File

@@ -0,0 +1,23 @@
.ui-multiselect { padding:2px 0 2px 4px; text-align:left }
.ui-multiselect span.ui-icon { float:right }
.ui-multiselect-single .ui-multiselect-checkboxes input { position:absolute !important; top: auto !important; left:-9999px; }
.ui-multiselect-single .ui-multiselect-checkboxes label { padding:5px !important }
.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 4px }
.ui-multiselect-header ul { font-size:0.9em }
.ui-multiselect-header ul li { float:left; padding:0 10px 0 0 }
.ui-multiselect-header a { text-decoration:none }
.ui-multiselect-header a:hover { text-decoration:underline }
.ui-multiselect-header span.ui-icon { float:left }
.ui-multiselect-header li.ui-multiselect-close { float:right; text-align:right; padding-right:0 }
.ui-multiselect-menu { display:none; padding:3px; position:absolute; z-index:10000; text-align: left }
.ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; overflow-y:scroll }
.ui-multiselect-checkboxes label { cursor:default; display:block; border:1px solid transparent; padding:3px 1px }
.ui-multiselect-checkboxes label input { position:relative; top:1px }
.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; padding-right:3px }
.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label { text-align:center; font-weight:bold; border-bottom:1px solid }
.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label a { display:block; padding:3px; margin:1px 0; text-decoration:none }
/* remove label borders in IE6 because IE6 does not support transparency */
* html .ui-multiselect-checkboxes label { border:none }

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

404
css/redmond/jquery-ui-1.7.1.custom.css vendored Normal file
View File

@@ -0,0 +1,404 @@
/*
* jQuery UI CSS Framework
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
*/
/* Layout helpers
----------------------------------*/
.ui-helper-hidden { display: none; }
.ui-helper-hidden-accessible { position: absolute; left: -99999999px; }
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ui-helper-clearfix { display: inline-block; }
/* required comment for clearfix to work in Opera \*/
* html .ui-helper-clearfix { height:1%; }
.ui-helper-clearfix { display:block; }
/* end clearfix */
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
/* Interaction Cues
----------------------------------*/
.ui-state-disabled { cursor: default !important; }
/* Icons
----------------------------------*/
/* states and images */
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
/* Misc visuals
----------------------------------*/
/* Overlays */
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
/*
* jQuery UI CSS Framework
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Lucida%20Grande,%20Lucida%20Sans,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=5c9ccc&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=55&borderColorHeader=4297d7&fcHeader=ffffff&iconColorHeader=d8e7f3&bgColorContent=fcfdfd&bgTextureContent=06_inset_hard.png&bgImgOpacityContent=100&borderColorContent=a6c9e2&fcContent=222222&iconColorContent=469bdd&bgColorDefault=dfeffc&bgTextureDefault=02_glass.png&bgImgOpacityDefault=85&borderColorDefault=c5dbec&fcDefault=2e6e9e&iconColorDefault=6da8d5&bgColorHover=d0e5f5&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=79b7e7&fcHover=1d5987&iconColorHover=217bc0&bgColorActive=f5f8f9&bgTextureActive=06_inset_hard.png&bgImgOpacityActive=100&borderColorActive=79b7e7&fcActive=e17009&iconColorActive=f9bd01&bgColorHighlight=fbec88&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=fad42e&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
*/
/* Component containers
----------------------------------*/
.ui-widget { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1.1em; }
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em; }
.ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; }
.ui-widget-content a { color: #222222; }
.ui-widget-header { border: 1px solid #4297d7; background: #5c9ccc url(images/ui-bg_gloss-wave_55_5c9ccc_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; }
.ui-widget-header a { color: #ffffff; }
/* Interaction states
----------------------------------*/
.ui-state-default, .ui-widget-content .ui-state-default { border: 1px solid #c5dbec; background: #dfeffc url(images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #2e6e9e; outline: none; }
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #2e6e9e; text-decoration: none; outline: none; }
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus { border: 1px solid #79b7e7; background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1d5987; outline: none; }
.ui-state-hover a, .ui-state-hover a:hover { color: #1d5987; text-decoration: none; outline: none; }
.ui-state-active, .ui-widget-content .ui-state-active { border: 1px solid #79b7e7; background: #f5f8f9 url(images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #e17009; outline: none; }
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #e17009; outline: none; text-decoration: none; }
/* Interaction Cues
----------------------------------*/
.ui-state-highlight, .ui-widget-content .ui-state-highlight {border: 1px solid #fad42e; background: #fbec88 url(images/ui-bg_flat_55_fbec88_40x100.png) 50% 50% repeat-x; color: #363636; }
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a { color: #363636; }
.ui-state-error, .ui-widget-content .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; }
.ui-state-error a, .ui-widget-content .ui-state-error a { color: #cd0a0a; }
.ui-state-error-text, .ui-widget-content .ui-state-error-text { color: #cd0a0a; }
.ui-state-disabled, .ui-widget-content .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
.ui-priority-primary, .ui-widget-content .ui-priority-primary { font-weight: bold; }
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
/* Icons
----------------------------------*/
/* states and images */
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_469bdd_256x240.png); }
.ui-widget-content .ui-icon {background-image: url(images/ui-icons_469bdd_256x240.png); }
.ui-widget-header .ui-icon {background-image: url(images/ui-icons_d8e7f3_256x240.png); }
.ui-state-default .ui-icon { background-image: url(images/ui-icons_6da8d5_256x240.png); }
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_217bc0_256x240.png); }
.ui-state-active .ui-icon {background-image: url(images/ui-icons_f9bd01_256x240.png); }
.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
/* positioning */
.ui-icon-carat-1-n { background-position: 0 0; }
.ui-icon-carat-1-ne { background-position: -16px 0; }
.ui-icon-carat-1-e { background-position: -32px 0; }
.ui-icon-carat-1-se { background-position: -48px 0; }
.ui-icon-carat-1-s { background-position: -64px 0; }
.ui-icon-carat-1-sw { background-position: -80px 0; }
.ui-icon-carat-1-w { background-position: -96px 0; }
.ui-icon-carat-1-nw { background-position: -112px 0; }
.ui-icon-carat-2-n-s { background-position: -128px 0; }
.ui-icon-carat-2-e-w { background-position: -144px 0; }
.ui-icon-triangle-1-n { background-position: 0 -16px; }
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
.ui-icon-triangle-1-e { background-position: -32px -16px; }
.ui-icon-triangle-1-se { background-position: -48px -16px; }
.ui-icon-triangle-1-s { background-position: -64px -16px; }
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
.ui-icon-triangle-1-w { background-position: -96px -16px; }
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
.ui-icon-arrow-1-n { background-position: 0 -32px; }
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
.ui-icon-arrow-1-e { background-position: -32px -32px; }
.ui-icon-arrow-1-se { background-position: -48px -32px; }
.ui-icon-arrow-1-s { background-position: -64px -32px; }
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
.ui-icon-arrow-1-w { background-position: -96px -32px; }
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
.ui-icon-arrow-4 { background-position: 0 -80px; }
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
.ui-icon-extlink { background-position: -32px -80px; }
.ui-icon-newwin { background-position: -48px -80px; }
.ui-icon-refresh { background-position: -64px -80px; }
.ui-icon-shuffle { background-position: -80px -80px; }
.ui-icon-transfer-e-w { background-position: -96px -80px; }
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
.ui-icon-folder-collapsed { background-position: 0 -96px; }
.ui-icon-folder-open { background-position: -16px -96px; }
.ui-icon-document { background-position: -32px -96px; }
.ui-icon-document-b { background-position: -48px -96px; }
.ui-icon-note { background-position: -64px -96px; }
.ui-icon-mail-closed { background-position: -80px -96px; }
.ui-icon-mail-open { background-position: -96px -96px; }
.ui-icon-suitcase { background-position: -112px -96px; }
.ui-icon-comment { background-position: -128px -96px; }
.ui-icon-person { background-position: -144px -96px; }
.ui-icon-print { background-position: -160px -96px; }
.ui-icon-trash { background-position: -176px -96px; }
.ui-icon-locked { background-position: -192px -96px; }
.ui-icon-unlocked { background-position: -208px -96px; }
.ui-icon-bookmark { background-position: -224px -96px; }
.ui-icon-tag { background-position: -240px -96px; }
.ui-icon-home { background-position: 0 -112px; }
.ui-icon-flag { background-position: -16px -112px; }
.ui-icon-calendar { background-position: -32px -112px; }
.ui-icon-cart { background-position: -48px -112px; }
.ui-icon-pencil { background-position: -64px -112px; }
.ui-icon-clock { background-position: -80px -112px; }
.ui-icon-disk { background-position: -96px -112px; }
.ui-icon-calculator { background-position: -112px -112px; }
.ui-icon-zoomin { background-position: -128px -112px; }
.ui-icon-zoomout { background-position: -144px -112px; }
.ui-icon-search { background-position: -160px -112px; }
.ui-icon-wrench { background-position: -176px -112px; }
.ui-icon-gear { background-position: -192px -112px; }
.ui-icon-heart { background-position: -208px -112px; }
.ui-icon-star { background-position: -224px -112px; }
.ui-icon-link { background-position: -240px -112px; }
.ui-icon-cancel { background-position: 0 -128px; }
.ui-icon-plus { background-position: -16px -128px; }
.ui-icon-plusthick { background-position: -32px -128px; }
.ui-icon-minus { background-position: -48px -128px; }
.ui-icon-minusthick { background-position: -64px -128px; }
.ui-icon-close { background-position: -80px -128px; }
.ui-icon-closethick { background-position: -96px -128px; }
.ui-icon-key { background-position: -112px -128px; }
.ui-icon-lightbulb { background-position: -128px -128px; }
.ui-icon-scissors { background-position: -144px -128px; }
.ui-icon-clipboard { background-position: -160px -128px; }
.ui-icon-copy { background-position: -176px -128px; }
.ui-icon-contact { background-position: -192px -128px; }
.ui-icon-image { background-position: -208px -128px; }
.ui-icon-video { background-position: -224px -128px; }
.ui-icon-script { background-position: -240px -128px; }
.ui-icon-alert { background-position: 0 -144px; }
.ui-icon-info { background-position: -16px -144px; }
.ui-icon-notice { background-position: -32px -144px; }
.ui-icon-help { background-position: -48px -144px; }
.ui-icon-check { background-position: -64px -144px; }
.ui-icon-bullet { background-position: -80px -144px; }
.ui-icon-radio-off { background-position: -96px -144px; }
.ui-icon-radio-on { background-position: -112px -144px; }
.ui-icon-pin-w { background-position: -128px -144px; }
.ui-icon-pin-s { background-position: -144px -144px; }
.ui-icon-play { background-position: 0 -160px; }
.ui-icon-pause { background-position: -16px -160px; }
.ui-icon-seek-next { background-position: -32px -160px; }
.ui-icon-seek-prev { background-position: -48px -160px; }
.ui-icon-seek-end { background-position: -64px -160px; }
.ui-icon-seek-first { background-position: -80px -160px; }
.ui-icon-stop { background-position: -96px -160px; }
.ui-icon-eject { background-position: -112px -160px; }
.ui-icon-volume-off { background-position: -128px -160px; }
.ui-icon-volume-on { background-position: -144px -160px; }
.ui-icon-power { background-position: 0 -176px; }
.ui-icon-signal-diag { background-position: -16px -176px; }
.ui-icon-signal { background-position: -32px -176px; }
.ui-icon-battery-0 { background-position: -48px -176px; }
.ui-icon-battery-1 { background-position: -64px -176px; }
.ui-icon-battery-2 { background-position: -80px -176px; }
.ui-icon-battery-3 { background-position: -96px -176px; }
.ui-icon-circle-plus { background-position: 0 -192px; }
.ui-icon-circle-minus { background-position: -16px -192px; }
.ui-icon-circle-close { background-position: -32px -192px; }
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
.ui-icon-circle-zoomin { background-position: -176px -192px; }
.ui-icon-circle-zoomout { background-position: -192px -192px; }
.ui-icon-circle-check { background-position: -208px -192px; }
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
.ui-icon-circlesmall-close { background-position: -32px -208px; }
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
.ui-icon-squaresmall-close { background-position: -80px -208px; }
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
/* Misc visuals
----------------------------------*/
/* Corner radius */
.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; }
.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; }
.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; }
.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; }
.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; }
.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; }
.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; }
.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; }
.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; }
/* Overlays */
.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); }
.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; }/* Accordion
----------------------------------*/
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
.ui-accordion .ui-accordion-li-fix { display: inline; }
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em 2.2em; }
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; }
.ui-accordion .ui-accordion-content-active { display: block; }/* Datepicker
----------------------------------*/
.ui-datepicker { width: 17em; padding: .2em .2em 0; }
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
.ui-datepicker .ui-datepicker-prev { left:2px; }
.ui-datepicker .ui-datepicker-next { right:2px; }
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
.ui-datepicker .ui-datepicker-title select { float:left; font-size:1em; margin:1px 0; }
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year { width: 49%;}
.ui-datepicker .ui-datepicker-title select.ui-datepicker-year { float: right; }
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
.ui-datepicker td { border: 0; padding: 1px; }
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
/* with multiple calendars */
.ui-datepicker.ui-datepicker-multi { width:auto; }
.ui-datepicker-multi .ui-datepicker-group { float:left; }
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
.ui-datepicker-row-break { clear:both; width:100%; }
/* RTL support */
.ui-datepicker-rtl { direction: rtl; }
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
.ui-datepicker-cover {
display: none; /*sorry for IE5*/
display/**/: block; /*sorry for IE5*/
position: absolute; /*must have*/
z-index: -1; /*must have*/
filter: mask(); /*must have*/
top: -4px; /*must have*/
left: -4px; /*must have*/
width: 200px; /*must have*/
height: 200px; /*must have*/
}/* Dialog
----------------------------------*/
.ui-dialog { position: relative; padding: .2em; width: 300px; }
.ui-dialog .ui-dialog-titlebar { padding: .5em .3em .3em 1em; position: relative; }
.ui-dialog .ui-dialog-title { float: left; margin: .1em 0 .2em; }
.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
.ui-dialog .ui-dialog-content { border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; }
.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
.ui-draggable .ui-dialog-titlebar { cursor: move; }
/* Progressbar
----------------------------------*/
.ui-progressbar { height:2em; text-align: left; }
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }/* Resizable
----------------------------------*/
.ui-resizable { position: relative;}
.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;}
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0px; }
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0px; }
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0px; height: 100%; }
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0px; height: 100%; }
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/* Slider
----------------------------------*/
.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; }
.ui-slider-horizontal { height: .8em; }
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
.ui-slider-vertical { width: .8em; height: 100px; }
.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
.ui-slider-vertical .ui-slider-range-max { top: 0; }/* Tabs
----------------------------------*/
.ui-tabs { padding: .2em; zoom: 1; }
.ui-tabs .ui-tabs-nav { list-style: none; position: relative; padding: .2em .2em 0; }
.ui-tabs .ui-tabs-nav li { position: relative; float: left; border-bottom-width: 0 !important; margin: 0 .2em -1px 0; padding: 0; }
.ui-tabs .ui-tabs-nav li a { float: left; text-decoration: none; padding: .5em 1em; }
.ui-tabs .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 1px; border-bottom-width: 0; }
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; }
.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
.ui-tabs .ui-tabs-panel { padding: 1em 1.4em; display: block; border-width: 0; background: none; }
.ui-tabs .ui-tabs-hide { display: none !important; }

110
css/ui.slider.extras.css Normal file
View File

@@ -0,0 +1,110 @@
/*NEW SLIDER STYLES FOR SCALE, ETC*/
/* slider widget */
.ui-slider {
text-decoration: none !important;
}
.ui-slider .ui-slider-handle {
overflow: visible !important;
}
.ui-slider .ui-slider-tooltip {
display: none;
}
.ui-slider .screenReaderContext {
position: absolute;
width: 0;
height: 0;
overflow: hidden;
left: -999999999px;
}
.ui-slider .ui-state-active .ui-slider-tooltip, .ui-slider .ui-state-focus .ui-slider-tooltip, .ui-slider .ui-state-hover .ui-slider-tooltip {
display: block;
position: absolute;
bottom: 2.5em;
text-align: center;
padding: .3em .2em .4em;
font-size: .9em;
width: 8em;
margin-left: -3.7em;
}
.ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down, .ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down-inner {
position: absolute;
display: block;
width:0;
height:0;
border-bottom-width: 0;
background: none;
}
.ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down {
border-left: 7px dashed transparent;
border-right: 7px dashed transparent;
border-top-width: 8px;
bottom: -8px;
right: auto;
left: 50%;
margin-left: -7px;
}
.ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down-inner {
border-left: 6px dashed transparent;
border-right: 6px dashed transparent;
border-top: 7px solid #fff;
bottom: auto;
top: -9px;
left: -6px;
}
.ui-slider a {
text-decoration: none;
}
.ui-slider ol, .ui-slider li, .ui-slider dl, .ui-slider dd, .ui-slider dt {
list-style: none;
margin: 0;
padding: 0;
}
.ui-slider ol, .ui-slider dl {
position: relative;
top: 1.3em;
width: 100%;
}
.ui-slider dt {
top: 1.5em;
position: absolute;
padding-top: .2em;
text-align: center;
border-bottom: 1px dotted #ddd;
height: .7em;
color: #999;
}
.ui-slider dt span {
background: #fff;
padding: 0 .5em;
}
.ui-slider li, .ui-slider dd {
position: absolute;
overflow: visible;
color: #666;
}
.ui-slider span.ui-slider-label {
position: absolute;
}
.ui-slider li span.ui-slider-label, .ui-slider dd span.ui-slider-label {
display: none;
}
.ui-slider li span.ui-slider-label-show, .ui-slider dd span.ui-slider-label-show {
display: block;
}
.ui-slider span.ui-slider-tic {
position: absolute;
left: 0;
height: .8em;
top: -1.3em;
}
.ui-slider li span.ui-widget-content, .ui-slider dd span.ui-widget-content {
border-right: 0;
border-left-width: 1px;
border-left-style: solid;
border-top: 0;
border-bottom: 0;
}
.ui-slider .first .ui-slider-tic, .ui-slider .last .ui-slider-tic {
display: none;
}

58
functions.php Normal file
View File

@@ -0,0 +1,58 @@
<?php
function now() {
return array(date('Y'), date('W'));
}
function timeToSeconds($sTime) {
$aTime = explode(':', $sTime);
return 60 * (60 * $aTime[0] + $aTime[1]);
}
function arrayToSeconds($aTime) {
return 60 * (60 * $aTime['hour'] + $aTime['minute']);
}
function getTime($iYear, $iWeek, $iDay = 0) {
$iFirst = mktime(1, 1, 1, 1, 1, $iYear);
$iOffset = (11 - date('w', $iFirst)) % 7 - 3 + $iDay;
return strtotime(($iWeek - 1) . ' weeks ' . $iOffset . ' days', $iFirst);
}
function convertType($sType) {
global $aConfig;
$sType = strtolower($sType);
foreach ($aConfig['types'] as $sKey => $aTypes) {
if ($sKey == $sType || in_array($sType, $aTypes)) {
return $sKey;
}
}
return $sKey;
}
function convertData($aData, &$aTable, &$aInfo) {
global $aConfig;
foreach ($aData as $sGroup => $aDays) {
$aTable[$sGroup] = array();
foreach ($aDays as $iDay => $aDay) {
foreach ($aDay as $aCourse) {
$sText = isset($aCourse['room'])
? sprintf('[%s-%s] %s @ %s', $aCourse['start'], $aCourse['end'], $aCourse['course'], $aCourse['room'])
: sprintf('[%s-%s] %s', $aCourse['start'], $aCourse['end'], $aCourse['course']);
$aInfo[] = array(
'text' => $sText,
'type' => convertType($aCourse['type']));
$iId = count($aInfo) - 1;
$iStart = timeToSeconds($aCourse['start']);
$iEnd = timeToSeconds($aCourse['end']);
for ($iHour = $aConfig['start']['hour']; $iHour <= $aConfig['end']['hour']; ++$iHour) {
for ($iMinute = 0; $iMinute < $aConfig['steps']; ++$iMinute) {
$iTime = 60 * (60 * $iHour + $aConfig['step'] * $iMinute);
if ($iTime >= $iStart && $iTime <= $iEnd) {
$aTable[$sGroup][$iDay][$iHour][$iMinute] = $iId;
}
}
}
}
}
}
}

96
index.php Normal file
View File

@@ -0,0 +1,96 @@
<?php
require_once 'config.php';
require_once 'template.php';
require_once 'cache.php';
require_once 'vurooster.php';
require_once 'uvarooster.php';
$bForm = true;
if (isset($_POST['action']) && $_POST['action'] == 'view') {
/* Weeks */
$iWeeks = isset($_POST['weeks']) ? $_POST['weeks'] : $aConfig['weeks'];
/* Week */
$bNow = true;
if (isset($_POST['week-from'])) {
$aWeek = explode('-', $_POST['week-from']);
if (count($aWeek == 2)) {
$iYear = $aWeek[0];
if (($iYear == $aConfig['year'] && $aWeek[1] >= $aConfig['week'] && $aWeek[1] <= 52) || ($iYear == $aConfig['year'] + 1 && $aWeek[1] > 1 && $aWeek[1] < $aConfig['week'])) {
list($iYear, $iWeek) = $aWeek;
$bNow = false;
}
}
}
if ($bNow === true) {
list($iYear, $iWeek) = now();
}
/* Groups */
if (isset($_POST['group'])) {
$aSelected = array_intersect($_POST['group'], array_keys($aConfig['filters']));
foreach ($aConfig['groups'] as $sCategory => $aGroups) {
$aGroupSelected = array();
foreach ($aGroups[1] as $sValue => $sText) {
if (in_array($sValue, $aSelected)) {
$aGroupSelected[] = $sValue;
}
}
if (count($aGroupSelected) == count($aGroups[1])) {
$aSelected = array_diff($aSelected, $aGroupSelected);
$aSelected[] = $sCategory;
}
}
$aGroups = array();
foreach ($aSelected as $sGroup) {
if (isset($aConfig['filters'][$sGroup])) {
$aGroups[] = $aConfig['filters'][$sGroup];
}
}
if (count($aGroups) > 0) {
$oVuRooster = new VuRooster;
$oVuCache = new Cache($oVuRooster);
$oVuCache->clean();
$oUvaRooster = new UvaRooster;
$oUvaCache = new Cache($oUvaRooster);
$aWeeks = array();
try {
$aGroups = $oVuCache->getGroups($aGroups);
$oVuRooster->setWeek($iYear, $iWeek);
$oUvaRooster->setWeek($iYear, $iWeek);
$aTables = $aInfos = array();
for ($i = 0; $i < $iWeeks; ++$i) {
$aWeeks[] = $oVuRooster->getWeek();
$aVuData = $aUvaData = array();
foreach ($aGroups as $sGroup => $sName) {
try {
$aVuData[$sName] = $oVuCache->getData($sGroup);
if (isset($aConfig['uva'][$sName])) {
$aUvaData[$sName] = $oUvaCache->getData($aConfig['uva'][$sName]);
}
} catch (Exception $e) {
die(printf('<pre style="color: red"><strong>ERROR:</strong> %s</pre>', $e->getMessage()));
}
}
convertData($aVuData, $aTable, $aInfo);
convertData($aUvaData, $aTable, $aInfo);
$aTables[] = $aTable;
$aInfos[] = $aInfo;
$oVuRooster->nextWeek();
$oUvaRooster->nextWeek();
}
echo Template::getWeeks($aTables, $aInfos, $aWeeks);
} catch (Exception $e) {
die(printf('<pre style="color: red"><strong>ERROR:</strong> %s</pre>', $e->getMessage()));
}
}
$bForm = false;
}
}
if ($bForm === true) {
echo Template::getForm();
}

40
js/form.js Normal file
View File

@@ -0,0 +1,40 @@
$(window).ready(function () {
$('select#weeks').selectToUISlider({
labels : 52,
tooltip : false
}).hide()
$('select#week-from, select#week-to').selectToUISlider({
labels : 18,
labelSrc : 'text',
tooltip : false
}).hide()
$('label[for="week-from"]').hide()
$('label[for="week-to"]').text('Selecteer weken')
$('select#weeks + div.ui-slider').bind('slide', function(e, ui) {
slider = $('select#week-to + div.ui-slider');
adjustWeeks(slider, 1, slider.slider('values', 0) + ui.value)
}).css('width', '40%')
$('select#week-to + div.ui-slider').bind('slide', function(e, ui) {
weeks = parseInt($('select#weeks').val())
if ($(ui.handle).attr('id').split('handle_')[1] == 'week-from') {
adjustWeeks(this, 1, ui.value + weeks)
} else {
adjustWeeks(this, 0, ui.value - weeks)
}
}).css('width', '80%')
function adjustWeeks(handle, index, value) {
$(handle).slider('values', index, value)
}
$('select#group').multiselect({
checkAllText : 'Selecteer alles',
uncheckAllText : 'Selecteer niets',
selectedText : '# van # geselecteerd',
noneSelectedText : $('label[for="group"]').hide().text()
})
})

705
js/jquery.multiselect.js Normal file
View File

@@ -0,0 +1,705 @@
/* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */
/*
* jQuery MultiSelect UI Widget 1.13
* Copyright (c) 2012 Eric Hynds
*
* http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
*
* Depends:
* - jQuery 1.4.2+
* - jQuery UI 1.8 widget factory
*
* Optional:
* - jQuery UI effects
* - jQuery UI position utility
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function($, undefined){
var multiselectID = 0;
$.widget("ech.multiselect", {
// default options
options: {
header: true,
height: 175,
minWidth: 225,
classes: '',
checkAllText: 'Check all',
uncheckAllText: 'Uncheck all',
noneSelectedText: 'Select options',
selectedText: '# selected',
selectedList: 0,
show: null,
hide: null,
autoOpen: false,
multiple: true,
position: {}
},
_create: function(){
var el = this.element.hide(),
o = this.options;
this.speed = $.fx.speeds._default; // default speed for effects
this._isOpen = false; // assume no
var
button = (this.button = $('<button type="button"><span class="ui-icon ui-icon-triangle-2-n-s"></span></button>'))
.addClass('ui-multiselect ui-widget ui-state-default ui-corner-all')
.addClass( o.classes )
.attr({ 'title':el.attr('title'), 'aria-haspopup':true, 'tabIndex':el.attr('tabIndex') })
.insertAfter( el ),
buttonlabel = (this.buttonlabel = $('<span />'))
.html( o.noneSelectedText )
.appendTo( button ),
menu = (this.menu = $('<div />'))
.addClass('ui-multiselect-menu ui-widget ui-widget-content ui-corner-all')
.addClass( o.classes )
.appendTo( document.body ),
header = (this.header = $('<div />'))
.addClass('ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix')
.appendTo( menu ),
headerLinkContainer = (this.headerLinkContainer = $('<ul />'))
.addClass('ui-helper-reset')
.html(function(){
if( o.header === true ){
return '<li><a class="ui-multiselect-all" href="#"><span class="ui-icon ui-icon-check"></span><span>' + o.checkAllText + '</span></a></li><li><a class="ui-multiselect-none" href="#"><span class="ui-icon ui-icon-closethick"></span><span>' + o.uncheckAllText + '</span></a></li>';
} else if(typeof o.header === "string"){
return '<li>' + o.header + '</li>';
} else {
return '';
}
})
.append('<li class="ui-multiselect-close"><a href="#" class="ui-multiselect-close"><span class="ui-icon ui-icon-circle-close"></span></a></li>')
.appendTo( header ),
checkboxContainer = (this.checkboxContainer = $('<ul />'))
.addClass('ui-multiselect-checkboxes ui-helper-reset')
.appendTo( menu );
// perform event bindings
this._bindEvents();
// build menu
this.refresh( true );
// some addl. logic for single selects
if( !o.multiple ){
menu.addClass('ui-multiselect-single');
}
},
_init: function(){
if( this.options.header === false ){
this.header.hide();
}
if( !this.options.multiple ){
this.headerLinkContainer.find('.ui-multiselect-all, .ui-multiselect-none').hide();
}
if( this.options.autoOpen ){
this.open();
}
if( this.element.is(':disabled') ){
this.disable();
}
},
refresh: function( init ){
var el = this.element,
o = this.options,
menu = this.menu,
checkboxContainer = this.checkboxContainer,
optgroups = [],
html = "",
id = el.attr('id') || multiselectID++; // unique ID for the label & option tags
// build items
el.find('option').each(function( i ){
var $this = $(this),
parent = this.parentNode,
title = this.innerHTML,
description = this.title,
value = this.value,
inputID = 'ui-multiselect-' + (this.id || id + '-option-' + i),
isDisabled = this.disabled,
isSelected = this.selected,
labelClasses = [ 'ui-corner-all' ],
liClasses = (isDisabled ? 'ui-multiselect-disabled ' : ' ') + this.className,
optLabel;
// is this an optgroup?
if( parent.tagName === 'OPTGROUP' ){
optLabel = parent.getAttribute( 'label' );
// has this optgroup been added already?
if( $.inArray(optLabel, optgroups) === -1 ){
html += '<li class="ui-multiselect-optgroup-label ' + parent.className + '"><a href="#">' + optLabel + '</a></li>';
optgroups.push( optLabel );
}
}
if( isDisabled ){
labelClasses.push( 'ui-state-disabled' );
}
// browsers automatically select the first option
// by default with single selects
if( isSelected && !o.multiple ){
labelClasses.push( 'ui-state-active' );
}
html += '<li class="' + liClasses + '">';
// create the label
html += '<label for="' + inputID + '" title="' + description + '" class="' + labelClasses.join(' ') + '">';
html += '<input id="' + inputID + '" name="multiselect_' + id + '" type="' + (o.multiple ? "checkbox" : "radio") + '" value="' + value + '" title="' + title + '"';
// pre-selected?
if( isSelected ){
html += ' checked="checked"';
html += ' aria-selected="true"';
}
// disabled?
if( isDisabled ){
html += ' disabled="disabled"';
html += ' aria-disabled="true"';
}
// add the title and close everything off
html += ' /><span>' + title + '</span></label></li>';
});
// insert into the DOM
checkboxContainer.html( html );
// cache some moar useful elements
this.labels = menu.find('label');
this.inputs = this.labels.children('input');
// set widths
this._setButtonWidth();
this._setMenuWidth();
// remember default value
this.button[0].defaultValue = this.update();
// broadcast refresh event; useful for widgets
if( !init ){
this._trigger('refresh');
}
},
// updates the button text. call refresh() to rebuild
update: function(){
var o = this.options,
$inputs = this.inputs,
$checked = $inputs.filter(':checked'),
numChecked = $checked.length,
value;
if( numChecked === 0 ){
value = o.noneSelectedText;
} else {
if($.isFunction( o.selectedText )){
value = o.selectedText.call(this, numChecked, $inputs.length, $checked.get());
} else if( /\d/.test(o.selectedList) && o.selectedList > 0 && numChecked <= o.selectedList){
value = $checked.map(function(){ return $(this).next().html(); }).get().join(', ');
} else {
value = o.selectedText.replace('#', numChecked).replace('#', $inputs.length);
}
}
this.buttonlabel.html( value );
return value;
},
// binds events
_bindEvents: function(){
var self = this, button = this.button;
function clickHandler(){
self[ self._isOpen ? 'close' : 'open' ]();
return false;
}
// webkit doesn't like it when you click on the span :(
button
.find('span')
.bind('click.multiselect', clickHandler);
// button events
button.bind({
click: clickHandler,
keypress: function( e ){
switch(e.which){
case 27: // esc
case 38: // up
case 37: // left
self.close();
break;
case 39: // right
case 40: // down
self.open();
break;
}
},
mouseenter: function(){
if( !button.hasClass('ui-state-disabled') ){
$(this).addClass('ui-state-hover');
}
},
mouseleave: function(){
$(this).removeClass('ui-state-hover');
},
focus: function(){
if( !button.hasClass('ui-state-disabled') ){
$(this).addClass('ui-state-focus');
}
},
blur: function(){
$(this).removeClass('ui-state-focus');
}
});
// header links
this.header
.delegate('a', 'click.multiselect', function( e ){
// close link
if( $(this).hasClass('ui-multiselect-close') ){
self.close();
// check all / uncheck all
} else {
self[ $(this).hasClass('ui-multiselect-all') ? 'checkAll' : 'uncheckAll' ]();
}
e.preventDefault();
});
// optgroup label toggle support
this.menu
.delegate('li.ui-multiselect-optgroup-label a', 'click.multiselect', function( e ){
e.preventDefault();
var $this = $(this),
$inputs = $this.parent().nextUntil('li.ui-multiselect-optgroup-label').find('input:visible:not(:disabled)'),
nodes = $inputs.get(),
label = $this.parent().text();
// trigger event and bail if the return is false
if( self._trigger('beforeoptgrouptoggle', e, { inputs:nodes, label:label }) === false ){
return;
}
// toggle inputs
self._toggleChecked(
$inputs.filter(':checked').length !== $inputs.length,
$inputs
);
self._trigger('optgrouptoggle', e, {
inputs: nodes,
label: label,
checked: nodes[0].checked
});
})
.delegate('label', 'mouseenter.multiselect', function(){
if( !$(this).hasClass('ui-state-disabled') ){
self.labels.removeClass('ui-state-hover');
$(this).addClass('ui-state-hover').find('input').focus();
}
})
.delegate('label', 'keydown.multiselect', function( e ){
e.preventDefault();
switch(e.which){
case 9: // tab
case 27: // esc
self.close();
break;
case 38: // up
case 40: // down
case 37: // left
case 39: // right
self._traverse(e.which, this);
break;
case 13: // enter
$(this).find('input')[0].click();
break;
}
})
.delegate('input[type="checkbox"], input[type="radio"]', 'click.multiselect', function( e ){
var $this = $(this),
val = this.value,
checked = this.checked,
tags = self.element.find('option');
// bail if this input is disabled or the event is cancelled
if( this.disabled || self._trigger('click', e, { value: val, text: this.title, checked: checked }) === false ){
e.preventDefault();
return;
}
// make sure the input has focus. otherwise, the esc key
// won't close the menu after clicking an item.
$this.focus();
// toggle aria state
$this.attr('aria-selected', checked);
// change state on the original option tags
tags.each(function(){
if( this.value === val ){
this.selected = checked;
} else if( !self.options.multiple ){
this.selected = false;
}
});
// some additional single select-specific logic
if( !self.options.multiple ){
self.labels.removeClass('ui-state-active');
$this.closest('label').toggleClass('ui-state-active', checked );
// close menu
self.close();
}
// fire change on the select box
self.element.trigger("change");
// setTimeout is to fix multiselect issue #14 and #47. caused by jQuery issue #3827
// http://bugs.jquery.com/ticket/3827
setTimeout($.proxy(self.update, self), 10);
});
// close each widget when clicking on any other element/anywhere else on the page
$(document).bind('mousedown.multiselect', function( e ){
if(self._isOpen && !$.contains(self.menu[0], e.target) && !$.contains(self.button[0], e.target) && e.target !== self.button[0]){
self.close();
}
});
// deal with form resets. the problem here is that buttons aren't
// restored to their defaultValue prop on form reset, and the reset
// handler fires before the form is actually reset. delaying it a bit
// gives the form inputs time to clear.
$(this.element[0].form).bind('reset.multiselect', function(){
setTimeout($.proxy(self.refresh, self), 10);
});
},
// set button width
_setButtonWidth: function(){
var width = this.element.outerWidth(),
o = this.options;
if( /\d/.test(o.minWidth) && width < o.minWidth){
width = o.minWidth;
}
// set widths
this.button.width( width );
},
// set menu width
_setMenuWidth: function(){
var m = this.menu,
width = this.button.outerWidth()-
parseInt(m.css('padding-left'),10)-
parseInt(m.css('padding-right'),10)-
parseInt(m.css('border-right-width'),10)-
parseInt(m.css('border-left-width'),10);
m.width( width || this.button.outerWidth() );
},
// move up or down within the menu
_traverse: function( which, start ){
var $start = $(start),
moveToLast = which === 38 || which === 37,
// select the first li that isn't an optgroup label / disabled
$next = $start.parent()[moveToLast ? 'prevAll' : 'nextAll']('li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)')[ moveToLast ? 'last' : 'first']();
// if at the first/last element
if( !$next.length ){
var $container = this.menu.find('ul').last();
// move to the first/last
this.menu.find('label')[ moveToLast ? 'last' : 'first' ]().trigger('mouseover');
// set scroll position
$container.scrollTop( moveToLast ? $container.height() : 0 );
} else {
$next.find('label').trigger('mouseover');
}
},
// This is an internal function to toggle the checked property and
// other related attributes of a checkbox.
//
// The context of this function should be a checkbox; do not proxy it.
_toggleState: function( prop, flag ){
return function(){
if( !this.disabled ) {
this[ prop ] = flag;
}
if( flag ){
this.setAttribute('aria-selected', true);
} else {
this.removeAttribute('aria-selected');
}
};
},
_toggleChecked: function( flag, group ){
var $inputs = (group && group.length) ? group : this.inputs,
self = this;
// toggle state on inputs
$inputs.each(this._toggleState('checked', flag));
// give the first input focus
$inputs.eq(0).focus();
// update button text
this.update();
// gather an array of the values that actually changed
var values = $inputs.map(function(){
return this.value;
}).get();
// toggle state on original option tags
this.element
.find('option')
.each(function(){
if( !this.disabled && $.inArray(this.value, values) > -1 ){
self._toggleState('selected', flag).call( this );
}
});
// trigger the change event on the select
if( $inputs.length ) {
this.element.trigger("change");
}
},
_toggleDisabled: function( flag ){
this.button
.attr({ 'disabled':flag, 'aria-disabled':flag })[ flag ? 'addClass' : 'removeClass' ]('ui-state-disabled');
var inputs = this.menu.find('input');
var key = "ech-multiselect-disabled";
if(flag) {
// remember which elements this widget disabled (not pre-disabled)
// elements, so that they can be restored if the widget is re-enabled.
inputs = inputs.filter(':enabled')
.data(key, true)
} else {
inputs = inputs.filter(function() {
return $.data(this, key) === true;
}).removeData(key);
}
inputs
.attr({ 'disabled':flag, 'arial-disabled':flag })
.parent()[ flag ? 'addClass' : 'removeClass' ]('ui-state-disabled');
this.element
.attr({ 'disabled':flag, 'aria-disabled':flag });
},
// open the menu
open: function( e ){
var self = this,
button = this.button,
menu = this.menu,
speed = this.speed,
o = this.options,
args = [];
// bail if the multiselectopen event returns false, this widget is disabled, or is already open
if( this._trigger('beforeopen') === false || button.hasClass('ui-state-disabled') || this._isOpen ){
return;
}
var $container = menu.find('ul').last(),
effect = o.show,
pos = button.offset();
// figure out opening effects/speeds
if( $.isArray(o.show) ){
effect = o.show[0];
speed = o.show[1] || self.speed;
}
// if there's an effect, assume jQuery UI is in use
// build the arguments to pass to show()
if( effect ) {
args = [ effect, speed ];
}
// set the scroll of the checkbox container
$container.scrollTop(0).height(o.height);
// position and show menu
if( $.ui.position && !$.isEmptyObject(o.position) ){
o.position.of = o.position.of || button;
menu
.show()
.position( o.position )
.hide();
// if position utility is not available...
} else {
menu.css({
top: pos.top + button.outerHeight(),
left: pos.left
});
}
// show the menu, maybe with a speed/effect combo
$.fn.show.apply(menu, args);
// select the first option
// triggering both mouseover and mouseover because 1.4.2+ has a bug where triggering mouseover
// will actually trigger mouseenter. the mouseenter trigger is there for when it's eventually fixed
this.labels.eq(0).trigger('mouseover').trigger('mouseenter').find('input').trigger('focus');
button.addClass('ui-state-active');
this._isOpen = true;
this._trigger('open');
},
// close the menu
close: function(){
if(this._trigger('beforeclose') === false){
return;
}
var o = this.options,
effect = o.hide,
speed = this.speed,
args = [];
// figure out opening effects/speeds
if( $.isArray(o.hide) ){
effect = o.hide[0];
speed = o.hide[1] || this.speed;
}
if( effect ) {
args = [ effect, speed ];
}
$.fn.hide.apply(this.menu, args);
this.button.removeClass('ui-state-active').trigger('blur').trigger('mouseleave');
this._isOpen = false;
this._trigger('close');
},
enable: function(){
this._toggleDisabled(false);
},
disable: function(){
this._toggleDisabled(true);
},
checkAll: function( e ){
this._toggleChecked(true);
this._trigger('checkAll');
},
uncheckAll: function(){
this._toggleChecked(false);
this._trigger('uncheckAll');
},
getChecked: function(){
return this.menu.find('input').filter(':checked');
},
destroy: function(){
// remove classes + data
$.Widget.prototype.destroy.call( this );
this.button.remove();
this.menu.remove();
this.element.show();
return this;
},
isOpen: function(){
return this._isOpen;
},
widget: function(){
return this.menu;
},
getButton: function(){
return this.button;
},
// react to option changes after initialization
_setOption: function( key, value ){
var menu = this.menu;
switch(key){
case 'header':
menu.find('div.ui-multiselect-header')[ value ? 'show' : 'hide' ]();
break;
case 'checkAllText':
menu.find('a.ui-multiselect-all span').eq(-1).text(value);
break;
case 'uncheckAllText':
menu.find('a.ui-multiselect-none span').eq(-1).text(value);
break;
case 'height':
menu.find('ul').last().height( parseInt(value,10) );
break;
case 'minWidth':
this.options[ key ] = parseInt(value,10);
this._setButtonWidth();
this._setMenuWidth();
break;
case 'selectedText':
case 'selectedList':
case 'noneSelectedText':
this.options[key] = value; // these all needs to update immediately for the update() call
this.update();
break;
case 'classes':
menu.add(this.button).removeClass(this.options.classes).addClass(value);
break;
case 'multiple':
menu.toggleClass('ui-multiselect-single', !value);
this.options.multiple = value;
this.element[0].multiple = value;
this.refresh();
}
$.Widget.prototype._setOption.apply( this, arguments );
}
});
})(jQuery);

View File

@@ -0,0 +1,240 @@
/*
* --------------------------------------------------------------------
* jQuery-Plugin - selectToUISlider - creates a UI slider component from a select element(s)
* by Scott Jehl, scott@filamentgroup.com
* http://www.filamentgroup.com
* reference article: http://www.filamentgroup.com/lab/update_jquery_ui_16_slider_from_a_select_element/
* demo page: http://www.filamentgroup.com/examples/slider_v2/index.html
*
* Copyright (c) 2008 Filament Group, Inc
* Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
*
* Usage Notes: please refer to our article above for documentation
*
* --------------------------------------------------------------------
*/
jQuery.fn.selectToUISlider = function(settings){
var selects = jQuery(this);
//accessible slider options
var options = jQuery.extend({
labels: 3, //number of visible labels
tooltip: true, //show tooltips, boolean
tooltipSrc: 'text',//accepts 'value' as well
labelSrc: 'value',//accepts 'value' as well ,
sliderOptions: null
}, settings);
//handle ID attrs - selects each need IDs for handles to find them
var handleIds = (function(){
var tempArr = [];
selects.each(function(){
tempArr.push('handle_'+jQuery(this).attr('id'));
});
return tempArr;
})();
//array of all option elements in select element (ignores optgroups)
var selectOptions = (function(){
var opts = [];
selects.eq(0).find('option').each(function(){
opts.push({
value: jQuery(this).attr('value'),
text: jQuery(this).text()
});
});
return opts;
})();
//array of opt groups if present
var groups = (function(){
if(selects.eq(0).find('optgroup').size()>0){
var groupedData = [];
selects.eq(0).find('optgroup').each(function(i){
groupedData[i] = {};
groupedData[i].label = jQuery(this).attr('label');
groupedData[i].options = [];
jQuery(this).find('option').each(function(){
groupedData[i].options.push({text: jQuery(this).text(), value: jQuery(this).attr('value')});
});
});
return groupedData;
}
else return null;
})();
//check if obj is array
function isArray(obj) {
return obj.constructor == Array;
}
//return tooltip text from option index
function ttText(optIndex){
return (options.tooltipSrc == 'text') ? selectOptions[optIndex].text : selectOptions[optIndex].value;
}
//plugin-generated slider options (can be overridden)
var sliderOptions = {
step: 1,
min: 0,
orientation: 'horizontal',
max: selectOptions.length-1,
range: selects.length > 1,//multiple select elements = true
slide: function(e, ui) {//slide function
var thisHandle = jQuery(ui.handle);
//handle feedback
var textval = ttText(ui.value);
thisHandle
.attr('aria-valuetext', textval)
.attr('aria-valuenow', ui.value)
.find('.ui-slider-tooltip .ttContent')
.text( textval );
//control original select menu
var currSelect = jQuery('#' + thisHandle.attr('id').split('handle_')[1]);
currSelect.find('option').eq(ui.value).attr('selected', 'selected');
},
values: (function(){
var values = [];
selects.each(function(){
values.push( jQuery(this).get(0).selectedIndex );
});
return values;
})()
};
//slider options from settings
options.sliderOptions = (settings) ? jQuery.extend(sliderOptions, settings.sliderOptions) : sliderOptions;
//select element change event
selects.bind('change keyup click', function(){
var thisIndex = jQuery(this).get(0).selectedIndex;
var thisHandle = jQuery('#handle_'+ jQuery(this).attr('id'));
var handleIndex = thisHandle.data('handleNum');
thisHandle.parents('.ui-slider:eq(0)').slider("values", handleIndex, thisIndex);
});
//create slider component div
var sliderComponent = jQuery('<div></div>');
//CREATE HANDLES
selects.each(function(i){
var hidett = '';
//associate label for ARIA
var thisLabel = jQuery('label[for=' + jQuery(this).attr('id') +']');
//labelled by aria doesn't seem to work on slider handle. Using title attr as backup
var labelText = (thisLabel.size()>0) ? 'Slider control for '+ thisLabel.text()+'' : '';
var thisLabelId = thisLabel.attr('id') || thisLabel.attr('id', 'label_'+handleIds[i]).attr('id');
if( options.tooltip == false ){hidett = ' style="display: none;"';}
jQuery('<a '+
'href="#" tabindex="0" '+
'id="'+handleIds[i]+'" '+
'class="ui-slider-handle" '+
'role="slider" '+
'aria-labelledby="'+thisLabelId+'" '+
'aria-valuemin="'+options.sliderOptions.min+'" '+
'aria-valuemax="'+options.sliderOptions.max+'" '+
'aria-valuenow="'+options.sliderOptions.values[i]+'" '+
'aria-valuetext="'+ttText(options.sliderOptions.values[i])+'" '+
'><span class="screenReaderContext">'+labelText+'</span>'+
'<span class="ui-slider-tooltip ui-widget-content ui-corner-all"'+ hidett +'><span class="ttContent"></span>'+
'<span class="ui-tooltip-pointer-down ui-widget-content"><span class="ui-tooltip-pointer-down-inner"></span></span>'+
'</span></a>')
.data('handleNum',i)
.appendTo(sliderComponent);
});
//CREATE SCALE AND TICS
//write dl if there are optgroups
if(groups) {
var inc = 0;
var scale = sliderComponent.append('<dl class="ui-slider-scale ui-helper-reset" role="presentation"></dl>').find('.ui-slider-scale:eq(0)');
jQuery(groups).each(function(h){
scale.append('<dt style="width: '+ (100/groups.length).toFixed(2) +'%' +'; left:'+ (h/(groups.length-1) * 100).toFixed(2) +'%' +'"><span>'+this.label+'</span></dt>');//class name becomes camelCased label
var groupOpts = this.options;
jQuery(this.options).each(function(i){
var style = (inc == selectOptions.length-1 || inc == 0) ? 'style="display: none;"' : '' ;
var labelText = (options.labelSrc == 'text') ? groupOpts[i].text : groupOpts[i].value;
scale.append('<dd style="left:'+ leftVal(inc) +'"><span class="ui-slider-label">'+ labelText +'</span><span class="ui-slider-tic ui-widget-content"'+ style +'></span></dd>');
inc++;
});
});
}
//write ol
else {
var scale = sliderComponent.append('<ol class="ui-slider-scale ui-helper-reset" role="presentation"></ol>').find('.ui-slider-scale:eq(0)');
jQuery(selectOptions).each(function(i){
var style = (i == selectOptions.length-1 || i == 0) ? 'style="display: none;"' : '' ;
var labelText = (options.labelSrc == 'text') ? this.text : this.value;
scale.append('<li style="left:'+ leftVal(i) +'"><span class="ui-slider-label">'+ labelText +'</span><span class="ui-slider-tic ui-widget-content"'+ style +'></span></li>');
});
}
function leftVal(i){
return (i/(selectOptions.length-1) * 100).toFixed(2) +'%';
}
//show and hide labels depending on labels pref
//show the last one if there are more than 1 specified
if(options.labels > 1) sliderComponent.find('.ui-slider-scale li:last span.ui-slider-label, .ui-slider-scale dd:last span.ui-slider-label').addClass('ui-slider-label-show');
//set increment
var increm = Math.max(1, Math.round(selectOptions.length / options.labels));
//show em based on inc
for(var j=0; j<selectOptions.length; j+=increm){
if((selectOptions.length - j) > increm){//don't show if it's too close to the end label
sliderComponent.find('.ui-slider-scale li:eq('+ j +') span.ui-slider-label, .ui-slider-scale dd:eq('+ j +') span.ui-slider-label').addClass('ui-slider-label-show');
}
}
//style the dt's
sliderComponent.find('.ui-slider-scale dt').each(function(i){
jQuery(this).css({
'left': ((100 /( groups.length))*i).toFixed(2) + '%'
});
});
//inject and return
sliderComponent
.insertAfter(jQuery(this).eq(this.length-1))
.slider(options.sliderOptions)
.attr('role','application')
.find('.ui-slider-label')
.each(function(){
jQuery(this).css('marginLeft', -jQuery(this).width()/2);
});
//update tooltip arrow inner color
sliderComponent.find('.ui-tooltip-pointer-down-inner').each(function(){
var bWidth = jQuery('.ui-tooltip-pointer-down-inner').css('borderTopWidth');
var bColor = jQuery(this).parents('.ui-slider-tooltip').css('backgroundColor')
jQuery(this).css('border-top', bWidth+' solid '+bColor);
});
var values = sliderComponent.slider('values');
if(isArray(values)){
jQuery(values).each(function(i){
sliderComponent.find('.ui-slider-tooltip .ttContent').eq(i).text( ttText(this) );
});
}
else {
sliderComponent.find('.ui-slider-tooltip .ttContent').eq(0).text( ttText(values) );
}
return this;
}

45
rooster.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
abstract class Rooster {
const SEMESTER1_YEAR = 2011;
const SEMESTER2_YEAR = 2012;
const SEMESTER1_WEEK = 36;
const SEMESTER2_WEEK = 36;
var $iYear;
var $iWeek;
var $sWeek;
function __construct() {
$this->iYear = (int) date('Y');
$this->iWeek = (int) date('W');
$this->setWeek($this->iYear, $this->iWeek);
}
function setWeek($iYear, $iWeek) {
if ($iYear == self::SEMESTER1_YEAR && $iWeek >= self::SEMESTER1_WEEK && $iWeek <= 52) {
$iWeeks = $iWeek - self::SEMESTER1_WEEK + 1;
} else if ($iYear == self::SEMESTER2_YEAR && $iWeek >= 1 && $iWeek < self::SEMESTER2_WEEK) {
$iWeeks = $iWeek - self::SEMESTER2_WEEK + 52 + 1;
} else {
throw new Exception('Given week is out of range');
}
$this->iYear = $iYear;
$this->iWeek = $iWeek;
$this->sWeek = $iWeeks;
}
function nextWeek() {
if ($this->iWeek == 52) {
++$this->iYear;
$this->iWeek = 0;
}
++$this->iWeek;
}
function getWeek() {
return array($this->iYear, $this->iWeek);
}
abstract function getPage($sObject);
abstract function getData($sRooster = null);
}

17
style.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
header('Content-Type: text/css');
require_once 'css/default.css';
require_once 'config.php';
echo "\n";
foreach ($aConfig['colors'] as $sType => $aColor) {
printf(<<<CSS
tbody td.type-%s {
background: %s;
}
CSS
, $sType, $aColor[1]);
}
exit;

208
template.php Normal file
View File

@@ -0,0 +1,208 @@
<?php
require_once 'config.php';
require_once 'functions.php';
class Template {
static $aDays = array('MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY');
const DAY = 'j M';
static function getWeeks($aTables, $aInfos, $aWeeks) {
$aRoosters = array();
$sRooster = '';
foreach ($aWeeks as $aWeek) {
$sRooster .= self::getRooster(current($aTables), current($aInfos), $aWeek[0], $aWeek[1]);
next($aTables);
next($aInfos);
}
return str_replace(
array('{LEGENDA}', '{ROOSTER}'),
array(self::getLegenda(), $sRooster),
file_get_contents('template/page.html'));
}
static function getWeek($aTable, $aInfo, $iYear, $iWeek) {
return str_replace(
array('{LEGENDA}', '{ROOSTER}'),
array(self::getLegenda(), self::getRooster($aTable, $aInfo, $iYear, $iWeek)),
file_get_contents('template/page.html'));
}
static function getRooster($aTable, $aInfo, $iYear, $iWeek) {
global $aConfig;
$iGroups = count($aGroups = array_keys($aTable));
$sBarTemplate = file_get_contents('template/rooster-bar.html');
$sBar = '';
foreach ($aGroups as $iGroup => $sGroup) {
$sBar .= str_replace('{GROUP}', $sGroup, $sBarTemplate);
}
$sBar = str_repeat($sBar, 5);
$sRooster = str_replace(
array('{COLUMNS}', '{WEEK}', '{GROUPS}', '{BAR}', '{BODY}'),
array(5 * $iGroups, $iWeek, $iGroups, $sBar, self::getRoosterBody($aTable, $aInfo)),
file_get_contents('template/rooster.html'));
foreach (self::$aDays as $iDay => $sDay) {
$sRooster = str_replace(sprintf('{%s}', $sDay), date(self::DAY, getTime($iYear, $iWeek, $iDay)), $sRooster);
}
return $sRooster;
}
static function getRoosterBody($aTable, $aInfo) {
global $aConfig;
$sRowTemplate = file_get_contents('template/rooster-body-row.html');
$sRowHourTemplate = file_get_contents('template/rooster-body-row-hour.html');
$sRowMinuteTemplate = file_get_contents('template/rooster-body-row-minute.html');
$sRowDataTemplate = file_get_contents('template/rooster-body-row-data.html');
$iGroups = count($aGroups = array_keys($aTable));
$sRoosterBody = '';
for ($iHour = $aConfig['start']['hour']; $iHour <= $aConfig['end']['hour']; ++$iHour) {
if ($iHour == $aConfig['start']['hour']) {
$iMinute = $aConfig['start']['minute'] / $aConfig['step'];
$iSteps = $aConfig['steps'] - floor($iMinute);
} else {
$iMinute = 0;
$iSteps = $aConfig['steps'];
}
if ($iHour == $aConfig['end']['hour']) {
$iStop = $aConfig['end']['minute'] / $aConfig['step'];
$iSteps = ceil($iStop);
} else {
$iStop = $aConfig['steps'];
}
$bHour = true;
for (; $iMinute < $iStop; ++$iMinute) {
if ($bHour) {
$sRowHour = str_replace(array('{SPAN}', '{HOUR}'), array($iSteps, $iHour), $sRowHourTemplate);
$bHour = false;
} else {
$sRowHour = null;
}
$sRowMinute = str_replace('{MINUTE}', sprintf('%02d', $aConfig['step'] * $iMinute), $sRowMinuteTemplate);
$sRowData = '';
for ($iDay = 0; $iDay < 5; ++$iDay) {
foreach ($aGroups as $iGroup => $sGroup) {
if (isset($aTable[$sGroup][$iDay][$iHour][$iMinute])) {
$iId = $aTable[$sGroup][$iDay][$iHour][$iMinute];
$sText = $aInfo[$iId]['text'];
$sType = $aInfo[$iId]['type'];
} else {
$sText = null;
$sType = 'none';
}
$sRowData .= str_replace(
array('{TYPE}', '{BORDER}', '{TITLE}'),
array($sType, $iGroup == $iGroups - 1 ? ' border' : null, $sText),
$sRowDataTemplate);
}
}
$sRoosterBody .= str_replace(
array('{HOUR}', '{MINUTE}', '{DATA}'),
array($sRowHour, $sRowMinute, $sRowData), $sRowTemplate);
}
}
return $sRoosterBody;
}
static function getLegenda() {
global $aConfig;
$sRowTemplate = file_get_contents('template/legenda-row.html');
$sData = '';
foreach ($aConfig['colors'] as $sType => $aColor) {
$sData .= str_replace(array('{NAME}', '{TYPE}'), array($aColor[0], $sType), $sRowTemplate);
}
return str_replace('{BODY}', $sData, file_get_contents('template/legenda.html'));
}
static function getFormWeeks() {
global $aConfig;
$sOption = file_get_contents('template/form-option-selected.html');
$aOptions = array();
$iSelected = ceil($aConfig['weeks'] / 2);
for ($iWeeks = 1; $iWeeks <= $aConfig['weeks']; ++$iWeeks) {
$aOptions[] = str_replace(
array('{VALUE}', '{SELECTED}', '{TEXT}'),
array($iWeeks, $iWeeks == $iSelected ? ' selected="selected"' : null, $iWeeks),
$sOption);
}
return str_replace('{OPTIONS}', implode("\n", $aOptions), file_get_contents('template/form-weeks.html'));
}
static function getFormWeek() {
global $aConfig;
$sOption = file_get_contents('template/form-option.html');
/* From */
$aNow = now();
$aOptions = self::getWeekOptions($sOption, $aConfig['year'], $aNow, $aConfig['week'], 53);
$sFrom = vsprintf('%d-%d', $aNow);
$aOptgroups = array(str_replace(
array('{LABEL}', '{OPTIONS}'),
array($aConfig['year'], implode("\n", $aOptions)),
file_get_contents('template/form-optgroup.html')));
/* To */
$iWeeks = ceil($aConfig['weeks'] / 2);
$aNow = array(
$aNow[0] + ($aNow[1] + $iWeeks > 52 ? 1 : 0),
($aNow[1] + $iWeeks) % 52);
$aOptions = self::getWeekOptions($sOption, $aConfig['year'] + 1, $aNow, 1, $aConfig['week']);
$sTo = vsprintf('%d-%d', $aNow);
$aOptgroups[] = str_replace(
array('{LABEL}', '{OPTIONS}'),
array($aConfig['year'] + 1, implode("\n", $aOptions)),
file_get_contents('template/form-optgroup.html'));
$sOptions = implode("\n", $aOptgroups);
return str_replace(
array('{OPTIONS-FROM}', '{OPTIONS-TO}'),
array(
str_replace($sFrom, sprintf('%s" selected="selected', $sFrom), $sOptions),
str_replace($sTo, sprintf('%s" selected="selected', $sTo), $sOptions)),
file_get_contents('template/form-week.html'));
}
static function getWeekOptions($sOption, $iYear, $aNow, $iFrom, $iTo) {
$aOptions = array();
for ($iWeek = $iFrom; $iWeek < $iTo; ++$iWeek) {
$aOptions[] = str_replace(
array('{VALUE}', '{TEXT}'),
array($sValue = sprintf('%d-%d', $iYear, $iWeek), $iWeek),
$sOption);
if ($aNow[0] && $iWeek == $aNow[1]) {
$sFrom = $sValue;
}
}
return $aOptions;
}
static function getFormGroup() {
global $aConfig;
$aOptgroups = array();
$sOption = file_get_contents('template/form-option.html');
foreach ($aConfig['groups'] as $sCategory => $aGroups) {
$aOptions = array();
foreach ($aGroups[1] as $sValue => $sText) {
$aOptions[] = str_replace(
array('{VALUE}', '{TEXT}'),
array($sValue, $sText),
$sOption);
}
$aOptgroups[] = str_replace(
array('{LABEL}', '{OPTIONS}'),
array($aGroups[0], implode("\n", $aOptions)),
file_get_contents('template/form-optgroup.html'));
}
return str_replace('{OPTIONS}', implode("\n", $aOptgroups), file_get_contents('template/form-group.html'));
}
static function getForm() {
return str_replace(
array('{WEEKS}', '{WEEK}', '{GROUP}'),
array(self::getFormWeeks(), self::getFormWeek(), self::getFormGroup()),
file_get_contents('template/form.html'));
}
}

4
template/form-group.html Normal file
View File

@@ -0,0 +1,4 @@
<label for="group">Selecteer groepen</label>
<select name="group[]" id="group" multiple="multiple">
{OPTIONS}
</select>

View File

@@ -0,0 +1,3 @@
<optgroup label="{LABEL}">
{OPTIONS}
</optgroup>

View File

@@ -0,0 +1 @@
<option value="{VALUE}"{SELECTED}>{TEXT}</option>

View File

@@ -0,0 +1 @@
<option value="{VALUE}">{TEXT}</option>

8
template/form-week.html Normal file
View File

@@ -0,0 +1,8 @@
<label for="week-from">Week vanaf</label>
<select name="week-from" id="week-from">
{OPTIONS-FROM}
</select>
<label for="week-to">Week tot</label>
<select name="week-to" id="week-to">
{OPTIONS-TO}
</select>

4
template/form-weeks.html Normal file
View File

@@ -0,0 +1,4 @@
<label for="weeks">Aantal weken</label>
<select name="weeks" id="weeks">
{OPTIONS}
</select>

31
template/form.html Normal file
View File

@@ -0,0 +1,31 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Gecombineerde roosters</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/redmond/jquery-ui-1.7.1.custom.css" type="text/css" />
<link rel="stylesheet" href="css/ui.slider.extras.css" type="text/css" />
<link rel="stylesheet" href="css/jquery.multiselect.css" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/selectToUISlider.jQuery.js"></script>
<script type="text/javascript" src="js/jquery.multiselect.js"></script>
<script type="text/javascript" src="js/form.js"></script>
</head>
<body>
<form action="" method="post">
<input type="hidden" name="action" value="view" />
<fieldset>
<legend>Instellingen</legend>
{WEEKS}
{WEEK}
{GROUP}
</fieldset>
<input type="submit" value="Roosters ophalen" />
</form>
</body>
</html>

View File

@@ -0,0 +1,4 @@
<tr>
<td class="strong">{NAME}</td>
<td class="type-{TYPE}">&nbsp;</td>
</tr>

11
template/legenda.html Normal file
View File

@@ -0,0 +1,11 @@
<table>
<caption>Legenda</caption>
<thead>
<tr>
<th>Type</th>
<th>Kleur</th>
</tr>
</thead>
<tbody>
{BODY} </tbody>
</table>

14
template/page.html Normal file
View File

@@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Gecombineerde roosters</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p><a href="">&lt;&lt; Terug naar formulier</a></p>
{LEGENDA}
{ROOSTER}
</body>
</html>

View File

@@ -0,0 +1 @@
<th class="bar">{GROUP}</th>

View File

@@ -0,0 +1 @@
<td class="type-{TYPE}{BORDER}" title="{TITLE}">&nbsp;</td>

View File

@@ -0,0 +1 @@
<th rowspan="{SPAN}" class="hour">{HOUR}</th>

View File

@@ -0,0 +1 @@
<th class="minute">{MINUTE}</th>

View File

@@ -0,0 +1,2 @@
<tr>
{HOUR}{MINUTE}{DATA} </tr>

22
template/rooster.html Normal file
View File

@@ -0,0 +1,22 @@
<table>
<caption>Rooster week <strong>{WEEK}</strong></caption>
<colgroup>
<col span="2" />
<col width="20" span="{COLUMNS}" />
</colgroup>
<thead>
<tr>
<th colspan="2" class="week"></th>
<th colspan="{GROUPS}">Ma<br/><small>({MONDAY})</small></th>
<th colspan="{GROUPS}">Di<br/><small>({TUESDAY})</small></th>
<th colspan="{GROUPS}">Wo<br/><small>({WEDNESDAY})</small></th>
<th colspan="{GROUPS}">Do<br/><small>({THURSDAY})</small></th>
<th colspan="{GROUPS}">Vr<br/><small>({FRIDAY})</small></th>
</tr>
<tr>
<th colspan="2" class="corner">&nbsp;</th>
{BAR} </tr>
</thead>
<tbody>
{BODY} </tbody>
</table>

76
test.php Normal file
View File

@@ -0,0 +1,76 @@
<?php
require_once 'cache.php';
require_once 'template.php';
$oRooster = new Rooster;
$oCache = new Cache($oRooster);
$oCache->clean();
$iYear = 2011;
$iWeek = 36;
$iWeeks = $aConfig['weeks'];
$aGroups = array($aConfig['filters']['S'], $aConfig['filters']['F']);
$aWeeks = array();
try {
$aGroups = $oCache->getGroups($aGroups);
$oRooster->setWeek($iYear, $iWeek);
$aData = array();
for ($i = 0; $i < $iWeeks; ++$i) {
$aWeeks[] = $oRooster->getWeek();
foreach ($aGroups as $sGroup => $sName) {
try {
$aData[$sName] = $oCache->getData($sGroup);
} catch (Exception $e) {
die(printf('<pre style="color: red"><strong>ERROR:</strong> %s</pre>', $e->getMessage()));
}
}
$oRooster->nextWeek();
}
} catch (Exception $e) {
die(printf('<pre style="color: red"><strong>ERROR:</strong> %s</pre>', $e->getMessage()));
}
convertData($aData, $aTable, $aInfo);
echo Template::getWeeks($aTable, $aInfo, $aWeeks);
$oRooster = new Rooster;
$oCache = new Cache($oRooster);
$oCache->clean(true);
if (isset($_GET['group'])) {
if (isset($aConfig['filters'][$_GET['group']])) {
$aGroups = array_flip($oCache->getGroups(array($aConfig['filters'][$_GET['group']])));
if (isset($aGroups[$_GET['group']])) {
$iYear = isset($_GET['year']) ? $_GET['year'] : null;
$iWeek = isset($_GET['week']) ? $_GET['week'] : null;
try {
die($oCache->getRooster($aGroups[$_GET['group']], $iYear, $iWeek));
} catch (Exception $e) {
die('Ongeldige week!');
}
}
}
die('Ongeldige groep!');
}
try {
$aGroups = $oCache->getGroups(array($aConfig['filters']['S']));
$oRooster->setWeek(2012, 10);
$aData = array();
for ($i = 0; $i < $aConfig['weeks']; ++$i) {
foreach ($aGroups as $sGroup => $sName) {
try {
$aData[$sName] = $oCache->getData($sGroup);
} catch (Exception $e) {
printf('<pre style="color: red"><strong>ERROR:</strong> %s</pre>', $e->getMessage());
}
}
$oRooster->nextWeek();
}
file_put_contents('temp', serialize($aData));
} catch (Exception $e) {
printf('<pre style="color: red"><strong>ERROR:</strong> %s</pre>', $e->getMessage());
}

77
uvarooster.php Normal file
View File

@@ -0,0 +1,77 @@
<?php
require_once 'rooster.php';
class UvaRooster extends Rooster {
const URL = 'http://rooster.uva.nl/current_nl/';
function getPage($sObject) {
$sUrl = sprintf('%sshowtimetable.aspx?%s', self::URL, http_build_query(array(
'type' => 'posbydayurl',
'idstring' => $sObject,
'weeks' => $this->sWeek)));
if (($this->sContents = file_get_contents($sUrl)) === false) {
throw new Exception('Failed to load page');
}
return $this->sContents;
}
function getData($sRooster = null) {
$sRooster = isset($sRooster) ? $sRooster : $this->sContents;
if (substr_count($sRooster, '<td><b>') != 7) {
echo $sRooster;
throw new Exception('Page does not contain valid data');
}
$aDays = explode('<td><b>', $sRooster);
array_shift($aDays);
array_pop($aDays);
array_pop($aDays);
$aData = array();
foreach ($aDays as $iDay => $sDay) {
if (strpos($sDay, '<tbody>') !== false) {
$aColumns = null;
$aRows = explode('<tr>', $sDay);
array_shift($aRows);
array_pop($aRows);
$sHeader = array_shift($aRows);
if (!isset($aColumns)) {
foreach (explode("\n", strip_tags($sHeader)) as $iColumn => $sColumn) {
switch (trim($sColumn)) {
case 'Start':
$aColumns[$iColumn] = 'start';
break;
case 'Eind':
$aColumns[$iColumn] = 'end';
break;
case 'Vak':
$aColumns[$iColumn] = 'course';
break;
case 'Type':
$aColumns[$iColumn] = 'type';
break;
case 'Locatie':
$aColumns[$iColumn] = 'room';
break;
}
}
}
$aData[$iDay] = array();
foreach ($aRows as $sRow) {
$aInfo = array();
$aRow = explode("\n", strip_tags($sRow));
foreach ($aColumns as $iColumn => $sColumn) {
if (isset($aRow[$iColumn])) {
$aRow[$iColumn] = trim($aRow[$iColumn]);
$aInfo[$sColumn] = $sColumn == 'course'
? preg_replace('~[\s]+\([^\)]+\)$~', null, $aRow[$iColumn])
: $aRow[$iColumn];
}
}
$aData[$iDay][] = $aInfo;
}
}
}
return $aData;
}
}

187
vurooster.php Normal file
View File

@@ -0,0 +1,187 @@
<?php
require_once 'rooster.php';
// t=deze week, n=volgende week, +x=xe week vanaf begin academisch jaar
class VuRooster extends Rooster {
const URL_SEMESTER = 'http://rooster.vu.nl/';
var $sCookieFile;
var $rCurl;
var $sUrl;
var $aAspFields;
var $sContents;
var $bOnGroupsPage;
function __construct() {
$this->sCookieFile = tempnam('tmp', 'curl');
$this->rCurl = curl_init();
curl_setopt_array($this->rCurl, array(
CURLOPT_COOKIESESSION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_REFERER => true,
CURLOPT_COOKIEJAR => $this->sCookieFile,
CURLOPT_COOKIEFILE => $this->sCookieFile,
CURLOPT_URL => self::URL_SEMESTER));
parent::__construct();
}
function __destruct() {
curl_close($this->rCurl);
unlink($this->sCookieFile);
}
function setWeek($iYear, $iWeek) {
parent::setWeek($iYear, $iWeek);
$this->sWeek = sprintf('+%d', $this->sWeek);
curl_setopt($this->rCurl, CURLOPT_POST, false);
$this->execute();
$this->bOnGroupsPage = false;
}
function buildQuery($aFields) {
$aQuery = array();
foreach ($aFields as $sKey => $mValue) {
$aQuery[] = sprintf('%s=%s', $sKey, $mValue);
}
return implode('&', $aQuery);
}
function getAspFields() {
if ($this->bOnGroupsPage) {
return $this->aAspFields;
}
preg_match('~id="__VIEWSTATE" value="([^"]+)"~i', $this->sContents, $aViewState);
preg_match('~id="__EVENTVALIDATION" value="([^"]+)"~i', $this->sContents, $aEventValidation);
if (count($aViewState) < 2 || count($aEventValidation) < 2) {
throw new Exception('Failed to get asp fields from contents');
}
return $this->aAspFields = array(
'__VIEWSTATE' => urlencode($aViewState[1]),
'__EVENTVALIDATION' => urlencode($aEventValidation[1]));
}
function setPostFields($aPostFields) {
try {
$aAspFields = $this->getAspFields();
} catch (Exception $e) {
throw new Exception('Failed to get required asp fields from contents');
}
$sQuery = $this->buildQuery(array_merge($aAspFields, $aPostFields));
curl_setopt($this->rCurl, CURLOPT_POSTFIELDS, $sQuery);
}
function execute() {
if (!($sContents = curl_exec($this->rCurl))) {
throw new Exception('Failed to execute request');
}
$this->sContents = $sContents;
}
function loadGroupsPage() {
if ($this->bOnGroupsPage) {
return;
}
try {
/* Enter group selection mode */
$this->setPostFields(array(
'__EVENTTARGET' => 'LinkBtn_studentsets'));
$this->execute();
/* Stay on groups page */
$this->getAspFields();
$this->bOnGroupsPage = true;
} catch (Exception $e) {
throw new Exception('Failed to navigate to groups page');
}
}
function getGroups($aFilters) {
$this->loadGroupsPage();
preg_match('~<select [^>]* id="dlObject" [^>]*>~', $this->sContents, $aMatch);
if (count($aMatch) == 0) {
throw new Exception('Failed to get object list from page');
}
$aPart = explode($aMatch[0], $this->sContents);
$sPart = $aPart[1];
$aPart = explode('</select>', $sPart);
$sPart = $aPart[0];
$aGroups = array();
foreach ($aFilters as $sFilter) {
$sRegex = sprintf('~"([^"]+)">%s~i', $sFilter);
preg_match_all($sRegex, $sPart, $aMatches, PREG_SET_ORDER);
foreach ($aMatches as $aMatch) {
$aGroups[$aMatch[1]] = $aMatch[2];
}
}
return $aGroups;
}
function getPage($sObject) {
try {
$this->loadGroupsPage();
/* Select group and period */
$this->setPostFields(array(
'tLinkType' => 'studentsets',
'dlObject' => urlencode($sObject),
'lbWeeks' => $this->sWeek,
'dlType' => urlencode('TextSpreadsheet;SWS_Groep'),
'bGetTimetable' => null));
$this->execute();
return $this->sContents;
} catch (Exception $e) {
throw new Exception('Failed to load page');
}
}
function getData($sRooster = null) {
$aDays = explode('<table class=\'spreadsheet\'', isset($sRooster) ? $sRooster : $this->sContents);
if (count($aDays) != 8) {
throw new Exception('Page does not contain valid data');
}
array_shift($aDays);
array_pop($aDays);
array_pop($aDays);
$aData = array();
foreach ($aDays as $iDay => $sDay) {
$aColumns = null;
$aRows = explode('<tr>', $sDay);
$sHeader = array_shift($aRows);
if (!isset($aColumns)) {
preg_match_all('~<td>([^>]*)</td>~', $sHeader, $aMatches);
foreach ($aMatches[1] as $iColumn => $sColumn) {
switch ($sColumn) {
case 'Start':
$aColumns[$iColumn] = 'start';
break;
case 'Einde':
$aColumns[$iColumn] = 'end';
break;
case 'Vaknaam':
$aColumns[$iColumn] = 'course';
break;
case 'Type':
$aColumns[$iColumn] = 'type';
break;
case 'Zalen':
$aColumns[$iColumn] = 'room';
break;
}
}
}
$aData[$iDay] = array();
foreach ($aRows as $sRow) {
$sRow = str_replace('<br>', null, $sRow);
preg_match_all('~<td>([^>]*)</td>~', $sRow, $aMatches);
$aInfo = array();
foreach ($aColumns as $iColumn => $sColumn) {
$aInfo[$sColumn] = $aMatches[1][$iColumn];
}
$aData[$iDay][] = $aInfo;
}
}
return $aData;
}
}