Changelog entry for patch #3313326
[phpmyadmin/ammaryasirr.git] / setup / lib / form_processing.lib.php
blob17f58a60e05a7ce6e8f90187b843d958dab68529
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Formset processing library
6 * @package phpMyAdmin-setup
7 */
9 /**
10 * Processes forms registered in $form_display, handles error correction
12 * @param FormDisplay $form_display
14 function process_formset(FormDisplay $form_display) {
15 if (filter_input(INPUT_GET, 'mode') == 'revert') {
16 // revert erroneous fields to their default values
17 $form_display->fixErrors();
18 // drop post data
19 header('HTTP/1.1 303 See Other');
20 header('Location: index.php');
21 exit;
23 if (!$form_display->process(false)) {
24 // handle form view and failed POST
25 $form_display->display(true, true);
26 } else {
27 // check for form errors
28 if ($form_display->hasErrors()) {
29 // form has errors, show warning
30 $separator = PMA_get_arg_separator('html');
31 $page = filter_input(INPUT_GET, 'page');
32 $formset = filter_input(INPUT_GET, 'formset');
33 $formset = $formset ? "{$separator}formset=$formset" : '';
34 $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
35 if ($id === null && $page == 'servers') {
36 // we've just added a new server, get it's id
37 $id = ConfigFile::getInstance()->getServerCount();
39 $id = $id ? "{$separator}id=$id" : '';
41 <div class="error">
42 <h4><?php echo __('Warning') ?></h4>
43 <?php echo __('Submitted form contains errors') ?><br />
44 <a href="?page=<?php echo $page . $formset . $id . $separator ?>mode=revert"><?php echo __('Try to revert erroneous fields to their default values') ?></a>
45 </div>
46 <?php $form_display->displayErrors() ?>
47 <a class="btn" href="index.php"><?php echo __('Ignore errors') ?></a>
48 &nbsp;
49 <a class="btn" href="?page=<?php echo $page . $formset . $id . $separator ?>mode=edit"><?php echo __('Show form') ?></a>
50 <?php
51 } else {
52 // drop post data
53 header('HTTP/1.1 303 See Other');
54 header('Location: index.php');
55 exit;