MDL-21233 obviously input tag writing does not belong into the moodle_url class, moving to html_writer instead + simplifying api
This commit is contained in:
+2
-2
@@ -77,7 +77,7 @@ if (empty($SITE->fullname)) {
|
||||
|
||||
echo '<form action="settings.php" method="post" id="adminsettings">';
|
||||
echo '<div class="settingsform clearfix">';
|
||||
echo $PAGE->url->hidden_params_out();
|
||||
echo html_writer::input_hidden_params($PAGE->url);
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
||||
|
||||
@@ -119,7 +119,7 @@ if (empty($SITE->fullname)) {
|
||||
|
||||
echo '<form action="settings.php" method="post" id="adminsettings">';
|
||||
echo '<div class="settingsform clearfix">';
|
||||
echo $PAGE->url->hidden_params_out();
|
||||
echo html_writer::input_hidden_params($PAGE->url);
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="return" value="'.$return.'" />';
|
||||
echo $OUTPUT->heading($settingspage->visiblename);
|
||||
|
||||
+1
-1
@@ -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 = '';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ class portfolio_add_button {
|
||||
}
|
||||
|
||||
$formoutput = '<form method="post" action="' . $CFG->wwwroot . '/portfolio/add.php" id="portfolio-add-button">' . "\n";
|
||||
$formoutput .= $url->hidden_params_out();
|
||||
$formoutput .= html_writer::input_hidden_params($url);
|
||||
$linkoutput = '<a href="' . $url->out();
|
||||
|
||||
switch ($format) {
|
||||
|
||||
@@ -486,30 +486,6 @@ class moodle_url {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs params as hidden form elements.
|
||||
*
|
||||
* @param array $exclude params to ignore
|
||||
* @param integer $indent indentation
|
||||
* @param array $overrideparams params to add to the output params, these
|
||||
* override existing ones with the same name.
|
||||
* @return string html for form elements.
|
||||
*/
|
||||
public function hidden_params_out(array $exclude = null, $indent = 0, array $overrideparams = null) {
|
||||
$exclude = (array)$exclude;
|
||||
$params = $this->merge_overrideparams($overrideparams);
|
||||
|
||||
$tabindent = str_repeat("\t", $indent);
|
||||
$str = '';
|
||||
foreach ($params as $key => $val) {
|
||||
if (FALSE === array_search($key, $exclude)) {
|
||||
$val = s($val);
|
||||
$str.= "$tabindent<input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for printing of encoded URL.
|
||||
* @return string
|
||||
|
||||
+1
-1
@@ -553,7 +553,7 @@ if ($quiz_reordertool) {
|
||||
echo '</div><div class="bd">';
|
||||
echo '<form action="edit.php" method="post">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo $thispageurl->hidden_params_out();
|
||||
echo html_writer::input_hidden_params($thispageurl);
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
//YUI does not submit the value of the submit button so
|
||||
//we need to add the value:
|
||||
|
||||
@@ -374,7 +374,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true,
|
||||
if ($reordertool) {
|
||||
echo '<form method="post" action="edit.php" id="quizquestions"><div>';
|
||||
|
||||
echo $pageurl->hidden_params_out();
|
||||
echo html_writer::input_hidden_params($pageurl);
|
||||
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
|
||||
|
||||
echo $reordercontrolstop;
|
||||
@@ -523,7 +523,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true,
|
||||
<fieldset class="invisiblefieldset" style="display: block;">
|
||||
<label for="<?php echo "inputq$question->id" ?>"><?php echo $strgrade; ?></label>:<br />
|
||||
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
|
||||
<?php echo $pageurl->hidden_params_out(); ?>
|
||||
<?php echo html_writer::input_hidden_params($pageurl); ?>
|
||||
<input type="hidden" name="savechanges" value="save" />
|
||||
<?php
|
||||
echo '<input type="text" name="g' . $question->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 '<form method="get" action="edit.php" id="displayoptions">';
|
||||
echo "<fieldset class='invisiblefieldset'>";
|
||||
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 '<noscript><div class="centerpara"><input type="submit" value="'. get_string('go') . '" />';
|
||||
@@ -1131,7 +1131,7 @@ function quiz_print_grading_form($quiz, $pageurl, $tabindex) {
|
||||
echo "<form method=\"post\" action=\"edit.php\"><div>";
|
||||
echo '<fieldset class="invisiblefieldset" style="display: block;">';
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />";
|
||||
echo $pageurl->hidden_params_out();
|
||||
echo html_writer::input_hidden_params($pageurl);
|
||||
$a = '<input type="text" id="inputmaxgrade" name="maxgrade" size="' . ($quiz->decimalpoints + 2) . '" tabindex="' . $tabindex
|
||||
. '" value="' . quiz_format_grade($quiz, $quiz->grade) . '" />';
|
||||
echo '<label for="inputmaxgrade">' . get_string('maximumgradex', '', $a) . "</label>";
|
||||
|
||||
@@ -74,10 +74,11 @@ class quiz_report_overview_table extends table_sql {
|
||||
if (!$this->is_downloading()) {
|
||||
if ($this->candelete) {
|
||||
// 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 '<div style="display: none;">';
|
||||
echo $this->reporturl->hidden_params_out(array(), 0, $this->displayoptions);
|
||||
echo html_writer::input_hidden_params($url);
|
||||
echo '</div>';
|
||||
echo '<div>';
|
||||
}
|
||||
|
||||
@@ -292,10 +292,11 @@ class quiz_overview_report extends quiz_default_report {
|
||||
$regradealldrylabel = get_string('regradealldry', 'quiz_overview');
|
||||
$regradealllabel = get_string('regradeall', 'quiz_overview');
|
||||
}
|
||||
$displayurl = new moodle_url($reporturl, $displayoptions);
|
||||
echo '<div class="mdl-align">';
|
||||
echo '<form action="'.$reporturl->out(true).'">';
|
||||
echo '<form action="'.$displayurl->out(true).'">';
|
||||
echo '<div>';
|
||||
echo $reporturl->hidden_params_out(array(), 0, $displayoptions);
|
||||
echo html_writer::input_hidden_params($displayurl);
|
||||
echo '<input type="submit" name="regradeall" value="'.$regradealllabel.'"/>';
|
||||
echo '<input type="submit" name="regradealldry" value="'.$regradealldrylabel.'"/>';
|
||||
if ($countregradeneeded){
|
||||
|
||||
@@ -31,12 +31,13 @@ class quiz_report_responses_table extends table_sql {
|
||||
if (!$this->is_downloading()) {
|
||||
if ($this->candelete) {
|
||||
// Start form
|
||||
$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="' . $this->reporturl->out(true) .
|
||||
echo '<form id="attemptsform" method="post" action="' . $displayurl->out(true) .
|
||||
'" onsubmit="confirm(\''.$strreallydel.'\');">';
|
||||
echo '<div style="display: none;">';
|
||||
echo $this->reporturl->hidden_params_out(array(), 0, $this->displayoptions);
|
||||
echo html_writer::input_hidden_params($displayurl);
|
||||
echo '</div>';
|
||||
echo '<div>';
|
||||
}
|
||||
|
||||
@@ -1191,7 +1191,7 @@ class question_bank_view {
|
||||
protected function display_options($recurse = 1, $showhidden = false, $showquestiontext = false) {
|
||||
echo '<form method="get" action="edit.php" id="displayoptions">';
|
||||
echo "<fieldset class='invisiblefieldset'>";
|
||||
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'));
|
||||
$this->display_category_form_checkbox('qbshowtext', get_string('showquestiontext', 'quiz'));
|
||||
@@ -1281,7 +1281,7 @@ class question_bank_view {
|
||||
echo '<form method="post" action="edit.php">';
|
||||
echo '<fieldset class="invisiblefieldset" style="display: block;">';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo $pageurl->hidden_params_out();
|
||||
echo html_writer::input_hidden_params($pageurl);
|
||||
|
||||
echo '<div class="categoryquestionscontainer">';
|
||||
$this->start_table();
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
print_question($questions[$id], $curstate, $number, $quiz, $options);
|
||||
|
||||
echo '<div class="controls">';
|
||||
echo $url->hidden_params_out();
|
||||
echo html_writer::input_hidden_params($url);
|
||||
|
||||
// Print the mark and finish attempt buttons
|
||||
echo '<input name="markall" type="submit" value="' . get_string('markall',
|
||||
|
||||
Reference in New Issue
Block a user