2006-08-12 20:22:09 +00:00
|
|
|
<?php
|
|
|
|
|
2006-08-14 00:27:15 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/Enum.php';
|
|
|
|
require_once 'HTMLPurifier/AttrDef/Color.php';
|
|
|
|
require_once 'HTMLPurifier/AttrDef/Composite.php';
|
|
|
|
require_once 'HTMLPurifier/AttrDef/CSSLength.php';
|
2006-08-14 02:47:49 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/Percentage.php';
|
2006-08-16 01:39:06 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/Multiple.php';
|
2006-08-16 15:12:48 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/TextDecoration.php';
|
2006-08-16 17:25:25 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/FontFamily.php';
|
2006-08-27 00:11:13 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/Font.php';
|
2006-08-27 00:49:34 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/Border.php';
|
2006-08-29 02:01:58 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/ListStyle.php';
|
2007-01-14 16:24:02 +00:00
|
|
|
require_once 'HTMLPurifier/AttrDef/CSSURI.php';
|
2006-08-14 00:27:15 +00:00
|
|
|
|
2006-08-19 23:06:59 +00:00
|
|
|
/**
|
|
|
|
* Defines allowed CSS attributes and what their values are.
|
|
|
|
* @see HTMLPurifier_HTMLDefinition
|
|
|
|
*/
|
2006-08-12 20:22:09 +00:00
|
|
|
class HTMLPurifier_CSSDefinition
|
|
|
|
{
|
|
|
|
|
2006-08-19 23:06:59 +00:00
|
|
|
/**
|
|
|
|
* Assoc array of attribute name to definition object.
|
|
|
|
*/
|
2006-08-12 20:22:09 +00:00
|
|
|
var $info = array();
|
|
|
|
|
2006-08-19 23:06:59 +00:00
|
|
|
/**
|
|
|
|
* Constructs the info array. The meat of this class.
|
|
|
|
*/
|
2006-08-31 20:33:07 +00:00
|
|
|
function setup($config) {
|
2006-08-12 20:22:09 +00:00
|
|
|
|
|
|
|
$this->info['text-align'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('left', 'right', 'center', 'justify'), false);
|
2006-08-16 01:39:06 +00:00
|
|
|
|
|
|
|
$border_style =
|
2006-08-13 19:08:14 +00:00
|
|
|
$this->info['border-bottom-style'] =
|
|
|
|
$this->info['border-right-style'] =
|
|
|
|
$this->info['border-left-style'] =
|
|
|
|
$this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum(
|
2006-08-13 16:52:31 +00:00
|
|
|
array('none', 'hidden', 'dotted', 'dashed', 'solid', 'double',
|
|
|
|
'groove', 'ridge', 'inset', 'outset'), false);
|
2006-08-16 01:39:06 +00:00
|
|
|
|
|
|
|
$this->info['border-style'] = new HTMLPurifier_AttrDef_Multiple($border_style);
|
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
$this->info['clear'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('none', 'left', 'right', 'both'), false);
|
|
|
|
$this->info['float'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('none', 'left', 'right'), false);
|
|
|
|
$this->info['font-style'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('normal', 'italic', 'oblique'), false);
|
|
|
|
$this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('normal', 'small-caps'), false);
|
2006-08-29 02:01:58 +00:00
|
|
|
|
2007-01-15 01:14:24 +00:00
|
|
|
$uri_or_none = new HTMLPurifier_AttrDef_Composite(
|
|
|
|
array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('none')),
|
|
|
|
new HTMLPurifier_AttrDef_CSSURI()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
$this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('inside', 'outside'), false);
|
|
|
|
$this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('disc', 'circle', 'square', 'decimal', 'lower-roman',
|
2007-01-15 01:14:24 +00:00
|
|
|
'upper-roman', 'lower-alpha', 'upper-alpha', 'none'), false);
|
|
|
|
$this->info['list-style-image'] = $uri_or_none;
|
2006-08-29 02:01:58 +00:00
|
|
|
|
2006-08-31 20:33:07 +00:00
|
|
|
$this->info['list-style'] = new HTMLPurifier_AttrDef_ListStyle($config);
|
2006-08-29 02:01:58 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
$this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('capitalize', 'uppercase', 'lowercase', 'none'), false);
|
2006-08-13 21:23:57 +00:00
|
|
|
$this->info['color'] = new HTMLPurifier_AttrDef_Color();
|
|
|
|
|
2007-01-15 01:14:24 +00:00
|
|
|
$this->info['background-image'] = $uri_or_none;
|
|
|
|
$this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('repeat', 'repeat-x', 'repeat-y', 'no-repeat')
|
|
|
|
);
|
|
|
|
$this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('scroll', 'fixed')
|
|
|
|
);
|
|
|
|
|
|
|
|
// pending its own validator as a shorthand
|
2006-08-28 20:10:01 +00:00
|
|
|
$this->info['background'] =
|
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$border_color =
|
2006-08-13 21:23:57 +00:00
|
|
|
$this->info['border-top-color'] =
|
|
|
|
$this->info['border-bottom-color'] =
|
|
|
|
$this->info['border-left-color'] =
|
|
|
|
$this->info['border-right-color'] =
|
2006-08-13 23:08:38 +00:00
|
|
|
$this->info['background-color'] = new HTMLPurifier_AttrDef_Composite(array(
|
2006-08-13 21:23:57 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('transparent')),
|
|
|
|
new HTMLPurifier_AttrDef_Color()
|
|
|
|
));
|
2006-08-13 16:52:31 +00:00
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->info['border-color'] = new HTMLPurifier_AttrDef_Multiple($border_color);
|
|
|
|
|
|
|
|
$border_width =
|
2006-08-13 23:08:38 +00:00
|
|
|
$this->info['border-top-width'] =
|
|
|
|
$this->info['border-bottom-width'] =
|
|
|
|
$this->info['border-left-width'] =
|
|
|
|
$this->info['border-right-width'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')),
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength(true) //disallow negative
|
|
|
|
));
|
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->info['border-width'] = new HTMLPurifier_AttrDef_Multiple($border_width);
|
|
|
|
|
2006-08-13 23:08:38 +00:00
|
|
|
$this->info['letter-spacing'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('normal')),
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength()
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->info['word-spacing'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('normal')),
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength()
|
|
|
|
));
|
|
|
|
|
2006-08-14 02:08:45 +00:00
|
|
|
$this->info['font-size'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('xx-small', 'x-small',
|
|
|
|
'small', 'medium', 'large', 'x-large', 'xx-large',
|
|
|
|
'larger', 'smaller')),
|
|
|
|
new HTMLPurifier_AttrDef_Percentage(),
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength()
|
|
|
|
));
|
|
|
|
|
2006-08-16 00:18:58 +00:00
|
|
|
$this->info['line-height'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('normal')),
|
|
|
|
new HTMLPurifier_AttrDef_Number(true), // no negatives
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength(true),
|
|
|
|
new HTMLPurifier_AttrDef_Percentage(true)
|
|
|
|
));
|
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$margin =
|
2006-08-16 00:18:58 +00:00
|
|
|
$this->info['margin-top'] =
|
|
|
|
$this->info['margin-bottom'] =
|
|
|
|
$this->info['margin-left'] =
|
|
|
|
$this->info['margin-right'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength(),
|
|
|
|
new HTMLPurifier_AttrDef_Percentage(),
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
|
|
|
));
|
2006-08-14 02:08:45 +00:00
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->info['margin'] = new HTMLPurifier_AttrDef_Multiple($margin);
|
|
|
|
|
2006-08-16 00:18:58 +00:00
|
|
|
// non-negative
|
2006-08-16 01:39:06 +00:00
|
|
|
$padding =
|
2006-08-16 00:18:58 +00:00
|
|
|
$this->info['padding-top'] =
|
|
|
|
$this->info['padding-bottom'] =
|
|
|
|
$this->info['padding-left'] =
|
|
|
|
$this->info['padding-right'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength(true),
|
|
|
|
new HTMLPurifier_AttrDef_Percentage(true)
|
|
|
|
));
|
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$this->info['padding'] = new HTMLPurifier_AttrDef_Multiple($padding);
|
|
|
|
|
2006-08-16 00:18:58 +00:00
|
|
|
$this->info['text-indent'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength(),
|
|
|
|
new HTMLPurifier_AttrDef_Percentage()
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->info['width'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength(true),
|
|
|
|
new HTMLPurifier_AttrDef_Percentage(true),
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
|
|
|
));
|
2006-08-14 02:08:45 +00:00
|
|
|
|
2006-08-16 15:12:48 +00:00
|
|
|
$this->info['text-decoration'] = new HTMLPurifier_AttrDef_TextDecoration();
|
|
|
|
|
2006-08-16 17:25:25 +00:00
|
|
|
$this->info['font-family'] = new HTMLPurifier_AttrDef_FontFamily();
|
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
// this could use specialized code
|
|
|
|
$this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300',
|
|
|
|
'400', '500', '600', '700', '800', '900'), false);
|
|
|
|
|
2006-08-27 00:11:13 +00:00
|
|
|
// MUST be called after other font properties, as it references
|
|
|
|
// a CSSDefinition object
|
2006-08-31 20:33:07 +00:00
|
|
|
$this->info['font'] = new HTMLPurifier_AttrDef_Font($config);
|
2006-08-27 00:11:13 +00:00
|
|
|
|
2006-08-27 00:49:34 +00:00
|
|
|
// same here
|
|
|
|
$this->info['border'] =
|
|
|
|
$this->info['border-bottom'] =
|
|
|
|
$this->info['border-top'] =
|
|
|
|
$this->info['border-left'] =
|
2006-08-31 20:33:07 +00:00
|
|
|
$this->info['border-right'] = new HTMLPurifier_AttrDef_Border($config);
|
2006-08-27 00:49:34 +00:00
|
|
|
|
2006-08-27 01:45:23 +00:00
|
|
|
$this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'collapse', 'seperate'));
|
|
|
|
|
|
|
|
$this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'top', 'bottom'));
|
|
|
|
|
|
|
|
$this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'auto', 'fixed'));
|
|
|
|
|
|
|
|
$this->info['vertical-align'] = new HTMLPurifier_AttrDef_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('baseline', 'sub', 'super',
|
|
|
|
'top', 'text-top', 'middle', 'bottom', 'text-bottom')),
|
|
|
|
new HTMLPurifier_AttrDef_CSSLength(),
|
|
|
|
new HTMLPurifier_AttrDef_Percentage()
|
|
|
|
));
|
|
|
|
|
2006-08-12 20:22:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|