From 5d0cc05b2054e1efa412f769d2d6a19b1d3b12b3 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Mon, 19 Jun 2017 15:17:48 +0800 Subject: [PATCH] MDL-59277 navigation: add support for container type in get_css_type() --- lib/navigationlib.php | 4 +++- lib/tests/navigationlib_test.php | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/navigationlib.php b/lib/navigationlib.php index da9cb842abc..280b1191be8 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -134,7 +134,9 @@ class navigation_node implements renderable { /** @var bool Set to true if we KNOW that this node can be expanded. */ public $isexpandable = false; /** @var array */ - protected $namedtypes = array(0=>'system',10=>'category',20=>'course',30=>'structure',40=>'activity',50=>'resource',60=>'custom',70=>'setting',71=>'siteadmin', 80=>'user'); + protected $namedtypes = array(0 => 'system', 10 => 'category', 20 => 'course', 30 => 'structure', 40 => 'activity', + 50 => 'resource', 60 => 'custom', 70 => 'setting', 71 => 'siteadmin', 80 => 'user', + 90 => 'container'); /** @var moodle_url */ protected static $fullmeurl = null; /** @var bool toogles auto matching of active node */ diff --git a/lib/tests/navigationlib_test.php b/lib/tests/navigationlib_test.php index 085e7d9eef4..0848ee8effa 100644 --- a/lib/tests/navigationlib_test.php +++ b/lib/tests/navigationlib_test.php @@ -56,6 +56,7 @@ class core_navigationlib_testcase extends advanced_testcase { $demo4 = $demo3->add('demo4', $inactiveurl, navigation_node::TYPE_COURSE, null, 'demo4', new pix_icon('i/course', '')); $demo5 = $demo3->add('demo5', $activeurl, navigation_node::TYPE_COURSE, null, 'demo5', new pix_icon('i/course', '')); $demo5->add('activity1', null, navigation_node::TYPE_ACTIVITY, null, 'activity1')->make_active(); + $demo6 = $demo3->add('demo6', null, navigation_node::TYPE_CONTAINER, 'container node test', 'demo6'); $hiddendemo1 = $this->node->add('hiddendemo1', $inactiveurl, navigation_node::TYPE_CATEGORY, null, 'hiddendemo1', new pix_icon('i/course', '')); $hiddendemo1->hidden = true; $hiddendemo1->add('hiddendemo2', $inactiveurl, navigation_node::TYPE_COURSE, null, 'hiddendemo2', new pix_icon('i/course', ''))->helpbutton = 'Here is a help button'; @@ -239,9 +240,11 @@ class core_navigationlib_testcase extends advanced_testcase { $csstype2 = $this->node->get('demo3')->get('demo5')->get_css_type(); $this->node->get('demo3')->get('demo5')->type = 1000; $csstype3 = $this->node->get('demo3')->get('demo5')->get_css_type(); + $csstype4 = $this->node->get('demo3')->get('demo6')->get_css_type(); $this->assertSame('type_category', $csstype1); $this->assertSame('type_course', $csstype2); $this->assertSame('type_unknown', $csstype3); + $this->assertSame('type_container', $csstype4); } public function test_node_make_active() {