From 2a7b0b30aaf257e34e14c4b6357e4ab6fee3a369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?"J.=20Rene=CC=81e=20Beach"?= Date: Fri, 24 May 2013 15:08:59 -0700 Subject: [PATCH] Issue #1842036-72 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: J. ReneĢe Beach --- .../Drupal/Core/Controller/DialogController.php | 17 +++++++++--- .../Drupal/Core/Controller/HtmlFormController.php | 3 +++ .../Drupal/Core/Entity/EntityFormController.php | 3 +++ .../Drupal/Core/Entity/EntityListController.php | 3 +++ core/lib/Drupal/Core/Form/ConfirmFormBase.php | 5 ++++ .../Routing/Enhancer/ContentControllerEnhancer.php | 9 +++++-- .../Drupal/action/Controller/ActionController.php | 3 +++ .../aggregator/Routing/AggregatorController.php | 6 +++++ core/modules/ban/ban.admin.inc | 3 +++ .../block/lib/Drupal/block/BlockListController.php | 3 +++ core/modules/book/book.pages.inc | 3 +++ core/modules/comment/comment.module | 4 +++ core/modules/config/config.admin.inc | 2 -- .../Drupal/config/Tests/ConfigEntityListTest.php | 3 +++ .../config_test/ConfigTestFormController.php | 3 +++ .../field_ui/lib/Drupal/field_ui/FieldOverview.php | 4 ++- .../Drupal/field_ui/Form/FieldInstanceEditForm.php | 3 +++ core/modules/filter/filter.admin.inc | 3 +++ core/modules/forum/forum.admin.inc | 22 +++++++++++++++ core/modules/image/image.admin.inc | 14 ++++++++-- core/modules/language/language.admin.inc | 7 +++-- core/modules/menu/menu.admin.inc | 24 +++++++++++++++-- core/modules/node/content_types.inc | 6 +++++ core/modules/node/node.admin.inc | 3 +++ core/modules/node/node.module | 11 ++++++-- core/modules/node/node.pages.inc | 6 +++++ core/modules/openid/openid.pages.inc | 3 +++ core/modules/path/path.admin.inc | 3 +++ core/modules/search/search.admin.inc | 28 ++++++++++++++++++-- .../lib/Drupal/shortcut/ShortcutListController.php | 4 +++ core/modules/shortcut/shortcut.admin.inc | 3 +++ core/modules/system/system.admin.inc | 6 +++++ core/modules/taxonomy/taxonomy.admin.inc | 3 +++ .../EntityTranslationController.php | 3 +++ .../translation_entity/translation_entity.module | 3 +++ .../translation_entity.pages.inc | 3 +++ .../lib/Drupal/views_ui/ViewEditFormController.php | 6 ++++- .../lib/Drupal/views_ui/ViewListController.php | 5 ++-- 38 files changed, 221 insertions(+), 22 deletions(-) diff --git a/core/lib/Drupal/Core/Controller/DialogController.php b/core/lib/Drupal/Core/Controller/DialogController.php index 4b26686..72658db 100644 --- a/core/lib/Drupal/Core/Controller/DialogController.php +++ b/core/lib/Drupal/Core/Controller/DialogController.php @@ -54,6 +54,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. @@ -68,12 +69,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); } @@ -83,14 +86,20 @@ 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\Controller\HtmlFormController::content'; + } $subrequest = $this->forward($request, $_content); if ($subrequest->isOk()) { $content = $subrequest->getContent(); diff --git a/core/lib/Drupal/Core/Controller/HtmlFormController.php b/core/lib/Drupal/Core/Controller/HtmlFormController.php index 7eb85f3..9aea732 100644 --- a/core/lib/Drupal/Core/Controller/HtmlFormController.php +++ b/core/lib/Drupal/Core/Controller/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/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 53f1de3..d52a1a8 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -225,6 +225,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..4bd5509 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -77,6 +77,9 @@ public function getOperations(EntityInterface $entity) { $operations['delete'] = array( 'title' => t('Delete'), 'href' => $uri['path'] . '/delete', + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), 'options' => $uri['options'], 'weight' => 100, ); 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/Routing/Enhancer/ContentControllerEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/ContentControllerEnhancer.php index c355cc7..9fe5223 100644 --- a/core/lib/Drupal/Core/Routing/Enhancer/ContentControllerEnhancer.php +++ b/core/lib/Drupal/Core/Routing/Enhancer/ContentControllerEnhancer.php @@ -48,8 +48,13 @@ public function __construct(ContentNegotiation $negotiation) { * {@inheritdoc} */ public function enhance(array $defaults, Request $request) { - if (empty($defaults['_controller']) && !empty($defaults['_content'])) { - $type = $this->negotiation->getContentType($request); + // If no controller is set and either a) _content is set or b) _form is set + // but request is not for html, then enhance the route. + if (empty($defaults['_controller']) && + ($type = $this->negotiation->getContentType($request)) && + (!empty($defaults['_content']) || + (!empty($defaults['_form']) && $type != 'html'))) { + if (isset($this->types[$type])) { $defaults['_controller'] = $this->types[$type]; } diff --git a/core/modules/action/lib/Drupal/action/Controller/ActionController.php b/core/modules/action/lib/Drupal/action/Controller/ActionController.php index 09423fb..2c3b4bd 100644 --- a/core/modules/action/lib/Drupal/action/Controller/ActionController.php +++ b/core/modules/action/lib/Drupal/action/Controller/ActionController.php @@ -94,6 +94,9 @@ public function adminManage() { $links['delete'] = array( 'title' => t('delete'), 'href' => "admin/config/system/actions/delete/$action->aid", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); } $row[] = array( diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php index abef5af..1dfc837 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php @@ -151,10 +151,16 @@ public function adminOverview() { $links['delete'] = array( 'title' => t('Delete'), 'href' => "admin/config/services/aggregator/delete/feed/$feed->fid", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); $links['remove'] = array( 'title' => t('Remove items'), 'href' => "admin/config/services/aggregator/remove/$feed->fid", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); $links['update'] = array( 'title' => t('Update items'), diff --git a/core/modules/ban/ban.admin.inc b/core/modules/ban/ban.admin.inc index 9f20a45..b47ced8 100644 --- a/core/modules/ban/ban.admin.inc +++ b/core/modules/ban/ban.admin.inc @@ -26,6 +26,9 @@ function ban_admin_page($default_ip = '') { $links['delete'] = array( 'title' => t('delete'), 'href' => "admin/config/people/ban/delete/$ip->iid", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); $row[] = array( 'data' => array( diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 5b18b3c..759350b 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -166,6 +166,9 @@ public function buildForm(array $form, array &$form_state) { $links['delete'] = array( 'title' => t('delete'), 'href' => 'admin/structure/block/manage/' . $entity_id . '/delete', + 'ajax' => array( + '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 b2d0190..cc053fb 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -920,7 +920,11 @@ function comment_links(Comment $comment, EntityInterface $node) { 'title' => t('delete'), 'href' => "comment/{$comment->id()}/delete", 'html' => TRUE, + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); + } 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 a961286..7761484 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -5,8 +5,6 @@ * Admin page callbacks for the config module. */ -use Drupal\Core\Ajax\AjaxResponse; -use Drupal\Core\Ajax\OpenModalDialogCommand; use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\StorageComparerManifest; diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index b67cb4a..9c6f08e 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -68,6 +68,9 @@ function testList() { 'delete' => array ( 'title' => t('Delete'), 'href' => $uri['path'] . '/delete', + 'ajax' => array( + '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 44e4be7..41685a6 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -147,7 +147,9 @@ 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.')), + 'ajax' => array( + '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 d8788a7..3e758ee 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 @@ -158,6 +158,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 a4493a9..66711bd 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -53,6 +53,9 @@ function filter_admin_overview($form) { $links['disable'] = array( 'title' => t('disable'), 'href' => "admin/config/content/formats/$id/disable", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); } diff --git a/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc index 2a8a50d..e376fdd 100644 --- a/core/modules/forum/forum.admin.inc +++ b/core/modules/forum/forum.admin.inc @@ -5,6 +5,9 @@ * Administrative page callbacks for the Forum module. */ +use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\Ajax\OpenModalDialogCommand; +use Drupal\forum\Form\DeleteForm; use Drupal\taxonomy\Plugin\Core\Entity\Term; /** @@ -77,6 +80,9 @@ function forum_form_forum($form, &$form_state, Term $term) { $form['actions']['delete'] = array( '#type' => 'submit', '#value' => t('Delete'), + '#ajax' => array( + 'callback' => 'forum_forum_delete_ajax_submit', + ), '#submit' => array('forum_forum_delete'), ); $form['tid'] = array('#type' => 'value', '#value' => $term->id()); @@ -190,6 +196,9 @@ function forum_form_container($form, &$form_state, Term $term) { $form['actions']['delete'] = array( '#type' => 'submit', '#value' => t('Delete'), + '#ajax' => array( + 'callback' => 'forum_forum_delete_ajax_submit', + ), '#submit' => array('forum_forum_delete'), ); $form['tid'] = array('#type' => 'value', '#value' => $term->id()); @@ -200,6 +209,19 @@ function forum_form_container($form, &$form_state, Term $term) { } /** + * AJAX submit handler for forum_form_forum() and forum_form_container(). + */ +function forum_forum_delete_ajax_submit($form, &$form_state) { + $confirm_form = new DeleteForm(); + $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; +} + +/** * Form submission handler for forum_form_forum() and forum_form_container(). * * Handler for when 'delete' is clicked. diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 9ed3aa9..015ac5b 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -93,6 +93,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 +524,19 @@ 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'), + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), + 'attributes' => array( + 'class' => array('image-style-link'), + ), ); $row[] = array( 'data' => array( diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index 59f1efa..7e37513 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -54,6 +54,9 @@ function language_admin_overview_form($form, &$form_state) { $links['delete'] = array( 'title' => t('delete'), 'href' => 'admin/config/regional/language/delete/' . $langcode, + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); } $form['languages'][$langcode]['operations'] = array( @@ -663,8 +666,8 @@ function theme_language_negotiation_configure_browser_form_table($variables) { $links['delete'] = array( 'title' => t('Delete'), 'href' => "admin/config/regional/language/detection/browser/delete/$key", - 'attributes' => array( - 'class' => array('image-style-link'), + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', ), ); $row[] = array( diff --git a/core/modules/menu/menu.admin.inc b/core/modules/menu/menu.admin.inc index 4150b99..e75f08d 100644 --- a/core/modules/menu/menu.admin.inc +++ b/core/modules/menu/menu.admin.inc @@ -174,16 +174,36 @@ function _menu_overview_tree_form($tree, $delta = 50) { $links['delete'] = array( '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', + '#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', + 'ajax' => array( + '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..ab5fb89 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -49,6 +49,9 @@ function node_overview_types() { $links['delete'] = array( 'title' => t('Delete'), 'href' => 'admin/structure/types/manage/' . $type->type . '/delete', + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), 'weight' => 15, ); } @@ -275,6 +278,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..38a8da1 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -565,6 +565,9 @@ function node_admin_nodes() { $operations['delete'] = array( 'title' => t('Delete'), 'href' => 'node/' . $node->nid . '/delete', + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), 'query' => $destination, ); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 1e1084e..e625ea1 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'); } @@ -3472,7 +3474,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..248416e 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -277,12 +277,18 @@ function node_revision_overview($node) { $links['revert'] = array( 'title' => t('Revert'), 'href' => "node/$node->nid/revisions/$revision->vid/revert", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); } if ($delete_permission) { $links['delete'] = array( 'title' => t('Delete'), 'href' => "node/$node->nid/revisions/$revision->vid/delete", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); } $row[] = array( diff --git a/core/modules/openid/openid.pages.inc b/core/modules/openid/openid.pages.inc index df730af..656c43c 100644 --- a/core/modules/openid/openid.pages.inc +++ b/core/modules/openid/openid.pages.inc @@ -56,6 +56,9 @@ function openid_user_identities($account) { $links['delete'] = array( 'title' => t('Delete'), 'href' => 'user/' . $account->uid . '/openid/delete/' . $identity->aid, + 'ajax' => array( + '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..fc5febe 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -64,6 +64,9 @@ function path_admin_overview($keys = NULL) { $operations['delete'] = array( 'title' => t('delete'), 'href' => "admin/config/search/path/delete/$data->pid", + 'ajax' => array( + '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..1bd7a20 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutListController.php @@ -42,10 +42,14 @@ public function getOperations(EntityInterface $entity) { $operations['delete'] = array( 'title' => t('Delete set'), 'href' => $uri['path'] . '/delete', + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), 'options' => $uri['options'], 'weight' => 100, ); } + return $operations; } diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index 2f7acf6..c55aae3 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -221,6 +221,9 @@ function shortcut_set_customize($form, &$form_state, $shortcut_set) { $links['delete'] = array( 'title' => t('Delete'), 'href' => "admin/config/user-interface/shortcut/link/$mlid/delete", + 'ajax' => array( + '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 1566c80..920527b 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1862,6 +1862,9 @@ function system_date_time_formats() { $links['delete'] = array( 'title' => t('Delete'), 'href' => 'admin/config/regional/date-time/formats/' . $date_format_id . '/delete', + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); $row['operations'] = array('data' => array( '#type' => 'operations', @@ -2038,6 +2041,9 @@ function system_date_format_language_overview_page() { $links['reset'] = array( 'title' => t('Reset'), 'href' => "admin/config/regional/date-time/locale/$langcode/reset", + 'ajax' => array( + 'accepts' => 'application/vnd.drupal-modal', + ), ); $row[] = array( 'data' => array( diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index 0703071..ec6b4ec 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -294,6 +294,9 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { 'delete' => array( 'title' => t('delete'), 'href' => 'taxonomy/term/' . $term->id() . '/delete', + 'ajax' => array( + '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..357ce24 100644 --- a/core/modules/translation_entity/translation_entity.pages.inc +++ b/core/modules/translation_entity/translation_entity.pages.inc @@ -111,6 +111,9 @@ 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']['ajax'] = array( + 'accepts' => 'application/vnd.drupal-modal', + ); } } } 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 9f3e0b6..fbcab16 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,11 @@ public function form(array $form, array &$form_state) { $form['locked'] = array( '#type' => 'container', '#attributes' => array('class' => array('view-locked', 'messages', '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'; } } -- 1.7.10.4