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