MDL-19211 reverting to old style editor preferences, the actual code that uses the...
authorPetr Skoda <skodak@moodle.org>
Sat, 10 Jul 2010 10:50:51 +0000 (10:50 +0000)
committerPetr Skoda <skodak@moodle.org>
Sat, 10 Jul 2010 10:50:51 +0000 (10:50 +0000)
admin/settings/appearance.php
admin/settings/plugins.php
lib/adminlib.php
lib/db/upgrade.php
user/editlib.php

index 65106dc..6759a2f 100644 (file)
@@ -89,38 +89,10 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
 
     $ADMIN->add('appearance', $temp);
 
-/* TODO: reimplement editor settings and preferences, editors are now full plugins ;-)
-    // "htmleditor" settingpage
-    $ADMIN->add('appearance', new admin_category('htmleditor', get_string('htmleditor', 'admin')));
-
-    $temp = new admin_settingpage('htmleditorsettings', get_string('htmleditorsettings', 'admin'));
-
-    $htmleditors = get_available_editors();
-
-    $temp->add(new admin_setting_configselect('defaulthtmleditor', get_string('defaulthtmleditor', 'admin'), null, 'tinymce', $htmleditors));
-    $temp->add(new admin_setting_configcheckbox('htmleditor', get_string('usehtmleditor', 'admin'), get_string('confightmleditor','admin'), 1));
-    $temp->add(new admin_setting_emoticons());
-    $ADMIN->add('htmleditor', $temp);
-
-
- TODO: before deleting these settings migrate or drop config values!
-    $temp = new admin_settingpage('htmlarea', get_string('htmlarea', 'admin'));
-    $temp->add(new admin_setting_configtext('editorbackgroundcolor', get_string('editorbackgroundcolor', 'admin'), get_string('edhelpbgcolor'), '#ffffff', PARAM_NOTAGS));
-    $temp->add(new admin_setting_configtext('editorfontfamily', get_string('editorfontfamily', 'admin'), get_string('edhelpfontfamily'), 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif', PARAM_NOTAGS));
-    $temp->add(new admin_setting_configtext('editorfontsize', get_string('editorfontsize', 'admin'), get_string('edhelpfontsize'), '', PARAM_NOTAGS));
-    $temp->add(new admin_setting_special_editorfontlist());
-    $temp->add(new admin_setting_configcheckbox('editorkillword', get_string('editorkillword', 'admin'), get_string('edhelpcleanword'), 1));
-    $temp->add(new admin_setting_special_editorhidebuttons());
-    $ADMIN->add('htmleditor', $temp);
-
-    $temp = new admin_settingpage('tinymce', 'TinyMCE');
-    // add tinymce configuration options here
-    $ADMIN->add('htmleditor', $temp);
-*/
-
     // "htmlsettings" settingpage
     $temp = new admin_settingpage('htmlsettings', get_string('htmlsettings', 'admin'));
     $temp->add(new admin_setting_configcheckbox('formatstringstriptags', get_string('stripalltitletags', 'admin'), get_string('configstripalltitletags', 'admin'), 1));
+    $temp->add(new admin_setting_emoticons());
     $ADMIN->add('appearance', $temp);
 
     // "documentation" settingpage
index 156c972..611ac11 100644 (file)
@@ -133,6 +133,9 @@ if ($hassiteconfig) {
     $ADMIN->add('modules', new admin_category('editorsettings', get_string('editors', 'editor')));
     $temp = new admin_settingpage('manageeditors', get_string('editorsettings', 'editor'));
     $temp->add(new admin_setting_manageeditors());
+    $htmleditors = get_available_editors();
+    $temp->add(new admin_setting_configselect('defaulthtmleditor', get_string('defaulthtmleditor', 'admin'), null, 'tinymce', $htmleditors));
+    $temp->add(new admin_setting_configcheckbox('htmleditor', get_string('usehtmleditor', 'admin'), get_string('confightmleditor','admin'), 1));
     $ADMIN->add('editorsettings', $temp);
 
     $editors_available = get_available_editors();
index e13cf50..81730ca 100644 (file)
@@ -3122,127 +3122,6 @@ class admin_setting_special_frontpagedesc extends admin_setting {
     }
 }
 
-/**
- * Special font selector for use in admin section
- *
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class admin_setting_special_editorfontlist extends admin_setting {
-
-/**
- * Construct method, calls parent::__construct with specific args
- */
-    public function __construct() {
-        global $CFG;
-        $name = 'editorfontlist';
-        $visiblename = get_string('editorfontlist', 'admin');
-        $description = get_string('configeditorfontlist', 'admin');
-        $defaults = array('k0' => 'Trebuchet',
-            'v0' => 'Trebuchet MS,Verdana,Arial,Helvetica,sans-serif',
-            'k1' => 'Arial',
-            'v1' => 'arial,helvetica,sans-serif',
-            'k2' => 'Courier New',
-            'v2' => 'courier new,courier,monospace',
-            'k3' => 'Georgia',
-            'v3' => 'georgia,times new roman,times,serif',
-            'k4' => 'Tahoma',
-            'v4' => 'tahoma,arial,helvetica,sans-serif',
-            'k5' => 'Times New Roman',
-            'v5' => 'times new roman,times,serif',
-            'k6' => 'Verdana',
-            'v6' => 'verdana,arial,helvetica,sans-serif',
-            'k7' => 'Impact',
-            'v7' => 'impact',
-            'k8' => 'Wingdings',
-            'v8' => 'wingdings');
-        parent::__construct($name, $visiblename, $description, $defaults);
-    }
-
-    /**
-     * Return the current setting
-     *
-     * @return array Array of the current setting(s)
-     */
-    public function get_setting() {
-        global $CFG;
-        $result = $this->config_read($this->name);
-        if (is_null($result)) {
-            return NULL;
-        }
-        $i = 0;
-        $currentsetting = array();
-        $items = explode(';', $result);
-        foreach ($items as $item) {
-            $item = explode(':', $item);
-            $currentsetting['k'.$i] = $item[0];
-            $currentsetting['v'.$i] = $item[1];
-            $i++;
-        }
-        return $currentsetting;
-    }
-
-    /**
-     * Save the new setting(s)
-     *
-     * @todo Add vartype handling to ensure $data is an array
-     * @param array $data Array containing the new settings
-     * @return bool
-     */
-    public function write_setting($data) {
-
-    // there miiight be an easier way to do this :)
-    // if this is changed, make sure the $defaults array above is modified so that this
-    // function processes it correctly
-
-        $keys = array();
-        $values = array();
-
-        foreach ($data as $key => $value) {
-            if (substr($key,0,1) == 'k') {
-                $keys[substr($key,1)] = $value;
-            } elseif (substr($key,0,1) == 'v') {
-                $values[substr($key,1)] = $value;
-            }
-        }
-
-        $result = array();
-        for ($i = 0; $i < count($keys); $i++) {
-            if (($keys[$i] !== '') && ($values[$i] !== '')) {
-                $result[] = clean_param($keys[$i],PARAM_NOTAGS).':'.clean_param($values[$i], PARAM_NOTAGS);
-            }
-        }
-
-        return ($this->config_write($this->name, implode(';', $result)) ? '' : get_string('errorsetting', 'admin'));
-    }
-
-    /**
-     * Returns XHTML for the options
-     *
-     * @todo Add vartype handling to ensure that $data is an array
-     * @param array $data An array of values to set
-     * @param string $query
-     * @return string XHTML
-     */
-    public function output_html($data, $query='') {
-        $fullname = $this->get_full_name();
-        $return = '<div class="form-group">';
-        for ($i = 0; $i < count($data) / 2; $i++) {
-            $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.$i.']" value="'.$data['k'.$i].'" />';
-            $return .= '&nbsp;&nbsp;';
-            $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.$i.']" value="'.$data['v'.$i].'" /><br />';
-        }
-        $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.$i.']" value="" />';
-        $return .= '&nbsp;&nbsp;';
-        $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.$i.']" value="" /><br />';
-        $return .= '<input type="text" class="form-text" name="'.$fullname.'[k'.($i + 1).']" value="" />';
-        $return .= '&nbsp;&nbsp;';
-        $return .= '<input type="text" class="form-text" name="'.$fullname.'[v'.($i + 1).']" value="" />';
-        $return .= '</div>';
-
-        return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', NULL, $query);
-    }
-
-}
 /**
  * Special settings for emoticons
  *
@@ -3399,146 +3278,6 @@ class admin_setting_emoticons extends admin_setting {
     }
 
 }
-/**
- * Used to set editor options/settings
- *
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-class admin_setting_special_editorhidebuttons extends admin_setting {
-/** @var array Array of possible options */
-    public $items;
-
-    /**
-     * Calls parent::__construct with specific options
-     */
-    public function __construct() {
-        parent::__construct('editorhidebuttons', get_string('editorhidebuttons', 'admin'),
-            get_string('confeditorhidebuttons', 'admin'), array());
-        // weird array... buttonname => buttonimage (assume proper path appended). if you leave buttomimage blank, text will be printed instead
-        $this->items = array('fontname' => '',
-            'fontsize' => '',
-            'formatblock' => '',
-            'bold' => 'ed_format_bold.gif',
-            'italic' => 'ed_format_italic.gif',
-            'underline' => 'ed_format_underline.gif',
-            'strikethrough' => 'ed_format_strike.gif',
-            'subscript' => 'ed_format_sub.gif',
-            'superscript' => 'ed_format_sup.gif',
-            'copy' => 'ed_copy.gif',
-            'cut' => 'ed_cut.gif',
-            'paste' => 'ed_paste.gif',
-            'clean' => 'ed_wordclean.gif',
-            'undo' => 'ed_undo.gif',
-            'redo' => 'ed_redo.gif',
-            'justifyleft' => 'ed_align_left.gif',
-            'justifycenter' => 'ed_align_center.gif',
-            'justifyright' => 'ed_align_right.gif',
-            'justifyfull' => 'ed_align_justify.gif',
-            'lefttoright' => 'ed_left_to_right.gif',
-            'righttoleft' => 'ed_right_to_left.gif',
-            'insertorderedlist' => 'ed_list_num.gif',
-            'insertunorderedlist' => 'ed_list_bullet.gif',
-            'outdent' => 'ed_indent_less.gif',
-            'indent' => 'ed_indent_more.gif',
-            'forecolor' => 'ed_color_fg.gif',
-            'hilitecolor' => 'ed_color_bg.gif',
-            'inserthorizontalrule' => 'ed_hr.gif',
-            'createanchor' => 'ed_anchor.gif',
-            'createlink' => 'ed_link.gif',
-            'unlink' => 'ed_unlink.gif',
-            'insertimage' => 'ed_image.gif',
-            'inserttable' => 'insert_table.gif',
-            'insertsmile' => 'em.icon.smile.gif',
-            'insertchar' => 'icon_ins_char.gif',
-            'spellcheck' => 'spell-check.gif',
-            'htmlmode' => 'ed_html.gif',
-            'popupeditor' => 'fullscreen_maximize.gif',
-            'search_replace' => 'ed_replace.gif');
-    }
-
-    /**
-     * Get an array of current settings
-     *
-     * @return array Array of current settings
-     */
-    public function get_setting() {
-        $result = $this->config_read($this->name);
-        if (is_null($result)) {
-            return NULL;
-        }
-        if ($result === '') {
-            return array();
-        }
-        return explode(' ', $result);
-    }
-
-    /**
-     * Save the selected settings
-     *
-     * @param array $data Array of settings to save
-     * @return mixed empty string, error string, or bool true=>success, false=>error
-     */
-    public function write_setting($data) {
-        if (!is_array($data)) {
-            return ''; // ignore it
-        }
-        unset($data['xxxxx']);
-        $result = array();
-
-        foreach ($data as $key => $value) {
-            if (!isset($this->items[$key])) {
-                return get_string('errorsetting', 'admin');
-            }
-            if ($value == '1') {
-                $result[] = $key;
-            }
-        }
-        return ($this->config_write($this->name, implode(' ', $result)) ? '' : get_string('errorsetting', 'admin'));
-    }
-
-    /**
-     * Return XHTML for the field and wrapping div(s)
-     *
-     * @param array $data
-     * @param string $query
-     * @return string XHTML for output
-     */
-    public function output_html($data, $query='') {
-
-        global $CFG;
-
-        // checkboxes with input name="$this->name[$key]" value="1"
-        // we do 15 fields per column
-
-        $return = '<div class="form-group">';
-        $return .= '<table><tr><td valign="top" align="right">';
-        $return .= '<input type="hidden" name="'.$this->get_full_name().'[xxxxx]" value="1" />'; // something must be submitted even if nothing selected
-
-        $count = 0;
-
-        foreach($this->items as $key => $value) {
-            if ($count % 15 == 0 and $count != 0) {
-                $return .= '</td><td valign="top" align="right">';
-            }
-
-            $return .= '<label for="'.$this->get_id().$key.'">';
-            $return .= ($value == '' ? get_string($key,'editor') : '<img width="18" height="18" src="'.$CFG->wwwroot.'/lib/editor/htmlarea/images/'.$value.'" alt="'.get_string($key,'editor').'" title="'.get_string($key,'editor').'" />').'&nbsp;';
-            $return .= '<input type="checkbox" class="form-checkbox" value="1" id="'.$this->get_id().$key.'" name="'.$this->get_full_name().'['.$key.']"'.(in_array($key,$data) ? ' checked="checked"' : '').' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
-            $return .= '</label>';
-            $count++;
-            if ($count % 15 != 0) {
-                $return .= '<br /><br />';
-            }
-        }
-
-        $return .= '</td></tr>';
-        $return .= '</table>';
-        $return .= '</div>';
-
-        return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', NULL, $query);
-    }
-}
 
 /**
  * Special setting for limiting of the list of available languages.
index ac2f945..30eac6e 100644 (file)
@@ -4701,7 +4701,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
 
     /// Launch change of precision for field city
         $dbman->change_field_precision($table, $field);
-        
+
     /// Conditionally launch add index typeitem_ix
         if (!$dbman->index_exists($table, $index)) {
             $dbman->add_index($table, $index);
@@ -4710,6 +4710,18 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         upgrade_main_savepoint(true, 2010070801);
     }
 
+    if ($oldversion < 2010070900) {
+        //purge unused editor settings
+        unset_config('editorbackgroundcolor');
+        unset_config('editorfontfamily');
+        unset_config('editorfontsize');
+        unset_config('editorkillword');
+        unset_config('editorhidebuttons');
+        unset_config('editorfontlist');
+
+        upgrade_main_savepoint(true, 2010070900);
+    }
+
     return true;
 }
 
index b84fdce..e296b9f 100644 (file)
@@ -127,7 +127,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
     $choices['0'] = get_string('textformat');
     $choices['1'] = get_string('htmlformat');
     $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
-    $mform->setDefault('mailformat', 1);    
+    $mform->setDefault('mailformat', 1);
 
     if (!empty($CFG->allowusermailcharset)) {
         $choices = array();
@@ -138,7 +138,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
             $choices['0'] = get_string('site').' (UTF-8)';
         }
         $choices = array_merge($choices, $charsets);
-        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);        
+        $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
     }
 
     $choices = array();
@@ -161,7 +161,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
         $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
         $mform->setDefault('trackforums', 0);
     }
-/* TODO: reimplement editor preferences
+
     if (!empty($CFG->htmleditor)) {
         $choices = array();
         $choices['0'] = get_string('texteditor');
@@ -169,7 +169,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
         $mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
         $mform->setDefault('htmleditor', 1);
     }
-*/
+
     if (empty($CFG->enableajax)) {
         $mform->addElement('static', 'ajaxdisabled', get_string('ajaxuse'), get_string('ajaxno'));
     } else {
@@ -221,7 +221,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
                 $choices[$key] = $theme->name;
             }
         }
-        $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);        
+        $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
     }
 
     $mform->addElement('editor', 'description_editor', get_string('userdescription'), null, $editoroptions);
@@ -251,7 +251,7 @@ function useredit_shared_definition(&$mform, $editoroptions = null) {
     }
 
     /// Moodle optional fields
-    $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));   
+    $mform->addElement('header', 'moodle_optional', get_string('optional', 'form'));
 
     $mform->addElement('text', 'url', get_string('webpage'), 'maxlength="255" size="50"');
     $mform->setType('url', PARAM_URL);