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


PHP HTMLPurifier_Config类代码示例

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


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

示例1: transform

 /**
  * @param array $attr
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return array
  */
 public function transform($attr, $config, $context)
 {
     $src = true;
     if (!isset($attr['src'])) {
         if ($config->get('Core.RemoveInvalidImg')) {
             return $attr;
         }
         $attr['src'] = $config->get('Attr.DefaultInvalidImage');
         $src = false;
     }
     if (!isset($attr['alt'])) {
         if ($src) {
             $alt = $config->get('Attr.DefaultImageAlt');
             if ($alt === null) {
                 // truncate if the alt is too long
                 $attr['alt'] = substr(basename($attr['src']), 0, 40);
             } else {
                 $attr['alt'] = $alt;
             }
         } else {
             $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt');
         }
     }
     return $attr;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:31,代码来源:ImgRequired.php

示例2: create

 /**
  * Factory method that creates a cache object based on configuration
  * @param string $type Name of definitions handled by cache
  * @param HTMLPurifier_Config $config Config instance
  * @return mixed
  */
 public function create($type, $config)
 {
     $method = $config->get('Cache.DefinitionImpl');
     if ($method === null) {
         return new HTMLPurifier_DefinitionCache_Null($type);
     }
     if (!empty($this->caches[$method][$type])) {
         return $this->caches[$method][$type];
     }
     if (isset($this->implementations[$method]) && class_exists($class = $this->implementations[$method], false)) {
         $cache = new $class($type);
     } else {
         if ($method != 'Serializer') {
             trigger_error("Unrecognized DefinitionCache {$method}, using Serializer instead", E_USER_WARNING);
         }
         $cache = new HTMLPurifier_DefinitionCache_Serializer($type);
     }
     foreach ($this->decorators as $decorator) {
         $new_cache = $decorator->decorate($cache);
         // prevent infinite recursion in PHP 4
         unset($cache);
         $cache = $new_cache;
     }
     $this->caches[$method][$type] = $cache;
     return $this->caches[$method][$type];
 }
开发者ID:youprofit,项目名称:casebox,代码行数:32,代码来源:DefinitionCacheFactory.php

示例3: validate

 /**
  * @param string $string
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return bool|string
  */
 public function validate($string, $config, $context)
 {
     if ($this->valid_values === false) {
         $this->valid_values = $config->get('Attr.AllowedFrameTargets');
     }
     return parent::validate($string, $config, $context);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:13,代码来源:FrameTarget.php

示例4: prepare

 /**
  * @param HTMLPurifier_Config $config
  * @return void
  */
 public function prepare($config)
 {
     $our_host = $config->getDefinition('URI')->host;
     if ($our_host !== null) {
         $this->ourHostParts = array_reverse(explode('.', $our_host));
     }
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:11,代码来源:DisableExternal.php

示例5: filter

 /**
  * @param HTMLPurifier_URI $uri
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return bool
  */
 public function filter(&$uri, $config, $context)
 {
     // check if filter not applicable
     if (!$config->get('HTML.SafeIframe')) {
         return true;
     }
     // check if the filter should actually trigger
     if (!$context->get('EmbeddedURI', true)) {
         return true;
     }
     $token = $context->get('CurrentToken', true);
     if (!($token && $token->name == 'iframe')) {
         return true;
     }
     // check if we actually have some whitelists enabled
     if ($this->regexp === null) {
         return false;
     }
     // actually check the whitelists
     if (!preg_match($this->regexp, $uri->toString())) {
         return false;
     }
     // Make sure that if we're an HTTPS site, the iframe is also HTTPS
     if (is_https() && $uri->scheme == 'http') {
         // Convert it to a protocol-relative URL
         $uri->scheme = null;
     }
     return $uri;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:35,代码来源:SafeIframe.php

示例6: __construct

 /**
  * @param HTMLPurifier_Config $config
  */
 public function __construct($config)
 {
     $def = $config->getCSSDefinition();
     $this->info['border-width'] = $def->info['border-width'];
     $this->info['border-style'] = $def->info['border-style'];
     $this->info['border-top-color'] = $def->info['border-top-color'];
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:10,代码来源:Border.php

示例7: setup

 /**
  * @param HTMLPurifier_Config $config
  */
 public function setup($config)
 {
     if ($config->get('HTML.SafeIframe')) {
         $this->safe = true;
     }
     $this->addElement('iframe', 'Inline', 'Flow', 'Common', array('src' => 'URI#embedded', 'width' => 'Length', 'height' => 'Length', 'name' => 'ID', 'scrolling' => 'Enum#yes,no,auto', 'frameborder' => 'Enum#0,1', 'longdesc' => 'URI', 'marginheight' => 'Pixels', 'marginwidth' => 'Pixels'));
 }
开发者ID:beyondye,项目名称:ENPHP,代码行数:10,代码来源:Iframe.php

示例8: validate

 /**
  * @param string $string
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return bool|string
  */
 public function validate($string, $config, $context)
 {
     static $colors = null;
     if ($colors === null) {
         $colors = $config->get('Core.ColorKeywords');
     }
     $string = trim($string);
     if (empty($string)) {
         return false;
     }
     $lower = strtolower($string);
     if (isset($colors[$lower])) {
         return $colors[$lower];
     }
     if ($string[0] === '#') {
         $hex = substr($string, 1);
     } else {
         $hex = $string;
     }
     $length = strlen($hex);
     if ($length !== 3 && $length !== 6) {
         return false;
     }
     if (!ctype_xdigit($hex)) {
         return false;
     }
     if ($length === 3) {
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
     }
     return "#{$hex}";
 }
开发者ID:beyondye,项目名称:ENPHP,代码行数:37,代码来源:Color.php

示例9: validate

 /**
  * Public interface for validating components of a URI.  Performs a
  * bunch of default actions. Don't overload this method.
  * @param HTMLPurifier_URI $uri Reference to a HTMLPurifier_URI object
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return bool success or failure
  */
 public function validate(&$uri, $config, $context)
 {
     if ($this->default_port == $uri->port) {
         $uri->port = null;
     }
     // kludge: browsers do funny things when the scheme but not the
     // authority is set
     if (!$this->may_omit_host && (!is_null($uri->scheme) && ($uri->host === '' || is_null($uri->host))) || is_null($uri->scheme) && $uri->host === '') {
         do {
             if (is_null($uri->scheme)) {
                 if (substr($uri->path, 0, 2) != '//') {
                     $uri->host = null;
                     break;
                 }
                 // URI is '////path', so we cannot nullify the
                 // host to preserve semantics.  Try expanding the
                 // hostname instead (fall through)
             }
             // first see if we can manually insert a hostname
             $host = $config->get('URI.Host');
             if (!is_null($host)) {
                 $uri->host = $host;
             } else {
                 // we can't do anything sensible, reject the URL.
                 return false;
             }
         } while (false);
     }
     return $this->doValidate($uri, $config, $context);
 }
开发者ID:aslijiasheng,项目名称:ciFramework,代码行数:38,代码来源:URIScheme.php

示例10: transform

 /**
  * @param array $attr
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return array
  */
 public function transform($attr, $config, $context)
 {
     if (isset($attr['dir'])) {
         return $attr;
     }
     $attr['dir'] = $config->get('Attr.DefaultTextDir');
     return $attr;
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:14,代码来源:BdoDir.php

示例11: setup

 /**
  * @param HTMLPurifier_Config $config
  */
 public function setup($config)
 {
     // These definitions are not intrinsically safe: the attribute transforms
     // are a vital part of ensuring safety.
     $allowed = $config->get('HTML.SafeScripting');
     $script = $this->addElement('script', 'Inline', 'Empty', null, array('type' => 'Enum#application/javascript', 'src*' => new HTMLPurifier_AttrDef_Enum(array_keys($allowed))));
     $script->attr_transform_pre[] = $script->attr_transform_post[] = new HTMLPurifier_AttrTransform_ScriptRequired();
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:11,代码来源:SafeScripting.php

示例12: __construct

 /**
  * @param HTMLPurifier_Config $config
  */
 public function __construct($config)
 {
     $def = $config->getCSSDefinition();
     $this->info['background-color'] = $def->info['background-color'];
     $this->info['background-image'] = $def->info['background-image'];
     $this->info['background-repeat'] = $def->info['background-repeat'];
     $this->info['background-attachment'] = $def->info['background-attachment'];
     $this->info['background-position'] = $def->info['background-position'];
 }
开发者ID:Jaaviieer,项目名称:PrograWeb,代码行数:12,代码来源:Background.php

示例13: __construct

 /**
  * @param HTMLPurifier_Config $config
  */
 public function __construct($config)
 {
     $def = $config->getCSSDefinition();
     $this->info['font-style'] = $def->info['font-style'];
     $this->info['font-variant'] = $def->info['font-variant'];
     $this->info['font-weight'] = $def->info['font-weight'];
     $this->info['font-size'] = $def->info['font-size'];
     $this->info['line-height'] = $def->info['line-height'];
     $this->info['font-family'] = $def->info['font-family'];
 }
开发者ID:beyondye,项目名称:ENPHP,代码行数:13,代码来源:Font.php

示例14: setup

 /**
  * @param HTMLPurifier_Config $config
  */
 public function setup($config)
 {
     $max = $config->get('HTML.MaxImgLength');
     $img = $this->addElement('img', 'Inline', 'Empty', 'Common', array('alt*' => 'Text', 'height' => 'Pixels#' . $max, 'width' => 'Pixels#' . $max, 'longdesc' => 'URI', 'src*' => new HTMLPurifier_AttrDef_URI(true)));
     if ($max === null || $config->get('HTML.Trusted')) {
         $img->attr['height'] = $img->attr['width'] = 'Length';
     }
     // kind of strange, but splitting things up would be inefficient
     $img->attr_transform_pre[] = $img->attr_transform_post[] = new HTMLPurifier_AttrTransform_ImgRequired();
 }
开发者ID:mayliupeng,项目名称:ciFramework,代码行数:13,代码来源:Image.php

示例15: setup

 /**
  * @param HTMLPurifier_Config $config
  */
 public function setup($config)
 {
     // These definitions are not intrinsically safe: the attribute transforms
     // are a vital part of ensuring safety.
     $max = $config->get('HTML.MaxImgLength');
     $object = $this->addElement('object', 'Inline', 'Optional: param | Flow | #PCDATA', 'Common', array('type' => 'Enum#application/x-shockwave-flash', 'width' => 'Pixels#' . $max, 'height' => 'Pixels#' . $max, 'data' => 'URI#embedded', 'codebase' => new HTMLPurifier_AttrDef_Enum(array('http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'))));
     $object->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeObject();
     $param = $this->addElement('param', false, 'Empty', false, array('id' => 'ID', 'name*' => 'Text', 'value' => 'Text'));
     $param->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeParam();
     $this->info_injector[] = 'SafeObject';
 }
开发者ID:youprofit,项目名称:casebox,代码行数:14,代码来源:SafeObject.php


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