转义 javascript 代码标记，适用于不允许html内容的类型.
应用场合：对于url,callback等类型值使用

@param  string|array $value
@return mixed
324634
static public function escape_script($value) 
    {
        if(is_array($value)){
            foreach ($value as $key => $val){
                $value[$key] = escape_script($val);
            }
        }else{
            $value = preg_replace ( '/\<([\/]?)script([^\>]*?)\>/si', '&lt;\\1script\\2&gt;', $value );
            $value = preg_replace ( '/\<([\/]?)iframe([^\>]*?)\>/si', '&lt;\\1iframe\\2&gt;', $value );
            $value = preg_replace ( '/\<([\/]?)frame([^\>]*?)\>/si', '&lt;\\1frame\\2&gt;', $value );
            $value = str_replace ( 'javascript:', 'javascript：', $value );
        }
        return $value;
    }
98460
public function render($value)
    {
        $options = [
            'cssMinifier' => function ($css) {
                return $this->css->render($css);
            },
            'jsMinifier' => function ($js) {
                return $this->js->render($js);
            },
            'jsCleanComments' => true,
        ];

        return Minify_HTML::minify($value, $options);
    }
913981
public static function getValue($value)
    {
        if (is_string($value)) {
            return static::escapeText($value);
        }
        if (is_bool($value)) {
            return static::getBoolean($value);
        }
        if (is_array($value)) {
            return static::getArray($value);
        }
        return $value;
    }
108299
public static function realUrl(string $value)
    {
        list($scheme, $url) = explode('//', $value);
        $reverse = explode('/', $url);
        $arr = [];
        foreach ($reverse as $item) {
            $arr[] = $item;
            if ($item == '..') {
                array_pop($arr);    // remove 2x from array stack
                array_pop($arr);
            }
        }
        return $scheme . '//' . implode('/', $arr);
    }
791017
protected function encode($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'encode'], $value);
        } else {
            return str_replace(['+', '%7E'], [' ', '~'], rawurlencode($value));
        }
    }
1136881
protected static function getParametersInValue($value)
    {
        $parameters = [];
        $regex = '/'.self::PARAM_MARKER.'(.*?)'.self::PARAM_MARKER.'/';
        $value = is_array($value) ? $value : [$value];

        foreach ($value as $attrValue) {
            if (is_string($attrValue) && preg_match_all($regex, $attrValue, $matches) && isset($matches[1])) {
                $parameters = array_merge($parameters, $matches[1]);
            }
        }

        return $parameters;
    }
1222663
public function compile($value = "")
	{
		$html = $this->compiledLabel;

		if (!empty($this->help)) {
			$html .= "<div class='help'>{$this->help}</div>";
		}

		$html .= "<input type=\"{$this->type}\" name=\"{$this->name}\" {$this->compiledAttr} value=\"{$value}\" />";

		return $html;
	}
922995
public function parse_value($value) {
        global $COURSE;

        if (strpos($value, '$ToolProxyBinding.custom.url') !== false) {
            if ($COURSE->format == 'site') {
                $this->params['context_type'] = 'Group';
            } else {
                $this->params['context_type'] = 'CourseSection';
            }
            $this->params['context_id'] = $COURSE->id;
            $this->params['vendor_code'] = $this->get_service()->get_tool_proxy()->vendorcode;
            $this->params['product_code'] = $this->get_service()->get_tool_proxy()->guid;
            $value = str_replace('$ToolProxyBinding.custom.url', parent::get_endpoint(), $value);
        }
        return $value;

    }
353656
public function checkHtml($value)
    {
        if (!Type::isStringLike($value)) {
            return false;
        }

        $string = "$value";

        return $string != strip_tags($string);
    }
120865
protected function serializeValue($value)
    {
        if (is_string($value)) {
            return $value;
        }
        if (is_object($value) || is_array($value)) {
            return json_encode($value);
        }
    }
286827
public static function parse($value)
    {
        if (\is_string($value)) {
            $operator = null;
            if (\strpos($value, AbstractMatcher::OPERATOR_AND)) {
                $operator = AbstractMatcher::OPERATOR_AND;
                $value = \explode(AbstractMatcher::OPERATOR_AND, $value);
            } elseif (\strpos($value, AbstractMatcher::OPERATOR_OR)) {
                $operator = AbstractMatcher::OPERATOR_OR;
                $value = \explode(AbstractMatcher::OPERATOR_OR, $value);
            } elseif (0 === \strpos($value, AbstractMatcher::OPERATOR_NOT)) {
                $value = [AbstractMatcher::OPERATOR_NOT => \substr($value, 1)];
            }
            if (null !== $operator) {
                return [
                    $operator => \array_map(
                        function ($val) {
                            return 0 === \strpos($val, AbstractMatcher::OPERATOR_NOT)
                                ? [AbstractMatcher::OPERATOR_NOT => \substr($val, 1)]
                                : $val;
                        },
                        $value
                    )
                ];
            }
        }

        return $value;
    }
984258
public function convertFromUrlEncode($value)
    {
        $converted = urldecode($value);
        if (!$converted || $converted === $value) {
            return $value;
        } else {
            return $value . "\n" . $converted;
        }
    }
1016607
public static function clean_vars($value){
        if(is_array($value)){
            foreach($value as $key => $val) {
                $value[$key] = self::clean_vars($val);
            }
        }
        else{
            $value= self::filter_simple_xss($value);
        }
        return $value;
    }
29701
static private function stringify($value)
        {
            if (is_bool($value)) {
                return $value ? '<TRUE>' : '<FALSE>';
            }

            if (is_scalar($value)) {
                $val = (string) $value;

                if (strlen($val) > 100) {
                    $val = substr($val, 0, 97) . '...';
                }

                return $val;
            }

            if (Arrays::is($value)) {
                return '<ARRAY>';
            }

            if (is_object($value)) {
                return get_class($value);
            }

            if (is_resource($value)) {
                return '<RESOURCE>';
            }

            if ($value === null) {
                return '<NULL>';
            }

            return 'unknown';
        }
125949
public static function getTypeCodeFromObject( $value )
	{
		if ( is_null( $value ) )
		{
			return TypeCode::Null_;
		}

		if ( is_array( $value ) )
		{
			return TypeCode::assocArray;
		}

		if ( is_string( $value ) )
		{
			return strlen( $value ) === 1 ? TypeCode::Char : TypeCode::String;
		}

		if ( $value instanceof DateTime )
		{
			return TypeCode::DateTime;
		}

		if ( $value instanceof DateTimeInterval )
		{
			return TypeCode::DateTimeInterval;
		}

		if ( is_double( $value ) )
		{
			return TypeCode::Double;
		}

		if ( is_int( $value ) )
		{
			return TypeCode::Int32;
		}

		if ( is_bool( $value ) )
		{
			return TypeCode::Boolean;
		}

		if ( is_object( $value ) )
		{
			return TypeCode::Object;
		}
	}
326573
protected function processCallbackArray($value)
    {
        if ($this->isCallbackArray($value)) {
            
            $class  = $value['class'];
            $method = $value['method'];
            
            if ($result = call_user_func("{$class}::{$method}")) {
                
                if (isset($value['property'])) {
                    return $result->{$value['property']};
                }
                
                return $result;
                
            }
            
        }
    }
668444
private static function stringify($value)
    {
        if (is_bool($value)) {
            return $value ? '<TRUE>' : '<FALSE>';
        }

        if (is_scalar($value)) {
            $val = (string)$value;

            if (strlen($val) > 100) {
                $val = substr($val, 0, 97) . '...';
            }

            return $val;
        }

        if (is_array($value)) {
            return '<ARRAY>';
        }

        if (is_object($value)) {
            return get_class($value);
        }

        if (is_resource($value)) {
            return '<RESOURCE>';
        }

        if ($value === NULL) {
            return '<NULL>';
        }

        return 'unknown';
    }