Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like csstidy often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use csstidy, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
73 | class csstidy { |
||
74 | |||
75 | /** |
||
76 | * Saves the parsed CSS. This array is empty if preserve_css is on. |
||
77 | * @var array |
||
78 | * @access public |
||
79 | */ |
||
80 | public $css = array(); |
||
81 | /** |
||
82 | * Saves the parsed CSS (raw) |
||
83 | * @var array |
||
84 | * @access private |
||
85 | */ |
||
86 | public $tokens = array(); |
||
87 | /** |
||
88 | * Printer class |
||
89 | * @see csstidy_print |
||
90 | * @var object |
||
91 | * @access public |
||
92 | */ |
||
93 | public $print; |
||
94 | /** |
||
95 | * Optimiser class |
||
96 | * @see csstidy_optimise |
||
97 | * @var object |
||
98 | * @access private |
||
99 | */ |
||
100 | public $optimise; |
||
101 | /** |
||
102 | * Saves the CSS charset (@charset) |
||
103 | * @var string |
||
104 | * @access private |
||
105 | */ |
||
106 | public $charset = ''; |
||
107 | /** |
||
108 | * Saves all @import URLs |
||
109 | * @var array |
||
110 | * @access private |
||
111 | */ |
||
112 | public $import = array(); |
||
113 | /** |
||
114 | * Saves the namespace |
||
115 | * @var string |
||
116 | * @access private |
||
117 | */ |
||
118 | public $namespace = ''; |
||
119 | /** |
||
120 | * Contains the version of csstidy |
||
121 | * @var string |
||
122 | * @access private |
||
123 | */ |
||
124 | public $version = '1.3'; |
||
125 | /** |
||
126 | * Stores the settings |
||
127 | * @var array |
||
128 | * @access private |
||
129 | */ |
||
130 | public $settings = array(); |
||
131 | /** |
||
132 | * Saves the parser-status. |
||
133 | * |
||
134 | * Possible values: |
||
135 | * - is = in selector |
||
136 | * - ip = in property |
||
137 | * - iv = in value |
||
138 | * - instr = in string (started at " or ' or ( ) |
||
139 | * - ic = in comment (ignore everything) |
||
140 | * - at = in @-block |
||
141 | * |
||
142 | * @var string |
||
143 | * @access private |
||
144 | */ |
||
145 | public $status = 'is'; |
||
146 | /** |
||
147 | * Saves the current at rule (@media) |
||
148 | * @var string |
||
149 | * @access private |
||
150 | */ |
||
151 | public $at = ''; |
||
152 | /** |
||
153 | * Saves the current selector |
||
154 | * @var string |
||
155 | * @access private |
||
156 | */ |
||
157 | public $selector = ''; |
||
158 | /** |
||
159 | * Saves the current property |
||
160 | * @var string |
||
161 | * @access private |
||
162 | */ |
||
163 | public $property = ''; |
||
164 | /** |
||
165 | * Saves the position of , in selectors |
||
166 | * @var array |
||
167 | * @access private |
||
168 | */ |
||
169 | public $sel_separate = array(); |
||
170 | /** |
||
171 | * Saves the current value |
||
172 | * @var string |
||
173 | * @access private |
||
174 | */ |
||
175 | public $value = ''; |
||
176 | /** |
||
177 | * Saves the current sub-value |
||
178 | * |
||
179 | * Example for a subvalue: |
||
180 | * background:url(foo.png) red no-repeat; |
||
181 | * "url(foo.png)", "red", and "no-repeat" are subvalues, |
||
182 | * separated by whitespace |
||
183 | * @var string |
||
184 | * @access private |
||
185 | */ |
||
186 | public $sub_value = ''; |
||
187 | /** |
||
188 | * Array which saves all subvalues for a property. |
||
189 | * @var array |
||
190 | * @see sub_value |
||
191 | * @access private |
||
192 | */ |
||
193 | public $sub_value_arr = array(); |
||
194 | /** |
||
195 | * Saves the stack of characters that opened the current strings |
||
196 | * @var array |
||
197 | * @access private |
||
198 | */ |
||
199 | public $str_char = array(); |
||
200 | public $cur_string = array(); |
||
201 | /** |
||
202 | * Status from which the parser switched to ic or instr |
||
203 | * @var array |
||
204 | * @access private |
||
205 | */ |
||
206 | public $from = array(); |
||
207 | /** |
||
208 | /** |
||
209 | * =true if in invalid at-rule |
||
210 | * @var bool |
||
211 | * @access private |
||
212 | */ |
||
213 | public $invalid_at = false; |
||
214 | /** |
||
215 | * =true if something has been added to the current selector |
||
216 | * @var bool |
||
217 | * @access private |
||
218 | */ |
||
219 | public $added = false; |
||
220 | /** |
||
221 | * Array which saves the message log |
||
222 | * @var array |
||
223 | * @access private |
||
224 | */ |
||
225 | public $log = array(); |
||
226 | /** |
||
227 | * Saves the line number |
||
228 | * @var integer |
||
229 | * @access private |
||
230 | */ |
||
231 | public $line = 1; |
||
232 | /** |
||
233 | * Marks if we need to leave quotes for a string |
||
234 | * @var array |
||
235 | * @access private |
||
236 | */ |
||
237 | public $quoted_string = array(); |
||
238 | |||
239 | /** |
||
240 | * List of tokens |
||
241 | * @var string |
||
242 | */ |
||
243 | public $tokens_list = ""; |
||
244 | /** |
||
245 | * Loads standard template and sets default settings |
||
246 | * @access private |
||
247 | * @version 1.3 |
||
248 | */ |
||
249 | function csstidy() { |
||
|
|||
250 | $this->settings['remove_bslash'] = true; |
||
251 | $this->settings['compress_colors'] = true; |
||
252 | $this->settings['compress_font-weight'] = true; |
||
253 | $this->settings['lowercase_s'] = false; |
||
254 | /* |
||
255 | 1 common shorthands optimization |
||
256 | 2 + font property optimization |
||
257 | 3 + background property optimization |
||
258 | */ |
||
259 | $this->settings['optimise_shorthands'] = 1; |
||
260 | $this->settings['remove_last_;'] = true; |
||
261 | /* rewrite all properties with low case, better for later gzip OK, safe*/ |
||
262 | $this->settings['case_properties'] = 1; |
||
263 | /* sort properties in alpabetic order, better for later gzip |
||
264 | * but can cause trouble in case of overiding same propertie or using hack |
||
265 | */ |
||
266 | $this->settings['sort_properties'] = false; |
||
267 | /* |
||
268 | 1, 3, 5, etc -- enable sorting selectors inside @media: a{}b{}c{} |
||
269 | 2, 5, 8, etc -- enable sorting selectors inside one CSS declaration: a,b,c{} |
||
270 | preserve order by default cause it can break functionnality |
||
271 | */ |
||
272 | $this->settings['sort_selectors'] = 0; |
||
273 | /* is dangeroues to be used: CSS is broken sometimes */ |
||
274 | $this->settings['merge_selectors'] = 0; |
||
275 | /* preserve or not browser hacks */ |
||
276 | $this->settings['discard_invalid_selectors'] = false; |
||
277 | $this->settings['discard_invalid_properties'] = false; |
||
278 | $this->settings['css_level'] = 'CSS2.1'; |
||
279 | $this->settings['preserve_css'] = false; |
||
280 | $this->settings['timestamp'] = false; |
||
281 | $this->settings['template'] = ''; // say that propertie exist |
||
282 | $this->set_cfg('template','default'); // call load_template |
||
283 | $this->optimise = new csstidy_optimise($this); |
||
284 | |||
285 | $this->tokens_list = & $GLOBALS['csstidy']['tokens']; |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * Get the value of a setting. |
||
290 | * @param string $setting |
||
291 | * @access public |
||
292 | * @return mixed |
||
293 | * @version 1.0 |
||
294 | */ |
||
295 | function get_cfg($setting) { |
||
296 | if (isset($this->settings[$setting])) { |
||
297 | return $this->settings[$setting]; |
||
298 | } |
||
299 | return false; |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * Load a template |
||
304 | * @param string $template used by set_cfg to load a template via a configuration setting |
||
305 | * @access private |
||
306 | * @version 1.4 |
||
307 | */ |
||
308 | function _load_template($template) { |
||
309 | switch ($template) { |
||
310 | case 'default': |
||
311 | $this->load_template('default'); |
||
312 | break; |
||
313 | |||
314 | case 'highest': |
||
315 | $this->load_template('highest_compression'); |
||
316 | break; |
||
317 | |||
318 | case 'high': |
||
319 | $this->load_template('high_compression'); |
||
320 | break; |
||
321 | |||
322 | case 'low': |
||
323 | $this->load_template('low_compression'); |
||
324 | break; |
||
325 | |||
326 | default: |
||
327 | $this->load_template($template); |
||
328 | break; |
||
329 | } |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * Set the value of a setting. |
||
334 | * @param string $setting |
||
335 | * @param mixed $value |
||
336 | * @access public |
||
337 | * @return bool |
||
338 | * @version 1.0 |
||
339 | */ |
||
340 | function set_cfg($setting, $value=null) { |
||
341 | if (is_array($setting) && $value === null) { |
||
342 | foreach ($setting as $setprop => $setval) { |
||
343 | $this->settings[$setprop] = $setval; |
||
344 | } |
||
345 | if (array_key_exists('template', $setting)) { |
||
346 | $this->_load_template($this->settings['template']); |
||
347 | } |
||
348 | return true; |
||
349 | } else if (isset($this->settings[$setting]) && $value !== '') { |
||
350 | $this->settings[$setting] = $value; |
||
351 | if ($setting === 'template') { |
||
352 | $this->_load_template($this->settings['template']); |
||
353 | } |
||
354 | return true; |
||
355 | } |
||
356 | return false; |
||
357 | } |
||
358 | |||
359 | /** |
||
360 | * Adds a token to $this->tokens |
||
361 | * @param mixed $type |
||
362 | * @param string $data |
||
363 | * @param bool $do add a token even if preserve_css is off |
||
364 | * @access private |
||
365 | * @version 1.0 |
||
366 | */ |
||
367 | function _add_token($type, $data, $do = false) { |
||
372 | |||
373 | /** |
||
374 | * Add a message to the message log |
||
375 | * @param string $message |
||
376 | * @param string $type |
||
377 | * @param integer $line |
||
378 | * @access private |
||
379 | * @version 1.0 |
||
380 | */ |
||
381 | function log($message, $type, $line = -1) { |
||
391 | |||
392 | /** |
||
393 | * Parse unicode notations and find a replacement character |
||
394 | * @param string $string |
||
395 | * @param integer $i |
||
396 | * @access private |
||
397 | * @return string |
||
398 | * @version 1.2 |
||
399 | */ |
||
400 | function _unicode(&$string, &$i) { |
||
401 | ++$i; |
||
402 | $add = ''; |
||
403 | $replaced = false; |
||
404 | |||
405 | while ($i < strlen($string) && (ctype_xdigit($string{$i}) || ctype_space($string{$i})) && strlen($add) < 6) { |
||
406 | $add .= $string{$i}; |
||
407 | |||
408 | if (ctype_space($string{$i})) { |
||
409 | break; |
||
410 | } |
||
411 | $i++; |
||
412 | } |
||
413 | |||
414 | if (hexdec($add) > 47 && hexdec($add) < 58 || hexdec($add) > 64 && hexdec($add) < 91 || hexdec($add) > 96 && hexdec($add) < 123) { |
||
415 | $this->log('Replaced unicode notation: Changed \\' . $add . ' to ' . chr(hexdec($add)), 'Information'); |
||
416 | $add = chr(hexdec($add)); |
||
417 | $replaced = true; |
||
418 | } else { |
||
419 | $add = trim('\\' . $add); |
||
420 | } |
||
421 | |||
422 | if (@ctype_xdigit($string{$i + 1}) && ctype_space($string{$i}) |
||
423 | && !$replaced || !ctype_space($string{$i})) { |
||
424 | $i--; |
||
425 | } |
||
426 | |||
427 | if ($add !== '\\' || !$this->get_cfg('remove_bslash') || strpos($this->tokens_list, $string{$i + 1}) !== false) { |
||
428 | return $add; |
||
429 | } |
||
430 | |||
431 | if ($add === '\\') { |
||
432 | $this->log('Removed unnecessary backslash', 'Information'); |
||
433 | } |
||
434 | return ''; |
||
435 | } |
||
436 | |||
437 | /** |
||
438 | * Write formatted output to a file |
||
439 | * @param string $filename |
||
440 | * @param string $doctype when printing formatted, is a shorthand for the document type |
||
441 | * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet |
||
442 | * @param string $title when printing formatted, is the title to be added in the head of the document |
||
443 | * @param string $lang when printing formatted, gives a two-letter language code to be added to the output |
||
444 | * @access public |
||
445 | * @version 1.4 |
||
446 | */ |
||
447 | function write_page($filename, $doctype='xhtml1.1', $externalcss=true, $title='', $lang='en') { |
||
450 | |||
451 | /** |
||
452 | * Write plain output to a file |
||
453 | * @param string $filename |
||
454 | * @param bool $formatted whether to print formatted or not |
||
455 | * @param string $doctype when printing formatted, is a shorthand for the document type |
||
456 | * @param bool $externalcss when printing formatted, indicates whether styles to be attached internally or as an external stylesheet |
||
457 | * @param string $title when printing formatted, is the title to be added in the head of the document |
||
458 | * @param string $lang when printing formatted, gives a two-letter language code to be added to the output |
||
459 | * @param bool $pre_code whether to add pre and code tags around the code (for light HTML formatted templates) |
||
460 | * @access public |
||
461 | * @version 1.4 |
||
462 | */ |
||
463 | function write($filename, $formatted=false, $doctype='xhtml1.1', $externalcss=true, $title='', $lang='en', $pre_code=true) { |
||
464 | $filename .= ( $formatted) ? '.xhtml' : '.css'; |
||
465 | |||
466 | if (!is_dir('temp')) { |
||
467 | $madedir = mkdir('temp'); |
||
468 | if (!$madedir) { |
||
469 | print 'Could not make directory "temp" in ' . dirname(__FILE__); |
||
470 | exit; |
||
471 | } |
||
472 | } |
||
473 | $handle = fopen('temp/' . $filename, 'w'); |
||
474 | if ($handle) { |
||
475 | if (!$formatted) { |
||
476 | fwrite($handle, $this->print->plain()); |
||
477 | } else { |
||
478 | fwrite($handle, $this->print->formatted_page($doctype, $externalcss, $title, $lang, $pre_code)); |
||
479 | } |
||
480 | } |
||
481 | fclose($handle); |
||
482 | } |
||
483 | |||
484 | /** |
||
485 | * Loads a new template |
||
486 | * @param string $content either filename (if $from_file == true), content of a template file, "high_compression", "highest_compression", "low_compression", or "default" |
||
487 | * @param bool $from_file uses $content as filename if true |
||
488 | * @access public |
||
489 | * @version 1.1 |
||
490 | * @see http://csstidy.sourceforge.net/templates.php |
||
491 | */ |
||
492 | function load_template($content, $from_file=true) { |
||
493 | $predefined_templates = & $GLOBALS['csstidy']['predefined_templates']; |
||
494 | if ($content === 'high_compression' || $content === 'default' || $content === 'highest_compression' || $content === 'low_compression') { |
||
495 | $this->template = $predefined_templates[$content]; |
||
496 | return; |
||
497 | } |
||
498 | |||
499 | |||
500 | if ($from_file) { |
||
501 | $content = strip_tags(file_get_contents($content), '<span>'); |
||
502 | } |
||
503 | $content = str_replace("\r\n", "\n", $content); // Unify newlines (because the output also only uses \n) |
||
504 | $template = explode('|', $content); |
||
505 | |||
506 | for ($i = 0; $i < count($template); $i++) { |
||
507 | $this->template[$i] = $template[$i]; |
||
508 | } |
||
509 | } |
||
510 | |||
511 | /** |
||
512 | * Starts parsing from URL |
||
513 | * @param string $url |
||
514 | * @access public |
||
515 | * @version 1.0 |
||
516 | */ |
||
517 | function parse_from_url($url) { |
||
520 | |||
521 | /** |
||
522 | * Checks if there is a token at the current position |
||
523 | * @param string $string |
||
524 | * @param integer $i |
||
525 | * @access public |
||
526 | * @version 1.11 |
||
527 | */ |
||
528 | function is_token(&$string, $i) { |
||
531 | |||
532 | /** |
||
533 | * Parses CSS in $string. The code is saved as array in $this->css |
||
534 | * @param string $string the CSS code |
||
535 | * @access public |
||
536 | * @return bool |
||
537 | * @version 1.1 |
||
538 | */ |
||
539 | function parse($string) { |
||
937 | |||
938 | /** |
||
939 | * Explodes selectors |
||
940 | * @access private |
||
941 | * @version 1.0 |
||
942 | */ |
||
943 | function explode_selectors() { |
||
944 | // Explode multiple selectors |
||
945 | if ($this->get_cfg('merge_selectors') === 1) { |
||
946 | $new_sels = array(); |
||
947 | $lastpos = 0; |
||
948 | $this->sel_separate[] = strlen($this->selector); |
||
949 | foreach ($this->sel_separate as $num => $pos) { |
||
950 | if ($num == count($this->sel_separate) - 1) { |
||
951 | $pos += 1; |
||
952 | } |
||
953 | |||
954 | $new_sels[] = substr($this->selector, $lastpos, $pos - $lastpos - 1); |
||
955 | $lastpos = $pos; |
||
956 | } |
||
957 | |||
958 | if (count($new_sels) > 1) { |
||
959 | foreach ($new_sels as $selector) { |
||
960 | if (isset($this->css[$this->at][$this->selector])) { |
||
961 | $this->merge_css_blocks($this->at, $selector, $this->css[$this->at][$this->selector]); |
||
962 | } |
||
963 | } |
||
964 | unset($this->css[$this->at][$this->selector]); |
||
965 | } |
||
966 | } |
||
967 | $this->sel_separate = array(); |
||
968 | } |
||
969 | |||
970 | /** |
||
971 | * Checks if a character is escaped (and returns true if it is) |
||
972 | * @param string $string |
||
973 | * @param integer $pos |
||
974 | * @access public |
||
975 | * @return bool |
||
976 | * @version 1.02 |
||
977 | */ |
||
978 | static function escaped(&$string, $pos) { |
||
981 | |||
982 | /** |
||
983 | * Adds a property with value to the existing CSS code |
||
984 | * @param string $media |
||
985 | * @param string $selector |
||
986 | * @param string $property |
||
987 | * @param string $new_val |
||
988 | * @access private |
||
989 | * @version 1.2 |
||
990 | */ |
||
991 | function css_add_property($media, $selector, $property, $new_val) { |
||
992 | if ($this->get_cfg('preserve_css') || trim($new_val) == '') { |
||
993 | return; |
||
994 | } |
||
995 | |||
996 | $this->added = true; |
||
997 | if (isset($this->css[$media][$selector][$property])) { |
||
998 | if ((csstidy::is_important($this->css[$media][$selector][$property]) && csstidy::is_important($new_val)) || !csstidy::is_important($this->css[$media][$selector][$property])) { |
||
999 | $this->css[$media][$selector][$property] = trim($new_val); |
||
1000 | } |
||
1001 | } else { |
||
1002 | $this->css[$media][$selector][$property] = trim($new_val); |
||
1003 | } |
||
1004 | } |
||
1005 | |||
1006 | /** |
||
1007 | * Start a new media section. |
||
1008 | * Check if the media is not already known, |
||
1009 | * else rename it with extra spaces |
||
1010 | * to avoid merging |
||
1011 | * |
||
1012 | * @param string $media |
||
1013 | * @return string |
||
1014 | */ |
||
1015 | function css_new_media_section($media){ |
||
1016 | if($this->get_cfg('preserve_css')) { |
||
1017 | return $media; |
||
1018 | } |
||
1019 | |||
1020 | // if the last @media is the same as this |
||
1021 | // keep it |
||
1022 | if (!$this->css OR !is_array($this->css) OR empty($this->css)){ |
||
1023 | return $media; |
||
1024 | } |
||
1025 | end($this->css); |
||
1026 | list($at,) = each($this->css); |
||
1027 | if ($at == $media){ |
||
1028 | return $media; |
||
1029 | } |
||
1030 | while (isset($this->css[$media])) |
||
1031 | if (is_numeric($media)) |
||
1032 | $media++; |
||
1033 | else |
||
1034 | $media .= " "; |
||
1035 | return $media; |
||
1036 | } |
||
1037 | |||
1038 | /** |
||
1039 | * Start a new selector. |
||
1040 | * If already referenced in this media section, |
||
1041 | * rename it with extra space to avoid merging |
||
1042 | * except if merging is required, |
||
1043 | * or last selector is the same (merge siblings) |
||
1044 | * |
||
1045 | * never merge @font-face |
||
1046 | * |
||
1047 | * @param string $media |
||
1048 | * @param string $selector |
||
1049 | * @return string |
||
1050 | */ |
||
1051 | function css_new_selector($media,$selector){ |
||
1052 | if($this->get_cfg('preserve_css')) { |
||
1053 | return $selector; |
||
1054 | } |
||
1055 | $selector = trim($selector); |
||
1056 | if (strncmp($selector,"@font-face",10)!=0){ |
||
1057 | if ($this->settings['merge_selectors'] != false) |
||
1058 | return $selector; |
||
1059 | |||
1060 | View Code Duplication | if (!$this->css OR !isset($this->css[$media]) OR !$this->css[$media]) |
|
1061 | return $selector; |
||
1062 | |||
1063 | // if last is the same, keep it |
||
1064 | end($this->css[$media]); |
||
1065 | list($sel,) = each($this->css[$media]); |
||
1066 | if ($sel == $selector){ |
||
1067 | return $selector; |
||
1068 | } |
||
1069 | } |
||
1070 | |||
1071 | while (isset($this->css[$media][$selector])) |
||
1072 | $selector .= " "; |
||
1073 | return $selector; |
||
1074 | } |
||
1075 | |||
1076 | /** |
||
1077 | * Start a new propertie. |
||
1078 | * If already references in this selector, |
||
1079 | * rename it with extra space to avoid override |
||
1080 | * |
||
1081 | * @param string $media |
||
1082 | * @param string $selector |
||
1083 | * @param string $property |
||
1084 | * @return string |
||
1085 | */ |
||
1086 | function css_new_property($media, $selector, $property){ |
||
1087 | if($this->get_cfg('preserve_css')) { |
||
1088 | return $property; |
||
1089 | } |
||
1090 | View Code Duplication | if (!$this->css OR !isset($this->css[$media][$selector]) OR !$this->css[$media][$selector]) |
|
1091 | return $property; |
||
1092 | |||
1093 | while (isset($this->css[$media][$selector][$property])) |
||
1094 | $property .= " "; |
||
1095 | |||
1096 | return $property; |
||
1097 | } |
||
1098 | |||
1099 | /** |
||
1100 | * Adds CSS to an existing media/selector |
||
1101 | * @param string $media |
||
1102 | * @param string $selector |
||
1103 | * @param array $css_add |
||
1104 | * @access private |
||
1105 | * @version 1.1 |
||
1106 | */ |
||
1107 | function merge_css_blocks($media, $selector, $css_add) { |
||
1108 | foreach ($css_add as $property => $value) { |
||
1109 | $this->css_add_property($media, $selector, $property, $value, false); |
||
1110 | } |
||
1111 | } |
||
1112 | |||
1113 | /** |
||
1114 | * Checks if $value is !important. |
||
1115 | * @param string $value |
||
1116 | * @return bool |
||
1117 | * @access public |
||
1118 | * @version 1.0 |
||
1119 | */ |
||
1120 | static function is_important(&$value) { |
||
1123 | |||
1124 | /** |
||
1125 | * Returns a value without !important |
||
1126 | * @param string $value |
||
1127 | * @return string |
||
1128 | * @access public |
||
1129 | * @version 1.0 |
||
1130 | */ |
||
1131 | static function gvw_important($value) { |
||
1132 | if (csstidy::is_important($value)) { |
||
1133 | $value = trim($value); |
||
1134 | $value = substr($value, 0, -9); |
||
1135 | $value = trim($value); |
||
1136 | $value = substr($value, 0, -1); |
||
1142 | |||
1143 | /** |
||
1144 | * Checks if the next word in a string from pos is a CSS property |
||
1145 | * @param string $istring |
||
1146 | * @param integer $pos |
||
1147 | * @return bool |
||
1148 | * @access private |
||
1149 | * @version 1.2 |
||
1150 | */ |
||
1151 | function property_is_next($istring, $pos) { |
||
1165 | |||
1166 | /** |
||
1167 | * Checks if a property is valid |
||
1168 | * @param string $property |
||
1169 | * @return bool; |
||
1170 | * @access public |
||
1171 | * @version 1.0 |
||
1172 | */ |
||
1173 | function property_is_valid($property) { |
||
1179 | |||
1180 | /** |
||
1181 | * Accepts a list of strings (e.g., the argument to format() in a @font-face src property) |
||
1182 | * and returns a list of the strings. Converts things like: |
||
1183 | * |
||
1184 | * format(abc) => format("abc") |
||
1185 | * format(abc def) => format("abc","def") |
||
1186 | * format(abc "def") => format("abc","def") |
||
1187 | * format(abc, def, ghi) => format("abc","def","ghi") |
||
1188 | * format("abc",'def') => format("abc","def") |
||
1189 | * format("abc, def, ghi") => format("abc, def, ghi") |
||
1190 | * |
||
1191 | * @param string |
||
1192 | * @return array |
||
1193 | */ |
||
1194 | |||
1195 | function parse_string_list($value) { |
||
1242 | } |
||
1243 |