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


PHP HTMLPurifier_LanguageFactory类代码示例

本文整理汇总了PHP中HTMLPurifier_LanguageFactory的典型用法代码示例。如果您正苦于以下问题:PHP HTMLPurifier_LanguageFactory类的具体用法?PHP HTMLPurifier_LanguageFactory怎么用?PHP HTMLPurifier_LanguageFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: instance

 /**
  * Retrieve sole instance of the factory.
  * @param $prototype Optional prototype to overload sole instance with,
  *                   or bool true to reset to default factory.
  */
 public static function instance($prototype = null)
 {
     static $instance = null;
     if ($prototype !== null) {
         $instance = $prototype;
     } elseif ($instance === null || $prototype == true) {
         $instance = new HTMLPurifier_LanguageFactory();
         $instance->setup();
     }
     return $instance;
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:16,代码来源:LanguageFactory.php

示例2: generateEnLanguage

 protected function generateEnLanguage()
 {
     $factory = HTMLPurifier_LanguageFactory::instance();
     $config = HTMLPurifier_Config::create(array('Core.Language' => 'en'));
     $context = new HTMLPurifier_Context();
     return $factory->create($config, $context);
 }
开发者ID:youprofit,项目名称:casebox,代码行数:7,代码来源:LanguageTest.php

示例3: setup

 public function setup()
 {
     parent::setup();
     $config = HTMLPurifier_Config::createDefault();
     $this->language = HTMLPurifier_LanguageFactory::instance()->create($config, $this->context);
     $this->context->register('Locale', $this->language);
     $this->collector = new HTMLPurifier_ErrorCollector($this->context);
     $this->context->register('Generator', new HTMLPurifier_Generator($config, $this->context));
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:9,代码来源:AttrValidator_ErrorsTest.php

示例4: load

 /**
  * Loads language object with necessary info from factory cache
  * @note This is a lazy loader
  */
 public function load()
 {
     if ($this->_loaded) {
         return;
     }
     $factory = HTMLPurifier_LanguageFactory::instance();
     $factory->loadLanguage($this->code);
     foreach ($factory->keys as $key) {
         $this->{$key} = $factory->cache[$this->code][$key];
     }
     $this->_loaded = true;
 }
开发者ID:BGCX067,项目名称:ezrpg-svn-to-git,代码行数:16,代码来源:Language.php

示例5: purify

 /**
  * Filters an HTML snippet/document to be XSS-free and standards-compliant.
  *
  * @param $html String of HTML to purify
  * @param $config HTMLPurifier_Config object for this operation, if omitted,
  *                defaults to the config object specified during this
  *                object's construction. The parameter can also be any type
  *                that HTMLPurifier_Config::create() supports.
  * @return Purified HTML
  */
 public function purify($html, $config = null)
 {
     // :TODO: make the config merge in, instead of replace
     $config = $config ? HTMLPurifier_Config::create($config) : $this->config;
     // implementation is partially environment dependant, partially
     // configuration dependant
     $lexer = HTMLPurifier_Lexer::create($config);
     $context = new HTMLPurifier_Context();
     // setup HTML generator
     $this->generator = new HTMLPurifier_Generator($config, $context);
     $context->register('Generator', $this->generator);
     // set up global context variables
     if ($config->get('Core.CollectErrors')) {
         // may get moved out if other facilities use it
         $language_factory = HTMLPurifier_LanguageFactory::instance();
         $language = $language_factory->create($config, $context);
         $context->register('Locale', $language);
         $error_collector = new HTMLPurifier_ErrorCollector($context);
         $context->register('ErrorCollector', $error_collector);
     }
     // setup id_accumulator context, necessary due to the fact that
     // AttrValidator can be called from many places
     $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context);
     $context->register('IDAccumulator', $id_accumulator);
     $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
     // setup filters
     $filter_flags = $config->getBatch('Filter');
     $custom_filters = $filter_flags['Custom'];
     unset($filter_flags['Custom']);
     $filters = array();
     foreach ($filter_flags as $filter => $flag) {
         if (!$flag) {
             continue;
         }
         if (strpos($filter, '.') !== false) {
             continue;
         }
         $class = "HTMLPurifier_Filter_{$filter}";
         $filters[] = new $class();
     }
     foreach ($custom_filters as $filter) {
         // maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat
         $filters[] = $filter;
     }
     $filters = array_merge($filters, $this->filters);
     // maybe prepare(), but later
     for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) {
         $html = $filters[$i]->preFilter($html, $config, $context);
     }
     // purified HTML
     $html = $this->generator->generateFromTokens($this->strategy->execute($lexer->tokenizeHTML($html, $config, $context), $config, $context));
     for ($i = $filter_size - 1; $i >= 0; $i--) {
         $html = $filters[$i]->postFilter($html, $config, $context);
     }
     $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
     $this->context =& $context;
     return $html;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:68,代码来源:HTMLPurifier.php

示例6: create

 /**
  * Creates a language object, handles class fallbacks
  * @param $config Instance of HTMLPurifier_Config
  * @param $context Instance of HTMLPurifier_Context
  */
 function create($config, &$context)
 {
     // validate language code
     $code = $this->validator->validate($config->get('Core', 'Language'), $config, $context);
     if ($code === false) {
         $code = 'en';
     }
     // malformed code becomes English
     $pcode = str_replace('-', '_', $code);
     // make valid PHP classname
     static $depth = 0;
     // recursion protection
     if ($code == 'en') {
         $class = 'HTMLPurifier_Language';
         $file = $this->dir . '/Language.php';
     } else {
         $class = 'HTMLPurifier_Language_' . $pcode;
         $file = $this->dir . '/Language/classes/' . $code . '.php';
         // PHP5/APC deps bug workaround can go here
         // you can bypass the conditional include by loading the
         // file yourself
         if (file_exists($file) && !class_exists($class)) {
             include_once $file;
         }
     }
     if (!class_exists($class)) {
         // go fallback
         $fallback = HTMLPurifier_LanguageFactory::getFallbackFor($code);
         $depth++;
         $lang = HTMLPurifier_LanguageFactory::factory($fallback);
         $depth--;
     } else {
         $lang = new $class($config, $context);
     }
     $lang->code = $code;
     return $lang;
 }
开发者ID:fferriere,项目名称:web,代码行数:42,代码来源:LanguageFactory.php

示例7: purify

 /**
  * Filters an HTML snippet/document to be XSS-free and standards-compliant.
  * 
  * @param $html String of HTML to purify
  * @param $config HTMLPurifier_Config object for this operation, if omitted,
  *                defaults to the config object specified during this
  *                object's construction. The parameter can also be any type
  *                that HTMLPurifier_Config::create() supports.
  * @return Purified HTML
  */
 function purify($html, $config = null)
 {
     $config = $config ? HTMLPurifier_Config::create($config) : $this->config;
     // implementation is partially environment dependant, partially
     // configuration dependant
     $lexer = HTMLPurifier_Lexer::create($config);
     $context = new HTMLPurifier_Context();
     // our friendly neighborhood generator, all primed with configuration too!
     $this->generator->generateFromTokens(array(), $config, $context);
     $context->register('Generator', $this->generator);
     // set up global context variables
     if ($config->get('Core', 'CollectErrors')) {
         // may get moved out if other facilities use it
         $language_factory = HTMLPurifier_LanguageFactory::instance();
         $language = $language_factory->create($config, $context);
         $context->register('Locale', $language);
         $error_collector = new HTMLPurifier_ErrorCollector($context);
         $context->register('ErrorCollector', $error_collector);
     }
     $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
     for ($i = 0, $size = count($this->filters); $i < $size; $i++) {
         $html = $this->filters[$i]->preFilter($html, $config, $context);
     }
     // purified HTML
     $html = $this->generator->generateFromTokens($this->strategy->execute($lexer->tokenizeHTML($html, $config, $context), $config, $context), $config, $context);
     for ($i = $size - 1; $i >= 0; $i--) {
         $html = $this->filters[$i]->postFilter($html, $config, $context);
     }
     $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
     $this->context =& $context;
     return $html;
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:42,代码来源:HTMLPurifier.php

示例8: setUp

 public function setUp()
 {
     $this->factory = HTMLPurifier_LanguageFactory::instance();
     parent::setUp();
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:5,代码来源:LanguageFactoryTest.php


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