public function SocialGroupViewsBulkOperationsBulkForm::viewsForm in Open Social 8.5
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
- 8.6 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
- 8.7 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
- 8.8 modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
- 10.3.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
- 10.0.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
- 10.1.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
- 10.2.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupViewsBulkOperationsBulkForm.php \Drupal\social_group\Plugin\views\field\SocialGroupViewsBulkOperationsBulkForm::viewsForm()
File
- modules/
social_features/ social_group/ src/ Plugin/ views/ field/ SocialGroupViewsBulkOperationsBulkForm.php, line 62
Class
- SocialGroupViewsBulkOperationsBulkForm
- Defines the Groups Views Bulk Operations field plugin.
Namespace
Drupal\social_group\Plugin\views\fieldCode
public function viewsForm(array &$form, FormStateInterface $form_state) {
$this->view
->setExposedInput([
'status' => TRUE,
]);
parent::viewsForm($form, $form_state);
if ($this->view
->id() !== 'group_manage_members') {
return;
}
// Get pager data if available.
if (!empty($this->view->pager) && method_exists($this->view->pager, 'hasMoreRecords')) {
$pagerData = [
'current' => $this->view->pager
->getCurrentPage(),
'more' => $this->view->pager
->hasMoreRecords(),
];
}
// Render select all results checkbox when there is a pager and more data.
$display_select_all = isset($pagerData) && ($pagerData['more'] || $pagerData['current'] > 0);
if ($display_select_all) {
$form['header'][$this->options['id']]['select_all'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Select all @count results in this view', [
'@count' => $this->tempStoreData['total_results'] ? ' ' . $this->tempStoreData['total_results'] : '',
]),
'#attributes' => [
'class' => [
'vbo-select-all',
'form-no-label',
'checkbox',
],
],
];
}
// Render proper classes for the header in VBO form.
$wrapper =& $form['header'][$this->options['id']];
$wrapper['#attributes']['class'][] = 'card';
$wrapper['#attributes']['class'][] = 'card__block';
$form['#attached']['library'][] = 'social_group/views_bulk_operations.frontUi';
// Render page title.
$count = count($this->tempStoreData['list']);
$title = $this
->formatPlural($count, '<b>@count Member</b> is selected', '<b>@count Members</b> are selected');
$wrapper['multipage']['#title'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => [
'placeholder',
],
],
'#value' => $title,
];
$wrapper['multipage']['list']['#title'] = $this
->t('See selected members on other pages');
// We don't show the multipage list if there are no items selected.
if (count($wrapper['multipage']['list']['#items']) < 1) {
unset($wrapper['multipage']['list']);
}
$actions =& $wrapper['actions'];
$actions['#theme'] = 'links__dropbutton__operations__actions';
$actions['#label'] = $this
->t('Actions');
unset($actions['#type']);
unset($wrapper['multipage']['clear']);
$items = [];
$weights = [
'social_group_send_email_action' => 10,
'social_group_members_export_member_action' => 20,
'social_group_delete_group_content_action' => 30,
'social_group_change_member_role_action' => 40,
];
foreach ($weights as $key => $weight) {
if (isset($actions[$key])) {
$actions[$key]['#weight'] = $weight;
}
}
foreach (Element::children($actions, TRUE) as $key) {
$items[] = $actions[$key];
}
$actions['#links'] = $items;
$form['actions']['#access'] = FALSE;
}