MDL-23646 tinymce: Add upgrade algorithm for custom toolbars.
This commit is contained in:
@@ -88,30 +88,32 @@ fontselect,fontsizeselect,wrap,code,search,replace,|,cleanup,removeformat,pastet
|
||||
set_config('customtoolbar', $neworder, 'editor_tinymce');
|
||||
} else {
|
||||
// Simple auto conversion algorithm.
|
||||
$toolbars = explode($oldorder, "\n");
|
||||
$toolbars = explode("\n", $oldorder);
|
||||
$newtoolbars = array();
|
||||
foreach ($toolbars as $toolbar) {
|
||||
$sepcount = substr_count($toolbar, '|');
|
||||
|
||||
if ($sepcount > 0) {
|
||||
// We assume the middle separator (rounding down).
|
||||
$divisionindex = $sepcount / 2;
|
||||
$divisionindex = round($sepcount / 2, 0, PHP_ROUND_HALF_DOWN);
|
||||
|
||||
$buttons = explode($toolbar, ',');
|
||||
$buttons = explode(',', $toolbar);
|
||||
$index = 0;
|
||||
foreach ($buttons as $key => $button) {
|
||||
if ($button === "|") {
|
||||
if ($index == $divisionindex) {
|
||||
$buttons[$key] = 'wrap';
|
||||
break;
|
||||
} else {
|
||||
$index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$toolbar = implode($buttons, ',');
|
||||
$toolbar = implode(',', $buttons);
|
||||
}
|
||||
array_push($newtoolbars, $toolbar);
|
||||
}
|
||||
$neworder = implode($newtoolbars, "\n");
|
||||
$neworder = implode("\n", $newtoolbars);
|
||||
|
||||
// Set the new config.
|
||||
unset_config('customtoolbar', 'editor_tinymce');
|
||||
|
||||
Reference in New Issue
Block a user