File: form_processing.lib.php

package info (click to toggle)
phpmyadmin 4%3A3.3.7-11
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 19,656 kB
  • ctags: 112,701
  • sloc: php: 196,369; sh: 617; sql: 208; perl: 142; python: 105; makefile: 42
file content (61 lines) | stat: -rw-r--r-- 2,467 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
 * Formset processing library
 *
 * @package    phpMyAdmin-setup
 * @author     Piotr Przybylski <piotrprz@gmail.com>
 * @license    http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
 * @version    $Id$
 */

/**
 * Processes forms registered in $form_display, handles error correction
 *
 * @param FormDisplay $form_display
 */
function process_formset(FormDisplay $form_display) {
	if (isset($_GET['mode']) && $_GET['mode'] == 'revert') {
        // revert erroneous fields to their default values
        $form_display->fixErrors();
        // drop post data
        header('HTTP/1.1 303 See Other');
        header('Location: index.php');
        exit;
    }
    if (!$form_display->process(false)) {
        // handle form view and failed POST
        $form_display->display(true, true);
    } else {
        // check for form errors
        if ($form_display->hasErrors()) {
            // form has errors, show warning
            $separator = PMA_get_arg_separator('html');
            $page = isset($_GET['page']) ? $_GET['page'] : null;
            $formset = isset($_GET['formset']) ? $_GET['formset'] : null;
            $formset = $formset ? "{$separator}formset=$formset" : '';
            $id = PMA_isValid($_GET['id'], 'numeric') ? $_GET['id'] : null;
            if ($id === null && $page == 'servers') {
            	// we've just added a new server, get it's id
            	$id = ConfigFile::getInstance()->getServerCount();
            }
            $id = $id ? "{$separator}id=$id" : '';
            ?>
            <div class="warning">
                <h4><?php echo $GLOBALS['strSetupWarning'] ?></h4>
                <?php echo PMA_lang('error_form') ?><br />
                <a href="?page=<?php echo $page . $formset . $id . $separator . PMA_generate_common_url() . $separator ?>mode=revert"><?php echo PMA_lang('RevertErroneousFields') ?></a>
            </div>
            <?php $form_display->displayErrors() ?>
            <a class="btn" href="index.php?<?php echo PMA_generate_common_url() ?>"><?php echo PMA_lang('IgnoreErrors') ?></a>
            &nbsp;
            <a class="btn" href="?page=<?php echo $page . $formset . $id . $separator . PMA_generate_common_url() . $separator ?>mode=edit"><?php echo PMA_lang('ShowForm') ?></a>
            <?php
        } else {
            // drop post data
            header('HTTP/1.1 303 See Other');
            header('Location: index.php');
            exit;
        }
    }
}
?>