lib/Pico.php
public function getPageUrl($page, $queryData = null, $dropIndex = true)
    {
        if (is_array($queryData)) {
            $queryData = http_build_query($queryData, '', '&');
        } elseif (($queryData !== null) && !is_string($queryData)) {
            throw new InvalidArgumentException(
                'Argument 2 passed to ' . get_called_class() . '::getPageUrl() must be of the type array or string, '
                . (is_object($queryData) ? get_class($queryData) : gettype($queryData)) . ' given'
            );
        }

        // drop "index"
        if ($dropIndex) {
            if ($page === 'index') {
                $page = '';
            } elseif (($pagePathLength = strrpos($page, '/')) !== false) {
                if (substr($page, $pagePathLength + 1) === 'index') {
                    $page = substr($page, 0, $pagePathLength);
                }
            }
        }

        if ($queryData) {
            $queryData = ($this->isUrlRewritingEnabled() || !$page) ? '?' . $queryData : '&' . $queryData;
        } else {
            $queryData = '';
        }

        if (!$page) {
            return $this->getBaseUrl() . $queryData;
        } elseif (!$this->isUrlRewritingEnabled()) {
            return $this->getBaseUrl() . '?' . rawurlencode($page) . $queryData;
        } else {
            return $this->getBaseUrl() . implode('/', array_map('rawurlencode', explode('/', $page))) . $queryData;
        }
    }
public function getPageUrl($page, $queryData = null, $dropIndex = true)
    {
        if (is_array($queryData)) {
            $queryData = http_build_query($queryData, '', '&');
        } elseif (($queryData !== null) && !is_string($queryData)) {
            throw new InvalidArgumentException(
                'Argument 2 passed to ' . get_called_class() . '::getPageUrl() must be of the type array or string, '
                . (is_object($queryData) ? get_class($queryData) : gettype($queryData)) . ' given'
            );
        }

        // drop "index"
        if ($dropIndex) {
            if ($page === 'index') {
                $page = '';
            } elseif (($pagePathLength = strrpos($page, '/')) !== false) {
                if (substr($page, $pagePathLength + 1) === 'index') {
                    $page = substr($page, 0, $pagePathLength);
                }
            }
        }

        if ($queryData) {
            $queryData = ($this->isUrlRewritingEnabled() || !$page) ? '?' . $queryData : '&' . $queryData;
        } else {
            $queryData = '';
        }

        if (!$page) {
            return $this->getBaseUrl() . $queryData;
        } elseif (!$this->isUrlRewritingEnabled()) {
            return $this->getBaseUrl() . '?' . rawurlencode($page) . $queryData;
        } else {
            return $this->getBaseUrl() . implode('/', array_map('rawurlencode', explode('/', $page))) . $queryData;
        }
    }
public function getPageUrl ( $ page , $ queryData = null , $ dropIndex = true ) { if ( is_array ( $ queryData ) ) { $ queryData = http_build_query ( $ queryData , '' , '&' ) ; } elseif ( ( $ queryData !== null ) && ! is_string ( $ queryData ) ) { throw new InvalidArgumentException ( 'Argument 2 passed to ' . get_called_class ( ) . '::getPageUrl() must be of the type array or string, ' . ( is_object ( $ queryData ) ? get_class ( $ queryData ) : gettype ( $ queryData ) ) . ' given' ) ; } // drop "index" if ( $ dropIndex ) { if ( $ page === 'index' ) { $ page = '' ; } elseif ( ( $ pagePathLength = strrpos ( $ page , '/' ) ) !== false ) { if ( substr ( $ page , $ pagePathLength + 1 ) === 'index' ) { $ page = substr ( $ page , 0 , $ pagePathLength ) ; } } } if ( $ queryData ) { $ queryData = ( $ this -> isUrlRewritingEnabled ( ) || ! $ page ) ? '?' . $ queryData : '&' . $ queryData ; } else { $ queryData = '' ; } if ( ! $ page ) { return $ this -> getBaseUrl ( ) . $ queryData ; } elseif ( ! $ this -> isUrlRewritingEnabled ( ) ) { return $ this -> getBaseUrl ( ) . '?' . rawurlencode ( $ page ) . $ queryData ; } else { return $ this -> getBaseUrl ( ) . implode ( '/' , array_map ( 'rawurlencode' , explode ( '/' , $ page ) ) ) . $ queryData ; } }
Returns the URL to a given page

This method can be used in Twig templates by applying the `link` filter
to a string representing a page ID.

@param string            $page      ID of the page to link to
@param array|string|null $queryData either an array of properties to
create a URL-encoded query string from, or a already encoded string
@param bool              $dropIndex if the last path component is
"index", passing TRUE (default) will remove this path component

@return string URL
Returns the URL to a given page