From 650a44fc268ea61332ea5dc674fb3efdb0dd1260 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 5 Jul 2013 13:52:59 +0800 Subject: [PATCH] MDL-23646 tinymce: Add upgrade algorithm for custom toolbars. --- lib/editor/tinymce/db/upgrade.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/editor/tinymce/db/upgrade.php b/lib/editor/tinymce/db/upgrade.php index a44bef88c43..8487e9cf972 100644 --- a/lib/editor/tinymce/db/upgrade.php +++ b/lib/editor/tinymce/db/upgrade.php @@ -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');