diff --git a/node_export.module b/node_export.module index 36460fd..8c527a7 100755 --- a/node_export.module +++ b/node_export.module @@ -252,6 +252,52 @@ function node_export_bulk_operation($nodes = NULL, $format = NULL, $delivery = N } /** + * Implements hook_action_info() + */ +function node_export_action_info() { + return array( + 'node_export_export_nodes_action' => array( + 'type' => 'node', + 'label' => t('Export Nodes'), + 'behavior' => array('changes_property'), + // This action only works when invoked through VBO. That's why it's + // declared as non-configurable to prevent it from being shown in the + // "Create an advanced action" dropdown on admin/config/system/actions. + 'configurable' => FALSE, + 'vbo_configurable' => TRUE, + ) + ); +} + +/** + * Export Nodes Action + * + * This currently never gets called because we stop at the configuration form + * which is called before the action is run. Technically it's called after the + * configuration form is submitted, but we're just presenting the node_export + * gui form right there. + */ +function node_export_export_nodes_action($context, &$form_state) { + // This action doesn't actually do anything... or should it? I don't know... +} + +/** + * Export Nodes Action "Configuration" Form + * + * Technically for a normal action this is where you would provide config + * for the actual execution of the action. However, we're hijacking it to + * present the completed node_export_gui page. + */ +function node_export_export_nodes_action_form($context, &$form_state) { + // Get the name of the vbo views field + $vbo = _views_bulk_operations_get_field($form_state['build_info']['args'][0]); + // Adjust the selection in case the user chose 'select all' + _views_bulk_operations_adjust_selection($form_state['selection'], $form_state['select_all_pages'], $vbo); + $nodes = array_combine($form_state['selection'],$form_state['selection']); + return node_export_bulk_operation($nodes); +} + +/** * Export nodes. * * @param $nids @@ -1229,4 +1275,4 @@ if (!function_exists('uuid_get_uuid')) { } return db_query("SELECT uuid FROM {" . $table . "} WHERE " . $key . " = :id", array(':id' => $id))->fetchField(); } -} \ No newline at end of file +}