PDO4You\Pagination::getPagination PHP Method

getPagination() public static method

Displays the pagination
public static getPagination ( ) : null | string
return null | string
    public static function getPagination()
    {
        if (self::getPaging() == false) {
            return null;
        }
        $page = self::getCurrentPage();
        $total_of_pages = self::getTotalOfPages();
        $nave = '<div class="pagination">';
        if ($page != 1) {
            $nave .= '<a class="first" href="' . self::buildPaginator('1') . '">' . self::$buttons['first'] . '</a>';
        } else {
            $nave .= '<a class="first nolink">' . self::$buttons['first'] . '</a>';
        }
        if ($page != 1 && $total_of_pages > 0) {
            $nave .= '<a class="previous" href="' . self::buildPaginator($page - 1) . '">' . self::$buttons['previous'] . '</a>';
        } else {
            $nave .= '<a class="previous nolink">' . self::$buttons['previous'] . '</a>';
        }
        if ($total_of_pages == 0) {
            $nave .= '<a class="selected">1</a>';
        } else {
            for ($x = 1; $x <= $total_of_pages; $x++) {
                if ($page == $x + 3) {
                    $nave .= '<a href="' . self::buildPaginator($x) . '">' . $x . '</a>';
                }
                if ($page == $x + 2) {
                    $nave .= '<a href="' . self::buildPaginator($x) . '">' . $x . '</a>';
                }
                if ($page == $x + 1) {
                    $nave .= '<a href="' . self::buildPaginator($x) . '">' . $x . '</a>';
                }
                if ($page == $x) {
                    $nave .= '<a class="selected">' . $x . '</a>';
                }
                if ($page == $x - 1) {
                    $nave .= '<a href="' . self::buildPaginator($x) . '">' . $x . '</a>';
                }
                if ($page == $x - 2) {
                    $nave .= '<a href="' . self::buildPaginator($x) . '">' . $x . '</a>';
                }
                if ($page == $x - 3) {
                    $nave .= '<a href="' . self::buildPaginator($x) . '">' . $x . '</a>';
                }
            }
        }
        if ($page < $total_of_pages) {
            $nave .= '<a class="next" href="' . self::buildPaginator($page + 1) . '">' . self::$buttons['next'] . '</a>';
        } else {
            $nave .= '<a class="next nolink">' . self::$buttons['next'] . '</a>';
        }
        if ($page != $total_of_pages && $total_of_pages > 0) {
            $nave .= '<a class="last" href="' . self::buildPaginator($total_of_pages) . '">' . self::$buttons['last'] . '</a>';
        } else {
            $nave .= '<a class="last nolink">' . self::$buttons['last'] . '</a>';
        }
        $nave .= '</div>';
        return $nave;
    }

Usage Example

コード例 #1
0
ファイル: demo6.php プロジェクト: giovanniramos/pdo4you
: <input type="text" name="firstname" /></div>
        <div><?php 
echo $demo::LAST_NAME;
?>
: <input type="text" name="lastname" /></div>
        <div><?php 
echo $demo::MAIL;
?>
: <input type="text" name="mail" /></div>
        <div><input type="submit" value="Register" /></div>
    </form>

    <?php 
echo $demo->getMessage();
?>

    <?php 
echo $demo::TOTAL_USERS;
?>
: <?php 
echo $demo->getTotalOfRecords();
?>

    <?php 
echo $demo->showRecords();
?>

    <?php 
echo pager::getPagination();
?>
</div>