⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configschema.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
            return;        }        foreach ($aliases as $alias => $real) {            if (HTMLPURIFIER_SCHEMA_STRICT) {                if (!$def->info[$namespace][$name] !== true &&                    !isset($def->info[$namespace][$name]->allowed[$real])                ) {                    trigger_error('Cannot define alias to value that is not allowed',                        E_USER_ERROR);                    return;                }                if (isset($def->info[$namespace][$name]->allowed[$alias])) {                    trigger_error('Cannot define alias over allowed value',                        E_USER_ERROR);                    return;                }            }            $def->info[$namespace][$name]->aliases[$alias] = $real;        }    }        /**     * Defines a set of allowed values for a directive.     * @static     * @param $namespace Namespace of directive     * @param $name Name of directive     * @param $allowed_values Arraylist of allowed values     */    function defineAllowedValues($namespace, $name, $allowed_values) {        $def =& HTMLPurifier_ConfigSchema::instance();        if (HTMLPURIFIER_SCHEMA_STRICT && !isset($def->info[$namespace][$name])) {            trigger_error('Cannot define allowed values for undefined directive',                E_USER_ERROR);            return;        }        $directive =& $def->info[$namespace][$name];        $type = $directive->type;        if (HTMLPURIFIER_SCHEMA_STRICT && $type != 'string' && $type != 'istring') {            trigger_error('Cannot define allowed values for directive whose type is not string',                E_USER_ERROR);            return;        }        if ($directive->allowed === true) {            $directive->allowed = array();        }        foreach ($allowed_values as $value) {            $directive->allowed[$value] = true;        }        if (            HTMLPURIFIER_SCHEMA_STRICT &&            $def->defaults[$namespace][$name] !== null &&            !isset($directive->allowed[$def->defaults[$namespace][$name]])        ) {            trigger_error('Default value must be in allowed range of variables',                E_USER_ERROR);            $directive->allowed = true; // undo undo!            return;        }    }        /**     * Defines a directive alias for backwards compatibility     * @static     * @param $namespace     * @param $name Directive that will be aliased     * @param $new_namespace     * @param $new_name Directive that the alias will be to     */    function defineAlias($namespace, $name, $new_namespace, $new_name) {        $def =& HTMLPurifier_ConfigSchema::instance();        if (HTMLPURIFIER_SCHEMA_STRICT) {            if (!isset($def->info[$namespace])) {                trigger_error('Cannot define directive alias in undefined namespace',                    E_USER_ERROR);                return;            }            if (!ctype_alnum($name)) {                trigger_error('Directive name must be alphanumeric',                    E_USER_ERROR);                return;            }            if (isset($def->info[$namespace][$name])) {                trigger_error('Cannot define alias over directive',                    E_USER_ERROR);                return;            }            if (!isset($def->info[$new_namespace][$new_name])) {                trigger_error('Cannot define alias to undefined directive',                    E_USER_ERROR);                return;            }            if ($def->info[$new_namespace][$new_name]->class == 'alias') {                trigger_error('Cannot define alias to alias',                    E_USER_ERROR);                return;            }        }        $def->info[$namespace][$name] =            new HTMLPurifier_ConfigDef_DirectiveAlias(                $new_namespace, $new_name);        $def->info[$new_namespace][$new_name]->directiveAliases[] = "$namespace.$name";    }        /**     * Validate a variable according to type. Return null if invalid.     */    function validate($var, $type, $allow_null = false) {        if (!isset($this->types[$type])) {            trigger_error('Invalid type', E_USER_ERROR);            return;        }        if ($allow_null && $var === null) return null;        switch ($type) {            case 'mixed':                //if (is_string($var)) $var = unserialize($var);                return $var;            case 'istring':            case 'string':            case 'text': // no difference, just is longer/multiple line string            case 'itext':                if (!is_string($var)) break;                if ($type === 'istring' || $type === 'itext') $var = strtolower($var);                return $var;            case 'int':                if (is_string($var) && ctype_digit($var)) $var = (int) $var;                elseif (!is_int($var)) break;                return $var;            case 'float':                if (is_string($var) && is_numeric($var)) $var = (float) $var;                elseif (!is_float($var)) break;                return $var;            case 'bool':                if (is_int($var) && ($var === 0 || $var === 1)) {                    $var = (bool) $var;                } elseif (is_string($var)) {                    if ($var == 'on' || $var == 'true' || $var == '1') {                        $var = true;                    } elseif ($var == 'off' || $var == 'false' || $var == '0') {                        $var = false;                    } else {                        break;                    }                } elseif (!is_bool($var)) break;                return $var;            case 'list':            case 'hash':            case 'lookup':                if (is_string($var)) {                    // special case: technically, this is an array with                    // a single empty string item, but having an empty                    // array is more intuitive                    if ($var == '') return array();                    if (strpos($var, "\n") === false && strpos($var, "\r") === false) {                        // simplistic string to array method that only works                        // for simple lists of tag names or alphanumeric characters                        $var = explode(',',$var);                    } else {                        $var = preg_split('/(,|[\n\r]+)/', $var);                    }                    // remove spaces                    foreach ($var as $i => $j) $var[$i] = trim($j);                    if ($type === 'hash') {                        // key:value,key2:value2                        $nvar = array();                        foreach ($var as $keypair) {                            $c = explode(':', $keypair, 2);                            if (!isset($c[1])) continue;                            $nvar[$c[0]] = $c[1];                        }                        $var = $nvar;                    }                }                if (!is_array($var)) break;                $keys = array_keys($var);                if ($keys === array_keys($keys)) {                    if ($type == 'list') return $var;                    elseif ($type == 'lookup') {                        $new = array();                        foreach ($var as $key) {                            $new[$key] = true;                        }                        return $new;                    } else break;                }                if ($type === 'lookup') {                    foreach ($var as $key => $value) {                        $var[$key] = true;                    }                }                return $var;        }        $error = new HTMLPurifier_Error();        return $error;    }        /**     * Takes an absolute path and munges it into a more manageable relative path     */    function mungeFilename($filename) {        if (!HTMLPURIFIER_SCHEMA_STRICT) return $filename;        $offset = strrpos($filename, 'HTMLPurifier');        $filename = substr($filename, $offset);        $filename = str_replace('\\', '/', $filename);        return $filename;    }        /**     * Checks if var is an HTMLPurifier_Error object     */    function isError($var) {        if (!is_object($var)) return false;        if (!is_a($var, 'HTMLPurifier_Error')) return false;        return true;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -