diff options
author | MaZderMind | 2015-02-26 17:57:42 +0100 |
---|---|---|
committer | MaZderMind | 2015-02-26 17:57:42 +0100 |
commit | 6db2f0f4b9816ccd271332b89a05a9d0d753216b (patch) | |
tree | fd7ecf7cf16b33bdb75c45e747d12f9ecca43358 /lib | |
parent | 9fb5b19bb0652b9c187c9b552c0a7ec4d6778222 (diff) |
shuffle things around on the way to a bootstrap-based configurable website
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bootstrap.php | 2 | ||||
-rw-r--r-- | lib/config.php | 49 | ||||
-rw-r--r-- | lib/helper.php | 38 |
3 files changed, 39 insertions, 50 deletions
diff --git a/lib/bootstrap.php b/lib/bootstrap.php index 63d429c..57d9174 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -2,7 +2,7 @@ require_once('lib/PhpTemplate.php'); require_once('lib/helper.php'); -require_once('lib/config.php'); +require_once('config.php'); $tpl = new PhpTemplate('template/page.phtml'); $tpl->set(array( diff --git a/lib/config.php b/lib/config.php deleted file mode 100644 index 69bccaf..0000000 --- a/lib/config.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -date_default_timezone_set('Europe/Berlin'); - -// guessed automatically -// $GLOBALS['CONFIG']['baseurl'] = 'http://foo.com/bar/'; - -$GLOBALS['CONFIG']['SCHEDULE'] = 'http://events.ccc.de/congress/2014/Fahrplan/schedule.xml'; -$GLOBALS['CONFIG']['SCHEDULE_SCALE'] = 0.2; // float, px per second -$GLOBALS['CONFIG']['SCHEDULE_OFFSET'] = 0; - - -$GLOBALS['CONFIG']['ROOMS'] = array( - 'saal1' => 'Saal 1', - 'saal2' => 'Saal 2', - 'saalg' => 'Saal G', - 'saal6' => 'Saal 6', - - 'lounge' => 'Lounge', - 'ambient' => 'Ambient', - - 'sendezentrum' => 'Sendezentrum', -); - -$GLOBALS['CONFIG']['FORMATS'] = array( - 'hd' => 'FullHD Video', - 'sd' => 'SD Video', - 'audio' => 'Audio', - 'slides' => 'Slide-Images', -); - -$GLOBALS['CONFIG']['FORMAT_TEXT'] = array( - 'hd' => '1920x1080, h264+aac, 3 MBit/s', - 'sd' => '1024x576, h264+aac, 1 MBit/s', - 'webm' => '1024x576 vp8+vorbis in webm, 1 MBit/s', - - 'mp3' => 'MP3, 128 kBit/s', - 'opus' => 'Opus (RFC 6716), 96 kBit/s', - - 'party-mp3' => 'MP3, 320 kBit/s', - 'party-opus' => 'Opus (RFC 6716), 128 kBit/s', -); - -// various room-name nappings -$GLOBALS['CONFIG']['FAHRPLAN_ROOM_MAPPING'] = array( - 'Saal 1' => 'saal1', - 'Saal 2' => 'saal2', - 'Saal G' => 'saalg', - 'Saal 6' => 'saal6', -); diff --git a/lib/helper.php b/lib/helper.php index 2127c14..98397e4 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -96,3 +96,41 @@ function strtoduration($str) $parts = explode(':', $str); return ((int)$parts[0] * 60 + (int)$parts[1]) * 60; } + +function has($keychain) +{ + return _has($GLOBALS['CONFIG'], $keychain); +} +function _has($array, $keychain) +{ + if(!is_array($keychain)) + $keychain = explode('.', $keychain); + + $key = $keychain[0]; + if(!isset($array[$key])) + return false; + + if(count($keychain) == 1) + return true; + + return _has($array[$key], array_slice($keychain, 1)); +} + +function get($keychain, $default = null) +{ + return _get($GLOBALS['CONFIG'], $keychain, $default); +} +function _get($array, $keychain, $default) +{ + if(!is_array($keychain)) + $keychain = explode('.', $keychain); + + $key = $keychain[0]; + if(!isset($array[$key])) + return $default; + + if(count($keychain) == 1) + return $array[$key]; + + return _get($array[$key], array_slice($keychain, 1), $default); +} |