public function setUrl($url, $pattern = "/page/(:num)")
    {
        $_pattern = str_replace("(:num)", "([0-9]+)", $pattern);
        preg_match("~$_pattern~i", $url, $m);
        /**
         * No match found.
         * We'll add the pagination in the url, so this way it can be ready for next pages.
         * This way a url http://xyz.com/?q=boom , becomes http://xyz.com/?q=boom&page=2
         */
        if (count($m) == 0) {
            $pag_ = str_replace("(:num)", 0, $pattern);

            // page pattern contain the equal sign, we'll add it to the query ?page=123
            if (strpos($pattern, "=") !== false) {
                if (strpos($url, "?") !== false) {
                    $url .= "&" . $pag_;
                } else {
                    $url .= "?" . $pag_;
                }
                return $this->setUrl($url, $pattern);
            } else if (strpos($pattern, "/") !== false) { //Friendly url : /page/123
                $url_arr = explode("?", $url, 2);
                $segment = $url_arr[0];
                $query   = isset($url_arr[1]) ? $url_arr[1] : '';
                if (strpos($url, "?") !== false) {
                    if (preg_match("/\/$/", $segment)) {
                        $url = $segment . (preg_replace("/^\//", "", $pag_));
                        $url .= ((preg_match("/\/$/", $pag_)) ? "" : "/") . "?{$query}";
                    } else {
                        $url = $segment . $pag_;
                        $url .= ((preg_match("/\/$/", $pag_)) ? "" : "/") . "?{$query}";
                    }
                } else {
                    if (preg_match("/\/$/", $segment)) {
                        $url .= (preg_replace("/^\//", "", $pag_));
                    } else {
                        $url .= $pag_;
                    }
                }
                return $this->setUrl($url, $pattern);
            }
        }
        $match = current($m);
        $last = end($m);
        $page = $last ? $last : 1;

        // TemplateUrl will be used to create all the page numbers 
        $this->templateUrl = str_replace($match, preg_replace("/[0-9]+/", "(#pageNumber)", $match), $url);
        $this->current($page);
        return $this;
    }
public function setUrl($url, $pattern = "/page/(:num)")
    {
        $_pattern = str_replace("(:num)", "([0-9]+)", $pattern);
        preg_match("~$_pattern~i", $url, $m);
        /**
         * No match found.
         * We'll add the pagination in the url, so this way it can be ready for next pages.
         * This way a url http://xyz.com/?q=boom , becomes http://xyz.com/?q=boom&page=2
         */
        if (count($m) == 0) {
            $pag_ = str_replace("(:num)", 0, $pattern);

            // page pattern contain the equal sign, we'll add it to the query ?page=123
            if (strpos($pattern, "=") !== false) {
                if (strpos($url, "?") !== false) {
                    $url .= "&" . $pag_;
                } else {
                    $url .= "?" . $pag_;
                }
                return $this->setUrl($url, $pattern);
            } else if (strpos($pattern, "/") !== false) { //Friendly url : /page/123
                $url_arr = explode("?", $url, 2);
                $segment = $url_arr[0];
                $query   = isset($url_arr[1]) ? $url_arr[1] : '';
                if (strpos($url, "?") !== false) {
                    if (preg_match("/\/$/", $segment)) {
                        $url = $segment . (preg_replace("/^\//", "", $pag_));
                        $url .= ((preg_match("/\/$/", $pag_)) ? "" : "/") . "?{$query}";
                    } else {
                        $url = $segment . $pag_;
                        $url .= ((preg_match("/\/$/", $pag_)) ? "" : "/") . "?{$query}";
                    }
                } else {
                    if (preg_match("/\/$/", $segment)) {
                        $url .= (preg_replace("/^\//", "", $pag_));
                    } else {
                        $url .= $pag_;
                    }
                }
                return $this->setUrl($url, $pattern);
            }
        }
        $match = current($m);
        $last = end($m);
        $page = $last ? $last : 1;

        // TemplateUrl will be used to create all the page numbers 
        $this->templateUrl = str_replace($match, preg_replace("/[0-9]+/", "(#pageNumber)", $match), $url);
        $this->current($page);
        return $this;
    }
public function setUrl ( $ url , $ pattern = "/page/(:num)" ) { $ _pattern = str_replace ( "(:num)" , "([0-9]+)" , $ pattern ) ; preg_match ( "~$_pattern~i" , $ url , $ m ) ; /**
         * No match found.
         * We'll add the pagination in the url, so this way it can be ready for next pages.
         * This way a url http://xyz.com/?q=boom , becomes http://xyz.com/?q=boom&page=2
         */ if ( count ( $ m ) == 0 ) { $ pag_ = str_replace ( "(:num)" , 0 , $ pattern ) ; // page pattern contain the equal sign, we'll add it to the query ?page=123 if ( strpos ( $ pattern , "=" ) !== false ) { if ( strpos ( $ url , "?" ) !== false ) { $ url .= "&" . $ pag_ ; } else { $ url .= "?" . $ pag_ ; } return $ this -> setUrl ( $ url , $ pattern ) ; } else if ( strpos ( $ pattern , "/" ) !== false ) { //Friendly url : /page/123 $ url_arr = explode ( "?" , $ url , 2 ) ; $ segment = $ url_arr [ 0 ] ; $ query = isset ( $ url_arr [ 1 ] ) ? $ url_arr [ 1 ] : '' ; if ( strpos ( $ url , "?" ) !== false ) { if ( preg_match ( "/\/$/" , $ segment ) ) { $ url = $ segment . ( preg_replace ( "/^\//" , "" , $ pag_ ) ) ; $ url .= ( ( preg_match ( "/\/$/" , $ pag_ ) ) ? "" : "/" ) . "?{$query}" ; } else { $ url = $ segment . $ pag_ ; $ url .= ( ( preg_match ( "/\/$/" , $ pag_ ) ) ? "" : "/" ) . "?{$query}" ; } } else { if ( preg_match ( "/\/$/" , $ segment ) ) { $ url .= ( preg_replace ( "/^\//" , "" , $ pag_ ) ) ; } else { $ url .= $ pag_ ; } } return $ this -> setUrl ( $ url , $ pattern ) ; } } $ match = current ( $ m ) ; $ last = end ( $ m ) ; $ page = $ last ? $ last : 1 ; // TemplateUrl will be used to create all the page numbers  $ this -> templateUrl = str_replace ( $ match , preg_replace ( "/[0-9]+/" , "(#pageNumber)" , $ match ) , $ url ) ; $ this -> current ( $ page ) ; return $ this ; }
Set the URL, automatically it will parse every thing to it

@param string $url
@param string $pattern
@return static
Set the URL automatically it will parse every thing to it