Révision 7e72b748
Ajouté par Assos Assos il y a plus de 6 ans
drupal7/sites/all/modules/ctools/includes/css.inc | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
/* |
|
3 |
/**
|
|
4 | 4 |
* @file |
5 | 5 |
* CSS filtering functions. Contains a disassembler, filter, compressor, and |
6 | 6 |
* decompressor. |
... | ... | |
149 | 149 |
* |
150 | 150 |
* @param $css |
151 | 151 |
* A chunk of well-formed CSS text to cache. |
152 |
* @param $filter |
|
152 |
* @param bool $filter
|
|
153 | 153 |
* If TRUE the css will be filtered. If FALSE the text will be cached |
154 | 154 |
* as-is. |
155 | 155 |
* |
156 |
* @return $filename
|
|
156 |
* @return string
|
|
157 | 157 |
* The filename the CSS will be cached in. |
158 | 158 |
*/ |
159 | 159 |
function ctools_css_cache($css, $filter = TRUE) { |
... | ... | |
164 | 164 |
// Create the css/ within the files folder. |
165 | 165 |
$path = 'public://ctools/css'; |
166 | 166 |
if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) { |
167 |
// if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) { |
|
168 | 167 |
drupal_set_message(t('Unable to create CTools CSS cache directory. Check the permissions on your files directory.'), 'error'); |
169 | 168 |
return; |
170 | 169 |
} |
... | ... | |
213 | 212 |
* An array of css data, as produced by @see ctools_css_disassemble() |
214 | 213 |
* disassembler and the @see ctools_css_filter_css_data() filter. |
215 | 214 |
* |
216 |
* @return string $css
|
|
215 |
* @return string |
|
217 | 216 |
* css optimized for human viewing. |
218 | 217 |
*/ |
219 | 218 |
function ctools_css_assemble($css_data) { |
... | ... | |
243 | 242 |
* An array of css data, as produced by @see ctools_css_disassemble() |
244 | 243 |
* disassembler and the @see ctools_css_filter_css_data() filter. |
245 | 244 |
* |
246 |
* @return string $css
|
|
245 |
* @return string |
|
247 | 246 |
* css optimized for use. |
248 | 247 |
*/ |
249 | 248 |
function ctools_css_compress($css_data) { |
... | ... | |
279 | 278 |
* @param string $css |
280 | 279 |
* A string containing the css to be disassembled. |
281 | 280 |
* |
282 |
* @return array $disassembled_css
|
|
281 |
* @return array |
|
283 | 282 |
* An array of disassembled, slightly cleaned-up/formatted css statements. |
284 | 283 |
*/ |
285 | 284 |
function ctools_css_disassemble($css) { |
... | ... | |
385 | 384 |
* An array of disassembled, filtered CSS. |
386 | 385 |
*/ |
387 | 386 |
function ctools_css_filter_css_data($css, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') { |
388 |
//function ctools_css_filter_css_data($css, &$filtered = NULL, $allowed_properties = array(), $allowed_values = array(), $allowed_values_regex = '', $disallowed_values_regex = '') { |
|
389 | 387 |
// Retrieve the default list of allowed properties if none is provided. |
390 | 388 |
$allowed_properties = !empty($allowed_properties) ? $allowed_properties : ctools_css_filter_default_allowed_properties(); |
391 | 389 |
// Retrieve the default list of allowed values if none is provided. |
... | ... | |
393 | 391 |
// Define allowed values regex if none is provided. |
394 | 392 |
$allowed_values_regex = !empty($allowed_values_regex) ? $allowed_values_regex : '/(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)/'; |
395 | 393 |
// Define disallowed url() value contents, if none is provided. |
396 |
// $disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/[url|expression]\s*\(\s*[^\s)]+?\s*\)\s*/'; |
|
397 | 394 |
$disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/(url|expression)/'; |
398 | 395 |
|
399 | 396 |
foreach ($css as $selector_str => $declaration) { |
400 | 397 |
foreach ($declaration as $property => $value) { |
401 | 398 |
if (!in_array($property, $allowed_properties)) { |
402 |
// $filtered['properties'][$selector_str][$property] = $value; |
|
399 |
// $filtered['properties'][$selector_str][$property] = $value;.
|
|
403 | 400 |
unset($css[$selector_str][$property]); |
404 | 401 |
continue; |
405 | 402 |
} |
406 | 403 |
$value = str_replace('!important', '', $value); |
407 | 404 |
if (preg_match($disallowed_values_regex, $value) || !(in_array($value, $allowed_values) || preg_match($allowed_values_regex, $value))) { |
408 |
// $filtered['values'][$selector_str][$property] = $value; |
|
405 |
// $filtered['values'][$selector_str][$property] = $value;.
|
|
409 | 406 |
unset($css[$selector_str][$property]); |
410 | 407 |
continue; |
411 | 408 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules