';
if (!empty($element['#view_nodes']) && is_array($element['#view_nodes'])) {
$rows = array();
foreach ($element['#view_nodes'] as $node) {
$arow = array();
$arow[] = array('data' => ($multiple ? theme('checkbox', $element[$node->nid]) : theme('radio', $element[$node->nid])));
foreach ($view->field as $field) {
if ($fields[$field['id']]['visible'] !== FALSE) {
$cell['data'] = views_theme_field('views_handle_field', $field['queryname'],
$fields, $field, $node, $view);
$cell['class'] = "view-field ". views_css_safe('view-field-'. $field['queryname']);
$arow[] = $cell;
}
}
$rows[] = $arow;
}
}
else {
$rows[] = array(array('data' => t('No posts available.'), 'colspan' => (count($view->table_header) + 1)));
}
// Add a column to the header to accomodate our selection column, and include
// the 'select all' checkbox if we are using checkboxes.
$extra = $multiple ? theme('table_select_header_cell') : ' ';
if (is_array($view->table_header)) {
array_unshift($view->table_header, $extra);
}
// Add the first row as option to select all records across all pages.
if ($view->use_pager) {
$arow = array(
array(
'data' => ''. t('All !nodes nodes on this page are selected.', array('!nodes' => count($element['#view_nodes'])))
.' '
.''. t('All !nodes nodes in this view are selected.', array('!nodes' => $view->total_rows))
.' ',
'class' => 'view-field view-field-select-all',
'colspan' => count($view->table_header) + 1,
),
);
array_unshift($rows, $arow);
}
$output .= theme('views_form_table', $view->table_header, $rows);
$output .= theme('hidden', $element['select_all']);
$output .= '
';
return theme('form_element', $element, $output);
}
/**
* Default views_node_selector form table theme function.
*/
function theme_views_form_table($header, $rows) {
return theme('table', $header, $rows);
}
/**
* True views_node_selector form element expansion function.
*
* @see views_bulk_operations_elements() in views_bulk_operations.module
* @see expand_views_node_selector() in views_bulk_operations.module
* @see form_builder() in Drupal core includes/form.inc
*/
function _expand_views_node_selector($element){
$options = array();
foreach ($element['#view_nodes'] as $node) {
$options[$node->nid] = '';
}
$element['#options'] = $options;
if ($element['#multiple']) {
$element = expand_checkboxes($element);
}
else {
// Handle the case of an array of default values for radios.
if (is_array($element['#default_value'])) {
$element['#default_value'] = current($element['#default_value']);
}
$element = expand_radios($element);
}
// Check for disabled items
foreach ($options as $nid => $v) {
if (in_array($nid, $element['#disabled_nodes'])) {
$element[$nid]['#disabled'] = TRUE;
}
// Disable the theme function for the radio/checkbox elements so that
// the output can be built in theme_views_node_selector.
$element[$nid]['#theme'] = '';
// Add CSS class.
$element[$nid]['#attributes']['class'] = 'view-field';
}
// Ummm unset the #options so that FAPI doesn't give me the "Illegal choice %choice in !name element" error.
unset($element['#options']);
$element['select_all'] = array('#type' => 'hidden', '#default_value' => @$element['#value']['select_all']);
return $element;
}
/**
* Pre-process default values when using checkboxes.
*
* @see form_builder() in Drupal core includes/form.inc
*/
function views_node_selector_value(&$form) {
if ($form['#multiple']) {
checkboxes_value($form);
}
}