]> git.mjollnir.org Git - moodle.git/commitdiff
questions MDL-20276 Fixed minor issue with URL handling within the paging bar for...
authorsamhemelryk <samhemelryk>
Wed, 16 Sep 2009 02:43:58 +0000 (02:43 +0000)
committersamhemelryk <samhemelryk>
Wed, 16 Sep 2009 02:43:58 +0000 (02:43 +0000)
lib/weblib.php
question/edit.php
question/editlib.php
question/question.php

index 850262b18503c4a9a599fd2cf1aa02166af47144..2d0d0d13739a61936a740153727dcf8bc09d92da 100644 (file)
@@ -557,20 +557,14 @@ function prepare_url($url, $stripformparams=false) {
     // Handle relative URLs
     if (substr($output, 0, 4) != 'http' && substr($output, 0, 1) != '/') {
         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.');
+            throw new coding_exception('Unrecognied URL scheme. Please check the formatting of the URL passed to this function. Absolute URLs are the preferred scheme.');
         }
     }
 
-    // Add wwwroot only if the URL does not already start with http:// or https://
-    if (!preg_match('|https?://|', $output) ) {
-        $output = $CFG->wwwroot . $output;
-    }
-
     return $output;
 }
 
index 4d87285f86a207db7a86fbe00508d24e6beed6d4..8711cb103aee93204adc3a5b2261f8f35f304f68 100644 (file)
     require_once("../config.php");
     require_once("editlib.php");
 
+    $url = new moodle_url($CFG->wwwroot.'/question/edit.php');
+    if (($lastchanged = optional_param('lastchanged', 0, PARAM_INT)) !== 0) {
+        $url->param('lastchanged', $lastchanged);
+    }
+    if (($category = optional_param('category', 0, PARAM_TEXT)) !== 0) {
+        $url->param('category', $category);
+    }
+    if (($qpage = optional_param('qpage', 0, PARAM_INT)) !== 0) {
+        $url->param('qpage', $qpage);
+    }
+    if (($cat = optional_param('cat', 0, PARAM_TEXT)) !== 0) {
+        $url->param('cat', $cat);
+    }
+    if (($courseid = optional_param('courseid', 0, PARAM_INT)) !== 0) {
+        $url->param('courseid', $courseid);
+    }
+    if (($returnurl = optional_param('returnurl', 0, PARAM_INT)) !== 0) {
+        $url->param('returnurl', $returnurl);
+    }
+    $PAGE->set_url($url);
+
     list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) = question_edit_setup('questions');
     $questionbank = new question_bank_view($contexts, $thispageurl, $COURSE, $cm);
     $questionbank->process_actions();
index 64b766175e3044c242ee71f89be394726fa4ccd1..d03f8175d2f2256bb9bc5a000055354ca9f83585 100644 (file)
@@ -1300,13 +1300,7 @@ class question_bank_view {
             } else {
                 $showall = '<a href="edit.php?'.$pageurl->get_query_string(array('qperpage'=>DEFAULT_QUESTIONS_PER_PAGE)).'">'.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).'</a>';
             }
-            if ($paging) {
-                $paging = substr($paging, 0, strrpos($paging, '</div>'));
-                $paging .= "<br />$showall</div>";
-            } else {
-                $paging = "<div class='paging'>$showall</div>";
-            }
-            echo $paging;
+            echo "<div class='paging'>$showall</div>";
         }
         echo '</div>';
 
index 7e574e335ad96bb654c2f8159ae6d9761bb494b0..af9b63f79279fe5cc78f2188f8cd3edff812cb90 100644 (file)
@@ -26,6 +26,39 @@ $returnurl = optional_param('returnurl', 0, PARAM_LOCALURL);
 $appendqnumstring = optional_param('appendqnumstring', '', PARAM_ALPHA);
 $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
 
+$url = new moodle_url($CFG->wwwroot.'/question/question.php');
+if ($id !== 0) {
+    $url->param('id', $id);
+}
+if ($qtype !== '') {
+    $url->param('qtype', $qtype);
+}
+if ($categoryid !== 0) {
+    $url->param('category', $categoryid);
+}
+if ($cmid !== 0) {
+    $url->param('cmid', $cmid);
+}
+if ($courseid !== 0) {
+    $url->param('courseid', $courseid);
+}
+if ($wizardnow !== '') {
+    $url->param('wizardnow', $wizardnow);
+}
+if ($movecontext !== 0) {
+    $url->param('movecontext', $movecontext);
+}
+if ($returnurl !== 0) {
+    $url->param('returnurl', $returnurl);
+}
+if ($appendqnumstring !== '') {
+    $url->param('appendqnumstring', $appendqnumstring);
+}
+if ($inpopup !== 0) {
+    $url->param('inpopup', $inpopup);
+}
+$PAGE->set_url($url);
+
 if ($movecontext && !$id){
     print_error('questiondoesnotexist', 'question', $returnurl);
 }