Skip to content

Commit

Permalink
moodle_page: MDL-12212 ->subpage field
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhunt committed May 6, 2009
1 parent 5ec434a commit 5ed7053
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class moodle_page {

protected $_pagetype = null;

protected $_subpage = null;

protected $_docspath = null;

protected $_legacyclass = null;
Expand Down Expand Up @@ -224,6 +226,13 @@ public function get_pagetype() {
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.
*/
Expand Down Expand Up @@ -426,6 +435,16 @@ public function set_pagetype($pagetype) {
$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.
*/
Expand Down
7 changes: 7 additions & 0 deletions lib/simpletest/testpagelib_moodlepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,13 @@ public function test_set_url_does_not_change_explicit_page_type() {
// 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);
}
}

/**
Expand Down

0 comments on commit 5ed7053

Please sign in to comment.