IPaging

Interface for the Paging links generator classes. This interface is to insures the class will always be backward compatible.
Source
IPaging.php
Implementations
Paging

Methods

__construct

IPaging $obj = new IPaging(array configs)

Constructor.

Arguments

    configs (array)
    Paging configs
    {
        int    page      : 1
            current page number,
        string url       : CURRENT_URL
            URL to be used for paging links,
        const  link      : Paging::LINK_QUERY
            paging link type,
        string key       : Paging::URL_KEY=page
            the key to be used in query string or URL to assign page number
            to it. e.g ?page=2 or url/page/2,
        int    max_rows  : Paging::MAX_ROWS
            max number of rows per page,
        int    max_links : Paging::MAX_LINKS
            number of links to show previous and next to the current page link.
            e.g. 6 = 2|3|4(5)6|7|8,
        int    count     :
            the total data row count,
        bool   abstract  : false
            the raw output shape. false=return a verbose array true=return a
            short and simple array,
        string js        : Arta.pageList(Paging::PAGE)
            if link=LINK_JS then you can set the JavaScript function for
            paging link clicks to this key. "Paging::PAGE" and "Paging::URL"
            strings can be used in the value and will be replaced by their
            real values in the paging links,
        const style      : Paging::LINK_NOM
            render setting - the paging links text display style e.g.
            "Paging::LINK_FROM_TO"=[1-10][11-20][21-30] or
            "Paging::LINK_NOM"=[1][2][3],
        string next      : _(next)
            render setting - text label for the "next" link,
        string previous  : _(prev)
            render setting - text label for the "previous" link,
        string first     : _(first)
            render setting - text label for the "first" link,
        string last      : _(last)
            render setting - text label for the "last" link,
        string tag       : li
            render setting - link container tags,
        string info      : _(Paging::FROM - Paging::TO / Paging::COUNT)
            render setting - template for the extra info being shown beside
            the links. "Paging::FROM", "Paging::TO" and "Paging::COUNT" will
            be replaced with their real values. set to null to disable
            this feature,
        string infopos   : right
            render setting - the place to show the extra info
            may be "right or "left" to the paging links,
        string midware   : null
            render setting - name of a static class method as "Class::method"
            all the link labels will be passed to this method and the
            returned value  will be used instead. this can be useful to
            customize the label texts,
        string leftbox   : null
            render setting - a custom string to be placed left to the links,
        string rightbox  : null
            render setting - a custom string to be placed right to the links,
    }
    

Returns

void

current

int $obj->current()

Get current page number.

Returns

int
Current page number

raw

array $obj->raw()

Get raw paging links data structure. To be used for manually rendering paging links.

Returns

array
Based on setting key "abstract" returns one the following structures:
If in the configs "abstract"=true then returns {
    int   count : the total data row count,
    bool  js    : true=JavaScript functions have been used on the links,
    array links : [
        {
            int    page : link page number,
            string url  : link URL or JavaScript function,
            int    from : the page for this link starts with this row number,
            int    to   : the page for this link ends with this row number,
        },
    ]
}

If in the configs "abstract"=false then returns {
    int   count : the total data row count,
    bool  js    : true=JavaScript functions have been used on the links,
    array links : [
        {
            int    page : link page number,
            string url  : link URL or JavaScript function,
            int    from : the page for this link starts with this row number,
            int    to   : the page for this link ends with this row number,
        },
    ]
    array first : {
        int  page   :  1,
        bool active :  suggests to enable or disabled the link,
    },
    array last : {
        int  page   :  the last page number,
        bool active :  suggests to enable or disabled the link,
    },
    array previous : {
        int  page   :  the previous page number,
        bool active :  suggests to enable or disabled the link,
    },
    array next : {
        int  page   :  the next page number,
        bool active :  suggests to enable or disabled the link,
    },
    array current : {
        int  page   :  the current page number,
        bool active :  suggests to enable or disabled the link,
    }
}

render

string $obj->render()

Get rendered paging links as HTML.

Returns

string
Paging links HTML