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


PHP HTMLPurifier_ConfigSchema::define方法代码示例

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


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

示例1: direction

<?php

require_once 'HTMLPurifier/AttrTransform.php';
// this MUST be placed in post, as it assumes that any value in dir is valid
HTMLPurifier_ConfigSchema::define('Attr', 'DefaultTextDir', 'ltr', 'string', 'Defines the default text direction (ltr or rtl) of the document ' . 'being parsed.  This generally is the same as the value of the dir ' . 'attribute in HTML, or ltr if that is not specified.');
HTMLPurifier_ConfigSchema::defineAllowedValues('Attr', 'DefaultTextDir', array('ltr', 'rtl'));
/**
 * Post-trasnform that ensures that bdo tags have the dir attribute set.
 */
class HTMLPurifier_AttrTransform_BdoDir extends HTMLPurifier_AttrTransform
{
    function transform($attr, $config, &$context)
    {
        if (isset($attr['dir'])) {
            return $attr;
        }
        $attr['dir'] = $config->get('Attr', 'DefaultTextDir');
        return $attr;
    }
}
开发者ID:fferriere,项目名称:web,代码行数:20,代码来源:BdoDir.php

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

示例3:

    <strong>Warning:</strong> If another directive conflicts with the 
    elements here, <em>that</em> directive will win and override. For 
    example, %HTML.EnableAttrID will take precedence over *.id in this 
    directive.  You must set that directive to true before you can use 
    IDs at all. This directive has been available since 1.3.0.
</p>
');
HTMLPurifier_ConfigSchema::define('HTML', 'Allowed', null, 'itext/null', '
<p>
    This is a convenience directive that rolls the functionality of
    %HTML.AllowedElements and %HTML.AllowedAttributes into one directive.
    Specify elements and attributes that are allowed using:
    <code>element1[attr1|attr2],element2...</code>. You can also use
    newlines instead of commas to separate elements.
</p>
<p>
    <strong>Warning</strong>:
    All of the constraints on the component directives are still enforced.
    The syntax is a <em>subset</em> of TinyMCE\'s <code>valid_elements</code>
    whitelist: directly copy-pasting it here will probably result in
    broken whitelists. If %HTML.AllowedElements or %HTML.AllowedAttributes
    are set, this directive has no effect.
    This directive has been available since 2.0.0.
</p>
');
/**
 * Definition of the purified HTML that describes allowed children,
 * attributes, and many other things.
 * 
 * Conventions:
 * 
 * All member variables that are prefixed with info
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:32,代码来源:HTMLDefinition.php

示例4: array

<?php

require_once 'HTMLPurifier/URIFilter.php';
HTMLPurifier_ConfigSchema::define('URI', 'HostBlacklist', array(), 'list', 'List of strings that are forbidden in the host of any URI. Use it to ' . 'kill domain names of spam, etc. Note that it will catch anything in ' . 'the domain, so <tt>moo.com</tt> will catch <tt>moo.com.example.com</tt>. ' . 'This directive has been available since 1.3.0.');
class HTMLPurifier_URIFilter_HostBlacklist extends HTMLPurifier_URIFilter
{
    public $name = 'HostBlacklist';
    protected $blacklist = array();
    public function prepare($config)
    {
        $this->blacklist = $config->get('URI', 'HostBlacklist');
    }
    public function filter(&$uri, $config, $context)
    {
        foreach ($this->blacklist as $blacklisted_host_fragment) {
            if (strpos($uri->host, $blacklisted_host_fragment) !== false) {
                return false;
            }
        }
        return true;
    }
}
开发者ID:jbzdak,项目名称:wikidot,代码行数:22,代码来源:HostBlacklist.php

示例5: transform

<?php

require_once HTML_PURIFIER_LIB_PATH . '/HTMLPurifier/AttrTransform.php';
// must be called POST validation
HTMLPurifier_ConfigSchema::define('Attr', 'DefaultInvalidImage', '', 'string', 'This is the default image an img tag will be pointed to if it does ' . 'not have a valid src attribute.  In future versions, we may allow the ' . 'image tag to be removed completely, but due to design issues, this is ' . 'not possible right now.');
HTMLPurifier_ConfigSchema::define('Attr', 'DefaultInvalidImageAlt', 'Invalid image', 'string', 'This is the content of the alt tag of an invalid image if the user ' . 'had not previously specified an alt attribute.  It has no effect when the ' . 'image is valid but there was no alt attribute present.');
/**
 * Transform that supplies default values for the src and alt attributes
 * in img tags, as well as prevents the img tag from being removed
 * because of a missing alt tag. This needs to be registered as both
 * a pre and post attribute transform.
 */
class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform
{
    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) {
                $attr['alt'] = basename($attr['src']);
            } else {
                $attr['alt'] = $config->get('Attr', 'DefaultInvalidImageAlt');
            }
        }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:31,代码来源:ImgRequired.php

示例6: array

<?php

require_once 'HTMLPurifier/AttrDef.php';
HTMLPurifier_ConfigSchema::define('Core', 'ColorKeywords', array('maroon' => '#800000', 'red' => '#FF0000', 'orange' => '#FFA500', 'yellow' => '#FFFF00', 'olive' => '#808000', 'purple' => '#800080', 'fuchsia' => '#FF00FF', 'white' => '#FFFFFF', 'lime' => '#00FF00', 'green' => '#008000', 'navy' => '#000080', 'blue' => '#0000FF', 'aqua' => '#00FFFF', 'teal' => '#008080', 'black' => '#000000', 'silver' => '#C0C0C0', 'gray' => '#808080'), 'hash', '
Lookup array of color names to six digit hexadecimal number corresponding
to color, with preceding hash mark. Used when parsing colors.
This directive has been available since 2.0.0.
');
/**
 * Validates Color as defined by CSS.
 */
class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef
{
    function validate($color, $config, &$context)
    {
        static $colors = null;
        if ($colors === null) {
            $colors = $config->get('Core', 'ColorKeywords');
        }
        $color = trim($color);
        if ($color === '') {
            return false;
        }
        $lower = strtolower($color);
        if (isset($colors[$lower])) {
            return $colors[$lower];
        }
        if (strpos($color, 'rgb(') !== false) {
            // rgb literal handling
            $length = strlen($color);
            if (strpos($color, ')') !== $length - 1) {
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:31,代码来源:Color.php

示例7: context

<?php

// does not support network paths
require_once 'HTMLPurifier/URIFilter.php';
HTMLPurifier_ConfigSchema::define('URI', 'MakeAbsolute', false, 'bool', '
<p>
    Converts all URIs into absolute forms. This is useful when the HTML
    being filtered assumes a specific base path, but will actually be
    viewed in a different context (and setting an alternate base URI is
    not possible). %URI.Base must be set for this directive to work.
    This directive has been available since 2.1.0.
</p>
');
class HTMLPurifier_URIFilter_MakeAbsolute extends HTMLPurifier_URIFilter
{
    var $name = 'MakeAbsolute';
    var $base;
    var $basePathStack = array();
    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_ERROR);
            return;
        }
        $this->base->fragment = null;
        // fragment is invalid for base URI
        $stack = explode('/', $this->base->path);
        array_pop($stack);
        // discard last segment
开发者ID:fferriere,项目名称:web,代码行数:31,代码来源:MakeAbsolute.php

示例8: array

<?php

// HTMLPurifier_ChildDef and inheritance have three types of output:
// true = leave nodes as is
// false = delete parent node and all children
// array(...) = replace children nodes with these
HTMLPurifier_ConfigSchema::define('Core', 'EscapeInvalidChildren', false, 'bool', 'When true, a child is found that is not allowed in the context of the ' . 'parent element will be transformed into text as if it were ASCII. When ' . 'false, that element and all internal tags will be dropped, though text ' . 'will be preserved.  There is no option for dropping the element but ' . 'preserving child nodes.');
/**
 * Defines allowed child nodes and validates tokens against it.
 */
class HTMLPurifier_ChildDef
{
    /**
     * Type of child definition, usually right-most part of class name lowercase.
     * Used occasionally in terms of context.
     */
    public $type;
    /**
     * Bool that indicates whether or not an empty array of children is okay
     * 
     * This is necessary for redundant checking when changes affecting
     * a child node may cause a parent node to now be disallowed.
     */
    public $allow_empty;
    /**
     * Lookup array of all elements that this definition could possibly allow
     */
    public $elements = array();
    /**
     * Validates nodes according to definition and returns modification.
     * 
开发者ID:jbzdak,项目名称:wikidot,代码行数:31,代码来源:ChildDef.php

示例9: array

<?php

require_once HTML_PURIFIER_LIB_PATH . '/HTMLPurifier/AttrDef.php';
HTMLPurifier_ConfigSchema::define('Attr', 'AllowedRel', array(), 'lookup', 'List of allowed forward document relationships in the rel attribute. ' . 'Common values may be nofollow or print. By default, this is empty, ' . 'meaning that no document relationships are allowed. This directive ' . 'was available since 1.6.0.');
HTMLPurifier_ConfigSchema::define('Attr', 'AllowedRev', array(), 'lookup', 'List of allowed reverse document relationships in the rev attribute. ' . 'This attribute is a bit of an edge-case; if you don\'t know what it ' . 'is for, stay away. This directive was available since 1.6.0.');
/**
 * Validates a rel/rev link attribute against a directive of allowed values
 * @note We cannot use Enum because link types allow multiple
 *       values.
 * @note Assumes link types are ASCII text
 */
class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef
{
    /** Name config attribute to pull. */
    var $name;
    function HTMLPurifier_AttrDef_HTML_LinkTypes($name)
    {
        $configLookup = array('rel' => 'AllowedRel', 'rev' => 'AllowedRev');
        if (!isset($configLookup[$name])) {
            trigger_error('Unrecognized attribute name for link ' . 'relationship.', E_USER_ERROR);
            return;
        }
        $this->name = $configLookup[$name];
    }
    function validate($string, $config, &$context)
    {
        $allowed = $config->get('Attr', $this->name);
        if (empty($allowed)) {
            return false;
        }
        $string = $this->parseCDATA($string);
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:31,代码来源:LinkTypes.php

示例10: array

<?php

require_once 'HTMLPurifier/Injector.php';
HTMLPurifier_ConfigSchema::define('AutoFormat', 'Linkify', false, 'bool', '
<p>
  This directive turns on linkification, auto-linking http, ftp and
  https URLs. <code>a</code> tags with the <code>href</code> attribute
  must be allowed. This directive has been available since 2.0.1.
</p>
');
/**
 * Injector that converts http, https and ftp text URLs to actual links.
 */
class HTMLPurifier_Injector_Linkify extends HTMLPurifier_Injector
{
    var $name = 'Linkify';
    var $needed = array('a' => array('href'));
    function handleText(&$token)
    {
        if (!$this->allowsElement('a')) {
            return;
        }
        if (strpos($token->data, '://') === false) {
            // our really quick heuristic failed, abort
            // this may not work so well if we want to match things like
            // "google.com", but then again, most people don't
            return;
        }
        // there is/are URL(s). Let's split the string:
        // Note: this regex is extremely permissive
        $bits = preg_split('#((?:https?|ftp)://[^\\s\'"<>()]+)#S', $token->data, -1, PREG_SPLIT_DELIM_CAPTURE);
开发者ID:fferriere,项目名称:web,代码行数:31,代码来源:Linkify.php

示例11: array

<?php

require_once 'HTMLPurifier/Strategy.php';
require_once 'HTMLPurifier/HTMLDefinition.php';
require_once 'HTMLPurifier/Generator.php';
require_once 'HTMLPurifier/Injector/AutoParagraph.php';
require_once 'HTMLPurifier/Injector/Linkify.php';
require_once 'HTMLPurifier/Injector/PurifierLinkify.php';
HTMLPurifier_ConfigSchema::define('AutoFormat', 'Custom', array(), 'list', '
<p>
  This directive can be used to add custom auto-format injectors.
  Specify an array of injector names (class name minus the prefix)
  or concrete implementations. Injector class must exist. This directive
  has been available since 2.0.1.
</p>
');
/**
 * Takes tokens makes them well-formed (balance end tags, etc.)
 */
class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
{
    /**
     * Locally shared variable references
     */
    protected $inputTokens, $inputIndex, $outputTokens, $currentNesting, $currentInjector, $injectors;
    public function execute($tokens, $config, $context)
    {
        $definition = $config->getHTMLDefinition();
        // local variables
        $result = array();
        $generator = new HTMLPurifier_Generator();
开发者ID:jbzdak,项目名称:wikidot,代码行数:31,代码来源:MakeWellFormed.php

示例12: array

<?php

HTMLPurifier_ConfigSchema::define('Attr', 'AllowedFrameTargets', array(), 'lookup', 'Lookup table of all allowed link frame targets.  Some commonly used ' . 'link targets include _blank, _self, _parent and _top. Values should ' . 'be lowercase, as validation will be done in a case-sensitive manner ' . 'despite W3C\'s recommendation. XHTML 1.0 Strict does not permit ' . 'the target attribute so this directive will have no effect in that ' . 'doctype. XHTML 1.1 does not enable the Target module by default, you ' . 'will have to manually enable it (see the module documentation for more details.)');
require_once 'HTMLPurifier/AttrDef/Enum.php';
/**
 * Special-case enum attribute definition that lazy loads allowed frame targets
 */
class HTMLPurifier_AttrDef_HTML_FrameTarget extends HTMLPurifier_AttrDef_Enum
{
    var $valid_values = false;
    // uninitialized value
    var $case_sensitive = false;
    function HTMLPurifier_AttrDef_HTML_FrameTarget()
    {
    }
    function validate($string, $config, &$context)
    {
        if ($this->valid_values === false) {
            $this->valid_values = $config->get('Attr', 'AllowedFrameTargets');
        }
        return parent::validate($string, $config, $context);
    }
}
开发者ID:fferriere,项目名称:web,代码行数:23,代码来源:FrameTarget.php

示例13: buggy

<?php

require_once 'HTMLPurifier/Lexer.php';
HTMLPurifier_ConfigSchema::define('Core', 'DirectLexLineNumberSyncInterval', 0, 'int', '
<p>
  Specifies the number of tokens the DirectLex line number tracking
  implementations should process before attempting to resyncronize the
  current line count by manually counting all previous new-lines. When
  at 0, this functionality is disabled. Lower values will decrease
  performance, and this is only strictly necessary if the counting
  algorithm is buggy (in which case you should report it as a bug).
  This has no effect when %Core.MaintainLineNumbers is disabled or DirectLex is
  not being used. This directive has been available since 2.0.0.
</p>
');
/**
 * Our in-house implementation of a parser.
 * 
 * A pure PHP parser, DirectLex has absolutely no dependencies, making
 * it a reasonably good default for PHP4.  Written with efficiency in mind,
 * it can be four times faster than HTMLPurifier_Lexer_PEARSax3, although it
 * pales in comparison to HTMLPurifier_Lexer_DOMLex.
 * 
 * @todo Reread XML spec and document differences.
 */
class HTMLPurifier_Lexer_DirectLex extends HTMLPurifier_Lexer
{
    /**
     * Whitespace characters for str(c)spn.
     * @protected
     */
开发者ID:fferriere,项目名称:web,代码行数:31,代码来源:DirectLex.php

示例14: meaning

require_once 'HTMLPurifier/Injector.php';
HTMLPurifier_ConfigSchema::define('AutoFormat', 'AutoParagraph', false, 'bool', '
<p>
  This directive turns on auto-paragraphing, where double newlines are
  converted in to paragraphs whenever possible. Auto-paragraphing:
</p>
<ul>
  <li>Always applies to inline elements or text in the root node,</li>
  <li>Applies to inline elements or text with double newlines in nodes
      that allow paragraph tags,</li>
  <li>Applies to double newlines in paragraph tags</li>
</ul>
<p>
  <code>p</code> tags must be allowed for this directive to take effect.
  We do not use <code>br</code> tags for paragraphing, as that is
  semantically incorrect.
</p>
<p>
  To prevent auto-paragraphing as a content-producer, refrain from using
  double-newlines except to specify a new paragraph or in contexts where
  it has special meaning (whitespace usually has no meaning except in
  tags like <code>pre</code>, so this should not be difficult.) To prevent
  the paragraphing of inline text adjacent to block elements, wrap them
  in <code>div</code> tags (the behavior is slightly different outside of
  the root node.)
</p>
<p>
  This directive has been available since 2.0.1.
</p>
');
/**
开发者ID:fferriere,项目名称:web,代码行数:31,代码来源:AutoParagraph.php

示例15: array

<?php

HTMLPurifier_ConfigSchema::define('Attr', 'IDBlacklist', array(), 'list', 'Array of IDs not allowed in the document.');
/**
 * Component of HTMLPurifier_AttrContext that accumulates IDs to prevent dupes
 * @note In Slashdot-speak, dupe means duplicate.
 * @note The default constructor does not accept $config or $context objects:
 *       use must use the static build() factory method to perform initialization.
 */
class HTMLPurifier_IDAccumulator
{
    /**
     * Lookup table of IDs we've accumulated.
     * @public
     */
    public $ids = array();
    /**
     * Builds an IDAccumulator, also initializing the default blacklist
     * @param $config Instance of HTMLPurifier_Config
     * @param $context Instance of HTMLPurifier_Context
     * @return Fully initialized HTMLPurifier_IDAccumulator
     */
    public static function build($config, $context)
    {
        $id_accumulator = new HTMLPurifier_IDAccumulator();
        $id_accumulator->load($config->get('Attr', 'IDBlacklist'));
        return $id_accumulator;
    }
    /**
     * Add an ID to the lookup table.
     * @param $id ID to be added.
开发者ID:jbzdak,项目名称:wikidot,代码行数:31,代码来源:IDAccumulator.php


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