From cabaa7bd4cb8f44d8f113e2063dc56243ef1641b Mon Sep 17 00:00:00 2001 From: "tim.plunkett" Date: Sat, 8 Sep 2012 20:24:31 +0200 Subject: [PATCH] Issue #1778806 by tim.plunkett: Consider removing views_clean_css_identifier() in favor of drupal_clean_css_identifier(). --- .../Plugin/views/field/FieldPluginBase.php | 6 ++-- theme/theme.inc | 4 +-- views.module | 33 ------------------- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php b/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php index 680bbce4a7e..f6c4a2bee9b 100644 --- a/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php +++ b/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php @@ -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); } diff --git a/theme/theme.inc b/theme/theme.inc index 075d7cdd40e..8f0c034dea0 100644 --- a/theme/theme.inc +++ b/theme/theme.inc @@ -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); diff --git a/views.module b/views.module index 69cfde617f1..0dbab5f4720 100644 --- a/views.module +++ b/views.module @@ -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. *