]> git.mjollnir.org Git - moodle.git/commitdiff
outputlib: MDL-20631 link_to_popup throws an exception if $link->text is empty, but...
authorTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 23 Oct 2009 18:49:00 +0000 (18:49 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 23 Oct 2009 18:49:00 +0000 (18:49 +0000)
lib/outputrenderers.php

index 358a97608c89a74081ba566c770beaaec60cf3a9..02e26589c1e5f37a97805fe26ef3e58ee16dba43 100644 (file)
@@ -1333,21 +1333,6 @@ class moodle_core_renderer extends moodle_renderer_base {
      */
     public function link_to_popup($link, $image=null) {
         $link = clone($link);
-        $link->prepare();
-
-        $this->prepare_event_handlers($link);
-
-        if (empty($link->url)) {
-            throw new coding_exception('Called $OUTPUT->link_to_popup($link) method without $link->url set.');
-        }
-
-        $linkurl = prepare_url($link->url);
-
-        $tagoptions = array(
-                'title' => $link->title,
-                'id' => $link->id,
-                'href' => ($linkurl) ? $linkurl : prepare_url($popup->url),
-                'class' => $link->get_classes_string());
 
         // Use image if one is given
         if (!empty($image) && $image instanceof html_image) {
@@ -1364,6 +1349,21 @@ class moodle_core_renderer extends moodle_renderer_base {
             }
         }
 
+        $link->prepare();
+        $this->prepare_event_handlers($link);
+
+        if (empty($link->url)) {
+            throw new coding_exception('Called $OUTPUT->link_to_popup($link) method without $link->url set.');
+        }
+
+        $linkurl = prepare_url($link->url);
+
+        $tagoptions = array(
+                'title' => $link->title,
+                'id' => $link->id,
+                'href' => ($linkurl) ? $linkurl : prepare_url($popup->url),
+                'class' => $link->get_classes_string());
+
         return $this->output_tag('a', $tagoptions, $link->text);
     }