]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19756
authornicolasconnault <nicolasconnault>
Thu, 13 Aug 2009 01:15:58 +0000 (01:15 +0000)
committernicolasconnault <nicolasconnault>
Thu, 13 Aug 2009 01:15:58 +0000 (01:15 +0000)
* Removed outputpixfinders.php and put that code back in outputlib.php
* Created labelled_html_component class and subclassed all appropriate components from it
* Added component::add_confirm_action($message) as a shortcut for adding a confirmation popup
* Fixed bug in close_window_button()

lib/deprecatedlib.php
lib/javascript-static.js
lib/outputcomponents.php
lib/outputlib.php
lib/outputpixfinders.php [deleted file]
lib/outputrenderers.php
lib/weblib.php

index bdd238de481a7842f5f5cdd17607ebcd22933cbe..4b08d911ffa38d7bebf45987fba1a4e8e0c1201e 100644 (file)
@@ -2901,7 +2901,7 @@ function print_arrow($direction='up', $strsort=null, $return=false) {
 function doc_link($path='', $text='', $iconpath='') {
     global $CFG, $OUTPUT;
 
-    // debugging('doc_link() has been deprecated. Please change your code to use $OUTPUT->action_icon().');
+    // debugging('doc_link() has been deprecated. Please change your code to use $OUTPUT->doc_link().');
 
     if (empty($CFG->docroot)) {
         return '';
index c8581d6539e5ca1d3fd532d3988a2d726964c3ba..98e86ebad472c887e99a922d91b9f89c1ee46c75 100644 (file)
@@ -1041,8 +1041,9 @@ block_hider.prototype.update_state = function () {
 }
 
 /** Close the current browser window. */
-function close_window() {
-    window.close();
+function close_window(e) {
+    YAHOO.util.Event.preventDefault(e);
+    self.close();
 }
 
 /**
index f9d1431f9876d000834515650a5fee423a19a7f7..8953056ec987e141d4690d41471b3c5256e232cb 100644 (file)
@@ -48,10 +48,6 @@ class moodle_html_component {
      * @var string $style value to use for the style attribute of this HTML tag.
      */
     public $style = '';
-    /**
-     * @var mixed $label The label for that component. String or html_label object
-     */
-    public $label;
     /**
      * @var array class names to add to this HTML element.
      */
@@ -191,6 +187,23 @@ class moodle_html_component {
         return $this->actions;
     }
 
+    /**
+     * Shortcut for adding a JS confirm dialog when the component is clicked.
+     * The message must be a yes/no question.
+     * @param string $message The yes/no confirmation question. If "Yes" is clicked, the original action will occur.
+     * @return void
+     */
+    public function add_confirm_action($message) {
+        $this->add_action(new component_action('click', 'confirm_dialog', array('message' => $message)));
+    }
+}
+
+class labelled_html_component extends moodle_html_component {
+    /**
+     * @var mixed $label The label for that component. String or html_label object
+     */
+    public $label;
+
     /**
      * Adds a descriptive label to the component.
      *
@@ -225,16 +238,6 @@ class moodle_html_component {
             $this->label->text = $text;
         }
     }
-
-    /**
-     * Shortcut for adding a JS confirm dialog when the component is clicked.
-     * The message must be a yes/no question.
-     * @param string $message The yes/no confirmation question. If "Yes" is clicked, the original action will occur.
-     * @return void
-     */
-    public function add_confirm_action($message) {
-        $this->add_action(new component_action('click', 'confirm_dialog', array('message' => $message)));
-    }
 }
 
 /// Components representing HTML elements
@@ -284,7 +287,7 @@ class html_label extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_select extends moodle_html_component {
+class html_select extends labelled_html_component {
     /**
      * The html_select object parses an array of options into component objects
      * @see nested attribute
@@ -735,7 +738,7 @@ class html_select extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_select_option extends moodle_html_component {
+class html_select_option extends labelled_html_component {
     /**
      * @var string $value The value of this option (will be sent with form)
      */
@@ -782,7 +785,7 @@ class html_select_option extends moodle_html_component {
      * @param string $alt
      * @return html_select_option A component ready for $OUTPUT->checkbox()
      */
-    public function make_checkbox($value, $checked, $label='', $alt='') {
+    public function make_checkbox($value, $checked, $label, $alt='') {
         $checkbox = new html_select_option();
         $checkbox->value = $value;
         $checkbox->selected = $checked;
@@ -828,7 +831,7 @@ class html_select_optgroup extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_field extends moodle_html_component {
+class html_field extends labelled_html_component {
     /**
      * @var string $name The name attribute of the field
      */
@@ -900,7 +903,7 @@ class html_field extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_table extends moodle_html_component {
+class html_table extends labelled_html_component {
     /**
      * @var array of headings. The n-th array item is used as a heading of the n-th column.
      *
@@ -1216,7 +1219,7 @@ class html_link extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_button extends moodle_html_component {
+class html_button extends labelled_html_component {
     /**
      * @var string $text
      */
@@ -1253,7 +1256,7 @@ class html_button extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class html_image extends moodle_html_component {
+class html_image extends labelled_html_component {
     /**
      * @var string $alt A descriptive text
      */
@@ -1813,7 +1816,7 @@ class moodle_user_picture extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class moodle_help_icon extends moodle_html_component {
+class moodle_help_icon extends labelled_html_component {
     /**
      * @var html_link $link A html_link object that will hold the URL info
      */
@@ -1943,7 +1946,7 @@ class moodle_help_icon extends moodle_html_component {
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since     Moodle 2.0
  */
-class moodle_action_icon extends moodle_html_component {
+class moodle_action_icon extends labelled_html_component {
     /**
      * @var string $linktext Optional text to display next to the icon
      */
@@ -1973,6 +1976,13 @@ class moodle_action_icon extends moodle_html_component {
     public function prepare() {
         $this->image->add_class('action-icon');
 
+        if (!empty($this->actions)) {
+            foreach ($this->actions as $action) {
+                $this->link->add_action($action);
+            }
+            unset($this->actions);
+        }
+
         parent::prepare();
 
         if (empty($this->image->src)) {
index aa4eb64ea75274e7ea4bdf030d65615318af7ec5..6a8e05fb892f71413f3c650a99ae3b1c9a2af3d4 100644 (file)
@@ -26,7 +26,6 @@ define('HTML_ATTR_EMPTY', '@EMPTY@');
 require_once($CFG->libdir.'/outputcomponents.php');
 require_once($CFG->libdir.'/outputactions.php');
 require_once($CFG->libdir.'/outputfactories.php');
-require_once($CFG->libdir.'/outputpixfinders.php');
 require_once($CFG->libdir.'/outputrenderers.php');
 
 /**
@@ -889,6 +888,198 @@ class xhtml_container_stack {
     }
 }
 
+/**
+ * An icon finder is responsible for working out the correct URL for an icon.
+ *
+ * A icon finder must also have a constructor that takes a theme object.
+ * (See {@link standard_icon_finder::__construct} for an example.)
+ *
+ * Note that we are planning to change the Moodle icon naming convention before
+ * the Moodle 2.0 release. Therefore, this API will probably change.
+ *
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+interface icon_finder {
+    /**
+     * Return the URL for an icon identified as in pre-Moodle 2.0 code.
+     *
+     * Suppose you have old code like $url = "$CFG->pixpath/i/course.gif";
+     * then old_icon_url('i/course'); will return the equivalent URL that is correct now.
+     *
+     * @param string $iconname the name of the icon.
+     * @return string the URL for that icon.
+     */
+    public function old_icon_url($iconname);
+
+    /**
+     * Return the URL for an icon identified as in pre-Moodle 2.0 code.
+     *
+     * Suppose you have old code like $url = "$CFG->modpixpath/$mod/icon.gif";
+     * then mod_icon_url('icon', $mod); will return the equivalent URL that is correct now.
+     *
+     * @param string $iconname the name of the icon.
+     * @param string $module the module the icon belongs to.
+     * @return string the URL for that icon.
+     */
+    public function mod_icon_url($iconname, $module);
+}
+
+/**
+ * This icon finder implements the old scheme that was used when themes that had
+ * $THEME->custompix = false.
+ *
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class pix_icon_finder implements icon_finder {
+    /**
+     * Constructor
+     * @param theme_config $theme the theme we are finding icons for (which is irrelevant).
+     */
+    public function __construct($theme) {
+    }
+
+    /**
+     * Implement interface method.
+     * @param string $iconname the name of the icon.
+     * @return string the URL for that icon.
+     */
+    public function old_icon_url($iconname) {
+        global $CFG;
+        if (file_exists($CFG->dirroot . '/pix/' . $iconname . '.png')) {
+            return $CFG->httpswwwroot . '/pix/' . $iconname . '.png';
+        } else {
+            return $CFG->httpswwwroot . '/pix/' . $iconname . '.gif';
+        }
+    }
+
+    /**
+     * Implement interface method.
+     * @param string $iconname the name of the icon.
+     * @param string $module the module the icon belongs to.
+     * @return string the URL for that icon.
+     */
+    public function mod_icon_url($iconname, $module) {
+        global $CFG;
+        if (file_exists($CFG->dirroot . '/mod/' . $module . '/' . $iconname . '.png')) {
+            return $CFG->httpswwwroot . '/mod/' . $module . '/' . $iconname . '.png';
+        } else {
+            return $CFG->httpswwwroot . '/mod/' . $module . '/' . $iconname . '.gif';
+        }
+    }
+}
+
+
+/**
+ * This icon finder implements the old scheme that was used for themes that had
+ * $THEME->custompix = true.
+ *
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class theme_icon_finder implements icon_finder {
+    protected $themename;
+    /**
+     * Constructor
+     * @param theme_config $theme the theme we are finding icons for.
+     */
+    public function __construct($theme) {
+        $this->themename = $theme->name;
+    }
+
+    /**
+     * Implement interface method.
+     * @param string $iconname the name of the icon.
+     * @return string the URL for that icon.
+     */
+    public function old_icon_url($iconname) {
+        global $CFG;
+        if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/' . $iconname . '.png')) {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/' . $iconname . '.png';
+        } else {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/' . $iconname . '.gif';
+        }
+    }
+
+    /**
+     * Implement interface method.
+     * @param string $iconname the name of the icon.
+     * @param string $module the module the icon belongs to.
+     * @return string the URL for that icon.
+     */
+    public function mod_icon_url($iconname, $module) {
+        global $CFG;
+        if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.png')) {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.png';
+        } else {
+            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.gif';
+        }
+    }
+}
+
+
+/**
+ * This icon finder implements the algorithm in pix/smartpix.php.
+ *
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since     Moodle 2.0
+ */
+class smartpix_icon_finder extends pix_icon_finder {
+    protected $places = array();
+
+    /**
+     * Constructor
+     * @param theme_config $theme the theme we are finding icons for.
+     */
+    public function __construct($theme) {
+        global $CFG;
+        $this->places[$CFG->themedir . '/' . $theme->name . '/pix/'] =
+                $CFG->httpsthemewww . '/' . $theme->name . '/pix/';
+        if (!empty($theme->parent)) {
+            $this->places[$CFG->themedir . '/' . $theme->parent . '/pix/'] =
+                    $CFG->httpsthemewww . '/' . $theme->parent . '/pix/';
+        }
+    }
+
+    /**
+     * Implement interface method.
+     * @param string $iconname the name of the icon.
+     * @return string the URL for that icon.
+     */
+    public function old_icon_url($iconname) {
+        foreach ($this->places as $dirroot => $urlroot) {
+            if (file_exists($dirroot . $iconname . '.png')) {
+                return $dirroot . $iconname . '.png';
+            } else if (file_exists($dirroot . $iconname . '.gif')) {
+                return $dirroot . $iconname . '.gif';
+            }
+        }
+        return parent::old_icon_url($iconname);
+    }
+
+    /**
+     * Implement interface method.
+     * @param string $iconname the name of the icon.
+     * @param string $module the module the icon belongs to.
+     * @return string the URL for that icon.
+     */
+    public function mod_icon_url($iconname, $module) {
+        foreach ($this->places as $dirroot => $urlroot) {
+            if (file_exists($dirroot . 'mod/' . $iconname . '.png')) {
+                return $dirroot . 'mod/' . $iconname . '.png';
+            } else if (file_exists($dirroot . 'mod/' . $iconname . '.gif')) {
+                return $dirroot . 'mod/' . $iconname . '.gif';
+            }
+        }
+        return parent::old_icon_url($iconname, $module);
+    }
+}
+
 
 /**
  * Output CSS while replacing constants/variables. See MDL-6798 for details
diff --git a/lib/outputpixfinders.php b/lib/outputpixfinders.php
deleted file mode 100644 (file)
index decae9b..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-<?php
-
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Interface and classes for icon finders.
- *
- * Please see http://docs.moodle.org/en/Developement:How_Moodle_outputs_HTML
- * for an overview.
- *
- * @package   moodlecore
- * @copyright 2009 Tim Hunt
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-/**
- * An icon finder is responsible for working out the correct URL for an icon.
- *
- * A icon finder must also have a constructor that takes a theme object.
- * (See {@link standard_icon_finder::__construct} for an example.)
- *
- * Note that we are planning to change the Moodle icon naming convention before
- * the Moodle 2.0 release. Therefore, this API will probably change.
- *
- * @copyright 2009 Tim Hunt
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-interface icon_finder {
-    /**
-     * Return the URL for an icon identified as in pre-Moodle 2.0 code.
-     *
-     * Suppose you have old code like $url = "$CFG->pixpath/i/course.gif";
-     * then old_icon_url('i/course'); will return the equivalent URL that is correct now.
-     *
-     * @param string $iconname the name of the icon.
-     * @return string the URL for that icon.
-     */
-    public function old_icon_url($iconname);
-
-    /**
-     * Return the URL for an icon identified as in pre-Moodle 2.0 code.
-     *
-     * Suppose you have old code like $url = "$CFG->modpixpath/$mod/icon.gif";
-     * then mod_icon_url('icon', $mod); will return the equivalent URL that is correct now.
-     *
-     * @param string $iconname the name of the icon.
-     * @param string $module the module the icon belongs to.
-     * @return string the URL for that icon.
-     */
-    public function mod_icon_url($iconname, $module);
-}
-
-/**
- * This icon finder implements the old scheme that was used when themes that had
- * $THEME->custompix = false.
- *
- * @copyright 2009 Tim Hunt
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class pix_icon_finder implements icon_finder {
-    /**
-     * Constructor
-     * @param theme_config $theme the theme we are finding icons for (which is irrelevant).
-     */
-    public function __construct($theme) {
-    }
-
-    /**
-     * Implement interface method.
-     * @param string $iconname the name of the icon.
-     * @return string the URL for that icon.
-     */
-    public function old_icon_url($iconname) {
-        global $CFG;
-        if (file_exists($CFG->dirroot . '/pix/' . $iconname . '.png')) {
-            return $CFG->httpswwwroot . '/pix/' . $iconname . '.png';
-        } else {
-            return $CFG->httpswwwroot . '/pix/' . $iconname . '.gif';
-        }
-    }
-
-    /**
-     * Implement interface method.
-     * @param string $iconname the name of the icon.
-     * @param string $module the module the icon belongs to.
-     * @return string the URL for that icon.
-     */
-    public function mod_icon_url($iconname, $module) {
-        global $CFG;
-        if (file_exists($CFG->dirroot . '/mod/' . $module . '/' . $iconname . '.png')) {
-            return $CFG->httpswwwroot . '/mod/' . $module . '/' . $iconname . '.png';
-        } else {
-            return $CFG->httpswwwroot . '/mod/' . $module . '/' . $iconname . '.gif';
-        }
-    }
-}
-
-
-/**
- * This icon finder implements the old scheme that was used for themes that had
- * $THEME->custompix = true.
- *
- * @copyright 2009 Tim Hunt
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class theme_icon_finder implements icon_finder {
-    protected $themename;
-    /**
-     * Constructor
-     * @param theme_config $theme the theme we are finding icons for.
-     */
-    public function __construct($theme) {
-        $this->themename = $theme->name;
-    }
-
-    /**
-     * Implement interface method.
-     * @param string $iconname the name of the icon.
-     * @return string the URL for that icon.
-     */
-    public function old_icon_url($iconname) {
-        global $CFG;
-        if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/' . $iconname . '.png')) {
-            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/' . $iconname . '.png';
-        } else {
-            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/' . $iconname . '.gif';
-        }
-    }
-
-    /**
-     * Implement interface method.
-     * @param string $iconname the name of the icon.
-     * @param string $module the module the icon belongs to.
-     * @return string the URL for that icon.
-     */
-    public function mod_icon_url($iconname, $module) {
-        global $CFG;
-        if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.png')) {
-            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.png';
-        } else {
-            return $CFG->httpsthemewww . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.gif';
-        }
-    }
-}
-
-
-/**
- * This icon finder implements the algorithm in pix/smartpix.php.
- *
- * @copyright 2009 Tim Hunt
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since     Moodle 2.0
- */
-class smartpix_icon_finder extends pix_icon_finder {
-    protected $places = array();
-
-    /**
-     * Constructor
-     * @param theme_config $theme the theme we are finding icons for.
-     */
-    public function __construct($theme) {
-        global $CFG;
-        $this->places[$CFG->themedir . '/' . $theme->name . '/pix/'] =
-                $CFG->httpsthemewww . '/' . $theme->name . '/pix/';
-        if (!empty($theme->parent)) {
-            $this->places[$CFG->themedir . '/' . $theme->parent . '/pix/'] =
-                    $CFG->httpsthemewww . '/' . $theme->parent . '/pix/';
-        }
-    }
-
-    /**
-     * Implement interface method.
-     * @param string $iconname the name of the icon.
-     * @return string the URL for that icon.
-     */
-    public function old_icon_url($iconname) {
-        foreach ($this->places as $dirroot => $urlroot) {
-            if (file_exists($dirroot . $iconname . '.png')) {
-                return $dirroot . $iconname . '.png';
-            } else if (file_exists($dirroot . $iconname . '.gif')) {
-                return $dirroot . $iconname . '.gif';
-            }
-        }
-        return parent::old_icon_url($iconname);
-    }
-
-    /**
-     * Implement interface method.
-     * @param string $iconname the name of the icon.
-     * @param string $module the module the icon belongs to.
-     * @return string the URL for that icon.
-     */
-    public function mod_icon_url($iconname, $module) {
-        foreach ($this->places as $dirroot => $urlroot) {
-            if (file_exists($dirroot . 'mod/' . $iconname . '.png')) {
-                return $dirroot . 'mod/' . $iconname . '.png';
-            } else if (file_exists($dirroot . 'mod/' . $iconname . '.gif')) {
-                return $dirroot . 'mod/' . $iconname . '.gif';
-            }
-        }
-        return parent::old_icon_url($iconname, $module);
-    }
-}
-
-
index c14789e6e4322e75ddd44c70de611b11472bcd8b..bd293821881d6152f27c8020f95dac4499597bd3 100644 (file)
@@ -1155,7 +1155,7 @@ class moodle_core_renderer extends moodle_renderer_base {
         // Removing the button so it doesn't get output again
         unset($form->button);
 
-        return $this->form($form, $buttonoutput);
+        return $this->output_tag('div', array('class' => 'singlebutton'), $this->form($form, $buttonoutput));
     }
 
     /**
@@ -1206,8 +1206,7 @@ class moodle_core_renderer extends moodle_renderer_base {
                 'class' => $form->get_classes_string());
 
         $divoutput = $this->output_tag('div', array(), $hiddenoutput . $contents . $buttonoutput);
-        $formoutput = $this->output_tag('form', $formattributes, $divoutput);
-        $output = $this->output_tag('div', array('class' => 'singlebutton'), $formoutput);
+        $output = $this->output_tag('form', $formattributes, $divoutput);
 
         return $output;
     }
@@ -1545,12 +1544,13 @@ class moodle_core_renderer extends moodle_renderer_base {
      * @param string $text The lang string for the button's label (already output from get_string())
      * @return string|void if $return is true, void otherwise
      */
-    public function close_window_button($text) {
+    public function close_window_button($text='') {
         if (empty($text)) {
             $text = get_string('closewindow');
         }
         $closeform = new html_form();
         $closeform->url = '#';
+        $closeform->method = 'get';
         $closeform->button->text = $text;
         $closeform->button->add_action('click', 'close_window');
         $closeform->button->prepare();
index 15881359e6f995a859ce079b1cf28e4a5f7f2b68..6d19a9daaed3597fe6dc31e52b3047589e3bf79c 100644 (file)
@@ -559,6 +559,8 @@ function prepare_url($url, $stripformparams=false) {
         if (preg_match('/(.*)\/([A-Za-z0-9-_]*\.php)$/', $PAGE->url->out(true), $matches)) {
 
             return $matches[1] . "/$output";
+        } else if ($output == '') {
+            return $PAGE->url->out(false, array(), false) . '#';
         } else {
             throw new coding_exception('Your page uses bizarre relative URLs which Moodle cannot handle. Please use absolute URLs.');
         }