summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-02 14:56:32 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-02 14:56:32 +0000
commit92760988b9decb01831ba89bcc54056a702c3836 (patch)
tree4a27865ed1737d832e82a575521940503147cd43 /includes
parente7dedc4330f3d7bbc4fd861a4e5619d780bcca6c (diff)
downloadbrdo-92760988b9decb01831ba89bcc54056a702c3836.tar.gz
brdo-92760988b9decb01831ba89bcc54056a702c3836.tar.bz2
- Patch #648410 by Dave Reid: standardize add 'empty' row functionality to all tables.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc2
-rw-r--r--includes/form.inc11
-rw-r--r--includes/locale.inc11
-rw-r--r--includes/theme.inc8
4 files changed, 14 insertions, 18 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 9f8b6a66b..ee1b10c2c 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -5427,7 +5427,7 @@ function drupal_common_theme() {
'variables' => array('links' => NULL),
),
'table' => array(
- 'variables' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => TRUE),
+ 'variables' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => TRUE, 'empty' => ''),
),
'table_select_header_cell' => array(
'variables' => array(),
diff --git a/includes/form.inc b/includes/form.inc
index 39090a349..6e992e5c6 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -2338,6 +2338,7 @@ function theme_container($variables) {
function theme_tableselect($variables) {
$element = $variables['element'];
$rows = array();
+ $header = $element['#header'];
if (!empty($element['#options'])) {
// Generate a table row for each selectable item in #options.
foreach ($element['#options'] as $key => $value) {
@@ -2360,15 +2361,9 @@ function theme_tableselect($variables) {
// Add an empty header or a "Select all" checkbox to provide room for the
// checkboxes/radios in the first table column.
$first_col = $element['#js_select'] ? array(theme('table_select_header_cell')) : array('');
- $header = array_merge($first_col, $element['#header']);
+ $header = array_merge($first_col, $header);
}
- else {
- // If there are no selectable options, display the empty text over the
- // entire width of the table.
- $header = $element['#header'];
- $rows[] = array(array('data' => $element['#empty'], 'colspan' => count($header)));
- }
- return theme('table', array('header' => $header, 'rows' => $rows));
+ return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => $element['#empty']));
}
/**
diff --git a/includes/locale.inc b/includes/locale.inc
index 1dae9c722..fe01cbd3d 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -2801,15 +2801,8 @@ function _locale_translate_seek() {
);
}
- if (count($rows)) {
- $output .= theme('table', array('header' => $header, 'rows' => $rows));
- if ($pager = theme('pager', array('tags' => NULL))) {
- $output .= $pager;
- }
- }
- else {
- $output .= t('No strings found for your search.');
- }
+ $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No strings available.')));
+ $output .= theme('pager', array('tags' => NULL));
return $output;
}
diff --git a/includes/theme.inc b/includes/theme.inc
index 63af79711..635b2b0bb 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -1706,6 +1706,8 @@ function theme_submenu($variables) {
* within a table. For example, one may easily group three columns and
* apply same background style to all.
* - sticky: Use a "sticky" table header.
+ * - empty: The message to display in an extra row if table does not have any
+ * rows.
*
* @return
* An HTML string representing the table.
@@ -1717,6 +1719,7 @@ function theme_table($variables) {
$caption = $variables['caption'];
$colgroups = $variables['colgroups'];
$sticky = $variables['sticky'];
+ $empty = $variables['empty'];
// Add sticky headers, if applicable.
if (count($header) && $sticky) {
@@ -1784,6 +1787,11 @@ function theme_table($variables) {
$ts = array();
}
+ // Add the 'empty' row message if available.
+ if (!count($rows) && $empty) {
+ $rows[] = array(array('data' => $empty, 'colspan' => count($header), 'class' => array('empty', 'message')));
+ }
+
// Format the table rows:
if (count($rows)) {
$output .= "<tbody>\n";