summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc15
-rw-r--r--includes/form.inc54
-rw-r--r--includes/locale.inc8
-rw-r--r--includes/pager.inc20
-rw-r--r--includes/tablesort.inc16
-rw-r--r--includes/theme.inc33
6 files changed, 58 insertions, 88 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 910f4028a..a7947828e 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2286,12 +2286,7 @@ function l($text, $path, array $options = array()) {
// Append active class.
if (($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) &&
(empty($options['language']) || $options['language']->language == $language->language)) {
- if (isset($options['attributes']['class'])) {
- $options['attributes']['class'] .= ' active';
- }
- else {
- $options['attributes']['class'] = 'active';
- }
+ $options['attributes']['class'][] = 'active';
}
// Remove all HTML and PHP tags from a tooltip. For best performance, we act only
@@ -3265,7 +3260,7 @@ function drupal_get_library($module, $name) {
* In a situation where a single weight column is being sorted in the table, the
* classes could be added like this (in the theme function):
* @code
- * $form['my_elements'][$delta]['weight']['#attributes']['class'] = "my-elements-weight";
+ * $form['my_elements'][$delta]['weight']['#attributes']['class'] = array('my-elements-weight');
* @endcode
*
* Each row of the table must also have a class of "draggable" in order to enable the
@@ -3274,7 +3269,7 @@ function drupal_get_library($module, $name) {
* $row = array(...);
* $rows[] = array(
* 'data' => $row,
- * 'class' => 'draggable',
+ * 'class' => array('draggable'),
* );
* @endcode
*
@@ -3292,7 +3287,7 @@ function drupal_get_library($module, $name) {
* the block regions on the admin/structure/block page), a separate subgroup class
* must also be added to differentiate the groups.
* @code
- * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = "my-elements-weight my-elements-weight-" . $region;
+ * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = array('my-elements-weight', 'my-elements-weight-' . $region);
* @endcode
*
* $group is still 'my-element-weight', and the additional $subgroup variable
@@ -4262,7 +4257,7 @@ function drupal_common_theme() {
'arguments' => array('display' => NULL),
),
'links' => array(
- 'arguments' => array('links' => NULL, 'attributes' => array('class' => 'links')),
+ 'arguments' => array('links' => NULL, 'attributes' => array('class' => array('links'))),
),
'image' => array(
'arguments' => array('path' => NULL, 'alt' => '', 'title' => '', 'attributes' => array(), 'getsize' => TRUE),
diff --git a/includes/form.inc b/includes/form.inc
index ee35a6b16..bfacdad99 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -1595,12 +1595,12 @@ function theme_fieldset($element) {
drupal_add_js('misc/collapse.js');
if (!isset($element['#attributes']['class'])) {
- $element['#attributes']['class'] = '';
+ $element['#attributes']['class'] = array();
}
- $element['#attributes']['class'] .= ' collapsible';
+ $element['#attributes']['class'][] = 'collapsible';
if (!empty($element['#collapsed'])) {
- $element['#attributes']['class'] .= ' collapsed';
+ $element['#attributes']['class'][] = 'collapsed';
}
}
$element['#attributes']['id'] = $element['#id'];
@@ -1649,8 +1649,8 @@ function theme_radio($element) {
*/
function theme_radios($element) {
$class = 'form-radios';
- if (isset($element['#attributes']['class'])) {
- $class .= ' ' . $element['#attributes']['class'];
+ if (!empty($element['#attributes']['class'])) {
+ $class .= ' ' . implode(' ', $element['#attributes']['class']);
}
$element['#children'] = '<div class="' . $class . '">' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
@@ -1666,14 +1666,14 @@ function form_process_password_confirm($element) {
'#title' => t('Password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
'#required' => $element['#required'],
- '#attributes' => array('class' => 'password-field'),
+ '#attributes' => array('class' => array('password-field')),
);
$element['pass2'] = array(
'#type' => 'password',
'#title' => t('Confirm password'),
'#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
'#required' => $element['#required'],
- '#attributes' => array('class' => 'password-confirm'),
+ '#attributes' => array('class' => array('password-confirm')),
);
$element['#element_validate'] = array('password_confirm_validate');
$element['#tree'] = TRUE;
@@ -1986,8 +1986,8 @@ function theme_checkbox($element) {
*/
function theme_checkboxes($element) {
$class = 'form-checkboxes';
- if (isset($element['#attributes']['class'])) {
- $class .= ' ' . $element['#attributes']['class'];
+ if (!empty($element['#attributes']['class'])) {
+ $class .= ' ' . implode(' ', $element['#attributes']['class']);
}
$element['#children'] = '<div class="' . $class . '">' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
@@ -2049,9 +2049,9 @@ function form_process_checkboxes($element) {
* @code
* $options = array();
* $options[0]['title'] = "A red row"
- * $options[0]['#attributes'] = array ('class' => 'red-row');
+ * $options[0]['#attributes'] = array ('class' => array('red-row'));
* $options[1]['title'] = "A blue row"
- * $options[1]['#attributes'] = array ('class' => 'blue-row');
+ * $options[1]['#attributes'] = array ('class' => array('blue-row'));
*
* $form['myselector'] = array (
* '#type' => 'tableselect',
@@ -2278,7 +2278,7 @@ function form_process_vertical_tabs($element, &$form_state) {
$element[$name . '__active_tab'] = array(
'#type' => 'hidden',
'#default_value' => $element['#default_tab'],
- '#attributes' => array('class' => 'vertical-tabs-active-tab'),
+ '#attributes' => array('class' => array('vertical-tabs-active-tab')),
);
return $element;
@@ -2331,13 +2331,7 @@ function theme_submit($element) {
* @ingroup themeable
*/
function theme_button($element) {
- // Make sure not to overwrite classes.
- if (isset($element['#attributes']['class'])) {
- $element['#attributes']['class'] = 'form-' . $element['#button_type'] . ' ' . $element['#attributes']['class'];
- }
- else {
- $element['#attributes']['class'] = 'form-' . $element['#button_type'];
- }
+ $element['#attributes']['class'][] = 'form-' . $element['#button_type'];
return '<input type="submit" ' . (empty($element['#name']) ? '' : 'name="' . $element['#name'] . '" ') . 'id="' . $element['#id'] . '" value="' . check_plain($element['#value']) . '" ' . drupal_attributes($element['#attributes']) . " />\n";
}
@@ -2353,13 +2347,7 @@ function theme_button($element) {
* @ingroup themeable
*/
function theme_image_button($element) {
- // Make sure not to overwrite classes.
- if (isset($element['#attributes']['class'])) {
- $element['#attributes']['class'] = 'form-' . $element['#button_type'] . ' ' . $element['#attributes']['class'];
- }
- else {
- $element['#attributes']['class'] = 'form-' . $element['#button_type'];
- }
+ $element['#attributes']['class'][] = 'form-' . $element['#button_type'];
return '<input type="image" name="' . $element['#name'] . '" ' .
(!empty($element['#value']) ? ('value="' . check_plain($element['#value']) . '" ') : '') .
@@ -2594,16 +2582,18 @@ function theme_form_element($element) {
* Array of new class names to be added.
*/
function _form_set_class(&$element, $class = array()) {
+ if (!empty($class)) {
+ if (!isset($element['#attributes']['class'])) {
+ $element['#attributes']['class'] = array();
+ }
+ $element['#attributes']['class'] = array_merge($element['#attributes']['class'], $class);
+ }
if ($element['#required']) {
- $class[] = 'required';
+ $element['#attributes']['class'][] = 'required';
}
if (form_get_error($element)) {
- $class[] = 'error';
- }
- if (isset($element['#attributes']['class'])) {
- $class[] = $element['#attributes']['class'];
+ $element['#attributes']['class'][] = 'error';
}
- $element['#attributes']['class'] = implode(' ', $class);
}
/**
diff --git a/includes/locale.inc b/includes/locale.inc
index e8f3998ed..8e803eb61 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -46,7 +46,7 @@ function locale_languages_overview_form() {
$form['weight'][$langcode] = array(
'#type' => 'weight',
'#default_value' => $language->weight,
- '#attributes' => array('class' => 'language-order-weight'),
+ '#attributes' => array('class' => array('language-order-weight')),
);
$form['name'][$langcode] = array('#markup' => check_plain($language->name));
$form['native'][$langcode] = array('#markup' => check_plain($language->native));
@@ -91,7 +91,7 @@ function theme_locale_languages_overview_form($form) {
drupal_render($form['weight'][$key]),
l(t('edit'), 'admin/config/regional/language/edit/' . $key) . (($key != 'en' && $key != $default->language) ? ' ' . l(t('delete'), 'admin/config/regional/language/delete/' . $key) : '')
),
- 'class' => 'draggable'
+ 'class' => array('draggable'),
);
}
}
@@ -2303,8 +2303,8 @@ function _locale_translate_seek() {
array('data' => check_plain(truncate_utf8($string['source'], 150, FALSE, TRUE)) . '<br /><small>' . $string['location'] . '</small>'),
$string['context'],
array('data' => _locale_translate_language_list($string['languages'], $limit_language), 'align' => 'center'),
- array('data' => l(t('edit'), "admin/config/regional/translate/edit/$lid", array('query' => drupal_get_destination())), 'class' => 'nowrap'),
- array('data' => l(t('delete'), "admin/config/regional/translate/delete/$lid", array('query' => drupal_get_destination())), 'class' => 'nowrap'),
+ array('data' => l(t('edit'), "admin/config/regional/translate/edit/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
+ array('data' => l(t('delete'), "admin/config/regional/translate/delete/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
);
}
diff --git a/includes/pager.inc b/includes/pager.inc
index 2b6a03291..26b9eb833 100644
--- a/includes/pager.inc
+++ b/includes/pager.inc
@@ -298,13 +298,13 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan
if ($pager_total[$element] > 1) {
if ($li_first) {
$items[] = array(
- 'class' => 'pager-first',
+ 'class' => array('pager-first'),
'data' => $li_first,
);
}
if ($li_previous) {
$items[] = array(
- 'class' => 'pager-previous',
+ 'class' => array('pager-previous'),
'data' => $li_previous,
);
}
@@ -313,7 +313,7 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan
if ($i != $pager_max) {
if ($i > 1) {
$items[] = array(
- 'class' => 'pager-ellipsis',
+ 'class' => array('pager-ellipsis'),
'data' => '…',
);
}
@@ -321,26 +321,26 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan
for (; $i <= $pager_last && $i <= $pager_max; $i++) {
if ($i < $pager_current) {
$items[] = array(
- 'class' => 'pager-item',
+ 'class' => array('pager-item'),
'data' => theme('pager_previous', $i, $element, ($pager_current - $i), $parameters),
);
}
if ($i == $pager_current) {
$items[] = array(
- 'class' => 'pager-current',
+ 'class' => array('pager-current'),
'data' => $i,
);
}
if ($i > $pager_current) {
$items[] = array(
- 'class' => 'pager-item',
+ 'class' => array('pager-item'),
'data' => theme('pager_next', $i, $element, ($i - $pager_current), $parameters),
);
}
}
if ($i < $pager_max) {
$items[] = array(
- 'class' => 'pager-ellipsis',
+ 'class' => array('pager-ellipsis'),
'data' => '…',
);
}
@@ -348,17 +348,17 @@ function theme_pager($tags = array(), $element = 0, $parameters = array(), $quan
// End generation.
if ($li_next) {
$items[] = array(
- 'class' => 'pager-next',
+ 'class' => array('pager-next'),
'data' => $li_next,
);
}
if ($li_last) {
$items[] = array(
- 'class' => 'pager-last',
+ 'class' => array('pager-last'),
'data' => $li_last,
);
}
- return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
+ return theme('item_list', $items, NULL, 'ul', array('class' => array('pager')));
}
}
diff --git a/includes/tablesort.inc b/includes/tablesort.inc
index e6a7b785a..8259a9af4 100644
--- a/includes/tablesort.inc
+++ b/includes/tablesort.inc
@@ -185,12 +185,7 @@ function tablesort_header($cell, $header, $ts) {
$title = t('sort by @s', array('@s' => $cell['data']));
if ($cell['data'] == $ts['name']) {
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
- if (isset($cell['class'])) {
- $cell['class'] .= ' active';
- }
- else {
- $cell['class'] = 'active';
- }
+ $cell['class'][] = 'active';
$image = theme('tablesort_indicator', $ts['sort']);
}
else {
@@ -228,15 +223,10 @@ function tablesort_header($cell, $header, $ts) {
function tablesort_cell($cell, $header, $ts, $i) {
if (isset($header[$i]['data']) && $header[$i]['data'] == $ts['name'] && !empty($header[$i]['field'])) {
if (is_array($cell)) {
- if (isset($cell['class'])) {
- $cell['class'] .= ' active';
- }
- else {
- $cell['class'] = 'active';
- }
+ $cell['class'][] = 'active';
}
else {
- $cell = array('data' => $cell, 'class' => 'active');
+ $cell = array('data' => $cell, 'class' => array('active'));
}
}
return $cell;
diff --git a/includes/theme.inc b/includes/theme.inc
index 50c78987b..d0adb23ed 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1389,7 +1389,7 @@ function theme_status_messages($display = NULL) {
* @return
* A string containing an unordered list of links.
*/
-function theme_links($links, $attributes = array('class' => 'links')) {
+function theme_links($links, $attributes = array('class' => array('links'))) {
global $language;
$output = '';
@@ -1400,18 +1400,18 @@ function theme_links($links, $attributes = array('class' => 'links')) {
$i = 1;
foreach ($links as $key => $link) {
- $class = $key;
+ $class = array($key);
// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
- $class .= ' first';
+ $class[] = 'first';
}
if ($i == $num_links) {
- $class .= ' last';
+ $class[] = 'last';
}
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
&& (empty($link['language']) || $link['language']->language == $language->language)) {
- $class .= ' active';
+ $class[] = 'active';
}
$output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
@@ -1519,7 +1519,7 @@ function theme_submenu($links) {
* ),
* // Row with attributes on the row and some of its cells.
* array(
- * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => 'funky'
+ * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky')
* )
* );
* @endverbatim
@@ -1541,17 +1541,17 @@ function theme_submenu($links) {
* // COLGROUP with one COL element.
* array(
* array(
- * 'class' => 'funky', // Attribute for the COL element.
+ * 'class' => array('funky'), // Attribute for the COL element.
* ),
* ),
* // Colgroup with attributes and inner COL elements.
* array(
* 'data' => array(
* array(
- * 'class' => 'funky', // Attribute for the COL element.
+ * 'class' => array('funky'), // Attribute for the COL element.
* ),
* ),
- * 'class' => 'jazzy', // Attribute for the COLGROUP element.
+ * 'class' => array('jazzy'), // Attribute for the COLGROUP element.
* ),
* );
* @endverbatim
@@ -1570,7 +1570,7 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL, $co
drupal_add_js('misc/tableheader.js');
// Add 'sticky-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
- $attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : ($attributes['class'] . ' sticky-enabled');
+ $attributes['class'][] = 'sticky-enabled';
}
$output = '<table' . drupal_attributes($attributes) . ">\n";
@@ -1656,12 +1656,7 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL, $co
if (count($cells)) {
// Add odd/even class
$class = $flip[$class];
- if (isset($attributes['class'])) {
- $attributes['class'] .= ' ' . $class;
- }
- else {
- $attributes['class'] = $class;
- }
+ $attributes['class'][] = $class;
// Build row
$output .= ' <tr' . drupal_attributes($attributes) . '>';
@@ -1686,7 +1681,7 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL, $co
function theme_table_select_header_cell() {
drupal_add_js('misc/tableselect.js');
- return array('class' => 'select-all');
+ return array('class' => array('select-all'));
}
/**
@@ -1778,10 +1773,10 @@ function theme_item_list($items = array(), $title = NULL, $type = 'ul', $attribu
$data .= theme_item_list($children, NULL, $type, $attributes); // Render nested list
}
if ($i == 0) {
- $attributes['class'] = empty($attributes['class']) ? 'first' : ($attributes['class'] . ' first');
+ $attributes['class'][] = 'first';
}
if ($i == $num_items - 1) {
- $attributes['class'] = empty($attributes['class']) ? 'last' : ($attributes['class'] . ' last');
+ $attributes['class'][] = 'last';
}
$output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>\n";
}