]> git.mjollnir.org Git - moodle.git/commitdiff
moodle_url MDL-20674 Added a method to allow the dev to set the anchor attribute...
authorSam Hemelryk <sam@moodle.com>
Fri, 30 Oct 2009 06:20:59 +0000 (06:20 +0000)
committerSam Hemelryk <sam@moodle.com>
Fri, 30 Oct 2009 06:20:59 +0000 (06:20 +0000)
lib/weblib.php

index a5f7fb6453975c7cf772074b16d5ae60022aa096..24927cebf8e21c4e0f238408bcfff5e43aee5260 100644 (file)
@@ -548,6 +548,17 @@ class moodle_url {
 
         return true;
     }
+
+    /**
+     * Sets the anchor for the URI (the bit after the hash)
+     * @param string $anchor
+     */
+    public function set_anchor($anchor) {
+        // Match the anchor against the NMTOKEN spec
+        if (preg_match('#[a-zA-Z\_\:][a-zA-Z0-9\_\-\.\:]*#', $anchor)) {
+            $this->fragment = $anchor;
+        }
+    }
 }
 
 /**