From: tjhunt Date: Wed, 6 May 2009 09:03:49 +0000 (+0000) Subject: moodle_page: MDL-12212 ->subpage field X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5ed70539f990493f32812d0935ff2faacad0d47e;p=moodle.git moodle_page: MDL-12212 ->subpage field --- diff --git a/lib/pagelib.php b/lib/pagelib.php index 2b744d8a1b..e623fed27c 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -88,6 +88,8 @@ class moodle_page { protected $_pagetype = null; + protected $_subpage = null; + protected $_docspath = null; protected $_legacyclass = null; @@ -224,6 +226,13 @@ class moodle_page { return $this->_pagetype; } + /** + * @return string|null The subpage identifier, if any. + */ + public function get_subpage() { + return $this->_subpage; + } + /** * @return string the class names to put on the body element in the HTML. */ @@ -426,6 +435,16 @@ class moodle_page { $this->_pagetype = $pagetype; } + /** + * If context->id and pagetype are not enough to uniquely identify this page, + * then you can set a subpage id as well. For example, the tags page sets + * @param string $subpage an arbitrary identifier that, along with context->id + * and pagetype, uniquely identifies this page. + */ + public function set_subpage($subpage) { + $this->_subpage = $subpage; + } + /** * @param string $class add this class name ot the class attribute on the body tag. */ diff --git a/lib/simpletest/testpagelib_moodlepage.php b/lib/simpletest/testpagelib_moodlepage.php index e6abd33ba0..4c69a8b0d2 100644 --- a/lib/simpletest/testpagelib_moodlepage.php +++ b/lib/simpletest/testpagelib_moodlepage.php @@ -314,6 +314,13 @@ class moodle_page_test extends UnitTestCase { // Validate $this->assertEqual('a-page-type', $this->testpage->pagetype); } + + public function test_set_subpage() { + // Exercise SUT + $this->testpage->set_subpage('somestring'); + // Validate + $this->assertEqual('somestring', $this->testpage->subpage); + } } /**