Get a full url from an url code

@param  string $code       Url code
@param  array  $addedArgs  (optional) Additional arguments
@param  string $anchor     (optional) Anchor
347304
public static function getUrlFromCode($code, $addedArgs = array(), $anchor = null)
  {
    self::initialize();

    $code = self::clearQueryArg($code);

    if ($code == '_root') {
      return WebApp::url();
    }

    if (StringTools::right($code, 1) != '/') {
      $code .= '/';
    }

    $args = array('q' => $code);
    $args = array_merge($args, $addedArgs);
    return Url::getUrl(null, $args, true, $anchor);
  }
88512
public function replaceElementUsingLink( $execMethod, $args = [ ], $targetDiv, $linkText, $anchorAttrs = [ ] )
    {
        $url = $this->url( $execMethod, $args, true );
        $attrs = [ ];
        foreach ($anchorAttrs as $k => $v) {
            $attrs[ ] = "{$k}='{$v}'";
        }
        $attrsStr = implode( ' ', $attrs );
        return <<<EOS
        <script type="application/javascript">
            if( typeof(execLink) != "function" ){
                var execLink = function( url, targetDiv ){
                    // Send the data using post
                    var posting = $.get( url, $( form ).serialize() );
                 
                    // Put the results in a div
                    posting.done(function( data ) {
                        $( "#"+targetDiv ).replaceWith( data );
                        $("body").css("cursor", "default");
                    });
    
                    // Show optional progress
                    $("body").css("cursor", "progress");
                }
            }
        </script>
        <a href="#" onclick="execLink( '{$url}', '{$targetDiv}' ); return false;" {$attrsStr}>{$linkText}</a>
EOS;
    }
41852
public function url( array $args = []) {
        $url = get_comments_link( $this->post_ID );
        if ( $args ) {
            $url = add_query_arg( $args, $url );
        }

        return $url;
    }
832418
public static function currentUrl(bool $includeQuery = true, bool $urlEncode = false)
    {
        if (RequestHelper::isCli()) {
            return null;
        }

        $url = static::protocolHostPort() . static::currentUri($includeQuery, $urlEncode);

        return $urlEncode ? urlencode($url) : $url;
    }
556993
public function addLink($linkIdent, $link)
    {
        if (!is_string($linkIdent) && !is_numeric($linkIdent)) {
            throw new InvalidArgumentException(
                'Link identifier must be a string or '
            );
        }

        if (is_array($link)) {
            $active = true;
            $name   = null;
            $url    = null;
            $permissions = [];

            if (isset($link['ident'])) {
                $linkIdent = $link['ident'];
            } else {
                $link['ident'] = $linkIdent;
            }

            if (isset($link['active'])) {
                $active = !!$link['active'];
            }

            if (isset($link['name'])) {
                $name = $this->translator()->translation($link['name']);
            }

            if (isset($link['url'])) {
                $url = $this->translator()->translation($link['url']);
            }

            if (isset($link['required_acl_permissions'])) {
                $permissions = $link['required_acl_permissions'];
            }

            if ($name === null && $url === null) {
                return $this;
            }

            $this->links[$linkIdent] = [
                'active'   => $active,
                'name'     => $name,
                'url'      => $url,
                'selected' => $this->isCurrentItem([ $linkIdent, (string)$url ]),
                'required_acl_permissions' => $permissions
            ];
        } else {
            throw new InvalidArgumentException(sprintf(
                'Link must be an associative array, received %s',
                (is_object($link) ? get_class($link) : gettype($link))
            ));
        }

        return $this;
    }
420428
function (basePath, anchors) {
    var fullPath = normalizePath(this.path, basePath) || '/';

    anchors = anchors || [];
    function getAnchor (title) {
      var anchor = String(title).toLowerCase()
        .replace(/[\s\-]+/g, ' ')
        .replace(/[^a-z0-9 ]/g, '')
        .trim()
        .replace(/ /g, '-');
      if (anchors.indexOf(anchor) > -1) {
        var i = 2;
        while (anchors.indexOf(anchor + '-' + i) > -1) {
          i++;
        }
        anchor += '-' + i;
      }
      anchors.push(anchor);
      return anchor;
    }

    var html = '';
    if (this.title) {
      html +=
        '<h1 id="' + getAnchor(this.title) + '">' + this.title + '</h1>\n';
    }
    if (this.description) {
      html += '<p>' + this.description.replace(/\n/g, '<br>') + '</p>\n';
    }

    // Export own request handlers.
    for (var method in this.handlers) {
      var handler = this.handlers[method];
      var title = handler.title || '(no title)';
      html += '<h2 id="' + getAnchor(title) + '">' + title + '</h2>\n';
      html += '<pre>' + method.toUpperCase() + ' ' + fullPath + '</pre>\n';
      if (handler.description) {
        html += '<p>' + handler.description.replace(/\n/g, '<br>') + '</p>\n';
      }

      if (handler.examples && handler.examples.length > 0) {
        var example = handler.examples[0];

        var request = example.request || {};
        if (request.urlParameters || request.headers || request.body) {
          html += '<h3>Input</h3>\n<pre>';
          var exampleURL = method.toUpperCase() + ' ' + fullPath;
          if (request.urlParameters) {
            exampleURL = replaceUrlParameters(exampleURL,
              request.urlParameters);
          }
          html += exampleURL + '\n';
          var requestHeaders = request.headers || {};
          for (var header in requestHeaders) {
            html += header + ': ' + requestHeaders[header] + '\n';
          }
          if (request.body) {
            html += '\n' + jsonStringifyIfObject(request.body).trim() + '\n';
          }
          html += '</pre>\n';
        }

        var response = example.response || {};
        var hasResponseStatus = isExplicitExample(response.status);
        var hasResponseBody = isExplicitExample(response.body);
        if (hasResponseStatus || response.headers || hasResponseBody) {
          html += '<h3>Response</h3>\n<pre>';
          if (hasResponseStatus) {
            var message = http.STATUS_CODES[response.status];
            html += 'Status: ' + response.status + ' ' + message + '\n';
          }
          var responseHeaders = response.headers || {};
          for (var header in responseHeaders) {
            var headerValue = responseHeaders[header];
            if (isExplicitExample(headerValue)) {
              html += header + ': ' + headerValue + '\n';
            }
          }
          if (hasResponseBody) {
            if (hasResponseStatus || Object.keys(responseHeaders).length > 0) {
              html += '\n';
            }
            html += jsonStringifyIfObject(response.body).trim() + '\n';
          }
          html += '</pre>\n';
        }
        // TODO Document all unique possible status codes?
        // TODO Document all request parameters?
      }
    }

    // Export children's request handlers recursively.
    for (var path in this.children) {
      var child = this.children[path];
      html += child.toHTML(fullPath, anchors);
    }

    return html;
  }
758087
function getExpandedUrl(url, options) {
	var x = 0,
		i;
	if (options.urls) {
		i = options.urls.length;
		while (x < i) {
			if (options.urls[x].match === url) {
				if (options.urls[x].expanded) {
					return options.urls[x].expanded;
				}
				return null;
			}
			x++;
		}
	}
	return null;
}
1121645
private function createVariadicUrl($haystack, array $args)
    {
        $varCount = substr_count($haystack, self::ROUTE_PARAM_VAR);
        $argCount = count($args);

        // In case, the length is different
        if ($varCount != $argCount) {
            $difference = abs($argCount - $varCount);

            for ($i = 0; $i < $difference; $i++) {
                array_push($args, self::ROUTE_PARAM_VAR);
            }
        }

        $haystack = str_replace(self::ROUTE_PARAM_VAR, '%s', $haystack);
        return vsprintf($haystack, $args);
    }
460685
public AddOns getAddOns(final String planCode) {
        return doGET(Plan.PLANS_RESOURCE +
                "/" +
                planCode +
                AddOn.ADDONS_RESOURCE,
                AddOns.class,
                new QueryParams());
    }
150292
protected function getCallArgs(array $arguments, array $extraArguments, $value = null): array
    {
        foreach ($extraArguments as $name => $val) {
            $arguments[] = $val;
        }

        return $arguments;
    }
1238998
static function appendToUrl($url, $append)
	{
		if ( $append )
		{
		    $regs = [];
			if ( preg_match('|^(.+?)(?:\?(.*?))?(#.*)?$|', $url, $regs) )
			{
				$u = $regs[1];  // URL part
				$q = $regs[2];  // querystring
				$a = $regs[3];  // anchor #xxxx
				
				// append a new parameter if one or more already exist
				if ( $q )
					$q = $q . "&" . $append;
				else
					$q = $append;
					
				// rebuild full url
				return $u . '?' . $q . $a;
			}
			else
				// impossible case 
				return $url;
		}
		else
			return $url;
	}
840047
public static function url($url, $code = 302, $headers = array())
    {
        $r = static::createRedirectResponse((string) $url, $code, $headers);

        return $r;
    }
1340637
function appendUrl(url, urls) {
    var i = urls.length
        found = false;
    while (i--) {
        if (utils.compareUrl(urls[i], url)) 
          found = true; 
    }
    if (found === false && utils.isUrl(url)) 
      urls.push(url);
}
55151
public function addDocumentation(string $url, ?string $anchor = null ): KBDocumentation
    {
        $this->url = $url;
        if ($this->docs === null) {
            $this->docs = array();
        }
        $kbd          = new KBDocumentation($url, $anchor);
        $this->docs[] = $kbd;
        return $kbd;
    }
635183
public function getLink($controller, $params = array(), $fullPath = false)
    {
        if ($controller instanceof Controller) {
            $controller = get_class($controller);
        }
        $controller = (string)$controller;
        if(substr($controller, 0, 1) === "\\") {
            $controller = substr($controller, 1);
        }
        try {

            $url = Bootstrap::getSingleton()->getManager()->getRouter()->generate($controller, $params);
            if ($fullPath) {
                $protocol = 'http';
                if (strpos($_SERVER['SCRIPT_URI'], 'https') !== false) {
                    $protocol = 'https';
                }
                return $protocol . '://' . $_SERVER['HTTP_HOST'] . $url;
            }
            return $url;
        } catch (\Exception $ex) {

        }
        return "";
    }
703385
public function executeCode($code, array $arguments = [])
    {
        if (! ($code instanceof MongoCode)) {
            $code = new MongoCode($code);
        }

        return $this->database->execute($code, $arguments);
    }
921413
public static function toString($args, $link  = '') {
		$str = '';
		if (is_array($args)) {
			foreach ($args as $value) {
				$str .= self::toString($value, $link);
			}
		} else {
			$str .= $args.$link;
		}
		return $str;
	}