mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 05:25:08 +02:00
MDL-21233 finally removed the omitquerystring parameters from the out method because: 1/ the least used parameter should nto be first, 2/ it is colliding with the other two paramters, now we have separate funtion for that instead
This commit is contained in:
parent
340d461269
commit
eb7880654f
@ -270,7 +270,7 @@ class block_global_navigation_tree extends block_tree {
|
||||
if ($node->key == $child->key && $node->type == $child->type) {
|
||||
if ($node->action instanceof moodle_url && $child->action instanceof moodle_url && $node->action->compare($child->action)) {
|
||||
unset($history[$key]);
|
||||
} else if ($child->action instanceof moodle_url && $child->action->out(true) == $node->action) {
|
||||
} else if ($child->action instanceof moodle_url && $child->action->out_omit_querystring() == $node->action) {
|
||||
unset($history[$key]);
|
||||
} else if ($child->action == $node->action) {
|
||||
unset($history[$key]);
|
||||
|
@ -286,7 +286,7 @@ class block_manager {
|
||||
* @return string URL for moving block $this->movingblock to this position.
|
||||
*/
|
||||
protected function get_move_target_url($region, $weight) {
|
||||
return $this->page->url->out(false, array('bui_moveid' => $this->movingblock,
|
||||
return $this->page->url->out(array('bui_moveid' => $this->movingblock,
|
||||
'bui_newregion' => $region, 'bui_newweight' => $weight, 'sesskey' => sesskey()), false);
|
||||
}
|
||||
|
||||
@ -889,7 +889,7 @@ class block_manager {
|
||||
}
|
||||
|
||||
$controls = array();
|
||||
$actionurl = $this->page->url->out(false, array('sesskey'=> sesskey()), false);
|
||||
$actionurl = $this->page->url->out(array('sesskey'=> sesskey()), false);
|
||||
|
||||
// Assign roles icon.
|
||||
if (has_capability('moodle/role:assign', $block->context)) {
|
||||
@ -1066,7 +1066,7 @@ class block_manager {
|
||||
$editpage->set_pagelayout('base');
|
||||
$editpage->set_course($this->page->course);
|
||||
$editpage->set_context($block->context);
|
||||
$editurlbase = str_replace($CFG->wwwroot . '/', '', $this->page->url->out(true));
|
||||
$editurlbase = str_replace($CFG->wwwroot . '/', '', $this->page->url->out_omit_querystring());
|
||||
$editurlparams = $this->page->url->params();
|
||||
$editurlparams['bui_editid'] = $blockid;
|
||||
$editpage->set_url($editurlbase, $editurlparams);
|
||||
|
@ -1073,7 +1073,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
|
||||
$this->_formName = $formName;
|
||||
if (is_a($action, 'moodle_url')){
|
||||
$this->_pageparams = html_writer::input_hidden_params($action);
|
||||
$action = $action->out(true);
|
||||
$action = $action->out_omit_querystring();
|
||||
} else {
|
||||
$this->_pageparams = '';
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class moodle_list {
|
||||
$html .= " $currentpage \n";
|
||||
}
|
||||
else {
|
||||
$html .= "<a href=\"".$this->pageurl->out(false, array($this->pageparamname => $currentpage))."\">";
|
||||
$html .= "<a href=\"".$this->pageurl->out(array($this->pageparamname => $currentpage))."\">";
|
||||
$html .= " $currentpage </a>\n";
|
||||
}
|
||||
}
|
||||
|
@ -1069,12 +1069,12 @@ class html_select extends labelled_html_component {
|
||||
}
|
||||
|
||||
if (!empty($selected)) {
|
||||
$selectedurl = $baseurl->out(false, array($name => $selected), false);
|
||||
$selectedurl = $baseurl->out(array($name => $selected), false);
|
||||
}
|
||||
|
||||
// Replace real value by formatted URLs
|
||||
foreach ($options as $value => $label) {
|
||||
$options[$baseurl->out(false, array($name => $value), false)] = $label;
|
||||
$options[$baseurl->out(array($name => $value), false)] = $label;
|
||||
unset($options[$value]);
|
||||
}
|
||||
|
||||
|
@ -1072,7 +1072,7 @@ class core_renderer extends renderer_base {
|
||||
$output = html_writer::tag('div', array(), $output);
|
||||
|
||||
// now the form itself around it
|
||||
$url = $button->url->out(true); // url without params
|
||||
$url = $button->url->out_omit_querystring(); // url without params
|
||||
if ($url === '') {
|
||||
$url = '#'; // there has to be always some action
|
||||
}
|
||||
|
@ -832,7 +832,7 @@ class moodle_page {
|
||||
|
||||
$this->_url = new moodle_url($url, $params);
|
||||
|
||||
$fullurl = $this->_url->out(true);
|
||||
$fullurl = $this->_url->out_omit_querystring();
|
||||
if (strpos($fullurl, "$CFG->httpswwwroot/") !== 0) {
|
||||
debugging('Most probably incorrect set_page() url argument, it does not match the httpswwwroot!');
|
||||
}
|
||||
|
@ -140,5 +140,5 @@ $PAGE->set_heading('PDF library test');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading('Press the button to generate test PDF', 2);
|
||||
echo $OUTPUT->continue_button($PAGE->url->out(false, array('getpdf' => 1)));
|
||||
echo $OUTPUT->continue_button(new moodle_url($PAGE->url, array('getpdf' => 1)));
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -491,7 +491,7 @@ class moodle_url {
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->out(false, null, true);
|
||||
return $this->out(null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -500,26 +500,19 @@ class moodle_url {
|
||||
* If you use the returned URL in HTML code, you want the escaped ampersands. If you use
|
||||
* the returned URL in HTTP headers, you want $escaped=false.
|
||||
*
|
||||
* @param boolean $omitquerystring whether to output page params as a query string in the url.
|
||||
* @param array $overrideparams params to add to the output url, these override existing ones with the same name.
|
||||
* @param boolean $escaped Use & as params separator instead of plain &
|
||||
* @return string Resulting URL
|
||||
*/
|
||||
public function out($omitquerystring = false, array $overrideparams = null, $escaped = true) {
|
||||
$uri = $this->scheme ? $this->scheme.':'.((strtolower($this->scheme) == 'mailto') ? '':'//'): '';
|
||||
$uri .= $this->user ? $this->user.($this->pass? ':'.$this->pass:'').'@':'';
|
||||
$uri .= $this->host ? $this->host : '';
|
||||
$uri .= $this->port ? ':'.$this->port : '';
|
||||
$uri .= $this->path ? $this->path : '';
|
||||
public function out(array $overrideparams = null, $escaped = true) {
|
||||
$uri = $this->out_omit_querystring();
|
||||
|
||||
if (!$omitquerystring) {
|
||||
$querystring = $this->get_query_string($overrideparams, $escaped);
|
||||
if ($querystring) {
|
||||
$uri .= '?' . $querystring;
|
||||
}
|
||||
if (!is_null($this->anchor)) {
|
||||
$uri .= '#'.$this->anchor;
|
||||
}
|
||||
$querystring = $this->get_query_string($overrideparams, $escaped);
|
||||
if ($querystring) {
|
||||
$uri .= '?' . $querystring;
|
||||
}
|
||||
if (!is_null($this->anchor)) {
|
||||
$uri .= '#'.$this->anchor;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
@ -531,7 +524,20 @@ class moodle_url {
|
||||
* @return string
|
||||
*/
|
||||
public function out_raw() {
|
||||
return $this->out(false, null, false);
|
||||
return $this->out(null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns url without parameters, everything before '?'.
|
||||
* @return string
|
||||
*/
|
||||
public function out_omit_querystring() {
|
||||
$uri = $this->scheme ? $this->scheme.':'.((strtolower($this->scheme) == 'mailto') ? '':'//'): '';
|
||||
$uri .= $this->user ? $this->user.($this->pass? ':'.$this->pass:'').'@':'';
|
||||
$uri .= $this->host ? $this->host : '';
|
||||
$uri .= $this->port ? ':'.$this->port : '';
|
||||
$uri .= $this->path ? $this->path : '';
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -546,7 +552,7 @@ class moodle_url {
|
||||
public function out_action(array $overrideparams = null) {
|
||||
$overrideparams = (array)$overrideparams;
|
||||
$overrideparams = array('sesskey'=> sesskey()) + $overrideparams;
|
||||
return $this->out(false, $overrideparams);
|
||||
return $this->out($overrideparams);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -558,8 +564,8 @@ class moodle_url {
|
||||
*/
|
||||
public function compare(moodle_url $url, $matchtype = URL_MATCH_EXACT) {
|
||||
|
||||
$baseself = $this->out(true);
|
||||
$baseother = $url->out(true);
|
||||
$baseself = $this->out_omit_querystring();
|
||||
$baseother = $url->out_omit_querystring();
|
||||
|
||||
// Append index.php if there is no specific file
|
||||
if (substr($baseself,-1)=='/') {
|
||||
@ -639,12 +645,16 @@ function prepare_url($url, $stripformparams=false) {
|
||||
$output = $url;
|
||||
|
||||
if ($url instanceof moodle_url) {
|
||||
$output = $url->out($stripformparams, array(), false);
|
||||
if ($stripformparams) {
|
||||
$output = $url->out_omit_querystring();
|
||||
} else {
|
||||
$output = $url->out_raw();
|
||||
}
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
if (preg_match('/(.*)\/([A-Za-z0-9-_]*\.php)$/', $PAGE->url->out_omit_querystring(), $matches)) {
|
||||
return $matches[1] . "/$output";
|
||||
} else if ($output == '') {
|
||||
return $PAGE->url->out_raw() . '#';
|
||||
|
@ -449,7 +449,7 @@ echo $OUTPUT->header();
|
||||
|
||||
// Initialise the JavaScript.
|
||||
$quizeditconfig = new stdClass;
|
||||
$quizeditconfig->url = $thispageurl->out(false, array('qbanktool' => '0'));
|
||||
$quizeditconfig->url = $thispageurl->out(array('qbanktool' => '0'));
|
||||
$quizeditconfig->dialoglisteners = array();
|
||||
$numberoflisteners = max(quiz_number_of_pages($quiz->questions), 1);
|
||||
for ($pageiter = 1; $pageiter <= $numberoflisteners; $pageiter++) {
|
||||
@ -477,10 +477,10 @@ if ($quiz_qbanktool) {
|
||||
echo '<div class="questionbankwindow ' . $bankclass . 'sideblock">';
|
||||
echo '<div class="header"><div class="title"><h2>';
|
||||
echo get_string('questionbankcontents', 'quiz') .
|
||||
' <a href="' . $thispageurl->out(false, array('qbanktool' => '1')) .
|
||||
' <a href="' . $thispageurl->out(array('qbanktool' => '1')) .
|
||||
'" id="showbankcmd">[' . get_string('show').
|
||||
']</a>
|
||||
<a href="' . $thispageurl->out(false, array('qbanktool' => '0')) .
|
||||
<a href="' . $thispageurl->out(array('qbanktool' => '0')) .
|
||||
'" id="hidebankcmd">[' . get_string('hide').
|
||||
']</a>';
|
||||
echo '</h2></div></div><div class="content">';
|
||||
|
@ -603,7 +603,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true,
|
||||
|
||||
if (!$reordertool && !$quiz->shufflequestions) {
|
||||
echo $OUTPUT->container_start('addpage');
|
||||
$url = new moodle_url($pageurl->out(true), array('cmid' => $quiz->cmid, 'courseid' => $quiz->course, 'addpage' => $count, 'sesskey' => sesskey()));
|
||||
$url = new moodle_url($pageurl->out_omit_querystring(), array('cmid' => $quiz->cmid, 'courseid' => $quiz->course, 'addpage' => $count, 'sesskey' => sesskey()));
|
||||
echo $OUTPUT->single_button($url, get_string('addpagehere', 'quiz'), 'get', $hasattempts);
|
||||
echo $OUTPUT->container_end();
|
||||
}
|
||||
@ -644,7 +644,7 @@ function quiz_print_pagecontrols($quiz, $pageurl, $page, $hasattempts) {
|
||||
$defaultcategory = question_make_default_categories($contexts->all());
|
||||
|
||||
// Create the url the question page will return to
|
||||
$returnurl_addtoquiz = new moodle_url($pageurl->out(true), array('addonpage' => $page));
|
||||
$returnurl_addtoquiz = new moodle_url($pageurl->out_omit_querystring(), array('addonpage' => $page));
|
||||
|
||||
// Print a button linking to the choose question type page.
|
||||
$newquestionparams = array('returnurl' => $returnurl_addtoquiz->out(),
|
||||
@ -664,7 +664,7 @@ function quiz_print_pagecontrols($quiz, $pageurl, $page, $hasattempts) {
|
||||
<input type="hidden" class="addonpage_formelement" name="addonpage_form" value="<?php echo $page; ?>" />
|
||||
<input type="hidden" name="cmid" value="<?php echo $quiz->cmid; ?>" />
|
||||
<input type="hidden" name="courseid" value="<?php echo $quiz->course; ?>" />
|
||||
<input type="hidden" name="returnurl" value="<?php echo urlencode($pageurl->out(true)); ?>" />
|
||||
<input type="hidden" name="returnurl" value="<?php echo urlencode($pageurl->out_omit_querystring()); ?>" />
|
||||
<input type="submit" id="addrandomdialoglaunch_<?php echo $randombuttoncount; ?>" value="<?php echo get_string('addarandomquestion', 'quiz'); ?>" <?php echo " $disabled"; ?> />
|
||||
</div>
|
||||
</form>
|
||||
@ -758,7 +758,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
|
||||
$a->arrow = $OUTPUT->rarrow();
|
||||
$strshowcategorycontents = get_string('showcategorycontents', 'quiz', $a);
|
||||
|
||||
$openqbankurl = $pageurl->out(false, array('qbanktool' => 1,
|
||||
$openqbankurl = $pageurl->out(array('qbanktool' => 1,
|
||||
'cat' => $category->id . ',' . $category->contextid));
|
||||
$linkcategorycontents = ' <a href="' . $openqbankurl . '">' . $strshowcategorycontents . '</a>';
|
||||
|
||||
|
@ -158,7 +158,7 @@ class quiz_grading_report extends quiz_default_report {
|
||||
/// find out current groups mode
|
||||
|
||||
if ($groupmode = groups_get_activity_groupmode($this->cm)) { // Groups are being used
|
||||
groups_print_activity_menu($this->cm, $this->viewurl->out(false, array('userid'=>0, 'attemptid'=>0)));
|
||||
groups_print_activity_menu($this->cm, $this->viewurl->out(array('userid'=>0, 'attemptid'=>0)));
|
||||
}
|
||||
|
||||
if(empty($this->users)) {
|
||||
|
@ -76,7 +76,7 @@ class quiz_report_overview_table extends table_sql {
|
||||
// Start form
|
||||
$url = new moodle_url($this->reporturl, $this->displayoptions);
|
||||
echo '<div id="tablecontainer">';
|
||||
echo '<form id="attemptsform" method="post" action="' . $this->reporturl->out(true) .'">';
|
||||
echo '<form id="attemptsform" method="post" action="' . $this->reporturl->out_omit_querystring() .'">';
|
||||
echo '<div style="display: none;">';
|
||||
echo html_writer::input_hidden_params($url);
|
||||
echo '</div>';
|
||||
|
@ -170,12 +170,12 @@ class quiz_overview_report extends quiz_default_report {
|
||||
$this->regrade_all_needed($quiz, $groupstudents);
|
||||
}
|
||||
if ($regradeall || $regradealldry || $regradealldrydo){
|
||||
redirect($reporturl->out(false, $displayoptions, false), '', 5);
|
||||
redirect($reporturl->out($displayoptions, false), '', 5);
|
||||
}
|
||||
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
if (!$table->is_downloading()) {
|
||||
groups_print_activity_menu($cm, $reporturl->out(false, $displayoptions));
|
||||
groups_print_activity_menu($cm, $reporturl->out($displayoptions));
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ class quiz_overview_report extends quiz_default_report {
|
||||
}
|
||||
$displayurl = new moodle_url($reporturl, $displayoptions);
|
||||
echo '<div class="mdl-align">';
|
||||
echo '<form action="'.$displayurl->out(true).'">';
|
||||
echo '<form action="'.$displayurl->out_omit_querystring().'">';
|
||||
echo '<div>';
|
||||
echo html_writer::input_hidden_params($displayurl);
|
||||
echo '<input type="submit" name="regradeall" value="'.$regradealllabel.'"/>';
|
||||
@ -379,7 +379,7 @@ class quiz_overview_report extends quiz_default_report {
|
||||
$table->sortable(true, 'uniqueid');
|
||||
|
||||
// Set up the table
|
||||
$table->define_baseurl($reporturl->out(false, $displayoptions));
|
||||
$table->define_baseurl($reporturl->out($displayoptions));
|
||||
|
||||
$table->collapsible(false);
|
||||
|
||||
|
@ -138,7 +138,7 @@ class quiz_responses_report extends quiz_default_report {
|
||||
|
||||
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
||||
if (!$table->is_downloading()) {
|
||||
groups_print_activity_menu($cm, $reporturl->out(false, $displayoptions));
|
||||
groups_print_activity_menu($cm, $reporturl->out($displayoptions));
|
||||
}
|
||||
}
|
||||
// Print information on the number of existing attempts
|
||||
@ -306,7 +306,7 @@ class quiz_responses_report extends quiz_default_report {
|
||||
$table->sortable(true, 'concattedid');
|
||||
|
||||
// Set up the table
|
||||
$table->define_baseurl($reporturl->out(false, $displayoptions));
|
||||
$table->define_baseurl($reporturl->out($displayoptions));
|
||||
|
||||
$table->collapsible(true);
|
||||
|
||||
|
@ -34,7 +34,7 @@ class quiz_report_responses_table extends table_sql {
|
||||
$displayurl = new moodle_url($this->reporturl, $this->displayoptions);
|
||||
$strreallydel = addslashes_js(get_string('deleteattemptcheck','quiz'));
|
||||
echo '<div id="tablecontainer">';
|
||||
echo '<form id="attemptsform" method="post" action="' . $displayurl->out(true) .
|
||||
echo '<form id="attemptsform" method="post" action="' . $displayurl->out_omit_querystring() .
|
||||
'" onsubmit="confirm(\''.$strreallydel.'\');">';
|
||||
echo '<div style="display: none;">';
|
||||
echo html_writer::input_hidden_params($displayurl);
|
||||
|
@ -409,7 +409,7 @@ class quiz_statistics_report extends quiz_default_report {
|
||||
}
|
||||
$quizinformationtablehtml .= $OUTPUT->box_start('boxaligncenter generalbox boxwidthnormal mdl-align');
|
||||
$quizinformationtablehtml .= get_string('lastcalculated', 'quiz_statistics', $a);
|
||||
$aurl = new moodle_url($reporturl->out(true), $reporturl->params()+array('recalculate'=>1));
|
||||
$aurl = new moodle_url($reporturl->out_omit_querystring(), $reporturl->params()+array('recalculate'=>1));
|
||||
$quizinformationtablehtml .= $OUTPUT->single_button($aurl, get_string('recalculatenow', 'quiz_statistics'));
|
||||
$quizinformationtablehtml .= $OUTPUT->box_end();
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ class workshop_manual_allocator implements workshop_allocator {
|
||||
}
|
||||
}
|
||||
$m = implode('-', $m); // serialize message object to be passed via URL
|
||||
redirect($PAGE->url->out(false, array('m' => $m), false));
|
||||
redirect($PAGE->url->out(array('m' => $m), false));
|
||||
break;
|
||||
case 'del':
|
||||
if (!confirm_sesskey()) {
|
||||
@ -119,7 +119,7 @@ class workshop_manual_allocator implements workshop_allocator {
|
||||
}
|
||||
}
|
||||
$m = implode('-', $m); // serialize message object to be passed via URL
|
||||
redirect($PAGE->url->out(false, array('m' => $m), false));
|
||||
redirect($PAGE->url->out(array('m' => $m), false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class question_category_list_item extends list_item {
|
||||
/// Each section adds html to be displayed as part of this list item
|
||||
$questionbankurl = "{$CFG->wwwroot}/question/edit.php?".
|
||||
$this->parentlist->pageurl->get_query_string(array('category'=>"$category->id,$category->contextid"));
|
||||
$catediturl = $this->parentlist->pageurl->out(false, array('edit'=>$this->id));
|
||||
$catediturl = $this->parentlist->pageurl->out(array('edit'=>$this->id));
|
||||
$item = "<b><a title=\"{$str->edit}\" href=\"$catediturl\">".$category->name ."</a></b> <a title=\"$editqestions\" href=\"$questionbankurl\">".'('.$category->questioncount.')</a>';
|
||||
|
||||
$item .= ' '. $category->info;
|
||||
|
@ -999,7 +999,7 @@ class question_bank_view {
|
||||
if (count($newsort) > question_bank_view::MAX_SORTS) {
|
||||
$newsort = array_slice($newsort, 0, question_bank_view::MAX_SORTS, true);
|
||||
}
|
||||
return $this->baseurl->out(false, $this->sort_to_params($newsort));
|
||||
return $this->baseurl->out($this->sort_to_params($newsort));
|
||||
}
|
||||
|
||||
protected function build_query_sql($category, $recurse, $showhidden) {
|
||||
@ -1078,11 +1078,11 @@ class question_bank_view {
|
||||
}
|
||||
|
||||
public function edit_question_url($questionid) {
|
||||
return $this->editquestionurl->out(false, array('id' => $questionid));
|
||||
return $this->editquestionurl->out(array('id' => $questionid));
|
||||
}
|
||||
|
||||
public function move_question_url($questionid) {
|
||||
return $this->editquestionurl->out(false, array('id' => $questionid, 'movecontext' => 1));
|
||||
return $this->editquestionurl->out(array('id' => $questionid, 'movecontext' => 1));
|
||||
}
|
||||
|
||||
public function preview_question_url($questionid) {
|
||||
@ -1422,7 +1422,7 @@ class question_bank_view {
|
||||
$checkforfiles = true;
|
||||
}
|
||||
}
|
||||
$returnurl = $this->baseurl->out(false, array('category'=>"$tocategoryid,$contextid"));
|
||||
$returnurl = $this->baseurl->out(array('category'=>"$tocategoryid,$contextid"));
|
||||
if (!$checkforfiles){
|
||||
if (!question_move_questions_to_category(implode(',', $questionids), $tocategory->id)) {
|
||||
print_error('errormovingquestions', 'question', $returnurl, $questionids);
|
||||
|
@ -218,7 +218,7 @@
|
||||
echo "</p>\n";
|
||||
}
|
||||
$number = 1;
|
||||
echo '<form method="post" action="'.$url->out(true).'" enctype="multipart/form-data" id="responseform">', "\n";
|
||||
echo '<form method="post" action="'.$url->out_omit_querystring().'" enctype="multipart/form-data" id="responseform">', "\n";
|
||||
print_question($questions[$id], $curstate, $number, $quiz, $options);
|
||||
|
||||
echo '<div class="controls">';
|
||||
|
Loading…
x
Reference in New Issue
Block a user