Sets the fragment for the current URI, and returns the old fragment

@param  string $fragment Fragment of the current URI
@throws Zend_Uri_Exception When $fragment is not a valid HTTP fragment
@return string
352958
public function setFragment($fragment)
    {
        if ($this->validateFragment($fragment) === false) {
            include_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception("Fragment \"$fragment\" is not a valid HTTP fragment");
        }

        $oldFragment     = $this->_fragment;
        $this->_fragment = $fragment;

        return $oldFragment;
    }
91657
public static function getUriSegment(int $segment)
    {
        $segments = self::getUriSegments();
        return isset($segments[$segment]) ? $segments[$segment] : null;
    }
660450
public function setFromUrl()
    {
        // Cache?
        $cacheRebuild = true;
        if ($this->options->cache) {
            $cacheKey = md5($this->get());
            $cacheData = $this->cache->get($cacheKey);

            if (!empty($cacheData)) {
                $cacheRebuild = false;
                $this->set($cacheData);
            }
        }

        // Get dom
        if ($cacheRebuild) {
            $dom = new \PHPHtmlParser\Dom;
            $dom->load($this->url, $this->PHPHtmlParserOptions);
            $element = $dom->find($this->selector)[0];

            if (!empty($element)) {
                // Filter?
                if (!empty($this->filter->selector)) {
                    $newElement = new \PHPHtmlParser\Dom;
                    $newElement->load($element->outerHtml, $this->PHPHtmlParserOptions);
                    $filter = $newElement->find($this->filter->selector);

                    if (!empty($filter)) {
                        $i = 0;
                        foreach ($filter as $item) {
                            if ($i >= $this->filter->length) {
                                $item->delete();
                            }
                            $i++;
                        }
                    }
                    unset($filter);

                    $html = $newElement->outerHtml;

                } else {
                    $html = $element->outerHtml;
                }

                $this->set($html);

                if ($this->options->cache && !empty($cacheKey)) {
                    $this->cache->set($cacheKey, $html);
                }
            }
        }

        return $this;
    }
1180595
protected function filterFragment($fragment)
    {
        $fragment = preg_replace_callback(
            '/(?:[^' . self::CHARACTERS_UNRESERVED . self::CHARACTERS_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
            function ($match) {
                return rawurlencode($match[0]);
            },
            $fragment
        );

        if (is_null($fragment)) {
            throw new InvalidArgumentException(sprintf('Invalid fragment "%s".', $fragment));
        } elseif (!$fragment) {
            $fragment = '';
        }

        if (substr($fragment, 0, 1) === '#') {
            $fragment = substr($fragment, 1);
        }

        return $fragment;
    }
491438
protected function _setRequest($segments = array()){
		$segments = $this->_validateRequest($segments);
		if (count($segments) == 0){
			return $this->uri->_reindex_segments();
		}

		$this->setClass($segments[0]);

		if (isset($segments[1]))
		{
			// A standard method request
			$this->method = $segments[1];
		}
		else
		{
			// This lets the "routed" segment array identify that the default
			// index method is being used.
			$segments[1] = 'index';
		}

		// Update our "routed" segment array to contain the segments.
		// Note: If there is no custom routing, this array will be
		// identical to $this->uri->segments
		$this->uri->rsegments = $segments;
	}
573997
public EndpointInfoBuilder fragment(String fragment) {
        requireNonNull(fragment, "fragment");
        checkState(regexPathPrefix == null, "fragment cannot be set with regexPathPrefix: %s", regexPathPrefix);
        this.fragment = fragment;
        return this;
    }
176118
private function cleanupUrl($url)
    {
        // rewrite part of urls to something more readable
        foreach ($this->config['rewrite_url'] as $find => $action) {
            if (false !== strpos($url, $find) && \is_array($action)) {
                $url = strtr($url, $action);
            }
        }

        // convert fragment to actual query parameters
        if ($fragmentPos = strpos($url, '#!')) {
            $fragment = parse_url($url, PHP_URL_FRAGMENT);
            // strip '!'
            $fragment = substr($fragment, 1);
            $query = ['_escaped_fragment_' => $fragment];

            // url without fragment
            $url = substr($url, 0, $fragmentPos);
            $url .= parse_url($url, PHP_URL_QUERY) ? '&' : '?';
            // needed for some sites
            $url .= str_replace('%2F', '/', http_build_query($query));
        }

        // remove fragment
        if ($pos = strpos($url, '#')) {
            $url = substr($url, 0, $pos);
        }

        return $url;
    }
550354
public static URI setFragment(final URI path, final String fragment) {
        try {
            if (path.getPath() != null) {
                return new URI(path.getScheme(), path.getUserInfo(), path.getHost(), path.getPort(), path.getPath(), path.getQuery(), fragment);
            } else {
                return new URI(path.getScheme(), path.getSchemeSpecificPart(), fragment);
            }
        } catch (final URISyntaxException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
1186082
private function parseCallablePlaceholders($fragment)
    {
        if (strpos($fragment, "{") !== false) {
            foreach ($this->params as $placeholder => $value) {
                if (strpos($fragment, "{" . $placeholder . "}") !== false) {
                    $fragment = str_replace("{" . $placeholder . "}", ucwords(str_replace("-", " ", $value)), $fragment);
                }
            }
        }

        return $fragment;
    }
237008
public function getFragment(): string
    {
        if (!isset($this->segments['fragment'])) {
            throw new UrlException('Unable to get fragment for ' . $this->url);
        }

        return $this->segments['fragment'];
    }
1118263
public function withFragment(Fragment $fragment): self
    {
        $url = Structure::fromString((string) $this)->withFragment(
            new Frag((string) $fragment->substring(1))
        );

        return new self(
            (string) $url
        );
    }
625739
protected function getFragment(?string $fragment) : ?string
    {
        if ($fragment === null) {
            return null;
        }

        return '#' . $this->trim($fragment, '#');
    }
52606
public static function current()
    {
        if (!is_null(static::$uri)) {
            return static::$uri;
        }

        //Format a given URI.
        $uri = trim(self::$pathInfo, '/') ?: '/';

        //Set the URI segments for the request.
        $segments = explode('/', trim($uri, '/'));
        static::$segments = array_diff($segments, array(''));

        return static::$uri = $uri;
    }
711165
public function getSegment($segment = 1)
    {
        $segment = (!is_null($segment)) ? $segment : 1;
        $uri = $this->router->getCurrentUri();
        $urlArray = array_filter(explode('/', $uri));
        $indexCount = array_search(Router::$indexPage, $urlArray);

        if ($indexCount == true) {
            $num = $indexCount + $segment;

            return isset($urlArray[$num]) ? $urlArray[$num] : null;
        }

        return isset($urlArray[$segment]) ? $urlArray[$segment] : null;
    }
791537
protected function detectFragmentCycle(FragmentDefinitionNode $fragment): void
    {
        $fragmentName = $fragment->getNameValue();

        $this->visitedFragments[$fragmentName] = true;

        $spreadNodes = $this->context->getFragmentSpreads($fragment->getSelectionSet());

        if (empty($spreadNodes)) {
            return;
        }

        $this->spreadPathIndexByName[$fragmentName] = \count($this->spreadPath);

        foreach ($spreadNodes as $spreadNode) {
            $spreadName = $spreadNode->getNameValue();
            $cycleIndex = $this->spreadPathIndexByName[$spreadName] ?? null;

            if (null === $cycleIndex) {
                $this->spreadPath[] = $spreadNode;

                if (!isset($this->visitedFragments[$spreadName])) {
                    $spreadFragment = $this->context->getFragment($spreadName);

                    if (null !== $spreadFragment) {
                        $this->detectFragmentCycle($spreadFragment);
                    }
                }

                \array_pop($this->spreadPath);
            } else {
                $cyclePath = \array_slice($this->spreadPath, $cycleIndex);

                $this->context->reportError(
                    new ValidationException(
                        fragmentCycleMessage($spreadName, \array_map(function (FragmentSpreadNode $spread) {
                            return $spread->getNameValue();
                        }, $cyclePath)),
                        \array_merge($cyclePath, [$spreadNode])
                    )
                );
            }
        }

        $this->spreadPathIndexByName[$fragmentName] = null;
    }
493019
public function getUri()
    {
        if ($this->valid() === false) {
            require_once 'Zend/Uri/Exception.php';
            throw new Zend_Uri_Exception('One or more parts of the URI are invalid');
        }

        $password = strlen($this->_password) > 0 ? ":$this->_password" : '';
        $auth     = strlen($this->_username) > 0 ? "$this->_username$password@" : '';
        $port     = strlen($this->_port) > 0 ? ":$this->_port" : '';
        $query    = strlen($this->_query) > 0 ? "?$this->_query" : '';
        $fragment = strlen($this->_fragment) > 0 ? "#$this->_fragment" : '';

        return $this->_scheme
             . '://'
             . $auth
             . $this->_host
             . $port
             . $this->_path
             . $query
             . $fragment;
    }
982348
public static function setLastVisitedUrl($url){
	    if(empty($url)){
	        throw new common_Exception('Cannot register an empty URL for the last visited extension');
	    }
        $success = false;
	    
	    $userUri = common_session_SessionManager::getSession()->getUserUri();
	    if (!empty($userUri)) {
	        $user = new \core_kernel_classes_Resource($userUri);
    	    $user = new core_kernel_classes_Resource($userUri);
    	    if ($user->exists()) {
    	        // user in ontology
    	        
    	        //clean up what's stored
    	        $url = str_replace(ROOT_URL, '', $url);
    	        $success = $user->editPropertyValues(new core_kernel_classes_Property(TaoOntology::PROPERTY_USER_LAST_EXTENSION), $url);
    	    } // else we fail;
	    }
	    return $success;
	}