diff --git a/admin/settings.php b/admin/settings.php index fa554812c4c..12f94f56fec 100644 --- a/admin/settings.php +++ b/admin/settings.php @@ -77,7 +77,7 @@ if (empty($SITE->fullname)) { echo '
'; echo '
'; - echo $PAGE->url->hidden_params_out(); + echo html_writer::input_hidden_params($PAGE->url); echo ''; echo ''; @@ -119,7 +119,7 @@ if (empty($SITE->fullname)) { echo ''; echo '
'; - echo $PAGE->url->hidden_params_out(); + echo html_writer::input_hidden_params($PAGE->url); echo ''; echo ''; echo $OUTPUT->heading($settingspage->visiblename); diff --git a/lib/formslib.php b/lib/formslib.php index 4204eb2c32e..8c26ccd2a5d 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -1072,7 +1072,7 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless { $target = empty($target) ? array() : array('target' => $target); $this->_formName = $formName; if (is_a($action, 'moodle_url')){ - $this->_pageparams = $action->hidden_params_out(); + $this->_pageparams = html_writer::input_hidden_params($action); $action = $action->out(true); } else { $this->_pageparams = ''; diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index ca2cd1f8681..2855396a087 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -515,6 +515,27 @@ class html_writer { } return self::tag('optgroup', $attributes, $output); } + + /** + * Returns hidden input fields created from url parameters. + * @param moodle_url $url + * @param array $exclude list of excluded parameters + * @return string HTML fragment + */ + public static function input_hidden_params(moodle_url $url, array $exclude = null) { + $exclude = (array)$exclude; + $params = $url->params(); + foreach ($exclude as $key) { + unset($params[$key]); + } + + $output = ''; + foreach ($params as $key => $val) { + $attributes = array('type'=>'hidden', 'name'=>$key, 'value'=>$value); + $output .= self::empty_tag('input', $attributes)."\n"; + } + return $output; + } } diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index fa4065a4b77..784f28a75df 100644 --- a/lib/portfoliolib.php +++ b/lib/portfoliolib.php @@ -330,7 +330,7 @@ class portfolio_add_button { } $formoutput = '' . "\n"; - $formoutput .= $url->hidden_params_out(); + $formoutput .= html_writer::input_hidden_params($url); $linkoutput = ' $val) { - if (FALSE === array_search($key, $exclude)) { - $val = s($val); - $str.= "$tabindent\n"; - } - } - return $str; - } - /** * Shortcut for printing of encoded URL. * @return string diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 403c689308e..76842a262a4 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -553,7 +553,7 @@ if ($quiz_reordertool) { echo '
'; echo ''; echo '
'; - echo $thispageurl->hidden_params_out(); + echo html_writer::input_hidden_params($thispageurl); echo ''; //YUI does not submit the value of the submit button so //we need to add the value: diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index 530a8c08a9f..0b8194a64d3 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -374,7 +374,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true, if ($reordertool) { echo '
'; - echo $pageurl->hidden_params_out(); + echo html_writer::input_hidden_params($pageurl); echo ''; echo $reordercontrolstop; @@ -523,7 +523,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true,
:
- hidden_params_out(); ?> + id . '" id="inputq' . $question->id . @@ -1107,7 +1107,7 @@ class quiz_question_bank_view extends question_bank_view { protected function display_options($recurse = 1, $showhidden = false, $showquestiontext = false) { echo ''; echo "
"; - echo $this->baseurl->hidden_params_out(array('recurse', 'showhidden', 'showquestiontext')); + echo html_writer::input_hidden_params($this->baseurl, array('recurse', 'showhidden', 'showquestiontext')); $this->display_category_form_checkbox('recurse', get_string('recurse', 'quiz')); $this->display_category_form_checkbox('showhidden', get_string('showhidden', 'quiz')); echo '