diff --git a/core/lib/Drupal/Core/Ajax/DialogController.php b/core/lib/Drupal/Core/Ajax/DialogController.php index 478b0b7..0364fdc 100644 --- a/core/lib/Drupal/Core/Ajax/DialogController.php +++ b/core/lib/Drupal/Core/Ajax/DialogController.php @@ -40,6 +40,7 @@ protected function forward(Request $request, $content) { // We need to clean up the derived information and such so that the // subrequest can be processed properly without leaking data through. $attributes->remove('system_path'); + $attributes->set('dialog', TRUE); // Remove the accept header so the subrequest does not end up back in this // controller. @@ -54,12 +55,14 @@ protected function forward(Request $request, $content) { * @param \Symfony\Component\HttpFoundation\RequestRequest $request * The request object. * @param callable $_content - * The body content callable that contains the body region of this page. + * (optional) The body content callable that contains the body region of + * this page. If not given, it is assumed that the incoming request is for + * a form. * * @return \Drupal\Core\Ajax\AjaxResponse * AjaxResponse to return the content wrapper in a modal dialog. */ - public function modal(Request $request, $_content) { + public function modal(Request $request, $_content = FALSE) { return $this->dialog($request, $_content, TRUE); } @@ -69,19 +72,25 @@ public function modal(Request $request, $_content) { * @param \Symfony\Component\HttpFoundation\RequestRequest $request * The request object. * @param callable $_content - * The body content callable that contains the body region of this page. + * (optional) The body content callable that contains the body region of + * this page. If not given, it is assumed that the incoming request is for + * a form. * @param bool $modal * (optional) TRUE to render a modal dialog. Defaults to FALSE. * * @return \Drupal\Core\Ajax\AjaxResponse * AjaxResponse to return the content wrapper in a dialog. */ - public function dialog(Request $request, $_content, $modal = FALSE) { + public function dialog(Request $request, $_content = FALSE, $modal = FALSE) { + if (!$_content) { + // No $_content means we have a form instead. + $_content = '\Drupal\Core\HtmlFormController::content'; + } $subrequest = $this->forward($request, $_content); if ($subrequest->isOk()) { $content = $subrequest->getContent(); // @todo Remove use of drupal_get_title() when - // http://drupal.org/node/1871596 is in. + // http://drupal.org/node/1871596 is in. $title = drupal_get_title(); $response = new AjaxResponse(); // Fetch any modal options passed in from data-dialog-options. diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 98d4a3d..2a7ed6c 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -201,6 +201,9 @@ protected function actions(array $form, array &$form_state) { ), 'delete' => array( '#value' => t('Delete'), + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), // No need to validate the form when deleting the entity. '#submit' => array( array($this, 'delete'), diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index 354b27a..40f0076 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -77,9 +77,17 @@ public function getOperations(EntityInterface $entity) { $operations['delete'] = array( 'title' => t('Delete'), 'href' => $uri['path'] . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), 'options' => $uri['options'], 'weight' => 100, ); + + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + return $operations; } diff --git a/core/lib/Drupal/Core/Form/ConfirmFormBase.php b/core/lib/Drupal/Core/Form/ConfirmFormBase.php index 2aedb41..905310d 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormBase.php @@ -104,6 +104,11 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'link', '#title' => $this->getCancelText(), '#href' => $options['path'], + '#attributes' => array( + // This is a special class to which JavaScript assigns dialog closing + // behavior. + 'class' => array('dialog-cancel'), + ), '#options' => $options, ); // By default, render the form using theme_confirm_form(). diff --git a/core/lib/Drupal/Core/HtmlFormController.php b/core/lib/Drupal/Core/HtmlFormController.php index e19d8ea..fe269c2 100644 --- a/core/lib/Drupal/Core/HtmlFormController.php +++ b/core/lib/Drupal/Core/HtmlFormController.php @@ -63,6 +63,9 @@ public function content(Request $request, $_form) { $form_id = _drupal_form_id($form_object, $form_state); $form = drupal_build_form($form_id, $form_state); + if ($request->attributes->get('dialog')) { + return drupal_render($form); + } return new Response(drupal_render_page($form)); } diff --git a/core/lib/Drupal/Core/Routing/Enhancer/DialogEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/DialogEnhancer.php index c14b6fa..b6969ff 100644 --- a/core/lib/Drupal/Core/Routing/Enhancer/DialogEnhancer.php +++ b/core/lib/Drupal/Core/Routing/Enhancer/DialogEnhancer.php @@ -51,8 +51,10 @@ public function __construct(ContentNegotiation $negotiation) { * {@inheritdoc} */ public function enhance(array $defaults, Request $request) { - if (empty($defaults['_controller']) && !empty($defaults['_content']) && $this->negotiation->getContentType($request) == $this->targetContentType) { - $defaults['_controller'] = $this->controller; + if ($this->negotiation->getContentType($request) == $this->targetContentType) { + if (empty($defaults['_controller']) && (!empty($defaults['_content']) || !empty($defaults['_form']))) { + $defaults['_controller'] = $this->controller; + } } return $defaults; } diff --git a/core/modules/action/lib/Drupal/action/Controller/ActionController.php b/core/modules/action/lib/Drupal/action/Controller/ActionController.php index 09423fb..35444c5 100644 --- a/core/modules/action/lib/Drupal/action/Controller/ActionController.php +++ b/core/modules/action/lib/Drupal/action/Controller/ActionController.php @@ -94,6 +94,10 @@ public function adminManage() { $links['delete'] = array( 'title' => t('delete'), 'href' => "admin/config/system/actions/delete/$action->aid", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); } $row[] = array( @@ -119,6 +123,9 @@ public function adminManage() { '#header' => $header, '#rows' => $rows, ); + + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); } if ($actions_map) { diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php index ff2b222..0f29d0d 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php @@ -95,10 +95,18 @@ public function adminOverview() { $links['delete'] = array( 'title' => t('Delete'), 'href' => "admin/config/services/aggregator/delete/feed/$feed->fid", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $links['remove'] = array( 'title' => t('Remove items'), 'href' => "admin/config/services/aggregator/remove/$feed->fid", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $links['update'] = array( 'title' => t('Update items'), @@ -121,6 +129,9 @@ public function adminOverview() { '#empty' => t('No feeds available. Add feed.', array('@link' => url('admin/config/services/aggregator/add/feed'))), ); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + $result = $this->database->query('SELECT c.cid, c.title, COUNT(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title'); $header = array(t('Title'), t('Items'), t('Operations')); diff --git a/core/modules/ban/ban.admin.inc b/core/modules/ban/ban.admin.inc index 9f20a45..8ff6919 100644 --- a/core/modules/ban/ban.admin.inc +++ b/core/modules/ban/ban.admin.inc @@ -26,6 +26,10 @@ function ban_admin_page($default_ip = '') { $links['delete'] = array( 'title' => t('delete'), 'href' => "admin/config/people/ban/delete/$ip->iid", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $row[] = array( 'data' => array( @@ -45,6 +49,9 @@ function ban_admin_page($default_ip = '') { '#empty' => t('No blocked IP addresses available.'), ); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + return $build; } diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 5dd981f..9e8fd74 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -109,6 +109,8 @@ public function buildForm(array $form, array &$form_state) { $form['#attached']['css'][] = drupal_get_path('module', 'block') . '/block.admin.css'; $form['#attached']['library'][] = array('system', 'drupal.tableheader'); $form['#attached']['library'][] = array('block', 'drupal.block'); + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); // Add a last region for disabled blocks. $block_regions_with_disabled = $this->regions + array(BLOCK_REGION_NONE => BLOCK_REGION_NONE); @@ -166,6 +168,10 @@ public function buildForm(array $form, array &$form_state) { $links['delete'] = array( 'title' => t('delete'), 'href' => 'admin/structure/block/manage/' . $entity_id . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $form['blocks'][$entity_id]['operations'] = array( '#type' => 'operations', diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc index 67c4c99..6f66f78 100644 --- a/core/modules/book/book.pages.inc +++ b/core/modules/book/book.pages.inc @@ -139,6 +139,9 @@ function book_outline_form($form, &$form_state, EntityInterface $node) { '#value' => t('Remove from book outline'), '#access' => _book_node_is_removable($node), '#weight' => 20, + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), '#submit' => array('book_remove_button_submit'), ); diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 6d0d003..129750e 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -921,7 +921,15 @@ function comment_links(Comment $comment, EntityInterface $node) { 'title' => t('delete'), 'href' => "comment/{$comment->id()}/delete", 'html' => TRUE, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); + + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + } if ($comment->access('update')) { $links['comment-edit'] = array( diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index 57704de..72eab6a 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -6,8 +6,6 @@ */ use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Ajax\AjaxResponse; -use Drupal\Core\Ajax\OpenModalDialogCommand; /** * Helper function to construct the storage changes in a configuration synchronization form. diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index f851cbc..ca82c9b 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -68,6 +68,10 @@ function testList() { 'delete' => array ( 'title' => t('Delete'), 'href' => $uri['path'] . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), 'options' => $uri['options'], 'weight' => 100, ), diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php index efba401..5e29c59 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php @@ -55,6 +55,9 @@ public function form(array $form, array &$form_state) { $form['actions']['delete'] = array( '#type' => 'submit', '#value' => 'Delete', + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); return $form; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index f02e2eb..1f72b28 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -57,6 +57,9 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL, $widget_types = field_info_widget_types(); $extra_fields = field_info_extra_fields($this->entity_type, $this->bundle, 'form'); + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + $form += array( '#entity_type' => $this->entity_type, '#bundle' => $this->bundle, @@ -145,7 +148,11 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL, $links['delete'] = array( 'title' => t('Delete'), 'href' => "$admin_field_path/delete", - 'attributes' => array('title' => t('Delete instance.')), + 'attributes' => array( + 'title' => t('Delete instance.'), + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $table[$name]['operations']['data'] = array( '#type' => 'operations', diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php index 4803701..a089e86 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php @@ -168,6 +168,9 @@ public function buildForm(array $form, array &$form_state, FieldInstance $field_ $form['actions']['delete'] = array( '#type' => 'submit', '#value' => t('Delete field'), + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), '#submit' => array(array($this, 'delete')), ); return $form; diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc index aa3018c..91ff94e 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -17,6 +17,9 @@ function filter_admin_overview($form) { $formats = filter_formats(); $fallback_format = filter_fallback_format(); + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + $form['#tree'] = TRUE; $form['formats'] = array( '#type' => 'table', @@ -53,6 +56,10 @@ function filter_admin_overview($form) { $links['disable'] = array( 'title' => t('disable'), 'href' => "admin/config/content/formats/$id/disable", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); } diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 9ed3aa9..334c953 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -41,6 +41,9 @@ function image_style_form($form, &$form_state, $style) { $form['#tree'] = TRUE; $form['#attached']['css'][drupal_get_path('module', 'image') . '/image.admin.css'] = array(); + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + // Show the thumbnail preview. $form['preview'] = array( '#type' => 'item', @@ -93,6 +96,9 @@ function image_style_form($form, &$form_state, $style) { $links['delete'] = array( 'title' => t('delete'), 'href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/effects/' . $key . '/delete', + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); $form['effects'][$key]['operations'] = array( '#type' => 'operations', @@ -521,12 +527,17 @@ function theme_image_style_list($variables) { $links['edit'] = array( 'title' => t('edit'), 'href' => 'admin/config/media/image-styles/manage/' . $style->id(), - 'class' => array('image-style-link'), + 'attributes' => array( + 'class' => array('image-style-link'), + ), ); $links['delete'] = array( 'title' => t('delete'), 'href' => 'admin/config/media/image-styles/manage/' . $style->id() . '/delete', - 'class' => array('image-style-link'), + 'attributes' => array( + 'class' => array('use-ajax', 'image-style-link'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $row[] = array( 'data' => array( @@ -544,6 +555,9 @@ function theme_image_style_list($variables) { )); } + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + return theme('table', array('header' => $header, 'rows' => $rows)); } diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index 59f1efa..303aa8c 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -16,6 +16,9 @@ function language_admin_overview_form($form, &$form_state) { $languages = language_list(); $default = language_default(); + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + $form['languages'] = array( '#languages' => $languages, '#language_default' => $default, @@ -54,6 +57,10 @@ function language_admin_overview_form($form, &$form_state) { $links['delete'] = array( 'title' => t('delete'), 'href' => 'admin/config/regional/language/delete/' . $langcode, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); } $form['languages'][$langcode]['operations'] = array( @@ -664,7 +671,8 @@ function theme_language_negotiation_configure_browser_form_table($variables) { 'title' => t('Delete'), 'href' => "admin/config/regional/language/detection/browser/delete/$key", 'attributes' => array( - 'class' => array('image-style-link'), + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', ), ); $row[] = array( @@ -683,6 +691,9 @@ function theme_language_negotiation_configure_browser_form_table($variables) { t('Operations'), ); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'lang-neg-browser'))); return $output; diff --git a/core/modules/menu/menu.admin.inc b/core/modules/menu/menu.admin.inc index 4150b99..9caed4f 100644 --- a/core/modules/menu/menu.admin.inc +++ b/core/modules/menu/menu.admin.inc @@ -174,16 +174,38 @@ function _menu_overview_tree_form($tree, $delta = 50) { $links['delete'] = array( 'title' => t('Delete'), 'href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), + ); + $operations['delete'] = array( + '#type' => 'link', + '#title' => t('Delete'), + '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete', + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); - $operations['delete'] = array('#type' => 'link', '#title' => t('Delete'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete'); } // Set the reset column. elseif ($item['module'] == 'system' && $item['customized']) { $links['reset'] = array( 'title' => t('Reset'), 'href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), + ); + $operations['reset'] = array( + '#type' => 'link', + '#title' => t('Reset'), + '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset', + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); - $operations['reset'] = array('#type' => 'link', '#title' => t('Reset'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset'); } $form[$mlid]['operations'] = array( '#type' => 'operations', diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc index f8b144a..549e691 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -20,6 +20,9 @@ function node_overview_types() { $header = array(t('Name'), t('Operations')); $rows = array(); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + foreach ($names as $key => $name) { $type = $types[$key]; if (node_hook($type->type, 'form')) { @@ -49,6 +52,10 @@ function node_overview_types() { $links['delete'] = array( 'title' => t('Delete'), 'href' => 'admin/structure/types/manage/' . $type->type . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), 'weight' => 15, ); } @@ -275,6 +282,9 @@ function node_type_form($form, &$form_state, $type = NULL) { $form['actions']['delete'] = array( '#type' => 'submit', '#value' => t('Delete content type'), + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), '#weight' => 45, ); } diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 139b2d2..fd273b3 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -428,6 +428,9 @@ function node_admin_content($form, $form_state) { function node_admin_nodes() { $admin_access = user_access('administer nodes'); + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + // Build the 'Update options' form. $form['options'] = array( '#type' => 'details', @@ -565,6 +568,10 @@ function node_admin_nodes() { $operations['delete'] = array( 'title' => t('Delete'), 'href' => 'node/' . $node->nid . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), 'query' => $destination, ); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 7ba5d23..3e9ced8 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -95,7 +95,9 @@ function node_help($path, $arg) { $message = t('The content access permissions need to be rebuilt.'); } else { - $message = t('The content access permissions need to be rebuilt. Rebuild permissions.', array('@node_access_rebuild' => url('admin/reports/status/rebuild'))); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + $message = t('The content access permissions need to be rebuilt. Rebuild permissions.', array('@node_access_rebuild' => url('admin/reports/status/rebuild'))); } drupal_set_message($message, 'error'); } @@ -3495,7 +3497,12 @@ function node_requirements($phase) { $requirements['node_access'] = array( 'title' => t('Node Access Permissions'), 'value' => $value, - 'description' => $description . ' ' . l(t('Rebuild permissions'), 'admin/reports/status/rebuild'), + 'description' => $description . ' ' . l(t('Rebuild permissions'), 'admin/reports/status/rebuild', array( + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ) + )), ); } return $requirements; diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 863babd..fd46175 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -244,6 +244,10 @@ function node_delete_confirm_submit($form, &$form_state) { * @see node_menu() */ function node_revision_overview($node) { + + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + drupal_set_title(t('Revisions for %title', array('%title' => $node->label())), PASS_THROUGH); $header = array(t('Revision'), t('Operations')); @@ -277,12 +281,20 @@ function node_revision_overview($node) { $links['revert'] = array( 'title' => t('Revert'), 'href' => "node/$node->nid/revisions/$revision->vid/revert", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); } if ($delete_permission) { $links['delete'] = array( 'title' => t('Delete'), 'href' => "node/$node->nid/revisions/$revision->vid/delete", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); } $row[] = array( diff --git a/core/modules/openid/openid.pages.inc b/core/modules/openid/openid.pages.inc index 81a5905..5e30ffc 100644 --- a/core/modules/openid/openid.pages.inc +++ b/core/modules/openid/openid.pages.inc @@ -30,6 +30,9 @@ function openid_user_identities($account) { drupal_set_title(user_format_name($account)); drupal_add_css(drupal_get_path('module', 'openid') . '/openid.css'); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + // Check to see if we got a response $response = openid_complete(); if ($response['status'] == 'success') { @@ -56,6 +59,10 @@ function openid_user_identities($account) { $links['delete'] = array( 'title' => t('Delete'), 'href' => 'user/' . $account->uid . '/openid/delete/' . $identity->aid, + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $row[] = array( 'data' => array( diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index 773431c..475061f 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -19,6 +19,9 @@ function path_admin_overview($keys = NULL) { $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LANGUAGE_NOT_SPECIFIED))->fetchField(); $multilanguage = (module_exists('language') || $alias_exists); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + $header = array(); $header[] = array('data' => t('Alias'), 'field' => 'alias', 'sort' => 'asc'); $header[] = array('data' => t('System'), 'field' => 'source'); @@ -64,6 +67,10 @@ function path_admin_overview($keys = NULL) { $operations['delete'] = array( 'title' => t('delete'), 'href' => "admin/config/search/path/delete/$data->pid", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), 'query' => $destination, ); $row['data']['operations'] = array( diff --git a/core/modules/search/search.admin.inc b/core/modules/search/search.admin.inc index 6f0825f..96d9ae4 100644 --- a/core/modules/search/search.admin.inc +++ b/core/modules/search/search.admin.inc @@ -6,6 +6,9 @@ */ use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Ajax\OpenModalDialogCommand; +use Drupal\search\Form\ReindexConfirm; /** * Helper function to get real module names. @@ -45,7 +48,14 @@ function search_admin_settings($form, &$form_state) { $status = '

' . t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '

'; $form['status'] = array('#type' => 'details', '#title' => t('Indexing status')); $form['status']['status'] = array('#markup' => $status); - $form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'), '#submit' => array('search_admin_reindex_submit')); + $form['status']['wipe'] = array( + '#type' => 'submit', + '#value' => t('Re-index site'), + '#ajax' => array( + 'callback' => 'search_admin_reindex_ajax_submit', + ), + '#submit' => array('search_admin_reindex_submit'), + ); $items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500)); @@ -163,7 +173,21 @@ function search_admin_settings_submit($form, &$form_state) { } /** - * Form submission handler for the reindex button on search_admin_settings(). + * AJAX callback handler for the reindex button on search_admin_settings(). + */ +function search_admin_reindex_ajax_submit($form, &$form_state) { + $confirm_form = new ReindexConfirm(); + $title = $confirm_form->getQuestion(); + $confirm_form = drupal_get_form($confirm_form); + $html = drupal_render($confirm_form); + $response = new AjaxResponse(); + $response->addCommand(new OpenModalDialogCommand($title, $html)); + return $response; +} + +/** + * Non-AJAX Form submission handler for the reindex button on + * search_admin_settings(). */ function search_admin_reindex_submit($form, &$form_state) { // send the user to the confirmation page diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php index f1aaa60..bc2cd40 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php @@ -42,10 +42,18 @@ public function getOperations(EntityInterface $entity) { $operations['delete'] = array( 'title' => t('Delete set'), 'href' => $uri['path'] . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), 'options' => $uri['options'], 'weight' => 100, ); } + + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + return $operations; } diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index ed38a4a..54ebb70 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -202,6 +202,9 @@ function shortcut_set_customize($form, &$form_state, $shortcut_set) { 'links' => array(), ); + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + foreach ($shortcut_set->links as $uuid => $link) { $mlid = $link['mlid']; $form['shortcuts']['links'][$mlid]['name']['#markup'] = l($link['link_title'], $link['link_path']); @@ -221,6 +224,10 @@ function shortcut_set_customize($form, &$form_state, $shortcut_set) { $links['delete'] = array( 'title' => t('Delete'), 'href' => "admin/config/user-interface/shortcut/link/$mlid/delete", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $form['shortcuts']['links'][$mlid]['operations'] = array( '#type' => 'operations', diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 994eebf..2c68fcc 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -2663,6 +2663,10 @@ function system_date_time_formats() { $links['delete'] = array( 'title' => t('Delete'), 'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $row['operations'] = array('data' => array( '#type' => 'operations', @@ -2681,6 +2685,9 @@ function system_date_time_formats() { '#empty' => t('No custom date formats available. Add date format.', array('@link' => url('admin/config/regional/date-time/formats/add'))), ); + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + return $build; } @@ -2839,6 +2846,10 @@ function system_date_format_language_overview_page() { $links['reset'] = array( 'title' => t('Reset'), 'href' => "admin/config/regional/date-time/locale/$langcode/reset", + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), ); $row[] = array( 'data' => array( @@ -2849,6 +2860,9 @@ function system_date_format_language_overview_page() { $rows[] = $row; } + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + return theme('table', array('header' => $header, 'rows' => $rows)); } diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index 0703071..bcd6907 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -123,6 +123,9 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { return taxonomy_vocabulary_confirm_reset_alphabetical($form, $form_state, $vocabulary->id()); } + // Add the AJAX library to the form for dialog support. + $form['#attached']['library'][] = array('system', 'drupal.ajax'); + $form_state['taxonomy']['vocabulary'] = $vocabulary; $parent_fields = FALSE; @@ -294,6 +297,10 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { 'delete' => array( 'title' => t('delete'), 'href' => 'taxonomy/term/' . $term->id() . '/delete', + 'attributes' => array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ), 'query' => $destination, ), ); diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php index 4ffc6ef..1f8136e 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php @@ -208,6 +208,9 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac $form['actions']['delete_translation'] = array( '#type' => 'submit', '#value' => t('Delete translation'), + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), '#weight' => $weight, '#submit' => array(array($this, 'entityFormDeleteTranslation')), '#access' => $this->getTranslationAccess($entity, 'delete'), diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module index 82bd66d..f2e3229 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/translation_entity/translation_entity.module @@ -819,6 +819,9 @@ function translation_entity_form_field_ui_field_edit_form_alter(array &$form, ar '#prefix' => t('This field has data in existing content.') . ' ', '#title' => !$translatable ? t('Enable translation') : t('Disable translation'), '#href' => 'admin/config/regional/translation_entity/translatable/' . $field_name, + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), '#options' => array('query' => drupal_get_destination()), '#access' => user_access('administer entity translation'), ), diff --git a/core/modules/translation_entity/translation_entity.pages.inc b/core/modules/translation_entity/translation_entity.pages.inc index 38ae80b..fd091b5 100644 --- a/core/modules/translation_entity/translation_entity.pages.inc +++ b/core/modules/translation_entity/translation_entity.pages.inc @@ -111,6 +111,14 @@ function translation_entity_overview(EntityInterface $entity) { if ($controller->getTranslationAccess($entity, 'delete')) { $links['delete'] = isset($delete_links->links[$langcode]['href']) ? $delete_links->links[$langcode] : array('href' => $delete_links, 'language' => $language); $links['delete']['title'] = t('Delete'); + $links['delete']['attributes'] = array( + 'class' => array('use-ajax'), + 'data-accepts' => 'application/vnd.drupal-modal', + ); + + // Add the AJAX library to the form for dialog support. + drupal_add_library('system', 'drupal.ajax'); + } } } diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index 768bb96..0ad8eef 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -631,6 +631,9 @@ function user_admin_role($form, $form_state, $role) { $form['actions']['delete'] = array( '#type' => 'submit', '#value' => t('Delete role'), + '#ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), '#access' => !$role->isNew() && !in_array($role->id(), array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID)), '#submit' => array('user_admin_role_delete_submit'), ); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php index ff34a3d..cf7c966 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php @@ -77,7 +77,7 @@ public function form(array $form, array &$form_state) { $form['locked'] = array( '#type' => 'container', '#attributes' => array('class' => array('view-locked', 'messages', 'warning')), - '#children' => t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to break this lock.', array('!user' => theme('username', array('account' => user_load($view->lock->owner))), '!age' => format_interval(REQUEST_TIME - $view->lock->updated), '!break' => url('admin/structure/views/view/' . $view->id() . '/break-lock'))), + '#children' => t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to break this lock.', array('!user' => theme('username', array('account' => user_load($view->lock->owner))), '!age' => format_interval(REQUEST_TIME - $view->lock->updated), '!break' => url('admin/structure/views/view/' . $view->id() . '/break-lock'))), '#weight' => -10, ); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php index 7bb130e..6da4a6b 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php @@ -111,9 +111,10 @@ public function getOperations(EntityInterface $view) { public function buildOperations(EntityInterface $entity) { $build = parent::buildOperations($entity); - // Allow operations to specify that they use AJAX. + // Allow operations to specify that they use AJAX, but don't add it for + // links using modals foreach ($build['#links'] as &$operation) { - if (!empty($operation['ajax'])) { + if (!empty($operation['ajax']) && !is_array($operation['ajax'])) { $operation['attributes']['class'][] = 'use-ajax'; } }