Merge branch 'w35_MDL-34878_m24_tinymcebuttons' of git://github.com/skodak/moodle
authorAparup Banerjee <aparup@moodle.com>
Tue, 28 Aug 2012 07:00:26 +0000 (15:00 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 28 Aug 2012 07:00:26 +0000 (15:00 +0800)
lib/editor/tinymce/lang/en/editor_tinymce.php
lib/editor/tinymce/lib.php
lib/editor/tinymce/settings.php

index 1563b2e..2fbb512 100644 (file)
@@ -26,6 +26,8 @@
 //== Custom Moodle strings that are not part of upstream TinyMCE ==
 $string['common:browseimage'] = 'Find or upload an image...';
 $string['common:browsemedia'] = 'Find or upload a sound, video or applet...';
+$string['customtoolbar'] = 'Custom editor toolbar';
+$string['customtoolbar_desc'] = 'Each line contains a list of comma separated button names, use "|" as a group separator. Leave empty if you want standard toolbar.';
 $string['fontselectlist'] = 'Available fonts list';
 $string['media_dlg:filename'] = 'Filename';
 $string['pluginname'] = 'TinyMCE HTML editor';
index 2ef3db1..ac25047 100644 (file)
@@ -190,6 +190,25 @@ class tinymce_texteditor extends texteditor {
         // Allow plugins to adjust parameters.
         editor_tinymce_plugin::all_update_init_params($params, $context, $options);
 
+        // Should we override the default toolbar layout unconditionally?
+        $customtoolbar = trim($config->customtoolbar);
+        if ($customtoolbar) {
+            unset($params['theme_advanced_buttons1']);
+            unset($params['theme_advanced_buttons2']);
+            unset($params['theme_advanced_buttons3']);
+            unset($params['theme_advanced_buttons4']);
+            $customtoolbar = str_replace("\r", "\n", $customtoolbar);
+            $i = 1;
+            foreach (explode("\n", $customtoolbar) as $line) {
+                $line = preg_replace('/\s/', '', $line);
+                if ($line === '') {
+                    continue;
+                }
+                $params['theme_advanced_buttons'.$i] = $line;
+                $i++;
+            }
+        }
+
         // Remove temporary parameters.
         unset($params['moodle_config']);
 
index 461e62f..45c1bc8 100644 (file)
@@ -28,6 +28,8 @@ $ADMIN->add('editorsettings', new admin_category('editortinymce', new lang_strin
 
 $settings = new admin_settingpage('editorsettingstinymce', new lang_string('settings', 'editor_tinymce'));
 if ($ADMIN->fulltree) {
+    $settings->add(new admin_setting_configtextarea('editor_tinymce/customtoolbar',
+        get_string('customtoolbar', 'editor_tinymce'), get_string('customtoolbar_desc', 'editor_tinymce'), '', PARAM_RAW, 100, 6));
     $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));