From: Sam Hemelryk Date: Fri, 30 Oct 2009 06:20:59 +0000 (+0000) Subject: moodle_url MDL-20674 Added a method to allow the dev to set the anchor attribute... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=13b0b271723c77df514429e721f292841b0e26d8;p=moodle.git moodle_url MDL-20674 Added a method to allow the dev to set the anchor attribute of a moodle_url --- diff --git a/lib/weblib.php b/lib/weblib.php index a5f7fb6453..24927cebf8 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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; + } + } } /**