/** * Get 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 boolean $is_innodb whether its InnoDB or not * * @return string html content * * @access private * * @see _getTable() */ private function _getTableNavigation($pos_next, $pos_prev, $is_innodb) { $table_navigation_html = ''; // here, using htmlentities() would cause problems if the query // contains accented characters $html_sql_query = htmlspecialchars($this->__get('sql_query')); // Navigation bar $table_navigation_html .= '<table class="navigation nospacing nopadding">' . '<tr>' . '<td class="navigation_separator"></td>'; // Move to the beginning or to the previous page if ($_SESSION['tmpval']['pos'] && $_SESSION['tmpval']['max_rows'] != self::ALL_ROWS) { $table_navigation_html .= $this->_getMoveBackwardButtonsForTableNavigation($html_sql_query, $pos_prev); } // end move back $nbTotalPage = 1; //page redirection // (unless we are showing all records) if ($_SESSION['tmpval']['max_rows'] != self::ALL_ROWS) { //if1 $pageNow = @floor($_SESSION['tmpval']['pos'] / $_SESSION['tmpval']['max_rows']) + 1; $nbTotalPage = @ceil($this->__get('unlim_num_rows') / $_SESSION['tmpval']['max_rows']); if ($nbTotalPage > 1) { //if2 $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 .= PMA_Util::pageselector('pos', $_SESSION['tmpval']['max_rows'], $pageNow, $nbTotalPage, 200, 5, 5, 20, 10); $table_navigation_html .= '</form>' . '</td>'; } //_if2 } //_if1 $showing_all = false; if ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS) { $showing_all = true; } // Move to the next page or to the last one $endpos = $_SESSION['tmpval']['pos'] + $_SESSION['tmpval']['max_rows']; if ($endpos < $this->__get('unlim_num_rows') && $this->__get('num_rows') >= $_SESSION['tmpval']['max_rows'] && $_SESSION['tmpval']['max_rows'] != self::ALL_ROWS) { $table_navigation_html .= $this->_getMoveForwardButtonsForTableNavigation($html_sql_query, $pos_next, $is_innodb); } // end move toward // show separator if pagination happen if ($nbTotalPage > 1) { $table_navigation_html .= '<td><div class="navigation_separator">|</div></td>'; } // Display the "Show all" button if allowed if ($GLOBALS['cfg']['ShowAll'] || $this->__get('unlim_num_rows') <= 500) { $table_navigation_html .= $this->_getShowAllCheckboxForTableNavigation($showing_all, $html_sql_query); $table_navigation_html .= '<td><div class="navigation_separator">|</div></td>'; } // end show all $table_navigation_html .= '<td>' . '<div class="save_edited hide">' . '<input type="submit" value="' . __('Save edited data') . '" />' . '<div class="navigation_separator">|</div>' . '</div>' . '</td>' . '<td>' . '<div class="restore_column hide">' . '<input type="submit" value="' . __('Restore column order') . '" />' . '<div class="navigation_separator">|</div>' . '</div>' . '</td>'; // 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 $table_navigation_html .= '<td class="navigation_goto">'; $table_navigation_html .= '<form action="sql.php" method="post" ' . 'onsubmit="return ' . '(checkFormElementInRange(' . 'this, ' . '\'session_max_rows\', ' . '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) . '\', ' . '1)' . ' && ' . 'checkFormElementInRange(' . 'this, ' . '\'pos\', ' . '\'' . str_replace('\'', '\\\'', __('%d is not valid row number.')) . '\', ' . '0' . ($this->__get('unlim_num_rows') > 0 ? ', ' . ($this->__get('unlim_num_rows') - 1) : '') . ')' . ')' . '">'; $table_navigation_html .= PMA_URL_getHiddenInputs($this->__get('db'), $this->__get('table')); $table_navigation_html .= $this->_getAdditionalFieldsForTableNavigation($html_sql_query); $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') . '"' . ' data-for="' . $this->__get('unique_id') . '" />' . '</td>' . '<td class="navigation_separator"></td>' . '</tr>' . '</table>'; return $table_navigation_html; }
/** * Test for PMA_getHTMLforTableNavigation * * @return void */ public function testPMAGetHTMLforTableNavigation() { $result = PMA_getHTMLforTableNavigation(0, 0, 'phpmyadmin'); $this->assertContains('<table', $result); $this->assertContains(__('Search this table'), $result); $result_1 = PMA_getHTMLforTableNavigation(25, 10, 'phpmyadmin'); $this->assertContains('<form action="db_central_columns.php" method="post">' . PMA_URL_getHiddenInputs('phpmyadmin'), $result_1); $this->assertContains('<input type="submit" name="navig"' . ' class="ajax" ' . 'value="<" />', $result_1); $this->assertContains(PMA_Util::pageselector('pos', 10, 2, 3), $result_1); $this->assertContains('<input type="submit" name="navig"' . ' class="ajax" ' . 'value=">" />', $result_1); }
/** * 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 .= PMA_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 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="<" />' . '</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 .= PMA_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=">" />' . '</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; }
/** * Function to get html for the goto page option * * @param array $foreignData foreign data * * @return string */ function PMA_getHtmlForGotoPage($foreignData) { $gotopage = ''; isset($_REQUEST['pos']) ? $pos = $_REQUEST['pos'] : ($pos = 0); if (!is_array($foreignData['disp_row'])) { return $gotopage; } $session_max_rows = $GLOBALS['cfg']['MaxRows']; $pageNow = @floor($pos / $session_max_rows) + 1; $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows); if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) { $gotopage = PMA_Util::pageselector('pos', $session_max_rows, $pageNow, $nbTotalPage, 200, 5, 5, 20, 10, __('Page number:')); } return $gotopage; }
if (isset($rownumber)) { $rownumber_param = '&rownumber=' . urlencode($rownumber); } else { $rownumber_param = ''; } $gotopage = ''; $showall = ''; if (is_array($foreignData['disp_row'])) { if ($cfg['ShowAll'] && $foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) { $showall = '<input type="submit" name="foreign_navig" value="' . __('Show all') . '" />'; } $session_max_rows = $GLOBALS['cfg']['MaxRows']; $pageNow = @floor($pos / $session_max_rows) + 1; $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows); if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) { $gotopage = PMA_Util::pageselector('pos', $session_max_rows, $pageNow, $nbTotalPage, 200, 5, 5, 20, 10, __('Page number:')); } } if (isset($rownumber)) { $element_name = " var element_name = field + '[multi_edit][" . htmlspecialchars($rownumber) . "][' + fieldmd5 + ']';\n" . " var null_name = field_null + '[multi_edit][" . htmlspecialchars($rownumber) . "][' + fieldmd5 + ']';\n"; } else { $element_name = "var element_name = field + '[]'"; } $error = PMA_jsFormat(__('The target browser window could not be updated. ' . 'Maybe you have closed the parent window, or ' . 'your browser\'s security settings are ' . 'configured to block cross-window updates.')); if (!isset($fieldkey) || !is_numeric($fieldkey)) { $fieldkey = 0; } $code = <<<EOC self.focus(); function formupdate(fieldmd5, key) { var \$inline = window.opener.jQuery('.browse_foreign_clicked');
/** * Test for Page Selector * * @return void */ public function testPageSelector() { $this->assertContains('<select class="pageselector ajax" name="pma" >', PMA_Util::pageselector("pma", 3)); }