diff options
author | MaZderMind | 2015-03-31 17:16:40 +0200 |
---|---|---|
committer | MaZderMind | 2015-03-31 17:16:40 +0200 |
commit | 3de36d7a63fe91127f3413d58004bbd6505864a3 (patch) | |
tree | 4cc04b1e7a4567dbfa3b752f1791695f275771fd | |
parent | c01f7979db801aca3cd42234cc4a7fafaec0a9cd (diff) |
Remove Global has/get
Diffstat (limited to '')
-rw-r--r-- | lib/helper.php | 38 | ||||
-rw-r--r-- | model/Schedule.php | 6 | ||||
-rw-r--r-- | view/program-json.php | 2 |
3 files changed, 4 insertions, 42 deletions
diff --git a/lib/helper.php b/lib/helper.php index 7423a9c..3dd6b69 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -21,44 +21,6 @@ function forceslash($url) return $url; } -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); -} - function startswith($needle, $haystack) { return substr($haystack, 0, strlen($needle)) == $needle; diff --git a/model/Schedule.php b/model/Schedule.php index 0536791..3a9ee70 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -11,7 +11,7 @@ class Schedule extends ModelBase } public function getScale() { - return floatval(get('SCHEDULE.SCALE', 7)); + return floatval($this->get('SCHEDULE.SCALE', 7)); } private function fetchSchedule() @@ -205,12 +205,12 @@ class Schedule extends ModelBase private function isCacheEnabled() { - return has('SCHEDULE.CACHE') && function_exists('apc_fetch') && function_exists('apc_store'); + return $this->has('SCHEDULE.CACHE') && function_exists('apc_fetch') && function_exists('apc_store'); } private function getCacheDuration() { - return get('SCHEDULE.CACHE', 60*10 /* 10 minutes */); + return $this->get('SCHEDULE.CACHE', 60*10 /* 10 minutes */); } private $localCache = null; diff --git a/view/program-json.php b/view/program-json.php index 08f4289..739b71b 100644 --- a/view/program-json.php +++ b/view/program-json.php @@ -5,4 +5,4 @@ if(!$schedule->isEnabled()) throw new NotFoundException('Schedule is disabled'); header('Content-Type: application/json'); -echo json_encode(program()); +echo json_encode($schedule->getSchedule()); |