Paging

Renders paging links as HTML or in an array.
Source
Paging.php
Implements
IPaging
Depends on
Arta

Constants

MAX_ROWS = 30

The number of rows in a page.

URL_KEY = 'page'

Parameter to set page number to, in a URL e.g. url/?page=3 or path1/path2/page/3.

Properties

pages

$obj->pages

After calling raw() or render() this property will be set to the number of pages so the programmer can use this number.

Since
Artaengine 1.2.0',

Static Methods

queryKeys

void Paging::queryKeys()

Todo
this stupid method must be removed

Returns

void

Methods

__construct

Paging $obj = new Paging(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

__get

mixed __get(string key)

Get a paging setting.

Arguments

    key (string)
    Setting key

Returns

mixed
Setting value

__set

void __set(string key, mixed val)

Set a paging setting.

Arguments

    key (string)
    Setting key
    val (mixed)
    Setting Value

Returns

void

current

int $obj->current()

Get current page number.

Returns

int
Current page number

getConfigs

array $obj->getConfigs()

Get paging configs.

Returns

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,
}

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

setConfigs

void $obj->setConfigs(array configs)

Set paging configs.

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