? 348975-clone-display.patch ? 464490-views-field_alter-absolute-checkbox.patch ? 594402.views_.moderation-filters-ui.patch ? 692988.views_.taxonomy-form-query.patch ? 727894.patch ? 734706-3.views_.contact-form-access.patch ? 746846-proposed_fix.patch ? 768972.views_.filter-term-tid-disable-unabletofind.patch ? 781766-wrong-base-field-nodes-authored.patch ? 827188-argument_numeric.patch ? 827300.patch ? 848506.patch ? 852854-grammar-fix.patch ? alternative_1.patch ? diff ? doc ? dom-id-fix.patch ? handlers_views_handler_field.inc_.patch ? i859368-test.patch ? is_array_1.patch ? patches ? render_link ? tests ? typo_14.patch ? views-2-summary-path_0.patch ? views-3.x-help_plugins-6.x.patch ? views-317653_0.patch ? views-6.x-2.x-ignorecase-2.patch ? views-660140.patch ? views-666920-follow_0.patch ? views-clone-display_0_1.patch ? views-duplicate_node_handler_definition-6.x.patch ? views-feed-preview.patch ? views-revert-destination.patch ? views-rolesfix-832954-17.patch ? views-rolesfix-832954-17.patch.1 ? views-update-ret.patch ? views-user-status.patch ? views.base_.js_.patch ? views_402944.7.x.patch ? views_402944.patch ? views_date_rfc2822.patch ? views_handler_argument_dates_various.inc_.526106_1.patch ? views_name_validation_d6_29.patch ? views_pot_typo.patch ? views_taxonomy_filter-611728-2.patch ? viewsall ? modules/search/views-view-row-search.tpl.php ? modules/user/views_handler_field_is_online.inc Index: views_ui.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/views_ui.module,v retrieving revision 1.109.4.1 diff -u -p -r1.109.4.1 views_ui.module --- views_ui.module 7 Apr 2010 23:40:35 -0000 1.109.4.1 +++ views_ui.module 13 Aug 2010 23:17:43 -0000 @@ -129,6 +129,10 @@ function views_ui_menu() { 'page callback' => 'views_ui_add_display', 'page arguments' => array(3, 5), ); + $items['admin/build/views/%views_ui_js/clone-display/%views_ui_cache'] = $callback + array( + 'page callback' => 'views_ui_clone_display', + 'page arguments' => array(3, 5, 6), + ); // Live preview $items['admin/build/views/%views_ui_js/preview/%views_ui_cache'] = $callback + array( 'page callback' => 'views_ui_preview', Index: css/views-admin.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/css/views-admin.css,v retrieving revision 1.14.2.1 diff -u -p -r1.14.2.1 views-admin.css --- css/views-admin.css 18 Nov 2009 20:24:22 -0000 1.14.2.1 +++ css/views-admin.css 13 Aug 2010 23:17:43 -0000 @@ -639,6 +639,7 @@ html.js .views-hidden { max-width: 95%; } +.clone-display, .remove-display { float: right; margin: 0; @@ -648,7 +649,9 @@ html.js .views-hidden { } .views-display .remove-display form, -.remove-display input { +.remove-display input, +.views-display .clone-display form, +.clone-display input { margin: 0 !important; } Index: includes/admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/admin.inc,v retrieving revision 1.161.2.14 diff -u -p -r1.161.2.14 admin.inc --- includes/admin.inc 13 Aug 2010 21:47:11 -0000 1.161.2.14 +++ includes/admin.inc 13 Aug 2010 23:17:46 -0000 @@ -1084,12 +1084,14 @@ function template_preprocess_views_ui_ed // submit again. $vars['remove'] = ''; + $vars['clone'] = ''; if (empty($plugin['no remove'])) { - if (!empty($_POST['form_id']) && $_POST['form_id'] == 'views_ui_remove_display_form') { + if (!empty($_POST['form_id']) && in_array($_POST['form_id'], array('views_ui_remove_display_form', 'views_ui_clone_display_form'))) { unset($_POST['form_id']); } $form_state = array('view' => &$view, 'display_id' => $display->id, 'ajax' => FALSE); $vars['remove'] = drupal_build_form('views_ui_remove_display_form', $form_state); + $vars['clone'] = drupal_build_form('views_ui_clone_display_form', $form_state); } // basic fields @@ -1701,6 +1703,86 @@ function views_ui_add_display_form_submi } /** + * AJAX callback to add a display. + */ +function views_ui_clone_display($js, $view, $id) { + views_include('ajax'); + $form_state = array( + 'view' => &$view, + 'ajax' => $js, + 'display_id' => $id, + ); + + $output = views_ajax_form_wrapper('views_ui_clone_display_form', $form_state); + + if ($js) { + // If we don't have an output object, it was submitted. Set up the submission. + if (empty($output)) { + $id = $form_state['id']; + + // Make sure the new display is active + if (!$view->set_display('default')) { + views_ajax_render(t('Unable to initialize default display')); + } + + // Render the new display + list($title, $body) = views_ui_display_tab($view, $view->display[$id]); + + // Instruct the javascript on the browser to render the new tab. + $output = new stdClass; + $output->tab = array('#views-tab-' . $id => array('title' => $title, 'body' => $body)); + } + // Render the command object. This automatically exits. + views_ajax_render($output); + } + + // But the non-js variant will return output if it didn't redirect us. + return $output; +} + +/** + * From to clone a display from a view. + */ +function views_ui_clone_display_form(&$form_state) { + $view = &$form_state['view']; + $display_id = $form_state['display_id']; + + $form['clone_display'] = array( + '#type' => 'submit', + '#value' => t('Clone display'), + '#submit' => array('views_ui_clone_display_form_submit'), + ); + + $form['#id'] = 'views-clone-display-form'; + $form['#action'] = url("admin/build/views/nojs/clone-display/$view->name/$display_id"); + $form['#attributes'] = array('class' => 'views-ajax-form'); + + return $form; +} + +/** + * Submit handler to add a clone to a display from a view. + */ +function views_ui_clone_display_form_submit($form, &$form_state) { + // Create the new display + $id = $form_state['display_id']; + $display = $form_state['view']->display[$id]; + + $new_id = $form_state['view']->add_display($display->display_plugin); + $form_state['id'] = $new_id; + + // Replace the new display by a copy of the old + $form_state['view']->display[$new_id] = drupal_clone($display); + $form_state['view']->display[$new_id]->id = $new_id; + + // Store in cache + views_ui_cache_set($form_state['view']); + + // Send it back + $form_state['redirect'] = array('admin/build/views/edit/' . $form_state['view']->name, NULL, 'views-tab-' . $new_id); +} + +/** * Form to remove a display from a view. */ function views_ui_remove_display_form(&$form_state) { Index: includes/view.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/view.inc,v retrieving revision 1.167.2.8 diff -u -p -r1.167.2.8 view.inc --- includes/view.inc 13 Aug 2010 23:07:39 -0000 1.167.2.8 +++ includes/view.inc 13 Aug 2010 23:17:47 -0000 @@ -1815,21 +1815,14 @@ class views_db_object { $plugin['title'] = t('Broken'); } - // 'default' is singular and is unique, so just go with 'default' - // for it. For all others, start counting. + if (empty($id)) { - $id = ($type == 'default') ? $type : $type . '_1'; $title = $plugin['title']; - $count = 1; - - // Loop through IDs based upon our style plugin name until - // we find one that is unused. - while (!empty($this->display[$id])) { - $id = $type . '_' . ++$count; - if (empty($title)) { - $title = $plugin['title'] . ' ' . $count; - } + $id = $this->generate_display_id($type); + $count = str_replace($type . '_', '', $id); + if (empty($title)) { + $title = $plugin['title'] . ' ' . $count; } } @@ -1843,6 +1836,31 @@ class views_db_object { } /** + * Generate a display id of a certain plugin type. + * + * @param $type + * Which plugin should be used for the new display id. + */ + function generate_display_id($type) { + // 'default' is singular and is unique, so just go with 'default' + // for it. For all others, start counting. + if ($type == 'default') { + return 'default'; + } + // Initial id. + $id = $type . '_1'; + $count = 1; + + // Loop through IDs based upon our style plugin name until + // we find one that is unused. + while (!empty($this->display[$id])) { + $id = $type . '_' . ++$count; + } + + return $id; + } + + /** * Create a new display and a display handler for it. * @param $type * The plugin type from the views plugin data. Defaults to 'page'. Index: theme/views-ui-edit-tab.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/theme/views-ui-edit-tab.tpl.php,v retrieving revision 1.11 diff -u -p -r1.11 views-ui-edit-tab.tpl.php --- theme/views-ui-edit-tab.tpl.php 8 Aug 2008 16:57:44 -0000 1.11 +++ theme/views-ui-edit-tab.tpl.php 13 Aug 2010 23:17:47 -0000 @@ -10,6 +10,9 @@
+ + +