From 13b0b271723c77df514429e721f292841b0e26d8 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 30 Oct 2009 06:20:59 +0000 Subject: [PATCH] moodle_url MDL-20674 Added a method to allow the dev to set the anchor attribute of a moodle_url --- lib/weblib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; + } + } } /** -- 2.39.5