]> git.mjollnir.org Git - moodle.git/commitdiff
moodle_page: MDL-12212 ->subpage field
authortjhunt <tjhunt>
Wed, 6 May 2009 09:03:49 +0000 (09:03 +0000)
committertjhunt <tjhunt>
Wed, 6 May 2009 09:03:49 +0000 (09:03 +0000)
lib/pagelib.php
lib/simpletest/testpagelib_moodlepage.php

index 2b744d8a1b894b7df7720db823a0c5ed707a3d9e..e623fed27ccafc627b47f9c2b1719826837ed1ad 100644 (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.
      */
index e6abd33ba0ac716d4dd01cdaa980c3336536eb63..4c69a8b0d28535ed60adbe7e9b723643f7c17083 100644 (file)
@@ -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);
+    }
 }
 
 /**