From dd571ffe34ef4202a3bd95fb5a36ddbce0fb3096 Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Mon, 5 Oct 2009 01:18:26 +0000
Subject: [PATCH] #464862 follow-up by kkaefer: Rename drupal_css_class() to
 drupal_html_class_X(), for better accuracy.

---
 includes/common.inc                  | 20 ++++++++++----------
 includes/form.inc                    | 16 ++++++++--------
 includes/theme.inc                   |  4 ++--
 modules/block/block.module           |  2 +-
 modules/filter/filter.module         |  2 +-
 modules/node/node.module             |  2 +-
 modules/profile/profile.test         |  4 ++--
 modules/simpletest/tests/common.test | 28 ++++++++++++++--------------
 8 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/includes/common.inc b/includes/common.inc
index 878e8106de2f..e6630ca79624 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3095,23 +3095,23 @@ function drupal_clear_css_cache() {
 }
 
 /**
- * Prepare a string for use as a valid CSS identifier (element, class or ID selector).
+ * Prepare a string for use as a valid identifier (element, class or ID name).
  *
  * http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for valid
- * CSS identifiers (including element names, classes, and IDs in selectors.)
+ * identifiers (including element names, classes, and IDs in selectors.)
  *
  * @param $identifier
- *   The CSS identifier to clean.
+ *   The identifier to clean.
  * @param $filter
  *   An array of string replacements to use on the identifier.
  * @return
  *   The cleaned identifier.
  */
-function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '[' => '-', ']' => '')) {
+function drupal_clean_html_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '[' => '-', ']' => '')) {
   // By default, we filter using Drupal's coding standards.
   $identifier = strtr($identifier, $filter);
 
-  // Valid characters in a CSS identifier are:
+  // Valid characters in a identifier are:
   // - the hyphen (U+002D)
   // - a-z (U+0030 - U+0039)
   // - A-Z (U+0041 - U+005A)
@@ -3125,7 +3125,7 @@ function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_
 }
 
 /**
- * Prepare a string for use as a valid CSS class name.
+ * Prepare a string for use as a valid class name.
  *
  * Do not pass one string containing multiple classes as they will be
  * incorrectly concatenated with dashes, i.e. "one two" will become "one-two".
@@ -3135,8 +3135,8 @@ function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_
  * @return
  *   The cleaned class name.
  */
-function drupal_css_class($class) {
-  return drupal_clean_css_identifier(drupal_strtolower($class));
+function drupal_html_class($class) {
+  return drupal_clean_html_identifier(drupal_strtolower($class));
 }
 
 /**
@@ -3147,9 +3147,9 @@ function drupal_css_class($class) {
  * @return
  *   The cleaned ID.
  */
-function drupal_css_id($id) {
+function drupal_html_id($id) {
   $seen_ids = &drupal_static(__FUNCTION__, array());
-  $id = drupal_clean_css_identifier(drupal_strtolower($id));
+  $id = drupal_clean_html_identifier(drupal_strtolower($id));
 
   // Ensure IDs are unique. The first occurrence is held but left alone.
   // Subsequent occurrences get a number appended to them. This incrementing
diff --git a/includes/form.inc b/includes/form.inc
index ce7171e28ba3..21813389db74 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -547,12 +547,12 @@ function drupal_process_form($form_id, &$form, &$form_state) {
   if ($form_state['process_input']) {
     drupal_validate_form($form_id, $form, $form_state);
 
-    // drupal_css_id() maintains a cache of element IDs it has seen,
+    // drupal_html_id() maintains a cache of element IDs it has seen,
     // so it can prevent duplicates. We want to be sure we reset that
     // cache when a form is processed, so scenarios that result in
     // the form being built behind the scenes and again for the
     // browser don't increment all the element IDs needlessly.
-    drupal_static_reset('drupal_css_id');
+    drupal_static_reset('drupal_html_id');
 
     if ($form_state['submitted'] && !form_get_errors() && !$form_state['rebuild']) {
       // Execute form submit handlers.
@@ -636,7 +636,7 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
   elseif (isset($user->uid) && $user->uid && !$form_state['programmed']) {
     $form['#token'] = $form_id;
     $form['form_token'] = array(
-      '#id' => drupal_css_id('edit-' . $form_id . '-form-token'),
+      '#id' => drupal_html_id('edit-' . $form_id . '-form-token'),
       '#type' => 'token',
       '#default_value' => drupal_get_token($form['#token']),
     );
@@ -646,11 +646,11 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
     $form['form_id'] = array(
       '#type' => 'hidden',
       '#value' => $form_id,
-      '#id' => drupal_css_id("edit-$form_id"),
+      '#id' => drupal_html_id("edit-$form_id"),
     );
   }
   if (!isset($form['#id'])) {
-    $form['#id'] = drupal_css_id($form_id);
+    $form['#id'] = drupal_html_id($form_id);
   }
 
   $form += element_info('form');
@@ -1046,7 +1046,7 @@ function form_builder($form_id, $element, &$form_state) {
   }
 
   if (!isset($element['#id'])) {
-    $element['#id'] = drupal_css_id('edit-' . implode('-', $element['#parents']));
+    $element['#id'] = drupal_html_id('edit-' . implode('-', $element['#parents']));
   }
   // Handle input elements.
   if (!empty($element['#input'])) {
@@ -1919,7 +1919,7 @@ function form_process_radios($element) {
           '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
           '#attributes' => $element['#attributes'],
           '#parents' => $element['#parents'],
-          '#id' => drupal_css_id('edit-' . implode('-', $parents_for_id)),
+          '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
           '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
         );
       }
@@ -2235,7 +2235,7 @@ function form_process_tableselect($element) {
             '#default_value' => ($element['#default_value'] == $key) ? $key : NULL,
             '#attributes' => $element['#attributes'],
             '#parents' => $element['#parents'],
-            '#id' => drupal_css_id('edit-' . implode('-', $parents_for_id)),
+            '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
             '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
           );
         }
diff --git a/includes/theme.inc b/includes/theme.inc
index 736662db6a86..73fdf8575142 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -2136,14 +2136,14 @@ function template_preprocess_html(&$variables) {
         // Add current suggestion to page classes to make it possible to theme
         // the page depending on the current page type (e.g. node, admin, user,
         // etc.) as well as more specific data like node-12 or node-edit.
-        $variables['classes_array'][] = drupal_css_class($suggestion);
+        $variables['classes_array'][] = drupal_html_class($suggestion);
       }
     }
   }
   
   // If on an individual node page, add the node type to body classes.
   if ($node = menu_get_object()) {
-    $variables['classes_array'][] = drupal_css_class('node-type-' . $node->type);
+    $variables['classes_array'][] = drupal_html_class('node-type-' . $node->type);
   }
 
   // RDFa allows annotation of XHTML pages with RDF data, while GRDDL provides
diff --git a/modules/block/block.module b/modules/block/block.module
index 00b85cb07474..2e84ab94b254 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -823,7 +823,7 @@ function template_preprocess_block(&$variables) {
   // Create the $content variable that templates expect.
   $variables['content'] = $variables['elements']['#children'];
 
-  $variables['classes_array'][] = drupal_css_class('block-' . $variables['block']->module);
+  $variables['classes_array'][] = drupal_html_class('block-' . $variables['block']->module);
 
   $variables['template_files'][] = 'block-' . $variables['block']->region;
   $variables['template_files'][] = 'block-' . $variables['block']->module;
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 142482731085..b5da0aa66253 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -746,7 +746,7 @@ function filter_form($selected_format = NULL, $weight = NULL, $parents = array('
 
   drupal_add_js('misc/form.js');
   drupal_add_css(drupal_get_path('module', 'filter') . '/filter.css');
-  $element_id = drupal_css_id('edit-' . implode('-', $parents));
+  $element_id = drupal_html_id('edit-' . implode('-', $parents));
 
   $form = array(
     '#type' => 'fieldset',
diff --git a/modules/node/node.module b/modules/node/node.module
index 20187b30bd18..c0cf14b68304 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1195,7 +1195,7 @@ function template_preprocess_node(&$variables) {
   }
 
   // Gather node classes.
-  $variables['classes_array'][] = drupal_css_class('node-' . $node->type);
+  $variables['classes_array'][] = drupal_html_class('node-' . $node->type);
   if ($variables['promote']) {
     $variables['classes_array'][] = 'node-promoted';
   }
diff --git a/modules/profile/profile.test b/modules/profile/profile.test
index 507d5ebd371c..4ea8ee51a387 100644
--- a/modules/profile/profile.test
+++ b/modules/profile/profile.test
@@ -266,8 +266,8 @@ class ProfileTestAutocomplete extends ProfileTestCase {
     $this->setProfileField($field, $field['value']);
 
     // Set some html for what we want to see in the page output later.
-    $autocomplete_html = '<input class="autocomplete" type="hidden" id="' . drupal_css_id('edit-' . $field['form_name'] . '-autocomplete') . '" value="' . url('profile/autocomplete/' . $field['fid'], array('absolute' => TRUE)) . '" disabled="disabled" />';
-    $field_html = '<input type="text" maxlength="255" name="' . $field['form_name'] . '" id="' . drupal_css_id('edit-' . $field['form_name']) . '" size="60" value="' . $field['value'] . '" class="form-text form-autocomplete required" />';
+    $autocomplete_html = '<input class="autocomplete" type="hidden" id="' . drupal_html_id('edit-' . $field['form_name'] . '-autocomplete') . '" value="' . url('profile/autocomplete/' . $field['fid'], array('absolute' => TRUE)) . '" disabled="disabled" />';
+    $field_html = '<input type="text" maxlength="255" name="' . $field['form_name'] . '" id="' . drupal_html_id('edit-' . $field['form_name']) . '" size="60" value="' . $field['value'] . '" class="form-text form-autocomplete required" />';
 
     // Check that autocompletion html is found on the user's profile edit page.
     $this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 72f92820d7b5..e7b5af694e4b 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -579,49 +579,49 @@ class DrupalCSSIdentifierTestCase extends DrupalUnitTestCase {
   public static function getInfo() {
     return array(
       'name' => 'CSS identifiers',
-      'description' => 'Test the functions drupal_css_class() and drupal_css_id() for expected behavior',
+      'description' => 'Test the functions drupal_html_class() and drupal_html_id() for expected behavior',
       'group' => 'System',
     );
   }
 
   /**
-   * Tests that drupal_css_class() cleans the class name properly.
+   * Tests that drupal_html_class() cleans the class name properly.
    */
   function testDrupalCleanCSSIdentifier() {
     // Verify that no valid ASCII characters are stripped from the class name.
     $class = 'abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789';
-    $this->assertIdentical(drupal_clean_css_identifier($class, array()), $class, t('Verify valid ASCII characters pass through.'));
+    $this->assertIdentical(drupal_clean_html_identifier($class, array()), $class, t('Verify valid ASCII characters pass through.'));
 
     // Verify that no valid UTF-8 characters are stripped from the class name.
     $class = '¡¢£¤¥';
-    $this->assertIdentical(drupal_clean_css_identifier($class, array()), $class, t('Verify valid UTF-8 characters pass through.'));
+    $this->assertIdentical(drupal_clean_html_identifier($class, array()), $class, t('Verify valid UTF-8 characters pass through.'));
 
     // Verify that invalid characters (including non-breaking space) are stripped from the class name.
-    $this->assertIdentical(drupal_clean_css_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ class', array()), 'invalidclass', t('Strip invalid characters.'));
+    $this->assertIdentical(drupal_clean_html_identifier('invalid !"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ class', array()), 'invalidclass', t('Strip invalid characters.'));
   }
 
   /**
-   * Tests that drupal_css_class() cleans the class name properly.
+   * Tests that drupal_html_class() cleans the class name properly.
    */
   function testDrupalCSSClass() {
     // Verify Drupal coding standards are enforced.
-    $this->assertIdentical(drupal_css_class('CLASS NAME_[Ü]'), 'class-name--ü', t('Enforce Drupal coding standards.'));
+    $this->assertIdentical(drupal_html_class('CLASS NAME_[Ü]'), 'class-name--ü', t('Enforce Drupal coding standards.'));
   }
 
   /**
-   * Tests that drupal_css_id() cleans the id name properly.
+   * Tests that drupal_html_id() cleans the id name properly.
    */
   function testDrupalCSSId() {
     // Verify Drupal coding standards are enforced.
-    $this->assertIdentical(drupal_css_id('ID NAME_[Ü]'), 'id-name--ü', t('Enforce Drupal coding standards.'));
+    $this->assertIdentical(drupal_html_id('ID NAME_[Ü]'), 'id-name--ü', t('Enforce Drupal coding standards.'));
 
     // Reset the static cache so we can ensure the unique id count is at zero.
-    drupal_static_reset('drupal_css_id');
+    drupal_static_reset('drupal_html_id');
 
     // Clean up IDs with invalid starting characters.
-    $this->assertIdentical(drupal_css_id('test-unique-id'), 'test-unique-id', t('Test the uniqueness of IDs #1.'));
-    $this->assertIdentical(drupal_css_id('test-unique-id'), 'test-unique-id-2', t('Test the uniqueness of IDs #2.'));
-    $this->assertIdentical(drupal_css_id('test-unique-id'), 'test-unique-id-3', t('Test the uniqueness of IDs #3.'));
+    $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id', t('Test the uniqueness of IDs #1.'));
+    $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id-2', t('Test the uniqueness of IDs #2.'));
+    $this->assertIdentical(drupal_html_id('test-unique-id'), 'test-unique-id-3', t('Test the uniqueness of IDs #3.'));
   }
 }
 
@@ -1498,7 +1498,7 @@ class DrupalAttributesUnitTest extends DrupalUnitTestCase {
   }
 
   /**
-   * Tests that drupal_css_class() cleans the class name properly.
+   * Tests that drupal_html_class() cleans the class name properly.
    */
   function testDrupalAttributes() {
     // Verify that special characters are HTML encoded.
-- 
GitLab