From be515f5150f20c773371f680efad58f2d0fcaaf0 Mon Sep 17 00:00:00 2001 From: Benjamin Peter Date: Sat, 9 Dec 2017 23:44:47 +0100 Subject: Added multple translation tracks with configurable endpoints and labels --- model/Conferences.php | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'model/Conferences.php') diff --git a/model/Conferences.php b/model/Conferences.php index f7276ac..eb07327 100644 --- a/model/Conferences.php +++ b/model/Conferences.php @@ -72,16 +72,34 @@ class Conferences return in_array($mandator, Conferences::listConferences()); } - public static function loadConferenceConfig($mandator) { - $configfile = forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php'; - $config = include($configfile); - - if(!is_array($config)) { - throw new ConfigException("Loading $configfile did not return an array. Maybe it's missing a return-statement?"); - } - - return $config; - } + public static function loadConferenceConfig($mandator) { + $configfile = forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php'; + $config = include($configfile); + + if(!is_array($config)) { + throw new ConfigException("Loading $configfile did not return an array. Maybe it's missing a return-statement?"); + } + + // Allow setting TRANSLATION simply to true and fill in default values for uniformity + $rooms = $config['ROOMS']; + foreach ($rooms as $slug => $room) { + if (!isset($room['TRANSLATION'])) { + $config['ROOMS'][$slug]['TRANSLATION'] = []; + } + elseif (! is_array($room['TRANSLATION'])) { + if ($room['TRANSLATION'] === true) { + $config['ROOMS'][$slug]['TRANSLATION'] = [[ + 'endpoint' => 'translated', + 'label' => 'Translated' + ]]; + } + else { + $config['ROOMS'][$slug]['TRANSLATION'] = []; + } + } + } + return $config; + } public static function getConference($mandator) { return new Conference(Conferences::loadConferenceConfig($mandator), $mandator); -- cgit v1.2.3 From 46852c4f9c77ab77b9bcc18c901f9f8640d9f305 Mon Sep 17 00:00:00 2001 From: dedeibel Date: Mon, 11 Dec 2017 19:50:55 +0100 Subject: Explained config migration with more detail --- model/Conferences.php | 67 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 28 deletions(-) (limited to 'model/Conferences.php') diff --git a/model/Conferences.php b/model/Conferences.php index eb07327..575759e 100644 --- a/model/Conferences.php +++ b/model/Conferences.php @@ -72,34 +72,45 @@ class Conferences return in_array($mandator, Conferences::listConferences()); } - public static function loadConferenceConfig($mandator) { - $configfile = forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php'; - $config = include($configfile); - - if(!is_array($config)) { - throw new ConfigException("Loading $configfile did not return an array. Maybe it's missing a return-statement?"); - } - - // Allow setting TRANSLATION simply to true and fill in default values for uniformity - $rooms = $config['ROOMS']; - foreach ($rooms as $slug => $room) { - if (!isset($room['TRANSLATION'])) { - $config['ROOMS'][$slug]['TRANSLATION'] = []; - } - elseif (! is_array($room['TRANSLATION'])) { - if ($room['TRANSLATION'] === true) { - $config['ROOMS'][$slug]['TRANSLATION'] = [[ - 'endpoint' => 'translated', - 'label' => 'Translated' - ]]; - } - else { - $config['ROOMS'][$slug]['TRANSLATION'] = []; - } - } - } - return $config; - } + private static function migrateTranslationConfiguration($config) { + // Allow setting TRANSLATION simply to true and fill in default values for uniformity + $rooms = $config['ROOMS']; + foreach ($rooms as $slug => $room) { + // Translation is commented out, equaivalent of false + if (!isset($room['TRANSLATION'])) { + $config['ROOMS'][$slug]['TRANSLATION'] = []; + } + // Translation is present but not an array + elseif (! is_array($room['TRANSLATION'])) { + // Translation is true, set default values + if ($room['TRANSLATION'] === true) { + $config['ROOMS'][$slug]['TRANSLATION'] = [[ + 'endpoint' => 'translated', + 'label' => 'Translated' + ]]; + } + // Translation is false or garbage + else { + $config['ROOMS'][$slug]['TRANSLATION'] = []; + } + } + } + + return $config; + } + + public static function loadConferenceConfig($mandator) { + $configfile = forceslash(Conferences::MANDATOR_DIR).forceslash($mandator).'config.php'; + $config = include($configfile); + + if(!is_array($config)) { + throw new ConfigException("Loading $configfile did not return an array. Maybe it's missing a return-statement?"); + } + + $config = Conferences::migrateTranslationConfiguration($config); + + return $config; + } public static function getConference($mandator) { return new Conference(Conferences::loadConferenceConfig($mandator), $mandator); -- cgit v1.2.3