function testGenerateHtmlDropdownWithActive()
 {
     $name = "&test_dropdown_name";
     $choices = array("value_1" => "label_1", "value&_2\"" => "label_2");
     $active_choice = "value&_2\"";
     $id = "test_<dropdown>_name";
     $result = '<select name="' . htmlspecialchars($name) . '" id="' . htmlspecialchars($id) . '">';
     foreach ($choices as $one_choice_value => $one_choice_label) {
         $result .= '<option value="' . htmlspecialchars($one_choice_value) . '"';
         if ($one_choice_value == $active_choice) {
             $result .= ' selected="selected"';
         }
         $result .= '>' . htmlspecialchars($one_choice_label) . '</option>';
     }
     $result .= '</select>';
     $this->assertEquals($result, PMA_generateHtmlDropdown($name, $choices, $active_choice, $id));
 }
/**
 * Displays a navigation bar to browse among the results of a SQL query
 *
 * @param integer $pos_next                  the offset for the "next" page
 * @param integer $pos_prev                  the offset for the "previous" page
 * @param string  $sql_query                 the URL-encoded query
 * @param string  $id_for_direction_dropdown the id for the direction dropdown
 *
 * @return void
 *
 * @global  string   $db             the database name
 * @global  string   $table          the table name
 * @global  string   $goto           the URL to go back in case of errors
 * @global  integer  $num_rows       the total number of rows returned by the
 *                                   SQL query
 * @global  integer  $unlim_num_rows the total number of rows returned by the
 *                                   SQL any programmatically appended "LIMIT" clause
 * @global  boolean  $is_innodb      whether its InnoDB or not
 * @global  array    $showtable      table definitions
 *
 * @access  private
 *
 * @see     PMA_displayTable()
 */
function PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, $id_for_direction_dropdown)
{
    global $db, $table, $goto;
    global $num_rows, $unlim_num_rows;
    global $is_innodb;
    global $showtable;
    // here, using htmlentities() would cause problems if the query
    // contains accented characters
    $html_sql_query = htmlspecialchars($sql_query);
    /**
     * @todo move this to a central place
     * @todo for other future table types
     */
    $is_innodb = isset($showtable['Type']) && $showtable['Type'] == 'InnoDB';
    ?>

<!-- Navigation bar -->
<table class="navigation nospacing nopadding">
<tr>
    <td class="navigation_separator"></td>
    <?php 
    // Move to the beginning or to the previous page
    if ($_SESSION['tmp_user_values']['pos'] && $_SESSION['tmp_user_values']['max_rows'] != 'all') {
        PMA_displayTableNavigationOneButton('&lt;&lt;', _pgettext('First page', 'Begin'), 0, $html_sql_query);
        PMA_displayTableNavigationOneButton('&lt;', _pgettext('Previous page', 'Previous'), $pos_prev, $html_sql_query);
    }
    // end move back
    $nbTotalPage = 1;
    //page redirection
    // (unless we are showing all records)
    if ('all' != $_SESSION['tmp_user_values']['max_rows']) {
        //if1
        $pageNow = @floor($_SESSION['tmp_user_values']['pos'] / $_SESSION['tmp_user_values']['max_rows']) + 1;
        $nbTotalPage = @ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']);
        if ($nbTotalPage > 1) {
            //if2
            ?>
   <td>
        <?php 
            $_url_params = array('db' => $db, 'table' => $table, 'sql_query' => $sql_query, 'goto' => $goto);
            //<form> to keep the form alignment of button < and <<
            // and also to know what to execute when the selector changes
            echo '<form action="sql.php' . PMA_generate_common_url($_url_params) . '" method="post">';
            echo PMA_pageselector($_SESSION['tmp_user_values']['max_rows'], $pageNow, $nbTotalPage, 200, 5, 5, 20, 10);
            ?>
        </form>
    </td>
        <?php 
        }
        //_if2
    }
    //_if1
    // Display the "Show all" button if allowed
    if ($num_rows < $unlim_num_rows && ($GLOBALS['cfg']['ShowAll'] || $GLOBALS['cfg']['MaxRows'] * 5 >= $unlim_num_rows)) {
        echo "\n";
        ?>
    <td>
        <form action="sql.php" method="post">
            <?php 
        echo PMA_generate_common_hidden_inputs($db, $table);
        ?>
            <input type="hidden" name="sql_query" value="<?php 
        echo $html_sql_query;
        ?>
" />
            <input type="hidden" name="pos" value="0" />
            <input type="hidden" name="session_max_rows" value="all" />
            <input type="hidden" name="goto" value="<?php 
        echo $goto;
        ?>
" />
            <input type="submit" name="navig" value="<?php 
        echo __('Show all');
        ?>
" />
        </form>
    </td>
        <?php 
    }
    // end show all
    // Move to the next page or to the last one
    if ($_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'] < $unlim_num_rows && $num_rows >= $_SESSION['tmp_user_values']['max_rows'] && $_SESSION['tmp_user_values']['max_rows'] != 'all') {
        // display the Next button
        PMA_displayTableNavigationOneButton('&gt;', _pgettext('Next page', 'Next'), $pos_next, $html_sql_query);
        // prepare some options for the End button
        if ($is_innodb && $unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
            $input_for_real_end = '<input id="real_end_input" type="hidden" ' . 'name="find_real_end" value="1" />';
            // no backquote around this message
            $onclick = '';
        } else {
            $input_for_real_end = $onclick = '';
        }
        $onsubmit = 'onsubmit="return ' . ($_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows'] < $unlim_num_rows && $num_rows >= $_SESSION['tmp_user_values']['max_rows']) ? 'true' : 'false' . '"';
        // display the End button
        PMA_displayTableNavigationOneButton('&gt;&gt;', _pgettext('Last page', 'End'), @((ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']) - 1) * $_SESSION['tmp_user_values']['max_rows']), $html_sql_query, $onsubmit, $input_for_real_end, $onclick);
    }
    // end move toward
    // show separator if pagination happen
    if ($nbTotalPage > 1) {
        echo '<td><div class="navigation_separator">|</div></td>';
    }
    ?>
    <td>
        <div class="save_edited hide">
            <input type="submit" value="<?php 
    echo __('Save edited data');
    ?>
" />
            <div class="navigation_separator">|</div>
        </div>
    </td>
    <td>
        <div class="restore_column hide">
            <input type="submit" value="<?php 
    echo __('Restore column order');
    ?>
" />
            <div class="navigation_separator">|</div>
        </div>
    </td>

<?php 
    // if displaying a VIEW, $unlim_num_rows could be zero because
    // of $cfg['MaxExactCountViews']; in this case, avoid passing
    // the 5th parameter to checkFormElementInRange()
    // (this means we can't validate the upper limit
    ?>
    <td class="navigation_goto">
        <form action="sql.php" method="post"
    onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php 
    echo str_replace('\'', '\\\'', __('%d is not valid row number.'));
    ?>
', 1) &amp;&amp; checkFormElementInRange(this, 'pos', '<?php 
    echo str_replace('\'', '\\\'', __('%d is not valid row number.'));
    ?>
', 0<?php 
    echo $unlim_num_rows > 0 ? ',' . $unlim_num_rows - 1 : '';
    ?>
))">
            <?php 
    echo PMA_generate_common_hidden_inputs($db, $table);
    ?>
            <input type="hidden" name="sql_query" value="<?php 
    echo $html_sql_query;
    ?>
" />
            <input type="hidden" name="goto" value="<?php 
    echo $goto;
    ?>
" />
            <input type="submit" name="navig" <?php 
    echo $GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : '';
    ?>
 value="<?php 
    echo __('Show');
    ?>
 :" />
            <?php 
    echo __('Start row') . ': ' . "\n";
    ?>
            <input type="text" name="pos" size="3" value="<?php 
    echo $pos_next >= $unlim_num_rows ? 0 : $pos_next;
    ?>
"
                class="textfield" onfocus="this.select()" />
            <?php 
    echo __('Number of rows') . ': ' . "\n";
    ?>
            <input type="text" name="session_max_rows" size="3" value="<?php 
    echo $_SESSION['tmp_user_values']['max_rows'] != 'all' ? $_SESSION['tmp_user_values']['max_rows'] : $GLOBALS['cfg']['MaxRows'];
    ?>
"
                class="textfield" onfocus="this.select()" />
        <?php 
    if ($GLOBALS['cfg']['ShowDisplayDirection']) {
        // Display mode (horizontal/vertical and repeat headers)
        echo __('Mode') . ': ' . "\n";
        $choices = array('horizontal' => __('horizontal'), 'horizontalflipped' => __('horizontal (rotated headers)'), 'vertical' => __('vertical'));
        echo PMA_generateHtmlDropdown('disp_direction', $choices, $_SESSION['tmp_user_values']['disp_direction'], $id_for_direction_dropdown);
        unset($choices);
    }
    printf(__('Headers every %s rows'), '<input type="text" size="3" name="repeat_cells" value="' . $_SESSION['tmp_user_values']['repeat_cells'] . '" class="textfield" />');
    echo "\n";
    ?>
        </form>
    </td>
    <td class="navigation_separator"></td>
</tr>
</table>

    <?php 
}
}
if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
    $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
    $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
}
unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
// for MYISAM there is also COMPRESSED but it can be set only by the
// myisampack utility, so don't offer here the choice because if we
// try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
// does not return a warning
// (if the table was compressed, it can be seen on the Structure page)
if (isset($possible_row_formats[$tbl_storage_engine])) {
    $current_row_format = strtoupper($showtable['Row_format']);
    echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
    echo '<td>';
    echo PMA_generateHtmlDropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format');
    unset($possible_row_formats, $current_row_format);
    echo '</td>';
    echo '</tr>';
}
?>
    </table>
</fieldset>
<fieldset class="tblFooters">
        <input type="submit" name="submitoptions" value="<?php 
echo __('Go');
?>
" />
</fieldset>
</form>
</div>