function theme_remove_duplicates_tableselect in Remove Duplicates 7
Implements hook_theme().
Remove Duplicates tableselect theme function implementation.
1 theme call to theme_remove_duplicates_tableselect()
- remove_duplicates_element_info in ./
remove_duplicates.module - Implements hook_element_info().
File
- ./
remove_duplicates.module, line 1815 - Remove duplicate nodes according to node fields or Custom fields.
Code
function theme_remove_duplicates_tableselect($variables) {
$element = $variables['element'];
if (isset($element['#options']) && is_array($element['#options']['#tables'])) {
$rows = array();
if (!empty($element['#options']['#header']) && is_array($element['#options']['#header'])) {
// Add an empty header to provide room for
// the checkboxes in the first table column.
array_unshift($element['#options']['#header'], array(
'header' => TRUE,
'data' => array(),
));
$rows[] = $element['#options']['#header'];
}
foreach ($element['#options']['#tables'] as $sub_element) {
// Add an empty header to provide room for
// the checkboxes in the first table column.
if (!empty($sub_element['#header']) && is_array($sub_element['#header'])) {
if (!empty($sub_element['#header']['#prefix']) && is_array($sub_element['#header']['#prefix'])) {
array_unshift($sub_element['#header']['#prefix'], array(
'header' => TRUE,
'data' => array(),
));
$rows[] = $sub_element['#header']['#prefix'];
}
if (!empty($sub_element['#header']['#root']) && is_array($sub_element['#header']['#root'])) {
$header = $sub_element['#header']['#root'];
foreach ($sub_element['#header']['#root'] as $fieldname => $title) {
$sub_element['#header']['#root'][$fieldname] = array(
'header' => TRUE,
'data' => $title,
);
}
array_unshift($sub_element['#header']['#root'], array(
'header' => TRUE,
'data' => array(),
));
$rows[] = $sub_element['#header']['#root'];
}
}
if (!empty($sub_element['#options']) && is_array($sub_element['#options'])) {
// Generate a table row for each selectable item in #options.
foreach (element_children($sub_element['#options']) as $key) {
$row = array(
'data' => array(),
);
if (isset($sub_element['#options'][$key]['#attributes'])) {
$row += $sub_element['#options'][$key]['#attributes'];
}
// Render the checkbox / radio element.
$row['data'][] = drupal_render($element[$key]);
// As theme_table only maps header and row columns by order,
// create the correct order by iterating over the header fields.
if (!empty($header)) {
foreach ($header as $fieldname => $title) {
$row['data'][] = $sub_element['#options'][$key][$fieldname];
}
}
$rows[] = $row;
}
}
}
return theme('table', array(
'rows' => $rows,
'attributes' => $element['#attributes'],
));
}
}