当前位置: 首页>>代码示例>>PHP>>正文


PHP HTMLPurifier_ConfigSchema::instance方法代码示例

本文整理汇总了PHP中HTMLPurifier_ConfigSchema::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLPurifier_ConfigSchema::instance方法的具体用法?PHP HTMLPurifier_ConfigSchema::instance怎么用?PHP HTMLPurifier_ConfigSchema::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLPurifier_ConfigSchema的用法示例。


在下文中一共展示了HTMLPurifier_ConfigSchema::instance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: instance

 /**
  * {@inheritDoc}
  */
 public static function instance($prototype = null)
 {
     $instance = parent::instance($prototype);
     $instance->add('AutoFormat.LinkifyWithTextLengthLimit.Limit', null, 'mixed', true);
     $instance->add('AutoFormat.LinkifyWithTextLengthLimit.Suffix', ' ...', 'string', true);
     $instance->add('AutoFormat.LinkifyWithTextLengthLimit.RemoveProtocol', true, 'bool', false);
     return $instance;
 }
开发者ID:Viacomino,项目名称:sutra,代码行数:11,代码来源:CustomLinkifyConfigurationSchema.php

示例2: register

 public function register(Application $app)
 {
     parent::register($app);
     $app['form.secret'] = $app->share(function () use($app) {
         return md5('form_secret' . $app['salt']);
     });
     $app['html_purifier.allowed_elements'] = ['p', 'ul', 'ol', 'li', 'b', 'i', 'strong', 'em', 'img', 'sub', 'sup', 'blockquote', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'address', 'br', 'dl', 'dt', 'dd'];
     $app['html_purifier.allowed_attributes'] = ['*.class', 'img.src', 'img.alt', 'a.href', 'a.title', 'td.abbr', 'td.colspan', 'td.rowspan', 'th.abbr', 'th.colspan', 'th.rowspan', 'table.summary'];
     $app['html_purifier.config'] = $app->share(function () use($app) {
         $config = new \HTMLPurifier_Config(\HTMLPurifier_ConfigSchema::instance());
         $config->set('HTML.Doctype', 'XHTML 1.0 Strict');
         $config->set('HTML.AllowedElements', implode(',', $app['html_purifier.allowed_elements']));
         $config->set('HTML.AllowedAttributes', implode(',', $app['html_purifier.allowed_attributes']));
         $config->set('AutoFormat.RemoveEmpty', true);
         $config->set('AutoFormat.AutoParagraph', true);
         $config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
         $cachePath = $app['paths.cache'] . '/htmlpurifier';
         if (!is_dir($cachePath)) {
             mkdir($cachePath, 0777, true);
         }
         $config->set('Cache.SerializerPath', $cachePath);
         return $config;
     });
     $app['html_purifier'] = $app->share(function () use($app) {
         return new \HTMLPurifier($app['html_purifier.config']);
     });
     $app['form.html_purifier'] = $app->share(function () use($app) {
         return new HtmlPurifier($app['html_purifier']);
     });
     $app['form.html_extension'] = $app->share(function () use($app) {
         return new HtmlExtension(new HtmlType($app['form.html_purifier']), new HtmlTypeGuesser($app['annotations.reader']));
     });
     $app['form.extensions'] = $app->share($app->extend('form.extensions', function (array $extensions) use($app) {
         $extensions[] = new DoctrineOrmExtension($app['orm.manager_registry']);
         $extensions[] = $app['form.html_extension'];
         return $extensions;
     }));
     $app['form.type.extensions'] = $app->share($app->extend('form.type.extensions', function (array $extensions) use($app) {
         $extensions[] = new FormTypeExtension();
         $extensions[] = new DateTypeExtension();
         $extensions[] = new TimeTypeExtension();
         return $extensions;
     }));
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:44,代码来源:FormServiceProvider.php

示例3: getAllowedDirectivesForForm

 /**
  * Returns a list of array(namespace, directive) for all directives
  * that are allowed in a web-form context as per an allowed
  * namespaces/directives list.
  *
  * @param array $allowed List of allowed namespaces/directives
  * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy
  *
  * @return array
  */
 public static function getAllowedDirectivesForForm($allowed, $schema = null)
 {
     if (!$schema) {
         $schema = HTMLPurifier_ConfigSchema::instance();
     }
     if ($allowed !== true) {
         if (is_string($allowed)) {
             $allowed = array($allowed);
         }
         $allowed_ns = array();
         $allowed_directives = array();
         $blacklisted_directives = array();
         foreach ($allowed as $ns_or_directive) {
             if (strpos($ns_or_directive, '.') !== false) {
                 // directive
                 if ($ns_or_directive[0] == '-') {
                     $blacklisted_directives[substr($ns_or_directive, 1)] = true;
                 } else {
                     $allowed_directives[$ns_or_directive] = true;
                 }
             } else {
                 // namespace
                 $allowed_ns[$ns_or_directive] = true;
             }
         }
     }
     $ret = array();
     foreach ($schema->info as $key => $def) {
         list($ns, $directive) = explode('.', $key, 2);
         if ($allowed !== true) {
             if (isset($blacklisted_directives["{$ns}.{$directive}"])) {
                 continue;
             }
             if (!isset($allowed_directives["{$ns}.{$directive}"]) && !isset($allowed_ns[$ns])) {
                 continue;
             }
         }
         if (isset($def->isAlias)) {
             continue;
         }
         if ($directive == 'DefinitionID' || $directive == 'DefinitionRev') {
             continue;
         }
         $ret[] = array($ns, $directive);
     }
     return $ret;
 }
开发者ID:dingdong2310,项目名称:g5_theme,代码行数:57,代码来源:HTMLPurifier.standalone.php

示例4: HTMLPurifier_ConfigSchema

<?php

// overload default configuration schema temporarily
$custom_schema = new HTMLPurifier_ConfigSchema();
$old = HTMLPurifier_ConfigSchema::instance();
$custom_schema =& HTMLPurifier_ConfigSchema::instance($custom_schema);
HTMLPurifier_ConfigSchema::defineNamespace('Element', 'Chemical substances that cannot be further decomposed');
HTMLPurifier_ConfigSchema::define('Element', 'Abbr', 'H', 'string', 'Abbreviation of element name.');
HTMLPurifier_ConfigSchema::define('Element', 'Name', 'hydrogen', 'istring', 'Full name of atoms.');
HTMLPurifier_ConfigSchema::define('Element', 'Number', 1, 'int', 'Atomic number, is identity.');
HTMLPurifier_ConfigSchema::define('Element', 'Mass', 1.00794, 'float', 'Atomic mass.');
HTMLPurifier_ConfigSchema::define('Element', 'Radioactive', false, 'bool', 'Does it have rapid decay?');
HTMLPurifier_ConfigSchema::define('Element', 'Isotopes', array('1' => true, '2' => true, '3' => true), 'lookup', 'What numbers of neutrons for this element have been observed?');
HTMLPurifier_ConfigSchema::define('Element', 'Traits', array('nonmetallic', 'odorless', 'flammable'), 'list', 'What are general properties of the element?');
HTMLPurifier_ConfigSchema::define('Element', 'IsotopeNames', array('1' => 'protium', '2' => 'deuterium', '3' => 'tritium'), 'hash', 'Lookup hash of neutron counts to formal names.');
HTMLPurifier_ConfigSchema::defineNamespace('Instrument', 'Of the musical type.');
HTMLPurifier_ConfigSchema::define('Instrument', 'Manufacturer', 'Yamaha', 'string', 'Who made it?');
HTMLPurifier_ConfigSchema::defineAllowedValues('Instrument', 'Manufacturer', array('Yamaha', 'Conn-Selmer', 'Vandoren', 'Laubin', 'Buffet', 'other'));
HTMLPurifier_ConfigSchema::defineValueAliases('Instrument', 'Manufacturer', array('Selmer' => 'Conn-Selmer'));
HTMLPurifier_ConfigSchema::define('Instrument', 'Family', 'woodwind', 'istring', 'What family is it?');
HTMLPurifier_ConfigSchema::defineAllowedValues('Instrument', 'Family', array('brass', 'woodwind', 'percussion', 'string', 'keyboard', 'electronic'));
HTMLPurifier_ConfigSchema::defineValueAliases('Instrument', 'Family', array('synth' => 'electronic'));
HTMLPurifier_ConfigSchema::defineNamespace('ReportCard', 'It is for grades.');
HTMLPurifier_ConfigSchema::define('ReportCard', 'English', null, 'string/null', 'Grade from English class.');
HTMLPurifier_ConfigSchema::define('ReportCard', 'Absences', 0, 'int', 'How many times missing from school?');
HTMLPurifier_ConfigSchema::defineNamespace('Text', 'This stuff is long, boring, and English.');
HTMLPurifier_ConfigSchema::define('Text', 'AboutUs', 'Nothing much, but this should be decently long so that a textarea would be better', 'text', 'Who are we? What are we up to?');
HTMLPurifier_ConfigSchema::define('Text', 'Hash', "not-case-sensitive\nstill-not-case-sensitive\nsuper-not-case-sensitive", 'itext', 'This is of limited utility, but of course it ends up being used.');
开发者ID:hasshy,项目名称:sahana-tw,代码行数:28,代码来源:testSchema.php

示例5: defineAlias

 /** @see HTMLPurifier_ConfigSchema->addAlias() */
 public static function defineAlias($namespace, $name, $new_namespace, $new_name)
 {
     HTMLPurifier_ConfigSchema::deprecated(__METHOD__);
     $def = HTMLPurifier_ConfigSchema::instance();
     $def->addAlias($namespace, $name, $new_namespace, $new_name);
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:HTMLPurifier.standalone.php

示例6: defineAlias

 /**
  * Defines a directive alias for backwards compatibility
  * @param $namespace
  * @param $name Directive that will be aliased
  * @param $new_namespace
  * @param $new_name Directive that the alias will be to
  */
 public static 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}";
 }
开发者ID:BGCX067,项目名称:ezrpg-svn-to-git,代码行数:35,代码来源:ConfigSchema.php

示例7: file_get_contents

<?php

require_once 'common.php';
if (isset($_GET['doc'])) {
    if (file_exists('testSchema.html') && filemtime('testSchema.php') < filemtime('testSchema.html') && !isset($_GET['purge'])) {
        echo file_get_contents('testSchema.html');
        exit;
    }
    if (version_compare('5', PHP_VERSION, '>')) {
        exit('Requires PHP 5 or higher.');
    }
    // setup schema for parsing
    require_once 'testSchema.php';
    $new_schema = $custom_schema;
    // dereference the reference
    HTMLPurifier_ConfigSchema::instance($old);
    // restore old version
    // setup ConfigDoc environment
    require_once '../configdoc/library/ConfigDoc.auto.php';
    // perform the ConfigDoc generation
    $configdoc = new ConfigDoc();
    $html = $configdoc->generate($new_schema, 'plain', array('css' => '../configdoc/styles/plain.css', 'title' => 'Sample Configuration Documentation'));
    $configdoc->cleanup();
    file_put_contents('testSchema.html', $html);
    echo $html;
    exit;
}
?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
开发者ID:hasshy,项目名称:sahana-tw,代码行数:31,代码来源:configForm.php

示例8: trigger_error

    if (file_exists($file)) {
        trigger_error("File already exists; skipped {$name}");
        return;
    }
    $file = new FSTools_File($file);
    $file->open('w');
    $multiline = false;
    foreach ($hash as $key => $value) {
        $multiline = $multiline || strpos($value, "\n") !== false;
        if ($multiline) {
            $file->put("--{$key}--" . PHP_EOL);
            $file->put(str_replace("\n", PHP_EOL, $value) . PHP_EOL);
        } else {
            if ($key == 'ID') {
                $file->put("{$value}" . PHP_EOL);
            } else {
                $file->put("{$key}: {$value}" . PHP_EOL);
            }
        }
    }
    $file->close();
}
$schema = HTMLPurifier_ConfigSchema::instance();
$adapter = new HTMLPurifier_ConfigSchema_StringHashReverseAdapter($schema);
foreach ($schema->info as $ns => $ns_array) {
    saveHash($adapter->get($ns));
    foreach ($ns_array as $dir => $x) {
        saveHash($adapter->get($ns, $dir));
    }
}
// vim: et sw=4 sts=4
开发者ID:artbypravesh,项目名称:morningpages,代码行数:31,代码来源:old-extract-schema.php

示例9: createDefault

 /**
  * Creates a configuration object using the default config schema instance
  *
  * @return HTMLPurifier_Config
  */
 public static function createDefault()
 {
     $schema = HTMLPurifier_ConfigSchema::instance();
     $config = self::create(null, $schema);
     return $config;
 }
开发者ID:xemlock,项目名称:htmlpurifier-html5,代码行数:11,代码来源:HTML5Config.php


注:本文中的HTMLPurifier_ConfigSchema::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。