2006-08-29 02:01:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/AttrDef.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validates shorthand CSS property list-style.
|
|
|
|
* @note This currently does not support list-style-image, as that functionality
|
|
|
|
* is not implemented yet elsewhere.
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_AttrDef_ListStyle extends HTMLPurifier_AttrDef
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Local copy of component validators.
|
|
|
|
* @note See HTMLPurifier_AttrDef_Font::$info for a similar impl.
|
|
|
|
*/
|
|
|
|
var $info;
|
|
|
|
|
2006-08-31 20:33:07 +00:00
|
|
|
function HTMLPurifier_AttrDef_ListStyle($config) {
|
|
|
|
$def = $config->getCSSDefinition();
|
2006-08-29 02:01:58 +00:00
|
|
|
$this->info['list-style-type'] = $def->info['list-style-type'];
|
|
|
|
$this->info['list-style-position'] = $def->info['list-style-position'];
|
2007-01-14 16:24:02 +00:00
|
|
|
$this->info['list-style-image'] = $def->info['list-style-image'];
|
2006-08-29 02:01:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function validate($string, $config, &$context) {
|
|
|
|
|
|
|
|
// regular pre-processing
|
|
|
|
$string = $this->parseCDATA($string);
|
|
|
|
if ($string === '') return false;
|
|
|
|
|
|
|
|
$bits = explode(' ', strtolower($string)); // bits to process
|
|
|
|
|
|
|
|
$caught_type = false;
|
|
|
|
$caught_position = false;
|
2007-01-14 16:24:02 +00:00
|
|
|
$caught_image = false;
|
2006-08-29 02:01:58 +00:00
|
|
|
$caught_none = false; // as in keyword none, which is in all of them
|
|
|
|
|
|
|
|
$ret = '';
|
|
|
|
|
|
|
|
foreach ($bits as $bit) {
|
2007-01-14 16:24:02 +00:00
|
|
|
if ($caught_none && ($caught_type || $caught_position || $caught_image)) break;
|
|
|
|
if ($caught_type && $caught_position && $caught_image) break;
|
2006-08-29 02:01:58 +00:00
|
|
|
|
|
|
|
if ($bit === '') continue;
|
|
|
|
|
|
|
|
if ($bit === 'none') {
|
|
|
|
if ($caught_none) continue;
|
|
|
|
$caught_none = true;
|
|
|
|
$ret .= 'none ';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we add anymore, roll it into a loop
|
|
|
|
|
|
|
|
$r = $this->info['list-style-type']->validate($bit, $config, $context);
|
|
|
|
if ($r !== false) {
|
|
|
|
if ($caught_type) continue;
|
|
|
|
$caught_type = true;
|
|
|
|
$ret .= $r . ' ';
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = $this->info['list-style-position']->validate($bit, $config, $context);
|
|
|
|
if ($r !== false) {
|
|
|
|
if ($caught_position) continue;
|
|
|
|
$caught_position = true;
|
|
|
|
$ret .= $r . ' ';
|
|
|
|
continue;
|
|
|
|
}
|
2007-01-14 16:24:02 +00:00
|
|
|
|
|
|
|
$r = $this->info['list-style-image']->validate($bit, $config, $context);
|
|
|
|
if ($r !== false) {
|
|
|
|
if ($caught_image) continue;
|
|
|
|
$caught_image = true;
|
|
|
|
$ret .= $r . ' ';
|
|
|
|
continue;
|
|
|
|
}
|
2006-08-29 02:01:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$ret = rtrim($ret);
|
|
|
|
return $ret ? $ret : false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|