'Bulk export', 'access arguments' => array('use views exporter'), 'page callback' => 'views_export_export', 'type' => MENU_LOCAL_TASK, ); $items['admin/build/views/tools/export/results'] = array( 'access arguments' => array('use views exporter'), 'page callback' => 'views_export_export', 'type' => MENU_CALLBACK, ); return $items; } function views_export_theme() { return array( 'views_export_export_form' => array( 'args' => array('form' => NULL), ), ); } /** * Implementation of hook_perm(). */ function views_export_perm() { return array('use views exporter'); } /** * Page callback to export views in bulk. */ function views_export_export() { $tags = array(); if (!empty($_GET['tags'])) { $tags = explode(',', $_GET['tags']); } $exportables = array(); foreach (module_implements('views_exportables') as $module) { $function = $module . '_views_exportables'; $exportables[$module] = $function('list', $tags); } if ($exportables) { $form_state = array( 'no_redirect' => TRUE, 'exportables' => $exportables, 'tags' => $tags, ); $output = drupal_build_form('views_export_export_form', $form_state); if (!$output) { $output = $form_state['output']; } return $output; } else { return t('There are no views to be exported at this time.'); } } /** * Form to choose a group of views to export. */ function views_export_export_form(&$form_state) { foreach ($form_state['exportables'] as $module => $views) { foreach ($views as $name => $data) { $options[$name] = $data['name']; } $form['modules']['#tree'] = TRUE; $form['modules'][$module] = array( '#type' => 'checkboxes', '#options' => $options, '#default_value' => array(), ); } $tags = array(); foreach (views_get_all_views() as $name => $view) { if (!empty($view->tag)) { $tags[$view->tag] = $view->tag; } } asort($tags); $form['tags'] = array( '#type' => 'select', '#title' => t('Show only these tags'), '#options' => $tags, '#default_value' => $form_state['tags'], '#multiple' => TRUE, ); $form['apply'] = array( '#type' => 'submit', '#value' => t('Apply'), '#submit' => array('views_export_export_form_apply'), ); $form['name'] = array( '#type' => 'textfield', '#title' => t('Module name'), '#description' => t('Enter the module name to export code to.'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Export'), ); $form['#action'] = url('admin/build/views/tools/export/results'); $form['#redirect'] = FALSE; $form['#exportables'] = $form_state['exportables']; return $form; } function theme_views_export_export_form($form) { $output = ''; $files = module_rebuild_cache(); $exportables = $form['#exportables']; $output .= drupal_render($form['tags']); $output .= drupal_render($form['apply']); $output .= '