Skip to content
Permalink
Browse files

Merge branch 'w51_MDL-37186_m24_tinymceconfig' of git://github.com/sk…

…odak/moodle into MOODLE_24_STABLE
  • Loading branch information...
stronk7 committed Jan 8, 2013
2 parents 793c431 + 544f0f9 commit 0f83a143b0d93d7b6ce523fcbc8513a24d0449d1
@@ -246,3 +246,30 @@ public function output_html($data, $query='') {
return highlight($query, $return);
}
}
class editor_tinymce_json_setting_textarea extends admin_setting_configtextarea {
/**
* Returns an XHTML string for the editor
*
* @param string $data
* @param string $query
* @return string XHTML string for the editor
*/
public function output_html($data, $query='') {
$result = parent::output_html($data, $query);
$data = trim($data);
if ($data) {
$decoded = json_decode($data, true);
// Note: it is not very nice to abuse these file classes, but anyway...
if (is_array($decoded)) {
$valid = '<span class="pathok">&#x2714;</span>';
} else {
$valid = '<span class="patherror">&#x2718;</span>';
}
$result = str_replace('</textarea>', '</textarea>'.$valid, $result);
}
return $result;
}
}
@@ -27,6 +27,8 @@
//== Custom Moodle strings that are not part of upstream TinyMCE ==
$string['availablebuttons'] = 'Available buttons';
$string['customconfig'] = 'Custom configuration';
$string['customconfig_desc'] = 'Custom advanced TinyMCE configuration in JSON format, for example: {"option1" : "value2", "option2" : "value2"}. Any options specified here override standard and plugin settings.';
$string['customtoolbar'] = 'Editor toolbar';
$string['customtoolbar_desc'] = 'Each line contains a list of comma separated button names, use "|" as a group separator, empty lines are ignored. See <a href="{$a}" target="_blank">{$a}</a> for the list of default TinyMCE buttons.';
$string['fontselectlist'] = 'Available fonts list';
@@ -184,6 +184,16 @@ protected function get_init_params($elementid, array $options=null) {
$params['theme_advanced_buttons1'] = '';
}
if (!empty($config->customconfig)) {
$config->customconfig = trim($config->customconfig);
$decoded = json_decode($config->customconfig, true);
if (is_array($decoded)) {
foreach ($decoded as $k=>$v) {
$params[$k] = $v;
}
}
}
if (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted'])) {
// now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
// but they scream even more when we strip all tags that are not strict :-(
@@ -40,7 +40,9 @@
get_string('customtoolbar', 'editor_tinymce'), get_string('customtoolbar_desc', 'editor_tinymce', 'http://www.tinymce.com/wiki.php/Buttons/controls'), $default, PARAM_RAW, 100, 8));
$settings->add(new admin_setting_configtextarea('editor_tinymce/fontselectlist',
get_string('fontselectlist', 'editor_tinymce'), '',
'Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings', PARAM_RAW));
'Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings', PARAM_RAW, 100, 8));
$settings->add(new editor_tinymce_json_setting_textarea('editor_tinymce/customconfig',
get_string('customconfig', 'editor_tinymce'), get_string('customconfig_desc', 'editor_tinymce'), '', PARAM_RAW, 100, 8));
}
$ADMIN->add('editortinymce', $settings);
unset($settings);

0 comments on commit 0f83a14

Please sign in to comment.
You can’t perform that action at this time.