Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -41,8 +41,8 @@ use Drupal\Core\Url;
|
|||
* array('dynamic_content', 'section') for this parameter.
|
||||
*/
|
||||
function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_parents) {
|
||||
$seen_ids = &drupal_static(__FUNCTION__ . ':seen_ids', array());
|
||||
$seen_buttons = &drupal_static(__FUNCTION__ . ':seen_buttons', array());
|
||||
$seen_ids = &drupal_static(__FUNCTION__ . ':seen_ids', []);
|
||||
$seen_buttons = &drupal_static(__FUNCTION__ . ':seen_buttons', []);
|
||||
|
||||
// Add the AJAX behavior to the triggering element.
|
||||
$triggering_element = &$wrapping_element[$trigger_key];
|
||||
|
@ -60,28 +60,28 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa
|
|||
// should be displayed next to the triggering element on the form.
|
||||
$button_key = $trigger_key . '_trigger_update';
|
||||
$element_info = \Drupal::service('element_info');
|
||||
$wrapping_element[$button_key] = array(
|
||||
$wrapping_element[$button_key] = [
|
||||
'#type' => 'submit',
|
||||
// Hide this button when JavaScript is enabled.
|
||||
'#attributes' => array('class' => array('js-hide')),
|
||||
'#submit' => array('views_ui_nojs_submit'),
|
||||
'#attributes' => ['class' => ['js-hide']],
|
||||
'#submit' => ['views_ui_nojs_submit'],
|
||||
// Add a process function to limit this button's validation errors to the
|
||||
// triggering element only. We have to do this in #process since until the
|
||||
// form API has added the #parents property to the triggering element for
|
||||
// us, we don't have any (easy) way to find out where its submitted values
|
||||
// will eventually appear in $form_state->getValues().
|
||||
'#process' => array_merge(array('views_ui_add_limited_validation'), $element_info->getInfoProperty('submit', '#process', array())),
|
||||
'#process' => array_merge(['views_ui_add_limited_validation'], $element_info->getInfoProperty('submit', '#process', [])),
|
||||
// Add an after-build function that inserts a wrapper around the region of
|
||||
// the form that needs to be refreshed by AJAX (so that the AJAX system can
|
||||
// detect and dynamically update it). This is done in #after_build because
|
||||
// it's a convenient place where we have automatic access to the complete
|
||||
// form array, but also to minimize the chance that the HTML we add will
|
||||
// get clobbered by code that runs after we have added it.
|
||||
'#after_build' => array_merge($element_info->getInfoProperty('submit', '#after_build', array()), array('views_ui_add_ajax_wrapper')),
|
||||
);
|
||||
'#after_build' => array_merge($element_info->getInfoProperty('submit', '#after_build', []), ['views_ui_add_ajax_wrapper']),
|
||||
];
|
||||
// Copy #weight and #access from the triggering element to the button, so
|
||||
// that the two elements will be displayed together.
|
||||
foreach (array('#weight', '#access') as $property) {
|
||||
foreach (['#weight', '#access'] as $property) {
|
||||
if (isset($triggering_element[$property])) {
|
||||
$wrapping_element[$button_key][$property] = $triggering_element[$property];
|
||||
}
|
||||
|
@ -92,25 +92,25 @@ function views_ui_add_ajax_trigger(&$wrapping_element, $trigger_key, $refresh_pa
|
|||
// key and it may be a TranslatableMarkup.
|
||||
$button_title = !empty($triggering_element['#title']) ? (string) $triggering_element['#title'] : $trigger_key;
|
||||
if (empty($seen_buttons[$button_title])) {
|
||||
$wrapping_element[$button_key]['#value'] = t('Update "@title" choice', array(
|
||||
$wrapping_element[$button_key]['#value'] = t('Update "@title" choice', [
|
||||
'@title' => $button_title,
|
||||
));
|
||||
]);
|
||||
$seen_buttons[$button_title] = 1;
|
||||
}
|
||||
else {
|
||||
$wrapping_element[$button_key]['#value'] = t('Update "@title" choice (@number)', array(
|
||||
$wrapping_element[$button_key]['#value'] = t('Update "@title" choice (@number)', [
|
||||
'@title' => $button_title,
|
||||
'@number' => ++$seen_buttons[$button_title],
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
// Attach custom data to the triggering element and submit button, so we can
|
||||
// use it in both the process function and AJAX callback.
|
||||
$ajax_data = array(
|
||||
$ajax_data = [
|
||||
'wrapper' => $triggering_element['#ajax']['wrapper'],
|
||||
'trigger_key' => $trigger_key,
|
||||
'refresh_parents' => $refresh_parents,
|
||||
);
|
||||
];
|
||||
$seen_ids[$triggering_element['#ajax']['wrapper']] = TRUE;
|
||||
$triggering_element['#views_ui_ajax_data'] = $ajax_data;
|
||||
$wrapping_element[$button_key]['#views_ui_ajax_data'] = $ajax_data;
|
||||
|
@ -132,7 +132,7 @@ function views_ui_add_limited_validation($element, FormStateInterface $form_stat
|
|||
// Limit this button's validation to the AJAX triggering element, so it can
|
||||
// update the form for that change without requiring that the rest of the
|
||||
// form be filled out properly yet.
|
||||
$element['#limit_validation_errors'] = array($ajax_triggering_element['#parents']);
|
||||
$element['#limit_validation_errors'] = [$ajax_triggering_element['#parents']];
|
||||
|
||||
// If we are in the process of a form submission and this is the button that
|
||||
// was clicked, the form API workflow in \Drupal::formBuilder()->doBuildForm()
|
||||
|
@ -165,10 +165,10 @@ function views_ui_add_ajax_wrapper($element, FormStateInterface $form_state) {
|
|||
// The HTML ID that AJAX expects was also stored in a property on the
|
||||
// element, so use that information to insert the wrapper <div> here.
|
||||
$id = $element['#views_ui_ajax_data']['wrapper'];
|
||||
$refresh_element += array(
|
||||
$refresh_element += [
|
||||
'#prefix' => '',
|
||||
'#suffix' => '',
|
||||
);
|
||||
];
|
||||
$refresh_element['#prefix'] = '<div id="' . $id . '" class="views-ui-ajax-wrapper">' . $refresh_element['#prefix'];
|
||||
$refresh_element['#suffix'] .= '</div>';
|
||||
|
||||
|
@ -213,16 +213,16 @@ function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_sta
|
|||
|
||||
// @todo Move this to a separate function if it's needed on any forms that
|
||||
// don't have the display dropdown.
|
||||
$form['override'] = array(
|
||||
$form['override'] = [
|
||||
'#prefix' => '<div class="views-override clearfix form--inline views-offset-top" data-drupal-views-offset="top">',
|
||||
'#suffix' => '</div>',
|
||||
'#weight' => -1000,
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
// Add the "2 of 3" progress indicator.
|
||||
if ($form_progress = $view->getFormProgress()) {
|
||||
$form['progress']['#markup'] = '<div id="views-progress-indicator" class="views-progress-indicator">' . t('@current of @total', array('@current' => $form_progress['current'], '@total' => $form_progress['total'])) . '</div>';
|
||||
$form['progress']['#markup'] = '<div id="views-progress-indicator" class="views-progress-indicator">' . t('@current of @total', ['@current' => $form_progress['current'], '@total' => $form_progress['total']]) . '</div>';
|
||||
$form['progress']['#weight'] = -1001;
|
||||
}
|
||||
|
||||
|
@ -247,17 +247,17 @@ function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_sta
|
|||
}
|
||||
|
||||
$display_dropdown['default'] = ($section_overrides ? t('All displays (except overridden)') : t('All displays'));
|
||||
$display_dropdown[$display_id] = t('This @display_type (override)', array('@display_type' => $current_display->getPluginId()));
|
||||
$display_dropdown[$display_id] = t('This @display_type (override)', ['@display_type' => $current_display->getPluginId()]);
|
||||
// Only display the revert option if we are in a overridden section.
|
||||
if (!$section_defaulted) {
|
||||
$display_dropdown['default_revert'] = t('Revert to default');
|
||||
}
|
||||
|
||||
$form['override']['dropdown'] = array(
|
||||
$form['override']['dropdown'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('For'), // @TODO: Translators may need more context than this.
|
||||
'#options' => $display_dropdown,
|
||||
);
|
||||
];
|
||||
if ($current_display->isDefaulted($section)) {
|
||||
$form['override']['dropdown']['#default_value'] = 'defaults';
|
||||
}
|
||||
|
|
|
@ -170,9 +170,9 @@ details.box-padding {
|
|||
margin-bottom: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.views-ui-view-title {
|
||||
.views-ui-view-name h3 {
|
||||
font-weight: bold;
|
||||
margin-top: 0;
|
||||
margin: 0.25em 0;
|
||||
}
|
||||
.view-changed {
|
||||
margin-bottom: 21px;
|
||||
|
@ -183,22 +183,33 @@ details.box-padding {
|
|||
margin-bottom: 0;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.views-ui-view-displays ul {
|
||||
margin-left: 0; /* LTR */
|
||||
padding-left: 0; /* LTR */
|
||||
list-style: none;
|
||||
}
|
||||
[dir="rtl"] .views-ui-view-displays ul {
|
||||
margin-right: 0;
|
||||
padding-right: 0;
|
||||
margin-left: inherit;
|
||||
padding-left: inherit;
|
||||
}
|
||||
|
||||
/* These header classes are ambiguous and should be scoped to th elements */
|
||||
.views-ui-name {
|
||||
width: 18%;
|
||||
width: 20%;
|
||||
}
|
||||
.views-ui-description {
|
||||
width: 26%;
|
||||
width: 30%;
|
||||
}
|
||||
.views-ui-tag {
|
||||
width: 8%;
|
||||
.views-ui-machine-name {
|
||||
width: 15%;
|
||||
}
|
||||
.views-ui-path {
|
||||
width: auto;
|
||||
.views-ui-displays {
|
||||
width: 25%;
|
||||
}
|
||||
.views-ui-operations {
|
||||
width: 24%;
|
||||
width: 10%;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -187,13 +187,12 @@
|
|||
// Bind AJAX behaviors to all items showing the class.
|
||||
$('a.views-ajax-link', context).once('views-ajax').each(function () {
|
||||
var element_settings = base_element_settings;
|
||||
element_settings.base = base;
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
// Set the URL to go to the anchor.
|
||||
if ($(this).attr('href')) {
|
||||
element_settings.url = $(this).attr('href');
|
||||
}
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax(element_settings);
|
||||
});
|
||||
|
||||
|
@ -213,9 +212,8 @@
|
|||
|
||||
element_settings.wrapper = 'views-preview-wrapper';
|
||||
element_settings.method = 'replaceWith';
|
||||
element_settings.base = base;
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax(element_settings);
|
||||
});
|
||||
|
||||
|
@ -239,10 +237,9 @@
|
|||
element_settings.wrapper = 'views-preview-wrapper';
|
||||
element_settings.method = 'replaceWith';
|
||||
element_settings.event = 'click';
|
||||
element_settings.base = base;
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax(element_settings);
|
||||
});
|
||||
|
||||
|
|
|
@ -483,18 +483,18 @@
|
|||
* An array of all the filterable options.
|
||||
*/
|
||||
getOptions: function ($allOptions) {
|
||||
var $label;
|
||||
var $title;
|
||||
var $description;
|
||||
var $option;
|
||||
var options = [];
|
||||
var length = $allOptions.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
$option = $($allOptions[i]);
|
||||
$label = $option.find('label');
|
||||
$title = $option.find('.title');
|
||||
$description = $option.find('.description');
|
||||
options[i] = {
|
||||
// Search on the lowercase version of the label text + description.
|
||||
searchText: $label.text().toLowerCase() + ' ' + $description.text().toLowerCase(),
|
||||
// Search on the lowercase version of the title text + description.
|
||||
searchText: $title.text().toLowerCase() + ' ' + $description.text().toLowerCase(),
|
||||
// Maintain a reference to the jQuery object for each row, so we don't
|
||||
// have to create a new object inside the performance-sensitive keyup
|
||||
// handler.
|
||||
|
@ -708,6 +708,7 @@
|
|||
// When the link is clicked, dynamically click the hidden form button
|
||||
// for adding a new filter group.
|
||||
.once('views-rearrange-filter-handler')
|
||||
.find('#views-add-group-link')
|
||||
.on('click.views-rearrange-filter-handler', $.proxy(this, 'clickAddGroupButton'));
|
||||
|
||||
// Find each (visually hidden) button for removing a filter group and
|
||||
|
|
|
@ -32,10 +32,10 @@ class SetFormCommand implements CommandInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
return array(
|
||||
return [
|
||||
'command' => 'viewsSetForm',
|
||||
'url' => $this->url,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class ViewsUIController extends ControllerBase {
|
|||
|
||||
// Fetch all fieldapi fields which are used in views
|
||||
// Therefore search in all views, displays and handler-types.
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
$handler_types = ViewExecutable::getHandlerTypes();
|
||||
foreach ($views as $view) {
|
||||
$executable = $view->getExecutable();
|
||||
|
@ -81,12 +81,12 @@ class ViewsUIController extends ControllerBase {
|
|||
}
|
||||
}
|
||||
|
||||
$header = array(t('Field name'), t('Used in'));
|
||||
$rows = array();
|
||||
$header = [t('Field name'), t('Used in')];
|
||||
$rows = [];
|
||||
foreach ($fields as $field_name => $views) {
|
||||
$rows[$field_name]['data'][0]['data']['#plain_text'] = $field_name;
|
||||
foreach ($views as $view) {
|
||||
$rows[$field_name]['data'][1][] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view)));
|
||||
$rows[$field_name]['data'][1][] = $this->l($view, new Url('entity.view.edit_form', ['view' => $view]));
|
||||
}
|
||||
$item_list = [
|
||||
'#theme' => 'item_list',
|
||||
|
@ -98,12 +98,12 @@ class ViewsUIController extends ControllerBase {
|
|||
|
||||
// Sort rows by field name.
|
||||
ksort($rows);
|
||||
$output = array(
|
||||
$output = [
|
||||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#empty' => t('No fields have been used in views yet.'),
|
||||
);
|
||||
];
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class ViewsUIController extends ControllerBase {
|
|||
$views = [];
|
||||
// Link each view name to the view itself.
|
||||
foreach ($row['views'] as $row_name => $view) {
|
||||
$views[] = $this->l($view, new Url('entity.view.edit_form', array('view' => $view)));
|
||||
$views[] = $this->l($view, new Url('entity.view.edit_form', ['view' => $view]));
|
||||
}
|
||||
unset($row['views']);
|
||||
$row['views']['data'] = [
|
||||
|
@ -132,12 +132,12 @@ class ViewsUIController extends ControllerBase {
|
|||
|
||||
// Sort rows by field name.
|
||||
ksort($rows);
|
||||
return array(
|
||||
return [
|
||||
'#type' => 'table',
|
||||
'#header' => array(t('Type'), t('Name'), t('Provided by'), t('Used in')),
|
||||
'#header' => [t('Type'), t('Name'), t('Provided by'), t('Used in')],
|
||||
'#rows' => $rows,
|
||||
'#empty' => t('There are no enabled views.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,7 +180,7 @@ class ViewsUIController extends ControllerBase {
|
|||
* A JSON response containing the autocomplete suggestions for Views tags.
|
||||
*/
|
||||
public function autocompleteTag(Request $request) {
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
$string = $request->query->get('q');
|
||||
// Get matches from default views.
|
||||
$views = $this->entityManager()->getStorage('view')->loadMultiple();
|
||||
|
@ -223,8 +223,8 @@ class ViewsUIController extends ControllerBase {
|
|||
}
|
||||
$build['#title'] = $name;
|
||||
|
||||
$build['edit'] = $this->entityFormBuilder()->getForm($view, 'edit', array('display_id' => $display_id));
|
||||
$build['preview'] = $this->entityFormBuilder()->getForm($view, 'preview', array('display_id' => $display_id));
|
||||
$build['edit'] = $this->entityFormBuilder()->getForm($view, 'edit', ['display_id' => $display_id]);
|
||||
$build['preview'] = $this->entityFormBuilder()->getForm($view, 'preview', ['display_id' => $display_id]);
|
||||
return $build;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,52 +32,52 @@ class AdvancedSettingsForm extends ConfigFormBase {
|
|||
$form = parent::buildForm($form, $form_state);
|
||||
|
||||
$config = $this->config('views.settings');
|
||||
$form['cache'] = array(
|
||||
$form['cache'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Caching'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['cache']['skip_cache'] = array(
|
||||
$form['cache']['skip_cache'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Disable views data caching'),
|
||||
'#description' => $this->t("Views caches data about tables, modules and views available, to increase performance. By checking this box, Views will skip this cache and always rebuild this data when needed. This can have a serious performance impact on your site."),
|
||||
'#default_value' => $config->get('skip_cache'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['cache']['clear_cache'] = array(
|
||||
$form['cache']['clear_cache'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t("Clear Views' cache"),
|
||||
'#submit' => array('::cacheSubmit'),
|
||||
);
|
||||
'#submit' => ['::cacheSubmit'],
|
||||
];
|
||||
|
||||
$form['debug'] = array(
|
||||
$form['debug'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Debugging'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['debug']['sql_signature'] = array(
|
||||
$form['debug']['sql_signature'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Add Views signature to all SQL queries'),
|
||||
'#description' => $this->t("All Views-generated queries will include the name of the views and display 'view-name:display-name' as a string at the end of the SELECT clause. This makes identifying Views queries in database server logs simpler, but should only be used when troubleshooting."),
|
||||
|
||||
'#default_value' => $config->get('sql_signature'),
|
||||
);
|
||||
];
|
||||
|
||||
$options = Views::fetchPluginNames('display_extender');
|
||||
if (!empty($options)) {
|
||||
$form['extenders'] = array(
|
||||
$form['extenders'] = [
|
||||
'#type' => 'details',
|
||||
'#open' => TRUE,
|
||||
);
|
||||
$form['extenders']['display_extenders'] = array(
|
||||
];
|
||||
$form['extenders']['display_extenders'] = [
|
||||
'#title' => $this->t('Display extenders'),
|
||||
'#default_value' => array_filter($config->get('display_extenders')),
|
||||
'#options' => $options,
|
||||
'#type' => 'checkboxes',
|
||||
'#description' => $this->t('Select extensions of the views interface.')
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $form;
|
||||
|
@ -90,7 +90,7 @@ class AdvancedSettingsForm extends ConfigFormBase {
|
|||
$this->config('views.settings')
|
||||
->set('skip_cache', $form_state->getValue('skip_cache'))
|
||||
->set('sql_signature', $form_state->getValue('sql_signature'))
|
||||
->set('display_extenders', $form_state->getValue('display_extenders', array()))
|
||||
->set('display_extenders', $form_state->getValue('display_extenders', []))
|
||||
->save();
|
||||
|
||||
parent::submitForm($form, $form_state);
|
||||
|
|
|
@ -49,16 +49,16 @@ class AddHandler extends ViewsFormBase {
|
|||
$display_id = $form_state->get('display_id');
|
||||
$type = $form_state->get('type');
|
||||
|
||||
$form = array(
|
||||
'options' => array(
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
|
||||
),
|
||||
);
|
||||
$form = [
|
||||
'options' => [
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
|
||||
],
|
||||
];
|
||||
|
||||
$executable = $view->getExecutable();
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
|
||||
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
|
||||
return $form;
|
||||
}
|
||||
$display = &$executable->displayHandlers->get($display_id);
|
||||
|
@ -71,7 +71,7 @@ class AddHandler extends ViewsFormBase {
|
|||
$type = $types[$type]['type'];
|
||||
}
|
||||
|
||||
$form['#title'] = $this->t('Add @type', array('@type' => $ltitle));
|
||||
$form['#title'] = $this->t('Add @type', ['@type' => $ltitle]);
|
||||
$form['#section'] = $display_id . 'add-handler';
|
||||
|
||||
// Add the display override dropdown.
|
||||
|
@ -82,36 +82,36 @@ class AddHandler extends ViewsFormBase {
|
|||
$options = Views::viewsDataHelper()->fetchFields(array_keys($base_tables), $type, $display->useGroupBy(), $form_state->get('type'));
|
||||
|
||||
if (!empty($options)) {
|
||||
$form['override']['controls'] = array(
|
||||
'#theme_wrappers' => array('container'),
|
||||
$form['override']['controls'] = [
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#id' => 'views-filterable-options-controls',
|
||||
'#attributes' => ['class' => ['form--inline', 'views-filterable-options-controls']],
|
||||
);
|
||||
$form['override']['controls']['options_search'] = array(
|
||||
];
|
||||
$form['override']['controls']['options_search'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Search'),
|
||||
);
|
||||
];
|
||||
|
||||
$groups = array('all' => $this->t('- All -'));
|
||||
$form['override']['controls']['group'] = array(
|
||||
$groups = ['all' => $this->t('- All -')];
|
||||
$form['override']['controls']['group'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Category'),
|
||||
'#options' => array(),
|
||||
);
|
||||
'#options' => [],
|
||||
];
|
||||
|
||||
$form['options']['name'] = array(
|
||||
$form['options']['name'] = [
|
||||
'#prefix' => '<div class="views-radio-box form-checkboxes views-filterable-options">',
|
||||
'#suffix' => '</div>',
|
||||
'#type' => 'tableselect',
|
||||
'#header' => array(
|
||||
'#header' => [
|
||||
'title' => $this->t('Title'),
|
||||
'group' => $this->t('Category'),
|
||||
'help' => $this->t('Description'),
|
||||
),
|
||||
],
|
||||
'#js_select' => FALSE,
|
||||
);
|
||||
];
|
||||
|
||||
$grouped_options = array();
|
||||
$grouped_options = [];
|
||||
foreach ($options as $key => $option) {
|
||||
$group = preg_replace('/[^a-z0-9]/', '-', strtolower($option['group']));
|
||||
$groups[$group] = $option['group'];
|
||||
|
@ -136,50 +136,50 @@ class AddHandler extends ViewsFormBase {
|
|||
|
||||
foreach ($grouped_options as $group => $group_options) {
|
||||
foreach ($group_options as $key => $option) {
|
||||
$form['options']['name']['#options'][$key] = array(
|
||||
'#attributes' => array(
|
||||
'class' => array('filterable-option', $group),
|
||||
),
|
||||
'title' => array(
|
||||
'data' => array(
|
||||
$form['options']['name']['#options'][$key] = [
|
||||
'#attributes' => [
|
||||
'class' => ['filterable-option', $group],
|
||||
],
|
||||
'title' => [
|
||||
'data' => [
|
||||
'#title' => $option['title'],
|
||||
'#plain_text' => $option['title'],
|
||||
),
|
||||
'class' => array('title'),
|
||||
),
|
||||
],
|
||||
'class' => ['title'],
|
||||
],
|
||||
'group' => $option['group'],
|
||||
'help' => array(
|
||||
'help' => [
|
||||
'data' => $option['help'],
|
||||
'class' => array('description'),
|
||||
),
|
||||
);
|
||||
'class' => ['description'],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$form['override']['controls']['group']['#options'] = $groups;
|
||||
}
|
||||
else {
|
||||
$form['options']['markup'] = array(
|
||||
'#markup' => '<div class="js-form-item form-item">' . $this->t('There are no @types available to add.', array('@types' => $ltitle)) . '</div>',
|
||||
);
|
||||
$form['options']['markup'] = [
|
||||
'#markup' => '<div class="js-form-item form-item">' . $this->t('There are no @types available to add.', ['@types' => $ltitle]) . '</div>',
|
||||
];
|
||||
}
|
||||
// Add a div to show the selected items
|
||||
$form['selected'] = array(
|
||||
$form['selected'] = [
|
||||
'#type' => 'item',
|
||||
'#markup' => '<span class="views-ui-view-title">' . $this->t('Selected:') . '</span> ' . '<div class="views-selected-options"></div>',
|
||||
'#theme_wrappers' => array('form_element', 'views_ui_container'),
|
||||
'#attributes' => array(
|
||||
'class' => array('container-inline', 'views-add-form-selected', 'views-offset-bottom'),
|
||||
'#theme_wrappers' => ['form_element', 'views_ui_container'],
|
||||
'#attributes' => [
|
||||
'class' => ['container-inline', 'views-add-form-selected', 'views-offset-bottom'],
|
||||
'data-drupal-views-offset' => 'bottom',
|
||||
),
|
||||
);
|
||||
$view->getStandardButtons($form, $form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', array('@types' => $ltitle)));
|
||||
],
|
||||
];
|
||||
$view->getStandardButtons($form, $form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', ['@types' => $ltitle]));
|
||||
|
||||
// Remove the default submit function.
|
||||
$form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit'], function($var) {
|
||||
return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit');
|
||||
});
|
||||
$form['actions']['submit']['#submit'][] = array($view, 'submitItemAdd');
|
||||
$form['actions']['submit']['#submit'][] = [$view, 'submitItemAdd'];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@ class Analyze extends ViewsFormBase {
|
|||
$analyzer = Views::analyzer();
|
||||
$messages = $analyzer->getMessages($view->getExecutable());
|
||||
|
||||
$form['analysis'] = array(
|
||||
$form['analysis'] = [
|
||||
'#prefix' => '<div class="js-form-item form-item">',
|
||||
'#suffix' => '</div>',
|
||||
'#markup' => $analyzer->formatMessages($messages),
|
||||
);
|
||||
];
|
||||
|
||||
// Inform the standard button function that we want an OK button.
|
||||
$form_state->set('ok_button', TRUE);
|
||||
|
|
|
@ -54,17 +54,17 @@ class ConfigHandler extends ViewsFormBase {
|
|||
$type = $form_state->get('type');
|
||||
$id = $form_state->get('id');
|
||||
|
||||
$form = array(
|
||||
'options' => array(
|
||||
$form = [
|
||||
'options' => [
|
||||
'#tree' => TRUE,
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
|
||||
),
|
||||
);
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
|
||||
],
|
||||
];
|
||||
$executable = $view->getExecutable();
|
||||
$save_ui_cache = FALSE;
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
|
||||
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
|
||||
return $form;
|
||||
}
|
||||
$item = $executable->getHandler($display_id, $type, $id);
|
||||
|
@ -72,7 +72,7 @@ class ConfigHandler extends ViewsFormBase {
|
|||
if ($item) {
|
||||
$handler = $executable->display_handler->getHandler($type, $id);
|
||||
if (empty($handler)) {
|
||||
$form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
|
||||
$form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
|
||||
}
|
||||
else {
|
||||
$types = ViewExecutable::getHandlerTypes();
|
||||
|
@ -88,7 +88,7 @@ class ConfigHandler extends ViewsFormBase {
|
|||
// A whole bunch of code to figure out what relationships are valid for
|
||||
// this item.
|
||||
$relationships = $executable->display_handler->getOption('relationships');
|
||||
$relationship_options = array();
|
||||
$relationship_options = [];
|
||||
|
||||
foreach ($relationships as $relationship) {
|
||||
// relationships can't link back to self. But also, due to ordering,
|
||||
|
@ -118,7 +118,7 @@ class ConfigHandler extends ViewsFormBase {
|
|||
// it to none.
|
||||
$base_fields = Views::viewsDataHelper()->fetchFields($view->get('base_table'), $type, $executable->display_handler->useGroupBy());
|
||||
if (isset($base_fields[$item['table'] . '.' . $item['field']])) {
|
||||
$relationship_options = array_merge(array('none' => $this->t('Do not use a relationship')), $relationship_options);
|
||||
$relationship_options = array_merge(['none' => $this->t('Do not use a relationship')], $relationship_options);
|
||||
}
|
||||
$rel = empty($item['relationship']) ? 'none' : $item['relationship'];
|
||||
if (empty($relationship_options[$rel])) {
|
||||
|
@ -133,30 +133,30 @@ class ConfigHandler extends ViewsFormBase {
|
|||
$handler->init($executable, $executable->display_handler, $item);
|
||||
}
|
||||
|
||||
$form['options']['relationship'] = array(
|
||||
$form['options']['relationship'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Relationship'),
|
||||
'#options' => $relationship_options,
|
||||
'#default_value' => $rel,
|
||||
'#weight' => -500,
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$form['options']['relationship'] = array(
|
||||
$form['options']['relationship'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => 'none',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$form['#title'] = $this->t('Configure @type: @item', array('@type' => $types[$type]['lstitle'], '@item' => $handler->adminLabel()));
|
||||
$form['#title'] = $this->t('Configure @type: @item', ['@type' => $types[$type]['lstitle'], '@item' => $handler->adminLabel()]);
|
||||
|
||||
if (!empty($handler->definition['help'])) {
|
||||
$form['options']['form_description'] = array(
|
||||
$form['options']['form_description'] = [
|
||||
'#markup' => $handler->definition['help'],
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('js-form-item form-item description')),
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['class' => ['js-form-item form-item description']],
|
||||
'#weight' => -1000,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$form['#section'] = $display_id . '-' . $type . '-' . $id;
|
||||
|
@ -170,13 +170,13 @@ class ConfigHandler extends ViewsFormBase {
|
|||
|
||||
$view->getStandardButtons($form, $form_state, 'views_ui_config_item_form', $name);
|
||||
// Add a 'remove' button.
|
||||
$form['actions']['remove'] = array(
|
||||
$form['actions']['remove'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Remove'),
|
||||
'#submit' => array(array($this, 'remove')),
|
||||
'#limit_validation_errors' => array(array('override')),
|
||||
'#submit' => [[$this, 'remove']],
|
||||
'#limit_validation_errors' => [['override']],
|
||||
'#button_type' => 'danger',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if ($save_ui_cache) {
|
||||
|
|
|
@ -51,16 +51,16 @@ class ConfigHandlerExtra extends ViewsFormBase {
|
|||
$type = $form_state->get('type');
|
||||
$id = $form_state->get('id');
|
||||
|
||||
$form = array(
|
||||
'options' => array(
|
||||
$form = [
|
||||
'options' => [
|
||||
'#tree' => TRUE,
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
|
||||
),
|
||||
);
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
|
||||
],
|
||||
];
|
||||
$executable = $view->getExecutable();
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
|
||||
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
|
||||
return $form;
|
||||
}
|
||||
$item = $executable->getHandler($display_id, $type, $id);
|
||||
|
@ -68,13 +68,13 @@ class ConfigHandlerExtra extends ViewsFormBase {
|
|||
if ($item) {
|
||||
$handler = $executable->display_handler->getHandler($type, $id);
|
||||
if (empty($handler)) {
|
||||
$form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
|
||||
$form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
|
||||
}
|
||||
else {
|
||||
$handler->init($executable, $executable->display_handler, $item);
|
||||
$types = ViewExecutable::getHandlerTypes();
|
||||
|
||||
$form['#title'] = $this->t('Configure extra settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
|
||||
$form['#title'] = $this->t('Configure extra settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);
|
||||
|
||||
$form['#section'] = $display_id . '-' . $type . '-' . $id;
|
||||
|
||||
|
|
|
@ -52,16 +52,16 @@ class ConfigHandlerGroup extends ViewsFormBase {
|
|||
$type = $form_state->get('type');
|
||||
$id = $form_state->get('id');
|
||||
|
||||
$form = array(
|
||||
'options' => array(
|
||||
$form = [
|
||||
'options' => [
|
||||
'#tree' => TRUE,
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
|
||||
),
|
||||
);
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
|
||||
],
|
||||
];
|
||||
$executable = $view->getExecutable();
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
|
||||
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -72,13 +72,13 @@ class ConfigHandlerGroup extends ViewsFormBase {
|
|||
if ($item) {
|
||||
$handler = $executable->display_handler->getHandler($type, $id);
|
||||
if (empty($handler)) {
|
||||
$form['markup'] = array('#markup' => $this->t("Error: handler for @table > @field doesn't exist!", array('@table' => $item['table'], '@field' => $item['field'])));
|
||||
$form['markup'] = ['#markup' => $this->t("Error: handler for @table > @field doesn't exist!", ['@table' => $item['table'], '@field' => $item['field']])];
|
||||
}
|
||||
else {
|
||||
$handler->init($executable, $executable->display_handler, $item);
|
||||
$types = ViewExecutable::getHandlerTypes();
|
||||
|
||||
$form['#title'] = $this->t('Configure aggregation settings for @type %item', array('@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()));
|
||||
$form['#title'] = $this->t('Configure aggregation settings for @type %item', ['@type' => $types[$type]['lstitle'], '%item' => $handler->adminLabel()]);
|
||||
|
||||
$handler->buildGroupByForm($form['options'], $form_state);
|
||||
$form_state->set('handler', $handler);
|
||||
|
|
|
@ -60,15 +60,15 @@ class Display extends ViewsFormBase {
|
|||
|
||||
$executable = $view->getExecutable();
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
|
||||
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
|
||||
return $form;
|
||||
}
|
||||
|
||||
// Get form from the handler.
|
||||
$form['options'] = array(
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
|
||||
);
|
||||
$form['options'] = [
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
|
||||
];
|
||||
$executable->display_handler->buildOptionsForm($form['options'], $form_state);
|
||||
|
||||
// The handler options form sets $form['#title'], which we need on the entire
|
||||
|
|
|
@ -33,33 +33,33 @@ class EditDetails extends ViewsFormBase {
|
|||
$form['#title'] = $this->t('Name and description');
|
||||
$form['#section'] = 'details';
|
||||
|
||||
$form['details'] = array(
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('scroll'), 'data-drupal-views-scroll' => TRUE),
|
||||
);
|
||||
$form['details']['label'] = array(
|
||||
$form['details'] = [
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['class' => ['scroll'], 'data-drupal-views-scroll' => TRUE],
|
||||
];
|
||||
$form['details']['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Administrative name'),
|
||||
'#default_value' => $view->label(),
|
||||
);
|
||||
$form['details']['langcode'] = array(
|
||||
];
|
||||
$form['details']['langcode'] = [
|
||||
'#type' => 'language_select',
|
||||
'#title' => $this->t('View language'),
|
||||
'#description' => $this->t('Language of labels and other textual elements in this view.'),
|
||||
'#default_value' => $view->get('langcode'),
|
||||
);
|
||||
$form['details']['description'] = array(
|
||||
];
|
||||
$form['details']['description'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Administrative description'),
|
||||
'#default_value' => $view->get('description'),
|
||||
);
|
||||
$form['details']['tag'] = array(
|
||||
];
|
||||
$form['details']['tag'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Administrative tags'),
|
||||
'#description' => t('Enter a comma-separated list of words to describe your view.'),
|
||||
'#default_value' => $view->get('tag'),
|
||||
'#autocomplete_route_name' => 'views_ui.autocomplete',
|
||||
);
|
||||
];
|
||||
|
||||
$view->getStandardButtons($form, $form_state, 'views_ui_edit_details_form');
|
||||
return $form;
|
||||
|
|
|
@ -53,11 +53,11 @@ class Rearrange extends ViewsFormBase {
|
|||
$types = ViewExecutable::getHandlerTypes();
|
||||
$executable = $view->getExecutable();
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
|
||||
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
|
||||
return $form;
|
||||
}
|
||||
$display = &$executable->displayHandlers->get($display_id);
|
||||
$form['#title'] = $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle']));
|
||||
$form['#title'] = $this->t('Rearrange @type', ['@type' => $types[$type]['ltitle']]);
|
||||
$form['#section'] = $display_id . 'rearrange-item';
|
||||
|
||||
if ($display->defaultableSections($types[$type]['plural'])) {
|
||||
|
@ -69,31 +69,31 @@ class Rearrange extends ViewsFormBase {
|
|||
$count = 0;
|
||||
|
||||
// Get relationship labels
|
||||
$relationships = array();
|
||||
$relationships = [];
|
||||
foreach ($display->getHandlers('relationship') as $id => $handler) {
|
||||
$relationships[$id] = $handler->adminLabel();
|
||||
}
|
||||
|
||||
$form['fields'] = array(
|
||||
$form['fields'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => array('', $this->t('Weight'), $this->t('Remove')),
|
||||
'#header' => ['', $this->t('Weight'), $this->t('Remove')],
|
||||
'#empty' => $this->t('No fields available.'),
|
||||
'#tabledrag' => array(
|
||||
array(
|
||||
'#tabledrag' => [
|
||||
[
|
||||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
)
|
||||
),
|
||||
]
|
||||
],
|
||||
'#tree' => TRUE,
|
||||
'#prefix' => '<div class="scroll" data-drupal-views-scroll>',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($display->getOption($types[$type]['plural']) as $id => $field) {
|
||||
$form['fields'][$id] = array();
|
||||
$form['fields'][$id] = [];
|
||||
|
||||
$form['fields'][$id]['#attributes'] = array('class' => array('draggable'), 'id' => 'views-row-' . $id);
|
||||
$form['fields'][$id]['#attributes'] = ['class' => ['draggable'], 'id' => 'views-row-' . $id];
|
||||
|
||||
$handler = $display->getHandler($type, $id);
|
||||
if ($handler) {
|
||||
|
@ -105,34 +105,34 @@ class Rearrange extends ViewsFormBase {
|
|||
}
|
||||
else {
|
||||
$name = $id;
|
||||
$markup = $this->t('Broken field @id', array('@id' => $id));
|
||||
$markup = $this->t('Broken field @id', ['@id' => $id]);
|
||||
}
|
||||
$form['fields'][$id]['name'] = array('#markup' => $markup);
|
||||
$form['fields'][$id]['name'] = ['#markup' => $markup];
|
||||
|
||||
$form['fields'][$id]['weight'] = array(
|
||||
$form['fields'][$id]['weight'] = [
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => ++$count,
|
||||
'#attributes' => array('class' => array('weight')),
|
||||
'#title' => t('Weight for @title', array('@title' => $name)),
|
||||
'#attributes' => ['class' => ['weight']],
|
||||
'#title' => t('Weight for @title', ['@title' => $name]),
|
||||
'#title_display' => 'invisible',
|
||||
);
|
||||
];
|
||||
|
||||
$form['fields'][$id]['removed'] = array(
|
||||
$form['fields'][$id]['removed'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Remove @title', array('@title' => $name)),
|
||||
'#title' => t('Remove @title', ['@title' => $name]),
|
||||
'#title_display' => 'invisible',
|
||||
'#id' => 'views-removed-' . $id,
|
||||
'#attributes' => array('class' => array('views-remove-checkbox')),
|
||||
'#attributes' => ['class' => ['views-remove-checkbox']],
|
||||
'#default_value' => 0,
|
||||
'#suffix' => \Drupal::l(SafeMarkup::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
|
||||
Url::fromRoute('<none>', array(), array('attributes' => array(
|
||||
'#suffix' => \Drupal::l(SafeMarkup::format('<span>@text</span>', ['@text' => $this->t('Remove')]),
|
||||
Url::fromRoute('<none>', [], ['attributes' => [
|
||||
'id' => 'views-remove-link-' . $id,
|
||||
'class' => array('views-hidden', 'views-button-remove', 'views-remove-link'),
|
||||
'class' => ['views-hidden', 'views-button-remove', 'views-remove-link'],
|
||||
'alt' => $this->t('Remove this item'),
|
||||
'title' => $this->t('Remove this item')),
|
||||
))
|
||||
'title' => $this->t('Remove this item')],
|
||||
])
|
||||
),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$view->getStandardButtons($form, $form_state, 'views_ui_rearrange_form');
|
||||
|
@ -152,7 +152,7 @@ class Rearrange extends ViewsFormBase {
|
|||
$display = &$view->getExecutable()->displayHandlers->get($display_id);
|
||||
|
||||
$old_fields = $display->getOption($types[$type]['plural']);
|
||||
$new_fields = $order = array();
|
||||
$new_fields = $order = [];
|
||||
|
||||
// Make an array with the weights
|
||||
foreach ($form_state->getValue('fields') as $field => $info) {
|
||||
|
|
|
@ -43,12 +43,12 @@ class RearrangeFilter extends ViewsFormBase {
|
|||
$types = ViewExecutable::getHandlerTypes();
|
||||
$executable = $view->getExecutable();
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
$form['markup'] = array('#markup' => $this->t('Invalid display id @display', array('@display' => $display_id)));
|
||||
$form['markup'] = ['#markup' => $this->t('Invalid display id @display', ['@display' => $display_id])];
|
||||
return $form;
|
||||
}
|
||||
$display = $executable->displayHandlers->get($display_id);
|
||||
$form['#title'] = Html::escape($display->display['display_title']) . ': ';
|
||||
$form['#title'] .= $this->t('Rearrange @type', array('@type' => $types[$type]['ltitle']));
|
||||
$form['#title'] .= $this->t('Rearrange @type', ['@type' => $types[$type]['ltitle']]);
|
||||
$form['#section'] = $display_id . 'rearrange-item';
|
||||
|
||||
if ($display->defaultableSections($types[$type]['plural'])) {
|
||||
|
@ -68,12 +68,12 @@ class RearrangeFilter extends ViewsFormBase {
|
|||
$count = 0;
|
||||
|
||||
// Get relationship labels
|
||||
$relationships = array();
|
||||
$relationships = [];
|
||||
foreach ($display->getHandlers('relationship') as $id => $handler) {
|
||||
$relationships[$id] = $handler->adminLabel();
|
||||
}
|
||||
|
||||
$group_options = array();
|
||||
$group_options = [];
|
||||
|
||||
/**
|
||||
* Filter groups is an array that contains:
|
||||
|
@ -88,59 +88,59 @@ class RearrangeFilter extends ViewsFormBase {
|
|||
$grouping = count(array_keys($groups['groups'])) > 1;
|
||||
|
||||
$form['filter_groups']['#tree'] = TRUE;
|
||||
$form['filter_groups']['operator'] = array(
|
||||
$form['filter_groups']['operator'] = [
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'AND' => $this->t('And'),
|
||||
'OR' => $this->t('Or'),
|
||||
),
|
||||
],
|
||||
'#default_value' => $groups['operator'],
|
||||
'#attributes' => array(
|
||||
'class' => array('warning-on-change'),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['warning-on-change'],
|
||||
],
|
||||
'#title' => $this->t('Operator to use on all groups'),
|
||||
'#description' => $this->t('Either "group 0 AND group 1 AND group 2" or "group 0 OR group 1 OR group 2", etc'),
|
||||
'#access' => $grouping,
|
||||
);
|
||||
];
|
||||
|
||||
$form['remove_groups']['#tree'] = TRUE;
|
||||
|
||||
foreach ($groups['groups'] as $id => $group) {
|
||||
$form['filter_groups']['groups'][$id] = array(
|
||||
$form['filter_groups']['groups'][$id] = [
|
||||
'#title' => $this->t('Operator'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'AND' => $this->t('And'),
|
||||
'OR' => $this->t('Or'),
|
||||
),
|
||||
],
|
||||
'#default_value' => $group,
|
||||
'#attributes' => array(
|
||||
'class' => array('warning-on-change'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['warning-on-change'],
|
||||
],
|
||||
];
|
||||
|
||||
$form['remove_groups'][$id] = array(); // to prevent a notice
|
||||
$form['remove_groups'][$id] = []; // to prevent a notice
|
||||
if ($id != 1) {
|
||||
$form['remove_groups'][$id] = array(
|
||||
$form['remove_groups'][$id] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Remove group @group', array('@group' => $id)),
|
||||
'#value' => $this->t('Remove group @group', ['@group' => $id]),
|
||||
'#id' => "views-remove-group-$id",
|
||||
'#attributes' => array(
|
||||
'class' => array('views-remove-group'),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['views-remove-group'],
|
||||
],
|
||||
'#group' => $id,
|
||||
'#ajax' => ['url' => NULL],
|
||||
);
|
||||
];
|
||||
}
|
||||
$group_options[$id] = $id == 1 ? $this->t('Default group') : $this->t('Group @group', array('@group' => $id));
|
||||
$form['#group_renders'][$id] = array();
|
||||
$group_options[$id] = $id == 1 ? $this->t('Default group') : $this->t('Group @group', ['@group' => $id]);
|
||||
$form['#group_renders'][$id] = [];
|
||||
}
|
||||
|
||||
$form['#group_options'] = $group_options;
|
||||
$form['#groups'] = $groups;
|
||||
// We don't use getHandlers() because we want items without handlers to
|
||||
// appear and show up as 'broken' so that the user can see them.
|
||||
$form['filters'] = array('#tree' => TRUE);
|
||||
$form['filters'] = ['#tree' => TRUE];
|
||||
foreach ($handlers as $id => $field) {
|
||||
// If the group does not exist, move the filters to the default group.
|
||||
if (empty($field['group']) || empty($groups['groups'][$field['group']])) {
|
||||
|
@ -162,24 +162,24 @@ class RearrangeFilter extends ViewsFormBase {
|
|||
// Place this item into the proper group for rendering.
|
||||
$form['#group_renders'][$field['group']][] = $id;
|
||||
|
||||
$form['filters'][$id]['weight'] = array(
|
||||
'#title' => t('Weight for @id', array('@id' => $id)),
|
||||
$form['filters'][$id]['weight'] = [
|
||||
'#title' => t('Weight for @id', ['@id' => $id]),
|
||||
'#title_display' => 'invisible',
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => ++$count,
|
||||
'#size' => 8,
|
||||
);
|
||||
$form['filters'][$id]['group'] = array(
|
||||
'#title' => t('Group for @id', array('@id' => $id)),
|
||||
];
|
||||
$form['filters'][$id]['group'] = [
|
||||
'#title' => t('Group for @id', ['@id' => $id]),
|
||||
'#title_display' => 'invisible',
|
||||
'#type' => 'select',
|
||||
'#options' => $group_options,
|
||||
'#default_value' => $field['group'],
|
||||
'#attributes' => array(
|
||||
'class' => array('views-region-select', 'views-region-' . $id),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['views-region-select', 'views-region-' . $id],
|
||||
],
|
||||
'#access' => $field['group'] !== 'ungroupable',
|
||||
);
|
||||
];
|
||||
|
||||
if ($handler) {
|
||||
$name = $handler->adminLabel() . ' ' . $handler->adminSummary();
|
||||
|
@ -187,34 +187,34 @@ class RearrangeFilter extends ViewsFormBase {
|
|||
$name = '(' . $relationships[$field['relationship']] . ') ' . $name;
|
||||
}
|
||||
|
||||
$form['filters'][$id]['name'] = array(
|
||||
$form['filters'][$id]['name'] = [
|
||||
'#markup' => $name,
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$form['filters'][$id]['name'] = array('#markup' => $this->t('Broken field @id', array('@id' => $id)));
|
||||
$form['filters'][$id]['name'] = ['#markup' => $this->t('Broken field @id', ['@id' => $id])];
|
||||
}
|
||||
$form['filters'][$id]['removed'] = array(
|
||||
'#title' => t('Remove @id', array('@id' => $id)),
|
||||
$form['filters'][$id]['removed'] = [
|
||||
'#title' => t('Remove @id', ['@id' => $id]),
|
||||
'#title_display' => 'invisible',
|
||||
'#type' => 'checkbox',
|
||||
'#id' => 'views-removed-' . $id,
|
||||
'#attributes' => array('class' => array('views-remove-checkbox')),
|
||||
'#attributes' => ['class' => ['views-remove-checkbox']],
|
||||
'#default_value' => 0,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$view->getStandardButtons($form, $form_state, 'views_ui_rearrange_filter_form');
|
||||
$form['actions']['add_group'] = array(
|
||||
$form['actions']['add_group'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Create new filter group'),
|
||||
'#id' => 'views-add-group',
|
||||
'#group' => 'add',
|
||||
'#attributes' => array(
|
||||
'class' => array('views-add-group'),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['views-add-group'],
|
||||
],
|
||||
'#ajax' => ['url' => NULL],
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ class RearrangeFilter extends ViewsFormBase {
|
|||
$types = ViewExecutable::getHandlerTypes();
|
||||
$view = $form_state->get('view');
|
||||
$display = &$view->getExecutable()->displayHandlers->get($form_state->get('display_id'));
|
||||
$remember_groups = array();
|
||||
$remember_groups = [];
|
||||
|
||||
if (!empty($view->form_cache)) {
|
||||
$old_fields = $view->form_cache['handlers'];
|
||||
|
@ -237,7 +237,7 @@ class RearrangeFilter extends ViewsFormBase {
|
|||
|
||||
$groups = $form_state->getValue('filter_groups');
|
||||
// Whatever button was clicked, re-calculate field information.
|
||||
$new_fields = $order = array();
|
||||
$new_fields = $order = [];
|
||||
|
||||
// Make an array with the weights
|
||||
foreach ($form_state->getValue('filters') as $field => $info) {
|
||||
|
|
|
@ -40,10 +40,10 @@ class ReorderDisplays extends ViewsFormBase {
|
|||
'view' => $view->id(),
|
||||
'display_id' => $display_id,
|
||||
]);
|
||||
$form['view'] = array(
|
||||
$form['view'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $view
|
||||
);
|
||||
];
|
||||
|
||||
$displays = $view->get('display');
|
||||
$count = count($displays);
|
||||
|
@ -56,82 +56,82 @@ class ReorderDisplays extends ViewsFormBase {
|
|||
return 0;
|
||||
});
|
||||
|
||||
$form['displays'] = array(
|
||||
$form['displays'] = [
|
||||
'#type' => 'table',
|
||||
'#id' => 'reorder-displays',
|
||||
'#header' => array($this->t('Display'), $this->t('Weight'), $this->t('Remove')),
|
||||
'#header' => [$this->t('Display'), $this->t('Weight'), $this->t('Remove')],
|
||||
'#empty' => $this->t('No displays available.'),
|
||||
'#tabledrag' => array(
|
||||
array(
|
||||
'#tabledrag' => [
|
||||
[
|
||||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
)
|
||||
),
|
||||
]
|
||||
],
|
||||
'#tree' => TRUE,
|
||||
'#prefix' => '<div class="scroll" data-drupal-views-scroll>',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($displays as $id => $display) {
|
||||
$form['displays'][$id] = array(
|
||||
$form['displays'][$id] = [
|
||||
'#display' => $display,
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'display-row-' . $id,
|
||||
),
|
||||
],
|
||||
'#weight' => $display['position'],
|
||||
);
|
||||
];
|
||||
|
||||
// Only make row draggable if it's not the default display.
|
||||
if ($id !== 'default') {
|
||||
$form['displays'][$id]['#attributes']['class'][] = 'draggable';
|
||||
}
|
||||
|
||||
$form['displays'][$id]['title'] = array(
|
||||
$form['displays'][$id]['title'] = [
|
||||
'#markup' => $display['display_title'],
|
||||
);
|
||||
];
|
||||
|
||||
$form['displays'][$id]['weight'] = array(
|
||||
$form['displays'][$id]['weight'] = [
|
||||
'#type' => 'weight',
|
||||
'#value' => $display['position'],
|
||||
'#delta' => $count,
|
||||
'#title' => $this->t('Weight for @display', array('@display' => $display['display_title'])),
|
||||
'#title' => $this->t('Weight for @display', ['@display' => $display['display_title']]),
|
||||
'#title_display' => 'invisible',
|
||||
'#attributes' => array(
|
||||
'class' => array('weight'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['weight'],
|
||||
],
|
||||
];
|
||||
|
||||
$form['displays'][$id]['removed'] = array(
|
||||
'checkbox' => array(
|
||||
'#title' => t('Remove @id', array('@id' => $id)),
|
||||
$form['displays'][$id]['removed'] = [
|
||||
'checkbox' => [
|
||||
'#title' => t('Remove @id', ['@id' => $id]),
|
||||
'#title_display' => 'invisible',
|
||||
'#type' => 'checkbox',
|
||||
'#id' => 'display-removed-' . $id,
|
||||
'#attributes' => array(
|
||||
'class' => array('views-remove-checkbox'),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['views-remove-checkbox'],
|
||||
],
|
||||
'#default_value' => !empty($display['deleted']),
|
||||
),
|
||||
'link' => array(
|
||||
],
|
||||
'link' => [
|
||||
'#type' => 'link',
|
||||
'#title' => SafeMarkup::format('<span>@text</span>', array('@text' => $this->t('Remove'))),
|
||||
'#title' => SafeMarkup::format('<span>@text</span>', ['@text' => $this->t('Remove')]),
|
||||
'#url' => Url::fromRoute('<none>'),
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'display-remove-link-' . $id,
|
||||
'class' => array('views-button-remove', 'display-remove-link'),
|
||||
'class' => ['views-button-remove', 'display-remove-link'],
|
||||
'alt' => $this->t('Remove this display'),
|
||||
'title' => $this->t('Remove this display'),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
'#access' => ($id !== 'default'),
|
||||
);
|
||||
];
|
||||
|
||||
if (!empty($display['deleted'])) {
|
||||
$form['displays'][$id]['deleted'] = array(
|
||||
$form['displays'][$id]['deleted'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['displays'][$id]['#attributes']['class'][] = 'hidden';
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class ReorderDisplays extends ViewsFormBase {
|
|||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
/** @var $view \Drupal\views_ui\ViewUI */
|
||||
$view = $form_state->get('view');
|
||||
$order = array();
|
||||
$order = [];
|
||||
|
||||
$user_input = $form_state->getUserInput();
|
||||
foreach ($user_input['displays'] as $display => $info) {
|
||||
|
|
|
@ -108,7 +108,7 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
|
|||
unset($view->stack[$key]);
|
||||
|
||||
if (array_shift($top) != $identifier) {
|
||||
$view->stack = array();
|
||||
$view->stack = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
|
|||
$form_state = $reflection->newInstanceArgs(array_slice($top, 3, 2))->getFormState($view, $top[2], $form_state->get('ajax'));
|
||||
$form_class = get_class($form_state->getFormObject());
|
||||
|
||||
$form_state->setUserInput(array());
|
||||
$form_state->setUserInput([]);
|
||||
$form_url = views_ui_build_form_url($form_state);
|
||||
if (!$form_state->get('ajax')) {
|
||||
return new RedirectResponse($form_url->setAbsolute()->toString());
|
||||
|
@ -234,16 +234,16 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
|
|||
$response->setAttachments($form['#attached']);
|
||||
|
||||
$display = '';
|
||||
$status_messages = array('#type' => 'status_messages');
|
||||
$status_messages = ['#type' => 'status_messages'];
|
||||
if ($messages = $renderer->renderRoot($status_messages)) {
|
||||
$display = '<div class="views-messages">' . $messages . '</div>';
|
||||
}
|
||||
$display .= $output;
|
||||
|
||||
$options = array(
|
||||
$options = [
|
||||
'dialogClass' => 'views-ui-dialog js-views-ui-dialog',
|
||||
'width' => '75%',
|
||||
);
|
||||
];
|
||||
|
||||
$response->addCommand(new OpenModalDialogCommand($title, $display, $options));
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ class BasicSettingsForm extends ConfigFormBase {
|
|||
$form = parent::buildForm($form, $form_state);
|
||||
|
||||
$config = $this->config('views.settings');
|
||||
$options = array();
|
||||
$options = [];
|
||||
foreach ($this->themeHandler->listInfo() as $name => $theme) {
|
||||
if ($theme->status) {
|
||||
$options[$name] = $theme->info['name'];
|
||||
|
@ -74,94 +74,94 @@ class BasicSettingsForm extends ConfigFormBase {
|
|||
|
||||
// This is not currently a fieldset but we may want it to be later,
|
||||
// so this will make it easier to change if we do.
|
||||
$form['basic'] = array();
|
||||
$form['basic'] = [];
|
||||
|
||||
$form['basic']['ui_show_master_display'] = array(
|
||||
$form['basic']['ui_show_master_display'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Always show the master (default) display'),
|
||||
'#default_value' => $config->get('ui.show.master_display'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['basic']['ui_show_advanced_column'] = array(
|
||||
$form['basic']['ui_show_advanced_column'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Always show advanced display settings'),
|
||||
'#default_value' => $config->get('ui.show.advanced_column'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['basic']['ui_show_display_embed'] = array(
|
||||
$form['basic']['ui_show_display_embed'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Allow embedded displays'),
|
||||
'#description' => t('Embedded displays can be used in code via views_embed_view().'),
|
||||
'#default_value' => $config->get('ui.show.display_embed'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['basic']['ui_exposed_filter_any_label'] = array(
|
||||
$form['basic']['ui_exposed_filter_any_label'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Label for "Any" value on non-required single-select exposed filters'),
|
||||
'#options' => array('old_any' => '<Any>', 'new_any' => $this->t('- Any -')),
|
||||
'#options' => ['old_any' => '<Any>', 'new_any' => $this->t('- Any -')],
|
||||
'#default_value' => $config->get('ui.exposed_filter_any_label'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['live_preview'] = array(
|
||||
$form['live_preview'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Live preview settings'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['live_preview']['ui_always_live_preview'] = array(
|
||||
$form['live_preview']['ui_always_live_preview'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Automatically update preview on changes'),
|
||||
'#default_value' => $config->get('ui.always_live_preview'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['live_preview']['ui_show_preview_information'] = array(
|
||||
$form['live_preview']['ui_show_preview_information'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Show information and statistics about the view during live preview'),
|
||||
'#default_value' => $config->get('ui.show.preview_information'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['live_preview']['options'] = array(
|
||||
$form['live_preview']['options'] = [
|
||||
'#type' => 'container',
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="ui_show_preview_information"]' => array('checked' => TRUE),
|
||||
),
|
||||
),
|
||||
);
|
||||
'#states' => [
|
||||
'visible' => [
|
||||
':input[name="ui_show_preview_information"]' => ['checked' => TRUE],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form['live_preview']['options']['ui_show_sql_query_enabled'] = array(
|
||||
$form['live_preview']['options']['ui_show_sql_query_enabled'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Show the SQL query'),
|
||||
'#default_value' => $config->get('ui.show.sql_query.enabled'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['live_preview']['options']['ui_show_sql_query_where'] = array(
|
||||
$form['live_preview']['options']['ui_show_sql_query_where'] = [
|
||||
'#type' => 'radios',
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="ui_show_sql_query_enabled"]' => array('checked' => TRUE),
|
||||
),
|
||||
),
|
||||
'#states' => [
|
||||
'visible' => [
|
||||
':input[name="ui_show_sql_query_enabled"]' => ['checked' => TRUE],
|
||||
],
|
||||
],
|
||||
'#title' => t('Show SQL query'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'above' => $this->t('Above the preview'),
|
||||
'below' => $this->t('Below the preview'),
|
||||
),
|
||||
],
|
||||
'#default_value' => $config->get('ui.show.sql_query.where'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['live_preview']['options']['ui_show_performance_statistics'] = array(
|
||||
$form['live_preview']['options']['ui_show_performance_statistics'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Show performance statistics'),
|
||||
'#default_value' => $config->get('ui.show.performance_statistics'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['live_preview']['options']['ui_show_additional_queries'] = array(
|
||||
$form['live_preview']['options']['ui_show_additional_queries'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Show other queries run during render during live preview'),
|
||||
'#description' => $this->t("Drupal has the potential to run many queries while a view is being rendered. Checking this box will display every query run during view render as part of the live preview."),
|
||||
'#default_value' => $config->get('ui.show.additional_queries'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class BreakLockForm extends EntityConfirmFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
return $this->t('Do you want to break the lock on view %name?', array('%name' => $this->entity->id()));
|
||||
return $this->t('Do you want to break the lock on view %name?', ['%name' => $this->entity->id()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,11 +70,11 @@ class BreakLockForm extends EntityConfirmFormBase {
|
|||
public function getDescription() {
|
||||
$locked = $this->tempStore->getMetadata($this->entity->id());
|
||||
$account = $this->entityManager->getStorage('user')->load($locked->owner);
|
||||
$username = array(
|
||||
$username = [
|
||||
'#theme' => 'username',
|
||||
'#account' => $account,
|
||||
);
|
||||
return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', array('@user' => drupal_render($username)));
|
||||
];
|
||||
return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => drupal_render($username)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +96,7 @@ class BreakLockForm extends EntityConfirmFormBase {
|
|||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
if (!$this->tempStore->getMetadata($this->entity->id())) {
|
||||
$form['message']['#markup'] = $this->t('There is no lock on view %name to break.', array('%name' => $this->entity->id()));
|
||||
$form['message']['#markup'] = $this->t('There is no lock on view %name to break.', ['%name' => $this->entity->id()]);
|
||||
return $form;
|
||||
}
|
||||
return parent::buildForm($form, $form_state);
|
||||
|
|
|
@ -16,14 +16,14 @@ class AnalyzeTest extends ViewTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views_ui');
|
||||
public static $modules = ['views_ui'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -31,13 +31,13 @@ class AnalyzeTest extends ViewTestBase {
|
|||
$this->enableViewsTestModule();
|
||||
|
||||
// Add an admin user will full rights;
|
||||
$this->admin = $this->drupalCreateUser(array('administer views'));
|
||||
$this->admin = $this->drupalCreateUser(['administer views']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that analyze works in general.
|
||||
*/
|
||||
function testAnalyzeBasic() {
|
||||
public function testAnalyzeBasic() {
|
||||
$this->drupalLogin($this->admin);
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_view/edit');
|
||||
|
@ -47,13 +47,13 @@ class AnalyzeTest extends ViewTestBase {
|
|||
$this->clickLink(t('Analyze view'));
|
||||
$this->assertText(t('View analysis'));
|
||||
|
||||
foreach (array('ok', 'warning', 'error') as $type) {
|
||||
$xpath = $this->xpath('//div[contains(@class, :class)]', array(':class' => $type));
|
||||
$this->assertTrue(count($xpath), format_string('Analyse messages with @type found', array('@type' => $type)));
|
||||
foreach (['ok', 'warning', 'error'] as $type) {
|
||||
$xpath = $this->xpath('//div[contains(@class, :class)]', [':class' => $type]);
|
||||
$this->assertTrue(count($xpath), format_string('Analyse messages with @type found', ['@type' => $type]));
|
||||
}
|
||||
|
||||
// This redirects the user back to the main views edit page.
|
||||
$this->drupalPostForm(NULL, array(), t('Ok'));
|
||||
$this->drupalPostForm(NULL, [], t('Ok'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class ArgumentValidatorTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_argument');
|
||||
public static $testViews = ['test_argument'];
|
||||
|
||||
/**
|
||||
* Tests the 'Specify validation criteria' checkbox functionality.
|
||||
|
@ -46,12 +46,12 @@ class ArgumentValidatorTest extends UITestBase {
|
|||
* @param bool $specify_validation
|
||||
*/
|
||||
protected function saveArgumentHandlerWithValidationOptions($specify_validation) {
|
||||
$options = array(
|
||||
$options = [
|
||||
'options[validate][type]' => 'entity---node',
|
||||
'options[specify_validation]' => $specify_validation,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_argument/default/argument/id', $options, t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_argument', array(), t('Save'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_argument', [], t('Save'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class CachedDataUITest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests the user tempstore views data in the UI.
|
||||
|
@ -28,7 +28,7 @@ class CachedDataUITest extends UITestBase {
|
|||
|
||||
$this->drupalGet('admin/structure/views/view/test_view/edit');
|
||||
// Make sure we have 'changes' to the view.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', array(), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply'));
|
||||
$this->assertText('You have unsaved changes.');
|
||||
$this->assertEqual($temp_store->getMetadata('test_view')->owner, $views_admin_user_uid, 'View cache has been saved.');
|
||||
|
||||
|
@ -39,13 +39,13 @@ class CachedDataUITest extends UITestBase {
|
|||
$this->assertEqual($temp_store->getMetadata('test_view')->owner, $views_admin_user_uid, 'The view is locked.');
|
||||
|
||||
// Cancel the view edit and make sure the cache is deleted.
|
||||
$this->drupalPostForm(NULL, array(), t('Cancel'));
|
||||
$this->drupalPostForm(NULL, [], t('Cancel'));
|
||||
$this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'User tempstore data has been removed.');
|
||||
// Test we are redirected to the view listing page.
|
||||
$this->assertUrl('admin/structure/views', array(), 'Redirected back to the view listing page.');
|
||||
$this->assertUrl('admin/structure/views', [], 'Redirected back to the view listing page.');
|
||||
|
||||
// Log in with another user and make sure the view is locked and break.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', array(), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply'));
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_view/edit');
|
||||
|
@ -56,17 +56,17 @@ class CachedDataUITest extends UITestBase {
|
|||
$this->assertLinkByHref('admin/structure/views/view/test_view/break-lock');
|
||||
// Break the lock.
|
||||
$this->clickLink(t('break this lock'));
|
||||
$this->drupalPostForm(NULL, array(), t('Break lock'));
|
||||
$this->drupalPostForm(NULL, [], t('Break lock'));
|
||||
// Test that save and cancel buttons are shown.
|
||||
$this->assertFieldById('edit-actions-submit', t('Save'));
|
||||
$this->assertFieldById('edit-actions-cancel', t('Cancel'));
|
||||
// Test we can save the view.
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view/edit', array(), t('Save'));
|
||||
$this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view')));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view/edit', [], t('Save'));
|
||||
$this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
|
||||
|
||||
// Test that a deleted view has no tempstore data.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', array(), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view/delete', array(), t('Delete'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/default/title', [], t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view/delete', [], t('Delete'));
|
||||
// No view tempstore data should be returned for this view after deletion.
|
||||
$this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'View tempstore data has been removed after deletion.');
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class CustomBooleanTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* \Drupal\views\Tests\ViewTestBase::viewsData().
|
||||
|
@ -47,15 +47,15 @@ class CustomBooleanTest extends UITestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'plugin_id' => 'boolean',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view->save();
|
||||
|
||||
$this->executeView($view);
|
||||
|
@ -64,35 +64,35 @@ class CustomBooleanTest extends UITestBase {
|
|||
$custom_false = 'Nay';
|
||||
|
||||
// Set up some custom value mappings for different types.
|
||||
$custom_values = array(
|
||||
'plain' => array(
|
||||
$custom_values = [
|
||||
'plain' => [
|
||||
'true' => $custom_true,
|
||||
'false' => $custom_false,
|
||||
'test' => 'assertTrue',
|
||||
),
|
||||
'allowed tag' => array(
|
||||
],
|
||||
'allowed tag' => [
|
||||
'true' => '<p>' . $custom_true . '</p>',
|
||||
'false' => '<p>' . $custom_false . '</p>',
|
||||
'test' => 'assertTrue',
|
||||
),
|
||||
'disallowed tag' => array(
|
||||
],
|
||||
'disallowed tag' => [
|
||||
'true' => '<script>' . $custom_true . '</script>',
|
||||
'false' => '<script>' . $custom_false . '</script>',
|
||||
'test' => 'assertFalse',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Run the same tests on each type.
|
||||
foreach ($custom_values as $type => $values) {
|
||||
$options = array(
|
||||
$options = [
|
||||
'options[type]' => 'custom',
|
||||
'options[type_custom_true]' => $values['true'],
|
||||
'options[type_custom_false]' => $values['false'],
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/field/age', $options, 'Apply');
|
||||
|
||||
// Save the view.
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save');
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', [], 'Save');
|
||||
|
||||
$view = Views::getView('test_view');
|
||||
$output = $view->preview();
|
||||
|
@ -136,35 +136,35 @@ class CustomBooleanTest extends UITestBase {
|
|||
$custom_false = 'Nay';
|
||||
|
||||
// Set up some custom value mappings for different types.
|
||||
$custom_values = array(
|
||||
'plain' => array(
|
||||
$custom_values = [
|
||||
'plain' => [
|
||||
'true' => $custom_true,
|
||||
'false' => $custom_false,
|
||||
'test' => 'assertTrue',
|
||||
),
|
||||
'allowed tag' => array(
|
||||
],
|
||||
'allowed tag' => [
|
||||
'true' => '<p>' . $custom_true . '</p>',
|
||||
'false' => '<p>' . $custom_false . '</p>',
|
||||
'test' => 'assertTrue',
|
||||
),
|
||||
'disallowed tag' => array(
|
||||
],
|
||||
'disallowed tag' => [
|
||||
'true' => '<script>' . $custom_true . '</script>',
|
||||
'false' => '<script>' . $custom_false . '</script>',
|
||||
'test' => 'assertFalse',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Run the same tests on each type.
|
||||
foreach ($custom_values as $type => $values) {
|
||||
$options = array(
|
||||
$options = [
|
||||
'options[type]' => 'custom',
|
||||
'options[type_custom_true]' => $values['true'],
|
||||
'options[type_custom_false]' => $values['false'],
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/field/age', $options, 'Apply');
|
||||
|
||||
// Save the view.
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save');
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', [], 'Save');
|
||||
|
||||
$view = Views::getView('test_view');
|
||||
$output = $view->preview();
|
||||
|
|
|
@ -18,7 +18,7 @@ class DefaultViewsTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_status', 'test_page_display_menu', 'test_page_display_arguments');
|
||||
public static $testViews = ['test_view_status', 'test_page_display_menu', 'test_page_display_arguments'];
|
||||
|
||||
|
||||
protected function setUp() {
|
||||
|
@ -30,7 +30,7 @@ class DefaultViewsTest extends UITestBase {
|
|||
/**
|
||||
* Tests default views.
|
||||
*/
|
||||
function testDefaultViews() {
|
||||
public function testDefaultViews() {
|
||||
// Make sure the view starts off as disabled (does not appear on the listing
|
||||
// page).
|
||||
$edit_href = 'admin/structure/views/view/glossary';
|
||||
|
@ -55,16 +55,16 @@ class DefaultViewsTest extends UITestBase {
|
|||
// Edit the view and change the title. Make sure that the new title is
|
||||
// displayed.
|
||||
$new_title = $this->randomMachineName(16);
|
||||
$edit = array('title' => $new_title);
|
||||
$edit = ['title' => $new_title];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/glossary/page_1/title', $edit, t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/glossary/edit/page_1', array(), t('Save'));
|
||||
$this->drupalPostForm('admin/structure/views/view/glossary/edit/page_1', [], t('Save'));
|
||||
$this->drupalGet('glossary');
|
||||
$this->assertResponse(200);
|
||||
$this->assertText($new_title);
|
||||
|
||||
// Save another view in the UI.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/archive/page_1/title', array(), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/archive/edit/page_1', array(), t('Save'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/archive/page_1/title', [], t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/archive/edit/page_1', [], t('Save'));
|
||||
|
||||
// Check there is an enable link. i.e. The view has not been enabled after
|
||||
// editing.
|
||||
|
@ -85,19 +85,19 @@ class DefaultViewsTest extends UITestBase {
|
|||
// Duplicate the view and check that the normal schema of duplicated views is used.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'id' => 'duplicate_of_glossary',
|
||||
);
|
||||
$this->assertTitle(t('Duplicate of @label | @site-name', array('@label' => 'Glossary', '@site-name' => $this->config('system.site')->get('name'))));
|
||||
];
|
||||
$this->assertTitle(t('Duplicate of @label | @site-name', ['@label' => 'Glossary', '@site-name' => $this->config('system.site')->get('name')]));
|
||||
$this->drupalPostForm(NULL, $edit, t('Duplicate'));
|
||||
$this->assertUrl('admin/structure/views/view/duplicate_of_glossary', array(), 'The normal duplicating name schema is applied.');
|
||||
$this->assertUrl('admin/structure/views/view/duplicate_of_glossary', [], 'The normal duplicating name schema is applied.');
|
||||
|
||||
// Duplicate a view and set a custom name.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Duplicate'), '/glossary');
|
||||
$random_name = strtolower($this->randomMachineName());
|
||||
$this->drupalPostForm(NULL, array('id' => $random_name), t('Duplicate'));
|
||||
$this->assertUrl("admin/structure/views/view/$random_name", array(), 'The custom view name got saved.');
|
||||
$this->drupalPostForm(NULL, ['id' => $random_name], t('Duplicate'));
|
||||
$this->assertUrl("admin/structure/views/view/$random_name", [], 'The custom view name got saved.');
|
||||
|
||||
// Now disable the view, and make sure it stops appearing on the main view
|
||||
// listing page but instead goes back to displaying on the disabled views
|
||||
|
@ -129,7 +129,7 @@ class DefaultViewsTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Delete'), '/glossary/');
|
||||
// Submit the confirmation form.
|
||||
$this->drupalPostForm(NULL, array(), t('Delete'));
|
||||
$this->drupalPostForm(NULL, [], t('Delete'));
|
||||
// Ensure the view is no longer listed.
|
||||
$this->assertUrl('admin/structure/views');
|
||||
$this->assertNoLinkByHref($edit_href);
|
||||
|
@ -142,7 +142,7 @@ class DefaultViewsTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Delete'), 'duplicate_of_glossary');
|
||||
// Submit the confirmation form.
|
||||
$this->drupalPostForm(NULL, array(), t('Delete'));
|
||||
$this->drupalPostForm(NULL, [], t('Delete'));
|
||||
|
||||
$this->drupalGet('glossary');
|
||||
$this->assertResponse(200);
|
||||
|
@ -150,7 +150,7 @@ class DefaultViewsTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Delete'), $random_name);
|
||||
// Submit the confirmation form.
|
||||
$this->drupalPostForm(NULL, array(), t('Delete'));
|
||||
$this->drupalPostForm(NULL, [], t('Delete'));
|
||||
$this->drupalGet('glossary');
|
||||
$this->assertResponse(404);
|
||||
$this->assertText('Page not found');
|
||||
|
@ -159,13 +159,14 @@ class DefaultViewsTest extends UITestBase {
|
|||
/**
|
||||
* Tests that enabling views moves them to the correct table.
|
||||
*/
|
||||
function testSplitListing() {
|
||||
public function testSplitListing() {
|
||||
// Build a re-usable xpath query.
|
||||
$xpath = '//div[@id="views-entity-list"]/div[@class = :status]/table//tr[@title = :title]';
|
||||
$arguments = array(
|
||||
$xpath = '//div[@id="views-entity-list"]/div[@class = :status]/table//td/text()[contains(., :title)]';
|
||||
|
||||
$arguments = [
|
||||
':status' => 'views-list-section enabled',
|
||||
':title' => t('Machine name: test_view_status'),
|
||||
);
|
||||
':title' => 'test_view_status',
|
||||
];
|
||||
|
||||
$this->drupalGet('admin/structure/views');
|
||||
|
||||
|
@ -226,8 +227,8 @@ class DefaultViewsTest extends UITestBase {
|
|||
* The page content that results from clicking on the link, or FALSE on
|
||||
* failure. Failure also results in a failed assertion.
|
||||
*/
|
||||
function clickViewsOperationLink($label, $unique_href_part) {
|
||||
$links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
|
||||
public function clickViewsOperationLink($label, $unique_href_part) {
|
||||
$links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
|
||||
foreach ($links as $link_index => $link) {
|
||||
$position = strpos($link['href'], $unique_href_part);
|
||||
if ($position !== FALSE) {
|
||||
|
@ -235,7 +236,7 @@ class DefaultViewsTest extends UITestBase {
|
|||
break;
|
||||
}
|
||||
}
|
||||
$this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', array('@label' => $label, '@part' => $unique_href_part)));
|
||||
$this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', ['@label' => $label, '@part' => $unique_href_part]));
|
||||
if (isset($index)) {
|
||||
return $this->clickLink($label, $index);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class DisplayAttachmentTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_attachment_ui');
|
||||
public static $testViews = ['test_attachment_ui'];
|
||||
|
||||
/**
|
||||
* Tests the attachment UI.
|
||||
|
@ -31,31 +31,66 @@ class DisplayAttachmentTest extends UITestBase {
|
|||
// Display labels should be escaped.
|
||||
$this->assertEscaped('<em>Page</em>');
|
||||
|
||||
foreach (array('default', 'page-1') as $display_id) {
|
||||
$this->assertNoFieldChecked("edit-displays-$display_id", format_string('Make sure the @display_id can be marked as attached', array('@display_id' => $display_id)));
|
||||
foreach (['default', 'page-1'] as $display_id) {
|
||||
$this->assertNoFieldChecked("edit-displays-$display_id", format_string('Make sure the @display_id can be marked as attached', ['@display_id' => $display_id]));
|
||||
}
|
||||
|
||||
// Save the attachments and test the value on the view.
|
||||
$this->drupalPostForm($attachment_display_url, array('displays[page_1]' => 1), t('Apply'));
|
||||
$this->drupalPostForm($attachment_display_url, ['displays[page_1]' => 1], t('Apply'));
|
||||
// Options summary should be escaped.
|
||||
$this->assertEscaped('<em>Page</em>');
|
||||
$this->assertNoRaw('<em>Page</em>');
|
||||
$result = $this->xpath('//a[@id = :id]', array(':id' => 'views-attachment-1-displays'));
|
||||
$result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
|
||||
$this->assertEqual($result[0]->attributes()->title, t('Page'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$view = Views::getView('test_attachment_ui');
|
||||
$view->initDisplay();
|
||||
$this->assertEqual(array_keys(array_filter($view->displayHandlers->get('attachment_1')->getOption('displays'))), array('page_1'), 'The attached displays got saved as expected');
|
||||
$this->assertEqual(array_keys(array_filter($view->displayHandlers->get('attachment_1')->getOption('displays'))), ['page_1'], 'The attached displays got saved as expected');
|
||||
|
||||
$this->drupalPostForm($attachment_display_url, array('displays[default]' => 1, 'displays[page_1]' => 1), t('Apply'));
|
||||
$result = $this->xpath('//a[@id = :id]', array(':id' => 'views-attachment-1-displays'));
|
||||
$this->drupalPostForm($attachment_display_url, ['displays[default]' => 1, 'displays[page_1]' => 1], t('Apply'));
|
||||
$result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
|
||||
$this->assertEqual($result[0]->attributes()->title, t('Multiple displays'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$view = Views::getView('test_attachment_ui');
|
||||
$view->initDisplay();
|
||||
$this->assertEqual(array_keys($view->displayHandlers->get('attachment_1')->getOption('displays')), array('default', 'page_1'), 'The attached displays got saved as expected');
|
||||
$this->assertEqual(array_keys($view->displayHandlers->get('attachment_1')->getOption('displays')), ['default', 'page_1'], 'The attached displays got saved as expected');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the attachment working after the attached page was deleted.
|
||||
*/
|
||||
public function testRemoveAttachedDisplay() {
|
||||
// Create a view.
|
||||
$view = $this->randomView();
|
||||
$path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
|
||||
$attachment_display_url = 'admin/structure/views/nojs/display/' . $view['id'] . '/attachment_1/displays';
|
||||
|
||||
// Open the Page display and create the attachment display.
|
||||
$this->drupalGet($path_prefix . '/page_1');
|
||||
$this->drupalPostForm(NULL, [], 'Add Attachment');
|
||||
$this->assertText(t('Not defined'), 'The right text appears if there is no attachment selection yet.');
|
||||
|
||||
// Attach the Attachment to the Page display.
|
||||
$this->drupalPostForm($attachment_display_url, ['displays[page_1]' => 1], t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
// Open the Page display and mark it as deleted.
|
||||
$this->drupalGet($path_prefix . '/page_1');
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display.');
|
||||
$this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page');
|
||||
|
||||
// Open the attachment display and save it.
|
||||
$this->drupalGet($path_prefix . '/attachment_1');
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
// Check that there is no warning for the removed page display.
|
||||
$this->assertNoText("Plugin ID 'page_1' was not found.");
|
||||
|
||||
// Check that the attachment is no longer linked to the removed display.
|
||||
$this->assertText(t('Not defined'), 'The right text appears if there is no attachment selection yet.');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,14 +16,14 @@ class DisplayCRUDTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_display');
|
||||
public static $testViews = ['test_display'];
|
||||
|
||||
/**
|
||||
* Modules to enable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('contextual');
|
||||
public static $modules = ['contextual'];
|
||||
|
||||
/**
|
||||
* Tests adding a display.
|
||||
|
@ -39,14 +39,14 @@ class DisplayCRUDTest extends UITestBase {
|
|||
$this->drupalGet($path_prefix);
|
||||
|
||||
// Add a new display.
|
||||
$this->drupalPostForm(NULL, array(), 'Add Page');
|
||||
$this->drupalPostForm(NULL, [], 'Add Page');
|
||||
$this->assertLinkByHref($path_prefix . '/page_1', 0, 'Make sure after adding a display the new display appears in the UI');
|
||||
|
||||
$this->assertNoLink('Master*', 'Make sure the master display is not marked as changed.');
|
||||
$this->assertLink('Page*', 0, 'Make sure the added display is marked as changed.');
|
||||
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/path", array('path' => 'test/path'), t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/path", ['path' => 'test/path'], t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,22 +63,22 @@ class DisplayCRUDTest extends UITestBase {
|
|||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display.');
|
||||
|
||||
// Delete the page, so we can test the undo process.
|
||||
$this->drupalPostForm($path_prefix . '/page_1', array(), 'Delete Page');
|
||||
$this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page');
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there a undo button on the page display after deleting.');
|
||||
$element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', array(':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link'));
|
||||
$element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', [':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link']);
|
||||
$this->assertTrue(!empty($element), 'Make sure the display link is marked as to be deleted.');
|
||||
|
||||
$element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', array(':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link'));
|
||||
$element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', [':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link']);
|
||||
$this->assertTrue(!empty($element), 'Make sure the display link is marked as to be deleted.');
|
||||
|
||||
// Undo the deleting of the display.
|
||||
$this->drupalPostForm($path_prefix . '/page_1', array(), 'Undo delete of Page');
|
||||
$this->drupalPostForm($path_prefix . '/page_1', [], 'Undo delete of Page');
|
||||
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there is no undo button on the page display after reverting.');
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display after the reverting.');
|
||||
|
||||
// Now delete again and save the view.
|
||||
$this->drupalPostForm($path_prefix . '/page_1', array(), 'Delete Page');
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page');
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$this->assertNoLinkByHref($path_prefix . '/page_1', 'Make sure there is no display tab for the deleted display.');
|
||||
|
||||
|
@ -86,9 +86,9 @@ class DisplayCRUDTest extends UITestBase {
|
|||
$view = $this->randomView();
|
||||
$machine_name = 'new_machine_name';
|
||||
$path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/display_id", array('display_id' => $machine_name), 'Apply');
|
||||
$this->drupalPostForm(NULL, array(), 'Delete Page');
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/display_id", ['display_id' => $machine_name], 'Apply');
|
||||
$this->drupalPostForm(NULL, [], 'Delete Page');
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertNoLinkByHref($path_prefix . '/new_machine_name', 'Make sure there is no display tab for the deleted display.');
|
||||
}
|
||||
|
@ -111,24 +111,24 @@ class DisplayCRUDTest extends UITestBase {
|
|||
$path = $view['page[path]'];
|
||||
|
||||
$this->drupalGet($path_prefix);
|
||||
$this->drupalPostForm(NULL, array(), 'Duplicate Page');
|
||||
$this->drupalPostForm(NULL, [], 'Duplicate Page');
|
||||
$this->assertLinkByHref($path_prefix . '/page_2', 0, 'Make sure after duplicating the new display appears in the UI');
|
||||
$this->assertUrl($path_prefix . '/page_2', array(), 'The user got redirected to the new display.');
|
||||
$this->assertUrl($path_prefix . '/page_2', [], 'The user got redirected to the new display.');
|
||||
|
||||
// Set the title and override the css classes.
|
||||
$random_title = $this->randomMachineName();
|
||||
$random_css = $this->randomMachineName();
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/title", array('title' => $random_title), t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/css_class", array('override[dropdown]' => 'page_2', 'css_class' => $random_css), t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/title", ['title' => $random_title], t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_2/css_class", ['override[dropdown]' => 'page_2', 'css_class' => $random_css], t('Apply'));
|
||||
|
||||
// Duplicate as a different display type.
|
||||
$this->drupalPostForm(NULL, array(), 'Duplicate as Block');
|
||||
$this->drupalPostForm(NULL, [], 'Duplicate as Block');
|
||||
$this->assertLinkByHref($path_prefix . '/block_1', 0, 'Make sure after duplicating the new display appears in the UI');
|
||||
$this->assertUrl($path_prefix . '/block_1', array(), 'The user got redirected to the new display.');
|
||||
$this->assertUrl($path_prefix . '/block_1', [], 'The user got redirected to the new display.');
|
||||
$this->assertText(t('Block settings'));
|
||||
$this->assertNoText(t('Page settings'));
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$view = Views::getView($view['id']);
|
||||
$view->initDisplay();
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ class DisplayExtenderUITest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests the display extender UI.
|
||||
*/
|
||||
public function testDisplayExtenderUI() {
|
||||
$this->config('views.settings')->set('display_extenders', array('display_extender_test'))->save();
|
||||
$this->config('views.settings')->set('display_extenders', ['display_extender_test'])->save();
|
||||
|
||||
$view = Views::getView('test_view');
|
||||
$view_edit_url = "admin/structure/views/view/{$view->storage->id()}/edit";
|
||||
|
@ -32,9 +32,9 @@ class DisplayExtenderUITest extends UITestBase {
|
|||
$this->assertLinkByHref($display_option_url, 0, 'Make sure the option defined by the test display extender appears in the UI.');
|
||||
|
||||
$random_text = $this->randomMachineName();
|
||||
$this->drupalPostForm($display_option_url, array('test_extender_test_option' => $random_text), t('Apply'));
|
||||
$this->drupalPostForm($display_option_url, ['test_extender_test_option' => $random_text], t('Apply'));
|
||||
$this->assertLink($random_text);
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$view = Views::getView($view->storage->id());
|
||||
$view->initDisplay();
|
||||
$display_extender_options = $view->display_handler->getOption('display_extenders');
|
||||
|
|
|
@ -15,14 +15,14 @@ class DisplayFeedTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_display_feed', 'test_style_opml');
|
||||
public static $testViews = ['test_display_feed', 'test_style_opml'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views_ui', 'aggregator');
|
||||
public static $modules = ['views_ui', 'aggregator'];
|
||||
|
||||
/**
|
||||
* Tests feed display admin UI.
|
||||
|
@ -55,7 +55,7 @@ class DisplayFeedTest extends UITestBase {
|
|||
|
||||
// Load all the options of the checkbox.
|
||||
$result = $this->xpath('//div[@id="edit-displays"]/div');
|
||||
$options = array();
|
||||
$options = [];
|
||||
foreach ($result as $item) {
|
||||
foreach ($item->input->attributes() as $attribute => $value) {
|
||||
if ($attribute == 'value') {
|
||||
|
@ -64,10 +64,10 @@ class DisplayFeedTest extends UITestBase {
|
|||
}
|
||||
}
|
||||
|
||||
$this->assertEqual($options, array('default', 'page'), 'Make sure all displays appears as expected.');
|
||||
$this->assertEqual($options, ['default', 'page'], 'Make sure all displays appears as expected.');
|
||||
|
||||
// Post and save this and check the output.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', array('displays[page]' => 'page'), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[page]' => 'page'], t('Apply'));
|
||||
// Options summary should be escaped.
|
||||
$this->assertEscaped('<em>Page</em>');
|
||||
$this->assertNoRaw('<em>Page</em>');
|
||||
|
@ -76,7 +76,7 @@ class DisplayFeedTest extends UITestBase {
|
|||
$this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', '<em>Page</em>');
|
||||
|
||||
// Add the default display, so there should now be multiple displays.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', array('displays[default]' => 'default'), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/' . $view_name . '/feed_1/displays', ['displays[default]' => 'default'], t('Apply'));
|
||||
$this->drupalGet('admin/structure/views/view/' . $view_name . '/edit/feed_1');
|
||||
$this->assertFieldByXpath('//*[@id="views-feed-1-displays"]', 'Multiple displays');
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ class DisplayPathTest extends UITestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('menu_ui');
|
||||
public static $modules = ['menu_ui'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_page_display_menu');
|
||||
public static $testViews = ['test_view', 'test_page_display_menu'];
|
||||
|
||||
/**
|
||||
* Runs the tests.
|
||||
|
@ -46,9 +46,9 @@ class DisplayPathTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views/view/test_view');
|
||||
|
||||
// Add a new page display and check the appearing text.
|
||||
$this->drupalPostForm(NULL, array(), 'Add Page');
|
||||
$this->drupalPostForm(NULL, [], 'Add Page');
|
||||
$this->assertText(t('No path is set'), 'The right text appears if no path was set.');
|
||||
$this->assertNoLink(t('View @display', array('@display' => 'page')), 'No view page link found on the page.');
|
||||
$this->assertNoLink(t('View @display', ['@display' => 'page']), 'No view page link found on the page.');
|
||||
|
||||
// Save a path and make sure the summary appears as expected.
|
||||
$random_path = $this->randomMachineName();
|
||||
|
@ -56,7 +56,7 @@ class DisplayPathTest extends UITestBase {
|
|||
// longer use Url::fromUri(), and this path will be able to contain ':'.
|
||||
$random_path = str_replace(':', '', $random_path);
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => $random_path), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => $random_path], t('Apply'));
|
||||
$this->assertText('/' . $random_path, 'The custom path appears in the summary.');
|
||||
$display_link_text = t('View @display', ['@display' => 'Page']);
|
||||
$this->assertLink($display_link_text, 0, 'view page link found on the page.');
|
||||
|
@ -69,13 +69,13 @@ class DisplayPathTest extends UITestBase {
|
|||
*/
|
||||
public function doPathXssFilterTest() {
|
||||
$this->drupalGet('admin/structure/views/view/test_view');
|
||||
$this->drupalPostForm(NULL, array(), 'Add Page');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_2/path', array('path' => '<object>malformed_path</object>'), t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), 'Add Page');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_3/path', array('path' => '<script>alert("hello");</script>'), t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), 'Add Page');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_4/path', array('path' => '<script>alert("hello I have placeholders %");</script>'), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], 'Add Page');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_2/path', ['path' => '<object>malformed_path</object>'], t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], 'Add Page');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_3/path', ['path' => '<script>alert("hello");</script>'], t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], 'Add Page');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_4/path', ['path' => '<script>alert("hello I have placeholders %");</script>'], t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
|
||||
$this->drupalGet('admin/structure/views');
|
||||
// The anchor text should be escaped.
|
||||
$this->assertEscaped('/<object>malformed_path</object>');
|
||||
|
@ -92,11 +92,11 @@ class DisplayPathTest extends UITestBase {
|
|||
protected function doAdvancedPathsValidationTest() {
|
||||
$url = 'admin/structure/views/nojs/display/test_view/page_1/path';
|
||||
|
||||
$this->drupalPostForm($url, array('path' => '%/magrathea'), t('Apply'));
|
||||
$this->drupalPostForm($url, ['path' => '%/magrathea'], t('Apply'));
|
||||
$this->assertUrl($url);
|
||||
$this->assertText('"%" may not be used for the first segment of a path.');
|
||||
|
||||
$this->drupalPostForm($url, array('path' => 'user/%1/example'), t('Apply'));
|
||||
$this->drupalPostForm($url, ['path' => 'user/%1/example'], t('Apply'));
|
||||
$this->assertUrl($url);
|
||||
$this->assertText("Numeric placeholders may not be used. Please use plain placeholders (%).");
|
||||
}
|
||||
|
@ -106,51 +106,51 @@ class DisplayPathTest extends UITestBase {
|
|||
*/
|
||||
public function testDeleteWithNoPath() {
|
||||
$this->drupalGet('admin/structure/views/view/test_view');
|
||||
$this->drupalPostForm(NULL, array(), t('Add Page'));
|
||||
$this->drupalPostForm(NULL, array(), t('Delete Page'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->assertRaw(t('The view %view has been saved.', array('%view' => 'Test view')));
|
||||
$this->drupalPostForm(NULL, [], t('Add Page'));
|
||||
$this->drupalPostForm(NULL, [], t('Delete Page'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the menu and tab option form.
|
||||
*/
|
||||
public function testMenuOptions() {
|
||||
$this->container->get('module_installer')->install(array('menu_ui'));
|
||||
$this->container->get('module_installer')->install(['menu_ui']);
|
||||
$this->drupalGet('admin/structure/views/view/test_view');
|
||||
|
||||
// Add a new page display.
|
||||
$this->drupalPostForm(NULL, array(), 'Add Page');
|
||||
$this->drupalPostForm(NULL, [], 'Add Page');
|
||||
|
||||
// Add an invalid path (only fragment).
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => '#foo'), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => '#foo'], t('Apply'));
|
||||
$this->assertText('Path is empty');
|
||||
|
||||
// Add an invalid path with a query.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => 'foo?bar'), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => 'foo?bar'], t('Apply'));
|
||||
$this->assertText('No query allowed.');
|
||||
|
||||
// Add an invalid path with just a query.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => '?bar'), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => '?bar'], t('Apply'));
|
||||
$this->assertText('Path is empty');
|
||||
|
||||
// Provide a random, valid path string.
|
||||
$random_string = $this->randomMachineName();
|
||||
|
||||
// Save a path.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => $random_string), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => $random_string], t('Apply'));
|
||||
$this->drupalGet('admin/structure/views/view/test_view');
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/menu', array('menu[type]' => 'default tab', 'menu[title]' => 'Test tab title'), t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/menu', ['menu[type]' => 'default tab', 'menu[title]' => 'Test tab title'], t('Apply'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl('admin/structure/views/nojs/display/test_view/page_1/tab_options');
|
||||
|
||||
$this->drupalPostForm(NULL, array('tab_options[type]' => 'tab', 'tab_options[title]' => $this->randomString()), t('Apply'));
|
||||
$this->drupalPostForm(NULL, ['tab_options[type]' => 'tab', 'tab_options[title]' => $this->randomString()], t('Apply'));
|
||||
$this->assertResponse(200);
|
||||
$this->assertUrl('admin/structure/views/view/test_view/edit/page_1');
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_view');
|
||||
$this->assertLink(t('Tab: @title', array('@title' => 'Test tab title')));
|
||||
$this->assertLink(t('Tab: @title', ['@title' => 'Test tab title']));
|
||||
// If it's a default tab, it should also have an additional settings link.
|
||||
$this->assertLinkByHref('admin/structure/views/nojs/display/test_view/page_1/tab_options');
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ class DisplayTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_display');
|
||||
public static $testViews = ['test_display'];
|
||||
|
||||
/**
|
||||
* Modules to enable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('contextual');
|
||||
public static $modules = ['contextual'];
|
||||
|
||||
/**
|
||||
* Tests adding a display.
|
||||
|
@ -53,9 +53,9 @@ class DisplayTest extends UITestBase {
|
|||
* Tests reordering of displays.
|
||||
*/
|
||||
public function testReorderDisplay() {
|
||||
$view = array(
|
||||
$view = [
|
||||
'block[create]' => TRUE
|
||||
);
|
||||
];
|
||||
$view = $this->randomView($view);
|
||||
|
||||
$this->clickLink(t('Reorder displays'));
|
||||
|
@ -64,15 +64,15 @@ class DisplayTest extends UITestBase {
|
|||
$this->assertTrue($this->xpath('//tr[@id="display-row-block_1"]'), 'Make sure the block display appears on the reorder listing');
|
||||
|
||||
// Ensure the view displays are in the expected order in configuration.
|
||||
$expected_display_order = array('default', 'block_1', 'page_1');
|
||||
$expected_display_order = ['default', 'block_1', 'page_1'];
|
||||
$this->assertEqual(array_keys(Views::getView($view['id'])->storage->get('display')), $expected_display_order, 'The correct display names are present.');
|
||||
// Put the block display in front of the page display.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'displays[page_1][weight]' => 2,
|
||||
'displays[block_1][weight]' => 1
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$view = Views::getView($view['id']);
|
||||
$displays = $view->storage->get('display');
|
||||
|
@ -92,17 +92,17 @@ class DisplayTest extends UITestBase {
|
|||
$path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
|
||||
|
||||
$this->drupalGet($path_prefix);
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', array(':class' => 'views-display-disabled')), 'Make sure the disabled display css class does not appear after initial adding of a view.');
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appear after initial adding of a view.');
|
||||
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is visible.');
|
||||
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is not visible.');
|
||||
$this->drupalPostForm(NULL, array(), 'Disable Page');
|
||||
$this->assertTrue($this->xpath('//div[contains(@class, :class)]', array(':class' => 'views-display-disabled')), 'Make sure the disabled display css class appears once the display is marked as such.');
|
||||
$this->drupalPostForm(NULL, [], 'Disable Page');
|
||||
$this->assertTrue($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class appears once the display is marked as such.');
|
||||
|
||||
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is not visible.');
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is visible.');
|
||||
$this->drupalPostForm(NULL, array(), 'Enable Page');
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', array(':class' => 'views-display-disabled')), 'Make sure the disabled display css class does not appears once the display is enabled again.');
|
||||
$this->drupalPostForm(NULL, [], 'Enable Page');
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appears once the display is enabled again.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,10 +111,10 @@ class DisplayTest extends UITestBase {
|
|||
public function testDisplayPluginsAlter() {
|
||||
$definitions = Views::pluginManager('display')->getDefinitions();
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'route_name' => 'entity.view.edit_form',
|
||||
'route_parameters_names' => array('view' => 'id'),
|
||||
);
|
||||
'route_parameters_names' => ['view' => 'id'],
|
||||
];
|
||||
|
||||
// Test the expected views_ui array exists on each definition.
|
||||
foreach ($definitions as $definition) {
|
||||
|
@ -136,16 +136,16 @@ class DisplayTest extends UITestBase {
|
|||
|
||||
$this->drupalGet('admin/structure/views/view/test_display/edit/display_no_area_test_1');
|
||||
|
||||
$areas = array(
|
||||
$areas = [
|
||||
'header',
|
||||
'footer',
|
||||
'empty',
|
||||
);
|
||||
];
|
||||
|
||||
// Assert that the expected text is found in each area category.
|
||||
foreach ($areas as $type) {
|
||||
$element = $this->xpath('//div[contains(@class, :class)]/div', array(':class' => $type));
|
||||
$this->assertEqual((string) $element[0], SafeMarkup::format('The selected display type does not use @type plugins', array('@type' => $type)));
|
||||
$element = $this->xpath('//div[contains(@class, :class)]/div', [':class' => $type]);
|
||||
$this->assertEqual((string) $element[0], SafeMarkup::format('The selected display type does not use @type plugins', ['@type' => $type]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,28 +159,28 @@ class DisplayTest extends UITestBase {
|
|||
|
||||
// Test the link text displays 'None' and not 'Block 1'
|
||||
$this->drupalGet($path);
|
||||
$result = $this->xpath("//a[contains(@href, :path)]", array(':path' => $link_display_path));
|
||||
$result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
|
||||
$this->assertEqual($result[0], t('None'), 'Make sure that the link option summary shows "None" by default.');
|
||||
|
||||
$this->drupalGet($link_display_path);
|
||||
$this->assertFieldChecked('edit-link-display-0');
|
||||
|
||||
// Test the default radio option on the link display form.
|
||||
$this->drupalPostForm($link_display_path, array('link_display' => 'page_1'), t('Apply'));
|
||||
$this->drupalPostForm($link_display_path, ['link_display' => 'page_1'], t('Apply'));
|
||||
// The form redirects to the master display.
|
||||
$this->drupalGet($path);
|
||||
|
||||
$result = $this->xpath("//a[contains(@href, :path)]", array(':path' => $link_display_path));
|
||||
$result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
|
||||
$this->assertEqual($result[0], 'Page', 'Make sure that the link option summary shows the right linked display.');
|
||||
|
||||
$this->drupalPostForm($link_display_path, array('link_display' => 'custom_url', 'link_url' => 'a-custom-url'), t('Apply'));
|
||||
$this->drupalPostForm($link_display_path, ['link_display' => 'custom_url', 'link_url' => 'a-custom-url'], t('Apply'));
|
||||
// The form redirects to the master display.
|
||||
$this->drupalGet($path);
|
||||
|
||||
$this->assertLink(t('Custom URL'), 0, 'The link option has custom URL as summary.');
|
||||
|
||||
// Test the default link_url value for new display
|
||||
$this->drupalPostForm(NULL, array(), t('Add Block'));
|
||||
$this->drupalPostForm(NULL, [], t('Add Block'));
|
||||
$this->assertUrl('admin/structure/views/view/test_display/edit/block_2');
|
||||
$this->clickLink(t('Custom URL'));
|
||||
$this->assertFieldByName('link_url', 'a-custom-url');
|
||||
|
@ -190,7 +190,7 @@ class DisplayTest extends UITestBase {
|
|||
* Tests contextual links on Views page displays.
|
||||
*/
|
||||
public function testPageContextualLinks() {
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links')));
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links']));
|
||||
$view = View::load('test_display');
|
||||
$view->enable()->save();
|
||||
$this->container->get('router.builder')->rebuildIfNeeded();
|
||||
|
@ -200,12 +200,12 @@ class DisplayTest extends UITestBase {
|
|||
$this->drupalGet('test-display');
|
||||
$id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
|
||||
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
|
||||
$this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
|
||||
$this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
|
||||
|
||||
// Get server-rendered contextual links.
|
||||
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
|
||||
$post = array('ids[0]' => $id);
|
||||
$response = $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => 'test-display')));
|
||||
$post = ['ids[0]' => $id];
|
||||
$response = $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => 'test-display']]);
|
||||
$this->assertResponse(200);
|
||||
$json = Json::decode($response);
|
||||
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1">Edit view</a></li></ul>');
|
||||
|
@ -217,7 +217,7 @@ class DisplayTest extends UITestBase {
|
|||
$this->drupalGet('test-display');
|
||||
$id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
|
||||
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
|
||||
$this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
|
||||
$this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -229,14 +229,14 @@ class DisplayTest extends UITestBase {
|
|||
|
||||
// The view should initially have the enabled class on it's form wrapper.
|
||||
$this->drupalGet('admin/structure/views/view/' . $id);
|
||||
$elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', array(':edit' => 'views-edit-view', ':status' => 'enabled'));
|
||||
$elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [':edit' => 'views-edit-view', ':status' => 'enabled']);
|
||||
$this->assertTrue($elements, 'The enabled class was found on the form wrapper');
|
||||
|
||||
$view = Views::getView($id);
|
||||
$view->storage->disable()->save();
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/' . $id);
|
||||
$elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', array(':edit' => 'views-edit-view', ':status' => 'disabled'));
|
||||
$elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [':edit' => 'views-edit-view', ':status' => 'disabled']);
|
||||
$this->assertTrue($elements, 'The disabled class was found on the form wrapper.');
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ class DisplayTest extends UITestBase {
|
|||
$display_title = "'<test>'";
|
||||
$this->drupalGet('admin/structure/views/view/test_display');
|
||||
$display_title_path = 'admin/structure/views/nojs/display/test_display/block_1/display_title';
|
||||
$this->drupalPostForm($display_title_path, array('display_title' => $display_title), t('Apply'));
|
||||
$this->drupalPostForm($display_title_path, ['display_title' => $display_title], t('Apply'));
|
||||
|
||||
// Ensure that the title is escaped as expected.
|
||||
$this->assertEscaped($display_title);
|
||||
|
|
|
@ -24,7 +24,7 @@ class DuplicateTest extends UITestBase {
|
|||
$random_view = $this->randomView();
|
||||
|
||||
// Initialize array for duplicated view.
|
||||
$view = array();
|
||||
$view = [];
|
||||
|
||||
// Generate random label and id for new view.
|
||||
$view['label'] = $this->randomMachineName(255);
|
||||
|
@ -34,7 +34,7 @@ class DuplicateTest extends UITestBase {
|
|||
$this->drupalPostForm('admin/structure/views/view/' . $random_view['id'] . '/duplicate', $view, t('Duplicate'));
|
||||
|
||||
// Assert that the page url is correct.
|
||||
$this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
|
||||
$this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
|
||||
|
||||
// Assert that the page title is correctly displayed.
|
||||
$this->assertText($view['label']);
|
||||
|
|
|
@ -16,12 +16,12 @@ class ExposedFormUITest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_exposed_admin_ui');
|
||||
public static $testViews = ['test_exposed_admin_ui'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('node', 'views_ui', 'block', 'taxonomy', 'field_ui', 'datetime');
|
||||
public static $modules = ['node', 'views_ui', 'block', 'taxonomy', 'field_ui', 'datetime'];
|
||||
|
||||
/**
|
||||
* Array of error message strings raised by the grouped form.
|
||||
|
@ -35,8 +35,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalCreateContentType(array('type' => 'article'));
|
||||
$this->drupalCreateContentType(array('type' => 'page'));
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
|
||||
// Create some random nodes.
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
|
@ -52,8 +52,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
/**
|
||||
* Tests the admin interface of exposed filter and sort items.
|
||||
*/
|
||||
function testExposedAdminUi() {
|
||||
$edit = array();
|
||||
public function testExposedAdminUi() {
|
||||
$edit = [];
|
||||
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
// Be sure that the button is called exposed.
|
||||
|
@ -78,12 +78,12 @@ class ExposedFormUITest extends UITestBase {
|
|||
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists');
|
||||
|
||||
// Check the validations of the filter handler.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['options[expose][identifier]'] = '';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertText(t('The identifier is required if the filter is exposed.'));
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['options[expose][identifier]'] = 'value';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertText(t('This identifier is not allowed.'));
|
||||
|
@ -95,7 +95,7 @@ class ExposedFormUITest extends UITestBase {
|
|||
|
||||
// Un-expose the filter.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
$this->drupalPostForm(NULL, array(), t('Hide filter'));
|
||||
$this->drupalPostForm(NULL, [], t('Hide filter'));
|
||||
|
||||
// After Un-exposing the filter, Operator and Value should be shown again.
|
||||
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists after hide filter');
|
||||
|
@ -104,7 +104,7 @@ class ExposedFormUITest extends UITestBase {
|
|||
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists after hide filter');
|
||||
|
||||
// Click the Expose sort button.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
|
||||
// Check the label of the expose button.
|
||||
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort'));
|
||||
|
@ -134,8 +134,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
/**
|
||||
* Tests the admin interface of exposed grouped filters.
|
||||
*/
|
||||
function testGroupedFilterAdminUi() {
|
||||
$edit = array();
|
||||
public function testGroupedFilterAdminUi() {
|
||||
$edit = [];
|
||||
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
|
||||
|
@ -146,7 +146,7 @@ class ExposedFormUITest extends UITestBase {
|
|||
|
||||
// Click the Grouped Filters button.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
$this->drupalPostForm(NULL, array(), t('Grouped filters'));
|
||||
$this->drupalPostForm(NULL, [], t('Grouped filters'));
|
||||
|
||||
// After click on 'Grouped Filters', the standard operator and value should
|
||||
// not be displayed.
|
||||
|
@ -161,7 +161,7 @@ class ExposedFormUITest extends UITestBase {
|
|||
|
||||
// Validate a single entry for a grouped filter.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
|
||||
$edit["options[group_info][group_items][1][value][article]"] = 'article';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
|
@ -170,7 +170,7 @@ class ExposedFormUITest extends UITestBase {
|
|||
|
||||
// Validate multiple entries for grouped filters.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
|
||||
$edit["options[group_info][group_items][1][value][article]"] = 'article';
|
||||
$edit["options[group_info][group_items][2][title]"] = 'Is Page';
|
||||
|
@ -179,28 +179,28 @@ class ExposedFormUITest extends UITestBase {
|
|||
$edit["options[group_info][group_items][3][value][article]"] = 'article';
|
||||
$edit["options[group_info][group_items][3][value][page]"] = 'page';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'Correct validation of the node type filter.');
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'Correct validation of the node type filter.');
|
||||
$this->assertNoGroupedFilterErrors();
|
||||
|
||||
// Validate an "is empty" filter -- title without value is valid.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit["options[group_info][group_items][1][title]"] = 'No body';
|
||||
$edit["options[group_info][group_items][1][operator]"] = 'empty';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'The "empty" operator validates correctly.');
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'The "empty" operator validates correctly.');
|
||||
$this->assertNoGroupedFilterErrors();
|
||||
|
||||
// Ensure the string "0" can be used as a value for numeric filters.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', array('name[node_field_data.nid]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria'))));
|
||||
$this->drupalPostForm(NULL, array(), t('Expose filter'));
|
||||
$this->drupalPostForm(NULL, array(), t('Grouped filters'));
|
||||
$edit = array();
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', ['name[node_field_data.nid]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
|
||||
$this->drupalPostForm(NULL, [], t('Expose filter'));
|
||||
$this->drupalPostForm(NULL, [], t('Grouped filters'));
|
||||
$edit = [];
|
||||
$edit['options[group_info][group_items][1][title]'] = 'Testing zero';
|
||||
$edit['options[group_info][group_items][1][operator]'] = '>';
|
||||
$edit['options[group_info][group_items][1][value][value]'] = '0';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'A string "0" is a valid value.');
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'A string "0" is a valid value.');
|
||||
$this->assertNoGroupedFilterErrors();
|
||||
|
||||
// Ensure "between" filters validate correctly.
|
||||
|
@ -210,14 +210,14 @@ class ExposedFormUITest extends UITestBase {
|
|||
$edit['options[group_info][group_items][1][value][min]'] = '0';
|
||||
$edit['options[group_info][group_items][1][value][max]'] = '10';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', array(), 'The "between" filter validates correctly.');
|
||||
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'The "between" filter validates correctly.');
|
||||
$this->assertNoGroupedFilterErrors();
|
||||
}
|
||||
|
||||
public function testGroupedFilterAdminUiErrors() {
|
||||
// Select the empty operator without a title specified.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit["options[group_info][group_items][1][title]"] = '';
|
||||
$edit["options[group_info][group_items][1][operator]"] = 'empty';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
|
@ -227,14 +227,14 @@ class ExposedFormUITest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Expose filter'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Grouped filters'));
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertText($this->groupFormUiErrors['missing_value']);
|
||||
|
||||
// Specify a value without a title.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit["options[group_info][group_items][1][title]"] = '';
|
||||
$edit["options[group_info][group_items][1][value][article]"] = 'article';
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
|
@ -265,4 +265,56 @@ class ExposedFormUITest extends UITestBase {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the configuration of grouped exposed filters.
|
||||
*/
|
||||
public function testExposedGroupedFilter() {
|
||||
// Click the Expose filter button.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Expose filter'));
|
||||
// Select 'Grouped filters' radio button.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Grouped filters'));
|
||||
// Add 3 groupings.
|
||||
$edit = [
|
||||
'options[group_button][radios][radios]' => 1,
|
||||
'options[group_info][group_items][1][title]' => '1st',
|
||||
'options[group_info][group_items][1][value][all]' => 'all',
|
||||
'options[group_info][group_items][2][title]' => '2nd',
|
||||
'options[group_info][group_items][2][value][article]' => 'article',
|
||||
'options[group_info][group_items][3][title]' => '3rd',
|
||||
'options[group_info][group_items][3][value][page]' => 'page',
|
||||
];
|
||||
// Apply the filter settings.
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
// Check that the view is saved without errors.
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Click the Expose filter button.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', ['name[node_field_data.status]' => 1], t('Add and configure filter criteria'));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status', [], t('Expose filter'));
|
||||
// Select 'Grouped filters' radio button.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status', [], t('Grouped filters'));
|
||||
// Add 3 groupings.
|
||||
$edit = [
|
||||
'options[group_button][radios][radios]' => 1,
|
||||
'options[group_info][group_items][1][title]' => 'Any',
|
||||
'options[group_info][group_items][1][value]' => 'All',
|
||||
'options[group_info][group_items][2][title]' => 'Published',
|
||||
'options[group_info][group_items][2][value]' => 1,
|
||||
'options[group_info][group_items][3][title]' => 'Unpublished',
|
||||
'options[group_info][group_items][3][value]' => 0,
|
||||
];
|
||||
// Apply the filter settings.
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
// Check that the view is saved without errors.
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status');
|
||||
// Assert the same settings defined before still are there.
|
||||
$this->assertFieldChecked('edit-options-group-info-group-items-1-value-all');
|
||||
$this->assertFieldChecked('edit-options-group-info-group-items-2-value-1');
|
||||
$this->assertFieldChecked('edit-options-group-info-group-items-3-value-0');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class FieldUITest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests the UI of field handlers.
|
||||
|
@ -31,7 +31,7 @@ class FieldUITest extends UITestBase {
|
|||
|
||||
// Hides the field and check whether the hidden label is appended.
|
||||
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name';
|
||||
$this->drupalPostForm($edit_handler_url, array('options[exclude]' => TRUE), t('Apply'));
|
||||
$this->drupalPostForm($edit_handler_url, ['options[exclude]' => TRUE], t('Apply'));
|
||||
|
||||
$this->assertText('Views test: Name [' . t('hidden') . ']');
|
||||
|
||||
|
@ -62,9 +62,9 @@ class FieldUITest extends UITestBase {
|
|||
$this->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.');
|
||||
|
||||
// Enable aggregation on the view.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'group_by' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('/admin/structure/views/nojs/display/test_view/default/group_by', $edit, t('Apply'));
|
||||
|
||||
$this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.');
|
||||
|
@ -81,7 +81,7 @@ class FieldUITest extends UITestBase {
|
|||
public function testFieldLabel() {
|
||||
// Create a view with unformatted style and make sure the fields have no
|
||||
// labels by default.
|
||||
$view = array();
|
||||
$view = [];
|
||||
$view['label'] = $this->randomMachineName(16);
|
||||
$view['id'] = strtolower($this->randomMachineName(16));
|
||||
$view['description'] = $this->randomMachineName(16);
|
||||
|
|
|
@ -15,22 +15,22 @@ class FilterBooleanWebTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests the filter boolean UI.
|
||||
*/
|
||||
public function testFilterBooleanUI() {
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', array('name[views_test_data.status]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria'))));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', ['name[views_test_data.status]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
|
||||
|
||||
// Check the field widget label. 'title' should be used as a fallback.
|
||||
$result = $this->cssSelect('#edit-options-value--wrapper legend span');
|
||||
$this->assertEqual((string) $result[0], 'Status');
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Expose filter'));
|
||||
$this->drupalPostForm(NULL, array(), t('Grouped filters'));
|
||||
$this->drupalPostForm(NULL, [], t('Expose filter'));
|
||||
$this->drupalPostForm(NULL, [], t('Grouped filters'));
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['options[group_info][group_items][1][title]'] = 'Published';
|
||||
$edit['options[group_info][group_items][1][operator]'] = '=';
|
||||
$edit['options[group_info][group_items][1][value]'] = 1;
|
||||
|
@ -56,7 +56,7 @@ class FilterBooleanWebTest extends UITestBase {
|
|||
$this->assertEqual(count($this->cssSelect('a.views-remove-link')), 3);
|
||||
|
||||
// Test selecting a default and removing an item.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['options[group_info][default_group]'] = 2;
|
||||
$edit['options[group_info][group_items][3][remove]'] = 1;
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Tests the numeric filter UI.
|
||||
|
@ -18,18 +18,18 @@ class FilterNumericWebTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests the filter numeric UI.
|
||||
*/
|
||||
public function testFilterNumericUI() {
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', array('name[views_test_data.age]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria'))));
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', ['name[views_test_data.age]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Expose filter'));
|
||||
$this->drupalPostForm(NULL, array(), t('Grouped filters'));
|
||||
$this->drupalPostForm(NULL, [], t('Expose filter'));
|
||||
$this->drupalPostForm(NULL, [], t('Grouped filters'));
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['options[group_info][group_items][1][title]'] = 'Old';
|
||||
$edit['options[group_info][group_items][1][operator]'] = '>';
|
||||
$edit['options[group_info][group_items][1][value][value]'] = 27;
|
||||
|
@ -48,17 +48,17 @@ class FilterNumericWebTest extends UITestBase {
|
|||
$this->assertFieldByName($name, $value);
|
||||
}
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
|
||||
$this->assertConfigSchemaByName('views.view.test_view');
|
||||
|
||||
// Test that the exposed filter works as expected.
|
||||
$this->drupalPostForm(NULL, array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$this->assertText('John');
|
||||
$this->assertText('Paul');
|
||||
$this->assertText('Ringo');
|
||||
$this->assertText('George');
|
||||
$this->assertText('Meredith');
|
||||
$this->drupalPostForm(NULL, array('age' => '2'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, ['age' => '2'], t('Update preview'));
|
||||
$this->assertText('John');
|
||||
$this->assertText('Paul');
|
||||
$this->assertNoText('Ringo');
|
||||
|
@ -67,21 +67,21 @@ class FilterNumericWebTest extends UITestBase {
|
|||
|
||||
// Change the filter to a single filter to test the schema when the operator
|
||||
// is not exposed.
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/filter/age', array(), t('Single filter'));
|
||||
$edit = array();
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/filter/age', [], t('Single filter'));
|
||||
$edit = [];
|
||||
$edit['options[value][value]'] = 25;
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
|
||||
$this->assertConfigSchemaByName('views.view.test_view');
|
||||
|
||||
// Test that the filter works as expected.
|
||||
$this->drupalPostForm(NULL, array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$this->assertText('John');
|
||||
$this->assertNoText('Paul');
|
||||
$this->assertNoText('Ringo');
|
||||
$this->assertNoText('George');
|
||||
$this->assertNoText('Meredith');
|
||||
$this->drupalPostForm(NULL, array('age' => '26'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, ['age' => '26'], t('Update preview'));
|
||||
$this->assertNoText('John');
|
||||
$this->assertText('Paul');
|
||||
$this->assertNoText('Ringo');
|
||||
|
@ -91,17 +91,17 @@ class FilterNumericWebTest extends UITestBase {
|
|||
// Change the filter to a 'between' filter to test if the label and
|
||||
// description are set for the 'minimum' filter element.
|
||||
$this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/age');
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['options[expose][label]'] = 'Age between';
|
||||
$edit['options[expose][description]'] = 'Description of the exposed filter';
|
||||
$edit['options[operator]'] = 'between';
|
||||
$edit['options[value][min]'] = 26;
|
||||
$edit['options[value][max]'] = 28;
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', array(), t('Save'));
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view', [], t('Save'));
|
||||
$this->assertConfigSchemaByName('views.view.test_view');
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
// Check the max field label.
|
||||
$this->assertRaw('<label for="edit-age-max">And</label>', 'Max field label found');
|
||||
$this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
|
||||
|
|
|
@ -17,21 +17,21 @@ class FilterUITest extends ViewTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_filter_in_operator_ui', 'test_filter_groups');
|
||||
public static $testViews = ['test_filter_in_operator_ui', 'test_filter_groups'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views_ui', 'node');
|
||||
public static $modules = ['views_ui', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->drupalCreateContentType(array('type' => 'page'));
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$this->enableViewsTestModule();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ class FilterUITest extends ViewTestBase {
|
|||
* Tests that an option for a filter is saved as expected from the UI.
|
||||
*/
|
||||
public function testFilterInOperatorUi() {
|
||||
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
|
||||
$admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$path = 'admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/type';
|
||||
|
@ -48,9 +48,9 @@ class FilterUITest extends ViewTestBase {
|
|||
$this->assertFieldByName('options[expose][reduce]', FALSE);
|
||||
|
||||
// Select "Limit list to selected items" option and apply.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'options[expose][reduce]' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm($path, $edit, t('Apply'));
|
||||
|
||||
// Verifies that the option was saved as expected.
|
||||
|
@ -62,7 +62,7 @@ class FilterUITest extends ViewTestBase {
|
|||
* Tests the filters from the UI.
|
||||
*/
|
||||
public function testFiltersUI() {
|
||||
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
|
||||
$admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_filter_groups');
|
||||
|
@ -94,28 +94,28 @@ class FilterUITest extends ViewTestBase {
|
|||
* Tests the identifier settings and restrictions.
|
||||
*/
|
||||
public function testFilterIdentifier() {
|
||||
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
|
||||
$admin_user = $this->drupalCreateUser(['administer views', 'administer site configuration']);
|
||||
$this->drupalLogin($admin_user);
|
||||
$path = 'admin/structure/views/nojs/handler/test_filter_in_operator_ui/default/filter/type';
|
||||
|
||||
// Set an empty identifier.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'options[expose][identifier]' => '',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm($path, $edit, t('Apply'));
|
||||
$this->assertText('The identifier is required if the filter is exposed.');
|
||||
|
||||
// Set the identifier to 'value'.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'options[expose][identifier]' => 'value',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm($path, $edit, t('Apply'));
|
||||
$this->assertText('This identifier is not allowed.');
|
||||
|
||||
// Set the identifier to a value with a restricted character.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'options[expose][identifier]' => 'value value',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm($path, $edit, t('Apply'));
|
||||
$this->assertText('This identifier has illegal characters.');
|
||||
}
|
||||
|
|
|
@ -14,32 +14,32 @@ class GroupByTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_views_groupby_save');
|
||||
public static $testViews = ['test_views_groupby_save'];
|
||||
|
||||
/**
|
||||
* Tests whether basic saving works.
|
||||
*
|
||||
* @todo This should check the change of the settings as well.
|
||||
*/
|
||||
function testGroupBySave() {
|
||||
public function testGroupBySave() {
|
||||
$this->drupalGet('admin/structure/views/view/test_views_groupby_save/edit');
|
||||
|
||||
$edit_groupby_url = 'admin/structure/views/nojs/handler-group/test_views_groupby_save/default/field/id';
|
||||
$this->assertNoLinkByHref($edit_groupby_url, 0, 'No aggregation link found.');
|
||||
|
||||
// Enable aggregation on the view.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'group_by' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by', $edit, t('Apply'));
|
||||
|
||||
$this->assertLinkByHref($edit_groupby_url, 0, 'Aggregation link found.');
|
||||
|
||||
// Change the groupby type in the UI.
|
||||
$this->drupalPostForm($edit_groupby_url, array('options[group_type]' => 'count'), t('Apply'));
|
||||
$this->drupalPostForm($edit_groupby_url, ['options[group_type]' => 'count'], t('Apply'));
|
||||
$this->assertLink('COUNT(Views test: ID)', 0, 'The count setting is displayed in the UI');
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_views_groupby_save');
|
||||
$display = $view->getDisplay('default');
|
||||
|
|
|
@ -19,14 +19,14 @@ class HandlerTest extends UITestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('node_test_views');
|
||||
public static $modules = ['node_test_views'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_empty', 'test_view_broken', 'node', 'test_node_view');
|
||||
public static $testViews = ['test_view_empty', 'test_view_broken', 'node', 'test_node_view'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -35,7 +35,7 @@ class HandlerTest extends UITestBase {
|
|||
parent::setUp();
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
ViewTestData::createTestViews(get_class($this), array('node_test_views'));
|
||||
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,13 +46,13 @@ class HandlerTest extends UITestBase {
|
|||
protected function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
|
||||
$schema['views_test_data']['fields']['uid'] = array(
|
||||
$schema['views_test_data']['fields']['uid'] = [
|
||||
'description' => "The {users}.uid of the author of the beatle entry.",
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0
|
||||
);
|
||||
];
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
@ -66,15 +66,15 @@ class HandlerTest extends UITestBase {
|
|||
*/
|
||||
protected function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['uid'] = array(
|
||||
$data['views_test_data']['uid'] = [
|
||||
'title' => t('UID'),
|
||||
'help' => t('The test data UID'),
|
||||
'relationship' => array(
|
||||
'relationship' => [
|
||||
'id' => 'standard',
|
||||
'base' => 'users_field_data',
|
||||
'base field' => 'uid'
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
|
||||
// Create a dummy field with no help text.
|
||||
$data['views_test_data']['no_help'] = $data['views_test_data']['name'];
|
||||
|
@ -95,43 +95,43 @@ class HandlerTest extends UITestBase {
|
|||
$add_handler_url = "admin/structure/views/nojs/add-handler/test_view_empty/default/$type";
|
||||
|
||||
// Area handler types need to use a different handler.
|
||||
if (in_array($type, array('header', 'footer', 'empty'))) {
|
||||
$this->drupalPostForm($add_handler_url, array('name[views.area]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
|
||||
if (in_array($type, ['header', 'footer', 'empty'])) {
|
||||
$this->drupalPostForm($add_handler_url, ['name[views.area]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
|
||||
$id = 'area';
|
||||
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id";
|
||||
}
|
||||
elseif ($type == 'relationship') {
|
||||
$this->drupalPostForm($add_handler_url, array('name[views_test_data.uid]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
|
||||
$this->drupalPostForm($add_handler_url, ['name[views_test_data.uid]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
|
||||
$id = 'uid';
|
||||
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id";
|
||||
}
|
||||
else {
|
||||
$this->drupalPostForm($add_handler_url, array('name[views_test_data.job]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
|
||||
$this->drupalPostForm($add_handler_url, ['name[views_test_data.job]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
|
||||
$id = 'job';
|
||||
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/$type/$id";
|
||||
}
|
||||
|
||||
$this->assertUrl($edit_handler_url, array(), 'The user got redirected to the handler edit form.');
|
||||
$this->assertUrl($edit_handler_url, [], 'The user got redirected to the handler edit form.');
|
||||
$random_label = $this->randomMachineName();
|
||||
$this->drupalPostForm(NULL, array('options[admin_label]' => $random_label), t('Apply'));
|
||||
$this->drupalPostForm(NULL, ['options[admin_label]' => $random_label], t('Apply'));
|
||||
|
||||
$this->assertUrl('admin/structure/views/view/test_view_empty/edit/default', array(), 'The user got redirected to the views edit form.');
|
||||
$this->assertUrl('admin/structure/views/view/test_view_empty/edit/default', [], 'The user got redirected to the views edit form.');
|
||||
|
||||
$this->assertLinkByHref($edit_handler_url, 0, 'The handler edit link appears in the UI.');
|
||||
$links = $this->xpath('//a[starts-with(normalize-space(text()), :label)]', array(':label' => $random_label));
|
||||
$links = $this->xpath('//a[starts-with(normalize-space(text()), :label)]', [':label' => $random_label]);
|
||||
$this->assertTrue(isset($links[0]), 'The handler edit link has the right label');
|
||||
|
||||
// Save the view and have a look whether the handler was added as expected.
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view_empty');
|
||||
$display = $view->getDisplay('default');
|
||||
$this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.');
|
||||
|
||||
// Remove the item and check that it's removed
|
||||
$this->drupalPostForm($edit_handler_url, array(), t('Remove'));
|
||||
$this->drupalPostForm($edit_handler_url, [], t('Remove'));
|
||||
$this->assertNoLinkByHref($edit_handler_url, 0, 'The handler edit link does not appears in the UI after removing.');
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view_empty');
|
||||
$display = $view->getDisplay('default');
|
||||
$this->assertFalse(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was removed from the view itself.');
|
||||
|
@ -140,19 +140,19 @@ class HandlerTest extends UITestBase {
|
|||
// Test adding a field of the user table using the uid relationship.
|
||||
$type_info = $handler_types['relationship'];
|
||||
$add_handler_url = "admin/structure/views/nojs/add-handler/test_view_empty/default/relationship";
|
||||
$this->drupalPostForm($add_handler_url, array('name[views_test_data.uid]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
|
||||
$this->drupalPostForm($add_handler_url, ['name[views_test_data.uid]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
|
||||
|
||||
$add_handler_url = "admin/structure/views/nojs/add-handler/test_view_empty/default/field";
|
||||
$type_info = $handler_types['field'];
|
||||
$this->drupalPostForm($add_handler_url, array('name[users_field_data.name]' => TRUE), t('Add and configure @handler', array('@handler' => $type_info['ltitle'])));
|
||||
$this->drupalPostForm($add_handler_url, ['name[users_field_data.name]' => TRUE], t('Add and configure @handler', ['@handler' => $type_info['ltitle']]));
|
||||
$id = 'name';
|
||||
$edit_handler_url = "admin/structure/views/nojs/handler/test_view_empty/default/field/$id";
|
||||
|
||||
$this->assertUrl($edit_handler_url, array(), 'The user got redirected to the handler edit form.');
|
||||
$this->assertUrl($edit_handler_url, [], 'The user got redirected to the handler edit form.');
|
||||
$this->assertFieldByName('options[relationship]', 'uid', 'Ensure the relationship select is filled with the UID relationship.');
|
||||
$this->drupalPostForm(NULL, array(), t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Apply'));
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view_empty');
|
||||
$display = $view->getDisplay('default');
|
||||
$this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.');
|
||||
|
@ -203,8 +203,8 @@ class HandlerTest extends UITestBase {
|
|||
|
||||
$href = "admin/structure/views/nojs/handler/test_view_broken/default/$type/id_broken";
|
||||
|
||||
$result = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
|
||||
$this->assertEqual(count($result), 1, SafeMarkup::format('Handler (%type) edit link found.', array('%type' => $type)));
|
||||
$result = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
|
||||
$this->assertEqual(count($result), 1, SafeMarkup::format('Handler (%type) edit link found.', ['%type' => $type]));
|
||||
|
||||
$text = 'Broken/missing handler';
|
||||
|
||||
|
@ -223,7 +223,7 @@ class HandlerTest extends UITestBase {
|
|||
];
|
||||
|
||||
foreach ($original_configuration as $key => $value) {
|
||||
$this->assertText(SafeMarkup::format('@key: @value', array('@key' => $key, '@value' => $value)));
|
||||
$this->assertText(SafeMarkup::format('@key: @value', ['@key' => $key, '@value' => $value]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,16 +16,16 @@ class NewViewConfigSchemaTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views_ui', 'node', 'comment', 'file', 'taxonomy', 'dblog', 'aggregator');
|
||||
public static $modules = ['views_ui', 'node', 'comment', 'file', 'taxonomy', 'dblog', 'aggregator'];
|
||||
|
||||
/**
|
||||
* Tests creating brand new views.
|
||||
*/
|
||||
public function testNewViews() {
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer views')));
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer views']));
|
||||
|
||||
// Create views with all core Views wizards.
|
||||
$wizards = array(
|
||||
$wizards = [
|
||||
// Wizard with their own classes.
|
||||
'node',
|
||||
'node_revision',
|
||||
|
@ -37,9 +37,9 @@ class NewViewConfigSchemaTest extends WebTestBase {
|
|||
// Standard derivative classes.
|
||||
'standard:aggregator_feed',
|
||||
'standard:aggregator_item',
|
||||
);
|
||||
];
|
||||
foreach ($wizards as $wizard_key) {
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['label'] = $this->randomString();
|
||||
$edit['id'] = strtolower($this->randomMachineName());
|
||||
$edit['show[wizard_key]'] = $wizard_key;
|
||||
|
|
|
@ -18,7 +18,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
/**
|
||||
* Tests that displays can be overridden via the UI.
|
||||
*/
|
||||
function testOverrideDisplays() {
|
||||
public function testOverrideDisplays() {
|
||||
// Create a basic view that shows all content, with a page and a block
|
||||
// display.
|
||||
$view['label'] = $this->randomMachineName(16);
|
||||
|
@ -33,15 +33,15 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
// same (empty) title in the views wizard, we expect the wizard to have set
|
||||
// things up so that they both inherit from the default display, and we
|
||||
// therefore only need to change that to have it take effect for both.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title'] = $original_title = $this->randomMachineName(16);
|
||||
$edit['override[dropdown]'] = 'default';
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", array(), t('Save'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save'));
|
||||
|
||||
// Add a node that will appear in the view, so that the block will actually
|
||||
// be displayed.
|
||||
$this->drupalCreateContentType(array('type' => 'page'));
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$this->drupalCreateNode();
|
||||
|
||||
// Make sure the title appears in the page.
|
||||
|
@ -63,11 +63,11 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Change the title for the page display only, and make sure that the
|
||||
// original title still appears on the page.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title'] = $new_title = $this->randomMachineName(16);
|
||||
$edit['override[dropdown]'] = 'page_1';
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", array(), t('Save'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save'));
|
||||
$this->drupalGet($view_path);
|
||||
$this->assertResponse(200);
|
||||
$this->assertText($new_title);
|
||||
|
@ -77,7 +77,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
/**
|
||||
* Tests that the wizard correctly sets up default and overridden displays.
|
||||
*/
|
||||
function testWizardMixedDefaultOverriddenDisplays() {
|
||||
public function testWizardMixedDefaultOverriddenDisplays() {
|
||||
// Create a basic view with a page, block, and feed. Give the page and feed
|
||||
// identical titles, but give the block a different one, so we expect the
|
||||
// page and feed to inherit their titles from the default display, but the
|
||||
|
@ -95,7 +95,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Add a node that will appear in the view, so that the block will actually
|
||||
// be displayed.
|
||||
$this->drupalCreateContentType(array('type' => 'page'));
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$this->drupalCreateNode();
|
||||
|
||||
// Make sure that the feed, page and block all start off with the correct
|
||||
|
@ -117,14 +117,14 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
// Put the block into the first sidebar region, and make sure it will not
|
||||
// display on the view's page display (since we will be searching for the
|
||||
// presence/absence of the view's title in both the page and the block).
|
||||
$this->drupalPlaceBlock("views_block:{$view['id']}-block_1", array(
|
||||
'visibility' => array(
|
||||
'request_path' => array(
|
||||
$this->drupalPlaceBlock("views_block:{$view['id']}-block_1", [
|
||||
'visibility' => [
|
||||
'request_path' => [
|
||||
'pages' => '/' . $view['page[path]'],
|
||||
'negate' => TRUE,
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->drupalGet('');
|
||||
$this->assertText($view['block[title]']);
|
||||
|
@ -132,10 +132,10 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Edit the page and change the title. This should automatically change
|
||||
// the feed's title also, but not the block.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title'] = $new_default_title = $this->randomMachineName(16);
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/page_1/title", $edit, t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", array(), t('Save'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/page_1", [], t('Save'));
|
||||
$this->drupalGet($view['page[path]']);
|
||||
$this->assertResponse(200);
|
||||
$this->assertText($new_default_title);
|
||||
|
@ -153,10 +153,10 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Edit the block and change the title. This should automatically change
|
||||
// the block title only, and leave the defaults alone.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title'] = $new_block_title = $this->randomMachineName(16);
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/block_1/title", $edit, t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", array(), t('Save'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", [], t('Save'));
|
||||
$this->drupalGet($view['page[path]']);
|
||||
$this->assertResponse(200);
|
||||
$this->assertText($new_default_title);
|
||||
|
@ -172,7 +172,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
/**
|
||||
* Tests that the revert to all displays select-option works as expected.
|
||||
*/
|
||||
function testRevertAllDisplays() {
|
||||
public function testRevertAllDisplays() {
|
||||
// Create a basic view with a page, block.
|
||||
// Because there is both a title on page and block we expect the title on
|
||||
// the block be overridden.
|
||||
|
@ -187,12 +187,12 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Revert the title of the block to the default ones, but submit some new
|
||||
// values to be sure that the new value is not stored.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$edit['title'] = $new_block_title = $this->randomMachineName();
|
||||
$edit['override[dropdown]'] = 'default_revert';
|
||||
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/{$view['id']}/block_1/title", $edit, t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", array(), t('Save'));
|
||||
$this->drupalPostForm("admin/structure/views/view/{$view['id']}/edit/block_1", [], t('Save'));
|
||||
$this->assertText($view['page[title]']);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,23 +17,23 @@ class PreviewTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager', 'test_click_sort');
|
||||
public static $testViews = ['test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager', 'test_click_sort'];
|
||||
|
||||
/**
|
||||
* Tests contextual links in the preview form.
|
||||
*/
|
||||
public function testPreviewContextual() {
|
||||
\Drupal::service('module_installer')->install(array('contextual'));
|
||||
\Drupal::service('module_installer')->install(['contextual']);
|
||||
$this->resetAll();
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_preview/edit');
|
||||
$this->assertResponse(200);
|
||||
$this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = [], t('Update preview'));
|
||||
|
||||
$elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', array(':ul-class' => 'contextual-links', ':li-class' => 'filter-add'));
|
||||
$elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', [':ul-class' => 'contextual-links', ':li-class' => 'filter-add']);
|
||||
$this->assertEqual(count($elements), 1, 'The contextual link to add a new field is shown.');
|
||||
|
||||
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
|
||||
|
||||
// Test that area text and exposed filters are present and rendered.
|
||||
$this->assertFieldByName('id', NULL, 'ID exposed filter field found.');
|
||||
|
@ -45,23 +45,23 @@ class PreviewTest extends UITestBase {
|
|||
/**
|
||||
* Tests arguments in the preview form.
|
||||
*/
|
||||
function testPreviewUI() {
|
||||
public function testPreviewUI() {
|
||||
$this->drupalGet('admin/structure/views/view/test_preview/edit');
|
||||
$this->assertResponse(200);
|
||||
|
||||
$this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = [], t('Update preview'));
|
||||
|
||||
$elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
|
||||
$this->assertEqual(count($elements), 5);
|
||||
|
||||
// Filter just the first result.
|
||||
$this->drupalPostForm(NULL, $edit = array('view_args' => '1'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = ['view_args' => '1'], t('Update preview'));
|
||||
|
||||
$elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
|
||||
$this->assertEqual(count($elements), 1);
|
||||
|
||||
// Filter for no results.
|
||||
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
|
||||
|
||||
$elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]');
|
||||
$this->assertEqual(count($elements), 0);
|
||||
|
@ -73,7 +73,7 @@ class PreviewTest extends UITestBase {
|
|||
$this->assertText('Test empty text', 'Rendered empty text found.');
|
||||
|
||||
// Test feed preview.
|
||||
$view = array();
|
||||
$view = [];
|
||||
$view['label'] = $this->randomMachineName(16);
|
||||
$view['id'] = strtolower($this->randomMachineName(16));
|
||||
$view['page[create]'] = 1;
|
||||
|
@ -83,7 +83,7 @@ class PreviewTest extends UITestBase {
|
|||
$view['page[feed_properties][path]'] = $this->randomMachineName(16);
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
$this->clickLink(t('Feed'));
|
||||
$this->drupalPostForm(NULL, array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$result = $this->xpath('//div[@id="views-live-preview"]/pre');
|
||||
$this->assertTrue(strpos($result[0], '<title>' . $view['page[title]'] . '</title>'), 'The Feed RSS preview was rendered.');
|
||||
|
||||
|
@ -92,7 +92,7 @@ class PreviewTest extends UITestBase {
|
|||
$settings = \Drupal::configFactory()->getEditable('views.settings');
|
||||
$settings->set('ui.show.performance_statistics', TRUE)->save();
|
||||
$this->drupalGet('admin/structure/views/view/test_preview/edit');
|
||||
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
|
||||
$this->assertText(t('Query build time'));
|
||||
$this->assertText(t('Query execute time'));
|
||||
$this->assertText(t('View render time'));
|
||||
|
@ -100,19 +100,19 @@ class PreviewTest extends UITestBase {
|
|||
|
||||
// Statistics and query.
|
||||
$settings->set('ui.show.sql_query.enabled', TRUE)->save();
|
||||
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
|
||||
$this->assertText(t('Query build time'));
|
||||
$this->assertText(t('Query execute time'));
|
||||
$this->assertText(t('View render time'));
|
||||
$this->assertRaw('<strong>Query</strong>');
|
||||
$this->assertText("SELECT views_test_data.name AS views_test_data_name\nFROM \n{views_test_data} views_test_data\nWHERE (( (views_test_data.id = '100' ) ))");
|
||||
$this->assertText("SELECT views_test_data.name AS views_test_data_name\nFROM \n{views_test_data} views_test_data\nWHERE (views_test_data.id = '100' )");
|
||||
|
||||
// Test that the statistics and query are rendered above the preview.
|
||||
$this->assertTrue(strpos($this->getRawContent(), 'views-query-info') < strpos($this->getRawContent(), 'view-test-preview'), 'Statistics shown above the preview.');
|
||||
|
||||
// Test that statistics and query rendered below the preview.
|
||||
$settings->set('ui.show.sql_query.where', 'below')->save();
|
||||
$this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
|
||||
$this->assertTrue(strpos($this->getRawContent(), 'view-test-preview') < strpos($this->getRawContent(), 'views-query-info'), 'Statistics shown below the preview.');
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ class PreviewTest extends UITestBase {
|
|||
* @see https://www.drupal.org/node/2452659
|
||||
*/
|
||||
public function testTaxonomyAJAX() {
|
||||
\Drupal::service('module_installer')->install(array('taxonomy'));
|
||||
\Drupal::service('module_installer')->install(['taxonomy']);
|
||||
$this->getPreviewAJAX('taxonomy_term', 'page_1', 0);
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ class PreviewTest extends UITestBase {
|
|||
public function testPreviewWithPagersUI() {
|
||||
|
||||
// Create 11 nodes and make sure that everyone is returned.
|
||||
$this->drupalCreateContentType(array('type' => 'page'));
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$this->drupalCreateNode();
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class PreviewTest extends UITestBase {
|
|||
$this->getPreviewAJAX('test_pager_full', 'default', 5);
|
||||
|
||||
// Test that the pager is present and rendered.
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
|
||||
$this->assertTrue(!empty($elements), 'Full pager found.');
|
||||
|
||||
// Verify elements and links to pages.
|
||||
|
@ -165,11 +165,11 @@ class PreviewTest extends UITestBase {
|
|||
$this->assertTrue($elements[4]->a, 'Link to last page found.');
|
||||
|
||||
// Navigate to next page.
|
||||
$elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--next'));
|
||||
$elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--next']);
|
||||
$this->clickPreviewLinkAJAX($elements[0]['href'], 5);
|
||||
|
||||
// Test that the pager is present and rendered.
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
|
||||
$this->assertTrue(!empty($elements), 'Full pager found.');
|
||||
|
||||
// Verify elements and links to pages.
|
||||
|
@ -201,7 +201,7 @@ class PreviewTest extends UITestBase {
|
|||
$this->getPreviewAJAX('test_mini_pager', 'default', 3);
|
||||
|
||||
// Test that the pager is present and rendered.
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
|
||||
$this->assertTrue(!empty($elements), 'Mini pager found.');
|
||||
|
||||
// Verify elements and links to pages.
|
||||
|
@ -213,11 +213,11 @@ class PreviewTest extends UITestBase {
|
|||
$this->assertTrue($elements[1]->a, 'Link to next page found.');
|
||||
|
||||
// Navigate to next page.
|
||||
$elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--next'));
|
||||
$elements = $this->xpath('//li[contains(@class, :class)]/a', [':class' => 'pager__item--next']);
|
||||
$this->clickPreviewLinkAJAX($elements[0]['href'], 3);
|
||||
|
||||
// Test that the pager is present and rendered.
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', array(':class' => 'pager__items'));
|
||||
$elements = $this->xpath('//ul[contains(@class, :class)]/li', [':class' => 'pager__items']);
|
||||
$this->assertTrue(!empty($elements), 'Mini pager found.');
|
||||
|
||||
// Verify elements and links to pages.
|
||||
|
@ -237,17 +237,17 @@ class PreviewTest extends UITestBase {
|
|||
* Tests the additional information query info area.
|
||||
*/
|
||||
public function testPreviewAdditionalInfo() {
|
||||
\Drupal::service('module_installer')->install(array('views_ui_test'));
|
||||
\Drupal::service('module_installer')->install(['views_ui_test']);
|
||||
$this->resetAll();
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_preview/edit');
|
||||
$this->assertResponse(200);
|
||||
|
||||
$this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = [], t('Update preview'));
|
||||
|
||||
// Check for implementation of hook_views_preview_info_alter().
|
||||
// @see views_ui_test.module
|
||||
$elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', array(':text' => t('Test row count')));
|
||||
$elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', [':text' => t('Test row count')]);
|
||||
$this->assertEqual(count($elements), 1, 'Views Query Preview Info area altered.');
|
||||
// Check that additional assets are attached.
|
||||
$this->assertTrue(strpos($this->getDrupalSettings()['ajaxPageState']['libraries'], 'views_ui_test/views_ui_test.test') !== FALSE, 'Attached library found.');
|
||||
|
@ -261,7 +261,7 @@ class PreviewTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views/view/test_preview_error/edit');
|
||||
$this->assertResponse(200);
|
||||
|
||||
$this->drupalPostForm(NULL, $edit = array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, $edit = [], t('Update preview'));
|
||||
|
||||
$this->assertText('Unable to preview due to validation errors.', 'Preview error text found.');
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class PreviewTest extends UITestBase {
|
|||
$this->getPreviewAJAX('test_click_sort', 'page_1', 0);
|
||||
|
||||
// Test that the header label is present.
|
||||
$elements = $this->xpath('//th[contains(@class, :class)]/a', array(':class' => 'views-field views-field-name'));
|
||||
$elements = $this->xpath('//th[contains(@class, :class)]/a', [':class' => 'views-field views-field-name']);
|
||||
$this->assertTrue(!empty($elements), 'The header label is present.');
|
||||
|
||||
// Verify link.
|
||||
|
@ -285,7 +285,7 @@ class PreviewTest extends UITestBase {
|
|||
$this->clickPreviewLinkAJAX($elements[0]['href'], 0);
|
||||
|
||||
// Test that the header label is present.
|
||||
$elements = $this->xpath('//th[contains(@class, :class)]/a', array(':class' => 'views-field views-field-name is-active'));
|
||||
$elements = $this->xpath('//th[contains(@class, :class)]/a', [':class' => 'views-field views-field-name is-active']);
|
||||
$this->assertTrue(!empty($elements), 'The header label is present.');
|
||||
|
||||
// Verify link.
|
||||
|
@ -304,7 +304,7 @@ class PreviewTest extends UITestBase {
|
|||
*/
|
||||
protected function getPreviewAJAX($view_name, $panel_id, $row_count) {
|
||||
$this->drupalGet('admin/structure/views/view/' . $view_name . '/preview/' . $panel_id);
|
||||
$result = $this->drupalPostAjaxForm(NULL, array(), array('op' => t('Update preview')));
|
||||
$result = $this->drupalPostAjaxForm(NULL, [], ['op' => t('Update preview')]);
|
||||
$this->assertPreviewAJAX($result, $row_count);
|
||||
}
|
||||
|
||||
|
@ -319,12 +319,12 @@ class PreviewTest extends UITestBase {
|
|||
protected function clickPreviewLinkAJAX($url, $row_count) {
|
||||
$content = $this->content;
|
||||
$drupal_settings = $this->drupalSettings;
|
||||
$ajax_settings = array(
|
||||
$ajax_settings = [
|
||||
'wrapper' => 'views-preview-wrapper',
|
||||
'method' => 'replaceWith',
|
||||
);
|
||||
];
|
||||
$url = $this->getAbsoluteUrl($url);
|
||||
$post = array('js' => 'true') + $this->getAjaxPageStatePostData();
|
||||
$post = ['js' => 'true'] + $this->getAjaxPageStatePostData();
|
||||
$result = Json::decode($this->drupalPost($url, '', $post, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]));
|
||||
if (!empty($result)) {
|
||||
$this->drupalProcessAjaxResponse($content, $result, $ajax_settings, $drupal_settings);
|
||||
|
@ -343,7 +343,7 @@ class PreviewTest extends UITestBase {
|
|||
protected function assertPreviewAJAX($result, $row_count) {
|
||||
// Has AJAX callback replied with an insert command? If so, we can
|
||||
// assume that the page content was updated with AJAX returned data.
|
||||
$result_commands = array();
|
||||
$result_commands = [];
|
||||
foreach ($result as $command) {
|
||||
$result_commands[$command['command']] = $command;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class QueryTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -41,8 +41,8 @@ class QueryTest extends UITestBase {
|
|||
// Save some query settings.
|
||||
$query_settings_path = "admin/structure/views/nojs/display/test_view/default/query";
|
||||
$random_value = $this->randomMachineName();
|
||||
$this->drupalPostForm($query_settings_path, array('query[options][test_setting]' => $random_value), t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm($query_settings_path, ['query[options][test_setting]' => $random_value], t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
// Check that the settings are saved into the view itself.
|
||||
$view = Views::getView('test_view');
|
||||
|
|
|
@ -17,7 +17,7 @@ class RearrangeFieldsTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Gets the fields from the View.
|
||||
|
@ -25,7 +25,7 @@ class RearrangeFieldsTest extends UITestBase {
|
|||
protected function getViewFields($view_name = 'test_view', $display_id = 'default') {
|
||||
$view = Views::getView($view_name);
|
||||
$view->setDisplay($display_id);
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
foreach ($view->displayHandlers->get('default')->getHandlers('field') as $field => $handler) {
|
||||
$fields[] = $field;
|
||||
}
|
||||
|
@ -58,13 +58,13 @@ class RearrangeFieldsTest extends UITestBase {
|
|||
$this->assertFieldOrder($view_name, $this->getViewFields($view_name));
|
||||
|
||||
// Checks that a field is not deleted if a value is not passed back.
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/rearrange/' . $view_name . '/default/field', $fields, t('Apply'));
|
||||
$this->assertFieldOrder($view_name, $this->getViewFields($view_name));
|
||||
|
||||
// Checks that revers the new field order is respected.
|
||||
$reversedFields = array_reverse($this->getViewFields($view_name));
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
foreach ($reversedFields as $delta => $field) {
|
||||
$fields['fields[' . $field . '][weight]'] = $delta;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class RedirectTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_redirect_view');
|
||||
public static $testViews = ['test_view', 'test_redirect_view'];
|
||||
|
||||
/**
|
||||
* Tests the redirecting.
|
||||
|
@ -25,8 +25,8 @@ class RedirectTest extends UITestBase {
|
|||
$random_destination = $this->randomMachineName();
|
||||
$edit_path = "admin/structure/views/view/$view_name/edit";
|
||||
|
||||
$this->drupalPostForm($edit_path, array(), t('Save'), array('query' => array('destination' => $random_destination)));
|
||||
$this->assertUrl($random_destination, array(), 'Make sure the user got redirected to the expected page defined in the destination.');
|
||||
$this->drupalPostForm($edit_path, [], t('Save'), ['query' => ['destination' => $random_destination]]);
|
||||
$this->assertUrl($random_destination, [], 'Make sure the user got redirected to the expected page defined in the destination.');
|
||||
|
||||
// Setup a view with a certain page display path. If you change the path
|
||||
// but have the old url in the destination the user should be redirected to
|
||||
|
@ -37,9 +37,9 @@ class RedirectTest extends UITestBase {
|
|||
$edit_path = "admin/structure/views/view/$view_name/edit";
|
||||
$path_edit_path = "admin/structure/views/nojs/display/$view_name/page_1/path";
|
||||
|
||||
$this->drupalPostForm($path_edit_path, array('path' => $new_path), t('Apply'));
|
||||
$this->drupalPostForm($edit_path, array(), t('Save'), array('query' => array('destination' => 'test-redirect-view')));
|
||||
$this->assertUrl($new_path, array(), 'Make sure the user got redirected to the expected page after changing the URL of a page display.');
|
||||
$this->drupalPostForm($path_edit_path, ['path' => $new_path], t('Apply'));
|
||||
$this->drupalPostForm($edit_path, [], t('Save'), ['query' => ['destination' => 'test-redirect-view']]);
|
||||
$this->assertUrl($new_path, [], 'Make sure the user got redirected to the expected page after changing the URL of a page display.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class ReportTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views', 'views_ui');
|
||||
public static $modules = ['views', 'views_ui'];
|
||||
|
||||
/**
|
||||
* Stores an admin user used by the different tests.
|
||||
|
@ -26,7 +26,7 @@ class ReportTest extends WebTestBase {
|
|||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer views'));
|
||||
$this->adminUser = $this->drupalCreateUser(['administer views']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ class RowUITest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests changing the row plugin and changing some options of a row.
|
||||
|
@ -33,20 +33,20 @@ class RowUITest extends UITestBase {
|
|||
$this->drupalGet($row_plugin_url);
|
||||
$this->assertFieldByName('row[type]', 'fields', 'The default row plugin selected in the UI should be fields.');
|
||||
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'row[type]' => 'test_row'
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertFieldByName('row_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
|
||||
$random_name = $this->randomMachineName();
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'row_options[test_option]' => $random_name
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalGet($row_options_url);
|
||||
$this->assertFieldByName('row_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.');
|
||||
|
||||
$this->drupalPostForm($view_edit_url, array(), t('Save'));
|
||||
$this->drupalPostForm($view_edit_url, [], t('Save'));
|
||||
$this->assertLink(t('Test row plugin'), 0, 'Make sure the test row plugin is shown in the UI');
|
||||
|
||||
$view = Views::getView($view_name);
|
||||
|
|
|
@ -27,7 +27,7 @@ class SettingsTest extends UITestBase {
|
|||
/**
|
||||
* Tests the settings for the edit ui.
|
||||
*/
|
||||
function testEditUI() {
|
||||
public function testEditUI() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Test the settings tab exists.
|
||||
|
@ -35,16 +35,16 @@ class SettingsTest extends UITestBase {
|
|||
$this->assertLinkByHref('admin/structure/views/settings');
|
||||
|
||||
// Test the confirmation message.
|
||||
$this->drupalPostForm('admin/structure/views/settings', array(), t('Save configuration'));
|
||||
$this->drupalPostForm('admin/structure/views/settings', [], t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
|
||||
// Configure to always show the master display.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'ui_show_master_display' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
|
||||
|
||||
$view = array();
|
||||
$view = [];
|
||||
$view['label'] = $this->randomMachineName(16);
|
||||
$view['id'] = strtolower($this->randomMachineName(16));
|
||||
$view['description'] = $this->randomMachineName(16);
|
||||
|
@ -56,9 +56,9 @@ class SettingsTest extends UITestBase {
|
|||
// Configure to not always show the master display.
|
||||
// If you have a view without a page or block the master display should be
|
||||
// still shown.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'ui_show_master_display' => FALSE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
|
||||
|
||||
$view['page[create]'] = FALSE;
|
||||
|
@ -75,45 +75,45 @@ class SettingsTest extends UITestBase {
|
|||
// @todo It doesn't seem to be a way to test this as this works just on js.
|
||||
|
||||
// Configure to show the embeddable display.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'ui_show_display_embed' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
|
||||
|
||||
$view['id'] = strtolower($this->randomMachineName());
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
$this->assertFieldById('edit-displays-top-add-display-embed');
|
||||
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'ui_show_display_embed' => FALSE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
$this->assertNoFieldById('edit-displays-top-add-display-embed');
|
||||
|
||||
// Configure to hide/show the sql at the preview.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'ui_show_sql_query_enabled' => FALSE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
|
||||
|
||||
$view['id'] = strtolower($this->randomMachineName());
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$xpath = $this->xpath('//div[@class="views-query-info"]/pre');
|
||||
$this->assertEqual(count($xpath), 0, 'The views sql is hidden.');
|
||||
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'ui_show_sql_query_enabled' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration'));
|
||||
|
||||
$view['id'] = strtolower($this->randomMachineName());
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Update preview'));
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$xpath = $this->xpath('//div[@class="views-query-info"]//pre');
|
||||
$this->assertEqual(count($xpath), 1, 'The views sql is shown.');
|
||||
$this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
|
||||
|
@ -122,20 +122,20 @@ class SettingsTest extends UITestBase {
|
|||
// Test the advanced settings form.
|
||||
|
||||
// Test the confirmation message.
|
||||
$this->drupalPostForm('admin/structure/views/settings/advanced', array(), t('Save configuration'));
|
||||
$this->drupalPostForm('admin/structure/views/settings/advanced', [], t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'skip_cache' => TRUE,
|
||||
'sql_signature' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/views/settings/advanced', $edit, t('Save configuration'));
|
||||
|
||||
$this->assertFieldChecked('edit-skip-cache', 'The skip_cache option is checked.');
|
||||
$this->assertFieldChecked('edit-sql-signature', 'The sql_signature option is checked.');
|
||||
|
||||
// Test the "Clear Views' cache" button.
|
||||
$this->drupalPostForm('admin/structure/views/settings/advanced', array(), t("Clear Views' cache"));
|
||||
$this->drupalPostForm('admin/structure/views/settings/advanced', [], t("Clear Views' cache"));
|
||||
$this->assertText(t('The cache has been cleared.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,14 +17,14 @@ class StorageTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views_ui', 'language');
|
||||
public static $modules = ['views_ui', 'language'];
|
||||
|
||||
/**
|
||||
* Tests changing label, description and tag.
|
||||
|
@ -36,20 +36,20 @@ class StorageTest extends UITestBase {
|
|||
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'label' => $this->randomMachineName(),
|
||||
'tag' => $this->randomMachineName(),
|
||||
'description' => $this->randomMachineName(30),
|
||||
'langcode' => 'fr',
|
||||
);
|
||||
];
|
||||
|
||||
$this->drupalPostForm("admin/structure/views/nojs/edit-details/$view_name/default", $edit, t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$view = Views::getView($view_name);
|
||||
|
||||
foreach (array('label', 'tag', 'description', 'langcode') as $property) {
|
||||
$this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property)));
|
||||
foreach (['label', 'tag', 'description', 'langcode'] as $property) {
|
||||
$this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', ['@property' => $property]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class StyleTableTest extends UITestBase {
|
|||
*/
|
||||
public function testWizard() {
|
||||
// Create a new view and check that the first field has a label.
|
||||
$view = array();
|
||||
$view = [];
|
||||
$view['label'] = $this->randomMachineName(16);
|
||||
$view['id'] = strtolower($this->randomMachineName(16));
|
||||
$view['show[wizard_key]'] = 'node';
|
||||
|
|
|
@ -17,7 +17,7 @@ class StyleUITest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests changing the style plugin and changing some options of a style.
|
||||
|
@ -32,20 +32,20 @@ class StyleUITest extends UITestBase {
|
|||
$this->drupalGet($style_plugin_url);
|
||||
$this->assertFieldByName('style[type]', 'default', 'The default style plugin selected in the UI should be unformatted list.');
|
||||
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'style[type]' => 'test_style'
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertFieldByName('style_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
|
||||
$random_name = $this->randomMachineName();
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'style_options[test_option]' => $random_name
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalGet($style_options_url);
|
||||
$this->assertFieldByName('style_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.');
|
||||
|
||||
$this->drupalPostForm($view_edit_url, array(), t('Save'));
|
||||
$this->drupalPostForm($view_edit_url, [], t('Save'));
|
||||
$this->assertLink(t('Test style plugin'), 0, 'Make sure the test style plugin is shown in the UI');
|
||||
|
||||
$view = Views::getView($view_name);
|
||||
|
@ -56,8 +56,8 @@ class StyleUITest extends UITestBase {
|
|||
|
||||
// Test that fields are working correctly in the UI for style plugins when
|
||||
// a field row plugin is selected.
|
||||
$this->drupalPostForm("admin/structure/views/view/$view_name/edit", array(), 'Add Page');
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/$view_name/page_1/row", array('row[type]' => 'fields'), t('Apply'));
|
||||
$this->drupalPostForm("admin/structure/views/view/$view_name/edit", [], 'Add Page');
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/$view_name/page_1/row", ['row[type]' => 'fields'], t('Apply'));
|
||||
// If fields are being used this text will not be shown.
|
||||
$this->assertNoText(t('The selected style or row format does not use fields.'));
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ abstract class UITestBase extends ViewTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'views_ui', 'block', 'taxonomy');
|
||||
public static $modules = ['node', 'views_ui', 'block', 'taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -38,24 +38,24 @@ abstract class UITestBase extends ViewTestBase {
|
|||
|
||||
$this->enableViewsTestModule();
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer views'));
|
||||
$this->adminUser = $this->drupalCreateUser(['administer views']);
|
||||
|
||||
$this->fullAdminUser = $this->drupalCreateUser(array('administer views',
|
||||
$this->fullAdminUser = $this->drupalCreateUser(['administer views',
|
||||
'administer blocks',
|
||||
'bypass node access',
|
||||
'access user profiles',
|
||||
'view all revisions',
|
||||
'administer permissions',
|
||||
));
|
||||
]);
|
||||
$this->drupalLogin($this->fullAdminUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper method which creates a random view.
|
||||
*/
|
||||
public function randomView(array $view = array()) {
|
||||
public function randomView(array $view = []) {
|
||||
// Create a new view in the UI.
|
||||
$default = array();
|
||||
$default = [];
|
||||
$default['label'] = $this->randomMachineName(16);
|
||||
$default['id'] = strtolower($this->randomMachineName(16));
|
||||
$default['description'] = $this->randomMachineName(16);
|
||||
|
@ -72,7 +72,7 @@ abstract class UITestBase extends ViewTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function drupalGet($path, array $options = array(), array $headers = array()) {
|
||||
protected function drupalGet($path, array $options = [], array $headers = []) {
|
||||
$url = $this->buildUrl($path, $options);
|
||||
|
||||
// Ensure that each nojs page is accessible via ajax as well.
|
||||
|
|
|
@ -28,7 +28,7 @@ class UnsavedPreviewTest extends ViewTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('node', 'views_ui');
|
||||
public static $modules = ['node', 'views_ui'];
|
||||
|
||||
/**
|
||||
* Sets up a Drupal site for running functional and integration tests.
|
||||
|
|
|
@ -17,7 +17,7 @@ class ViewEditTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_display', 'test_groupwise_term_ui');
|
||||
public static $testViews = ['test_view', 'test_display', 'test_groupwise_term_ui'];
|
||||
|
||||
/**
|
||||
* Tests the delete link on a views UI.
|
||||
|
@ -30,8 +30,8 @@ class ViewEditTest extends UITestBase {
|
|||
$this->assertTrue($view instanceof View);
|
||||
$this->clickLink(t('Delete view'));
|
||||
$this->assertUrl('admin/structure/views/view/test_view/delete');
|
||||
$this->drupalPostForm(NULL, array(), t('Delete'));
|
||||
$this->assertRaw(t('The view %name has been deleted.', array('%name' => $view->label())));
|
||||
$this->drupalPostForm(NULL, [], t('Delete'));
|
||||
$this->assertRaw(t('The view %name has been deleted.', ['%name' => $view->label()]));
|
||||
|
||||
$this->assertUrl('admin/structure/views');
|
||||
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view');
|
||||
|
@ -44,20 +44,20 @@ class ViewEditTest extends UITestBase {
|
|||
public function testOtherOptions() {
|
||||
$this->drupalGet('admin/structure/views/view/test_view');
|
||||
// Add a new attachment display.
|
||||
$this->drupalPostForm(NULL, array(), 'Add Attachment');
|
||||
$this->drupalPostForm(NULL, [], 'Add Attachment');
|
||||
|
||||
// Test that a long administrative comment is truncated.
|
||||
$edit = array('display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen');
|
||||
$edit = ['display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen'];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_comment', $edit, 'Apply');
|
||||
$this->assertText('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...');
|
||||
|
||||
// Change the machine name for the display from page_1 to test_1.
|
||||
$edit = array('display_id' => 'test_1');
|
||||
$edit = ['display_id' => 'test_1'];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_id', $edit, 'Apply');
|
||||
$this->assertLink(t('test_1'));
|
||||
|
||||
// Save the view, and test the new ID has been saved.
|
||||
$this->drupalPostForm(NULL, array(), 'Save');
|
||||
$this->drupalPostForm(NULL, [], 'Save');
|
||||
$view = \Drupal::entityManager()->getStorage('view')->load('test_view');
|
||||
$displays = $view->get('display');
|
||||
$this->assertTrue(!empty($displays['test_1']), 'Display data found for new display ID key.');
|
||||
|
@ -72,16 +72,16 @@ class ViewEditTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views/ajax/handler/test_view/fake_display_name/filter/title');
|
||||
$this->assertText('Invalid display id fake_display_name');
|
||||
|
||||
$edit = array('display_id' => 'test 1');
|
||||
$edit = ['display_id' => 'test 1'];
|
||||
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
|
||||
$this->assertText($error_text);
|
||||
|
||||
$edit = array('display_id' => 'test_1#');
|
||||
$edit = ['display_id' => 'test_1#'];
|
||||
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
|
||||
$this->assertText($error_text);
|
||||
|
||||
// Test using an existing display ID.
|
||||
$edit = array('display_id' => 'default');
|
||||
$edit = ['display_id' => 'default'];
|
||||
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
|
||||
$this->assertText(t('Display id should be unique.'));
|
||||
|
||||
|
@ -97,10 +97,10 @@ class ViewEditTest extends UITestBase {
|
|||
$fields['fields[id][removed]'] = 1;
|
||||
$fields['fields[name][removed]'] = 1;
|
||||
$this->drupalPostForm('admin/structure/views/nojs/rearrange/test_view/default/field', $fields, t('Apply'));
|
||||
$this->drupalPostForm(NULL, array(), 'Save');
|
||||
$this->drupalPostForm(NULL, array(), t('Cancel'));
|
||||
$this->drupalPostForm(NULL, [], 'Save');
|
||||
$this->drupalPostForm(NULL, [], t('Cancel'));
|
||||
$this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, 'No error message is displayed.');
|
||||
$this->assertUrl('admin/structure/views', array(), 'Redirected back to the view listing page..');
|
||||
$this->assertUrl('admin/structure/views', [], 'Redirected back to the view listing page..');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,21 +108,21 @@ class ViewEditTest extends UITestBase {
|
|||
*/
|
||||
public function testEditFormLanguageOptions() {
|
||||
// Language options should not exist without language module.
|
||||
$test_views = array(
|
||||
$test_views = [
|
||||
'test_view' => 'default',
|
||||
'test_display' => 'page_1',
|
||||
);
|
||||
];
|
||||
foreach ($test_views as $view_name => $display) {
|
||||
$this->drupalGet('admin/structure/views/view/' . $view_name);
|
||||
$this->assertResponse(200);
|
||||
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
|
||||
$this->assertNoLinkByHref($langcode_url);
|
||||
$this->assertNoLink(t('@type language selected for page', array('@type' => t('Content'))));
|
||||
$this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$this->assertNoLink(t('Content language of view row'));
|
||||
}
|
||||
|
||||
// Make the site multilingual and test the options again.
|
||||
$this->container->get('module_installer')->install(array('language', 'content_translation'));
|
||||
$this->container->get('module_installer')->install(['language', 'content_translation']);
|
||||
ConfigurableLanguage::createFromLangcode('hu')->save();
|
||||
$this->resetAll();
|
||||
$this->rebuildContainer();
|
||||
|
@ -134,12 +134,12 @@ class ViewEditTest extends UITestBase {
|
|||
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
|
||||
if ($view_name == 'test_view') {
|
||||
$this->assertNoLinkByHref($langcode_url);
|
||||
$this->assertNoLink(t('@type language selected for page', array('@type' => t('Content'))));
|
||||
$this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$this->assertNoLink(t('Content language of view row'));
|
||||
}
|
||||
else {
|
||||
$this->assertLinkByHref($langcode_url);
|
||||
$this->assertNoLink(t('@type language selected for page', array('@type' => t('Content'))));
|
||||
$this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$this->assertLink(t('Content language of view row'));
|
||||
}
|
||||
|
||||
|
@ -152,14 +152,14 @@ class ViewEditTest extends UITestBase {
|
|||
$this->assertFieldByName('rendering_language', '***LANGUAGE_entity_translation***');
|
||||
// Test that the order of the language list is similar to other language
|
||||
// lists, such as in the content translation settings.
|
||||
$expected_elements = array(
|
||||
$expected_elements = [
|
||||
'***LANGUAGE_entity_translation***',
|
||||
'***LANGUAGE_entity_default***',
|
||||
'***LANGUAGE_site_default***',
|
||||
'***LANGUAGE_language_interface***',
|
||||
'en',
|
||||
'hu',
|
||||
);
|
||||
];
|
||||
$elements = $this->xpath('//select[@id="edit-rendering-language"]/option');
|
||||
// Compare values inside the option elements with expected values.
|
||||
for ($i = 0; $i < count($elements); $i++) {
|
||||
|
@ -202,7 +202,7 @@ class ViewEditTest extends UITestBase {
|
|||
$this->drupalGet($langcode_url);
|
||||
$this->assertResponse(200);
|
||||
|
||||
$expected_elements = array(
|
||||
$expected_elements = [
|
||||
'all',
|
||||
'***LANGUAGE_site_default***',
|
||||
'***LANGUAGE_language_interface***',
|
||||
|
@ -211,7 +211,7 @@ class ViewEditTest extends UITestBase {
|
|||
'hu',
|
||||
'und',
|
||||
'zxx',
|
||||
);
|
||||
];
|
||||
$elements = $this->xpath('//div[@id="edit-options-value"]//input');
|
||||
// Compare values inside the option elements with expected values.
|
||||
for ($i = 0; $i < count($elements); $i++) {
|
||||
|
@ -229,7 +229,7 @@ class ViewEditTest extends UITestBase {
|
|||
$edit["name[taxonomy_term_field_data.tid_representative]"] = TRUE;
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_groupwise_term_ui/default/relationship', $edit, 'Add and configure relationships');
|
||||
// Apply changes.
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
$this->drupalPostForm('admin/structure/views/nojs/handler/test_groupwise_term_ui/default/relationship/tid_representative', $edit, 'Apply');
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class ViewsListTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('block', 'views_ui');
|
||||
public static $modules = ['block', 'views_ui'];
|
||||
|
||||
/**
|
||||
* A user with permission to administer views.
|
||||
|
|
|
@ -31,11 +31,11 @@ class ViewsUITourTest extends TourTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views_ui', 'tour', 'language', 'locale');
|
||||
public static $modules = ['views_ui', 'tour', 'language', 'locale'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer views', 'access tour'));
|
||||
$this->adminUser = $this->drupalCreateUser(['administer views', 'access tour']);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
}
|
||||
|
||||
|
@ -66,18 +66,18 @@ class ViewsUITourTest extends TourTestBase {
|
|||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
|
||||
// Handler titles that need translations.
|
||||
$handler_titles = array(
|
||||
$handler_titles = [
|
||||
'Format',
|
||||
'Fields',
|
||||
'Sort criteria',
|
||||
'Filter criteria',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($handler_titles as $handler_title) {
|
||||
// Create source string.
|
||||
$source = $this->localeStorage->createString(array(
|
||||
$source = $this->localeStorage->createString([
|
||||
'source' => $handler_title
|
||||
));
|
||||
]);
|
||||
$source->save();
|
||||
$this->createTranslation($source, $langcode);
|
||||
}
|
||||
|
@ -101,11 +101,11 @@ class ViewsUITourTest extends TourTestBase {
|
|||
* Creates single translation for source string.
|
||||
*/
|
||||
public function createTranslation($source, $langcode) {
|
||||
return $this->localeStorage->createTranslation(array(
|
||||
return $this->localeStorage->createTranslation([
|
||||
'lid' => $source->lid,
|
||||
'language' => $langcode,
|
||||
'translation' => $this->randomMachineName(100),
|
||||
))->save();
|
||||
])->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class WizardTest extends WizardTestBase {
|
|||
* Tests filling in the wizard with really long strings.
|
||||
*/
|
||||
public function testWizardFieldLength() {
|
||||
$view = array();
|
||||
$view = [];
|
||||
$view['label'] = $this->randomMachineName(256);
|
||||
$view['id'] = strtolower($this->randomMachineName(129));
|
||||
$view['page[create]'] = TRUE;
|
||||
|
@ -54,7 +54,7 @@ class WizardTest extends WizardTestBase {
|
|||
$view['rest_export[path]'] = $this->randomMachineName(254);
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
$this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.');
|
||||
$this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.');
|
||||
// Assert that the page title is correctly truncated.
|
||||
$this->assertText(views_ui_truncate($view['page[title]'], 32));
|
||||
}
|
||||
|
|
|
@ -14,12 +14,9 @@ class XssTest extends UITestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'user', 'views_ui', 'views_ui_test');
|
||||
public static $modules = ['node', 'user', 'views_ui', 'views_ui_test'];
|
||||
|
||||
public function testViewsUi() {
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$this->assertEscaped('<script>alert("foo");</script>, <marquee>test</marquee>', 'The view tag is properly escaped.');
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/sa_contrib_2013_035');
|
||||
$this->assertEscaped('<marquee>test</marquee>', 'Field admin label is properly escaped.');
|
||||
|
||||
|
|
|
@ -51,83 +51,83 @@ class ViewAddForm extends ViewFormBase {
|
|||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$form['#attached']['library'][] = 'views_ui/views_ui.admin';
|
||||
$form['#attributes']['class'] = array('views-admin');
|
||||
$form['#attributes']['class'] = ['views-admin'];
|
||||
|
||||
$form['name'] = array(
|
||||
$form['name'] = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('View basic information'),
|
||||
'#attributes' => array('class' => array('fieldset-no-legend')),
|
||||
);
|
||||
'#attributes' => ['class' => ['fieldset-no-legend']],
|
||||
];
|
||||
|
||||
$form['name']['label'] = array(
|
||||
$form['name']['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('View name'),
|
||||
'#required' => TRUE,
|
||||
'#size' => 32,
|
||||
'#default_value' => '',
|
||||
'#maxlength' => 255,
|
||||
);
|
||||
$form['name']['id'] = array(
|
||||
];
|
||||
$form['name']['id'] = [
|
||||
'#type' => 'machine_name',
|
||||
'#maxlength' => 128,
|
||||
'#machine_name' => array(
|
||||
'#machine_name' => [
|
||||
'exists' => '\Drupal\views\Views::getView',
|
||||
'source' => array('name', 'label'),
|
||||
),
|
||||
'source' => ['name', 'label'],
|
||||
],
|
||||
'#description' => $this->t('A unique machine-readable name for this View. It must only contain lowercase letters, numbers, and underscores.'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['name']['description_enable'] = array(
|
||||
$form['name']['description_enable'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Description'),
|
||||
);
|
||||
$form['name']['description'] = array(
|
||||
];
|
||||
$form['name']['description'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Provide description'),
|
||||
'#title_display' => 'invisible',
|
||||
'#size' => 64,
|
||||
'#default_value' => '',
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="description_enable"]' => array('checked' => TRUE),
|
||||
),
|
||||
),
|
||||
);
|
||||
'#states' => [
|
||||
'visible' => [
|
||||
':input[name="description_enable"]' => ['checked' => TRUE],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Create a wrapper for the entire dynamic portion of the form. Everything
|
||||
// that can be updated by AJAX goes somewhere inside here. For example, this
|
||||
// is needed by "Show" dropdown (below); it changes the base table of the
|
||||
// view and therefore potentially requires all options on the form to be
|
||||
// dynamically updated.
|
||||
$form['displays'] = array();
|
||||
$form['displays'] = [];
|
||||
|
||||
// Create the part of the form that allows the user to select the basic
|
||||
// properties of what the view will display.
|
||||
$form['displays']['show'] = array(
|
||||
$form['displays']['show'] = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('View settings'),
|
||||
'#tree' => TRUE,
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
);
|
||||
'#attributes' => ['class' => ['container-inline']],
|
||||
];
|
||||
|
||||
// Create the "Show" dropdown, which allows the base table of the view to be
|
||||
// selected.
|
||||
$wizard_plugins = $this->wizardManager->getDefinitions();
|
||||
$options = array();
|
||||
$options = [];
|
||||
foreach ($wizard_plugins as $key => $wizard) {
|
||||
$options[$key] = $wizard['title'];
|
||||
}
|
||||
$form['displays']['show']['wizard_key'] = array(
|
||||
$form['displays']['show']['wizard_key'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Show'),
|
||||
'#options' => $options,
|
||||
);
|
||||
];
|
||||
$show_form = &$form['displays']['show'];
|
||||
$default_value = \Drupal::moduleHandler()->moduleExists('node') ? 'node' : 'users';
|
||||
$show_form['wizard_key']['#default_value'] = WizardPluginBase::getSelected($form_state, array('show', 'wizard_key'), $default_value, $show_form['wizard_key']);
|
||||
$show_form['wizard_key']['#default_value'] = WizardPluginBase::getSelected($form_state, ['show', 'wizard_key'], $default_value, $show_form['wizard_key']);
|
||||
// Changing this dropdown updates the entire content of $form['displays'] via
|
||||
// AJAX.
|
||||
views_ui_add_ajax_trigger($show_form, 'wizard_key', array('displays'));
|
||||
views_ui_add_ajax_trigger($show_form, 'wizard_key', ['displays']);
|
||||
|
||||
// Build the rest of the form based on the currently selected wizard plugin.
|
||||
$wizard_key = $show_form['wizard_key']['#default_value'];
|
||||
|
@ -144,13 +144,13 @@ class ViewAddForm extends ViewFormBase {
|
|||
$actions = parent::actions($form, $form_state);
|
||||
$actions['submit']['#value'] = $this->t('Save and edit');
|
||||
// Remove EntityFormController::save() form the submission handlers.
|
||||
$actions['submit']['#submit'] = array(array($this, 'submitForm'));
|
||||
$actions['cancel'] = array(
|
||||
$actions['submit']['#submit'] = [[$this, 'submitForm']];
|
||||
$actions['cancel'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Cancel'),
|
||||
'#submit' => array('::cancel'),
|
||||
'#limit_validation_errors' => array(),
|
||||
);
|
||||
'#submit' => ['::cancel'],
|
||||
'#limit_validation_errors' => [],
|
||||
];
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ class ViewAddForm extends ViewFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$wizard_type = $form_state->getValue(array('show', 'wizard_key'));
|
||||
$wizard_type = $form_state->getValue(['show', 'wizard_key']);
|
||||
$wizard_instance = $this->wizardManager->createInstance($wizard_type);
|
||||
$form_state->set('wizard', $wizard_instance->getPluginDefinition());
|
||||
$form_state->set('wizard_instance', $wizard_instance);
|
||||
|
@ -187,7 +187,7 @@ class ViewAddForm extends ViewFormBase {
|
|||
return;
|
||||
}
|
||||
$this->entity->save();
|
||||
drupal_set_message($this->t('The view %name has been saved.', array('%name' => $form_state->getValue('label'))));
|
||||
drupal_set_message($this->t('The view %name has been saved.', ['%name' => $form_state->getValue('label')]));
|
||||
$form_state->setRedirectUrl($this->entity->urlInfo('edit-form'));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,26 +22,26 @@ class ViewDuplicateForm extends ViewFormBase {
|
|||
public function form(array $form, FormStateInterface $form_state) {
|
||||
parent::form($form, $form_state);
|
||||
|
||||
$form['#title'] = $this->t('Duplicate of @label', array('@label' => $this->entity->label()));
|
||||
$form['#title'] = $this->t('Duplicate of @label', ['@label' => $this->entity->label()]);
|
||||
|
||||
$form['label'] = array(
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('View name'),
|
||||
'#required' => TRUE,
|
||||
'#size' => 32,
|
||||
'#maxlength' => 255,
|
||||
'#default_value' => $this->t('Duplicate of @label', array('@label' => $this->entity->label())),
|
||||
);
|
||||
$form['id'] = array(
|
||||
'#default_value' => $this->t('Duplicate of @label', ['@label' => $this->entity->label()]),
|
||||
];
|
||||
$form['id'] = [
|
||||
'#type' => 'machine_name',
|
||||
'#maxlength' => 128,
|
||||
'#machine_name' => array(
|
||||
'#machine_name' => [
|
||||
'exists' => '\Drupal\views\Views::getView',
|
||||
'source' => array('label'),
|
||||
),
|
||||
'source' => ['label'],
|
||||
],
|
||||
'#default_value' => '',
|
||||
'#description' => $this->t('A unique machine-readable name for this View. It must only contain lowercase letters, numbers, and underscores.'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ class ViewDuplicateForm extends ViewFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function actions(array $form, FormStateInterface $form_state) {
|
||||
$actions['submit'] = array(
|
||||
$actions['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Duplicate'),
|
||||
);
|
||||
];
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
if ($display_id) {
|
||||
if (!$view->getExecutable()->setDisplay($display_id)) {
|
||||
$form['#markup'] = $this->t('Invalid display id @display', array('@display' => $display_id));
|
||||
$form['#markup'] = $this->t('Invalid display id @display', ['@display' => $display_id]);
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
@ -112,55 +112,55 @@ class ViewEditForm extends ViewFormBase {
|
|||
$form['#attached']['library'][] = 'views_ui/views_ui.admin';
|
||||
$form['#attached']['library'][] = 'views_ui/admin.styling';
|
||||
|
||||
$form += array(
|
||||
$form += [
|
||||
'#prefix' => '',
|
||||
'#suffix' => '',
|
||||
);
|
||||
];
|
||||
|
||||
$view_status = $view->status() ? 'enabled' : 'disabled';
|
||||
$form['#prefix'] .= '<div class="views-edit-view views-admin ' . $view_status . ' clearfix">';
|
||||
$form['#suffix'] = '</div>' . $form['#suffix'];
|
||||
|
||||
$form['#attributes']['class'] = array('form-edit');
|
||||
$form['#attributes']['class'] = ['form-edit'];
|
||||
|
||||
if ($view->isLocked()) {
|
||||
$username = array(
|
||||
$username = [
|
||||
'#theme' => 'username',
|
||||
'#account' => $this->entityManager->getStorage('user')->load($view->lock->owner),
|
||||
);
|
||||
$lock_message_substitutions = array(
|
||||
];
|
||||
$lock_message_substitutions = [
|
||||
'@user' => drupal_render($username),
|
||||
'@age' => $this->dateFormatter->formatTimeDiffSince($view->lock->updated),
|
||||
':url' => $view->url('break-lock-form'),
|
||||
);
|
||||
$form['locked'] = array(
|
||||
];
|
||||
$form['locked'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array('class' => array('view-locked', 'messages', 'messages--warning')),
|
||||
'#attributes' => ['class' => ['view-locked', 'messages', 'messages--warning']],
|
||||
'#children' => $this->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 <a href=":url">break this lock</a>.', $lock_message_substitutions),
|
||||
'#weight' => -10,
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$form['changed'] = array(
|
||||
$form['changed'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array('class' => array('view-changed', 'messages', 'messages--warning')),
|
||||
'#attributes' => ['class' => ['view-changed', 'messages', 'messages--warning']],
|
||||
'#children' => $this->t('You have unsaved changes.'),
|
||||
'#weight' => -10,
|
||||
);
|
||||
];
|
||||
if (empty($view->changed)) {
|
||||
$form['changed']['#attributes']['class'][] = 'js-hide';
|
||||
}
|
||||
}
|
||||
|
||||
$form['displays'] = array(
|
||||
$form['displays'] = [
|
||||
'#prefix' => '<h1 class="unit-title clearfix">' . $this->t('Displays') . '</h1>',
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array(
|
||||
'#attributes' => [
|
||||
'class' => [
|
||||
'views-displays',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$form['displays']['top'] = $this->renderDisplayTop($view);
|
||||
|
@ -170,13 +170,13 @@ class ViewEditForm extends ViewFormBase {
|
|||
$form_state->set('display_id', $display_id);
|
||||
|
||||
// The part of the page where editing will take place.
|
||||
$form['displays']['settings'] = array(
|
||||
$form['displays']['settings'] = [
|
||||
'#type' => 'container',
|
||||
'#id' => 'edit-display-settings',
|
||||
'#attributes' => array(
|
||||
'class' => array('edit-display-settings'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['edit-display-settings'],
|
||||
],
|
||||
];
|
||||
|
||||
// Add a text that the display is disabled.
|
||||
if ($view->getExecutable()->displayHandlers->has($display_id)) {
|
||||
|
@ -187,8 +187,8 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
// Add the edit display content
|
||||
$tab_content = $this->getDisplayTab($view);
|
||||
$tab_content['#theme_wrappers'] = array('container');
|
||||
$tab_content['#attributes'] = array('class' => array('views-display-tab'));
|
||||
$tab_content['#theme_wrappers'] = ['container'];
|
||||
$tab_content['#attributes'] = ['class' => ['views-display-tab']];
|
||||
$tab_content['#id'] = 'views-tab-' . $display_id;
|
||||
// Mark deleted displays as such.
|
||||
$display = $view->get('display');
|
||||
|
@ -200,10 +200,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
if ($view->getExecutable()->displayHandlers->has($display_id) && !$view->getExecutable()->displayHandlers->get($display_id)->isEnabled()) {
|
||||
$tab_content['#attributes']['class'][] = 'views-display-disabled';
|
||||
}
|
||||
$form['displays']['settings']['settings_content'] = array(
|
||||
$form['displays']['settings']['settings_content'] = [
|
||||
'#type' => 'container',
|
||||
'tab_content' => $tab_content,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $form;
|
||||
|
@ -216,12 +216,12 @@ class ViewEditForm extends ViewFormBase {
|
|||
$actions = parent::actions($form, $form_state);
|
||||
unset($actions['delete']);
|
||||
|
||||
$actions['cancel'] = array(
|
||||
$actions['cancel'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Cancel'),
|
||||
'#submit' => array('::cancel'),
|
||||
'#limit_validation_errors' => array(),
|
||||
);
|
||||
'#submit' => ['::cancel'],
|
||||
'#limit_validation_errors' => [],
|
||||
];
|
||||
if ($this->entity->isLocked()) {
|
||||
$actions['submit']['#access'] = FALSE;
|
||||
$actions['cancel']['#access'] = FALSE;
|
||||
|
@ -258,6 +258,16 @@ class ViewEditForm extends ViewFormBase {
|
|||
$displays = $view->get('display');
|
||||
foreach ($displays as $id => $display) {
|
||||
if (!empty($display['deleted'])) {
|
||||
// Remove view display from view attachment under the attachments
|
||||
// options.
|
||||
$display_handler = $executable->displayHandlers->get($id);
|
||||
if ($attachments = $display_handler->getAttachedDisplays()) {
|
||||
foreach ($attachments as $attachment ) {
|
||||
$attached_options = $executable->displayHandlers->get($attachment)->getOption('displays');
|
||||
unset($attached_options[$id]);
|
||||
$executable->displayHandlers->get($attachment)->setOption('displays', $attached_options);
|
||||
}
|
||||
}
|
||||
$executable->displayHandlers->remove($id);
|
||||
unset($displays[$id]);
|
||||
}
|
||||
|
@ -275,10 +285,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
unset($displays[$id]);
|
||||
|
||||
// Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors.
|
||||
$form_state->setRedirect('entity.view.edit_display_form', array(
|
||||
$form_state->setRedirect('entity.view.edit_display_form', [
|
||||
'view' => $view->id(),
|
||||
'display_id' => $new_id,
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
$view->set('display', $displays);
|
||||
|
@ -310,7 +320,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
$view->save();
|
||||
|
||||
drupal_set_message($this->t('The view %name has been saved.', array('%name' => $view->label())));
|
||||
drupal_set_message($this->t('The view %name has been saved.', ['%name' => $view->label()]));
|
||||
|
||||
// Remove this view from cache so we can edit it properly.
|
||||
$this->tempStore->delete($view->id());
|
||||
|
@ -335,14 +345,14 @@ class ViewEditForm extends ViewFormBase {
|
|||
* Returns a renderable array representing the edit page for one display.
|
||||
*/
|
||||
public function getDisplayTab($view) {
|
||||
$build = array();
|
||||
$build = [];
|
||||
$display_id = $this->displayID;
|
||||
$display = $view->getExecutable()->displayHandlers->get($display_id);
|
||||
// If the plugin doesn't exist, display an error message instead of an edit
|
||||
// page.
|
||||
if (empty($display)) {
|
||||
// @TODO: Improved UX for the case where a plugin is missing.
|
||||
$build['#markup'] = $this->t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", array('@display' => $display->display['id'], '@plugin' => $display->display['display_plugin']));
|
||||
$build['#markup'] = $this->t("Error: Display @display refers to a plugin named '@plugin', but that plugin is not available.", ['@display' => $display->display['id'], '@plugin' => $display->display['display_plugin']]);
|
||||
}
|
||||
// Build the content of the edit page.
|
||||
else {
|
||||
|
@ -364,10 +374,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
*/
|
||||
public function getDisplayDetails($view, $display) {
|
||||
$display_title = $this->getDisplayLabel($view, $display['id'], FALSE);
|
||||
$build = array(
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('id' => 'edit-display-settings-details'),
|
||||
);
|
||||
$build = [
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['id' => 'edit-display-settings-details'],
|
||||
];
|
||||
|
||||
$is_display_deleted = !empty($display['deleted']);
|
||||
// The master display cannot be duplicated.
|
||||
|
@ -376,14 +386,14 @@ class ViewEditForm extends ViewFormBase {
|
|||
$is_enabled = $view->getExecutable()->displayHandlers->get($display['id'])->isEnabled();
|
||||
|
||||
if ($display['id'] != 'default') {
|
||||
$build['top']['#theme_wrappers'] = array('container');
|
||||
$build['top']['#theme_wrappers'] = ['container'];
|
||||
$build['top']['#attributes']['id'] = 'edit-display-settings-top';
|
||||
$build['top']['#attributes']['class'] = array('views-ui-display-tab-actions', 'edit-display-settings-top', 'views-ui-display-tab-bucket', 'clearfix');
|
||||
$build['top']['#attributes']['class'] = ['views-ui-display-tab-actions', 'edit-display-settings-top', 'views-ui-display-tab-bucket', 'clearfix'];
|
||||
|
||||
// The Delete, Duplicate and Undo Delete buttons.
|
||||
$build['top']['actions'] = array(
|
||||
'#theme_wrappers' => array('dropbutton_wrapper'),
|
||||
);
|
||||
$build['top']['actions'] = [
|
||||
'#theme_wrappers' => ['dropbutton_wrapper'],
|
||||
];
|
||||
|
||||
// Because some of the 'links' are actually submit buttons, we have to
|
||||
// manually wrap each item in <li> and the whole list in <ul>.
|
||||
|
@ -391,14 +401,14 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
if (!$is_display_deleted) {
|
||||
if (!$is_enabled) {
|
||||
$build['top']['actions']['enable'] = array(
|
||||
$build['top']['actions']['enable'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Enable @display_title', ['@display_title' => $display_title]),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::submitDisplayEnable', '::submitDelayDestination'),
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::submitDisplayEnable', '::submitDelayDestination'],
|
||||
'#prefix' => '<li class="enable">',
|
||||
"#suffix" => '</li>',
|
||||
);
|
||||
];
|
||||
}
|
||||
// Add a link to view the page unless the view is disabled or has no
|
||||
// path.
|
||||
|
@ -413,118 +423,118 @@ class ViewEditForm extends ViewFormBase {
|
|||
else {
|
||||
$url = Url::fromUri("base:$path");
|
||||
}
|
||||
$build['top']['actions']['path'] = array(
|
||||
$build['top']['actions']['path'] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('View @display_title', ['@display_title' => $display_title]),
|
||||
'#options' => array('alt' => array($this->t("Go to the real page for this display"))),
|
||||
'#options' => ['alt' => [$this->t("Go to the real page for this display")]],
|
||||
'#url' => $url,
|
||||
'#prefix' => '<li class="view">',
|
||||
"#suffix" => '</li>',
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
if (!$is_default) {
|
||||
$build['top']['actions']['duplicate'] = array(
|
||||
$build['top']['actions']['duplicate'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Duplicate @display_title', ['@display_title' => $display_title]),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::submitDisplayDuplicate', '::submitDelayDestination'),
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::submitDisplayDuplicate', '::submitDelayDestination'],
|
||||
'#prefix' => '<li class="duplicate">',
|
||||
"#suffix" => '</li>',
|
||||
);
|
||||
];
|
||||
}
|
||||
// Always allow a display to be deleted.
|
||||
$build['top']['actions']['delete'] = array(
|
||||
$build['top']['actions']['delete'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Delete @display_title', ['@display_title' => $display_title]),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::submitDisplayDelete', '::submitDelayDestination'),
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::submitDisplayDelete', '::submitDelayDestination'],
|
||||
'#prefix' => '<li class="delete">',
|
||||
"#suffix" => '</li>',
|
||||
);
|
||||
];
|
||||
|
||||
foreach (Views::fetchPluginNames('display', NULL, array($view->get('storage')->get('base_table'))) as $type => $label) {
|
||||
foreach (Views::fetchPluginNames('display', NULL, [$view->get('storage')->get('base_table')]) as $type => $label) {
|
||||
if ($type == $display['display_plugin']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$build['top']['actions']['duplicate_as'][$type] = array(
|
||||
$build['top']['actions']['duplicate_as'][$type] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Duplicate as @type', ['@type' => $label]),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::submitDuplicateDisplayAsType', '::submitDelayDestination'),
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::submitDuplicateDisplayAsType', '::submitDelayDestination'],
|
||||
'#prefix' => '<li class="duplicate">',
|
||||
'#suffix' => '</li>',
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$build['top']['actions']['undo_delete'] = array(
|
||||
$build['top']['actions']['undo_delete'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Undo delete of @display_title', ['@display_title' => $display_title]),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::submitDisplayUndoDelete', '::submitDelayDestination'),
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::submitDisplayUndoDelete', '::submitDelayDestination'],
|
||||
'#prefix' => '<li class="undo-delete">',
|
||||
"#suffix" => '</li>',
|
||||
);
|
||||
];
|
||||
}
|
||||
if ($is_enabled) {
|
||||
$build['top']['actions']['disable'] = array(
|
||||
$build['top']['actions']['disable'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Disable @display_title', ['@display_title' => $display_title]),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::submitDisplayDisable', '::submitDelayDestination'),
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::submitDisplayDisable', '::submitDelayDestination'],
|
||||
'#prefix' => '<li class="disable">',
|
||||
"#suffix" => '</li>',
|
||||
);
|
||||
];
|
||||
}
|
||||
$build['top']['actions']['suffix']['#markup'] = '</ul>';
|
||||
|
||||
// The area above the three columns.
|
||||
$build['top']['display_title'] = array(
|
||||
$build['top']['display_title'] = [
|
||||
'#theme' => 'views_ui_display_tab_setting',
|
||||
'#description' => $this->t('Display name'),
|
||||
'#link' => $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($display_title, 'display_title'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$build['columns'] = array();
|
||||
$build['columns']['#theme_wrappers'] = array('container');
|
||||
$build['columns']['#attributes'] = array('id' => 'edit-display-settings-main', 'class' => array('clearfix', 'views-display-columns'));
|
||||
$build['columns'] = [];
|
||||
$build['columns']['#theme_wrappers'] = ['container'];
|
||||
$build['columns']['#attributes'] = ['id' => 'edit-display-settings-main', 'class' => ['clearfix', 'views-display-columns']];
|
||||
|
||||
$build['columns']['first']['#theme_wrappers'] = array('container');
|
||||
$build['columns']['first']['#attributes'] = array('class' => array('views-display-column', 'first'));
|
||||
$build['columns']['first']['#theme_wrappers'] = ['container'];
|
||||
$build['columns']['first']['#attributes'] = ['class' => ['views-display-column', 'first']];
|
||||
|
||||
$build['columns']['second']['#theme_wrappers'] = array('container');
|
||||
$build['columns']['second']['#attributes'] = array('class' => array('views-display-column', 'second'));
|
||||
$build['columns']['second']['#theme_wrappers'] = ['container'];
|
||||
$build['columns']['second']['#attributes'] = ['class' => ['views-display-column', 'second']];
|
||||
|
||||
$build['columns']['second']['settings'] = array();
|
||||
$build['columns']['second']['header'] = array();
|
||||
$build['columns']['second']['footer'] = array();
|
||||
$build['columns']['second']['empty'] = array();
|
||||
$build['columns']['second']['pager'] = array();
|
||||
$build['columns']['second']['settings'] = [];
|
||||
$build['columns']['second']['header'] = [];
|
||||
$build['columns']['second']['footer'] = [];
|
||||
$build['columns']['second']['empty'] = [];
|
||||
$build['columns']['second']['pager'] = [];
|
||||
|
||||
// The third column buckets are wrapped in details.
|
||||
$build['columns']['third'] = array(
|
||||
$build['columns']['third'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Advanced'),
|
||||
'#theme_wrappers' => array('details'),
|
||||
'#attributes' => array(
|
||||
'class' => array(
|
||||
'#theme_wrappers' => ['details'],
|
||||
'#attributes' => [
|
||||
'class' => [
|
||||
'views-display-column',
|
||||
'third',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
// Collapse the details by default.
|
||||
$build['columns']['third']['#open'] = \Drupal::config('views.settings')->get('ui.show.advanced_column');
|
||||
|
||||
// Each option (e.g. title, access, display as grid/table/list) fits into one
|
||||
// of several "buckets," or boxes (Format, Fields, Sort, and so on).
|
||||
$buckets = array();
|
||||
$buckets = [];
|
||||
|
||||
// Fetch options from the display plugin, with a list of buckets they go into.
|
||||
$options = array();
|
||||
$options = [];
|
||||
$view->getExecutable()->displayHandlers->get($display['id'])->optionsSummary($buckets, $options);
|
||||
|
||||
// Place each option into its bucket.
|
||||
|
@ -579,10 +589,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
$view->cacheSet();
|
||||
|
||||
// Redirect to the top-level edit page.
|
||||
$form_state->setRedirect('entity.view.edit_display_form', array(
|
||||
$form_state->setRedirect('entity.view.edit_display_form', [
|
||||
'view' => $view->id(),
|
||||
'display_id' => $id,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -598,10 +608,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
$view->cacheSet();
|
||||
|
||||
// Redirect to the top-level edit page.
|
||||
$form_state->setRedirect('entity.view.edit_display_form', array(
|
||||
$form_state->setRedirect('entity.view.edit_display_form', [
|
||||
'view' => $view->id(),
|
||||
'display_id' => $id,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -616,10 +626,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
$view->cacheSet();
|
||||
|
||||
// Redirect to the top-level edit page.
|
||||
$form_state->setRedirect('entity.view.edit_display_form', array(
|
||||
$form_state->setRedirect('entity.view.edit_display_form', [
|
||||
'view' => $view->id(),
|
||||
'display_id' => $id,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -671,43 +681,43 @@ class ViewEditForm extends ViewFormBase {
|
|||
public function renderDisplayTop(ViewUI $view) {
|
||||
$display_id = $this->displayID;
|
||||
$element['#theme_wrappers'][] = 'views_ui_container';
|
||||
$element['#attributes']['class'] = array('views-display-top', 'clearfix');
|
||||
$element['#attributes']['id'] = array('views-display-top');
|
||||
$element['#attributes']['class'] = ['views-display-top', 'clearfix'];
|
||||
$element['#attributes']['id'] = ['views-display-top'];
|
||||
|
||||
// Extra actions for the display
|
||||
$element['extra_actions'] = array(
|
||||
$element['extra_actions'] = [
|
||||
'#type' => 'dropbutton',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'views-display-extra-actions',
|
||||
),
|
||||
'#links' => array(
|
||||
'edit-details' => array(
|
||||
],
|
||||
'#links' => [
|
||||
'edit-details' => [
|
||||
'title' => $this->t('Edit view name/description'),
|
||||
'url' => Url::fromRoute('views_ui.form_edit_details', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]),
|
||||
'attributes' => array('class' => array('views-ajax-link')),
|
||||
),
|
||||
'analyze' => array(
|
||||
'attributes' => ['class' => ['views-ajax-link']],
|
||||
],
|
||||
'analyze' => [
|
||||
'title' => $this->t('Analyze view'),
|
||||
'url' => Url::fromRoute('views_ui.form_analyze', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]),
|
||||
'attributes' => array('class' => array('views-ajax-link')),
|
||||
),
|
||||
'duplicate' => array(
|
||||
'attributes' => ['class' => ['views-ajax-link']],
|
||||
],
|
||||
'duplicate' => [
|
||||
'title' => $this->t('Duplicate view'),
|
||||
'url' => $view->urlInfo('duplicate-form'),
|
||||
),
|
||||
'reorder' => array(
|
||||
],
|
||||
'reorder' => [
|
||||
'title' => $this->t('Reorder displays'),
|
||||
'url' => Url::fromRoute('views_ui.form_reorder_displays', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display_id]),
|
||||
'attributes' => array('class' => array('views-ajax-link')),
|
||||
),
|
||||
),
|
||||
);
|
||||
'attributes' => ['class' => ['views-ajax-link']],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($view->access('delete')) {
|
||||
$element['extra_actions']['#links']['delete'] = array(
|
||||
$element['extra_actions']['#links']['delete'] = [
|
||||
'title' => $this->t('Delete view'),
|
||||
'url' => $view->urlInfo('delete-form'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Let other modules add additional links here.
|
||||
|
@ -715,17 +725,17 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
if (isset($view->type) && $view->type != $this->t('Default')) {
|
||||
if ($view->type == $this->t('Overridden')) {
|
||||
$element['extra_actions']['#links']['revert'] = array(
|
||||
$element['extra_actions']['#links']['revert'] = [
|
||||
'title' => $this->t('Revert view'),
|
||||
'href' => "admin/structure/views/view/{$view->id()}/revert",
|
||||
'query' => array('destination' => $view->url('edit-form')),
|
||||
);
|
||||
'query' => ['destination' => $view->url('edit-form')],
|
||||
];
|
||||
}
|
||||
else {
|
||||
$element['extra_actions']['#links']['delete'] = array(
|
||||
$element['extra_actions']['#links']['delete'] = [
|
||||
'title' => $this->t('Delete view'),
|
||||
'url' => $view->urlInfo('delete-form'),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -740,18 +750,18 @@ class ViewEditForm extends ViewFormBase {
|
|||
}
|
||||
|
||||
// Buttons for adding a new display.
|
||||
foreach (Views::fetchPluginNames('display', NULL, array($view->get('base_table'))) as $type => $label) {
|
||||
$element['add_display'][$type] = array(
|
||||
foreach (Views::fetchPluginNames('display', NULL, [$view->get('base_table')]) as $type => $label) {
|
||||
$element['add_display'][$type] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Add @display', array('@display' => $label)),
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('::submitDisplayAdd', '::submitDelayDestination'),
|
||||
'#attributes' => array('class' => array('add-display')),
|
||||
'#value' => $this->t('Add @display', ['@display' => $label]),
|
||||
'#limit_validation_errors' => [],
|
||||
'#submit' => ['::submitDisplayAdd', '::submitDelayDestination'],
|
||||
'#attributes' => ['class' => ['add-display']],
|
||||
// Allow JavaScript to remove the 'Add ' prefix from the button label when
|
||||
// placing the button in a "Add" dropdown menu.
|
||||
'#process' => array_merge(array('views_ui_form_button_was_clicked'), $this->elementInfo->getInfoProperty('submit', '#process', array())),
|
||||
'#values' => array($this->t('Add @display', array('@display' => $label)), $label),
|
||||
);
|
||||
'#process' => array_merge(['views_ui_form_button_was_clicked'], $this->elementInfo->getInfoProperty('submit', '#process', [])),
|
||||
'#values' => [$this->t('Add @display', ['@display' => $label]), $label],
|
||||
];
|
||||
}
|
||||
|
||||
return $element;
|
||||
|
@ -814,10 +824,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
$view->cacheSet();
|
||||
|
||||
// Redirect to the new display's edit page.
|
||||
$form_state->setRedirect('entity.view.edit_display_form', array(
|
||||
$form_state->setRedirect('entity.view.edit_display_form', [
|
||||
'view' => $view->id(),
|
||||
'display_id' => $new_display_id,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -836,10 +846,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
$view->cacheSet();
|
||||
|
||||
// Redirect to the new display's edit page.
|
||||
$form_state->setRedirect('entity.view.edit_display_form', array(
|
||||
$form_state->setRedirect('entity.view.edit_display_form', [
|
||||
'view' => $view->id(),
|
||||
'display_id' => $display_id,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -862,10 +872,10 @@ class ViewEditForm extends ViewFormBase {
|
|||
$view->cacheSet();
|
||||
|
||||
// Redirect to the new display's edit page.
|
||||
$form_state->setRedirect('entity.view.edit_display_form', array(
|
||||
$form_state->setRedirect('entity.view.edit_display_form', [
|
||||
'view' => $view->id(),
|
||||
'display_id' => $new_display_id,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -875,14 +885,14 @@ class ViewEditForm extends ViewFormBase {
|
|||
* object emerges out of refactoring.
|
||||
*/
|
||||
public function buildOptionForm(ViewUI $view, $id, $option, $display) {
|
||||
$option_build = array();
|
||||
$option_build = [];
|
||||
$option_build['#theme'] = 'views_ui_display_tab_setting';
|
||||
|
||||
$option_build['#description'] = $option['title'];
|
||||
|
||||
$option_build['#link'] = $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($option['value'], $id, '', empty($option['desc']) ? '' : $option['desc']);
|
||||
|
||||
$option_build['#links'] = array();
|
||||
$option_build['#links'] = [];
|
||||
if (!empty($option['links']) && is_array($option['links'])) {
|
||||
foreach ($option['links'] as $link_id => $link_value) {
|
||||
$option_build['#settings_links'][] = $view->getExecutable()->displayHandlers->get($display['id'])->optionLink($option['setting'], $link_id, 'views-button-configure', $link_value);
|
||||
|
@ -915,9 +925,9 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
$types = $executable->getHandlerTypes();
|
||||
|
||||
$build = array(
|
||||
'#theme_wrappers' => array('views_ui_display_tab_bucket'),
|
||||
);
|
||||
$build = [
|
||||
'#theme_wrappers' => ['views_ui_display_tab_bucket'],
|
||||
];
|
||||
|
||||
$build['#overridden'] = FALSE;
|
||||
$build['#defaulted'] = FALSE;
|
||||
|
@ -943,11 +953,11 @@ class ViewEditForm extends ViewFormBase {
|
|||
$style_plugin = $executable->style_plugin;
|
||||
$uses_fields = $style_plugin && $style_plugin->usesFields();
|
||||
if (!$uses_fields) {
|
||||
$build['fields'][] = array(
|
||||
$build['fields'][] = [
|
||||
'#markup' => $this->t('The selected style or row format does not use fields.'),
|
||||
'#theme_wrappers' => array('views_ui_container'),
|
||||
'#attributes' => array('class' => array('views-display-setting')),
|
||||
);
|
||||
'#theme_wrappers' => ['views_ui_container'],
|
||||
'#attributes' => ['class' => ['views-display-setting']],
|
||||
];
|
||||
return $build;
|
||||
}
|
||||
break;
|
||||
|
@ -955,47 +965,47 @@ class ViewEditForm extends ViewFormBase {
|
|||
case 'footer':
|
||||
case 'empty':
|
||||
if (!$executable->display_handler->usesAreas()) {
|
||||
$build[$type][] = array(
|
||||
'#markup' => $this->t('The selected display type does not use @type plugins', array('@type' => $type)),
|
||||
'#theme_wrappers' => array('views_ui_container'),
|
||||
'#attributes' => array('class' => array('views-display-setting')),
|
||||
);
|
||||
$build[$type][] = [
|
||||
'#markup' => $this->t('The selected display type does not use @type plugins', ['@type' => $type]),
|
||||
'#theme_wrappers' => ['views_ui_container'],
|
||||
'#attributes' => ['class' => ['views-display-setting']],
|
||||
];
|
||||
return $build;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Create an array of actions to pass to links template.
|
||||
$actions = array();
|
||||
$actions = [];
|
||||
$count_handlers = count($executable->display_handler->getHandlers($type));
|
||||
|
||||
// Create the add text variable for the add action.
|
||||
$add_text = $this->t('Add <span class="visually-hidden">@type</span>', array('@type' => $types[$type]['ltitle']));
|
||||
$add_text = $this->t('Add <span class="visually-hidden">@type</span>', ['@type' => $types[$type]['ltitle']]);
|
||||
|
||||
$actions['add'] = array(
|
||||
$actions['add'] = [
|
||||
'title' => $add_text,
|
||||
'url' => Url::fromRoute('views_ui.form_add_handler', ['js' => 'nojs', 'view' => $view->id(), 'display_id' => $display['id'], 'type' => $type]),
|
||||
'attributes' => array('class' => array('icon compact add', 'views-ajax-link'), 'id' => 'views-add-' . $type),
|
||||
);
|
||||
'attributes' => ['class' => ['icon compact add', 'views-ajax-link'], 'id' => 'views-add-' . $type],
|
||||
];
|
||||
if ($count_handlers > 0) {
|
||||
// Create the rearrange text variable for the rearrange action.
|
||||
$rearrange_text = $type == 'filter' ? $this->t('And/Or Rearrange <span class="visually-hidden">filter criteria</span>') : $this->t('Rearrange <span class="visually-hidden">@type</span>', array('@type' => $types[$type]['ltitle']));
|
||||
$rearrange_text = $type == 'filter' ? $this->t('And/Or Rearrange <span class="visually-hidden">filter criteria</span>') : $this->t('Rearrange <span class="visually-hidden">@type</span>', ['@type' => $types[$type]['ltitle']]);
|
||||
|
||||
$actions['rearrange'] = array(
|
||||
$actions['rearrange'] = [
|
||||
'title' => $rearrange_text,
|
||||
'url' => $rearrange_url,
|
||||
'attributes' => array('class' => array($class, 'views-ajax-link'), 'id' => 'views-rearrange-' . $type),
|
||||
);
|
||||
'attributes' => ['class' => [$class, 'views-ajax-link'], 'id' => 'views-rearrange-' . $type],
|
||||
];
|
||||
}
|
||||
|
||||
// Render the array of links
|
||||
$build['#actions'] = array(
|
||||
$build['#actions'] = [
|
||||
'#type' => 'dropbutton',
|
||||
'#links' => $actions,
|
||||
'#attributes' => array(
|
||||
'class' => array('views-ui-settings-bucket-operations'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['views-ui-settings-bucket-operations'],
|
||||
],
|
||||
];
|
||||
|
||||
if (!$executable->display_handler->isDefaultDisplay()) {
|
||||
if (!$executable->display_handler->isDefaulted($types[$type]['plural'])) {
|
||||
|
@ -1009,14 +1019,14 @@ class ViewEditForm extends ViewFormBase {
|
|||
static $relationships = NULL;
|
||||
if (!isset($relationships)) {
|
||||
// Get relationship labels.
|
||||
$relationships = array();
|
||||
$relationships = [];
|
||||
foreach ($executable->display_handler->getHandlers('relationship') as $id => $handler) {
|
||||
$relationships[$id] = $handler->adminLabel();
|
||||
}
|
||||
}
|
||||
|
||||
// Filters can now be grouped so we do a little bit extra:
|
||||
$groups = array();
|
||||
$groups = [];
|
||||
$grouping = FALSE;
|
||||
if ($type == 'filter') {
|
||||
$group_info = $executable->display_handler->getOption('filter_groups');
|
||||
|
@ -1025,28 +1035,28 @@ class ViewEditForm extends ViewFormBase {
|
|||
// "OR" label next to items within the group.
|
||||
if (!empty($group_info['groups']) && (count($group_info['groups']) > 1 || current($group_info['groups']) == 'OR')) {
|
||||
$grouping = TRUE;
|
||||
$groups = array(0 => array());
|
||||
$groups = [0 => []];
|
||||
}
|
||||
}
|
||||
|
||||
$build['fields'] = array();
|
||||
$build['fields'] = [];
|
||||
|
||||
foreach ($executable->display_handler->getOption($types[$type]['plural']) as $id => $field) {
|
||||
// Build the option link for this handler ("Node: ID = article").
|
||||
$build['fields'][$id] = array();
|
||||
$build['fields'][$id] = [];
|
||||
$build['fields'][$id]['#theme'] = 'views_ui_display_tab_setting';
|
||||
|
||||
$handler = $executable->display_handler->getHandler($type, $id);
|
||||
if ($handler->broken()) {
|
||||
$build['fields'][$id]['#class'][] = 'broken';
|
||||
$field_name = $handler->adminLabel();
|
||||
$build['fields'][$id]['#link'] = $this->l($field_name, new Url('views_ui.form_handler', array(
|
||||
$build['fields'][$id]['#link'] = $this->l($field_name, new Url('views_ui.form_handler', [
|
||||
'js' => 'nojs',
|
||||
'view' => $view->id(),
|
||||
'display_id' => $display['id'],
|
||||
'type' => $type,
|
||||
'id' => $id,
|
||||
), array('attributes' => array('class' => array('views-ajax-link')))));
|
||||
], ['attributes' => ['class' => ['views-ajax-link']]]));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1057,39 +1067,39 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
$description = $handler->adminSummary();
|
||||
$link_text = $field_name . (empty($description) ? '' : " ($description)");
|
||||
$link_attributes = array('class' => array('views-ajax-link'));
|
||||
$link_attributes = ['class' => ['views-ajax-link']];
|
||||
if (!empty($field['exclude'])) {
|
||||
$link_attributes['class'][] = 'views-field-excluded';
|
||||
// Add a [hidden] marker, if the field is excluded.
|
||||
$link_text .= ' [' . $this->t('hidden') . ']';
|
||||
}
|
||||
$build['fields'][$id]['#link'] = $this->l($link_text, new Url('views_ui.form_handler', array(
|
||||
$build['fields'][$id]['#link'] = $this->l($link_text, new Url('views_ui.form_handler', [
|
||||
'js' => 'nojs',
|
||||
'view' => $view->id(),
|
||||
'display_id' => $display['id'],
|
||||
'type' => $type,
|
||||
'id' => $id,
|
||||
), array('attributes' => $link_attributes)));
|
||||
], ['attributes' => $link_attributes]));
|
||||
$build['fields'][$id]['#class'][] = Html::cleanCssIdentifier($display['id'] . '-' . $type . '-' . $id);
|
||||
|
||||
if ($executable->display_handler->useGroupBy() && $handler->usesGroupBy()) {
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', array('@text' => $this->t('Aggregation settings'))), new Url('views_ui.form_handler_group', array(
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', ['@text' => $this->t('Aggregation settings')]), new Url('views_ui.form_handler_group', [
|
||||
'js' => 'nojs',
|
||||
'view' => $view->id(),
|
||||
'display_id' => $display['id'],
|
||||
'type' => $type,
|
||||
'id' => $id,
|
||||
), array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => $this->t('Aggregation settings')))));
|
||||
], ['attributes' => ['class' => ['views-button-configure', 'views-ajax-link'], 'title' => $this->t('Aggregation settings')]]));
|
||||
}
|
||||
|
||||
if ($handler->hasExtraOptions()) {
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', array('@text' => $this->t('Settings'))), new Url('views_ui.form_handler_extra', array(
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', ['@text' => $this->t('Settings')]), new Url('views_ui.form_handler_extra', [
|
||||
'js' => 'nojs',
|
||||
'view' => $view->id(),
|
||||
'display_id' => $display['id'],
|
||||
'type' => $type,
|
||||
'id' => $id,
|
||||
), array('attributes' => array('class' => array('views-button-configure', 'views-ajax-link'), 'title' => $this->t('Settings')))));
|
||||
], ['attributes' => ['class' => ['views-button-configure', 'views-ajax-link'], 'title' => $this->t('Settings')]]));
|
||||
}
|
||||
|
||||
if ($grouping) {
|
||||
|
@ -1106,15 +1116,15 @@ class ViewEditForm extends ViewFormBase {
|
|||
// If using grouping, re-order fields so that they show up properly in the list.
|
||||
if ($type == 'filter' && $grouping) {
|
||||
$store = $build['fields'];
|
||||
$build['fields'] = array();
|
||||
$build['fields'] = [];
|
||||
foreach ($groups as $gid => $contents) {
|
||||
// Display an operator between each group.
|
||||
if (!empty($build['fields'])) {
|
||||
$build['fields'][] = array(
|
||||
$build['fields'][] = [
|
||||
'#theme' => 'views_ui_display_tab_setting',
|
||||
'#class' => array('views-group-text'),
|
||||
'#class' => ['views-group-text'],
|
||||
'#link' => ($group_info['operator'] == 'OR' ? $this->t('OR') : $this->t('AND')),
|
||||
);
|
||||
];
|
||||
}
|
||||
// Display an operator between each pair of filters within the group.
|
||||
$keys = array_keys($contents);
|
||||
|
|
|
@ -88,7 +88,7 @@ abstract class ViewFormBase extends EntityForm {
|
|||
$executable = $view->getExecutable();
|
||||
$executable->initDisplay();
|
||||
$display_id = $this->displayID;
|
||||
$tabs = array();
|
||||
$tabs = [];
|
||||
|
||||
// Create a tab for each display.
|
||||
foreach ($view->get('display') as $id => $display) {
|
||||
|
@ -99,15 +99,15 @@ abstract class ViewFormBase extends EntityForm {
|
|||
continue;
|
||||
}
|
||||
|
||||
$tabs[$id] = array(
|
||||
$tabs[$id] = [
|
||||
'#theme' => 'menu_local_task',
|
||||
'#weight' => $display['position'],
|
||||
'#link' => array(
|
||||
'#link' => [
|
||||
'title' => $this->getDisplayLabel($view, $id),
|
||||
'localized_options' => array(),
|
||||
'localized_options' => [],
|
||||
'url' => $view->urlInfo('edit-display-form')->setRouteParameter('display_id', $id),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
if (!empty($display['deleted'])) {
|
||||
$tabs[$id]['#link']['localized_options']['attributes']['class'][] = 'views-display-deleted-link';
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $storage.
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
|
||||
* The entity storage class.
|
||||
* @param \Drupal\Component\Plugin\PluginManagerInterface $display_manager
|
||||
* The views display plugin manager to use.
|
||||
|
@ -65,10 +65,10 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function load() {
|
||||
$entities = array(
|
||||
'enabled' => array(),
|
||||
'disabled' => array(),
|
||||
);
|
||||
$entities = [
|
||||
'enabled' => [],
|
||||
'disabled' => [],
|
||||
];
|
||||
foreach (parent::load() as $entity) {
|
||||
if ($entity->status()) {
|
||||
$entities['enabled'][] = $entity;
|
||||
|
@ -85,67 +85,73 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
*/
|
||||
public function buildRow(EntityInterface $view) {
|
||||
$row = parent::buildRow($view);
|
||||
return array(
|
||||
'data' => array(
|
||||
'view_name' => array(
|
||||
'data' => array(
|
||||
'#theme' => 'views_ui_view_info',
|
||||
'#view' => $view,
|
||||
'#displays' => $this->getDisplaysList($view)
|
||||
),
|
||||
),
|
||||
'description' => array(
|
||||
'data' => array(
|
||||
return [
|
||||
'data' => [
|
||||
'view_name' => [
|
||||
'data' => [
|
||||
'#plain_text' => $view->label(),
|
||||
],
|
||||
],
|
||||
'machine_name' => [
|
||||
'data' => [
|
||||
'#plain_text' => $view->id(),
|
||||
],
|
||||
],
|
||||
'description' => [
|
||||
'data' => [
|
||||
'#plain_text' => $view->get('description'),
|
||||
),
|
||||
'data-drupal-selector' => 'views-table-filter-text-source',
|
||||
),
|
||||
'tag' => array(
|
||||
'data' => array(
|
||||
'#plain_text' => $view->get('tag'),
|
||||
),
|
||||
'data-drupal-selector' => 'views-table-filter-text-source',
|
||||
),
|
||||
'path' => array(
|
||||
'data' => array(
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $this->getDisplayPaths($view),
|
||||
'#context' => ['list_style' => 'comma-list'],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
'displays' => [
|
||||
'data' => [
|
||||
'#theme' => 'views_ui_view_displays_list',
|
||||
'#displays' => $this->getDisplaysList($view),
|
||||
],
|
||||
],
|
||||
'operations' => $row['operations'],
|
||||
),
|
||||
'title' => $this->t('Machine name: @name', array('@name' => $view->id())),
|
||||
'class' => array($view->status() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'),
|
||||
);
|
||||
],
|
||||
'#attributes' => [
|
||||
'class' => [$view->status() ? 'views-ui-list-enabled' : 'views-ui-list-disabled'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildHeader() {
|
||||
return array(
|
||||
'view_name' => array(
|
||||
return [
|
||||
'view_name' => [
|
||||
'data' => $this->t('View name'),
|
||||
'class' => array('views-ui-name'),
|
||||
),
|
||||
'description' => array(
|
||||
'#attributes' => [
|
||||
'class' => ['views-ui-name'],
|
||||
],
|
||||
],
|
||||
'machine_name' => [
|
||||
'data' => $this->t('Machine name'),
|
||||
'#attributes' => [
|
||||
'class' => ['views-ui-machine-name'],
|
||||
],
|
||||
],
|
||||
'description' => [
|
||||
'data' => $this->t('Description'),
|
||||
'class' => array('views-ui-description'),
|
||||
),
|
||||
'tag' => array(
|
||||
'data' => $this->t('Tag'),
|
||||
'class' => array('views-ui-tag'),
|
||||
),
|
||||
'path' => array(
|
||||
'data' => $this->t('Path'),
|
||||
'class' => array('views-ui-path'),
|
||||
),
|
||||
'operations' => array(
|
||||
'#attributes' => [
|
||||
'class' => ['views-ui-description'],
|
||||
],
|
||||
],
|
||||
'displays' => [
|
||||
'data' => $this->t('Displays'),
|
||||
'#attributes' => [
|
||||
'class' => ['views-ui-displays'],
|
||||
],
|
||||
],
|
||||
'operations' => [
|
||||
'data' => $this->t('Operations'),
|
||||
'class' => array('views-ui-operations'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['views-ui-operations'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,15 +161,15 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
$operations = parent::getDefaultOperations($entity);
|
||||
|
||||
if ($entity->hasLinkTemplate('duplicate-form')) {
|
||||
$operations['duplicate'] = array(
|
||||
$operations['duplicate'] = [
|
||||
'title' => $this->t('Duplicate'),
|
||||
'weight' => 15,
|
||||
'url' => $entity->urlInfo('duplicate-form'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Add AJAX functionality to enable/disable operations.
|
||||
foreach (array('enable', 'disable') as $op) {
|
||||
foreach (['enable', 'disable'] as $op) {
|
||||
if (isset($operations[$op])) {
|
||||
$operations[$op]['url'] = $entity->urlInfo($op);
|
||||
// Enable and disable operations should use AJAX.
|
||||
|
@ -185,40 +191,37 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
$list['#attached']['library'][] = 'core/drupal.ajax';
|
||||
$list['#attached']['library'][] = 'views_ui/views_ui.listing';
|
||||
|
||||
$form['filters'] = array(
|
||||
$form['filters'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('table-filter', 'js-show'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['table-filter', 'js-show'],
|
||||
],
|
||||
];
|
||||
|
||||
$list['filters']['text'] = array(
|
||||
$list['filters']['text'] = [
|
||||
'#type' => 'search',
|
||||
'#title' => $this->t('Filter'),
|
||||
'#title_display' => 'invisible',
|
||||
'#size' => 40,
|
||||
'#placeholder' => $this->t('Filter by view name or description'),
|
||||
'#attributes' => array(
|
||||
'class' => array('views-filter-text'),
|
||||
'#size' => 60,
|
||||
'#placeholder' => $this->t('Filter by view name, machine name, description, or display path'),
|
||||
'#attributes' => [
|
||||
'class' => ['views-filter-text'],
|
||||
'data-table' => '.views-listing-table',
|
||||
'autocomplete' => 'off',
|
||||
'title' => $this->t('Enter a part of the view name or description to filter by.'),
|
||||
),
|
||||
);
|
||||
'title' => $this->t('Enter a part of the view name, machine name, description, or display path to filter by.'),
|
||||
],
|
||||
];
|
||||
|
||||
$list['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', array(), array('context' => 'Plural')) . '</h2>';
|
||||
$list['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', array(), array('context' => 'Plural')) . '</h2>';
|
||||
foreach (array('enabled', 'disabled') as $status) {
|
||||
$list['enabled']['heading']['#markup'] = '<h2>' . $this->t('Enabled', [], ['context' => 'Plural']) . '</h2>';
|
||||
$list['disabled']['heading']['#markup'] = '<h2>' . $this->t('Disabled', [], ['context' => 'Plural']) . '</h2>';
|
||||
foreach (['enabled', 'disabled'] as $status) {
|
||||
$list[$status]['#type'] = 'container';
|
||||
$list[$status]['#attributes'] = array('class' => array('views-list-section', $status));
|
||||
$list[$status]['table'] = array(
|
||||
'#type' => 'table',
|
||||
'#attributes' => array(
|
||||
'class' => array('views-listing-table'),
|
||||
),
|
||||
'#header' => $this->buildHeader(),
|
||||
'#rows' => array(),
|
||||
);
|
||||
$list[$status]['#attributes'] = ['class' => ['views-list-section', $status]];
|
||||
$list[$status]['table'] = [
|
||||
'#theme' => 'views_ui_views_listing_table',
|
||||
'#headers' => $this->buildHeader(),
|
||||
'#attributes' => ['class' => ['views-listing-table', $status]],
|
||||
];
|
||||
foreach ($entities[$status] as $entity) {
|
||||
$list[$status]['table']['#rows'][$entity->id()] = $this->buildRow($entity);
|
||||
}
|
||||
|
@ -241,13 +244,29 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
* An array of display types that this view includes.
|
||||
*/
|
||||
protected function getDisplaysList(EntityInterface $view) {
|
||||
$displays = array();
|
||||
foreach ($view->get('display') as $display) {
|
||||
$definition = $this->displayManager->getDefinition($display['display_plugin']);
|
||||
$displays = [];
|
||||
|
||||
$executable = $view->getExecutable();
|
||||
$executable->initDisplay();
|
||||
foreach ($executable->displayHandlers as $display) {
|
||||
$rendered_path = FALSE;
|
||||
$definition = $display->getPluginDefinition();
|
||||
if (!empty($definition['admin'])) {
|
||||
// Cast the admin label to a string since it is an object.
|
||||
// @see \Drupal\Core\StringTranslation\TranslatableMarkup
|
||||
$displays[] = (string) $definition['admin'];
|
||||
if ($display->hasPath()) {
|
||||
$path = $display->getPath();
|
||||
if ($view->status() && strpos($path, '%') === FALSE) {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$rendered_path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
|
||||
}
|
||||
else {
|
||||
$rendered_path = '/' . $path;
|
||||
}
|
||||
}
|
||||
$displays[] = [
|
||||
'display' => $definition['admin'],
|
||||
'path' => $rendered_path,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,33 +274,4 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
return $displays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of paths assigned to the view.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $view
|
||||
* The view entity.
|
||||
*
|
||||
* @return array
|
||||
* An array of paths for this view.
|
||||
*/
|
||||
protected function getDisplayPaths(EntityInterface $view) {
|
||||
$all_paths = array();
|
||||
$executable = $view->getExecutable();
|
||||
$executable->initDisplay();
|
||||
foreach ($executable->displayHandlers as $display) {
|
||||
if ($display->hasPath()) {
|
||||
$path = $display->getPath();
|
||||
if ($view->status() && strpos($path, '%') === FALSE) {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$all_paths[] = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
|
||||
}
|
||||
else {
|
||||
$all_paths[] = '/' . $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array_unique($all_paths);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,43 +22,43 @@ class ViewPreviewForm extends ViewFormBase {
|
|||
|
||||
$form_state->disableCache();
|
||||
|
||||
$form['controls']['#attributes'] = array('class' => array('clearfix'));
|
||||
$form['controls']['#attributes'] = ['class' => ['clearfix']];
|
||||
|
||||
$form['controls']['title'] = array(
|
||||
$form['controls']['title'] = [
|
||||
'#prefix' => '<h2 class="view-preview-form__title">',
|
||||
'#markup' => $this->t('Preview'),
|
||||
'#suffix' => '</h2>',
|
||||
);
|
||||
];
|
||||
|
||||
// Add a checkbox controlling whether or not this display auto-previews.
|
||||
$form['controls']['live_preview'] = array(
|
||||
$form['controls']['live_preview'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#id' => 'edit-displays-live-preview',
|
||||
'#title' => $this->t('Auto preview'),
|
||||
'#default_value' => \Drupal::config('views.settings')->get('ui.always_live_preview'),
|
||||
);
|
||||
];
|
||||
|
||||
// Add the arguments textfield
|
||||
$form['controls']['view_args'] = array(
|
||||
$form['controls']['view_args'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Preview with contextual filters:'),
|
||||
'#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')),
|
||||
'#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', ['%example' => '40/12/10']),
|
||||
'#id' => 'preview-args',
|
||||
);
|
||||
];
|
||||
|
||||
$args = array();
|
||||
$args = [];
|
||||
if (!$form_state->isValueEmpty('view_args')) {
|
||||
$args = explode('/', $form_state->getValue('view_args'));
|
||||
}
|
||||
|
||||
$user_input = $form_state->getUserInput();
|
||||
if ($form_state->get('show_preview') || !empty($user_input['js'])) {
|
||||
$form['preview'] = array(
|
||||
$form['preview'] = [
|
||||
'#weight' => 110,
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('id' => 'views-live-preview', 'class' => 'views-live-preview'),
|
||||
'#theme_wrappers' => ['container'],
|
||||
'#attributes' => ['id' => 'views-live-preview', 'class' => ['views-live-preview']],
|
||||
'preview' => $view->renderPreview($this->displayID, $args),
|
||||
);
|
||||
];
|
||||
}
|
||||
$uri = $view->urlInfo('preview-form');
|
||||
$uri->setRouteParameter('display_id', $this->displayID);
|
||||
|
@ -72,27 +72,27 @@ class ViewPreviewForm extends ViewFormBase {
|
|||
*/
|
||||
protected function actions(array $form, FormStateInterface $form_state) {
|
||||
$view = $this->entity;
|
||||
return array(
|
||||
'#attributes' => array(
|
||||
return [
|
||||
'#attributes' => [
|
||||
'id' => 'preview-submit-wrapper',
|
||||
'class' => array('preview-submit-wrapper')
|
||||
),
|
||||
'button' => array(
|
||||
'class' => ['preview-submit-wrapper']
|
||||
],
|
||||
'button' => [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Update preview'),
|
||||
'#attributes' => array('class' => array('arguments-preview')),
|
||||
'#submit' => array('::submitPreview'),
|
||||
'#attributes' => ['class' => ['arguments-preview']],
|
||||
'#submit' => ['::submitPreview'],
|
||||
'#id' => 'preview-submit',
|
||||
'#ajax' => array(
|
||||
'#ajax' => [
|
||||
'url' => Url::fromRoute('entity.view.preview_form', ['view' => $view->id(), 'display_id' => $this->displayID]),
|
||||
'wrapper' => 'views-preview-wrapper',
|
||||
'event' => 'click',
|
||||
'progress' => array('type' => 'fullscreen'),
|
||||
'progress' => ['type' => 'fullscreen'],
|
||||
'method' => 'replaceWith',
|
||||
'disable-refocus' => TRUE,
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $forms = array(
|
||||
public static $forms = [
|
||||
'add-handler' => '\Drupal\views_ui\Form\Ajax\AddItem',
|
||||
'analyze' => '\Drupal\views_ui\Form\Ajax\Analyze',
|
||||
'handler' => '\Drupal\views_ui\Form\Ajax\ConfigHandler',
|
||||
|
@ -118,7 +118,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
'rearrange' => '\Drupal\views_ui\Form\Ajax\Rearrange',
|
||||
'rearrange-filter' => '\Drupal\views_ui\Form\Ajax\RearrangeFilter',
|
||||
'reorder-displays' => '\Drupal\views_ui\Form\Ajax\ReorderDisplays',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Whether the config is being created, updated or deleted through the
|
||||
|
@ -277,22 +277,22 @@ class ViewUI implements ViewEntityInterface {
|
|||
* docblock outdated?
|
||||
*/
|
||||
public function getStandardButtons(&$form, FormStateInterface $form_state, $form_id, $name = NULL) {
|
||||
$form['actions'] = array(
|
||||
$form['actions'] = [
|
||||
'#type' => 'actions',
|
||||
);
|
||||
];
|
||||
|
||||
if (empty($name)) {
|
||||
$name = t('Apply');
|
||||
if (!empty($this->stack) && count($this->stack) > 1) {
|
||||
$name = t('Apply and continue');
|
||||
}
|
||||
$names = array(t('Apply'), t('Apply and continue'));
|
||||
$names = [t('Apply'), t('Apply and continue')];
|
||||
}
|
||||
|
||||
// Forms that are purely informational set an ok_button flag, so we know not
|
||||
// to create an "Apply" button for them.
|
||||
if (!$form_state->get('ok_button')) {
|
||||
$form['actions']['submit'] = array(
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $name,
|
||||
'#id' => 'edit-submit-' . Html::getUniqueId($form_id),
|
||||
|
@ -301,9 +301,9 @@ class ViewUI implements ViewEntityInterface {
|
|||
// the current display. Since we have no way of knowing at this point
|
||||
// which display the user wants to update, views_ui_standard_submit will
|
||||
// take care of running the regular submit handler as appropriate.
|
||||
'#submit' => array(array($this, 'standardSubmit')),
|
||||
'#submit' => [[$this, 'standardSubmit']],
|
||||
'#button_type' => 'primary',
|
||||
);
|
||||
];
|
||||
// Form API button click detection requires the button's #value to be the
|
||||
// same between the form build of the initial page request, and the
|
||||
// initial form build of the request processing the form submission.
|
||||
|
@ -315,21 +315,21 @@ class ViewUI implements ViewEntityInterface {
|
|||
// button labels.
|
||||
if (isset($names)) {
|
||||
$form['actions']['submit']['#values'] = $names;
|
||||
$form['actions']['submit']['#process'] = array_merge(array('views_ui_form_button_was_clicked'), \Drupal::service('element_info')->getInfoProperty($form['actions']['submit']['#type'], '#process', array()));
|
||||
$form['actions']['submit']['#process'] = array_merge(['views_ui_form_button_was_clicked'], \Drupal::service('element_info')->getInfoProperty($form['actions']['submit']['#type'], '#process', []));
|
||||
}
|
||||
// If a validation handler exists for the form, assign it to this button.
|
||||
$form['actions']['submit']['#validate'][] = [$form_state->getFormObject(), 'validateForm'];
|
||||
}
|
||||
|
||||
// Create a "Cancel" button. For purely informational forms, label it "OK".
|
||||
$cancel_submit = function_exists($form_id . '_cancel') ? $form_id . '_cancel' : array($this, 'standardCancel');
|
||||
$form['actions']['cancel'] = array(
|
||||
$cancel_submit = function_exists($form_id . '_cancel') ? $form_id . '_cancel' : [$this, 'standardCancel'];
|
||||
$form['actions']['cancel'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => !$form_state->get('ok_button') ? t('Cancel') : t('Ok'),
|
||||
'#submit' => array($cancel_submit),
|
||||
'#validate' => array(),
|
||||
'#limit_validation_errors' => array(),
|
||||
);
|
||||
'#submit' => [$cancel_submit],
|
||||
'#validate' => [],
|
||||
'#limit_validation_errors' => [],
|
||||
];
|
||||
|
||||
// Compatibility, to be removed later: // TODO: When is "later"?
|
||||
// We used to set these items on the form, but now we want them on the $form_state:
|
||||
|
@ -348,11 +348,11 @@ class ViewUI implements ViewEntityInterface {
|
|||
*/
|
||||
public function getOverrideValues($form, FormStateInterface $form_state) {
|
||||
// Make sure the dropdown exists in the first place.
|
||||
if ($form_state->hasValue(array('override', 'dropdown'))) {
|
||||
if ($form_state->hasValue(['override', 'dropdown'])) {
|
||||
// #default_value is used to determine whether it was the default value or not.
|
||||
// So the available options are: $display, 'default' and 'default_revert', not 'defaults'.
|
||||
$was_defaulted = ($form['override']['dropdown']['#default_value'] === 'defaults');
|
||||
$dropdown = $form_state->getValue(array('override', 'dropdown'));
|
||||
$dropdown = $form_state->getValue(['override', 'dropdown']);
|
||||
$is_defaulted = ($dropdown === 'default');
|
||||
$revert = ($dropdown === 'default_revert');
|
||||
|
||||
|
@ -369,7 +369,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
$revert = FALSE;
|
||||
}
|
||||
|
||||
return array($was_defaulted, $is_defaulted, $revert);
|
||||
return [$was_defaulted, $is_defaulted, $revert];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,10 +383,10 @@ class ViewUI implements ViewEntityInterface {
|
|||
Html::resetSeenIds();
|
||||
|
||||
if (empty($this->stack)) {
|
||||
$this->stack = array();
|
||||
$this->stack = [];
|
||||
}
|
||||
|
||||
$stack = array(implode('-', array_filter(array($key, $this->id(), $display_id, $type, $id))), $key, $display_id, $type, $id);
|
||||
$stack = [implode('-', array_filter([$key, $this->id(), $display_id, $type, $id])), $key, $display_id, $type, $id];
|
||||
// If we're being asked to add this form to the bottom of the stack, no
|
||||
// special logic is required. Our work is equally easy if we were asked to add
|
||||
// to the top of the stack, but there's nothing in it yet.
|
||||
|
@ -463,10 +463,10 @@ class ViewUI implements ViewEntityInterface {
|
|||
if (isset($types[$type]['type'])) {
|
||||
$key = $types[$type]['type'];
|
||||
}
|
||||
$item = array(
|
||||
$item = [
|
||||
'table' => $table,
|
||||
'field' => $field,
|
||||
);
|
||||
];
|
||||
$handler = Views::handlerManager($key)->getHandler($item);
|
||||
if ($this->getExecutable()->displayHandlers->get('default')->useGroupBy() && $handler->usesGroupBy()) {
|
||||
$this->addFormToStack('handler-group', $display_id, $type, $id);
|
||||
|
@ -512,7 +512,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
$this->additionalQueries = $queries;
|
||||
}
|
||||
|
||||
public function renderPreview($display_id, $args = array()) {
|
||||
public function renderPreview($display_id, $args = []) {
|
||||
// Save the current path so it can be restored before returning from this function.
|
||||
$request_stack = \Drupal::requestStack();
|
||||
$current_request = $request_stack->getCurrentRequest();
|
||||
|
@ -531,7 +531,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
|
||||
$combined = $show_query && $show_stats;
|
||||
|
||||
$rows = array('query' => array(), 'statistics' => array());
|
||||
$rows = ['query' => [], 'statistics' => []];
|
||||
|
||||
$errors = $executable->validate();
|
||||
$executable->destroy();
|
||||
|
@ -545,7 +545,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
// have some input in the query parameters, so we merge request() and
|
||||
// query() to ensure we get it all.
|
||||
$exposed_input = array_merge(\Drupal::request()->request->all(), \Drupal::request()->query->all());
|
||||
foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER, 'ajax_page_state', 'form_id', 'form_build_id', 'form_token') as $key) {
|
||||
foreach (['view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER, 'ajax_page_state', 'form_id', 'form_build_id', 'form_token'] as $key) {
|
||||
if (isset($exposed_input[$key])) {
|
||||
unset($exposed_input[$key]);
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
|
||||
if (!$executable->setDisplay($display_id)) {
|
||||
return [
|
||||
'#markup' => t('Invalid display id @display', array('@display' => $display_id)),
|
||||
'#markup' => t('Invalid display id @display', ['@display' => $display_id]),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -620,76 +620,76 @@ class ViewUI implements ViewEntityInterface {
|
|||
if ($show_query) {
|
||||
$query_string = $executable->build_info['query'];
|
||||
// Only the sql default class has a method getArguments.
|
||||
$quoted = array();
|
||||
$quoted = [];
|
||||
|
||||
if ($executable->query instanceof Sql) {
|
||||
$quoted = $query_string->getArguments();
|
||||
$connection = Database::getConnection();
|
||||
foreach ($quoted as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
$quoted[$key] = implode(', ', array_map(array($connection, 'quote'), $val));
|
||||
$quoted[$key] = implode(', ', array_map([$connection, 'quote'], $val));
|
||||
}
|
||||
else {
|
||||
$quoted[$key] = $connection->quote($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
$rows['query'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['query'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => "<strong>{% trans 'Query' %}</strong>",
|
||||
),
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => '<pre>{{ query }}</pre>',
|
||||
'#context' => array('query' => strtr($query_string, $quoted)),
|
||||
),
|
||||
),
|
||||
);
|
||||
'#context' => ['query' => strtr($query_string, $quoted)],
|
||||
],
|
||||
],
|
||||
];
|
||||
if (!empty($this->additionalQueries)) {
|
||||
$queries[] = array(
|
||||
$queries[] = [
|
||||
'#prefix' => '<strong>',
|
||||
'#markup' => t('These queries were run during view rendering:'),
|
||||
'#suffix' => '</strong>',
|
||||
);
|
||||
];
|
||||
foreach ($this->additionalQueries as $query) {
|
||||
$query_string = strtr($query['query'], $query['args']);
|
||||
$queries[] = array(
|
||||
$queries[] = [
|
||||
'#prefix' => "\n",
|
||||
'#markup' => t('[@time ms] @query', array('@time' => round($query['time'] * 100000, 1) / 100000.0, '@query' => $query_string)),
|
||||
);
|
||||
'#markup' => t('[@time ms] @query', ['@time' => round($query['time'] * 100000, 1) / 100000.0, '@query' => $query_string]),
|
||||
];
|
||||
}
|
||||
|
||||
$rows['query'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['query'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => "<strong>{% trans 'Other queries' %}</strong>",
|
||||
),
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'data' => [
|
||||
'#prefix' => '<pre>',
|
||||
'queries' => $queries,
|
||||
'#suffix' => '</pre>',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($show_info) {
|
||||
$rows['query'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['query'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => "<strong>{% trans 'Title' %}</strong>",
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
Xss::filterAdmin($executable->getTitle()),
|
||||
);
|
||||
];
|
||||
if (isset($path)) {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
|
@ -698,51 +698,51 @@ class ViewUI implements ViewEntityInterface {
|
|||
else {
|
||||
$path = t('This display has no path.');
|
||||
}
|
||||
$rows['query'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['query'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#prefix' => '<strong>',
|
||||
'#markup' => t('Path'),
|
||||
'#suffix' => '</strong>',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'data' => [
|
||||
'#markup' => $path,
|
||||
),
|
||||
)
|
||||
);
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
if ($show_stats) {
|
||||
$rows['statistics'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['statistics'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => "<strong>{% trans 'Query build time' %}</strong>",
|
||||
),
|
||||
),
|
||||
t('@time ms', array('@time' => intval($executable->build_time * 100000) / 100)),
|
||||
);
|
||||
],
|
||||
],
|
||||
t('@time ms', ['@time' => intval($executable->build_time * 100000) / 100]),
|
||||
];
|
||||
|
||||
$rows['statistics'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['statistics'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => "<strong>{% trans 'Query execute time' %}</strong>",
|
||||
),
|
||||
),
|
||||
t('@time ms', array('@time' => intval($executable->execute_time * 100000) / 100)),
|
||||
);
|
||||
],
|
||||
],
|
||||
t('@time ms', ['@time' => intval($executable->execute_time * 100000) / 100]),
|
||||
];
|
||||
|
||||
$rows['statistics'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['statistics'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => "<strong>{% trans 'View render time' %}</strong>",
|
||||
),
|
||||
),
|
||||
t('@time ms', array('@time' => intval($this->render_time * 100) / 100)),
|
||||
);
|
||||
],
|
||||
],
|
||||
t('@time ms', ['@time' => intval($this->render_time * 100) / 100]),
|
||||
];
|
||||
}
|
||||
\Drupal::moduleHandler()->alter('views_preview_info', $rows, $executable);
|
||||
}
|
||||
|
@ -750,36 +750,36 @@ class ViewUI implements ViewEntityInterface {
|
|||
// No query was run. Display that information in place of either the
|
||||
// query or the performance statistics, whichever comes first.
|
||||
if ($combined || ($show_location === 'above')) {
|
||||
$rows['query'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['query'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#prefix' => '<strong>',
|
||||
'#markup' => t('Query'),
|
||||
'#suffix' => '</strong>',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'data' => [
|
||||
'#markup' => t('No query was run'),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
else {
|
||||
$rows['statistics'][] = array(
|
||||
array(
|
||||
'data' => array(
|
||||
$rows['statistics'][] = [
|
||||
[
|
||||
'data' => [
|
||||
'#prefix' => '<strong>',
|
||||
'#markup' => t('Query'),
|
||||
'#suffix' => '</strong>',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
],
|
||||
],
|
||||
[
|
||||
'data' => [
|
||||
'#markup' => t('No query was run'),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -795,12 +795,12 @@ class ViewUI implements ViewEntityInterface {
|
|||
|
||||
// Assemble the preview, the query info, and the query statistics in the
|
||||
// requested order.
|
||||
$table = array(
|
||||
$table = [
|
||||
'#type' => 'table',
|
||||
'#prefix' => '<div class="views-query-info">',
|
||||
'#suffix' => '</div>',
|
||||
'#rows' => array_merge($rows['query'], $rows['statistics']),
|
||||
);
|
||||
];
|
||||
|
||||
if ($show_location == 'above') {
|
||||
$output = [
|
||||
|
@ -843,7 +843,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
$current = reset($keys) + 1;
|
||||
$total = end($keys) + 1;
|
||||
if ($total > 1) {
|
||||
$progress = array();
|
||||
$progress = [];
|
||||
$progress['current'] = $current;
|
||||
$progress['total'] = $total;
|
||||
}
|
||||
|
@ -892,7 +892,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
* Passes through all unknown calls onto the storage object.
|
||||
*/
|
||||
public function __call($method, $args) {
|
||||
return call_user_func_array(array($this->storage, $method), $args);
|
||||
return call_user_func_array([$this->storage, $method], $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -968,7 +968,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(array $values = array()) {
|
||||
public static function create(array $values = []) {
|
||||
return View::create($values);
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1167,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function url($rel = 'edit-form', $options = array()) {
|
||||
public function url($rel = 'edit-form', $options = []) {
|
||||
return $this->storage->url($rel, $options);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for views displays on the views listing page.
|
||||
*
|
||||
* Available variables:
|
||||
* - displays: Contains multiple display instances. Each display contains:
|
||||
* - display: Display name.
|
||||
* - path: Path to display, if any.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
<ul>
|
||||
{% for display in displays %}
|
||||
<li>
|
||||
{% if display.path %}
|
||||
{{ display.display }} <span data-drupal-selector="views-table-filter-text-source">({{ display.path }})</span>
|
||||
{% else %}
|
||||
{{ display.display }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
|
@ -0,0 +1,49 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation for views listing table.
|
||||
*
|
||||
* Available variables:
|
||||
* - headers: Contains table headers.
|
||||
* - rows: Contains multiple rows. Each row contains:
|
||||
* - view_name: The human-readable name of the view.
|
||||
* - machine_name: Machine name of the view.
|
||||
* - description: The description of the view.
|
||||
* - displays: List of displays attached to the view.
|
||||
* - operations: List of available operations.
|
||||
*
|
||||
* @see template_preprocess_views_ui_views_listing_table()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
<table{{ attributes.addClass('responsive-enabled') }}>
|
||||
<thead>
|
||||
<tr>
|
||||
{% for header in headers %}
|
||||
<th{{ header.attributes }}>{{ header.data }}</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
<tr{{ row.attributes }}>
|
||||
<td class="views-ui-view-name">
|
||||
<h3 data-drupal-selector="views-table-filter-text-source">{{ row.data.view_name.data }}</h3>
|
||||
</td>
|
||||
<td class="views-ui-view-machine-name" data-drupal-selector="views-table-filter-text-source">
|
||||
{{ row.data.machine_name.data }}
|
||||
</td>
|
||||
<td class="views-ui-view-description" data-drupal-selector="views-table-filter-text-source">
|
||||
{{ row.data.description.data }}
|
||||
</td>
|
||||
<td class="views-ui-view-displays">
|
||||
{{ row.data.displays.data }}
|
||||
</td>
|
||||
<td class="views-ui-view-operations">
|
||||
{{ row.data.operations.data }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,8 @@
|
|||
name: 'Views test field'
|
||||
type: module
|
||||
description: 'Add custom global field for testing purposes.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- views_ui
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* ViewsUI Test field module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for views_ui_add_handler_form.
|
||||
*
|
||||
* Changes the label for one of the tests fields to validate this label is not
|
||||
* searched on.
|
||||
*/
|
||||
function views_ui_test_field_form_views_ui_add_handler_form_alter(&$form, FormStateInterface $form_state) {
|
||||
$form['options']['name']['#options']['views.views_test_field_1']['title']['data']['#title'] .= ' FIELD_1_LABEL';
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide views data for testing purposes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_data().
|
||||
*/
|
||||
function views_ui_test_field_views_data() {
|
||||
|
||||
$data['views']['views_test_field_1'] = [
|
||||
'title' => t('Views test field 1 - FIELD_1_TITLE'),
|
||||
'help' => t('Field 1 for testing purposes - FIELD_1_DESCRIPTION'),
|
||||
'field' => [
|
||||
'id' => 'views_test_field_1',
|
||||
],
|
||||
];
|
||||
$data['views']['views_test_field_2'] = [
|
||||
'title' => t('Views test field 2 - FIELD_2_TITLE'),
|
||||
'help' => t('Field 2 for testing purposes - FIELD_2_DESCRIPTION'),
|
||||
'field' => [
|
||||
'id' => 'views_test_field_2',
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
|
||||
/**
|
||||
* Tests the JavaScript filtering of options in add handler form.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class FilterOptionsTest extends JavascriptTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'views', 'views_ui', 'views_ui_test_field'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests filtering options in the 'Add fields' dialog.
|
||||
*/
|
||||
public function testFilterOptionsAddFields() {
|
||||
$this->drupalGet('admin/structure/views/view/content');
|
||||
|
||||
$session = $this->getSession();
|
||||
$web_assert = $this->assertSession();
|
||||
$page = $session->getPage();
|
||||
|
||||
// Open the dialog.
|
||||
$page->clickLink('views-add-field');
|
||||
|
||||
// Wait for the popup to open and the search field to be available.
|
||||
$options_search = $web_assert->waitForField('override[controls][options_search]');
|
||||
|
||||
// Test that the both special fields are visible.
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
|
||||
// Test the ".title" field in search.
|
||||
$options_search->setValue('FIELD_1_TITLE');
|
||||
$page->waitFor(10, function () use ($page) {
|
||||
return !$page->findField('name[views.views_test_field_2]')->isVisible();
|
||||
});
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
|
||||
// Test the ".description" field in search.
|
||||
$options_search->setValue('FIELD_2_DESCRIPTION');
|
||||
$page->waitFor(10, function () use ($page) {
|
||||
return !$page->findField('name[views.views_test_field_1]')->isVisible();
|
||||
});
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
|
||||
// Test the "label" field not in search.
|
||||
$options_search->setValue('FIELD_1_LABEL');
|
||||
$page->waitFor(10, function () use ($page) {
|
||||
return !$page->findField('name[views.views_test_field_2]')->isVisible();
|
||||
});
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ class TagTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views', 'views_ui', 'user');
|
||||
public static $modules = ['views', 'views_ui', 'user'];
|
||||
|
||||
/**
|
||||
* Tests the views_ui_autocomplete_tag function.
|
||||
|
@ -28,15 +28,15 @@ class TagTest extends ViewsKernelTestBase {
|
|||
\Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');
|
||||
|
||||
// Save 15 views with a tag.
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$suffix = $i % 2 ? 'odd' : 'even';
|
||||
$tag = 'autocomplete_tag_test_' . $suffix . $this->randomMachineName();
|
||||
$tags[] = $tag;
|
||||
View::create(array('tag' => $tag, 'id' => $this->randomMachineName()))->save();
|
||||
View::create(['tag' => $tag, 'id' => $this->randomMachineName()])->save();
|
||||
}
|
||||
|
||||
// Make sure just ten results are returns.
|
||||
// Make sure just ten results are returned.
|
||||
$controller = ViewsUIController::create($this->container);
|
||||
$request = $this->container->get('request_stack')->getCurrentRequest();
|
||||
$request->query->set('q', 'autocomplete_tag_test');
|
||||
|
@ -46,7 +46,7 @@ class TagTest extends ViewsKernelTestBase {
|
|||
|
||||
// Make sure the returned array has the proper format.
|
||||
$suggestions = array_map(function ($tag) {
|
||||
return array('value' => $tag, 'label' => Html::escape($tag));
|
||||
return ['value' => $tag, 'label' => Html::escape($tag)];
|
||||
}, $tags);
|
||||
foreach ($matches as $match) {
|
||||
$this->assertTrue(in_array($match, $suggestions), 'Make sure the returned array has the proper format.');
|
||||
|
@ -59,7 +59,7 @@ class TagTest extends ViewsKernelTestBase {
|
|||
$matches = (array) json_decode($result->getContent(), TRUE);
|
||||
$this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
|
||||
foreach ($matches as $tag) {
|
||||
$this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag['value'])));
|
||||
$this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', ['@tag' => $tag['value']]));
|
||||
}
|
||||
|
||||
// Make sure an invalid result doesn't return anything.
|
||||
|
|
|
@ -17,8 +17,8 @@ class RearrangeFilterTest extends UnitTestCase {
|
|||
*/
|
||||
public function testStaticMethods() {
|
||||
// Test the RearrangeFilter::arrayKeyPlus method.
|
||||
$original = array(0 => 'one', 1 => 'two', 2 => 'three');
|
||||
$expected = array(1 => 'one', 2 => 'two', 3 => 'three');
|
||||
$original = [0 => 'one', 1 => 'two', 2 => 'three'];
|
||||
$expected = [1 => 'one', 2 => 'two', 3 => 'three'];
|
||||
$this->assertSame(RearrangeFilter::arrayKeyPlus($original), $expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,54 +38,54 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
|
||||
$display_manager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValueMap(array(
|
||||
array(
|
||||
->will($this->returnValueMap([
|
||||
[
|
||||
'default',
|
||||
TRUE,
|
||||
array(
|
||||
[
|
||||
'id' => 'default',
|
||||
'title' => 'Master',
|
||||
'theme' => 'views_view',
|
||||
'no_ui' => TRUE,
|
||||
'admin' => '',
|
||||
)
|
||||
),
|
||||
array(
|
||||
]
|
||||
],
|
||||
[
|
||||
'page',
|
||||
TRUE,
|
||||
array(
|
||||
[
|
||||
'id' => 'page',
|
||||
'title' => 'Page',
|
||||
'uses_menu_links' => TRUE,
|
||||
'uses_route' => TRUE,
|
||||
'contextual_links_locations' => array('page'),
|
||||
'contextual_links_locations' => ['page'],
|
||||
'theme' => 'views_view',
|
||||
'admin' => 'Page admin label',
|
||||
)
|
||||
),
|
||||
array(
|
||||
]
|
||||
],
|
||||
[
|
||||
'embed',
|
||||
TRUE,
|
||||
array(
|
||||
[
|
||||
'id' => 'embed',
|
||||
'title' => 'embed',
|
||||
'theme' => 'views_view',
|
||||
'admin' => 'Embed admin label',
|
||||
)
|
||||
),
|
||||
)));
|
||||
]
|
||||
],
|
||||
]));
|
||||
|
||||
|
||||
$default_display = $this->getMock('Drupal\views\Plugin\views\display\DefaultDisplay',
|
||||
array('initDisplay'),
|
||||
array(array(), 'default', $display_manager->getDefinition('default'))
|
||||
['initDisplay'],
|
||||
[[], 'default', $display_manager->getDefinition('default')]
|
||||
);
|
||||
$route_provider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
|
||||
$state = $this->getMock('\Drupal\Core\State\StateInterface');
|
||||
$menu_storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
|
||||
$page_display = $this->getMock('Drupal\views\Plugin\views\display\Page',
|
||||
array('initDisplay', 'getPath'),
|
||||
array(array(), 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage)
|
||||
['initDisplay', 'getPath'],
|
||||
[[], 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage]
|
||||
);
|
||||
$page_display->expects($this->any())
|
||||
->method('getPath')
|
||||
|
@ -94,11 +94,11 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
$this->returnValue('<object>malformed_path</object>'),
|
||||
$this->returnValue('<script>alert("placeholder_page/%")</script>')));
|
||||
|
||||
$embed_display = $this->getMock('Drupal\views\Plugin\views\display\Embed', array('initDisplay'),
|
||||
array(array(), 'default', $display_manager->getDefinition('embed'))
|
||||
$embed_display = $this->getMock('Drupal\views\Plugin\views\display\Embed', ['initDisplay'],
|
||||
[[], 'default', $display_manager->getDefinition('embed')]
|
||||
);
|
||||
|
||||
$values = array();
|
||||
$values = [];
|
||||
$values['status'] = FALSE;
|
||||
$values['display']['default']['id'] = 'default';
|
||||
$values['display']['default']['display_title'] = 'Display';
|
||||
|
@ -125,13 +125,13 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
|
||||
$display_manager->expects($this->any())
|
||||
->method('createInstance')
|
||||
->will($this->returnValueMap(array(
|
||||
array('default', $values['display']['default'], $default_display),
|
||||
array('page', $values['display']['page_1'], $page_display),
|
||||
array('page', $values['display']['page_2'], $page_display),
|
||||
array('page', $values['display']['page_3'], $page_display),
|
||||
array('embed', $values['display']['embed'], $embed_display),
|
||||
)));
|
||||
->will($this->returnValueMap([
|
||||
['default', $values['display']['default'], $default_display],
|
||||
['page', $values['display']['page_1'], $page_display],
|
||||
['page', $values['display']['page_2'], $page_display],
|
||||
['page', $values['display']['page_3'], $page_display],
|
||||
['embed', $values['display']['embed'], $embed_display],
|
||||
]));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$user = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||
|
@ -152,21 +152,34 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
$view_list_builder = new TestViewListBuilder($entity_type, $storage, $display_manager);
|
||||
$view_list_builder->setStringTranslation($this->getStringTranslationStub());
|
||||
|
||||
// Create new view with test values.
|
||||
$view = new View($values, 'view');
|
||||
|
||||
// Get the row object created by ViewListBuilder for this test view.
|
||||
$row = $view_list_builder->buildRow($view);
|
||||
|
||||
$expected_displays = array(
|
||||
'Embed admin label',
|
||||
'Page admin label',
|
||||
'Page admin label',
|
||||
'Page admin label',
|
||||
);
|
||||
$this->assertEquals($expected_displays, $row['data']['view_name']['data']['#displays']);
|
||||
// Expected output array for view's displays.
|
||||
$expected_displays = [
|
||||
'0' => [
|
||||
'display' => 'Embed admin label',
|
||||
'path' => FALSE,
|
||||
],
|
||||
'1' => [
|
||||
'display' => 'Page admin label',
|
||||
'path' => '/<object>malformed_path</object>',
|
||||
],
|
||||
'2' => [
|
||||
'display' => 'Page admin label',
|
||||
'path' => '/<script>alert("placeholder_page/%")</script>',
|
||||
],
|
||||
'3' => [
|
||||
'display' => 'Page admin label',
|
||||
'path' => '/test_page',
|
||||
],
|
||||
];
|
||||
|
||||
$display_paths = $row['data']['path']['data']['#items'];
|
||||
// These values will be escaped by Twig when rendered.
|
||||
$this->assertEquals('/test_page, /<object>malformed_path</object>, /<script>alert("placeholder_page/%")</script>', implode(', ', $display_paths));
|
||||
// Compare the expected and generated output.
|
||||
$this->assertEquals($expected_displays, $row['data']['displays']['data']['#displays']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,7 +187,7 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
class TestViewListBuilder extends ViewListBuilder {
|
||||
|
||||
public function buildOperations(EntityInterface $entity) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
* Tests entity method decoration.
|
||||
*/
|
||||
public function testEntityDecoration() {
|
||||
$method_args = array();
|
||||
$method_args['setOriginalId'] = array(12);
|
||||
$method_args['setStatus'] = array(TRUE);
|
||||
$method_args['enforceIsNew'] = array(FALSE);
|
||||
$method_args['label'] = array(LanguageInterface::LANGCODE_NOT_SPECIFIED);
|
||||
$method_args = [];
|
||||
$method_args['setOriginalId'] = [12];
|
||||
$method_args['setStatus'] = [TRUE];
|
||||
$method_args['enforceIsNew'] = [FALSE];
|
||||
$method_args['label'] = [LanguageInterface::LANGCODE_NOT_SPECIFIED];
|
||||
|
||||
$reflection = new \ReflectionClass('Drupal\Core\Config\Entity\ConfigEntityInterface');
|
||||
$interface_methods = array();
|
||||
$interface_methods = [];
|
||||
foreach ($reflection->getMethods() as $reflection_method) {
|
||||
$interface_methods[] = $reflection_method->getName();
|
||||
|
||||
|
@ -38,15 +38,15 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
// dependency management.
|
||||
if (!in_array($reflection_method->getName(), ['isNew', 'isSyncing', 'isUninstalling', 'getConfigDependencyKey', 'getConfigDependencyName', 'calculateDependencies'])) {
|
||||
if (count($reflection_method->getParameters()) == 0) {
|
||||
$method_args[$reflection_method->getName()] = array();
|
||||
$method_args[$reflection_method->getName()] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', $interface_methods, array(array(), 'view'));
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', $interface_methods, [[], 'view']);
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->setConstructorArgs(array($storage))
|
||||
->setConstructorArgs([$storage])
|
||||
->getMock();
|
||||
$storage->set('executable', $executable);
|
||||
|
||||
|
@ -58,7 +58,7 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
foreach ($args as $arg) {
|
||||
$method_mock->with($this->equalTo($arg));
|
||||
}
|
||||
call_user_func_array(array($view_ui, $method), $args);
|
||||
call_user_func_array([$view_ui, $method], $args);
|
||||
}
|
||||
|
||||
$storage->expects($this->once())
|
||||
|
@ -70,10 +70,10 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
* Tests the isLocked method.
|
||||
*/
|
||||
public function testIsLocked() {
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', array(), array(array(), 'view'));
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', [], [[], 'view']);
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->setConstructorArgs(array($storage))
|
||||
->setConstructorArgs([$storage])
|
||||
->getMock();
|
||||
$storage->set('executable', $executable);
|
||||
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||
|
@ -91,20 +91,20 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
$this->assertFalse($view_ui->isLocked());
|
||||
|
||||
// Set the lock object with a different owner than the mocked account above.
|
||||
$lock = (object) array(
|
||||
$lock = (object) [
|
||||
'owner' => 2,
|
||||
'data' => array(),
|
||||
'data' => [],
|
||||
'updated' => (int) $_SERVER['REQUEST_TIME'],
|
||||
);
|
||||
];
|
||||
$view_ui->lock = $lock;
|
||||
$this->assertTrue($view_ui->isLocked());
|
||||
|
||||
// Set a different lock object with the same object as the mocked account.
|
||||
$lock = (object) array(
|
||||
$lock = (object) [
|
||||
'owner' => 1,
|
||||
'data' => array(),
|
||||
'data' => [],
|
||||
'updated' => (int) $_SERVER['REQUEST_TIME'],
|
||||
);
|
||||
];
|
||||
$view_ui->lock = $lock;
|
||||
$this->assertFalse($view_ui->isLocked());
|
||||
}
|
||||
|
|
|
@ -19,15 +19,15 @@ function views_ui_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.views_ui':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Views UI module provides an interface for managing views for the <a href=":views">Views module</a>. For more information, see the <a href=":handbook">online documentation for the Views UI module</a>.', array(':views' => \Drupal::url('help.page', array('name' => 'views')), ':handbook' => 'https://www.drupal.org/documentation/modules/views_ui')) . '</p>';
|
||||
$output .= '<p>' . t('The Views UI module provides an interface for managing views for the <a href=":views">Views module</a>. For more information, see the <a href=":handbook">online documentation for the Views UI module</a>.', [':views' => \Drupal::url('help.page', ['name' => 'views']), ':handbook' => 'https://www.drupal.org/documentation/modules/views_ui']) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Creating and managing views') . '</dt>';
|
||||
$output .= '<dd>' . t('Views can be created from the <a href=":list">Views list page</a> by using the "Add view" action. Existing views can be managed from the <a href=":list">Views list page</a> by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".', array(':list' => \Drupal::url('entity.view.collection', array('name' => 'views_ui')))) . '</dd>';
|
||||
$output .= '<dd>' . t('Views can be created from the <a href=":list">Views list page</a> by using the "Add view" action. Existing views can be managed from the <a href=":list">Views list page</a> by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".', [':list' => \Drupal::url('entity.view.collection', ['name' => 'views_ui'])]) . '</dd>';
|
||||
$output .= '<dt>' . t('Enabling and disabling views') . '<dt>';
|
||||
$output .= '<dd>' . t('Views can be enabled or disabled from the <a href=":list">Views list page</a>. To enable a view, find the view within the "Disabled" list and select the "Enable" operation. To disable a view find the view within the "Enabled" list and select the "Disable" operation.', array(':list' => \Drupal::url('entity.view.collection', array('name' => 'views_ui')))) . '</dd>';
|
||||
$output .= '<dd>' . t('Views can be enabled or disabled from the <a href=":list">Views list page</a>. To enable a view, find the view within the "Disabled" list and select the "Enable" operation. To disable a view find the view within the "Enabled" list and select the "Disable" operation.', [':list' => \Drupal::url('entity.view.collection', ['name' => 'views_ui'])]) . '</dd>';
|
||||
$output .= '<dt>' . t('Exporting and importing views') . '</dt>';
|
||||
$output .= '<dd>' . t('Views can be exported and imported as configuration files by using the <a href=":config">Configuration Manager module</a>.', array(':config' => (\Drupal::moduleHandler()->moduleExists('config')) ? \Drupal::url('help.page', array('name' => 'config')) : '#')) . '</dd>';
|
||||
$output .= '<dd>' . t('Views can be exported and imported as configuration files by using the <a href=":config">Configuration Manager module</a>.', [':config' => (\Drupal::moduleHandler()->moduleExists('config')) ? \Drupal::url('help.page', ['name' => 'config']) : '#']) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
}
|
||||
|
@ -61,56 +61,69 @@ function views_ui_entity_type_build(array &$entity_types) {
|
|||
* Implements hook_theme().
|
||||
*/
|
||||
function views_ui_theme() {
|
||||
return array(
|
||||
return [
|
||||
// edit a view
|
||||
'views_ui_display_tab_setting' => array(
|
||||
'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()),
|
||||
'views_ui_display_tab_setting' => [
|
||||
'variables' => ['description' => '', 'link' => '', 'settings_links' => [], 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => []],
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
'views_ui_display_tab_bucket' => array(
|
||||
],
|
||||
'views_ui_display_tab_bucket' => [
|
||||
'render element' => 'element',
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
'views_ui_rearrange_filter_form' => array(
|
||||
],
|
||||
'views_ui_rearrange_filter_form' => [
|
||||
'render element' => 'form',
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
'views_ui_expose_filter_form' => array(
|
||||
],
|
||||
'views_ui_expose_filter_form' => [
|
||||
'render element' => 'form',
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
],
|
||||
|
||||
// list views
|
||||
'views_ui_view_info' => array(
|
||||
'variables' => array('view' => NULL, 'displays' => NULL),
|
||||
// Legacy theme hook for displaying views info.
|
||||
'views_ui_view_info' => [
|
||||
'variables' => ['view' => NULL, 'displays' => NULL],
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
],
|
||||
|
||||
// List views.
|
||||
'views_ui_views_listing_table' => [
|
||||
'variables' => [
|
||||
'headers' => NULL,
|
||||
'rows' => NULL,
|
||||
'attributes' => [],
|
||||
],
|
||||
'file' => 'views_ui.theme.inc',
|
||||
],
|
||||
'views_ui_view_displays_list' => [
|
||||
'variables' => ['displays' => []],
|
||||
],
|
||||
|
||||
// Group of filters.
|
||||
'views_ui_build_group_filter_form' => array(
|
||||
'views_ui_build_group_filter_form' => [
|
||||
'render element' => 'form',
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
],
|
||||
|
||||
// On behalf of a plugin
|
||||
'views_ui_style_plugin_table' => array(
|
||||
'views_ui_style_plugin_table' => [
|
||||
'render element' => 'form',
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
],
|
||||
|
||||
// When previewing a view.
|
||||
'views_ui_view_preview_section' => array(
|
||||
'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''),
|
||||
'views_ui_view_preview_section' => [
|
||||
'variables' => ['view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''],
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
],
|
||||
|
||||
// Generic container wrapper, to use instead of theme_container when an id
|
||||
// is not desired.
|
||||
'views_ui_container' => array(
|
||||
'variables' => array('children' => NULL, 'attributes' => array()),
|
||||
'views_ui_container' => [
|
||||
'variables' => ['children' => NULL, 'attributes' => []],
|
||||
'file' => 'views_ui.theme.inc',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,16 +141,16 @@ function views_ui_preprocess_views_view(&$variables) {
|
|||
|
||||
if (!empty($view->live_preview) && \Drupal::moduleHandler()->moduleExists('contextual')) {
|
||||
$view->setShowAdminLinks(FALSE);
|
||||
foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) {
|
||||
foreach (['title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before'] as $section) {
|
||||
if (!empty($variables[$section])) {
|
||||
$variables[$section] = array(
|
||||
$variables[$section] = [
|
||||
'#theme' => 'views_ui_view_preview_section',
|
||||
'#view' => $view,
|
||||
'#section' => $section,
|
||||
'#content' => $variables[$section],
|
||||
'#theme_wrappers' => array('views_ui_container'),
|
||||
'#attributes' => array('class' => array('contextual-region')),
|
||||
);
|
||||
'#theme_wrappers' => ['views_ui_container'],
|
||||
'#attributes' => ['class' => ['contextual-region']],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,28 +169,28 @@ function views_ui_preprocess_views_view(&$variables) {
|
|||
function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type, $title = FALSE) {
|
||||
$display = $view->display_handler->display;
|
||||
$handlers = $view->display_handler->getHandlers($type);
|
||||
$links = array();
|
||||
$links = [];
|
||||
|
||||
$types = ViewExecutable::getHandlerTypes();
|
||||
if ($title) {
|
||||
$links[$type . '-title'] = array(
|
||||
$links[$type . '-title'] = [
|
||||
'title' => $types[$type]['title'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($handlers as $id => $handler) {
|
||||
$field_name = $handler->adminLabel(TRUE);
|
||||
$links[$type . '-edit-' . $id] = array(
|
||||
'title' => t('Edit @section', array('@section' => $field_name)),
|
||||
$links[$type . '-edit-' . $id] = [
|
||||
'title' => t('Edit @section', ['@section' => $field_name]),
|
||||
'url' => Url::fromRoute('views_ui.form_handler', ['js' => 'nojs', 'view' => $view->storage->id(), 'display_id' => $display['id'], 'type' => $type, 'id' => $id]),
|
||||
'attributes' => array('class' => array('views-ajax-link')),
|
||||
);
|
||||
'attributes' => ['class' => ['views-ajax-link']],
|
||||
];
|
||||
}
|
||||
$links[$type . '-add'] = array(
|
||||
$links[$type . '-add'] = [
|
||||
'title' => t('Add new'),
|
||||
'url' => Url::fromRoute('views_ui.form_add_handler', ['js' => 'nojs', 'view' => $view->storage->id(), 'display_id' => $display['id'], 'type' => $type]),
|
||||
'attributes' => array('class' => array('views-ajax-link')),
|
||||
);
|
||||
'attributes' => ['class' => ['views-ajax-link']],
|
||||
];
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
@ -187,13 +200,13 @@ function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type
|
|||
*/
|
||||
function views_ui_view_preview_section_display_category_links(ViewExecutable $view, $type, $title) {
|
||||
$display = $view->display_handler->display;
|
||||
$links = array(
|
||||
$type . '-edit' => array(
|
||||
'title' => t('Edit @section', array('@section' => $title)),
|
||||
$links = [
|
||||
$type . '-edit' => [
|
||||
'title' => t('Edit @section', ['@section' => $title]),
|
||||
'url' => Url::fromRoute('views_ui.form_display', ['js' => 'nojs', 'view' => $view->storage->id(), 'display_id' => $display['id'], 'type' => $type]),
|
||||
'attributes' => array('class' => array('views-ajax-link')),
|
||||
),
|
||||
);
|
||||
'attributes' => ['class' => ['views-ajax-link']],
|
||||
],
|
||||
];
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
@ -202,7 +215,7 @@ function views_ui_view_preview_section_display_category_links(ViewExecutable $vi
|
|||
* Returns all contextual links for the main content part of the view.
|
||||
*/
|
||||
function views_ui_view_preview_section_rows_links(ViewExecutable $view) {
|
||||
$links = array();
|
||||
$links = [];
|
||||
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE));
|
||||
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE));
|
||||
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'sort', TRUE));
|
||||
|
@ -220,10 +233,10 @@ function views_ui_views_plugins_display_alter(&$plugins) {
|
|||
// paths underneath "admin/structure/views/view/{$view->id()}" (i.e., paths
|
||||
// for editing and performing other contextual actions on the view).
|
||||
foreach ($plugins as &$display) {
|
||||
$display['contextual links']['entity.view.edit_form'] = array(
|
||||
$display['contextual links']['entity.view.edit_form'] = [
|
||||
'route_name' => 'entity.view.edit_form',
|
||||
'route_parameters_names' => array('view' => 'id'),
|
||||
);
|
||||
'route_parameters_names' => ['view' => 'id'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +247,7 @@ function views_ui_contextual_links_view_alter(&$element, $items) {
|
|||
// Remove contextual links from being rendered, when so desired, such as
|
||||
// within a View preview.
|
||||
if (views_ui_contextual_links_suppress()) {
|
||||
$element['#links'] = array();
|
||||
$element['#links'] = [];
|
||||
}
|
||||
// Append the display ID to the Views UI edit links, so that clicking on the
|
||||
// contextual link takes you directly to the correct display tab on the edit
|
||||
|
@ -292,7 +305,7 @@ function views_ui_contextual_links_suppress_pop() {
|
|||
* node.views.inc as well.
|
||||
*/
|
||||
function views_ui_views_analyze(ViewExecutable $view) {
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
// Check for something other than the default display:
|
||||
if (count($view->displayHandlers) < 2) {
|
||||
$ret[] = Analyzer::formatMessage(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning');
|
||||
|
@ -307,7 +320,7 @@ function views_ui_views_analyze(ViewExecutable $view) {
|
|||
if ($display->hasPath() && $path = $display->getOption('path')) {
|
||||
$normal_path = \Drupal::service('path.alias_manager')->getPathByAlias($path);
|
||||
if ($path != $normal_path) {
|
||||
$ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display->display['display_title'])), 'warning');
|
||||
$ret[] = Analyzer::formatMessage(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', ['%display' => $display->display['display_title']]), 'warning');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use Drupal\Core\Render\Element;
|
|||
use Drupal\Core\Render\Element\Checkboxes;
|
||||
use Drupal\Core\Render\Element\Radios;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
|
||||
/**
|
||||
* Prepares variables for Views UI display tab setting templates.
|
||||
|
@ -42,6 +43,31 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for Views UI view listing templates.
|
||||
*
|
||||
* Default template: views-ui-view-listing-table.html.twig.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - headers: An associative array containing the headers for the view
|
||||
* listing table.
|
||||
* - rows: An associative array containing the rows data for the view
|
||||
* listing table.
|
||||
*/
|
||||
function template_preprocess_views_ui_views_listing_table(&$variables) {
|
||||
// Convert the attributes to valid attribute objects.
|
||||
foreach ($variables['headers'] as $key => $header) {
|
||||
$variables['headers'][$key]['attributes'] = new Attribute($header['#attributes']);
|
||||
}
|
||||
|
||||
if (!empty($variables['rows'])) {
|
||||
foreach ($variables['rows'] as $key => $row) {
|
||||
$variables['rows'][$key]['attributes'] = new Attribute($row['#attributes']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for Views UI display tab bucket templates.
|
||||
*
|
||||
|
@ -63,7 +89,7 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) {
|
|||
$variables['overridden'] = isset($element['#overridden']) ? $element['#overridden'] : NULL;
|
||||
$variables['content'] = $element['#children'];
|
||||
$variables['title'] = $element['#title'];
|
||||
$variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : array();
|
||||
$variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,14 +105,14 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
|
|||
$form = $variables['form'];
|
||||
|
||||
// Prepare table of options.
|
||||
$header = array(
|
||||
$header = [
|
||||
t('Default'),
|
||||
t('Weight'),
|
||||
t('Label'),
|
||||
t('Operator'),
|
||||
t('Value'),
|
||||
t('Operations'),
|
||||
);
|
||||
];
|
||||
|
||||
// Prepare default selectors.
|
||||
$form_state = new FormState();
|
||||
|
@ -94,15 +120,15 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
|
|||
$form['default_group_multiple'] = Checkboxes::processCheckboxes($form['default_group_multiple'], $form_state, $form);
|
||||
$form['default_group']['All']['#title'] = '';
|
||||
|
||||
$rows[] = array(
|
||||
$rows[] = [
|
||||
['data' => $form['default_group']['All']],
|
||||
'',
|
||||
array(
|
||||
[
|
||||
'data' => \Drupal::config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? t('<Any>') : t('- Any -'),
|
||||
'colspan' => 4,
|
||||
'class' => array('class' => 'any-default-radios-row'),
|
||||
),
|
||||
);
|
||||
'class' => ['class' => 'any-default-radios-row'],
|
||||
],
|
||||
];
|
||||
// Remove the 'All' default_group form element because it's added to the
|
||||
// table row.
|
||||
unset($variables['form']['default_group']['All']);
|
||||
|
@ -135,32 +161,32 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
|
|||
'#title' => SafeMarkup::format('<span>@text</span>', ['@text' => t('Remove')]),
|
||||
];
|
||||
$remove = [$form['group_items'][$group_id]['remove'], $link];
|
||||
$data = array(
|
||||
$data = [
|
||||
'default' => ['data' => $default],
|
||||
'weight' => ['data' => $form['group_items'][$group_id]['weight']],
|
||||
'title' => ['data' => $form['group_items'][$group_id]['title']],
|
||||
'operator' => ['data' => $form['group_items'][$group_id]['operator']],
|
||||
'value' => ['data' => $form['group_items'][$group_id]['value']],
|
||||
'remove' => ['data' => $remove],
|
||||
);
|
||||
$rows[] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable'));
|
||||
];
|
||||
$rows[] = ['data' => $data, 'id' => 'views-row-' . $group_id, 'class' => ['draggable']];
|
||||
}
|
||||
$variables['table'] = array(
|
||||
$variables['table'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#attributes' => array(
|
||||
'class' => array('views-filter-groups'),
|
||||
'#attributes' => [
|
||||
'class' => ['views-filter-groups'],
|
||||
'id' => 'views-filter-groups',
|
||||
),
|
||||
'#tabledrag' => array(
|
||||
array(
|
||||
],
|
||||
'#tabledrag' => [
|
||||
[
|
||||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
)
|
||||
),
|
||||
);
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
// Hide fields used in table.
|
||||
unset($variables['form']['group_items']);
|
||||
|
@ -177,7 +203,7 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
|
|||
*/
|
||||
function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
|
||||
$form = &$variables['form'];
|
||||
$rows = $ungroupable_rows = array();
|
||||
$rows = $ungroupable_rows = [];
|
||||
// Enable grouping only if > 1 group.
|
||||
$variables['grouping'] = count(array_keys($form['#group_options'])) > 1;
|
||||
|
||||
|
@ -186,41 +212,41 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
|
|||
if ($group_id !== 'ungroupable') {
|
||||
// Set up tabledrag so that it changes the group dropdown when rows are
|
||||
// dragged between groups.
|
||||
$options = array(
|
||||
$options = [
|
||||
'table_id' => 'views-rearrange-filters',
|
||||
'action' => 'match',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'views-group-select',
|
||||
'subgroup' => 'views-group-select-' . $group_id,
|
||||
);
|
||||
];
|
||||
drupal_attach_tabledrag($form['override'], $options);
|
||||
|
||||
// Title row, spanning all columns.
|
||||
$row = array();
|
||||
$row = [];
|
||||
// Add a cell to the first row, containing the group operator.
|
||||
$row[] = array(
|
||||
'class' => array('group', 'group-operator', 'container-inline'),
|
||||
$row[] = [
|
||||
'class' => ['group', 'group-operator', 'container-inline'],
|
||||
'data' => $form['filter_groups']['groups'][$group_id],
|
||||
'rowspan' => max(array(2, count($contents) + 1)),
|
||||
);
|
||||
'rowspan' => max([2, count($contents) + 1]),
|
||||
];
|
||||
// Title.
|
||||
$row[] = array(
|
||||
'class' => array('group', 'group-title'),
|
||||
'data' => array(
|
||||
$row[] = [
|
||||
'class' => ['group', 'group-title'],
|
||||
'data' => [
|
||||
'#prefix' => '<span>',
|
||||
'#markup' => $form['#group_options'][$group_id],
|
||||
'#suffix' => '</span>',
|
||||
),
|
||||
],
|
||||
'colspan' => 4,
|
||||
);
|
||||
$rows[] = array(
|
||||
'class' => array('views-group-title'),
|
||||
];
|
||||
$rows[] = [
|
||||
'class' => ['views-group-title'],
|
||||
'data' => $row,
|
||||
'id' => 'views-group-title-' . $group_id,
|
||||
);
|
||||
];
|
||||
|
||||
// Row which will only appear if the group has nothing in it.
|
||||
$row = array();
|
||||
$row = [];
|
||||
$class = 'group-' . (count($contents) ? 'populated' : 'empty');
|
||||
$instructions = '<span>' . t('No filters have been added.') . '</span> <span class="js-only">' . t('Drag to add filters.') . '</span>';
|
||||
// When JavaScript is enabled, the button for removing the group (if it's
|
||||
|
@ -229,63 +255,63 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
|
|||
if (!empty($form['remove_groups'][$group_id]['#type']) && $form['remove_groups'][$group_id]['#type'] == 'submit') {
|
||||
$form['remove_groups'][$group_id]['#attributes']['class'][] = 'js-hide';
|
||||
}
|
||||
$row[] = array(
|
||||
$row[] = [
|
||||
'colspan' => 5,
|
||||
'data' => array(
|
||||
array('#markup' => $instructions),
|
||||
'data' => [
|
||||
['#markup' => $instructions],
|
||||
$form['remove_groups'][$group_id],
|
||||
),
|
||||
);
|
||||
$rows[] = array(
|
||||
'class' => array(
|
||||
],
|
||||
];
|
||||
$rows[] = [
|
||||
'class' => [
|
||||
'group-message',
|
||||
'group-' . $group_id . '-message',
|
||||
$class,
|
||||
),
|
||||
],
|
||||
'data' => $row,
|
||||
'id' => 'views-group-' . $group_id,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($contents as $id) {
|
||||
if (isset($form['filters'][$id]['name'])) {
|
||||
$row = array();
|
||||
$row = [];
|
||||
$row[]['data'] = $form['filters'][$id]['name'];
|
||||
$form['filters'][$id]['weight']['#attributes']['class'] = array('weight');
|
||||
$form['filters'][$id]['weight']['#attributes']['class'] = ['weight'];
|
||||
$row[]['data'] = $form['filters'][$id]['weight'];
|
||||
$form['filters'][$id]['group']['#attributes']['class'] = array('views-group-select views-group-select-' . $group_id);
|
||||
$form['filters'][$id]['group']['#attributes']['class'] = ['views-group-select views-group-select-' . $group_id];
|
||||
$row[]['data'] = $form['filters'][$id]['group'];
|
||||
$form['filters'][$id]['removed']['#attributes']['class'][] = 'js-hide';
|
||||
|
||||
$remove_link = array(
|
||||
$remove_link = [
|
||||
'#type' => 'link',
|
||||
'#url' => Url::fromRoute('<none>'),
|
||||
'#title' => SafeMarkup::format('<span>@text</span>', array('@text' => t('Remove'))),
|
||||
'#title' => SafeMarkup::format('<span>@text</span>', ['@text' => t('Remove')]),
|
||||
'#weight' => '1',
|
||||
'#options' => array(
|
||||
'attributes' => array(
|
||||
'#options' => [
|
||||
'attributes' => [
|
||||
'id' => 'views-remove-link-' . $id,
|
||||
'class' => array(
|
||||
'class' => [
|
||||
'views-hidden',
|
||||
'views-button-remove',
|
||||
'views-groups-remove-link',
|
||||
'views-remove-link',
|
||||
),
|
||||
],
|
||||
'alt' => t('Remove this item'),
|
||||
'title' => t('Remove this item'),
|
||||
),
|
||||
),
|
||||
);
|
||||
$row[]['data'] = array(
|
||||
],
|
||||
],
|
||||
];
|
||||
$row[]['data'] = [
|
||||
$form['filters'][$id]['removed'],
|
||||
$remove_link,
|
||||
);
|
||||
];
|
||||
|
||||
$row = array(
|
||||
$row = [
|
||||
'data' => $row,
|
||||
'class' => array('draggable'),
|
||||
'class' => ['draggable'],
|
||||
'id' => 'views-row-' . $id,
|
||||
);
|
||||
];
|
||||
|
||||
if ($group_id !== 'ungroupable') {
|
||||
$rows[] = $row;
|
||||
|
@ -302,56 +328,56 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
|
|||
}
|
||||
|
||||
if (!empty($ungroupable_rows)) {
|
||||
$header = array(
|
||||
$header = [
|
||||
t('Ungroupable filters'),
|
||||
t('Weight'),
|
||||
array(
|
||||
[
|
||||
'data' => t('Group'),
|
||||
'class' => array('views-hide-label'),
|
||||
),
|
||||
array(
|
||||
'class' => ['views-hide-label'],
|
||||
],
|
||||
[
|
||||
'data' => t('Remove'),
|
||||
'class' => array('views-hide-label'),
|
||||
),
|
||||
);
|
||||
$variables['ungroupable_table'] = array(
|
||||
'class' => ['views-hide-label'],
|
||||
],
|
||||
];
|
||||
$variables['ungroupable_table'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $ungroupable_rows,
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'views-rearrange-filters-ungroupable',
|
||||
'class' => array('arrange'),
|
||||
),
|
||||
'#tabledrag' => array(
|
||||
array(
|
||||
'class' => ['arrange'],
|
||||
],
|
||||
'#tabledrag' => [
|
||||
[
|
||||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
)
|
||||
),
|
||||
);
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($rows)) {
|
||||
$rows[] = array(array('data' => t('No fields available.'), 'colspan' => '2'));
|
||||
$rows[] = [['data' => t('No fields available.'), 'colspan' => '2']];
|
||||
}
|
||||
|
||||
// Set up tabledrag so that the weights are changed when rows are dragged.
|
||||
$variables['table'] = array(
|
||||
$variables['table'] = [
|
||||
'#type' => 'table',
|
||||
'#rows' => $rows,
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'id' => 'views-rearrange-filters',
|
||||
'class' => array('arrange'),
|
||||
),
|
||||
'#tabledrag' => array(
|
||||
array(
|
||||
'class' => ['arrange'],
|
||||
],
|
||||
'#tabledrag' => [
|
||||
[
|
||||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// When JavaScript is enabled, the button for adding a new group should be
|
||||
// hidden, since it will be replaced by a link on the client side.
|
||||
|
@ -371,72 +397,72 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
|
|||
function template_preprocess_views_ui_style_plugin_table(&$variables) {
|
||||
$form = $variables['form'];
|
||||
|
||||
$header = array(
|
||||
$header = [
|
||||
t('Field'),
|
||||
t('Column'),
|
||||
t('Align'),
|
||||
t('Separator'),
|
||||
array(
|
||||
[
|
||||
'data' => t('Sortable'),
|
||||
'align' => 'center',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'data' => t('Default order'),
|
||||
'align' => 'center',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'data' => t('Default sort'),
|
||||
'align' => 'center',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'data' => t('Hide empty column'),
|
||||
'align' => 'center',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'data' => t('Responsive'),
|
||||
'align' => 'center',
|
||||
),
|
||||
);
|
||||
$rows = array();
|
||||
],
|
||||
];
|
||||
$rows = [];
|
||||
foreach (Element::children($form['columns']) as $id) {
|
||||
$row = array();
|
||||
$row = [];
|
||||
$row[]['data'] = $form['info'][$id]['name'];
|
||||
$row[]['data'] = $form['columns'][$id];
|
||||
$row[]['data'] = $form['info'][$id]['align'];
|
||||
$row[]['data'] = $form['info'][$id]['separator'];
|
||||
|
||||
if (!empty($form['info'][$id]['sortable'])) {
|
||||
$row[] = array(
|
||||
$row[] = [
|
||||
'data' => $form['info'][$id]['sortable'],
|
||||
'align' => 'center',
|
||||
);
|
||||
$row[] = array(
|
||||
];
|
||||
$row[] = [
|
||||
'data' => $form['info'][$id]['default_sort_order'],
|
||||
'align' => 'center',
|
||||
);
|
||||
$row[] = array(
|
||||
];
|
||||
$row[] = [
|
||||
'data' => $form['default'][$id],
|
||||
'align' => 'center',
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$row[] = '';
|
||||
$row[] = '';
|
||||
$row[] = '';
|
||||
}
|
||||
$row[] = array(
|
||||
$row[] = [
|
||||
'data' => $form['info'][$id]['empty_column'],
|
||||
'align' => 'center',
|
||||
);
|
||||
$row[] = array(
|
||||
];
|
||||
$row[] = [
|
||||
'data' => $form['info'][$id]['responsive'],
|
||||
'align' => 'center',
|
||||
);
|
||||
];
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
// Add the special 'None' row.
|
||||
$rows[] = array(array('data' => t('None'), 'colspan' => 6), array('align' => 'center', 'data' => $form['default'][-1]), array('colspan' => 2));
|
||||
$rows[] = [['data' => t('None'), 'colspan' => 6], ['align' => 'center', 'data' => $form['default'][-1]], ['colspan' => 2]];
|
||||
|
||||
// Unset elements from the form array that are used to build the table so that
|
||||
// they are not rendered twice.
|
||||
|
@ -444,12 +470,12 @@ function template_preprocess_views_ui_style_plugin_table(&$variables) {
|
|||
unset($form['info']);
|
||||
unset($form['columns']);
|
||||
|
||||
$variables['table'] = array(
|
||||
$variables['table'] = [
|
||||
'#type' => 'table',
|
||||
'#theme' => 'table__views_ui_style_plugin_table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
);
|
||||
];
|
||||
$variables['form'] = $form;
|
||||
}
|
||||
|
||||
|
@ -510,14 +536,14 @@ function template_preprocess_views_ui_view_preview_section(&$variables) {
|
|||
}
|
||||
|
||||
if (isset($links)) {
|
||||
$build = array(
|
||||
$build = [
|
||||
'#theme' => 'links__contextual',
|
||||
'#links' => $links,
|
||||
'#attributes' => array('class' => array('contextual-links')),
|
||||
'#attached' => array(
|
||||
'library' => array('contextual/drupal.contextual-links'),
|
||||
),
|
||||
);
|
||||
'#attributes' => ['class' => ['contextual-links']],
|
||||
'#attached' => [
|
||||
'library' => ['contextual/drupal.contextual-links'],
|
||||
],
|
||||
];
|
||||
$variables['links'] = $build;
|
||||
}
|
||||
}
|
||||
|
@ -526,5 +552,5 @@ function template_preprocess_views_ui_view_preview_section(&$variables) {
|
|||
* Implements hook_theme_suggestions_HOOK().
|
||||
*/
|
||||
function views_ui_theme_suggestions_views_ui_view_preview_section(array $variables) {
|
||||
return array('views_ui_view_preview_section__' . $variables['section']);
|
||||
return ['views_ui_view_preview_section__' . $variables['section']];
|
||||
}
|
||||
|
|
Reference in a new issue