コード例 #1
0
/**
 * Displays a navigation bar to browse among the results of a SQL query
 *
 * @uses    $_SESSION['tmp_user_values']['disp_direction']
 * @uses    $_SESSION['tmp_user_values']['repeat_cells']
 * @uses    $_SESSION['tmp_user_values']['max_rows']
 * @uses    $_SESSION['tmp_user_values']['pos']
 * @param   integer  the offset for the "next" page
 * @param   integer  the offset for the "previous" page
 * @param   string   the URL-encoded query
 * @param   string   the id for the direction dropdown 
 *
 * @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 border="0" cellpadding="2" cellspacing="0">
<tr>
    <?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;', $GLOBALS['strPos1'], 0, $html_sql_query);
        PMA_displayTableNavigationOneButton('&lt;', $GLOBALS['strPrevious'], $pos_prev, $html_sql_query);
    }
    // end move back
    ?>
<td>
    &nbsp;&nbsp;&nbsp;
</td>
<td align="center">
<?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
    ?>
    <form action="sql.php" method="post"
onsubmit="return (checkFormElementInRange(this, 'session_max_rows', '<?php 
    echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']);
    ?>
', 1) &amp;&amp; checkFormElementInRange(this, 'pos', '<?php 
    echo str_replace('\'', '\\\'', $GLOBALS['strInvalidRowNumber']);
    ?>
', 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" value="<?php 
    echo $GLOBALS['strShow'];
    ?>
 :" />
        <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 
    echo $GLOBALS['strRowsFrom'] . "\n";
    ?>
        <input type="text" name="pos" size="6" value="<?php 
    echo $pos_next >= $unlim_num_rows ? 0 : $pos_next;
    ?>
" class="textfield" onfocus="this.select()" />
        <br />
    <?php 
    // Display mode (horizontal/vertical and repeat headers)
    $choices = array('horizontal' => $GLOBALS['strRowsModeHorizontal'], 'horizontalflipped' => $GLOBALS['strRowsModeFlippedHorizontal'], 'vertical' => $GLOBALS['strRowsModeVertical']);
    $param1 = PMA_generate_html_dropdown('disp_direction', $choices, $_SESSION['tmp_user_values']['disp_direction'], $id_for_direction_dropdown);
    unset($choices);
    $param2 = '            <input type="text" size="3" name="repeat_cells" value="' . $_SESSION['tmp_user_values']['repeat_cells'] . '" class="textfield" />' . "\n" . '           ';
    echo '    ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
    ?>
    </form>
</td>
<td>
    &nbsp;&nbsp;&nbsp;
</td>
    <?php 
    // 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;', $GLOBALS['strNext'], $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 type="hidden" name="find_real_end" value="1" />';
            // no backquote around this message
            $onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], false) . '\')"';
        } else {
            $input_for_real_end = $onclick = '';
        }
        // display the End button
        PMA_displayTableNavigationOneButton('&gt;&gt;', $GLOBALS['strEnd'], @((ceil($unlim_num_rows / $_SESSION['tmp_user_values']['max_rows']) - 1) * $_SESSION['tmp_user_values']['max_rows']), $html_sql_query, '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') . '"', $input_for_real_end, $onclick);
    }
    // end move toward
    //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>
       &nbsp;&nbsp;&nbsp;
   </td>
   <td>
        <?php 
            //<form> for keep the form alignment of button < and <<
            ?>
        <form action="none">
        <?php 
            $_url_params = array('db' => $db, 'table' => $table, 'sql_query' => $sql_query, 'goto' => $goto);
            echo PMA_pageselector('sql.php' . PMA_generate_common_url($_url_params) . PMA_get_arg_separator('js'), $_SESSION['tmp_user_values']['max_rows'], $pageNow, $nbTotalPage, 200, 5, 5, 20, 10, $GLOBALS['strPageNumber']);
            ?>
        </form>
    </td>
        <?php 
        }
        //_if2
    }
    //_if1
    // Display the "Show all" button if allowed
    if ($GLOBALS['cfg']['ShowAll'] && $num_rows < $unlim_num_rows) {
        echo "\n";
        ?>
<td>
    &nbsp;&nbsp;&nbsp;
</td>
<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 $GLOBALS['strShowAll'];
        ?>
" />
    </form>
</td>
        <?php 
    }
    // end show all
    echo "\n";
    ?>
</tr>
</table>

    <?php 
}
コード例 #2
0
ファイル: display_tbl.lib.php プロジェクト: GStepOne/CI
/**
 * 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 nothing
 *
 * @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 border="0" cellpadding="0" cellspacing="0" class="navigation">
<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 = '';
        }
        // 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="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') . '"', $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_generate_html_dropdown('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 
}