Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / htmlpurifier / HTMLPurifier / CSSDefinition.php
blob2fc73b905d286f651480a5bb6a55f02c91b32dd7
1 <?php
3 require_once 'HTMLPurifier/Definition.php';
5 require_once 'HTMLPurifier/AttrDef/CSS/Background.php';
6 require_once 'HTMLPurifier/AttrDef/CSS/BackgroundPosition.php';
7 require_once 'HTMLPurifier/AttrDef/CSS/Border.php';
8 require_once 'HTMLPurifier/AttrDef/CSS/Color.php';
9 require_once 'HTMLPurifier/AttrDef/CSS/Composite.php';
10 require_once 'HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php';
11 require_once 'HTMLPurifier/AttrDef/CSS/Font.php';
12 require_once 'HTMLPurifier/AttrDef/CSS/FontFamily.php';
13 require_once 'HTMLPurifier/AttrDef/CSS/Length.php';
14 require_once 'HTMLPurifier/AttrDef/CSS/ListStyle.php';
15 require_once 'HTMLPurifier/AttrDef/CSS/Multiple.php';
16 require_once 'HTMLPurifier/AttrDef/CSS/Percentage.php';
17 require_once 'HTMLPurifier/AttrDef/CSS/TextDecoration.php';
18 require_once 'HTMLPurifier/AttrDef/CSS/URI.php';
19 require_once 'HTMLPurifier/AttrDef/Enum.php';
21 HTMLPurifier_ConfigSchema::define(
22 'CSS', 'DefinitionRev', 1, 'int', '
23 <p>
24 Revision identifier for your custom definition. See
25 %HTML.DefinitionRev for details. This directive has been available
26 since 2.0.0.
27 </p>
28 ');
30 /**
31 * Defines allowed CSS attributes and what their values are.
32 * @see HTMLPurifier_HTMLDefinition
34 class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition
37 var $type = 'CSS';
39 /**
40 * Assoc array of attribute name to definition object.
42 var $info = array();
44 /**
45 * Constructs the info array. The meat of this class.
47 function doSetup($config) {
49 $this->info['text-align'] = new HTMLPurifier_AttrDef_Enum(
50 array('left', 'right', 'center', 'justify'), false);
52 $border_style =
53 $this->info['border-bottom-style'] =
54 $this->info['border-right-style'] =
55 $this->info['border-left-style'] =
56 $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum(
57 array('none', 'hidden', 'dotted', 'dashed', 'solid', 'double',
58 'groove', 'ridge', 'inset', 'outset'), false);
60 $this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style);
62 $this->info['clear'] = new HTMLPurifier_AttrDef_Enum(
63 array('none', 'left', 'right', 'both'), false);
64 $this->info['float'] = new HTMLPurifier_AttrDef_Enum(
65 array('none', 'left', 'right'), false);
66 $this->info['font-style'] = new HTMLPurifier_AttrDef_Enum(
67 array('normal', 'italic', 'oblique'), false);
68 $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum(
69 array('normal', 'small-caps'), false);
71 $uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite(
72 array(
73 new HTMLPurifier_AttrDef_Enum(array('none')),
74 new HTMLPurifier_AttrDef_CSS_URI()
78 $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum(
79 array('inside', 'outside'), false);
80 $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum(
81 array('disc', 'circle', 'square', 'decimal', 'lower-roman',
82 'upper-roman', 'lower-alpha', 'upper-alpha', 'none'), false);
83 $this->info['list-style-image'] = $uri_or_none;
85 $this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config);
87 $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum(
88 array('capitalize', 'uppercase', 'lowercase', 'none'), false);
89 $this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color();
91 $this->info['background-image'] = $uri_or_none;
92 $this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum(
93 array('repeat', 'repeat-x', 'repeat-y', 'no-repeat')
95 $this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum(
96 array('scroll', 'fixed')
98 $this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition();
100 $border_color =
101 $this->info['border-top-color'] =
102 $this->info['border-bottom-color'] =
103 $this->info['border-left-color'] =
104 $this->info['border-right-color'] =
105 $this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
106 new HTMLPurifier_AttrDef_Enum(array('transparent')),
107 new HTMLPurifier_AttrDef_CSS_Color()
110 $this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config);
112 $this->info['border-color'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_color);
114 $border_width =
115 $this->info['border-top-width'] =
116 $this->info['border-bottom-width'] =
117 $this->info['border-left-width'] =
118 $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
119 new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')),
120 new HTMLPurifier_AttrDef_CSS_Length(true) //disallow negative
123 $this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width);
125 $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
126 new HTMLPurifier_AttrDef_Enum(array('normal')),
127 new HTMLPurifier_AttrDef_CSS_Length()
130 $this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
131 new HTMLPurifier_AttrDef_Enum(array('normal')),
132 new HTMLPurifier_AttrDef_CSS_Length()
135 $this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
136 new HTMLPurifier_AttrDef_Enum(array('xx-small', 'x-small',
137 'small', 'medium', 'large', 'x-large', 'xx-large',
138 'larger', 'smaller')),
139 new HTMLPurifier_AttrDef_CSS_Percentage(),
140 new HTMLPurifier_AttrDef_CSS_Length()
143 $this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
144 new HTMLPurifier_AttrDef_Enum(array('normal')),
145 new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives
146 new HTMLPurifier_AttrDef_CSS_Length(true),
147 new HTMLPurifier_AttrDef_CSS_Percentage(true)
150 $margin =
151 $this->info['margin-top'] =
152 $this->info['margin-bottom'] =
153 $this->info['margin-left'] =
154 $this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
155 new HTMLPurifier_AttrDef_CSS_Length(),
156 new HTMLPurifier_AttrDef_CSS_Percentage(),
157 new HTMLPurifier_AttrDef_Enum(array('auto'))
160 $this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin);
162 // non-negative
163 $padding =
164 $this->info['padding-top'] =
165 $this->info['padding-bottom'] =
166 $this->info['padding-left'] =
167 $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
168 new HTMLPurifier_AttrDef_CSS_Length(true),
169 new HTMLPurifier_AttrDef_CSS_Percentage(true)
172 $this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding);
174 $this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
175 new HTMLPurifier_AttrDef_CSS_Length(),
176 new HTMLPurifier_AttrDef_CSS_Percentage()
179 $this->info['width'] =
180 $this->info['height'] =
181 new HTMLPurifier_AttrDef_CSS_DenyElementDecorator(
182 new HTMLPurifier_AttrDef_CSS_Composite(array(
183 new HTMLPurifier_AttrDef_CSS_Length(true),
184 new HTMLPurifier_AttrDef_CSS_Percentage(true),
185 new HTMLPurifier_AttrDef_Enum(array('auto'))
186 )), 'img');
188 $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration();
190 $this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily();
192 // this could use specialized code
193 $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum(
194 array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300',
195 '400', '500', '600', '700', '800', '900'), false);
197 // MUST be called after other font properties, as it references
198 // a CSSDefinition object
199 $this->info['font'] = new HTMLPurifier_AttrDef_CSS_Font($config);
201 // same here
202 $this->info['border'] =
203 $this->info['border-bottom'] =
204 $this->info['border-top'] =
205 $this->info['border-left'] =
206 $this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config);
208 $this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum(array(
209 'collapse', 'separate'));
211 $this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum(array(
212 'top', 'bottom'));
214 $this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum(array(
215 'auto', 'fixed'));
217 $this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite(array(
218 new HTMLPurifier_AttrDef_Enum(array('baseline', 'sub', 'super',
219 'top', 'text-top', 'middle', 'bottom', 'text-bottom')),
220 new HTMLPurifier_AttrDef_CSS_Length(),
221 new HTMLPurifier_AttrDef_CSS_Percentage()
224 $this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2);
226 // partial support
227 $this->info['white-space'] = new HTMLPurifier_AttrDef_Enum(array('nowrap'));