當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HTMLPurifier_Config::getDefinition方法代碼示例

本文整理匯總了PHP中HTMLPurifier_Config::getDefinition方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTMLPurifier_Config::getDefinition方法的具體用法?PHP HTMLPurifier_Config::getDefinition怎麽用?PHP HTMLPurifier_Config::getDefinition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HTMLPurifier_Config的用法示例。


在下文中一共展示了HTMLPurifier_Config::getDefinition方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: split

 /**
  * @param string $string
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return bool|string
  */
 protected function split($string, $config, $context)
 {
     // really, this twiddle should be lazy loaded
     $name = $config->getDefinition('HTML')->doctype->name;
     if ($name == "XHTML 1.1" || $name == "XHTML 2.0") {
         return parent::split($string, $config, $context);
     } else {
         return preg_split('/\\s+/', $string);
     }
 }
開發者ID:mayliupeng,項目名稱:ciFramework,代碼行數:16,代碼來源:Class.php

示例3: prepare

 /**
  * @param HTMLPurifier_Config $config
  * @return bool
  */
 public function prepare($config)
 {
     $def = $config->getDefinition('URI');
     $this->base = $def->base;
     if (is_null($this->base)) {
         trigger_error('URI.MakeAbsolute is being ignored due to lack of ' . 'value for URI.Base configuration', E_USER_WARNING);
         return false;
     }
     $this->base->fragment = null;
     // fragment is invalid for base URI
     $stack = explode('/', $this->base->path);
     array_pop($stack);
     // discard last segment
     $stack = $this->_collapseStack($stack);
     // do pre-parsing
     $this->basePathStack = $stack;
     return true;
 }
開發者ID:beyondye,項目名稱:ENPHP,代碼行數:22,代碼來源:MakeAbsolute.php

示例4: cleanCSS

 /**
  * Takes CSS (the stuff found in <style>) and cleans it.
  * @warning Requires CSSTidy <http://csstidy.sourceforge.net/>
  * @param string $css CSS styling to clean
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @throws HTMLPurifier_Exception
  * @return string Cleaned CSS
  */
 public function cleanCSS($css, $config, $context)
 {
     // prepare scope
     $scope = $config->get('Filter.ExtractStyleBlocks.Scope');
     if ($scope !== null) {
         $scopes = array_map('trim', explode(',', $scope));
     } else {
         $scopes = array();
     }
     // remove comments from CSS
     $css = trim($css);
     if (strncmp('<!--', $css, 4) === 0) {
         $css = substr($css, 4);
     }
     if (strlen($css) > 3 && substr($css, -3) == '-->') {
         $css = substr($css, 0, -3);
     }
     $css = trim($css);
     set_error_handler('htmlpurifier_filter_extractstyleblocks_muteerrorhandler');
     $this->_tidy->parse($css);
     restore_error_handler();
     $css_definition = $config->getDefinition('CSS');
     $html_definition = $config->getDefinition('HTML');
     $new_css = array();
     foreach ($this->_tidy->css as $k => $decls) {
         // $decls are all CSS declarations inside an @ selector
         $new_decls = array();
         foreach ($decls as $selector => $style) {
             $selector = trim($selector);
             if ($selector === '') {
                 continue;
             }
             // should not happen
             // Parse the selector
             // Here is the relevant part of the CSS grammar:
             //
             // ruleset
             //   : selector [ ',' S* selector ]* '{' ...
             // selector
             //   : simple_selector [ combinator selector | S+ [ combinator? selector ]? ]?
             // combinator
             //   : '+' S*
             //   : '>' S*
             // simple_selector
             //   : element_name [ HASH | class | attrib | pseudo ]*
             //   | [ HASH | class | attrib | pseudo ]+
             // element_name
             //   : IDENT | '*'
             //   ;
             // class
             //   : '.' IDENT
             //   ;
             // attrib
             //   : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH ] S*
             //     [ IDENT | STRING ] S* ]? ']'
             //   ;
             // pseudo
             //   : ':' [ IDENT | FUNCTION S* [IDENT S*]? ')' ]
             //   ;
             //
             // For reference, here are the relevant tokens:
             //
             // HASH         #{name}
             // IDENT        {ident}
             // INCLUDES     ==
             // DASHMATCH    |=
             // STRING       {string}
             // FUNCTION     {ident}\(
             //
             // And the lexical scanner tokens
             //
             // name         {nmchar}+
             // nmchar       [_a-z0-9-]|{nonascii}|{escape}
             // nonascii     [\240-\377]
             // escape       {unicode}|\\[^\r\n\f0-9a-f]
             // unicode      \\{h}}{1,6}(\r\n|[ \t\r\n\f])?
             // ident        -?{nmstart}{nmchar*}
             // nmstart      [_a-z]|{nonascii}|{escape}
             // string       {string1}|{string2}
             // string1      \"([^\n\r\f\\"]|\\{nl}|{escape})*\"
             // string2      \'([^\n\r\f\\"]|\\{nl}|{escape})*\'
             //
             // We'll implement a subset (in order to reduce attack
             // surface); in particular:
             //
             //      - No Unicode support
             //      - No escapes support
             //      - No string support (by proxy no attrib support)
             //      - element_name is matched against allowed
             //        elements (some people might find this
             //        annoying...)
//.........這裏部分代碼省略.........
開發者ID:beyondye,項目名稱:ENPHP,代碼行數:101,代碼來源:ExtractStyleBlocks.php

示例5: wrapHTML

 /**
  * Wraps an HTML fragment in the necessary HTML
  * @param string $html
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return string
  */
 protected function wrapHTML($html, $config, $context)
 {
     $def = $config->getDefinition('HTML');
     $ret = '';
     if (!empty($def->doctype->dtdPublic) || !empty($def->doctype->dtdSystem)) {
         $ret .= '<!DOCTYPE html ';
         if (!empty($def->doctype->dtdPublic)) {
             $ret .= 'PUBLIC "' . $def->doctype->dtdPublic . '" ';
         }
         if (!empty($def->doctype->dtdSystem)) {
             $ret .= '"' . $def->doctype->dtdSystem . '" ';
         }
         $ret .= '>';
     }
     $ret .= '<html><head>';
     $ret .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
     // No protection if $html contains a stray </div>!
     $ret .= '</head><body>' . $html . '</body></html>';
     return $ret;
 }
開發者ID:beyondye,項目名稱:ENPHP,代碼行數:27,代碼來源:DOMLex.php

示例6: test_getDefinition

 public function test_getDefinition()
 {
     $this->schema->add('Cache.DefinitionImpl', null, 'string', true);
     $config = new HTMLPurifier_Config($this->schema);
     $this->expectException(new HTMLPurifier_Exception("Definition of Crust type not supported"));
     $config->getDefinition('Crust');
 }
開發者ID:Jaaviieer,項目名稱:PrograWeb,代碼行數:7,代碼來源:ConfigTest.php

示例7: isLocal

 /**
  * Returns true if this URL might be considered a 'local' URL given
  * the current context.  This is true when the host is null, or
  * when it matches the host supplied to the configuration.
  *
  * Note that this does not do any scheme checking, so it is mostly
  * only appropriate for metadata that doesn't care about protocol
  * security.  isBenign is probably what you actually want.
  * @param HTMLPurifier_Config $config
  * @param HTMLPurifier_Context $context
  * @return bool
  */
 public function isLocal($config, $context)
 {
     if ($this->host === null) {
         return true;
     }
     $uri_def = $config->getDefinition('URI');
     if ($uri_def->host === $this->host) {
         return true;
     }
     return false;
 }
開發者ID:aslijiasheng,項目名稱:ciFramework,代碼行數:23,代碼來源:URI.php

示例8:

 function test_getDefinition()
 {
     $this->schema->addNamespace('Cache', 'Cache stuff');
     $this->schema->add('Cache', 'DefinitionImpl', null, 'string', true);
     $this->schema->addNamespace('Crust', 'Krusty Krabs');
     $config = new HTMLPurifier_Config($this->schema);
     $this->expectException(new HTMLPurifier_Exception("Definition of Crust type not supported"));
     $config->getDefinition('Crust');
 }
開發者ID:patdunlavey,項目名稱:Williamstown-Beat,代碼行數:9,代碼來源:ConfigTest.php


注:本文中的HTMLPurifier_Config::getDefinition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。