Implement all composite CSS definitions.
[htmlpurifier.git] / library / HTMLPurifier / CSSDefinition.php
blob105a6797dac44cd97011d971544ff1c19a31a041
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';
9 class HTMLPurifier_CSSDefinition
12 var $info = array();
14 function &instance($prototype = null) {
15 static $instance = null;
16 if ($prototype) {
17 $instance = $prototype;
18 } elseif (!$instance) {
19 $instance = new HTMLPurifier_CSSDefinition();
20 $instance->setup();
22 return $instance;
25 function HTMLPurifier_CSSDefinition() {}
27 function setup() {
29 $this->info['text-align'] = new HTMLPurifier_AttrDef_Enum(
30 array('left', 'right', 'center', 'justify'), false);
31 $this->info['border-bottom-style'] =
32 $this->info['border-right-style'] =
33 $this->info['border-left-style'] =
34 $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum(
35 array('none', 'hidden', 'dotted', 'dashed', 'solid', 'double',
36 'groove', 'ridge', 'inset', 'outset'), false);
37 $this->info['clear'] = new HTMLPurifier_AttrDef_Enum(
38 array('none', 'left', 'right', 'both'), false);
39 $this->info['float'] = new HTMLPurifier_AttrDef_Enum(
40 array('none', 'left', 'right'), false);
41 $this->info['font-style'] = new HTMLPurifier_AttrDef_Enum(
42 array('normal', 'italic', 'oblique'), false);
43 $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum(
44 array('normal', 'small-caps'), false);
45 $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum(
46 array('inside', 'outside'), false);
47 $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum(
48 array('disc', 'circle', 'square', 'decimal', 'lower-roman',
49 'upper-roman', 'lower-alpha', 'upper-alpha'), false);
50 $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum(
51 array('capitalize', 'uppercase', 'lowercase', 'none'), false);
52 $this->info['color'] = new HTMLPurifier_AttrDef_Color();
54 $this->info['border-top-color'] =
55 $this->info['border-bottom-color'] =
56 $this->info['border-left-color'] =
57 $this->info['border-right-color'] =
58 $this->info['background-color'] = new HTMLPurifier_AttrDef_Composite(array(
59 new HTMLPurifier_AttrDef_Enum(array('transparent')),
60 new HTMLPurifier_AttrDef_Color()
61 ));
63 $this->info['border-top-width'] =
64 $this->info['border-bottom-width'] =
65 $this->info['border-left-width'] =
66 $this->info['border-right-width'] = new HTMLPurifier_AttrDef_Composite(array(
67 new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')),
68 new HTMLPurifier_AttrDef_CSSLength(true) //disallow negative
69 ));
71 $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_Composite(array(
72 new HTMLPurifier_AttrDef_Enum(array('normal')),
73 new HTMLPurifier_AttrDef_CSSLength()
74 ));
76 $this->info['word-spacing'] = new HTMLPurifier_AttrDef_Composite(array(
77 new HTMLPurifier_AttrDef_Enum(array('normal')),
78 new HTMLPurifier_AttrDef_CSSLength()
79 ));
81 $this->info['font-size'] = new HTMLPurifier_AttrDef_Composite(array(
82 new HTMLPurifier_AttrDef_Enum(array('xx-small', 'x-small',
83 'small', 'medium', 'large', 'x-large', 'xx-large',
84 'larger', 'smaller')),
85 new HTMLPurifier_AttrDef_Percentage(),
86 new HTMLPurifier_AttrDef_CSSLength()
87 ));
89 $this->info['line-height'] = new HTMLPurifier_AttrDef_Composite(array(
90 new HTMLPurifier_AttrDef_Enum(array('normal')),
91 new HTMLPurifier_AttrDef_Number(true), // no negatives
92 new HTMLPurifier_AttrDef_CSSLength(true),
93 new HTMLPurifier_AttrDef_Percentage(true)
94 ));
96 $this->info['margin-top'] =
97 $this->info['margin-bottom'] =
98 $this->info['margin-left'] =
99 $this->info['margin-right'] = new HTMLPurifier_AttrDef_Composite(array(
100 new HTMLPurifier_AttrDef_CSSLength(),
101 new HTMLPurifier_AttrDef_Percentage(),
102 new HTMLPurifier_AttrDef_Enum(array('auto'))
105 // non-negative
106 $this->info['padding-top'] =
107 $this->info['padding-bottom'] =
108 $this->info['padding-left'] =
109 $this->info['padding-right'] = new HTMLPurifier_AttrDef_Composite(array(
110 new HTMLPurifier_AttrDef_CSSLength(true),
111 new HTMLPurifier_AttrDef_Percentage(true)
114 $this->info['text-indent'] = new HTMLPurifier_AttrDef_Composite(array(
115 new HTMLPurifier_AttrDef_CSSLength(),
116 new HTMLPurifier_AttrDef_Percentage()
119 $this->info['width'] = new HTMLPurifier_AttrDef_Composite(array(
120 new HTMLPurifier_AttrDef_CSSLength(true),
121 new HTMLPurifier_AttrDef_Percentage(true),
122 new HTMLPurifier_AttrDef_Enum(array('auto'))
125 // this could use specialized code
126 $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(
127 array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300',
128 '400', '500', '600', '700', '800', '900'), false);