pageselector() public static method

Generate a pagination selector for browsing resultsets
public static pageselector ( string $name, integer $rows, integer $pageNow = 1, integer $nbTotalPage = 1, integer $showAll = 200, integer $sliceStart = 5, integer $sliceEnd = 5, integer $percent = 20, integer $range = 10, string $prompt = '' ) : string
$name string The name for the request parameter
$rows integer Number of rows in the pagination set
$pageNow integer current page number
$nbTotalPage integer number of total pages
$showAll integer If the number of pages is lower than this variable, no pages will be omitted in pagination
$sliceStart integer How many rows at the beginning should always be shown?
$sliceEnd integer How many rows at the end should always be shown?
$percent integer Percentage of calculation page offsets to hop to a next page
$range integer Near the current page, how many pages should be considered "nearby" and displayed as well?
$prompt string The prompt to display (sometimes empty)
return string
Esempio n. 1
0
 /**
  * Possibly return a page selector for table navigation
  *
  * @param string $table_navigation_html the current navigation HTML
  *
  * @return array ($table_navigation_html, $nbTotalPage)
  *
  * @access  private
  *
  */
 private function _getHtmlPageSelector($table_navigation_html)
 {
     $pageNow = @floor($_SESSION['tmpval']['pos'] / $_SESSION['tmpval']['max_rows']) + 1;
     $nbTotalPage = @ceil($this->__get('unlim_num_rows') / $_SESSION['tmpval']['max_rows']);
     if ($nbTotalPage > 1) {
         $table_navigation_html .= '<td>';
         $_url_params = array('db' => $this->__get('db'), 'table' => $this->__get('table'), 'sql_query' => $this->__get('sql_query'), 'goto' => $this->__get('goto'), 'is_browse_distinct' => $this->__get('is_browse_distinct'));
         //<form> to keep the form alignment of button < and <<
         // and also to know what to execute when the selector changes
         $table_navigation_html .= '<form action="sql.php' . PMA_URL_getCommon($_url_params) . '" method="post">';
         $table_navigation_html .= Util::pageselector('pos', $_SESSION['tmpval']['max_rows'], $pageNow, $nbTotalPage, 200, 5, 5, 20, 10);
         $table_navigation_html .= '</form>' . '</td>';
     }
     return array($table_navigation_html, $nbTotalPage);
 }
/**
 * get the html for table navigation in Central columns page
 *
 * @param int    $total_rows total number of rows in complete result set
 * @param int    $pos        offset of first result with complete result set
 * @param string $db         current database
 *
 * @return string html for table navigation in Central columns page
 */
function PMA_getHTMLforTableNavigation($total_rows, $pos, $db)
{
    $max_rows = $GLOBALS['cfg']['MaxRows'];
    $pageNow = $pos / $max_rows + 1;
    $nbTotalPage = ceil($total_rows / $max_rows);
    $table_navigation_html = '<table style="display:inline-block;max-width:49%" ' . 'class="navigation nospacing nopadding">' . '<tr>' . '<td class="navigation_separator"></td>';
    if ($pos - $max_rows >= 0) {
        $table_navigation_html .= '<td>' . '<form action="db_central_columns.php" method="post">' . PMA_URL_getHiddenInputs($db) . '<input type="hidden" name="pos" value="' . ($pos - $max_rows) . '" />' . '<input type="hidden" name="total_rows" value="' . $total_rows . '"/>' . '<input type="submit" name="navig"' . ' class="ajax" ' . 'value="&lt" />' . '</form>' . '</td>';
    }
    if ($nbTotalPage > 1) {
        $table_navigation_html .= '<td>';
        $table_navigation_html .= '<form action="db_central_columns.php' . '" method="post">' . PMA_URL_getHiddenInputs($db) . '<input type="hidden" name="total_rows" value="' . $total_rows . '"/>';
        $table_navigation_html .= Util::pageselector('pos', $max_rows, $pageNow, $nbTotalPage);
        $table_navigation_html .= '</form>' . '</td>';
    }
    if ($pos + $max_rows < $total_rows) {
        $table_navigation_html .= '<td>' . '<form action="db_central_columns.php" method="post">' . PMA_URL_getHiddenInputs($db) . '<input type="hidden" name="pos" value="' . ($pos + $max_rows) . '" />' . '<input type="hidden" name="total_rows" value="' . $total_rows . '"/>' . '<input type="submit" name="navig"' . ' class="ajax" ' . 'value="&gt" />' . '</form>' . '</td>';
    }
    $table_navigation_html .= '</form>' . '</td>' . '<td class="navigation_separator"></td>' . '<td>' . '<span>' . __('Filter rows') . ':</span>' . '<input type="text" class="filter_rows" placeholder="' . __('Search this table') . '">' . '</td>' . '<td class="navigation_separator"></td>' . '</tr>' . '</table>';
    return $table_navigation_html;
}