Permalink
Browse files

output-custommenu MDL-25447 Fixed up the processing of the custom men…

…u removing the hard-coded single step down
  • Loading branch information...
1 parent 621df74 commit 57bedaeeeafca352053227aba91f7677381e0902 Sam Hemelryk committed Dec 2, 2010
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/outputcomponents.php
View
@@ -2342,9 +2342,13 @@ public static function convert_text_to_menu_nodes($text) {
if (preg_match('/^(\-*)/', $line, $match) && $lastchild != null && $lastdepth !== null) {
$depth = strlen($match[1]);
if ($depth < $lastdepth) {
- if ($lastdepth > 1) {
- $depth = $lastdepth - 1;
- $lastchild = $lastchild->get_parent()->get_parent()->add($bits[0], $bits[1], $bits[2], $bits[3]);
+ $difference = $lastdepth - $depth;
+ if ($lastdepth > 1 && $lastdepth != $difference) {
+ $tempchild = $lastchild->get_parent();
+ for ($i =0; $i < $difference; $i++) {
+ $tempchild = $tempchild->get_parent();
+ }
+ $lastchild = $tempchild->add($bits[0], $bits[1], $bits[2], $bits[3]);
} else {
$depth = 0;
$lastchild = new custom_menu_item($bits[0], $bits[1], $bits[2], $bits[3]);

0 comments on commit 57bedae

Please sign in to comment.