mirror of
https://github.com/moodle/moodle.git
synced 2025-07-27 01:10:51 +02:00
Prior to this change, all the line endings in the imported HTMLPurifier library were using CRLF (\r\n aka Windows style), but the HTMLPurifier source and also the downloadable artefacts use LF (\n aka Linux style) as line endings. This has been the case since510d190382
when with the commit "MDL-38672 import HTML Purifier 4.5.0" all line endings were changed from LF to CRLF. There was no comment in the commit on why this change was done. As the original source uses LF, this commit partly reverts510d190382
and goes back to LF as line endings. Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Definition that uses different definitions depending on context.
|
|
*
|
|
* The del and ins tags are notable because they allow different types of
|
|
* elements depending on whether or not they're in a block or inline context.
|
|
* Chameleon allows this behavior to happen by using two different
|
|
* definitions depending on context. While this somewhat generalized,
|
|
* it is specifically intended for those two tags.
|
|
*/
|
|
class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef
|
|
{
|
|
|
|
/**
|
|
* Instance of the definition object to use when inline. Usually stricter.
|
|
* @type HTMLPurifier_ChildDef_Optional
|
|
*/
|
|
public $inline;
|
|
|
|
/**
|
|
* Instance of the definition object to use when block.
|
|
* @type HTMLPurifier_ChildDef_Optional
|
|
*/
|
|
public $block;
|
|
|
|
/**
|
|
* @type string
|
|
*/
|
|
public $type = 'chameleon';
|
|
|
|
/**
|
|
* @param array $inline List of elements to allow when inline.
|
|
* @param array $block List of elements to allow when block.
|
|
*/
|
|
public function __construct($inline, $block)
|
|
{
|
|
$this->inline = new HTMLPurifier_ChildDef_Optional($inline);
|
|
$this->block = new HTMLPurifier_ChildDef_Optional($block);
|
|
$this->elements = $this->block->elements;
|
|
}
|
|
|
|
/**
|
|
* @param HTMLPurifier_Node[] $children
|
|
* @param HTMLPurifier_Config $config
|
|
* @param HTMLPurifier_Context $context
|
|
* @return bool
|
|
*/
|
|
public function validateChildren($children, $config, $context)
|
|
{
|
|
if ($context->get('IsInline') === false) {
|
|
return $this->block->validateChildren(
|
|
$children,
|
|
$config,
|
|
$context
|
|
);
|
|
} else {
|
|
return $this->inline->validateChildren(
|
|
$children,
|
|
$config,
|
|
$context
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
// vim: et sw=4 sts=4
|