Commit cabaa7bd authored by tim.plunkett's avatar tim.plunkett Committed by tim.plunkett

Issue #1778806 by tim.plunkett: Consider removing views_clean_css_identifier()...

Issue #1778806 by tim.plunkett: Consider removing views_clean_css_identifier() in favor of drupal_clean_css_identifier().
parent 92e520db
......@@ -295,7 +295,7 @@ function element_classes($row_index = NULL) {
$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 @@ function element_label_classes($row_index = NULL) {
$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 @@ function element_wrapper_classes($row_index = NULL) {
$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);
}
......
......@@ -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);
......
......@@ -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.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment