diff --git a/editor/editor_utility.php b/editor/editor_utility.php index d16a6ae80266abfae0fcc6aecc1f60627361349b..8839f1c294965ba911e6af8ede675d74960ca16d 100644 --- a/editor/editor_utility.php +++ b/editor/editor_utility.php @@ -119,40 +119,11 @@ class vpl_editor_util { </div> <div id="vpl_ide_dialog_acetheme" class="vpl_ide_dialog" style="display: none;"> <select> - <option value="chrome">Chrome</option> - <option value="clouds">Clouds</option> - <option value="crimson_editor">Crimson Editor</option> - <option value="dawn">Dawn</option> - <option value="dreamweaver">Dreamweaver</option> - <option value="eclipse">Eclipse</option> - <option value="github">GitHub</option> - <option value="iplastic">IPlastic</option> - <option value="solarized_light">Solarized Light</option> - <option value="textmate">TextMate</option> - <option value="tomorrow">Tomorrow</option> - <option value="xcode">XCode</option> - <option value="kuroir">Kuroir</option> - <option value="katzenmilch">KatzenMilch</option> - <option value="sqlserver">SQL Server</option> - <option value="ambiance">Ambiance</option> - <option value="chaos">Chaos</option> - <option value="clouds_midnight">Clouds Midnight</option> - <option value="cobalt">Cobalt</option> - <option value="idle_fingers">idle Fingers</option> - <option value="kr_theme">krTheme</option> - <option value="merbivore">Merbivore</option> - <option value="merbivore_soft">Merbivore Soft</option> - <option value="mono_industrial">Mono Industrial</option> - <option value="monokai">Monokai</option> - <option value="pastel_on_dark">Pastel on dark</option> - <option value="solarized_dark">Solarized Dark</option> - <option value="terminal">Terminal</option> - <option value="tomorrow_night">Tomorrow Night</option> - <option value="tomorrow_night_blue">Tomorrow Night Blue</option> - <option value="tomorrow_night_bright">Tomorrow Night Bright</option> - <option value="tomorrow_night_eighties">Tomorrow Night 80s</option> - <option value="twilight">Twilight</option> - <option value="vibrant_ink">Vibrant Ink</option> + <?php + foreach (self::get_installed_themes() as $theme => $name) { + echo '<option value="' . $theme . '">' . $name . '</option>'; + } + ?> </select> </div> <div id="vpl_ide_dialog_comments" class="vpl_ide_dialog" @@ -354,4 +325,37 @@ class vpl_editor_util { $options ['nexturl'] = $nexturl; $PAGE->requires->js_call_amd('mod_vpl/evaluationmonitor', 'init', array($options) ); } + + public static function get_installed_themes() { + // Search for theme files. + global $CFG; + $acefiles = array_diff(scandir($CFG->dirroot . '/mod/vpl/editor/ace9/'), array('.', '..')); + $themefiles = array_filter($acefiles, function($name) { + return substr($name, 0, 6) == 'theme-'; + }); + // Process theme files names to get displayable name, + // by replacing underscores by spaces and + // by putting upper case letters at the beginning of words. + $themes = array(); + foreach ($themefiles as $themefile) { + $theme = substr($themefile, 6, strlen($themefile) - 9); + $themename = preg_replace_callback('/(^|_)([a-z])/', function($matches) { + return ' ' . strtoupper($matches[2]); + }, $theme); + $themes[$theme] = trim($themename); + } + // Some exceptions. + $themes['github'] = 'GitHub'; + $themes['idle_fingers'] = 'idle Fingers'; + $themes['iplastic'] = 'IPlastic'; + $themes['katzenmilch'] = 'KatzenMilch'; + $themes['kr_theme'] = 'krTheme'; + $themes['kr'] = 'kr'; + $themes['pastel_on_dark'] = 'Pastel on dark'; + $themes['sqlserver'] = 'SQL Server'; + $themes['textmate'] = 'TextMate'; + $themes['tomorrow_night_eighties'] = 'Tomorrow Night 80s'; + $themes['xcode'] = 'XCode'; + return $themes; + } } diff --git a/git b/git deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/settings.php b/settings.php index 8ff8dde57104e3509922360d8376584ffe816a1e..bc98fd2ea4f153ac4113c911f58057cf5c544251 100644 --- a/settings.php +++ b/settings.php @@ -26,6 +26,7 @@ defined('MOODLE_INTERNAL') || die; require_once($CFG->dirroot . '/mod/vpl/lib.php'); +require_once($CFG->dirroot . '/mod/vpl/editor/editor_utility.php'); $kbyte = 1024; $megabyte = 1024 * $kbyte; @@ -116,47 +117,7 @@ $default = vpl_get_array_key( $list, 60 ); $settings->add( new admin_setting_configselect( $prefix . 'discard_submission_period', get_string( 'discard_submission_period', VPL ), get_string( 'discard_submission_period_description', VPL ), $default, $list ) ); -$list = array( - 'ambiance', - 'chaos', - 'chrome', - 'clouds_midnight', - 'clouds', - 'cobalt', - 'crmson_editor', - 'dawn', - 'dreamweaver', - 'eclipse', - 'github', - 'idle_fingers', - 'iplastic', - 'katzenmilch', - 'kr_theme', - 'kr', - 'kuroir', - 'merbivore_soft', - 'merbivore', - 'mono_industrial', - 'monokai', - 'pastel_on_dark', - 'solarized_dark', - 'solarized_light', - 'sqlserver', - 'terminal', - 'texmate', - 'tomorrow_night_blue', - 'tomorrow_night_bright', - 'tomorrow_night_eighties', - 'tomorrow_night', - 'tomorrow', - 'twilight', - 'vibrant_ink', - 'xcode' -); -$themelist = array(); -foreach ($list as $theme) { - $themelist [$theme] = $theme; -} + $settings->add( new admin_setting_configselect( $prefix . 'editor_theme', get_string( 'editortheme', VPL ), - get_string( 'editortheme', VPL ), 'chrome', $themelist ) ); + get_string( 'editortheme', VPL ), 'chrome', vpl_editor_util::get_installed_themes() ) );