From dd571ffe34ef4202a3bd95fb5a36ddbce0fb3096 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Mon, 5 Oct 2009 01:18:26 +0000 Subject: #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 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index 878e8106d..e6630ca79 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 ce7171e28..21813389d 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 736662db6..73fdf8575 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 -- cgit v1.2.3