Merge branch 'QA_3_3'
[phpmyadmin/dkf.git] / setup / lib / form_processing.lib.php
blobda72f57cb6b7c86e4d5d551b0bd940deb654a925
1 <?php
2 /**
3 * Formset processing library
5 * @package phpMyAdmin-setup
6 * @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
7 * @version $Id$
8 */
10 /**
11 * Processes forms registered in $form_display, handles error correction
13 * @param FormDisplay $form_display
15 function process_formset(FormDisplay $form_display) {
16 if (filter_input(INPUT_GET, 'mode') == 'revert') {
17 // revert erroneous fields to their default values
18 $form_display->fixErrors();
19 // drop post data
20 header('HTTP/1.1 303 See Other');
21 header('Location: index.php');
22 exit;
24 if (!$form_display->process(false)) {
25 // handle form view and failed POST
26 $form_display->display(true, true);
27 } else {
28 // check for form errors
29 if ($form_display->hasErrors()) {
30 // form has errors, show warning
31 $separator = PMA_get_arg_separator('html');
32 $page = filter_input(INPUT_GET, 'page');
33 $formset = filter_input(INPUT_GET, 'formset');
34 $formset = $formset ? "{$separator}formset=$formset" : '';
35 $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
36 if ($id === null && $page == 'servers') {
37 // we've just added a new server, get it's id
38 $id = ConfigFile::getInstance()->getServerCount();
40 $id = $id ? "{$separator}id=$id" : '';
42 <div class="warning">
43 <h4><?php echo $GLOBALS['strSetupWarning'] ?></h4>
44 <?php echo PMA_lang('error_form') ?><br />
45 <a href="?page=<?php echo $page . $formset . $id . $separator ?>mode=revert"><?php echo PMA_lang('RevertErroneousFields') ?></a>
46 </div>
47 <?php $form_display->displayErrors() ?>
48 <a class="btn" href="index.php"><?php echo PMA_lang('IgnoreErrors') ?></a>
49 &nbsp;
50 <a class="btn" href="?page=<?php echo $page . $formset . $id . $separator ?>mode=edit"><?php echo PMA_lang('ShowForm') ?></a>
51 <?php
52 } else {
53 // drop post data
54 header('HTTP/1.1 303 See Other');
55 header('Location: index.php');
56 exit;