Implement all "Multiple" CSS properties.
[htmlpurifier.git] / library / HTMLPurifier / CSSDefinition.php
blob1948734bd6a0329afc6e6c31e567cda462482328
1 <?php
3 require_once 'HTMLPurifier/AttrDef/Enum.php';
4 require_once 'HTMLPurifier/AttrDef/Color.php';
5 require_once 'HTMLPurifier/AttrDef/Composite.php';
6 require_once 'HTMLPurifier/AttrDef/CSSLength.php';
7 require_once 'HTMLPurifier/AttrDef/Percentage.php';
8 require_once 'HTMLPurifier/AttrDef/Multiple.php';
10 class HTMLPurifier_CSSDefinition
13 var $info = array();
15 function &instance($prototype = null) {
16 static $instance = null;
17 if ($prototype) {
18 $instance = $prototype;
19 } elseif (!$instance) {
20 $instance = new HTMLPurifier_CSSDefinition();
21 $instance->setup();
23 return $instance;
26 function HTMLPurifier_CSSDefinition() {}
28 function setup() {
30 $this->info['text-align'] = new HTMLPurifier_AttrDef_Enum(
31 array('left', 'right', 'center', 'justify'), false);
33 $border_style =
34 $this->info['border-bottom-style'] =
35 $this->info['border-right-style'] =
36 $this->info['border-left-style'] =
37 $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum(
38 array('none', 'hidden', 'dotted', 'dashed', 'solid', 'double',
39 'groove', 'ridge', 'inset', 'outset'), false);
41 $this->info['border-style'] = new HTMLPurifier_AttrDef_Multiple($border_style);
43 $this->info['clear'] = new HTMLPurifier_AttrDef_Enum(
44 array('none', 'left', 'right', 'both'), false);
45 $this->info['float'] = new HTMLPurifier_AttrDef_Enum(
46 array('none', 'left', 'right'), false);
47 $this->info['font-style'] = new HTMLPurifier_AttrDef_Enum(
48 array('normal', 'italic', 'oblique'), false);
49 $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum(
50 array('normal', 'small-caps'), false);
51 $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum(
52 array('inside', 'outside'), false);
53 $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum(
54 array('disc', 'circle', 'square', 'decimal', 'lower-roman',
55 'upper-roman', 'lower-alpha', 'upper-alpha'), false);
56 $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum(
57 array('capitalize', 'uppercase', 'lowercase', 'none'), false);
58 $this->info['color'] = new HTMLPurifier_AttrDef_Color();
60 $border_color =
61 $this->info['border-top-color'] =
62 $this->info['border-bottom-color'] =
63 $this->info['border-left-color'] =
64 $this->info['border-right-color'] =
65 $this->info['background-color'] = new HTMLPurifier_AttrDef_Composite(array(
66 new HTMLPurifier_AttrDef_Enum(array('transparent')),
67 new HTMLPurifier_AttrDef_Color()
68 ));
70 $this->info['border-color'] = new HTMLPurifier_AttrDef_Multiple($border_color);
72 $border_width =
73 $this->info['border-top-width'] =
74 $this->info['border-bottom-width'] =
75 $this->info['border-left-width'] =
76 $this->info['border-right-width'] = new HTMLPurifier_AttrDef_Composite(array(
77 new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')),
78 new HTMLPurifier_AttrDef_CSSLength(true) //disallow negative
79 ));
81 $this->info['border-width'] = new HTMLPurifier_AttrDef_Multiple($border_width);
83 $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_Composite(array(
84 new HTMLPurifier_AttrDef_Enum(array('normal')),
85 new HTMLPurifier_AttrDef_CSSLength()
86 ));
88 $this->info['word-spacing'] = new HTMLPurifier_AttrDef_Composite(array(
89 new HTMLPurifier_AttrDef_Enum(array('normal')),
90 new HTMLPurifier_AttrDef_CSSLength()
91 ));
93 $this->info['font-size'] = new HTMLPurifier_AttrDef_Composite(array(
94 new HTMLPurifier_AttrDef_Enum(array('xx-small', 'x-small',
95 'small', 'medium', 'large', 'x-large', 'xx-large',
96 'larger', 'smaller')),
97 new HTMLPurifier_AttrDef_Percentage(),
98 new HTMLPurifier_AttrDef_CSSLength()
99 ));
101 $this->info['line-height'] = new HTMLPurifier_AttrDef_Composite(array(
102 new HTMLPurifier_AttrDef_Enum(array('normal')),
103 new HTMLPurifier_AttrDef_Number(true), // no negatives
104 new HTMLPurifier_AttrDef_CSSLength(true),
105 new HTMLPurifier_AttrDef_Percentage(true)
108 $margin =
109 $this->info['margin-top'] =
110 $this->info['margin-bottom'] =
111 $this->info['margin-left'] =
112 $this->info['margin-right'] = new HTMLPurifier_AttrDef_Composite(array(
113 new HTMLPurifier_AttrDef_CSSLength(),
114 new HTMLPurifier_AttrDef_Percentage(),
115 new HTMLPurifier_AttrDef_Enum(array('auto'))
118 $this->info['margin'] = new HTMLPurifier_AttrDef_Multiple($margin);
120 // non-negative
121 $padding =
122 $this->info['padding-top'] =
123 $this->info['padding-bottom'] =
124 $this->info['padding-left'] =
125 $this->info['padding-right'] = new HTMLPurifier_AttrDef_Composite(array(
126 new HTMLPurifier_AttrDef_CSSLength(true),
127 new HTMLPurifier_AttrDef_Percentage(true)
130 $this->info['padding'] = new HTMLPurifier_AttrDef_Multiple($padding);
132 $this->info['text-indent'] = new HTMLPurifier_AttrDef_Composite(array(
133 new HTMLPurifier_AttrDef_CSSLength(),
134 new HTMLPurifier_AttrDef_Percentage()
137 $this->info['width'] = new HTMLPurifier_AttrDef_Composite(array(
138 new HTMLPurifier_AttrDef_CSSLength(true),
139 new HTMLPurifier_AttrDef_Percentage(true),
140 new HTMLPurifier_AttrDef_Enum(array('auto'))
143 // this could use specialized code
144 $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(
145 array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300',
146 '400', '500', '600', '700', '800', '900'), false);