Issue #1778806 by tim.plunkett: Consider removing views_clean_css_identifier() in favor of drupal_clean_css_identifier().

8.0.x
tim.plunkett 2012-09-08 20:24:31 +02:00 committed by Tim Plunkett
parent 92e520db55
commit cabaa7bd4c
3 changed files with 5 additions and 38 deletions

View File

@ -295,7 +295,7 @@ abstract class FieldPluginBase extends HandlerBase {
$classes = explode(' ', $this->options['element_class']);
foreach ($classes as &$class) {
$class = $this->tokenize_value($class, $row_index);
$class = views_clean_css_identifier($class);
$class = drupal_clean_css_identifier($class);
}
return implode(' ', $classes);
}
@ -345,7 +345,7 @@ abstract class FieldPluginBase extends HandlerBase {
$classes = explode(' ', $this->options['element_label_class']);
foreach ($classes as &$class) {
$class = $this->tokenize_value($class, $row_index);
$class = views_clean_css_identifier($class);
$class = drupal_clean_css_identifier($class);
}
return implode(' ', $classes);
}
@ -357,7 +357,7 @@ abstract class FieldPluginBase extends HandlerBase {
$classes = explode(' ', $this->options['element_wrapper_class']);
foreach ($classes as &$class) {
$class = $this->tokenize_value($class, $row_index);
$class = views_clean_css_identifier($class);
$class = drupal_clean_css_identifier($class);
}
return implode(' ', $classes);
}

View File

@ -813,10 +813,10 @@ function template_preprocess_views_view_list(&$vars) {
$handler = $vars['view']->style_plugin;
$class = explode(' ', $handler->options['class']);
$class = array_map('views_clean_css_identifier', $class);
$class = array_map('drupal_clean_css_identifier', $class);
$wrapper_class = explode(' ', $handler->options['wrapper_class']);
$wrapper_class = array_map('views_clean_css_identifier', $wrapper_class);
$wrapper_class = array_map('drupal_clean_css_identifier', $wrapper_class);
$vars['class'] = implode(' ', $class);
$vars['wrapper_class'] = implode(' ', $wrapper_class);

View File

@ -2299,39 +2299,6 @@ function views_get_view_result($name, $display_id = NULL) {
}
}
/**
* Prepare a string for use as a valid CSS identifier (element, class or ID name).
* This function is similar to a core version but with more sane filter values.
*
* http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for valid
* CSS identifiers (including element names, classes, and IDs in selectors.)
*
* @param $identifier
* The identifier to clean.
* @param $filter
* An array of string replacements to use on the identifier.
* @return
* The cleaned identifier.
*
* @see drupal_clean_css_identifier()
*/
function views_clean_css_identifier($identifier, $filter = array(' ' => '-', '/' => '-', '[' => '-', ']' => '')) {
// By default, we filter using Drupal's coding standards.
$identifier = strtr($identifier, $filter);
// Valid characters in a CSS identifier are:
// - the hyphen (U+002D)
// - a-z (U+0030 - U+0039)
// - A-Z (U+0041 - U+005A)
// - the underscore (U+005F)
// - 0-9 (U+0061 - U+007A)
// - ISO 10646 characters U+00A1 and higher
// We strip out any character not in the above list.
$identifier = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier);
return $identifier;
}
/**
* #process callback to see if we need to check_plain() the options.
*