[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * TinyMCE editor integration upgrade. 19 * 20 * @package editor_tinymce 21 * @copyright 2012 Petr Skoda {@link http://skodak.org} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 function xmldb_editor_tinymce_upgrade($oldversion) { 28 global $CFG, $DB; 29 30 $dbman = $DB->get_manager(); 31 32 33 if ($oldversion < 2012083100) { 34 // Reset redesigned editor toolbar setting. 35 unset_config('customtoolbar', 'editor_tinymce'); 36 upgrade_plugin_savepoint(true, 2012083100, 'editor', 'tinymce'); 37 } 38 39 40 // Moodle v2.4.0 release upgrade line 41 // Put any upgrade step following this 42 43 44 // Moodle v2.5.0 release upgrade line. 45 // Put any upgrade step following this. 46 47 if ($oldversion < 2013061400) { 48 // Reset redesigned editor toolbar setting. 49 $oldorder = "fontselect,fontsizeselect,formatselect,|,undo,redo,|,search,replace,|,fullscreen 50 51 bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl 52 53 bullist,numlist,outdent,indent,|,link,unlink,|,image,nonbreaking,charmap,table,|,code"; 54 55 $neworder = "formatselect,bold,italic,|,bullist,numlist,|,link,unlink,|,image 56 57 undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table 58 59 fontselect,fontsizeselect,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen"; 60 $currentorder = get_config('editor_tinymce', 'customtoolbar'); 61 if ($currentorder == $oldorder) { 62 unset_config('customtoolbar', 'editor_tinymce'); 63 set_config('customtoolbar', $neworder, 'editor_tinymce'); 64 } 65 upgrade_plugin_savepoint(true, 2013061400, 'editor', 'tinymce'); 66 } 67 68 if ($oldversion < 2013070500) { 69 // Insert wrap plugin to nicely wrap the toolbars on small screens. 70 $oldorder = "formatselect,bold,italic,|,bullist,numlist,|,link,unlink,|,image 71 72 undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,|,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table 73 74 fontselect,fontsizeselect,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen"; 75 76 $neworder = "formatselect,bold,italic,wrap,bullist,numlist,|,link,unlink,|,image 77 78 undo,redo,|,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,wrap,outdent,indent,|,forecolor,backcolor,|,ltr,rtl,|,nonbreaking,charmap,table 79 80 fontselect,fontsizeselect,wrap,code,search,replace,|,cleanup,removeformat,pastetext,pasteword,|,fullscreen"; 81 $currentorder = get_config('editor_tinymce', 'customtoolbar'); 82 if ($currentorder == $oldorder) { 83 unset_config('customtoolbar', 'editor_tinymce'); 84 set_config('customtoolbar', $neworder, 'editor_tinymce'); 85 } else { 86 // Simple auto conversion algorithm. 87 $toolbars = explode("\n", $oldorder); 88 $newtoolbars = array(); 89 foreach ($toolbars as $toolbar) { 90 $sepcount = substr_count($toolbar, '|'); 91 92 if ($sepcount > 0) { 93 // We assume the middle separator (rounding down). 94 $divisionindex = round($sepcount / 2, 0, PHP_ROUND_HALF_DOWN); 95 96 $buttons = explode(',', $toolbar); 97 $index = 0; 98 foreach ($buttons as $key => $button) { 99 if ($button === "|") { 100 if ($index == $divisionindex) { 101 $buttons[$key] = 'wrap'; 102 break; 103 } else { 104 $index += 1; 105 } 106 } 107 } 108 $toolbar = implode(',', $buttons); 109 } 110 array_push($newtoolbars, $toolbar); 111 } 112 $neworder = implode("\n", $newtoolbars); 113 114 // Set the new config. 115 unset_config('customtoolbar', 'editor_tinymce'); 116 set_config('customtoolbar', $neworder, 'editor_tinymce'); 117 } 118 upgrade_plugin_savepoint(true, 2013070500, 'editor', 'tinymce'); 119 } 120 121 if ($oldversion < 2013102900) { 122 // Reset redesigned editor toolbar setting. 123 $currentorder = get_config('editor_tinymce', 'customtoolbar'); 124 // Start with a wrap. 125 $neworder = "wrap,". $currentorder; 126 // Replace all separators with wraps to allow for proper display of groups. 127 $neworder = preg_replace('/\|\|*/', "wrap", $neworder); 128 // Insert a wrap between the format selector and the bold button. 129 $neworder = str_replace("formatselect,bold", "formatselect,wrap,bold", $neworder); 130 set_config('customtoolbar', $neworder, 'editor_tinymce'); 131 upgrade_plugin_savepoint(true, 2013102900, 'editor', 'tinymce'); 132 } 133 134 if ($oldversion < 2013110600) { 135 // Reset redesigned editor toolbar setting. 136 $currentorder = get_config('editor_tinymce', 'customtoolbar'); 137 $olddefaultorder = "wrap,formatselect,wrap,bold,italic,wrap,bullist,numlist,wrap,link,unlink,wrap,image 138 139 undo,redo,wrap,underline,strikethrough,sub,sup,wrap,justifyleft,justifycenter,justifyright,wrap,outdent,indent,wrap,forecolor,backcolor,wrap,ltr,rtl,wrap,nonbreaking,charmap,table 140 141 fontselect,fontsizeselect,wrap,code,search,replace,wrap,cleanup,removeformat,pastetext,pasteword,wrap,fullscreen"; 142 $neworder = "wrap,formatselect,wrap,bold,italic,wrap,bullist,numlist,wrap,link,unlink,wrap,image 143 144 undo,redo,wrap,underline,strikethrough,sub,sup,wrap,justifyleft,justifycenter,justifyright,wrap,outdent,indent,wrap,forecolor,backcolor,wrap,ltr,rtl 145 146 fontselect,fontsizeselect,wrap,code,search,replace,wrap,nonbreaking,charmap,table,wrap,cleanup,removeformat,pastetext,pasteword,wrap,fullscreen"; 147 if ($currentorder == $olddefaultorder) { 148 set_config('customtoolbar', $neworder, 'editor_tinymce'); 149 } 150 151 upgrade_plugin_savepoint(true, 2013110600, 'editor', 'tinymce'); 152 } 153 154 // Moodle v2.6.0 release upgrade line. 155 // Put any upgrade step following this. 156 157 158 // Moodle v2.7.0 release upgrade line. 159 // Put any upgrade step following this. 160 161 if ($oldversion < 2014062900) { 162 // We only want to delete DragMath from the customtoolbar setting if the directory no longer exists. If 163 // the directory is present then it means it has been restored, so do not remove any settings. 164 if (!check_dir_exists($CFG->libdir . '/editor/tinymce/plugins/dragmath', false)) { 165 // Remove the DragMath plugin from the 'customtoolbar' setting (if it exists) as it has been removed. 166 $currentorder = get_config('editor_tinymce', 'customtoolbar'); 167 $newtoolbarrows = array(); 168 $currenttoolbarrows = explode("\n", $currentorder); 169 foreach ($currenttoolbarrows as $currenttoolbarrow) { 170 $currenttoolbarrow = implode(',', array_diff(str_getcsv($currenttoolbarrow), array('dragmath'))); 171 $newtoolbarrows[] = $currenttoolbarrow; 172 } 173 $neworder = implode("\n", $newtoolbarrows); 174 unset_config('customtoolbar', 'editor_tinymce'); 175 set_config('customtoolbar', $neworder, 'editor_tinymce'); 176 } 177 178 upgrade_plugin_savepoint(true, 2014062900, 'editor', 'tinymce'); 179 } 180 181 // Moodle v2.8.0 release upgrade line. 182 // Put any upgrade step following this. 183 184 return true; 185 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |