Stash::_clean_string PHP Méthode

_clean_string() private méthode

String manipulations
private _clean_string ( string $value = NULL ) : string
$value string the string to parse
Résultat string
    private function _clean_string($value = NULL)
    {
        // register parameters
        $trim = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('trim'));
        $strip_tags = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('strip_tags'));
        $strip_curly_braces = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('strip_curly_braces'));
        $strip_unparsed = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('strip_unparsed'));
        $compress = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('compress'));
        $backspace = (int) $this->EE->TMPL->fetch_param('backspace', 0);
        $strip_vars = $this->EE->TMPL->fetch_param('strip', FALSE);
        // support legacy parameter name
        if (!$strip_unparsed) {
            $strip_unparsed = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('remove_unparsed_vars'));
        }
        // trim?
        if ($trim) {
            $value = str_replace(array("\t", "\n", "\r", "", "\v"), '', trim($value));
        }
        // remove whitespace between tags which are separated by line returns?
        if ($compress) {
            // remove spaces between tags
            $value = preg_replace('~>\\s*\\n\\s*<~', '><', $value);
            // double spaces, leading and trailing spaces
            $value = trim(preg_replace('/\\s\\s+/', ' ', $value));
        }
        // strip tags?
        if ($strip_tags) {
            $value = strip_tags($value);
        }
        // strip curly braces?
        if ($strip_curly_braces) {
            $value = str_replace(array(LD, RD), '', $value);
        }
        // backspace?
        if ($backspace) {
            // backspace can break unparsed conditionals and tags, so lets check for them
            $remove_from_end = substr($value, -$backspace);
            if (strrpos($remove_from_end, RD) !== false) {
                // unparsed var or tag within the backspace range, trim end as far as we safely can
                $value = substr($value, 0, strrpos($value, RD) + 1);
            } else {
                $value = substr($value, 0, -$backspace);
            }
        }
        // xss clean?
        if ($this->xss_clean) {
            $value = $this->EE->security->xss_clean($value);
        }
        // remove leftover placeholder variables {var} (leave stash: vars untouched)
        if ($strip_unparsed) {
            $value = preg_replace('/\\{\\/?(?!\\/?stash)[a-zA-Z0-9_\\-:]+\\}/', '', $value);
        }
        // cleanup specified single and pair variable placeholders
        if ($strip_vars) {
            $strip_vars = explode("|", $strip_vars);
            foreach ($strip_vars as $var) {
                $value = str_replace(array(LD . $var . RD, LD . '/' . $var . RD), '', $value);
            }
        }
        return $value;
    }