コード例 #1
0
/**
 * Processes forms registered in $form_display, handles error correction
 *
 * @param FormDisplay $form_display
 */
function process_formset(FormDisplay $form_display)
{
    if (filter_input(INPUT_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 = filter_input(INPUT_GET, 'page');
            $formset = filter_input(INPUT_GET, 'formset');
            $formset = $formset ? "{$separator}formset=$formset" : '';
            $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
            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="error">
                <h4><?php echo __('Warning') ?></h4>
                <?php echo __('Submitted form contains errors') ?><br />
                <a href="?page=<?php echo $page . $formset . $id . $separator ?>mode=revert"><?php echo __('Try to revert erroneous fields to their default values') ?></a>
            </div>
            <?php $form_display->displayErrors() ?>
            <a class="btn" href="index.php"><?php echo __('Ignore errors') ?></a>
            &nbsp;
            <a class="btn" href="?page=<?php echo $page . $formset . $id . $separator ?>mode=edit"><?php echo __('Show form') ?></a>
            <?php
        } else {
            // drop post data
            header('HTTP/1.1 303 See Other');
            header('Location: index.php');
            exit;
        }
    }
}
コード例 #2
0
 /**
  * Test for FormDisplay::displayErrors
  *
  * @return void
  */
 public function testDisplayErrors()
 {
     $reflection = new \ReflectionClass('FormDisplay');
     $attrIsValidated = $reflection->getProperty('_isValidated');
     $attrIsValidated->setAccessible(true);
     $attrIsValidated->setValue($this->object, true);
     $attrIsValidated = $reflection->getProperty('_errors');
     $attrIsValidated->setAccessible(true);
     $attrIsValidated->setValue($this->object, array());
     $this->assertNull($this->object->displayErrors());
     $arr = array("Servers/1/test" => array('e1'), "foobar" => array('e2', 'e3'));
     $sysArr = array("Servers/1/test" => "Servers/1/test2");
     $attrSystemPaths = $reflection->getProperty('_systemPaths');
     $attrSystemPaths->setAccessible(true);
     $attrSystemPaths->setValue($this->object, $sysArr);
     $attrIsValidated->setValue($this->object, $arr);
     $GLOBALS['strConfigForm_foobar'] = 'foobar123';
     $this->expectOutputString('<dl><dt>Servers_test2_name</dt>' . '<dd>e1</dd></dl><dl><dt>foobar123</dt><dd>' . 'e2</dd><dd>e3</dd></dl>');
     $this->object->displayErrors();
 }
コード例 #3
0
        exit;
    } else {
        $error = $result;
    }
}
// display forms
$GLOBALS['js_include'][] = 'config.js';
require './libraries/header.inc.php';
require './libraries/user_preferences.inc.php';
if ($error) {
    $error->display();
}
if ($form_display->hasErrors()) {
    // form has errors
    ?>
    <div class="error config-form">
        <b><?php 
    echo __('Cannot save settings, submitted form contains errors');
    ?>
</b>
        <?php 
    $form_display->displayErrors();
    ?>
    </div>
    <?php 
}
$form_display->display(true, true);
/**
 * Displays the footer
 */
require './libraries/footer.inc.php';
コード例 #4
0
/**
 * Processes forms registered in $form_display, handles error correction
 *
 * @param FormDisplay $form_display Form to display
 *
 * @return void
 */
function PMA_Process_formset(FormDisplay $form_display)
{
    if (isset($_GET['mode']) && $_GET['mode'] == 'revert') {
        // revert erroneous fields to their default values
        $form_display->fixErrors();
        PMA_generateHeader303();
    }
    if (!$form_display->process(false)) {
        // handle form view and failed POST
        echo $form_display->getDisplay(true, true);
        return;
    }
    // check for form errors
    if (!$form_display->hasErrors()) {
        PMA_generateHeader303();
        return;
    }
    // form has errors, show warning
    $separator = PMA_URL_getArgSeparator('html');
    $page = isset($_GET['page']) ? $_GET['page'] : null;
    $formset = isset($_GET['formset']) ? $_GET['formset'] : null;
    $formset = $formset ? "{$separator}formset={$formset}" : '';
    $formId = PMA_isValid($_GET['id'], 'numeric') ? $_GET['id'] : null;
    if ($formId === null && $page == 'servers') {
        // we've just added a new server, get its id
        $formId = $form_display->getConfigFile()->getServerCount();
    }
    $formId = $formId ? "{$separator}id={$formId}" : '';
    ?>
    <div class="error">
        <h4><?php 
    echo __('Warning');
    ?>
</h4>
        <?php 
    echo __('Submitted form contains errors');
    ?>
<br />
        <a href="<?php 
    echo PMA_URL_getCommon() . $separator;
    ?>
page=<?php 
    echo $page . $formset . $formId . $separator;
    ?>
mode=revert">
            <?php 
    echo __('Try to revert erroneous fields to their default values');
    ?>
        </a>
    </div>
    <?php 
    echo $form_display->displayErrors();
    ?>
    <a class="btn" href="index.php<?php 
    echo PMA_URL_getCommon();
    ?>
">
        <?php 
    echo __('Ignore errors');
    ?>
    </a>
    &nbsp;
    <a class="btn" href="<?php 
    echo PMA_URL_getCommon() . $separator;
    ?>
page=<?php 
    echo $page . $formset . $formId . $separator;
    ?>
mode=edit">
        <?php 
    echo __('Show form');
    ?>
    </a>
    <?php 
}
コード例 #5
0
/**
 * Processes forms registered in $form_display, handles error correction
 *
 * @param FormDisplay $form_display Form to display
 *
 * @return void
 */
function PMA_Process_formset(FormDisplay $form_display)
{
    if (filter_input(INPUT_GET, 'mode') == 'revert') {
        // revert erroneous fields to their default values
        $form_display->fixErrors();
        PMA_generateHeader303();
    }
    if (!$form_display->process(false)) {
        // handle form view and failed POST
        $form_display->display(true, true);
        return;
    }
    // check for form errors
    if (!$form_display->hasErrors()) {
        PMA_generateHeader303();
        return;
    }
    // form has errors, show warning
    $separator = PMA_URL_getArgSeparator('html');
    $page = filter_input(INPUT_GET, 'page');
    $formset = filter_input(INPUT_GET, 'formset');
    $formset = $formset ? "{$separator}formset={$formset}" : '';
    $formId = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
    if ($formId === null && $page == 'servers') {
        // we've just added a new server, get its id
        $formId = $form_display->getConfigFile()->getServerCount();
    }
    $formId = $formId ? "{$separator}id={$formId}" : '';
    ?>
    <div class="error">
        <h4><?php 
    echo __('Warning');
    ?>
</h4>
        <?php 
    echo __('Submitted form contains errors');
    ?>
<br />
        <a href="?page=<?php 
    echo $page . $formset . $formId . $separator;
    ?>
mode=revert">
            <?php 
    echo __('Try to revert erroneous fields to their default values');
    ?>
        </a>
    </div>
    <?php 
    $form_display->displayErrors();
    ?>
    <a class="btn" href="index.php"><?php 
    echo __('Ignore errors');
    ?>
</a>
    &nbsp;
    <a class="btn" href="?page=<?php 
    echo $page . $formset . $formId . $separator;
    ?>
mode=edit"><?php 
    echo __('Show form');
    ?>
</a>
    <?php 
}
コード例 #6
0
/**
 * Processes forms registered in $form_display, handles error correction
 *
 * @param FormDisplay $form_display
 *
 * @return void
 */
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="error">
                <h4><?php 
            echo __('Warning');
            ?>
</h4>
                <?php 
            echo __('Submitted form contains errors');
            ?>
<br />
                <a href="?page=<?php 
            echo $page . $formset . $id . $separator . PMA_generate_common_url() . $separator;
            ?>
mode=revert"><?php 
            echo __('Try to revert erroneous fields to their default values');
            ?>
</a>
            </div>
            <?php 
            $form_display->displayErrors();
            ?>
            <a class="btn" href="index.php?<?php 
            echo PMA_generate_common_url();
            ?>
"><?php 
            echo __('Ignore errors');
            ?>
</a>
            &nbsp;
            <a class="btn" href="?page=<?php 
            echo $page . $formset . $id . $separator . PMA_generate_common_url() . $separator;
            ?>
mode=edit"><?php 
            echo __('Show form');
            ?>
</a>
            <?php 
        } else {
            // drop post data
            header('HTTP/1.1 303 See Other');
            header('Location: index.php');
            exit;
        }
    }
}
コード例 #7
0
            'form' => $form_param), $hash);
        exit;
    } else {
        $error = $result;
    }
}

// display forms
$GLOBALS['js_include'][] = 'config.js';
require 'libraries/header.inc.php';
require 'libraries/user_preferences.inc.php';
if ($error) {
    $error->display();
}
if ($form_display->hasErrors()) {
    // form has errors
    ?>
    <div class="error config-form">
        <b><?php echo __('Cannot save settings, submitted form contains errors') ?></b>
        <?php $form_display->displayErrors(); ?>
    </div>
    <?php
}
$form_display->display(true, true);

/**
 * Displays the footer
 */
require 'libraries/footer.inc.php';
?>