Print "trans" tag for string $str with parameters $parameters
for catalog $catalog.

@param $str
@param  array  $parameters
@param  string $catalog
@return string
357111
public function getEchoTrans($str, array $parameters = array(), $catalog = 'Admingenerator', $escape = null)
    {
        $transParameters='{}';
        $bag_parameters=array();

        if ($parameterBag = $this->getParameterBag($str)) {
            $str = $parameterBag['string'];
            $bag_parameters = $parameterBag['params'];
        }

        if (!empty($parameters) || !empty($bag_parameters)) {
            $transParameters="{";

            foreach ($parameters as $key => $value) {
                $transParameters.= "'%".$key."%': '".str_replace("'", "\'", $value)."',";
            }
            foreach ($bag_parameters as $key => $value) {
                $transParameters.= "'%".$key."%': ".str_replace("'", "\'", $value).",";
            }

            $transParameters.="}";
        }

        return sprintf(
            '{{ "%s"|trans(%s, "%s")%s }}',
            str_replace('"', '\"', $str),
            $transParameters,
            $catalog,
            $escape ? sprintf('|escape("%s")', $escape) : '|raw'
        );
    }
1287562
public static function encodeOperators(
        $str)
    {
        if (self::$_translations === null) {
            self::_buildTranslations();
        }

        return strtr($str, self::$_translations['encode']);
    }
146785
protected function _replaceData($str, $data) {
		// Supported tags.
		$tags = array(
			'[__]' => '[/__]', '[__d]' => '[/__d]', '[__c]' => '[/__c]', '[php]' => '[/php]', '[currency]' => '[/currency]',
			'[url]' => '[/url]', '[image]' => '[/image]', '[link]' => '[/link]', '[truncate]' => '[/truncate]', '[time]' => '[/time]'
		);

		// Find all array path (i.e. [Post.title], [Comment.{n}.text], [Roles.{n, }.name]) matches.
		if (!preg_match_all('/\[([A-Za-z0-9_{},\s\.]+)\]/iUs', $str, $matches)) {
			return $str;
		}

		foreach ($matches[0] as $i => $match) {
			// Skip when exact match of other tag.
			if (in_array($match, $tags) || isset($tags[$match])) {
				continue;
			}

			// Skip when matches tag with attributes (i.e. [truncate length=10]).
			$continue = false;
			foreach (array_keys($tags) as $needle) {
				if ($continue = strpos($match, substr($needle, 0, -1)) === 0) {
					break;
				}
			}
			if ($continue) {
				continue;
			}

			// Check if {f} or {l} in array path.
			// @todo Write tests.
			preg_match('/\{([fl])\}/iUs', $matches[1][$i], $el);

			if (!empty($el)) {
				$matches[1][$i] = str_replace('{' . $el[1] . '}', '{n}', $matches[1][$i]);

				if ('l' == $el[1]) {
					$replace = array_pop(Hash::extract($data, $matches[1][$i]));
				} else if ('f' == $el[1]) {
					$replace = array_shift(Hash::extract($data, $matches[1][$i]));
				}

				$str = str_replace($match, $replace, $str);
				continue;
			}

			// Check if {n} or {s} in array path.
			preg_match('/\{[ns](.+)\}/iUs', $matches[1][$i], $glue);

			// Set string to use in `implode()` extract results.
			if (empty($glue[1])) {
				$glue[1] = ' ';
			} else {
				$matches[1][$i] = str_replace($glue[0], substr($glue[0], 0, 2) . '}', $matches[1][$i]);
			}

			// Replace.
			$str = str_replace($match, implode($glue[1], Hash::extract($data, trim($matches[1][$i]))), $str);
		}

		return $str;
	}
738690
protected function translate($message, $parameters = array())
    {
        return $this->translator->trans($message, $parameters, $this->translationDomain);
    }
1354526
protected function parseAnnotationVars(string $str, array $vars): string
    {
        // not use vars
        if (false === strpos($str, '{')) {
            return $str;
        }

        $map = [];

        foreach ($vars as $key => $value) {
            $key = sprintf(self::ANNOTATION_VAR, $key);
            $map[$key] = $value;
        }

        return $map ? strtr($str, $map) : $str;
    }
716681
protected function _processString($str, $opts)
    {
        if (!empty($opts['length'])) {
            return substr($str, empty($opts['start']) ? 0 : $opts['start'], $opts['length']);
        } elseif (!empty($opts['start'])) {
            return substr($str, $opts['start']);
        }

        return $str;
    }
1107338
public static function headerStringToArray($str){

		if(!\is_string($str)){
			throw new \InvalidArgumentException('$str not a string');
		}

		$arr = array();
		$header = '';

		foreach(\explode("\r\n", \trim($str)) as $hStr){
			
			$header = \explode(':', $hStr, 2);
			
			if(\strlen($hStr >= 3)){ //[h]:[v], min 3
				$arr[\strtolower(\trim($header[0]))] 
						= isset($header[1]) ? \trim($header[1]) : null;
			}
			
		}

		return $arr;

	}
269949
function translate($str, $tokens = [])
    {
        if (array_key_exists($str, $this->translation)) {
            $str = $this->translation[$str];
        }
        if (is_array($tokens) && sizeof($tokens) > 0) {
            $str = vsprintf($str, $tokens);
        }

        return $str;
    }
526492
private function parseHeaders($str) {

		if(false === is_string($str)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($str)), E_USER_ERROR);
		}
		
		$headers = [];
		$status  = [];

		foreach(explode("\n", $str) as $header) {
			
			if(preg_match('/(:)/is', $header)) {
				list($key, $value) = preg_split('/(:)/is', $header, 2);
			}
			else {
				$key = $header;
			}

			if(trim($key) !== '') {

				if(preg_match('/(https?\/[0-9]\.[0-9])/i', $key, $http)) {

					$status['code'] = null;

					if(preg_match('/([0-9]+)/', ltrim($key, $http[0]), $code)) {
						$status['code'] = $code[0];
					}

					$status['protocol'] = $http[0];
					$status['status'] 	= trim($key);
					$status['text'] 	= trim(ltrim(trim(ltrim($key, $status['protocol'])), $status['code']));
					
				}
				else {
					$headers[strtolower($key)] = trim($value);
				}
			}
		}

		return ['headers' => $headers, 'status' => $status];
	}
492135
static function strfilter($str)
    {
        $str = str_replace(' ', '_', $str);

        $str = strip_tags($str);

        $str = htmlspecialchars($str);

        return $str;
    }
697921
function str_slug($str, $options = array()) {
        // Make sure string is in UTF-8 and strip invalid UTF-8 characters
        $str = mb_convert_encoding((string)$str, 'UTF-8', mb_list_encodings());

        $defaults = array(
            'delimiter' => '-',
            'limit' => null,
            'lowercase' => true,
            'replacements' => array(),
            'transliterate' => false,
        );

        // Merge options
        $options = array_merge($defaults, $options);

        $char_map = array(
            // Latin
            'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'AE', 'Ç' => 'C',
            'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I',
            'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ő' => 'O',
            'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ű' => 'U', 'Ý' => 'Y', 'Þ' => 'TH',
            'ß' => 'ss',
            'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'ae', 'ç' => 'c',
            'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i',
            'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ő' => 'o',
            'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th',
            'ÿ' => 'y',
            // Latin symbols
            '©' => '(c)',
            // Greek
            'Α' => 'A', 'Β' => 'B', 'Γ' => 'G', 'Δ' => 'D', 'Ε' => 'E', 'Ζ' => 'Z', 'Η' => 'H', 'Θ' => '8',
            'Ι' => 'I', 'Κ' => 'K', 'Λ' => 'L', 'Μ' => 'M', 'Ν' => 'N', 'Ξ' => '3', 'Ο' => 'O', 'Π' => 'P',
            'Ρ' => 'R', 'Σ' => 'S', 'Τ' => 'T', 'Υ' => 'Y', 'Φ' => 'F', 'Χ' => 'X', 'Ψ' => 'PS', 'Ω' => 'W',
            'Ά' => 'A', 'Έ' => 'E', 'Ί' => 'I', 'Ό' => 'O', 'Ύ' => 'Y', 'Ή' => 'H', 'Ώ' => 'W', 'Ϊ' => 'I',
            'Ϋ' => 'Y',
            'α' => 'a', 'β' => 'b', 'γ' => 'g', 'δ' => 'd', 'ε' => 'e', 'ζ' => 'z', 'η' => 'h', 'θ' => '8',
            'ι' => 'i', 'κ' => 'k', 'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => '3', 'ο' => 'o', 'π' => 'p',
            'ρ' => 'r', 'σ' => 's', 'τ' => 't', 'υ' => 'y', 'φ' => 'f', 'χ' => 'x', 'ψ' => 'ps', 'ω' => 'w',
            'ά' => 'a', 'έ' => 'e', 'ί' => 'i', 'ό' => 'o', 'ύ' => 'y', 'ή' => 'h', 'ώ' => 'w', 'ς' => 's',
            'ϊ' => 'i', 'ΰ' => 'y', 'ϋ' => 'y', 'ΐ' => 'i',
            // Turkish
            'Ş' => 'S', 'İ' => 'I', 'Ç' => 'C', 'Ü' => 'U', 'Ö' => 'O', 'Ğ' => 'G',
            'ş' => 's', 'ı' => 'i', 'ç' => 'c', 'ü' => 'u', 'ö' => 'o', 'ğ' => 'g',
            // Russian
            'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'Yo', 'Ж' => 'Zh',
            'З' => 'Z', 'И' => 'I', 'Й' => 'J', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O',
            'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C',
            'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sh', 'Ъ' => '', 'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'Yu',
            'Я' => 'Ya',
            'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo', 'ж' => 'zh',
            'з' => 'z', 'и' => 'i', 'й' => 'j', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o',
            'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c',
            'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sh', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e', 'ю' => 'yu',
            'я' => 'ya',
            // Ukrainian
            'Є' => 'Ye', 'І' => 'I', 'Ї' => 'Yi', 'Ґ' => 'G',
            'є' => 'ye', 'і' => 'i', 'ї' => 'yi', 'ґ' => 'g',
            // Czech
            'Č' => 'C', 'Ď' => 'D', 'Ě' => 'E', 'Ň' => 'N', 'Ř' => 'R', 'Š' => 'S', 'Ť' => 'T', 'Ů' => 'U',
            'Ž' => 'Z',
            'č' => 'c', 'ď' => 'd', 'ě' => 'e', 'ň' => 'n', 'ř' => 'r', 'š' => 's', 'ť' => 't', 'ů' => 'u',
            'ž' => 'z',
            // Polish
            'Ą' => 'A', 'Ć' => 'C', 'Ę' => 'e', 'Ł' => 'L', 'Ń' => 'N', 'Ó' => 'o', 'Ś' => 'S', 'Ź' => 'Z',
            'Ż' => 'Z',
            'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z',
            'ż' => 'z',
            // Latvian
            'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'i', 'Ķ' => 'k', 'Ļ' => 'L', 'Ņ' => 'N',
            'Š' => 'S', 'Ū' => 'u', 'Ž' => 'Z',
            'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n',
            'š' => 's', 'ū' => 'u', 'ž' => 'z'
        );

        // Make custom replacements
        $str = preg_replace(array_keys($options['replacements']), $options['replacements'], $str);

        // Transliterate characters to ASCII
        if ($options['transliterate']) {
            $str = str_replace(array_keys($char_map), $char_map, $str);
        }

        // Replace non-alphanumeric characters with our delimiter
        $str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str);

        // Remove duplicate delimiters
        $str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str);

        // Truncate slug to max. characters
        $str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8');

        // Remove delimiter from ends
        $str = trim($str, $options['delimiter']);

        return mb_strtolower($str, 'UTF-8') ;
    }
1174551
public function loadTemplateFromString($str)
    {
        $this->source = 'string: '.$str;
        $this->template = $this->tags = [];
        if (!$str) {
            return;
        }
        $this->tag_cnt = [];

        /* First expand self-closing tags {$tag} -> {tag}{/tag} */
        $str = preg_replace('/{\$([-_:\w]+)}/', '{\1}{/\1}', $str);

        $this->parseTemplate($str);

        return $this;
    }
1116390
public function trans($message, array $parameters = array())
    {
        return $this->translation->trans($message, $parameters, $this->domain, $this->locale);
    }
678550
public static function getBasic($str)
    {
        $r = '';
        /*
         * Split the string by line breakes.
         */
        foreach (preg_split('/\n\r|\n|\r/', $str, -1, PREG_SPLIT_NO_EMPTY) as $k => $line) {
            /*
             * And append it with tabs and line breaks to the return var.
             */
            $r .= Generator::getTabs();
            $r .= trim($line);
            $r .= Generator::getLineBreak();
        }

        return $r;
    }
228198
private function _parse_sections($str, $media_queries = array())
    {
        // Pre-process: collapse all whitespace and strip whitespace around '>',
        // '.', ':', '+', '#'

        $patterns = array("/[\\s\n]+/", "/\\s+([>.:+#])\\s+/");
        $replacements = array(" ", "\\1");
        $str = preg_replace($patterns, $replacements, $str);
        $DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();

        $sections = explode("}", $str);
        if ($DEBUGCSS) print '[_parse_sections';
        foreach ($sections as $sect) {
            $i = mb_strpos($sect, "{");
            if ($i === false) { continue; }

            //$selectors = explode(",", mb_substr($sect, 0, $i));
            $selectors = preg_split("/,(?![^\(]*\))/", mb_substr($sect, 0, $i),0, PREG_SPLIT_NO_EMPTY);
            if ($DEBUGCSS) print '[section';

            $style = $this->_parse_properties(trim(mb_substr($sect, $i + 1)));

            // Assign it to the selected elements
            foreach ($selectors as $selector) {
                $selector = trim($selector);

                if ($selector == "") {
                    if ($DEBUGCSS) print '#empty#';
                    continue;
                }
                if ($DEBUGCSS) print '#' . $selector . '#';
                //if ($DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }

                //FIXME: tag the selector with a hash of the media query to separate it from non-conditional styles (?), xpath comments are probably not what we want to do here
                if (count($media_queries) > 0) {
                    $style->set_media_queries($media_queries);
                }
                $this->add_style($selector, $style);
            }

            if ($DEBUGCSS) {
                print 'section]';
            }
        }

        if ($DEBUGCSS) {
            print '_parse_sections]';
        }
    }
1234469
public static function Translate( $item, $mapString, $transString )
	{
		if ( $item instanceof Undefined )
		    return "";

		$value = $item . "";
		$result = "";
		for ( $i = 0; $i < strlen( $value ); $i++ )
		{
			if ( ( $mapPos = strpos( $mapString, $value[ $i ] ) ) === false )
			{
				$result .= $value[ $i ];
				continue;
			}

			if ( $mapPos > strlen( $transString ) - 1 ) continue;

			$result .= $transString[ $mapPos ];
		}
		return $result;
	}
16574
public static function formatString($str, $args)
    {
        foreach ($args as $k => $v) {
            $str = preg_replace('/:'. $k. ':/', $v, $str);
        }
        return $str;
    }