displayErrors() 공개 메소드

Displays errors
public displayErrors ( ) : string
리턴 string HTML for errors
예제 #1
0
 /**
  * Test for FormDisplay::displayErrors
  *
  * @return void
  */
 public function testDisplayErrors()
 {
     $reflection = new \ReflectionClass('PMA\\libraries\\config\\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';
     $result = $this->object->displayErrors();
     $this->assertEquals('<dl><dt>Servers_test2_name</dt>' . '<dd>e1</dd></dl><dl><dt>foobar123</dt><dd>' . 'e2</dd><dd>e3</dd></dl>', $result);
 }
예제 #2
0
 }
 $cf->resetConfigData();
 $all_ok = $form_display->process(true, false);
 $all_ok = $all_ok && !$form_display->hasErrors();
 $_POST = $_POST_bak;
 if (!$all_ok && isset($_POST['fix_errors'])) {
     $form_display->fixErrors();
     $all_ok = true;
 }
 if (!$all_ok) {
     // mimic original form and post json in a hidden field
     include 'libraries/user_preferences.inc.php';
     $msg = Message::error(__('Configuration contains incorrect data for some fields.'));
     $msg->display();
     echo '<div class="config-form">';
     echo $form_display->displayErrors();
     echo '</div>';
     echo '<form action="prefs_manage.php" method="post">';
     echo PMA_URL_getHiddenInputs(), "\n";
     echo '<input type="hidden" name="json" value="', htmlspecialchars($json), '" />';
     echo '<input type="hidden" name="fix_errors" value="1" />';
     if (!empty($_POST['import_merge'])) {
         echo '<input type="hidden" name="import_merge" value="1" />';
     }
     if ($return_url) {
         echo '<input type="hidden" name="return_url" value="', htmlspecialchars($return_url), '" />';
     }
     echo '<p>';
     echo __('Do you want to import remaining settings?');
     echo '</p>';
     echo '<input type="submit" name="submit_import" value="', __('Yes'), '" />';
예제 #3
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 
}