PMA\libraries\Util::getListNavigator PHP Method

getListNavigator() public static method

Prepare navigation for a list
public static getListNavigator ( integer $count, integer $pos, array $_url_params, string $script, string $frame, integer $max_count, string $name = 'pos', string[] $classes = [] ) : string
$count integer number of elements in the list
$pos integer current position in the list
$_url_params array url parameters
$script string script name for form target
$frame string target frame
$max_count integer maximum number of elements to display from the list
$name string the name for the request parameter
$classes string[] additional classes for the container
return string $list_navigator_html the html content
    public static function getListNavigator($count, $pos, $_url_params, $script, $frame, $max_count, $name = 'pos', $classes = array())
    {
        $class = $frame == 'frame_navigation' ? ' class="ajax"' : '';
        $list_navigator_html = '';
        if ($max_count < $count) {
            $classes[] = 'pageselector';
            $list_navigator_html .= '<div class="' . implode(' ', $classes) . '">';
            if ($frame != 'frame_navigation') {
                $list_navigator_html .= __('Page number:');
            }
            // Move to the beginning or to the previous page
            if ($pos > 0) {
                $caption1 = '';
                $caption2 = '';
                if (self::showIcons('TableNavigationLinksMode')) {
                    $caption1 .= '&lt;&lt; ';
                    $caption2 .= '&lt; ';
                }
                if (self::showText('TableNavigationLinksMode')) {
                    $caption1 .= _pgettext('First page', 'Begin');
                    $caption2 .= _pgettext('Previous page', 'Previous');
                }
                $title1 = ' title="' . _pgettext('First page', 'Begin') . '"';
                $title2 = ' title="' . _pgettext('Previous page', 'Previous') . '"';
                $_url_params[$name] = 0;
                $list_navigator_html .= '<a' . $class . $title1 . ' href="' . $script . URL::getCommon($_url_params) . '">' . $caption1 . '</a>';
                $_url_params[$name] = $pos - $max_count;
                $list_navigator_html .= ' <a' . $class . $title2 . ' href="' . $script . URL::getCommon($_url_params) . '">' . $caption2 . '</a>';
            }
            $list_navigator_html .= '<form action="' . basename($script) . '" method="post">';
            $list_navigator_html .= URL::getHiddenInputs($_url_params);
            $list_navigator_html .= self::pageselector($name, $max_count, floor(($pos + 1) / $max_count) + 1, ceil($count / $max_count));
            $list_navigator_html .= '</form>';
            if ($pos + $max_count < $count) {
                $caption3 = '';
                $caption4 = '';
                if (self::showText('TableNavigationLinksMode')) {
                    $caption3 .= _pgettext('Next page', 'Next');
                    $caption4 .= _pgettext('Last page', 'End');
                }
                if (self::showIcons('TableNavigationLinksMode')) {
                    $caption3 .= ' &gt;';
                    $caption4 .= ' &gt;&gt;';
                    if (!self::showText('TableNavigationLinksMode')) {
                    }
                }
                $title3 = ' title="' . _pgettext('Next page', 'Next') . '"';
                $title4 = ' title="' . _pgettext('Last page', 'End') . '"';
                $_url_params[$name] = $pos + $max_count;
                $list_navigator_html .= '<a' . $class . $title3 . ' href="' . $script . URL::getCommon($_url_params) . '" >' . $caption3 . '</a>';
                $_url_params[$name] = floor($count / $max_count) * $max_count;
                if ($_url_params[$name] == $count) {
                    $_url_params[$name] = $count - $max_count;
                }
                $list_navigator_html .= ' <a' . $class . $title4 . ' href="' . $script . URL::getCommon($_url_params) . '" >' . $caption4 . '</a>';
            }
            $list_navigator_html .= '</div>' . "\n";
        }
        return $list_navigator_html;
    }

Usage Example

コード例 #1
0
 /**
  * Index action
  *
  * @return void
  */
 public function indexAction()
 {
     // Add/Remove favorite tables using Ajax request.
     if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) {
         $this->addRemoveFavoriteTablesAction();
         return;
     }
     // If there is an Ajax request for real row count of a table.
     if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) {
         $this->handleRealRowCountRequestAction();
         return;
     }
     // Drops/deletes/etc. multiple tables if required
     if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) {
         $this->multiSubmitAction();
     }
     $this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js'));
     $this->_url_query .= '&amp;goto=db_structure.php';
     // Gets the database structure
     $sub_part = '_structure';
     list($tables, $num_tables, $total_num_tables, , $is_show_stats, $db_is_system_schema, , , $pos) = Util::getDbInfo($GLOBALS['db'], $sub_part);
     $this->_tables = $tables;
     // updating $tables seems enough for #11376, but updating other
     // variables too in case they may cause some other problem.
     $this->_num_tables = $num_tables;
     $this->_pos = $pos;
     $this->_db_is_system_schema = $db_is_system_schema;
     $this->_total_num_tables = $total_num_tables;
     $this->_is_show_stats = $is_show_stats;
     include_once 'libraries/replication.inc.php';
     PageSettings::showGroup('DbStructure');
     // 1. No tables
     if ($this->_num_tables == 0) {
         $this->response->addHTML(Message::notice(__('No tables found in database.')));
         if (empty($db_is_system_schema)) {
             $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
         }
         return;
     }
     // else
     // 2. Shows table information
     /**
      * Displays the tables list
      */
     $this->response->addHTML('<div id="tableslistcontainer">');
     $_url_params = array('pos' => $this->_pos, 'db' => $this->db);
     // Add the sort options if they exists
     if (isset($_REQUEST['sort'])) {
         $_url_params['sort'] = $_REQUEST['sort'];
     }
     if (isset($_REQUEST['sort_order'])) {
         $_url_params['sort_order'] = $_REQUEST['sort_order'];
     }
     $this->response->addHTML(Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     $this->displayTableList();
     // display again the table list navigator
     $this->response->addHTML(Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']));
     $this->response->addHTML('</div><hr />');
     /**
      * Work on the database
      */
     /* DATABASE WORK */
     /* Printable view of a table */
     $this->response->addHTML(Template::get('database/structure/print_view_data_dictionary_link')->render(array('url_query' => $this->_url_query)));
     if (empty($this->_db_is_system_schema)) {
         $this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
     }
 }
All Usage Examples Of PMA\libraries\Util::getListNavigator
Util