array( 'name' => t('Bulk Operations View'), 'theme' => 'views_actions_view_bulk', 'needs_fields' => true, 'weight' => -10, ), ); } function theme_views_actions_view_bulk($view, $nodes, $type) { $output = drupal_get_form('views_actions_bulk_form', $view, $nodes, $type); $output .= views_actions_version(); return $output; } function views_actions_bulk_form($view, $nodes, $type, $form_values = NULL) { $form['#multistep'] = TRUE; $step = isset($form_values) ? (int) $form_values['step'] : 1; // $form_values is sent each successive step $form['step'] = array('#type' => 'hidden', '#value' => $step + 1); $actions = actions_get_all_actions(); $operations = module_invoke_all('node_operations'); if ($step == 1) { // First step: build the form foreach ($actions as $aid => $action) { if ($action['type'] == 'Node') { $options[$aid] = $action['description'].' '.t('(action)'); } } foreach ($operations as $oid => $operation) { if ($operation['callback']) { $options[$oid] = $operation['label'].' '.t('(node operation)'); } } $form['action'] = array( '#type' => 'select', '#title' => '', '#description' => t('Please select the action to perform on the selected nodes.'), '#options' => $options, '#prefix' => '
$RCSfile: $ version: $Revision: $, $Date: $
'); } function views_actions_views_default_views() { $view = new stdClass(); $view->name = 'admin_content'; $view->description = 'View, edit and delete your site\'s content.'; $view->access = array(); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = 'Content'; $view->page_header = ''; $view->page_header_format = '1'; $view->page_footer = ''; $view->page_footer_format = '1'; $view->page_empty = 'Could not find nodes matching the criteria.'; $view->page_empty_format = '1'; $view->page_type = 'bulk'; $view->url = 'admin/content/node2'; $view->use_pager = TRUE; $view->nodes_per_page = '10'; $view->sort = array ( ); $view->argument = array ( ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'title', 'label' => 'Title', 'handler' => 'views_handler_field_nodelink_with_mark', 'options' => 'link', ), array ( 'tablename' => 'node', 'field' => 'type', 'label' => 'Type', ), array ( 'tablename' => 'users', 'field' => 'name', 'label' => 'Author', ), array ( 'tablename' => 'views_actions', 'field' => 'views_actions_field_node_status', 'label' => 'Status', ), array ( 'tablename' => 'node', 'field' => 'edit', 'label' => 'Edit', 'handler' => 'views_handler_node_edit_destination', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'filenode', ), ), array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'node', 'field' => 'promote', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'node', 'field' => 'sticky', 'operator' => '=', 'options' => '', 'value' => '1', ), ); $view->exposed_filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'label' => 'Type', 'optional' => '1', 'is_default' => '0', 'operator' => '0', 'single' => '0', ), array ( 'tablename' => 'node', 'field' => 'status', 'label' => 'Published', 'optional' => '1', 'is_default' => '0', 'operator' => '0', 'single' => '0', ), array ( 'tablename' => 'node', 'field' => 'promote', 'label' => 'Promoted', 'optional' => '1', 'is_default' => '0', 'operator' => '0', 'single' => '0', ), array ( 'tablename' => 'node', 'field' => 'sticky', 'label' => 'Sticky', 'optional' => '1', 'is_default' => '0', 'operator' => '0', 'single' => '0', ), ); $view->requires = array(node, users, views_actions); $views[$view->name] = $view; $view = new stdClass(); $view->name = 'views_actions_test'; $view->description = 'Test view to make sure node selector patch has no side effects.'; $view->access = array (); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = ''; $view->page_header = 'Make sure the exposed filters and paginator work correctly. Submitting should output the selected nodes.'; $view->page_header_format = '1'; $view->page_footer = ''; $view->page_footer_format = '1'; $view->page_empty = ''; $view->page_empty_format = '1'; $view->page_type = 'table'; $view->url = ''; $view->use_pager = TRUE; $view->nodes_per_page = '5'; $view->sort = array ( ); $view->argument = array ( ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'title', 'label' => '', 'handler' => 'views_handler_field_nodelink', 'options' => 'link', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'blog', ), ), ); $view->exposed_filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'label' => '', 'optional' => '1', 'is_default' => '0', 'operator' => '0', 'single' => '0', ), ); $view->requires = array(node); $views[$view->name] = $view; return $views; } function views_actions_form_alter($form_id, &$form) { if ($form_id == 'views_filters') { // We don't display the filter form in the confirmation page if ($_POST['form_id'] == 'views_actions_bulk_form' && $_POST['step'] == 2) { $form['#prefix'] = ''; $view = $form['view']['#value']; $view->use_pager = FALSE; } } } function views_actions_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'views_actions/test', 'title' => t('Test the views_actions module'), 'type' => MENU_CALLBACK, 'callback' => 'drupal_get_form', 'callback arguments' => 'views_actions_form_selector_test', 'access' => TRUE, ); } return $items; } function views_actions_form_selector_test() { $form['nodes'] = array( '#title' => 'views_actions form_selector test', '#type' => 'views_node_selector', '#view' => 'views_actions_test', '#multiple' => TRUE, ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; } function views_actions_form_selector_test_submit($form_id, $form_values) { echo "SELECTED NODES:"; dpr($form_values['nodes']['selected']); } ?>