diff --git a/core/modules/comment/config/install/views.view.comment.yml b/core/modules/comment/config/install/views.view.comment.yml index b8965ce..037f2ac 100644 --- a/core/modules/comment/config/install/views.view.comment.yml +++ b/core/modules/comment/config/install/views.view.comment.yml @@ -1,8 +1,19 @@ -base_field: cid +langcode: en +status: true +dependencies: + module: + - comment + - content_translation + - node + - user +id: comment +label: Comment +module: views +description: 'Find and manage comments.' +tag: '' base_table: comment +base_field: cid core: 8.x -description: 'Find and manage comments.' -status: true display: default: display_plugin: default @@ -130,12 +141,14 @@ display: relationships: node: id: node - table: comment + table: comment_field_data field: node - required: true relationship: none group_type: group admin_label: Content + required: true + entity_type: comment + plugin_id: standard fields: comment_bulk_form: id: comment_bulk_form @@ -188,18 +201,18 @@ display: action_title: 'Update Options' include_exclude: include selected_actions: - comment_delete_action: comment_delete_action - comment_unpublish_action: comment_unpublish_action + - comment_delete_action + - comment_unpublish_action plugin_id: comment_bulk_form provider: comment subject: id: subject - table: comment + table: comment_field_data field: subject relationship: none group_type: group admin_label: '' - label: Subject + label: Title exclude: false alter: alter_text: false @@ -219,8 +232,8 @@ display: target: '' nl2br: false max_length: '' - word_boundary: false - ellipsis: false + word_boundary: true + ellipsis: true more_link: false more_link_text: '' more_link_path: '' @@ -242,11 +255,12 @@ display: hide_alter_empty: true link_to_comment: true link_to_entity: false + entity_type: comment + entity_field: subject plugin_id: comment - provider: comment name: id: name - table: comment + table: comment_field_data field: name relationship: none group_type: group @@ -293,8 +307,9 @@ display: empty_zero: false hide_alter_empty: true link_to_user: true + entity_type: comment + entity_field: name plugin_id: comment_username - provider: comment title: id: title table: node_field_data @@ -348,7 +363,7 @@ display: provider: node changed: id: changed - table: comment + table: comment_field_data field: changed relationship: none group_type: group @@ -394,11 +409,12 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - date_format: short + date_format: fallback custom_date_format: '' timezone: '' + entity_type: comment + entity_field: changed plugin_id: date - provider: views edit_comment: id: edit_comment table: comment @@ -617,19 +633,47 @@ display: provider: views filters: status: - value: true - table: comment - field: status - provider: comment id: status + table: comment_field_data + field: status + relationship: none + group_type: group + admin_label: '' + operator: '=' + value: true + group: 1 + exposed: false expose: + operator_id: '' + label: '' + description: '' + use_operator: false operator: '' - group: 1 + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + entity_type: comment + entity_field: status plugin_id: boolean sorts: changed: id: changed - table: comment + table: comment_field_data field: changed relationship: none group_type: group @@ -639,8 +683,9 @@ display: expose: label: '' granularity: second + entity_type: comment + entity_field: changed plugin_id: date - provider: views title: Comment header: { } footer: { } @@ -654,11 +699,16 @@ display: admin_label: '' empty: true tokenize: false - content: 'No comments available.' + content: + value: 'No comments available.' + format: basic_html format: basic_html plugin_id: text provider: views arguments: { } + display_extenders: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null page_1: display_plugin: page id: page_1 @@ -674,6 +724,9 @@ display: weight: 0 context: '0' display_description: '' + display_extenders: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null page_2: display_plugin: page id: page_2 @@ -692,7 +745,7 @@ display: filters: status: id: status - table: comment + table: comment_field_data field: status relationship: none group_type: group @@ -725,8 +778,9 @@ display: default_group: All default_group_multiple: { } group_items: { } + entity_type: comment + entity_field: status plugin_id: boolean - provider: comment defaults: filters: false filter_groups: false @@ -793,12 +847,12 @@ display: provider: comment subject: id: subject - table: comment + table: comment_field_data field: subject relationship: none group_type: group admin_label: '' - label: Subject + label: Title exclude: false alter: alter_text: false @@ -818,8 +872,8 @@ display: target: '' nl2br: false max_length: '' - word_boundary: false - ellipsis: false + word_boundary: true + ellipsis: true more_link: false more_link_text: '' more_link_path: '' @@ -841,11 +895,12 @@ display: hide_alter_empty: true link_to_comment: true link_to_entity: false + entity_type: comment + entity_field: subject plugin_id: comment - provider: comment name: id: name - table: comment + table: comment_field_data field: name relationship: none group_type: group @@ -892,8 +947,9 @@ display: empty_zero: false hide_alter_empty: true link_to_user: true + entity_type: comment + entity_field: name plugin_id: comment_username - provider: comment title: id: title table: node_field_data @@ -947,7 +1003,7 @@ display: provider: node changed: id: changed - table: comment + table: comment_field_data field: changed relationship: none group_type: group @@ -993,11 +1049,12 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - date_format: short + date_format: fallback custom_date_format: '' timezone: '' + entity_type: comment + entity_field: changed plugin_id: date - provider: views edit_comment: id: edit_comment table: comment @@ -1214,13 +1271,6 @@ display: destination: true plugin_id: dropbutton provider: views -label: Comment -module: views -id: comment -tag: '' -langcode: en -dependencies: - module: - - comment - - content_translation - - node + display_extenders: { } + field_langcode: '***LANGUAGE_language_content***' + field_langcode_add_to_query: null diff --git a/core/modules/comment/config/schema/comment.views.schema.yml b/core/modules/comment/config/schema/comment.views.schema.yml index 694be68..bfd62de 100644 --- a/core/modules/comment/config/schema/comment.views.schema.yml +++ b/core/modules/comment/config/schema/comment.views.schema.yml @@ -30,16 +30,6 @@ views.field.comment_entity_link: views.field.comment_bulk_form: type: views_field_bulk_form label: 'Comment bulk form' - mapping: - include_exclude: - type: string - label: 'Available actions' - selected_actions: - type: sequence - label: 'Available actions' - sequence: - - type: string - label: 'Action' views.field.comment_last_timestamp: type: views.field.date diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index 7d02d6b..610eb52 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -9,6 +9,7 @@ use Drupal\comment\CommentInterface; use Drupal\comment\CommentStorageInterface; +use Drupal\Core\Cache\Cache; use Drupal\user\TempStoreFactory; use Drupal\Component\Utility\Unicode; use Drupal\Core\Datetime\DateFormatter; @@ -291,7 +292,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } drupal_set_message($this->t('The update has been performed.')); $form_state->setRedirect('comment.admin'); - Cache::invalidateTags(array('content' => TRUE)); + Cache::invalidateTags(['content']); } else { $this->tempStoreFactory diff --git a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php index 73edf25..4dc8428 100644 --- a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php +++ b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php @@ -97,7 +97,6 @@ public function getConfirmText() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $edit = $form_state->getUserInput(); $this->comments = $this->tempStoreFactory->get('comment_multiple_delete_confirm')->get(\Drupal::currentUser()->id()); if (empty($this->comments)) { return new RedirectResponse($this->urlGenerator() @@ -110,9 +109,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#tree' => TRUE, ); - // array_filter() returns only elements with actual values. - $comment_counter = 0; - $this->comments = $this->commentStorage->loadMultiple(array_keys(array_filter($edit['comments']))); foreach ($this->comments as $comment) { $cid = $comment->id(); $form['comments'][$cid] = array( diff --git a/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php b/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php index dae4b7a..e4b691f 100644 --- a/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php +++ b/core/modules/comment/src/Plugin/views/field/CommentBulkForm.php @@ -8,114 +8,19 @@ namespace Drupal\comment\Plugin\views\field; use Drupal\system\Plugin\views\field\BulkForm; -use Drupal\Core\Entity\EntityManager; -use Drupal\Core\Form\FormErrorInterface; /** * Defines a comment operations bulk form element. * - * @PluginID("comment_bulk_form") + * @ViewsField("comment_bulk_form") */ class CommentBulkForm extends BulkForm { /** - * Constructs a new CommentBulkForm object. - */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManager $manager, FormErrorInterface $form_builder) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $manager, $form_builder); - - // Filter the actions to only include those for the 'comment' entity type. - $this->actions = array_filter($this->actions, function ($action) { - return $action->getType() == 'comment'; - }); - - } - - /** - * {@inheritdoc} - */ - protected function defineOptions() { - $options = parent::defineOptions(); - $options['include_exclude'] = array( - 'default' => 'exclude', - ); - $options['selected_actions'] = array( - 'default' => array(), - ); - return $options; - } - - /** - * {@inheritdoc} - */ - public function buildOptionsForm(&$form, &$form_state) { - parent::buildOptionsForm($form, $form_state); - - $form['include_exclude'] = array( - '#type' => 'radios', - '#title' => t('Available actions'), - '#options' => array( - 'exclude' => t('All actions, except selected'), - 'include' => t('Only selected actions'), - ), - '#default_value' => $this->options['include_exclude'], - ); - $form['selected_actions'] = array( - '#type' => 'checkboxes', - '#title' => t('Selected actions'), - '#options' => $this->getBulkOptions(FALSE), - '#default_value' => $this->options['selected_actions'], - ); - } - - /** - * {@inheritdoc} - */ - public function validateOptionsForm(&$form, &$form_state) { - parent::validateOptionsForm($form, $form_state); - - $form_state['values']['options']['selected_actions'] = array_filter($form_state['values']['options']['selected_actions']); - } - - /** - * {@inheritdoc} - */ - protected function getBulkOptions($filtered = TRUE) { - // Get all available actions. - $entity_type = $this->getEntityType(); - $options = array(); - // Filter the action list. - foreach ($this->actions as $id => $action) { - if ($filtered) { - $in_selected = in_array($id, $this->options['selected_actions']); - // If the field is configured to include only the selected actions, - // skip actions that were not selected. - if (($this->options['include_exclude'] == 'include') && !$in_selected) { - continue; - } - // Otherwise, if the field is configured to exclude the selected - // actions, skip actions that were selected. - elseif (($this->options['include_exclude'] == 'exclude') && $in_selected) { - continue; - } - } - // Only allow actions that are valid for this entity type. - if (($action->getType() == $entity_type)) { - $options[$id] = $action->label(); - } - } - - return $options; - } - - /** * {@inheritdoc} */ - public function views_form_validate(&$form, &$form_state) { - $selected = array_filter($form_state['values'][$this->options['id']]); - if (empty($selected)) { - $this->formBuilder->setErrorByName('', $form_state, t('No comments selected.')); - } + protected function emptySelectedMessage() { + return $this->t('No comments selected.'); } }