Get current page url

@param string $linkUrl Link url

@return null|string
182832
protected function getPageUrl($linkUrl)
    {
        $linkParts = parse_url($linkUrl);

        // Remove left / (but only if not root page)
        if ($linkParts['path'] === '/') {
            // Link points to root page
            $ret = '/';
        } else {
            // Link points to another page, strip left /
            $ret = ltrim($linkParts['path'], '/');
        }

        // Add query
        if (!empty($linkParts['query'])) {
            $ret .= '?' . $linkParts['query'];
        }

        return $ret;
    }
433036
function current_page_url() {
            $url = 'http';

            if ( isset( $_SERVER["HTTPS"] ) ) {
                if ( $_SERVER["HTTPS"] == "on" ) {
                    $url .= "s";
                }
            }
            $url .= "://";
            if ( $_SERVER["SERVER_PORT"] != "80" ) {
                $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
            } else {
                $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
            }

            return esc_url( $url );
        }
166982
public static function getUrl($url = false)
    {
        $url = false !== $url ? $url : self::$_url;
        return $url;
    }
1058902
protected function getLink($url, $curpage)
    {
        $url               = strpos($url, '?') === false ? $url . '?' . $this->param . '=' : $url . '&' . $this->param . '=';
        list($start, $end) = $this->getPageBound($curpage);

        $links   = [];
        $links[] = '<a href="' . $url . '1" class="firstpage">' . $this->label['first'] . '</a>';
        $links[] = '<a href="' . $this->getPrevUrl($curpage, $url) . '" class="prevpage">' . $this->label['prev'] . '</a>';
        for ($i = $start; $i <= $end; $i++) {
            if ($i == $curpage) {
                $links[] = '<a href="javascript:;" class="curpage">' . $i . '</a>';
            } else {
                $links[] = '<a href="' . $url . $i . '" class="pagenum">' . $i . '</a>';
            }
        }
        $links[] = '<a href="' . $this->getNextUrl($curpage, $url) . '" class="nextpage">' . $this->label['next'] . '</a>';
        $links[] = '<a href="' . $url . $this->totalpage . '" class="lastpage">' . $this->label['last'] . '</a>';
        return $links;
    }
123677
public function getLinkUrl(LinkRelation $relation)
    {
        $links = $this->getLinks();

        foreach ($links as $link) {
            if ($link['relation'] == $relation->toNative()) {
                return $link['uri'];
            }
        }

        return null;
    }
549734
public function getLinkURL()
    {
        if (!$this->ID) {
            return '';
        }

        $type = $this->Type;
        switch ($type) {
            case 'URL':
                $LinkURL = $this->URL;
                break;
            case 'Email':
                $LinkURL = $this->Email ? "mailto:$this->Email" : null;
                break;
            case 'Phone':
                $LinkURL = $this->Phone ? "tel:$this->Phone" : null;
                break;
            default:
                if ($this->getTypeHasDbField()) {
                    $LinkURL = $this->{$type};
                } else {
                    if ($type && $component = $this->getComponent($type)) {
                        if (!$component->exists()) {
                            $LinkURL = false;
                        } elseif ($component->hasMethod('Link')) {
                            $LinkURL = $component->Link() . $this->Anchor;
                        } else {
                            $LinkURL = "Please implement a Link() method on your dataobject \"$type\"";
                        }
                    }
                }
                break;
        }

        $this->extend('updateLinkURL', $LinkURL);

        return $LinkURL;
    }
528963
public function getUrl($url)
    {
        if (!$url || starts_with($url, ['#', '//', 'mailto:', 'tel:', 'http'])) {
            return $url;
        }

        // Get URL root
        $root = $this->app->getSetting('url');

        $url = trim($root, '/') . '/' . trim($url, '/');

        // Force trailing slash
        if ($this->app->getSetting('url_trailing_slash', false)
            && ! strrchr(basename($url), '.')
        ) {
            $url = "{$url}/";
        }

        return $url;
    }
200098
public static function getCurrentUrl(): string
    {
        $siteUrl = self::getSiteUrl();
        
        $request = self::getServerVariable('REQUEST_URI', self::getServerVariable('PHP_SELF', ''));
        $query = self::getQueryString();
        
        $indexPhpFound = strpos($request, INDEX_FILE);
        if (!USE_INDEX_FILE && ($indexPhpFound === 0 || $indexPhpFound === 1)) {
            // remove index.php
            $request = str_replace(INDEX_FILE, '', $request);
        }
        
        $currentUrl = $siteUrl . $request;
        if (!empty($query) && strpos($request, $query) === false) {
            $currentUrl .= '?' . $query;
        }
        
        return preg_replace("#([^:])//+#", "$1/", $currentUrl);
    }
557481
public function currentPageUrl($parameters = [], $routePersistence = true)
    {
        if (!$currentFile = $this->page->getFileName()) {
            return null;
        }

        return $this->pageUrl($currentFile, $parameters, $routePersistence);
    }
1299663
public function getCurrentUrl($queryString = true)
    {
        $rs    = $this->getServer('REQUEST_SCHEME');
        $https = $this->getServer('HTTPS') == 'on' ? true : false;
        $sn    = $this->getServer('SERVER_NAME');
        $port  = $this->getServer('SERVER_PORT');

        $port  = ($port == '80')
            ? ''
            : (($port == 443 && $https)
                ? ''
                : ':' . $port);

        if ($queryString) {
            $ru = rtrim($this->getServer('REQUEST_URI'), '/');
        } else {
            $ru = rtrim(strtok($this->getServer('REQUEST_URI'), '?'), '/');
        }

        $url  = $rs ? $rs : 'http';
        //$url .= $https ? 's' : '';
        $url .= '://';
        $url .= $sn . $port . htmlspecialchars($ru);
        
        return $url;
    }
710498
public function getPagination($url)
    {
        $gets = null;
        $gets = $this->gets;
        $page = $this->page;
        $gets['pageSize'] = $this->pageSize;
        if ($page > 1) {
            $gets['page'] = 1;
            $newUrl = URLUtil::addParameter($url, $gets);
            $laquo = "<li><a href=\"{$newUrl}\">&laquo;</a></li>";
            $gets['page'] = $page - 1;
            $newUrl = URLUtil::addParameter($url, $gets);
            $left = "<li><a href=\"{$newUrl}\">&lt;</a></li>";
        } else {
            $laquo = "<li class=\"disabled\"><a href='#'>&laquo;</a></li>";
            $left = "<li class=\"disabled\"><a href='#'>&lt;</a></li>";
        }
        if ($page < $this->total) {
            $gets['page'] = $this->total;
            $newUrl = URLUtil::addParameter($url, $gets);
            $raquo = "<li><a href=\"{$newUrl}\">&raquo;</a></li>";
            $gets['page'] = $page + 1;
            $newUrl = URLUtil::addParameter($url, $gets);
            $right = "<li><a href=\"{$newUrl}\">&gt;</a></li>";
        } else {
            $raquo = "<li class=\"disabled\"><a href='#'>&raquo;</a></li>";
            $right = "<li class=\"disabled\"><a href='#'>&gt;</a></li>";
        }

        $otherPages = [];
        $start = 1;
        if ($this->total > 5) {
            $start = $page;
            while (true) {
                if ($start - 2 >= 1 && $start + 2 <= $this->total) {
                    break;
                } else if ($start - 2 <= 1) {
                    $start++;
                } else if ($start + 2 >= $this->total) {
                    $start--;
                }
            }
            $end = $start + 2;
            $start -= 2;
        } else {
            $end = $this->total;
        }
        for ($i = $start; $i <= $end; $i++) {
            if ($page == $i) {
                $otherPages[] = "<li class=\"active\"><a href=\"#\">{$i}</a></li>";
            } else {
                $gets['page'] = $i;
                $newUrl = URLUtil::addParameter($url, $gets);
                $otherPages[] = "<li><a href=\"{$newUrl}\">{$i}</a></li>";
            }
        }

        array_unshift($otherPages, $left);
        array_unshift($otherPages, $laquo);
        array_push($otherPages, $right);
        array_push($otherPages, $raquo);
        $html = '<ul class="pagination">' . join("\n", $otherPages) . '</ul>';
        return $html;
    }
1135267
public function getCuztomUrl($path = __FILE__, $url = [])
    {
        // Retun URL if defined
        if (defined('CUZTOM_URL')) {
            return CUZTOM_URL;
        }

        // Base vars
        $path = dirname($path);
        $path = str_replace('\\', '/', $path);
        $expath = explode('/', $path);
        $current = $expath[count($expath) - 1];

        // Push to path array
        array_push($url, $current);

        // Check for current
        if (preg_match('/content|app/', $current)) {
            $path = '';
            $directories = array_reverse($url);

            foreach ($directories as $dir) {
                if (! preg_match('/content|app/', $dir)) {
                    $path = $path.'/'.$dir;
                }
            }

            return apply_filters('cuztom_url', WP_CONTENT_URL.$path);
        } else {
            return $this->getCuztomUrl($path, $url);
        }
    }
894484
public static function getRelativeUrl($url = null) {
        $url = is_null($url) ? '/'.ltrim($_SERVER['REQUEST_URI'], '/') : $url;
        $rootUrlPath	= parse_url(ROOT_URL, PHP_URL_PATH);
        $absPath		= parse_url($url, PHP_URL_PATH);
        if (substr($absPath, 0, strlen($rootUrlPath)) != $rootUrlPath ) {
            throw new ResolverException('Request Uri '.$url.' outside of TAO path '.ROOT_URL);
        }
        if ($absPath === $rootUrlPath) {
            $result = '';
        } else {
            $result = substr($absPath, strlen($rootUrlPath));
        }
        return $result;
    }
126897
public static function getCurrentPage($url = '')
    {
        if (static::$currentPage !== false) {
            return static::$currentPage;
        }
        /** @var static $model */
        $model = static::find()->where([
            'url' => preg_replace('/[\/]{2,}/', '/', '/' . $url . '/'),
            'visible' => static::VISIBLE_YES
        ])->orderBy('id DESC')->one();
        if (!$model) {
            return static::$currentPage = null;
        }
        if ($model->layout) {
            Yii::$app->controller->layout = $model->layout;
        }
        Yii::$app->view->title = $model->page_title;
        Yii::$app->view->registerMetaTag(['name' => 'description', 'content' => $model->page_description]);
        Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => $model->page_keywords]);
        return static::$currentPage = $model;
    }
360351
public function getAction($url)
    {
        // Current route holder
        $current =  false;

        // Get requested method
        $method = $this->app->request->method() ? : 'GET';
        $method = strtolower($method);

        // Check all routes until one matches
        foreach ($this->routes[$method] as $route) {
            $matches = [];
            if (preg_match($route['pattern'], $url, $matches)) {
                if (!empty($matches)) {
                    array_shift($matches);
                    $route['params'] = array_combine(
                        $route['params'],
                        $matches
                    );
                }
                $current = $route;
                break;
            }
        }

        // Abort if none of the routes matched
        if (!$current) {
            throw new \Exception('Route not found', 404);
        }

        // Return current route
        return $current;
    }
159411
public static function get_currentUrl($filter = array(), $queryFilter = array(), $queryFilterMethod = 'remove')
    {
        if (!is_array($filter) && !empty($filter)) {
            $filter = array($filter);
        }

        if (!empty(self::$fakeCurrentUrl)) {
            $pageURL = self::$fakeCurrentUrl;
        } else {
            $pageURL = self::get_realCurrentUrl();
        }

        if (empty($filter) && empty($queryFilter)) {
            return $pageURL;
        }

        if (empty($filter)) {
            $filter = array('http', 'name', 'port', 'path', 'request');
        }

        $urlParts = parse_url($pageURL);

        if (!in_array('http', $filter)) {
            $pageURL = preg_replace('#.*://#', '', $pageURL);
        }

        if (!in_array('name', $filter) && !in_array('host', $filter) && array_key_exists('host', $urlParts)) {
            $pageURL = str_replace($urlParts['host'], '', $pageURL);
        }

        if (!in_array('port', $filter) && array_key_exists('port', $urlParts)) {
            $pageURL = str_replace(':'.$urlParts['port'], '', $pageURL);
        }
        
        if (!in_array('path', $filter) && array_key_exists('path', $urlParts)) {
            $pageURL = str_replace($urlParts['path'], '', $pageURL);
        }

        if ((in_array('request', $filter) || in_array('query', $filter)) && array_key_exists('query', $urlParts)) {
            if (!empty($queryFilter) && is_array($queryFilter)) {
                parse_str($urlParts['query'], $query);
                

                self::filter_data($query, $queryFilter, $queryFilterMethod);

                $pageURL = explode('?', $pageURL);

                if (empty($query)) {
                    unset($pageURL[1]);
                } else {
                    $pageURL[1] = http_build_query($query);
                }

                $pageURL = implode('?', $pageURL);
            }
        } else {
            $pageURL = preg_replace('/\?.*/', '', $pageURL);
        }

        return $pageURL;
    }
619255
public function getLinkMain() {
        if($this->currentPageID()!=0 && $this->class=='CodeBankEditSnippet') {
            return $this->LinkWithSearch(Controller::join_links($this->Link('show'), $this->currentPageID()));
        }else if($this->currentPageID()!=0 && $this->class=='CodeBank') {
            $otherID=null;
            if(!empty($this->urlParams['OtherID']) && is_numeric($this->urlParams['OtherID'])) {
                $otherID=intval($this->urlParams['OtherID']);
            }
            
            return $this->LinkWithSearch(Controller::join_links($this->Link('show'), $this->currentPageID(), $otherID));
        }
        
        return $this->LinkWithSearch(singleton('CodeBank')->Link());
    }