2006-08-12 20:22:09 +00:00
|
|
|
<?php
|
|
|
|
|
2006-08-19 23:06:59 +00:00
|
|
|
/**
|
|
|
|
* Defines allowed CSS attributes and what their values are.
|
|
|
|
* @see HTMLPurifier_HTMLDefinition
|
|
|
|
*/
|
2007-05-24 21:50:43 +00:00
|
|
|
class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
|
2006-08-12 20:22:09 +00:00
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-11-25 02:24:39 +00:00
|
|
|
public $type = 'CSS';
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-19 23:06:59 +00:00
|
|
|
/**
|
|
|
|
* Assoc array of attribute name to definition object.
|
|
|
|
*/
|
2007-11-25 02:24:39 +00:00
|
|
|
public $info = array();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-19 23:06:59 +00:00
|
|
|
/**
|
|
|
|
* Constructs the info array. The meat of this class.
|
|
|
|
*/
|
2007-11-25 02:24:39 +00:00
|
|
|
protected function doSetup($config) {
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-12 20:22:09 +00:00
|
|
|
$this->info['text-align'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('left', 'right', 'center', 'justify'), false);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$border_style =
|
2008-12-06 07:28:20 +00:00
|
|
|
$this->info['border-bottom-style'] =
|
|
|
|
$this->info['border-right-style'] =
|
|
|
|
$this->info['border-left-style'] =
|
2006-08-13 19:08:14 +00:00
|
|
|
$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);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
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);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite(
|
2007-01-15 01:14:24 +00:00
|
|
|
array(
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('none')),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_URI()
|
2007-01-15 01:14:24 +00:00
|
|
|
)
|
|
|
|
);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
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;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-13 16:52:31 +00:00
|
|
|
$this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum(
|
|
|
|
array('capitalize', 'uppercase', 'lowercase', 'none'), false);
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
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')
|
|
|
|
);
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
|
|
|
$border_color =
|
|
|
|
$this->info['border-top-color'] =
|
|
|
|
$this->info['border-bottom-color'] =
|
|
|
|
$this->info['border-left-color'] =
|
|
|
|
$this->info['border-right-color'] =
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2006-08-13 21:23:57 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('transparent')),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Color()
|
2006-08-13 21:23:57 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['border-color'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_color);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
|
|
|
$border_width =
|
|
|
|
$this->info['border-top-width'] =
|
|
|
|
$this->info['border-bottom-width'] =
|
|
|
|
$this->info['border-left-width'] =
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2006-08-13 23:08:38 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')),
|
2008-05-21 01:56:48 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative
|
2006-08-13 23:08:38 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2006-08-13 23:08:38 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('normal')),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Length()
|
2006-08-13 23:08:38 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2006-08-13 23:08:38 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('normal')),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Length()
|
2006-08-13 23:08:38 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2006-08-14 02:08:45 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('xx-small', 'x-small',
|
|
|
|
'small', 'medium', 'large', 'x-large', 'xx-large',
|
|
|
|
'larger', 'smaller')),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage(),
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Length()
|
2006-08-14 02:08:45 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2006-08-16 00:18:58 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('normal')),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives
|
2008-05-21 01:56:48 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage(true)
|
2006-08-16 00:18:58 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-16 01:39:06 +00:00
|
|
|
$margin =
|
2008-12-06 07:28:20 +00:00
|
|
|
$this->info['margin-top'] =
|
|
|
|
$this->info['margin-bottom'] =
|
|
|
|
$this->info['margin-left'] =
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Length(),
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage(),
|
2006-08-16 00:18:58 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-16 00:18:58 +00:00
|
|
|
// non-negative
|
2006-08-16 01:39:06 +00:00
|
|
|
$padding =
|
2008-12-06 07:28:20 +00:00
|
|
|
$this->info['padding-top'] =
|
|
|
|
$this->info['padding-bottom'] =
|
|
|
|
$this->info['padding-left'] =
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2008-05-21 01:56:48 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage(true)
|
2006-08-16 00:18:58 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Length(),
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage()
|
2006-08-16 00:18:58 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-05-23 02:09:43 +00:00
|
|
|
$trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Length('0'),
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage(true),
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
|
|
|
));
|
2009-02-20 00:17:49 +00:00
|
|
|
$max = $config->get('CSS.MaxImgLength');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-03-29 23:48:54 +00:00
|
|
|
$this->info['width'] =
|
2008-04-22 22:28:54 +00:00
|
|
|
$this->info['height'] =
|
2008-05-23 02:09:43 +00:00
|
|
|
$max === null ?
|
2008-12-06 07:28:20 +00:00
|
|
|
$trusted_wh :
|
2008-05-23 02:09:43 +00:00
|
|
|
new HTMLPurifier_AttrDef_Switch('img',
|
|
|
|
// For img tags:
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Length('0', $max),
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('auto'))
|
|
|
|
)),
|
|
|
|
// For everyone else:
|
|
|
|
$trusted_wh
|
|
|
|
);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
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);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-27 00:11:13 +00:00
|
|
|
// MUST be called after other font properties, as it references
|
|
|
|
// a CSSDefinition object
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['font'] = new HTMLPurifier_AttrDef_CSS_Font($config);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-27 00:49:34 +00:00
|
|
|
// same here
|
|
|
|
$this->info['border'] =
|
2008-12-06 07:28:20 +00:00
|
|
|
$this->info['border-bottom'] =
|
|
|
|
$this->info['border-top'] =
|
|
|
|
$this->info['border-left'] =
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-27 01:45:23 +00:00
|
|
|
$this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum(array(
|
2007-08-11 06:52:26 +00:00
|
|
|
'collapse', 'separate'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-27 01:45:23 +00:00
|
|
|
$this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'top', 'bottom'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-27 01:45:23 +00:00
|
|
|
$this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'auto', 'fixed'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-02-14 20:38:51 +00:00
|
|
|
$this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
2006-08-27 01:45:23 +00:00
|
|
|
new HTMLPurifier_AttrDef_Enum(array('baseline', 'sub', 'super',
|
|
|
|
'top', 'text-top', 'middle', 'bottom', 'text-bottom')),
|
2007-02-14 20:38:51 +00:00
|
|
|
new HTMLPurifier_AttrDef_CSS_Length(),
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage()
|
2006-08-27 01:45:23 +00:00
|
|
|
));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-09-03 15:16:33 +00:00
|
|
|
$this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2);
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-05-03 04:07:47 +00:00
|
|
|
// partial support
|
|
|
|
$this->info['white-space'] = new HTMLPurifier_AttrDef_Enum(array('nowrap'));
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2009-02-20 00:17:49 +00:00
|
|
|
if ($config->get('CSS.Proprietary')) {
|
2007-12-16 23:16:45 +00:00
|
|
|
$this->doSetupProprietary($config);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2009-02-20 00:17:49 +00:00
|
|
|
if ($config->get('CSS.AllowTricky')) {
|
2008-02-25 22:05:49 +00:00
|
|
|
$this->doSetupTricky($config);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2010-11-12 18:45:03 +00:00
|
|
|
if ($config->get('CSS.Trusted')) {
|
|
|
|
$this->doSetupTrusted($config);
|
|
|
|
}
|
|
|
|
|
2009-02-20 00:17:49 +00:00
|
|
|
$allow_important = $config->get('CSS.AllowImportant');
|
2008-02-25 21:58:17 +00:00
|
|
|
// wrap all attr-defs with decorator that handles !important
|
|
|
|
foreach ($this->info as $k => $v) {
|
|
|
|
$this->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-03-30 21:44:16 +00:00
|
|
|
$this->setupConfigStuff($config);
|
2007-12-16 23:16:45 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-16 23:16:45 +00:00
|
|
|
protected function doSetupProprietary($config) {
|
|
|
|
// Internet Explorer only scrollbar colors
|
|
|
|
$this->info['scrollbar-arrow-color'] = new HTMLPurifier_AttrDef_CSS_Color();
|
|
|
|
$this->info['scrollbar-base-color'] = new HTMLPurifier_AttrDef_CSS_Color();
|
|
|
|
$this->info['scrollbar-darkshadow-color'] = new HTMLPurifier_AttrDef_CSS_Color();
|
|
|
|
$this->info['scrollbar-face-color'] = new HTMLPurifier_AttrDef_CSS_Color();
|
|
|
|
$this->info['scrollbar-highlight-color'] = new HTMLPurifier_AttrDef_CSS_Color();
|
|
|
|
$this->info['scrollbar-shadow-color'] = new HTMLPurifier_AttrDef_CSS_Color();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-16 23:16:45 +00:00
|
|
|
// technically not proprietary, but CSS3, and no one supports it
|
|
|
|
$this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue();
|
|
|
|
$this->info['-moz-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue();
|
|
|
|
$this->info['-khtml-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-12-16 23:16:45 +00:00
|
|
|
// only opacity, for now
|
|
|
|
$this->info['filter'] = new HTMLPurifier_AttrDef_CSS_Filter();
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-08-12 20:22:09 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-02-25 22:05:49 +00:00
|
|
|
protected function doSetupTricky($config) {
|
|
|
|
$this->info['display'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'inline', 'block', 'list-item', 'run-in', 'compact',
|
|
|
|
'marker', 'table', 'inline-table', 'table-row-group',
|
|
|
|
'table-header-group', 'table-footer-group', 'table-row',
|
|
|
|
'table-column-group', 'table-column', 'table-cell', 'table-caption', 'none'
|
|
|
|
));
|
|
|
|
$this->info['visibility'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'visible', 'hidden', 'collapse'
|
|
|
|
));
|
2008-11-27 21:14:50 +00:00
|
|
|
$this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(array('visible', 'hidden', 'auto', 'scroll'));
|
2008-02-25 22:05:49 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2010-11-12 18:45:03 +00:00
|
|
|
protected function doSetupTrusted($config) {
|
|
|
|
$this->info['position'] = new HTMLPurifier_AttrDef_Enum(array(
|
|
|
|
'static', 'relative', 'absolute', 'fixed'
|
|
|
|
));
|
|
|
|
$this->info['top'] =
|
|
|
|
$this->info['left'] =
|
|
|
|
$this->info['right'] =
|
|
|
|
$this->info['bottom'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Length(),
|
|
|
|
new HTMLPurifier_AttrDef_CSS_Percentage(),
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('auto')),
|
|
|
|
));
|
|
|
|
$this->info['z-index'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
|
|
|
|
new HTMLPurifier_AttrDef_Integer(),
|
|
|
|
new HTMLPurifier_AttrDef_Enum(array('auto')),
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-03-30 21:44:16 +00:00
|
|
|
/**
|
|
|
|
* Performs extra config-based processing. Based off of
|
|
|
|
* HTMLPurifier_HTMLDefinition.
|
|
|
|
* @todo Refactor duplicate elements into common class (probably using
|
|
|
|
* composition, not inheritance).
|
|
|
|
*/
|
|
|
|
protected function setupConfigStuff($config) {
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-03-30 21:44:16 +00:00
|
|
|
// setup allowed elements
|
|
|
|
$support = "(for information on implementing this, see the ".
|
|
|
|
"support forums) ";
|
2010-09-04 06:59:03 +00:00
|
|
|
$allowed_properties = $config->get('CSS.AllowedProperties');
|
|
|
|
if ($allowed_properties !== null) {
|
2008-03-30 21:44:16 +00:00
|
|
|
foreach ($this->info as $name => $d) {
|
2010-09-04 06:59:03 +00:00
|
|
|
if(!isset($allowed_properties[$name])) unset($this->info[$name]);
|
|
|
|
unset($allowed_properties[$name]);
|
2008-03-30 21:44:16 +00:00
|
|
|
}
|
|
|
|
// emit errors
|
2010-09-04 06:59:03 +00:00
|
|
|
foreach ($allowed_properties as $name => $d) {
|
2008-03-30 21:44:16 +00:00
|
|
|
// :TODO: Is this htmlspecialchars() call really necessary?
|
|
|
|
$name = htmlspecialchars($name);
|
|
|
|
trigger_error("Style attribute '$name' is not supported $support", E_USER_WARNING);
|
|
|
|
}
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2010-09-04 06:59:03 +00:00
|
|
|
$forbidden_properties = $config->get('CSS.ForbiddenProperties');
|
|
|
|
if ($forbidden_properties !== null) {
|
|
|
|
foreach ($this->info as $name => $d) {
|
|
|
|
if (isset($forbidden_properties[$name])) {
|
|
|
|
unset($this->info[$name]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-30 21:44:16 +00:00
|
|
|
}
|
2006-08-12 20:22:09 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|