moodle_page: MDL-12212 ->subpage field

This commit is contained in:
tjhunt
2009-05-06 09:03:49 +00:00
parent 5ec434a9c2
commit 5ed70539f9
2 changed files with 26 additions and 0 deletions
+19
View File
@@ -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.
*/
@@ -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);
}
}
/**