@param string $value
@param string $href

@return string
165879
protected function getHrefView(string $value, string $href): string
    {
        $confirm = $this->href_confirm ? str_replace(['"', "'"], ['', "\'"], __('Are you sure?')) : '';
        $href_view = '<a href="'
            . $href
            . '" class="nounderline"'
            . ($confirm ? ' onclick="return confirm(\'' . $confirm . '\');"' : '')
            . ($this->href_new_window ? ' target="_blank"' : '') . '>'
            . $value
            . '</a>';

        return $href_view;
    }
777000
public function _createRedirectUrl($href, $recipient)
    {
        $recipientPrimary = $recipient->getModel()->getPrimaryKey();
        $recipientSource = $this->getRecipientModelShortcut(get_class($recipient->getModel()));

        $m = $this->getChildModel();

        if (substr($href, 0, 1) == '#') return $href;

        $hrefParts = parse_url($href);

        if (!isset($hrefParts['path'])) {
            $hrefParts['path'] = '';
        }
        $query = isset($hrefParts['query']) ? $hrefParts['query'] : null;

        $useAbsoluteUrl = true;
        if (isset($hrefParts['scheme'])) {
            if (($hrefParts['scheme'] == 'http' || $hrefParts['scheme'] == 'https') && isset($hrefParts['host'])) {
                if ($hrefParts['host'] == $this->getData()->getDomain()) {
                    $useAbsoluteUrl = false;
                }
            }
        } else if (!isset($hrefParts['scheme']) && !isset($hrefParts['host'])) {
            $useAbsoluteUrl = false;
        }
        if ($useAbsoluteUrl) {
            $link = (isset($hrefParts['scheme']) ? "{$hrefParts['scheme']}:" : '') .
                (isset($hrefParts['host']) ? '//' : '') .
                (isset($hrefParts['host']) ? "{$hrefParts['host']}" : '') .
                (isset($hrefParts['port']) ? ":{$hrefParts['port']}" : '') .
                (isset($hrefParts['path']) ? "{$hrefParts['path']}" : '') .
                (isset($hrefParts['fragment']) ? "#{$hrefParts['fragment']}" : '');
        } else {
            $link = $hrefParts['path'];
            if (!$link) $link = '/';
            if (isset($hrefParts['fragment'])) $link .= '#' . $hrefParts['fragment'];
        }

        if (!isset($this->_redirectRowsCache[$link])) {
            $select = $m->select();
            $select->whereEquals('value', $link);
            $r = $m->getRow($select);
            if (!$r) {
                $r = $m->createRow(array(
                    'value' => $link,
                ));
                $r->save();
            }
            $this->_redirectRowsCache[$link] = $r;
        }
        $r = $this->_redirectRowsCache[$link];

        // $recipientSource muss immer dabei sein, auch wenn es nur ein
        // model gibt. Würde später eines dazukommen, funktionierten die alten
        // Links nicht mehr

        // linkId_userId_userSource_hash
        return $this->_createHashedRedirectUrl(array(
            $r->id, $recipient->$recipientPrimary, $recipientSource
        )).($query ? '&'.$query : '');
    }
379072
private static function encodeValue($value)
    {
        $value = gmp_strval($value);

        return Base64Url::encode(self::convertDecToBin($value));
    }
1063150
protected function _createLink($value, $pagingString = null)
    {
        if ($pagingString !=null ) {
            $link = $this->RequestContext->getSite()->getBaseURL().preg_replace("/\/[\/]+/", "/", ltrim($pagingString.'/'.$value.'/'));
            if($this->getLocal('UseQueryStringInCacheKey') != null)
                $link .= ($this->Request->getQueryString() != ""?"?".$this->Request->getQueryString():"");
            return $link;
        } else {
            return URLUtils::appendQueryString($this->Request->getFullURL(), array('view_page'=> $value));
        }
    }
1335341
public function asLink($href=NULL) {
		if (isset($href)) {
			$this->wrap("<a href='" . $href . "'>", "</a>");
		}
		return $this->addToProperty("class", "link");
	}
754541
public static function anchor($href, $text = null, $attr = array(), $secure = null)
	{
		if ( ! preg_match('#^(\w+://|javascript:|\#)# i', $href))
		{
			$urlparts = explode('?', $href, 2);
			$href = \Uri::create($urlparts[0], array(), isset($urlparts[1])?$urlparts[1]:array(), $secure);
		}
		elseif ( ! preg_match('#^(javascript:|\#)# i', $href) and is_bool($secure))
		{
			$href = http_build_url($href, array('scheme' => $secure ? 'https' : 'http'));

			// Trim the trailing slash
			$href = rtrim($href, '/');
		}

		// Create and display a URL hyperlink
		is_null($text) and $text = $href;

		$attr['href'] = $href;

		return html_tag('a', $attr, $text);
	}
411115
protected function setUrlAttr($value = null)
    {
        if (!is_null($value)) {
            $this->url = $value;
            $this->pdfUrl = $value . '.pdf';
        }
    }
822059
protected function valueToString($value) : string
    {
        if ($value === null) {
            $def_value = 'null';
        } elseif ($value === false) {
            $def_value = 'false';
        } elseif ($value === true) {
            $def_value = 'true';
        } elseif (is_string($value)) {
            $def_value = '"' . str_replace('"', '\\"', $value) . '"';
        } elseif (is_numeric($value)) {
            $def_value = '' . $value;
        }

        return $def_value;
    }
901614
protected function parseValue($value) {
        if(is_string($value)) {
            $value =  strpos($value,':') === 0 && in_array($value,array_keys($this->bind))? $this->escapeString($value) : '\''.$this->escapeString($value).'\'';
        }
        elseif(isset($value[0]) && is_string($value[0]) && strtolower($value[0]) == 'exp'){
            $value =  $this->escapeString($value[1]);
        }
        elseif(is_array($value)) {
            $value =  array_map([$this, 'parseValue'],$value);
        }
        elseif(is_bool($value)){
            $value =  $value ? '1' : '0';
        }
        elseif(is_null($value)){
            $value =  'null';
        }
        return $value;
    }
957387
private function upgradeUrl(&$value)
    {
        if (!empty($value)
            && false === strpos($value, 'http://')
            && false === strpos($value, 'https://')
            && false === strpos($value, 'ftp://')
            && false === strpos($value, 'ftps://')
            && false === strpos($value, 'mailto:')
            && false === strpos($value, '//')
        ) {
            $value = 'http://' . $value;
        }

        return $value;
    }
948335
public static function addUrlParam($link, $param, $value)
    {
        // TODO opravit
        $url = parse_url($link, PHP_URL_PATH);
        if (!isset($url[$param])) {
            if (mb_strpos($link, '?')) {
                $link .= '&'.$param.'='.$value;
            } else {
                $link .= '?'.$param.'='.$value;
            }
        }

        return $link;
    }
200651
public function parse_value($value) {
        if (strpos($value, '$ToolConsumerProfile.url') !== false) {
            $value = str_replace('$ToolConsumerProfile.url', $this->get_endpoint(), $value);
        }
        return $value;

    }
21048
public function escape($value, $context = 'html')
    {
        if (is_numeric($value)) {
            return $value;
        }

        // If we deal with a scalar value, we can cache the result to increase
        // the performance when the same value is escaped multiple times (e.g. loops)
        if (is_scalar($value)) {
            if (!isset(self::$escaperCache[$context][$value])) {
                self::$escaperCache[$context][$value] = $this->getEscaper($context)($value);
            }

            return self::$escaperCache[$context][$value];
        }

        return $this->getEscaper($context)($value);
    }
1110980
protected function compileEscapedEchos($value)
    {
        $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s(\r?\n)?/s', $this->escapedTags[0], $this->escapedTags[1]);

        $callback = function ($matches) {
            $whitespace = empty($matches[3]) ? '' : $matches[3].$matches[3];

            return $matches[1] ? $matches[0] : "<?php echo e({$matches[2]}); ?>{$whitespace}";
        };

        return preg_replace_callback($pattern, $callback, $value);
    }
187857
private static function urlencode_rfc3986($value)
        {
            if (Arrays::is($value)) {
                return array_map(array(__CLASS__, 'urlencode_rfc3986'), $value);
            } else {
                return str_replace('%7E', '~', rawurlencode($value));
            }
        }
87917
private static function stringify($value)
    {
        if (is_string($value)) {
            return sprintf('"%s"', preg_replace('/\n/', '\n', $value));
        }

        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_null($value)) {
            return 'null';
        }

        if (is_array($value)) {
            return sprintf('[%s]', implode(', ', array_map(
                function ($value) {
                    return self::stringify($value);
                },
                $value
            )));
        }

        return (string) $value;
    }
88140
public function anchor(String $url, String $value = NULL, Array $attributes = []) : String
    {
        if( ! IS::url($url) && strpos($url, '#') !== 0 )
        {
            $url = Request::getSiteURL($url);
        }

        $attributes['href'] = $url;

        return $this->_multiElement('a', $value ?? $url, $attributes);
    }