Returns the full url Gems should forward to after survey completion.

This fix allows multiple sites with multiple url's to share a single
installation.

@return string
973470
protected function calculateReturnUrl()
    {
        $currentUri = $this->util->getCurrentURI();

        /*
        // Referrer would be powerful when someone is usng multiple windows, but
        // the loop does not always provide a correct referrer.
        $referrer   = $_SERVER["HTTP_REFERER"];

        // If a referrer was specified and that referral is from the current site, then use it
        // as it is more dependable when the user has multiple windows open on the application.
        if ($referrer && (0 == strncasecmp($referrer, $currentUri, strlen($currentUri)))) {
            return $referrer;
            // \MUtil_Echo::track($referrer);
        } // */

        // Use the survey return if available.
        $surveyReturn = $this->currentUser->getSurveyReturn();
        if ($surveyReturn) {
            // Do not show the base url as it is in $currentUri
            $surveyReturn['NoBase'] = true;

            // Add route reset to prevet the current parameters to be
            // added to the url.
            $surveyReturn['RouteReset'] = true;

            // \MUtil_Echo::track($currentUri, \MUtil_Html::urlString($surveyReturn));
            return $currentUri . \MUtil_Html::urlString($surveyReturn);
        }

        // Ultimate backup solution for return
        return $currentUri . '/ask/forward/' . \MUtil_Model::REQUEST_ID . '/' . urlencode($this->getTokenId());
    }
325900
public function getFullDescription()
    {
        if ($this->_description) {
            return $this->_description;
        }

        $descr        = $this->getRoundDescription();
        $hasDescr     = strlen(trim($descr));
        $order        = $this->getRoundOrder();
        $survey       = $this->getSurvey();
        $surveyExists = $survey ? $survey->exists : false;

        if ($order) {
            if ($hasDescr) {
                if ($surveyExists) {
                    $this->_description = sprintf($this->_('%d: %s - %s'), $order, $descr, $survey->getName());
                } else {
                    $this->_description = sprintf($this->_('%d: %s'), $order, $descr);
                }
            } elseif ($surveyExists) {
                $this->_description = sprintf($this->_('%d: %s'), $order, $survey->getName());
            } else {
                $this->_description = $order;
            }
        } elseif ($hasDescr) {
            if ($surveyExists) {
                $this->_description = sprintf($this->_('%s - %s'), $descr, $survey->getName());
            } else {
                $this->_description = $descr;
            }
        } else {
            if ($surveyExists) {
                $this->_description = $survey->getName();
            } else {
                $this->_description = '';
            }
        }

        return $this->_description;
    }
890709
private function getReturnBaseUrl()
    {
        $baseUrl = '';

        /** @var TaoLtiSession $session */
        $session = \common_session_SessionManager::getSession();
        if ($session instanceof TaoLtiSession) {
            $launchData = $session->getLaunchData();
            if ($launchData->hasReturnUrl()) {
                $baseUrl = $launchData->getReturnUrl();
            }
        } else {
            if ($this->launchData->hasVariable(LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL)) {
                $baseUrl = $this->launchData->getVariable(LtiLaunchData::LAUNCH_PRESENTATION_RETURN_URL);
            }
        }

        return $baseUrl;
    }
2868
public function getRedirectUrlBase()
    {
        // URLConfirmationTokens may alter the URL to suppress the URL they're protecting,
        // so we need to ensure they're inspected last and therefore take priority
        $tokens = iterator_to_array($this->filteredTokens(), false);
        usort($tokens, function ($a, $b) {
            return ($a instanceof URLConfirmationToken) ? 1 : 0;
        });

        $urlBase = Director::baseURL();
        foreach ($tokens as $token) {
            $urlBase = $token->getRedirectUrlBase();
        }

        return $urlBase;
    }
276295
public function getSiteUrl()
    {
        $url = clone $this->getBaseUrl();

        if(JFactory::getApplication()->getName() == 'administrator')
        {
            // Replace the application name only once since it's possible that
            // we can run from http://localhost/administrator/administrator
            $i    = 1;
            $path = str_ireplace('/administrator', '', $url->getPath(), $i);
            $url->setPath($path);
        }

        return $url;
    }
1228018
public function getRouteURL()
    {
        if (empty($this->routeUrl)) {
            $param = trim(Server::get('REQUEST_URI'), '/');

            // strip base directory from request url
            $base_dir = $this->getBaseDir();
            $param = substr($param, strlen($base_dir));

            // Strip query string (?a=b) from Request Url
            $path = trim(explode('?', $param)[0], '/');
            $this->routeUrl = strtolower($path);

            if (empty($this->routeUrl)) {
                $this->routeUrl = '/';
            }
        }

        return $this->routeUrl;
    }
336742
public function getUrl()
    {
        $scheme = $this->scheme!=null ? $this->scheme . '://' : MString::EMPTY_STRING;
        $host = $this->host!=null ? $this->host : MString::EMPTY_STRING;
        $port = $this->port!=null ? ':' . $this->port : MString::EMPTY_STRING;
        $user = $this->user!=null ? $this->user : MString::EMPTY_STRING;
        $pass = $this->password!=null ? ':' . $this->password : MString::EMPTY_STRING;
        $pass = ($user||$pass) ? "$pass@" : MString::EMPTY_STRING;
        $path = $this->path!=null ? $this->path : MString::EMPTY_STRING;
        $query = $this->query!=null ? '?' . $this->query : MString::EMPTY_STRING;
        $fragment = $this->fragment!=null ? '#' . $this->fragment : MString::EMPTY_STRING;

        return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
    }
267287
protected function getUrl()
    {

        if (!($this->secure && $this->sandbox)) {
            return static::HTTP_URL;
        } else if (!$this->secure && $this->sandbox) {
            return static::SANDBOX_HTTP_URL;
        } else if ($this->secure && $this->sandbox) {
            return static::SANDBOX_HTTPS_URL;
        } else {
            return static::HTTPS_URL;
        }
    }
440345
public function getUrl($parts = self::FULL)
    {
        $url = '';

        //Add the scheme
        if (($parts & self::SCHEME) && !empty($this->scheme)) {
            $url .=  urlencode($this->scheme).'://';
        }

        //Add the username and password
        if (($parts & self::USER) && !empty($this->user)) {
            $url .= urlencode($this->user);
            if (($parts & self::PASS) && !empty($this->pass)) {
                $url .= ':' . urlencode($this->pass);
            }

            $url .= '@';
        }

        // Add the host and port, if any.
        if (($parts & self::HOST) && !empty($this->host)) {
            $url .=  urlencode($this->host);

            if (($parts & self::PORT) && !empty($this->port)) {
                $url .=  ':' . (int) $this->port;
            }
        }

        // Add the rest of the url. we use trim() instead of empty() on string
        // elements to allow for string-zero values.
        if (($parts & self::PATH) && !empty($this->path)) {
            $url .= $this->_pathEncode($this->path);
            if (($parts & self::FORMAT) && trim($this->format) !== '') {
                $url .= '.' . urlencode($this->format);
            }
        }

        $query = $this->getQuery();
        
        if (($parts & self::QUERY) && !empty($query)) {
            $url .= '?' . $this->getQuery();
        }

        if (($parts & self::FRAGMENT) && trim($this->fragment) !== '') {
            $url .=  '#' . urlencode($this->fragment);
        }

        return $url;
    }
685318
protected function getReturnURL()
    {
        $url = $this->request->getVar('returnURL');

        // Check that this url is a site url
        if (empty($url) || !Director::is_site_url($url)) {
            return null;
        }

        // Convert to absolute URL
        return Director::absoluteURL($url, true);
    }
1189718
public function getUrl() { // $includeId = true
        OpenpayConsole::trace('OpenpayApiResourceBase @getUrl > class/parent: '.get_class($this).'/'.($this->parent ? 'true' : 'false'));
        $parentUrl = '';

        if ($this->parent) {
            $parentUrl = $this->parent->getUrl();
            if ($this->parent instanceof OpenpayApiDerivedResource) {
                return $parentUrl.($this->id ? '/'.$this->id : '');
            }
        }
        $resourceUrlName = $this->getResourceUrlName();
        return ($parentUrl != '' ? $parentUrl : '').($resourceUrlName != '' ? '/'.$resourceUrlName : '').($this->id ? '/'.$this->id : '');
    }
916829
public function getGetUrl()
    {
        $scheme = empty($this->rowUrl["scheme"]) ? "http://" : $this->rowUrl["scheme"] . "://";
        $user   = empty($this->rowUrl["user"]) ? "" : $this->rowUrl["user"];
        $pass   = empty($this->rowUrl["pass"]) ? "" : $this->rowUrl["pass"];

        // if pass is there, put a : between user and pass (user:pass)
        if (!empty($pass)) {
            $user =  rawurlencode($user) .  ":";
        }

        // if user and password are there, put a @ after pass, so that user:pass@host will be constructed
        if (!empty($user) || !empty($pass)) {
            $pass = rawurlencode($pass) . "@";
        }

        $host = $this->rowUrl["host"];
        $port = empty($this->rowUrl["port"]) ? "" : ":" . $this->rowUrl["port"];

        $path = empty($this->rowUrl["path"]) ? "" : $this->rowUrl["path"];

        $urlquery = "";
        if (count($this->getParams) > 0)
        {
            $urlquery = "?" . http_build_query($this->getParams);
        }
        return $scheme . $user . $pass . $host . $port . $path . $urlquery;
    }
1133517
public function getFullUrl()
    {
        $parts = $this->toArray();
        unset($parts['full_url'], $parts['pass']);

        foreach ($parts as $method => $param) {
            if ($param) {
                $method = 'add' . ucfirst($method);
                $this->$method($param);
            }
        }

        return ltrim(implode($this->fullUrl), '/');
    }
686315
public function getUrl()
    {
        if ($this->findDocumentRootInScriptFileName() === $this->removeLastSlash($this->root)) {
            return $this->getRequestUri();
        }
        $path = $this->server->get('PATH_INFO');

        return $path;
    }
505395
public function getUrl()
    {
		if ($this->isLink()) {
			if ($this->getParentServer()->id != $this->prototype->getParentServer()->id) {
				return $this->prototype->getFullUrl();
			}
			else {
				return $this->prototype->getUrl();
			}
		}
		else {
			if ($this->_url === FALSE) $this->fillPath();
			return $this->_url;
		}
    }
365910
public static function getBaseUrl()
    {
        $protocol = isset($_SERVER['HTTPS']) ? 'https' : 'http';
        $url = $protocol . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];

        // cut at last '/' (we dont want to see index.php)
        return substr($url, 0, strrpos($url, '/'));
    }
1120642
public function url()
    {
        $scheme = $this->scheme();
        $scheme = $scheme ? $scheme . '://' : '//';
        $query = $this->query() ? '?' . http_build_query($this->query()) : '';
        $fragment = $this->fragment() ? '#' . $this->fragment() : '';
        return $scheme . $this->host() . $this->path() . $query . $fragment;
    }