Vrati seo friendly slug.

@param $text

@return mixed|string
182238
public static function slugify($text)
    {
        // replace non letter or digits by -
        $text = preg_replace('#[^\\pL\d]+#u', '-', $text);

        // trim
        $text = trim($text, '-');

        // transliterate
        if (function_exists('iconv')) {
            $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
        }

        // lowercase
        $text = mb_strtolower($text);

        // remove unwanted characters
        $text = preg_replace('#[^-\w]+#', '', $text);

        if (empty($text)) {
            return 'n-a';
        }

        return $text;
    }
54371
public function inject($text)
    {
        if (!is_string($text)) {
            return $text; // nothing to do here
        }

        foreach ($this->parameters as $key => $parameter) {
            if (strpos($text, $key) === false) {
                continue;
            }

            if (is_callable($parameter)) {
                $parameter = call_user_func($parameter);
            }

            $text = str_replace($key, $parameter, $text);
        }

        return $text;
    }
1089580
public function replace($text)
    {
        preg_match_all($this->pattern, $text, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
        $delta = 0;
        foreach ($matches as $match)
        {
            $stringsOnly = array();
            foreach ($match as $info)
            {
                $stringsOnly []= $info[0];
            }
            $replace = call_user_func($this->callback, $stringsOnly);
            if (false === $replace || null === $replace)
            {
                continue;
            }

            $text = substr_replace($text, $replace, $match[0][1] + $delta, strlen($match[0][0]));
            $delta += strlen($replace) - strlen($match[0][0]);
        }

        return $text;
    }
85648
protected function replaceMacros($text)
    {
        $request = Eresus_CMS::getLegacyKernel()->request;
        $text = str_replace(
            array(
                '$(httpHost)',
                '$(httpPath)',
                '$(httpRoot)',
                '$(styleRoot)',
                '$(dataRoot)',
            ),
            array(
                $request['host'],
                $request['path'],
                Eresus_CMS::getLegacyKernel()->root,
                Eresus_CMS::getLegacyKernel()->style,
                Eresus_CMS::getLegacyKernel()->data
            ),
            $text
        );

        return $text;
    }
1355323
public static function urlizeTrim($text, $separator = '-')
    {
        return trim(self::urlize(UtilString::toSlugg($text), $separator), $separator);
    }
213049
public function generateRouteFromText($text, $withSlash = false)
    {
        if ($withSlash) {
            $result = '';
            foreach (explode('/', $text) as $value) {
                if ('' !== $value = trim($value)) {
                    $result .= '/' . Urlizer::urlize($value);
                }
            }

            return $result ?: '/';
        }

        return $this->normalizeRoute(Urlizer::urlize($text));
    }
381476
public function getNext($text = '&raquo;')
	{
		// If the current page is greater than or equal to the last page, it means we
		// can't go any further into the pages, as we're already on this last page
		// that is available, so we will make it the "next" link style disabled.
		if ($this->currentPage >= $this->lastPage)
		{
			return $this->getDisabledTextWrapper($text);
		}
		else
		{
			$url = $this->paginator->getUrl($this->currentPage + 1);

			return $this->getPageLinkWrapper($url, $text);
		}
	}
1284799
public function getTitleFromFirstHeader($text)
    {
        $matches = [];
        $title = null;

        if (preg_match("#<h[1-6].*?>(.*)</h[1-6]>#", $text, $matches)) {
            $title = strip_tags($matches[1]);
        }

        return $title;
    }
1283465
public function lookup($text)
    {
        $url = $this->getLookupUrl($text);
        $response = $this->sendRequest(
            'GET',
            $url,
            [
                'version' => $this->serviceProtocolVersion
            ]
        );
        if ($response->getStatusCode() === 200) {
            $definitions = $this->parseLookupResponse($response);
            return $definitions;
        }
        return false;
    }
1079530
public function getLookupUrl($text)
    {
        $resource = 'api/v1/dicservice.json/lookup';
        $query = http_build_query(
            [
                'key' => $this->getApiKey(),
                'lang' => $this->getLanguage(),
                'ui' => $this->getUiLanguage(),
                'flags' => $this->getFlags(),
                'text' => $text
            ]
        );
        $url = $this->getServiceUrl($resource) . '?' . $query;

        return $url;
    }
963959
public function slugify(string $text): string
    {
        $map = $this->getMap();
        $text = str_replace(array_keys($map), array_values($map), trim($text));

        $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII; Lower()');

        $text = $transliterator->transliterate($text);
        $text = str_replace('&', 'and', $text);

        return preg_replace(
            ['/[^\w\s]/', '/\s+/'],
            ['', '-'],
            $text
        );
    }
253301
public function text( string $text ): string
	{
		$then = $this->getThen();
		if( $this->lang_text )
		{
			return $this->lang->text($text, $then);
		}
		else
		{
			return $text;
		}
	}
770588
public static function strtotitle($text) {
        if (empty($text)) {
            return $text;
        }

        if (function_exists('mb_convert_case')) {
            return mb_convert_case($text, MB_CASE_TITLE, 'UTF-8');
        }

        $text = self::strtolower($text);
        $words = explode(' ', $text);
        foreach ($words as $i=>$word) {
            $length = self::strlen($word);
            if (!$length) {
                continue;

            } else if ($length == 1) {
                $words[$i] = self::strtoupper($word);

            } else {
                $letter = self::substr($word, 0, 1);
                $letter = self::strtoupper($letter);
                $rest   = self::substr($word, 1);
                $words[$i] = $letter.$rest;
            }
        }
        return implode(' ', $words);
    }
925327
public static function makeUrls(string $text) : string
    {
        $urlPattern = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\/\S*)?/";
        preg_match_all($urlPattern, $text, $matches);
        $usedPatterns = array();
        foreach($matches[0] as $pattern){
            if(!array_key_exists($pattern, $usedPatterns)){
                $usedPatterns[$pattern]=true;
                // now try to catch last thing in text
                $text = str_replace($pattern, '<a href="'.$pattern.'" target="_blank">'.$pattern.'</a>', $text);
            }
        }
        return $text;
    }
741167
private function filter($text)
    {
        $text = preg_replace("/[^&a-z0-9-_\s']/i", '', $text);
        $text = str_replace(' ', $this->separator, $text);
        $text = trim(preg_replace("/{$this->separator}{2,}/", $this->separator, $text), $this->separator);

        return $text;
    }
1041395
public function _(string $text) : string
    {
        return $this->c->translator instanceof ITranslator ? $this->c->translator->translate($text) : $text;
    }
880506
public static function ucwords($text) {
    $regex = '/(^|[' . static::PREG_CLASS_WORD_BOUNDARY . '])([^' . static::PREG_CLASS_WORD_BOUNDARY . '])/u';
    return preg_replace_callback($regex, function(array $matches) {
      return $matches[1] . Unicode::strtoupper($matches[2]);
    }, $text);
  }