From 6e1654b79bb811cb2779c544532e2ad240410e2e Mon Sep 17 00:00:00 2001 From: Henning Bostelmann Date: Mon, 9 Nov 2015 23:22:53 +0000 Subject: [PATCH] MDL-52086 output renderers: show subtree only when tab is activated --- lib/outputrenderers.php | 48 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 075d6004c51..a91fa527996 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -3660,32 +3660,34 @@ EOD; return $str; } - // Print subtree - $str .= html_writer::start_tag('ul', array('class' => 'tabrow'. $tabobject->level)); - $cnt = 0; - foreach ($tabobject->subtree as $tab) { - $liclass = ''; - if (!$cnt) { - $liclass .= ' first'; - } - if ($cnt == count($tabobject->subtree) - 1) { - $liclass .= ' last'; - } - if ((empty($tab->subtree)) && (!empty($tab->selected))) { - $liclass .= ' onerow'; - } + // Print subtree. + if ($tabobject->level == 0 || $tabobject->selected || $tabobject->activated) { + $str .= html_writer::start_tag('ul', array('class' => 'tabrow'. $tabobject->level)); + $cnt = 0; + foreach ($tabobject->subtree as $tab) { + $liclass = ''; + if (!$cnt) { + $liclass .= ' first'; + } + if ($cnt == count($tabobject->subtree) - 1) { + $liclass .= ' last'; + } + if ((empty($tab->subtree)) && (!empty($tab->selected))) { + $liclass .= ' onerow'; + } - if ($tab->selected) { - $liclass .= ' here selected'; - } else if ($tab->activated) { - $liclass .= ' here active'; - } + if ($tab->selected) { + $liclass .= ' here selected'; + } else if ($tab->activated) { + $liclass .= ' here active'; + } - // This will recursively call function render_tabobject() for each item in subtree - $str .= html_writer::tag('li', $this->render($tab), array('class' => trim($liclass))); - $cnt++; + // This will recursively call function render_tabobject() for each item in subtree. + $str .= html_writer::tag('li', $this->render($tab), array('class' => trim($liclass))); + $cnt++; + } + $str .= html_writer::end_tag('ul'); } - $str .= html_writer::end_tag('ul'); return $str; }