activated pathauto for url aliases

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-29 23:57:27 +02:00
parent 33a04c55b1
commit 4921e8189b
279 changed files with 30072 additions and 0 deletions
@@ -0,0 +1,28 @@
block.settings.entity_field:*:*:
type: block_settings
label: 'Entity field block'
mapping:
formatter:
type: mapping
label: 'Field formatter'
mapping:
type:
type: string
label: 'Format type machine name'
weight:
type: integer
label: 'Weight'
region:
type: string
label: 'Region'
label:
type: string
label: 'Label setting machine name'
settings:
type: field.formatter.settings.[%parent.type]
label: 'Settings'
third_party_settings:
type: sequence
label: 'Third party settings'
sequence:
type: field.formatter.third_party.[%key]
@@ -0,0 +1,14 @@
name: Chaos tools blocks
type: module
description: 'Provides improvements to blocks that will one day be added to Drupal core.'
package: Chaos tool suite (Experimental)
# version: 3.x
# core: 8.x
dependencies:
- ctools
# Information added by Drupal.org packaging script on 2017-04-28
version: '8.x-3.0'
core: '8.x'
project: 'ctools'
datestamp: 1493401747
@@ -0,0 +1,376 @@
<?php
namespace Drupal\ctools_block\Plugin\Block;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Field\FormatterPluginManager;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\ContextAwarePluginInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a block to a field on an entity.
*
* @Block(
* id = "entity_field",
* deriver = "Drupal\ctools_block\Plugin\Deriver\EntityFieldDeriver",
* )
*/
class EntityField extends BlockBase implements ContextAwarePluginInterface, ContainerFactoryPluginInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected $entityFieldManager;
/**
* The field type manager.
*
* @var \Drupal\Core\Field\FieldTypePluginManagerInterface
*/
protected $fieldTypeManager;
/**
* The formatter manager.
*
* @var \Drupal\Core\Field\FormatterPluginManager
*/
protected $formatterManager;
/**
* The entity type id.
*
* @var string
*/
protected $entityTypeId;
/**
* The field name.
*
* @var string
*/
protected $fieldName;
/**
* The field definition.
*
* @var \Drupal\Core\Field\FieldDefinitionInterface
*/
protected $fieldDefinition;
/**
* The field storage definition.
*
* @var \Drupal\Core\Field\FieldStorageDefinitionInterface
*/
protected $fieldStorageDefinition;
/**
* Constructs a new EntityField.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager.
* @param \Drupal\Core\Field\FormatterPluginManager $formatter_manager
* The formatter manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, FormatterPluginManager $formatter_manager) {
$this->entityTypeManager = $entity_type_manager;
$this->entityFieldManager = $entity_field_manager;
$this->fieldTypeManager = $field_type_manager;
$this->formatterManager = $formatter_manager;
// Get the entity type and field name from the plugin id.
list (, $entity_type_id, $field_name) = explode(':', $plugin_id);
$this->entityTypeId = $entity_type_id;
$this->fieldName = $field_name;
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity_type.manager'),
$container->get('entity_field.manager'),
$container->get('plugin.manager.field.field_type'),
$container->get('plugin.manager.field.formatter')
);
}
/**
* {@inheritdoc}
*/
public function build() {
/** @var \Drupal\Core\Entity\FieldableEntityInterface $entity */
$entity = $this->getContextValue('entity');
$build = [];
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
$field = $entity->{$this->fieldName};
$display_settings = $this->getConfiguration()['formatter'];
$build['field'] = $field->view($display_settings);
// Set the cache data appropriately.
$build['#cache']['contexts'] = $this->getCacheContexts();
$build['#cache']['tags'] = $this->getCacheTags();
$build['#cache']['max-age'] = $this->getCacheMaxAge();
return $build;
}
/**
* {@inheritdoc}
*/
protected function blockAccess(AccountInterface $account) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = $this->getContextValue('entity');
// Make sure we have access to the entity.
$access = $entity->access('view', $account, TRUE);
if ($access->isAllowed()) {
// Check that the entity in question has this field.
if ($entity instanceof FieldableEntityInterface && $entity->hasField($this->fieldName)) {
// Check field access.
$field_access = $this->entityTypeManager
->getAccessControlHandler($this->entityTypeId)
->fieldAccess('view', $this->getFieldDefinition(), $account);
if ($field_access) {
// Build a renderable array for the field.
$build = $entity->get($this->fieldName)->view($this->configuration['formatter']);
// If there are actual renderable children, grant access.
if (Element::children($build)) {
return AccessResult::allowed();
}
}
}
// Entity doesn't have this field, so access is denied.
return AccessResult::forbidden();
}
// If we don't have access to the entity, return the forbidden result.
return $access;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$field_type_definition = $this->getFieldTypeDefinition();
return [
'formatter' => [
'label' => 'above',
'type' => $field_type_definition['default_formatter'] ?: '',
'settings' => [],
'third_party_settings' => [],
'weight' => 0,
],
];
}
/**
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state) {
$config = $this->getConfiguration();
$form['formatter_label'] = [
'#type' => 'select',
'#title' => $this->t('Label'),
'#options' => [
'above' => $this->t('Above'),
'inline' => $this->t('Inline'),
'hidden' => '- ' . $this->t('Hidden') . ' -',
'visually_hidden' => '- ' . $this->t('Visually Hidden') . ' -',
],
'#default_value' => $config['formatter']['label'],
];
$form['formatter_type'] = [
'#type' => 'select',
'#title' => $this->t('Formatter'),
'#options' => $this->getFormatterOptions(),
'#default_value' => $config['formatter']['type'],
'#ajax' => [
'callback' => [static::class, 'formatterSettingsAjaxCallback'],
'wrapper' => 'formatter-settings-wrapper',
'effect' => 'fade',
],
];
// Add the formatter settings to the form via AJAX.
$form['#process'][] = [$this, 'formatterSettingsProcessCallback'];
$form['formatter_settings_wrapper'] = [
'#prefix' => '<div id="formatter-settings-wrapper">',
'#suffix' => '</div>',
];
$form['formatter_settings_wrapper']['formatter_settings'] = [
'#tree' => TRUE,
// The settings from the formatter plugin will be added in the
// ::formatterSettingsProcessCallback method.
];
return $form;
}
/**
* Render API callback: builds the formatter settings elements.
*/
public function formatterSettingsProcessCallback(array &$element, FormStateInterface $form_state, array &$complete_form) {
$config = $this->getConfiguration();
$parents_base = $element['#parents'];
$formatter_parent = array_merge($parents_base, ['formatter_type']);
$formatter_settings_parent = array_merge($parents_base, ['formatter_settings']);
$settings_element = &$element['formatter_settings_wrapper']['formatter_settings'];
// Set the #parents on the formatter_settings so they end up as a peer to
// formatter_type.
$settings_element['#parents'] = $formatter_settings_parent;
// Get the formatter name in a way that works regardless of whether we're
// getting the value via AJAX or not.
$formatter_name = NestedArray::getValue($form_state->getUserInput(), $formatter_parent) ?: $element['formatter_type']['#default_value'];
// Place the formatter settings on the form if a formatter is selected.
$formatter = $this->getFormatter($formatter_name, $form_state->getValue('formatter_label'), $form_state->getValue($formatter_settings_parent, $config['formatter']['settings']), $config['formatter']['third_party_settings']);
$settings_element = array_merge($formatter->settingsForm($settings_element, $form_state), $settings_element);
// Store the array parents for our element so that we can use it to pull out
// the formatter settings in our AJAX callback.
$complete_form['#formatter_array_parents'] = $element['#array_parents'];
return $element;
}
/**
* Render API callback: gets the layout settings elements.
*/
public static function formatterSettingsAjaxCallback(array $form, FormStateInterface $form_state) {
$formatter_array_parents = $form['#formatter_array_parents'];
return NestedArray::getValue($form, array_merge($formatter_array_parents, ['formatter_settings_wrapper']));
}
/**
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['formatter']['label'] = $form_state->getValue('formatter_label');
$this->configuration['formatter']['type'] = $form_state->getValue('formatter_type');
// @todo Remove this manual cast after https://www.drupal.org/node/2635236
// is resolved.
$this->configuration['formatter']['settings'] = (array) $form_state->getValue('formatter_settings');
}
/**
* Gets the field definition.
*
* @return \Drupal\Core\Field\FieldDefinitionInterface
*/
protected function getFieldDefinition() {
if (empty($this->fieldDefinition)) {
$field_map = $this->entityFieldManager->getFieldMap();
$bundle = reset($field_map[$this->entityTypeId][$this->fieldName]['bundles']);
$field_definitions = $this->entityFieldManager->getFieldDefinitions($this->entityTypeId, $bundle);
$this->fieldDefinition = $field_definitions[$this->fieldName];
}
return $this->fieldDefinition;
}
/**
* Gets the field storage definition.
*
* @return \Drupal\Core\Field\FieldStorageDefinitionInterface
*/
protected function getFieldStorageDefinition() {
if (empty($this->fieldStorageDefinition)) {
$field_definitions = $this->entityFieldManager->getFieldStorageDefinitions($this->entityTypeId);
$this->fieldStorageDefinition = $field_definitions[$this->fieldName];
}
return $this->fieldStorageDefinition;
}
/**
* Gets field type definition.
*
* @return array
* The field type definition.
*/
protected function getFieldTypeDefinition() {
return $this->fieldTypeManager->getDefinition($this->getFieldStorageDefinition()->getType());
}
/**
* Gets the formatter options for this field type.
*
* @return array
* The formatter options.
*/
protected function getFormatterOptions() {
return $this->formatterManager->getOptions($this->getFieldStorageDefinition()->getType());
}
/**
* Gets the formatter object.
*
* @param string $type
* The formatter name.
* @param string $label
* The label option for the formatter.
* @param array $settings
* The formatter settings.
* @param array $third_party_settings
* The formatter third party settings.
*
* @return \Drupal\Core\Field\FormatterInterface
* The formatter object.
*/
protected function getFormatter($type, $label, array $settings, array $third_party_settings) {
return $this->formatterManager->createInstance($type, [
'field_definition' => $this->getFieldDefinition(),
'view_mode' => 'default',
'prepare' => TRUE,
'label' => $label,
'settings' => $settings,
'third_party_settings' => $third_party_settings,
]);
}
public function __wakeup() {
parent::__wakeup();
// @todo figure out why this happens.
// prevent $fieldStorageDefinition being erroneously set to $this.
$this->fieldStorageDefinition = NULL;
}
}
@@ -0,0 +1,65 @@
<?php
namespace Drupal\ctools_block\Plugin\Deriver;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\ctools\Plugin\Deriver\EntityDeriverBase;
/**
* Provides entity field block definitions for every field.
*/
class EntityFieldDeriver extends EntityDeriverBase {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$entity_type_labels = $this->entityManager->getEntityTypeLabels();
foreach ($this->entityManager->getFieldMap() as $entity_type_id => $entity_field_map) {
foreach ($this->entityManager->getFieldStorageDefinitions($entity_type_id) as $field_storage_definition) {
$field_name = $field_storage_definition->getName();
// The blocks are based on fields. However, we are looping through field
// storages for which no fields may exist. If that is the case, skip
// this field storage.
if (!isset($entity_field_map[$field_name])) {
continue;
}
$field_info = $entity_field_map[$field_name];
$derivative_id = $entity_type_id . ":" . $field_name;
// Get the admin label for both base and configurable fields.
if ($field_storage_definition->isBaseField()) {
$admin_label = $field_storage_definition->getLabel();
}
else {
// We take the field label used on the first bundle.
$first_bundle = reset($field_info['bundles']);
$bundle_field_definitions = $this->entityManager->getFieldDefinitions($entity_type_id, $first_bundle);
// The field storage config may exist, but it's possible that no
// fields are actually using it. If that's the case, skip to the next
// field.
if (empty($bundle_field_definitions[$field_name])) {
continue;
}
$admin_label = $bundle_field_definitions[$field_name]->getLabel();
}
// Set plugin definition for derivative.
$derivative = $base_plugin_definition;
$derivative['category'] = $this->t('@entity', ['@entity' => $entity_type_labels[$entity_type_id]]);
$derivative['admin_label'] = $admin_label;
$derivative['context'] = [
'entity' => new ContextDefinition('entity:' . $entity_type_id, $entity_type_labels[$entity_type_id], TRUE),
];
$this->derivatives[$derivative_id] = $derivative;
}
}
return $this->derivatives;
}
}
@@ -0,0 +1,23 @@
langcode: en
status: true
dependencies:
config:
- node.type.ctools_block_field_test
_core:
default_config_hash: hoRuk0InNhhRVGnhQ9hzifTXVz432i9hvPe-tVstUbc
id: node.ctools_block_field_test.promote
field_name: promote
entity_type: node
bundle: ctools_block_field_test
label: 'Promoted to front page'
description: ''
required: false
translatable: true
default_value:
-
value: 0
default_value_callback: ''
settings:
on_label: 'On'
off_label: 'Off'
field_type: boolean
@@ -0,0 +1,62 @@
langcode: en
status: true
dependencies:
config:
- field.field.node.ctools_block_field_test.body
- node.type.ctools_block_field_test
module:
- path
- text
_core:
default_config_hash: xpDeWNLzjX4dDB9YyBlO9y9FR4vHwMv0GKsuqDYy0Bc
id: node.ctools_block_field_test.default
targetEntityType: node
bundle: ctools_block_field_test
mode: default
content:
body:
type: text_textarea_with_summary
weight: 31
settings:
rows: 9
summary_rows: 3
placeholder: ''
third_party_settings: { }
created:
type: datetime_timestamp
weight: 10
settings: { }
third_party_settings: { }
path:
type: path
weight: 30
settings: { }
third_party_settings: { }
promote:
type: boolean_checkbox
settings:
display_label: true
weight: 15
third_party_settings: { }
sticky:
type: boolean_checkbox
settings:
display_label: true
weight: 16
third_party_settings: { }
title:
type: string_textfield
weight: -5
settings:
size: 60
placeholder: ''
third_party_settings: { }
uid:
type: entity_reference_autocomplete
weight: 5
settings:
match_operator: CONTAINS
size: 60
placeholder: ''
third_party_settings: { }
hidden: { }
@@ -0,0 +1,18 @@
langcode: en
status: true
dependencies:
config:
- field.field.node.ctools_block_field_test.body
- node.type.ctools_block_field_test
module:
- user
_core:
default_config_hash: clNnyw6fhh5SwIme5I_3zjbLv-PMfpY-JXofVAC3CV8
id: node.ctools_block_field_test.default
targetEntityType: node
bundle: ctools_block_field_test
mode: default
content: { }
hidden:
body: true
links: true
@@ -0,0 +1,27 @@
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
- field.field.node.ctools_block_field_test.body
- node.type.ctools_block_field_test
module:
- text
- user
_core:
default_config_hash: gQV5baI7pCIOBUtLkbJ1c2WJwM8CdlKiKOtLLIWnfy0
id: node.ctools_block_field_test.teaser
targetEntityType: node
bundle: ctools_block_field_test
mode: teaser
content:
body:
label: hidden
type: text_summary_or_trimmed
weight: 101
settings:
trim_length: 600
third_party_settings: { }
links:
weight: 100
hidden: { }
@@ -0,0 +1,23 @@
langcode: en
status: true
dependencies:
config:
- field.storage.node.body
- node.type.ctools_block_field_test
module:
- text
_core:
default_config_hash: fzUnwtwftRsgKExjpF6XdMqbUzP16ytkjQniBZl1Hqg
id: node.ctools_block_field_test.body
field_name: body
entity_type: node
bundle: ctools_block_field_test
label: Body
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
display_summary: true
field_type: text_with_summary
@@ -0,0 +1,37 @@
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_image
- node.type.ctools_block_field_test
module:
- image
id: node.ctools_block_field_test.field_image
field_name: field_image
entity_type: node
bundle: ctools_block_field_test
label: Image
description: ''
required: false
translatable: true
default_value: { }
default_value_callback: ''
settings:
file_directory: '[date:custom:Y]-[date:custom:m]'
file_extensions: 'png gif jpg jpeg'
max_filesize: ''
max_resolution: ''
min_resolution: ''
alt_field: true
title_field: false
alt_field_required: true
title_field_required: false
default_image:
uuid: null
alt: ''
title: ''
width: null
height: null
handler: 'default:file'
handler_settings: { }
field_type: image
@@ -0,0 +1,31 @@
langcode: en
status: true
dependencies:
module:
- file
- image
- node
id: node.field_image
field_name: field_image
entity_type: node
type: image
settings:
uri_scheme: public
default_image:
uuid: null
alt: ''
title: ''
width: null
height: null
target_type: file
display_field: false
display_default: false
module: image
locked: false
cardinality: 1
translatable: true
indexes:
target_id:
- target_id
persist_with_no_fields: false
custom_storage: false
@@ -0,0 +1,18 @@
langcode: en
status: true
dependencies:
module:
- menu_ui
third_party_settings:
menu_ui:
available_menus: { }
parent: ''
_core:
default_config_hash: hjC271ZF6B5XYgF6-F5Ak73sJiZWJRmSLsgk8S7Vo-8
name: 'CTools block field test'
type: ctools_block_field_test
description: 'A content type used for the ctools_block field tests.'
help: ''
new_revision: false
preview_mode: 0
display_submitted: false
@@ -0,0 +1,20 @@
name: 'Chaos tools blocks test'
type: module
description: 'Support module for Chaos tools blocks tests.'
# core: 8.x
package: Testing
# version: 8.0.1
dependencies:
- image
- menu_ui
- node
- path
- text
- user
features: true
# Information added by Drupal.org packaging script on 2017-04-28
version: '8.x-3.0'
core: '8.x'
project: 'ctools'
datestamp: 1493401747
@@ -0,0 +1,132 @@
<?php
namespace Drupal\Tests\ctools_block\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the entity field block.
*
* @group ctools_block
*/
class EntityFieldBlockTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['block', 'ctools_block', 'ctools_block_field_test'];
/**
* Tests using the node body field in a block.
*/
public function testBodyField() {
$block = $this->drupalPlaceBlock('entity_field:node:body', [
'formatter' => [
'type' => 'text_default',
],
'context_mapping' => [
'entity' => '@node.node_route_context:node',
],
]);
$node = $this->drupalCreateNode(['type' => 'ctools_block_field_test']);
$this->drupalGet('node/' . $node->id());
$assert = $this->assertSession();
$assert->pageTextContains($block->label());
$assert->pageTextContains($node->body->value);
$node->set('body', NULL)->save();
$this->getSession()->reload();
// The block should not appear if there is no value in the field.
$assert->pageTextNotContains($block->label());
}
/**
* Tests that empty image fields will still render their default value.
*/
public function testEmptyImageField() {
$source = \Drupal::moduleHandler()->getModule('image')->getPath() . '/sample.png';
file_unmanaged_copy($source, 'public://sample.png');
/** @var \Drupal\file\FileInterface $file */
$file = \Drupal::entityTypeManager()
->getStorage('file')
->create([
'uri' => 'public://sample.png',
]);
$file->save();
/** @var \Drupal\field\FieldConfigInterface $field */
$field = \Drupal::entityTypeManager()
->getStorage('field_config')
->load('node.ctools_block_field_test.field_image');
$settings = $field->getSettings();
$settings['default_image']['uuid'] = $file->uuid();
$field->set('settings', $settings)->save();
$this->drupalPlaceBlock('entity_field:node:field_image', [
'formatter' => [
'type' => 'image_image',
],
'context_mapping' => [
'entity' => '@node.node_route_context:node',
],
]);
$node = $this->drupalCreateNode(['type' => 'ctools_block_field_test']);
$this->drupalGet('node/' . $node->id());
$url = $file->getFileUri();
$url = file_create_url($url);
$url = file_url_transform_relative($url);
$this->assertSession()->responseContains('src="' . $url . '"');
}
/**
* Tests using the node uid base field in a block.
*/
public function testNodeBaseFields() {
$block = $this->drupalPlaceBlock('entity_field:node:title', [
'formatter' => [
'type' => 'string',
],
'context_mapping' => [
'entity' => '@node.node_route_context:node',
],
]);
$node = $this->drupalCreateNode(['type' => 'ctools_block_field_test', 'uid' => 1]);
$this->drupalGet('node/' . $node->id());
$assert = $this->assertSession();
$assert->pageTextContains($block->label());
$assert->pageTextContains($node->getTitle());
}
/**
* Tests that we are setting the render cache metadata correctly.
*/
public function testRenderCache() {
$this->drupalPlaceBlock('entity_field:node:body', [
'formatter' => [
'type' => 'text_default',
],
'context_mapping' => [
'entity' => '@node.node_route_context:node',
],
]);
$a = $this->drupalCreateNode(['type' => 'ctools_block_field_test']);
$b = $this->drupalCreateNode(['type' => 'ctools_block_field_test']);
$assert = $this->assertSession();
$this->drupalGet('node/' . $a->id());
$assert->pageTextContains($a->body->value);
$this->drupalGet('node/' . $b->id());
$assert->pageTextNotContains($a->body->value);
$assert->pageTextContains($b->body->value);
$text = 'This is my text. Are you not entertained?';
$a->body->value = $text;
$a->save();
$this->drupalGet('node/' . $a->id());
$assert->pageTextContains($text);
}
}
@@ -0,0 +1,15 @@
name: Chaos tools Views
type: module
description: 'A set of improvements to the core Views code that allows for greater control over Blocks.'
package: Chaos tool suite (Experimental)
# version: 3.x
# core: 8.x
dependencies:
- block
- views
# Information added by Drupal.org packaging script on 2017-04-28
version: '8.x-3.0'
core: '8.x'
project: 'ctools'
datestamp: 1493401747
@@ -0,0 +1,104 @@
<?php
use Drupal\views\Plugin\views\display\Block as CoreBlock;
use Drupal\ctools_views\Plugin\Display\Block;
/**
* Implements hook_views_plugins_display_alter().
*/
function ctools_views_views_plugins_display_alter(&$displays) {
if (!empty($displays['block']['class']) && $displays['block']['class'] == CoreBlock::class) {
$displays['block']['class'] = Block::class;
}
}
/**
* Implements hook_config_schema_info_alter().
*/
function ctools_views_config_schema_info_alter(&$definitions) {
// Add to the views block plugin schema.
$definitions['views_block']['mapping']['pager'] = [
'type' => 'string',
'label' => 'Pager type'
];
$definitions['views_block']['mapping']['fields'] = [
'type' => 'sequence',
'label' => 'Fields settings',
'sequence' => [
[
'type' => 'mapping',
'label' => 'Field settings',
'mapping' => [
'hide' => [
'type' => 'boolean',
'label' => 'Hide field',
],
'weight' => [
'type' => 'integer',
'label' => 'Field weight',
],
],
],
],
];
$definitions['views_block']['mapping']['filter'] = [
'type' => 'sequence',
'label' => 'Filters settings',
'sequence' => [
[
'type' => 'mapping',
'label' => 'Filter settings',
'mapping' => [
'type' => [
'type' => 'string',
'label' => 'Plugin id',
],
'disable' => [
'type' => 'boolean',
'label' => 'Disable filter',
],
],
],
],
];
$definitions['views_block']['mapping']['sort'] = [
'type' => 'sequence',
'label' => 'Sort settings',
'sequence' => [
[
'type' => 'string',
'label' => 'Sort order value',
],
],
];
$definitions['views_block']['mapping']['pager_offset'] = [
'type' => 'integer',
'label' => 'Pager offset'
];
// Add to the views block display plugin schema.
$definitions['views.display.block']['mapping']['allow']['mapping']['offset'] = [
'type' => 'string',
'label' => 'Pager offset',
];
$definitions['views.display.block']['mapping']['allow']['mapping']['pager'] = [
'type' => 'string',
'label' => 'Pager type',
];
$definitions['views.display.block']['mapping']['allow']['mapping']['hide_fields'] = [
'type' => 'string',
'label' => 'Hide fields',
];
$definitions['views.display.block']['mapping']['allow']['mapping']['sort_fields'] = [
'type' => 'string',
'label' => 'Sort fields',
];
$definitions['views.display.block']['mapping']['allow']['mapping']['disable_filters'] = [
'type' => 'string',
'label' => 'Disable filters',
];
$definitions['views.display.block']['mapping']['allow']['mapping']['configure_sorts'] = [
'type' => 'string',
'label' => 'Configure sorts',
];
}
@@ -0,0 +1,438 @@
<?php
namespace Drupal\ctools_views\Plugin\Display;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\Block\ViewsBlock;
use Drupal\views\Plugin\views\display\Block as CoreBlock;
use Drupal\views\Plugin\views\filter\InOperator;
/**
* Provides a Block display plugin that allows for greater control over Views
* block settings.
*/
class Block extends CoreBlock {
/**
* {@inheritdoc}
*/
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
$filtered_allow = array_filter($this->getOption('allow'));
$filter_options = [
'items_per_page' => $this->t('Items per page'),
'offset' => $this->t('Pager offset'),
'pager' => $this->t('Pager type'),
'hide_fields' => $this->t('Hide fields'),
'sort_fields' => $this->t('Reorder fields'),
'disable_filters' => $this->t('Disable filters'),
'configure_sorts' => $this->t('Configure sorts')
];
$filter_intersect = array_intersect_key($filter_options, $filtered_allow);
$options['allow'] = array(
'category' => 'block',
'title' => $this->t('Allow settings'),
'value' => empty($filtered_allow) ? $this->t('None') : implode(', ', $filter_intersect),
);
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$options = $form['allow']['#options'];
$options['offset'] = $this->t('Pager offset');
$options['pager'] = $this->t('Pager type');
$options['hide_fields'] = $this->t('Hide fields');
$options['sort_fields'] = $this->t('Reorder fields');
$options['disable_filters'] = $this->t('Disable filters');
$options['configure_sorts'] = $this->t('Configure sorts');
$form['allow']['#options'] = $options;
// Update the items_per_page if set.
$defaults = array_filter($form['allow']['#default_value']);
if (isset($defaults['items_per_page'])) {
$defaults['items_per_page'] = 'items_per_page';
}
$form['allow']['#default_value'] = $defaults;
}
/**
* {@inheritdoc}
*/
public function blockForm(ViewsBlock $block, array &$form, FormStateInterface $form_state) {
$form = parent::blockForm($block, $form, $form_state);
$allow_settings = array_filter($this->getOption('allow'));
$block_configuration = $block->getConfiguration();
// Modify "Items per page" block settings form.
if (!empty($allow_settings['items_per_page'])) {
// Items per page
$form['override']['items_per_page']['#type'] = 'number';
unset($form['override']['items_per_page']['#options']);
}
// Provide "Pager offset" block settings form.
if (!empty($allow_settings['offset'])) {
$form['override']['pager_offset'] = [
'#type' => 'number',
'#title' => $this->t('Pager offset'),
'#default_value' => isset($block_configuration['pager_offset']) ? $block_configuration['pager_offset'] : 0,
'#description' => $this->t('For example, set this to 3 and the first 3 items will not be displayed.'),
];
}
// Provide "Pager type" block settings form.
if (!empty($allow_settings['pager'])) {
$pager_options = [
'view' => $this->t('Inherit from view'),
'some' => $this->t('Display a specified number of items'),
'none' => $this->t('Display all items')
];
$form['override']['pager'] = [
'#type' => 'radios',
'#title' => $this->t('Pager'),
'#options' => $pager_options,
'#default_value' => isset($block_configuration['pager']) ? $block_configuration['pager'] : 'view'
];
}
// Provide "Hide fields" / "Reorder fields" block settings form.
if (!empty($allow_settings['hide_fields']) || !empty($allow_settings['sort_fields'])) {
// Set up the configuration table for hiding / sorting fields.
$fields = $this->getHandlers('field');
$header = [];
if (!empty($allow_settings['hide_fields'])) {
$header['hide'] = $this->t('Hide');
}
$header['label'] = $this->t('Label');
if (!empty($allow_settings['sort_fields'])) {
$header['weight'] = $this->t('Weight');
}
$form['override']['order_fields'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => array(),
];
if (!empty($allow_settings['sort_fields'])) {
$form['override']['order_fields']['#tabledrag'] = [
[
'action' => 'order',
'relationship' => 'sibling',
'group' => 'field-weight',
]
];
$form['override']['order_fields']['#attributes'] = ['id' => 'order-fields'];
}
// Sort available field plugins by their currently configured weight.
$sorted_fields = [];
if (!empty($allow_settings['sort_fields']) && isset($block_configuration['fields'])) {
uasort($block_configuration['fields'], '\Drupal\ctools_views\Plugin\Display\Block::sortFieldsByWeight');
foreach (array_keys($block_configuration['fields']) as $field_name) {
if (!empty($fields[$field_name])) {
$sorted_fields[$field_name] = $fields[$field_name];
unset($fields[$field_name]);
}
}
if (!empty($fields)) {
foreach ($fields as $field_name => $field_info) {
$sorted_fields[$field_name] = $field_info;
}
}
}
else {
$sorted_fields = $fields;
}
// Add each field to the configuration table.
foreach ($sorted_fields as $field_name => $plugin) {
$field_label = $plugin->adminLabel();
if (!empty($plugin->options['label'])) {
$field_label .= ' (' . $plugin->options['label'] . ')';
}
if (!empty($allow_settings['sort_fields'])) {
$form['override']['order_fields'][$field_name]['#attributes']['class'][] = 'draggable';
}
$form['override']['order_fields'][$field_name]['#weight'] = !empty($block_configuration['fields'][$field_name]['weight']) ? $block_configuration['fields'][$field_name]['weight'] : '';
if (!empty($allow_settings['hide_fields'])) {
$form['override']['order_fields'][$field_name]['hide'] = [
'#type' => 'checkbox',
'#default_value' => !empty($block_configuration['fields'][$field_name]['hide']) ? $block_configuration['fields'][$field_name]['hide'] : 0,
];
}
$form['override']['order_fields'][$field_name]['label'] = [
'#markup' => $field_label,
];
if (!empty($allow_settings['sort_fields'])) {
$form['override']['order_fields'][$field_name]['weight'] = [
'#type' => 'weight',
'#title' => $this->t('Weight for @title', ['@title' => $field_label]),
'#title_display' => 'invisible',
'#delta' => 50,
'#default_value' => !empty($block_configuration['fields'][$field_name]['weight']) ? $block_configuration['fields'][$field_name]['weight'] : 0,
'#attributes' => ['class' => ['field-weight']],
];
}
}
}
// Provide "Configure filters" / "Disable filters" block settings form.
if (!empty($allow_settings['disable_filters'])) {
$items = [];
foreach ((array) $this->getOption('filters') as $filter_name => $item) {
$item['value'] = isset($block_configuration["filter"][$filter_name]['value']) ? $block_configuration["filter"][$filter_name]['value'] : '';
$items[$filter_name] = $item;
}
$this->setOption('filters', $items);
$filters = $this->getHandlers('filter');
// Add a settings form for each exposed filter to configure or hide it.
foreach ($filters as $filter_name => $plugin) {
if ($plugin->isExposed() && $exposed_info = $plugin->exposedInfo()) {
$form['override']['filters'][$filter_name] = [
'#type' => 'details',
'#title' => $exposed_info['label'],
];
$form['override']['filters'][$filter_name]['plugin'] = [
'#type' => 'value',
'#value' => $plugin,
];
// Render "Disable filters" settings form.
if (!empty($allow_settings['disable_filters'])) {
$form['override']['filters'][$filter_name]['disable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Disable'),
'#default_value' => !empty($block_configuration['filter'][$filter_name]['disable']) ? $block_configuration['filter'][$filter_name]['disable'] : 0,
];
}
}
}
}
// Provide "Configure sorts" block settings form.
if (!empty($allow_settings['configure_sorts'])) {
$sorts = $this->getHandlers('sort');
$options = array(
'ASC' => $this->t('Sort ascending'),
'DESC' => $this->t('Sort descending'),
);
foreach ($sorts as $sort_name => $plugin) {
$form['override']['sort'][$sort_name] = [
'#type' => 'details',
'#title' => $plugin->adminLabel(),
];
$form['override']['sort'][$sort_name]['plugin'] = [
'#type' => 'value',
'#value' => $plugin,
];
$form['override']['sort'][$sort_name]['order'] = array(
'#title' => $this->t('Order'),
'#type' => 'radios',
'#options' => $options,
'#default_value' => $plugin->options['order']
);
// Set default values for sorts for this block.
if (!empty($block_configuration["sort"][$sort_name])) {
$form['override']['sort'][$sort_name]['order']['#default_value'] = $block_configuration["sort"][$sort_name];
}
}
}
return $form;
}
/**
* {@inheritdoc}
*/
public function blockSubmit(ViewsBlock $block, $form, FormStateInterface $form_state) {
// Set default value for items_per_page if left blank.
if (empty($form_state->getValue(array('override', 'items_per_page')))) {
$form_state->setValue(array('override', 'items_per_page'), "none");
}
parent::blockSubmit($block, $form, $form_state);
$configuration = $block->getConfiguration();
$allow_settings = array_filter($this->getOption('allow'));
// Save "Pager type" settings to block configuration.
if (!empty($allow_settings['pager'])) {
if ($pager = $form_state->getValue(['override', 'pager'])) {
$configuration['pager'] = $pager;
}
}
// Save "Pager offset" settings to block configuration.
if (!empty($allow_settings['offset'])) {
$configuration['pager_offset'] = $form_state->getValue(['override', 'pager_offset']);
}
// Save "Hide fields" / "Reorder fields" settings to block configuration.
if (!empty($allow_settings['hide_fields']) || !empty($allow_settings['sort_fields'])) {
if ($fields = array_filter($form_state->getValue(['override', 'order_fields']))) {
uasort($fields, '\Drupal\ctools_views\Plugin\Display\Block::sortFieldsByWeight');
$configuration['fields'] = $fields;
}
}
// Save "Configure filters" / "Disable filters" settings to block
// configuration.
unset($configuration['filter']);
if (!empty($allow_settings['disable_filters'])) {
if ($filters = $form_state->getValue(['override', 'filters'])) {
foreach ($filters as $filter_name => $filter) {
/** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $plugin */
$plugin = $form_state->getValue(['override', 'filters', $filter_name, 'plugin']);
$configuration["filter"][$filter_name]['type'] = $plugin->getPluginId();
// Check if we want to disable this filter.
if (!empty($allow_settings['disable_filters'])) {
$disable = $form_state->getValue(['override', 'filters', $filter_name, 'disable']);
// If marked disabled, we don't really care about other stuff.
if ($disable) {
$configuration["filter"][$filter_name]['disable'] = $disable;
continue;
}
}
}
}
}
// Save "Configure sorts" settings to block configuration.
if (!empty($allow_settings['configure_sorts'])) {
$sorts = $form_state->getValue(['override', 'sort']);
foreach ($sorts as $sort_name => $sort) {
$plugin = $sort['plugin'];
// Check if we want to override the default sort order
if ($plugin->options['order'] != $sort['order']) {
$configuration['sort'][$sort_name] = $sort['order'];
}
}
}
$block->setConfiguration($configuration);
}
/**
* {@inheritdoc}
*/
public function preBlockBuild(ViewsBlock $block) {
parent::preBlockBuild($block);
$allow_settings = array_filter($this->getOption('allow'));
$config = $block->getConfiguration();
list(, $display_id) = explode('-', $block->getDerivativeId(), 2);
// Change pager offset settings based on block configuration.
if (!empty($allow_settings['offset'])) {
$this->view->setOffset($config['pager_offset']);
}
// Change pager style settings based on block configuration.
if (!empty($allow_settings['pager'])) {
$pager = $this->view->display_handler->getOption('pager');
if (!empty($config['pager']) && $config['pager'] != 'view') {
$pager['type'] = $config['pager'];
}
$this->view->display_handler->setOption('pager', $pager);
}
// Change fields output based on block configuration.
if (!empty($allow_settings['hide_fields']) || !empty($allow_settings['sort_fields'])) {
if (!empty($config['fields']) && $this->view->getStyle()->usesFields()) {
$fields = $this->view->getHandlers('field');
uasort($config['fields'], '\Drupal\ctools_views\Plugin\Display\Block::sortFieldsByWeight');
$iterate_fields = !empty($allow_settings['sort_fields']) ? $config['fields'] : $fields;
foreach (array_keys($iterate_fields) as $field_name) {
// Remove each field in sequence and re-add them to sort
// appropriately or hide if disabled.
$this->view->removeHandler($display_id, 'field', $field_name);
if (empty($allow_settings['hide_fields']) || (!empty($allow_settings['hide_fields']) && empty($config['fields'][$field_name]['hide']))) {
$this->view->addHandler($display_id, 'field', $fields[$field_name]['table'], $fields[$field_name]['field'], $fields[$field_name], $field_name);
}
}
}
}
// Change filters output based on block configuration.
if (!empty($allow_settings['disable_filters'])) {
$filters = $this->view->getHandlers('filter', $display_id);
foreach ($filters as $filter_name => $filter) {
// If we allow disabled filters and this filter is disabled, disable it
// and continue.
if (!empty($allow_settings['disable_filters']) && !empty($config["filter"][$filter_name]['disable'])) {
$this->view->removeHandler($display_id, 'filter', $filter_name);
continue;
}
}
}
// Change sorts based on block configuration.
if (!empty($allow_settings['configure_sorts'])) {
$sorts = $this->view->getHandlers('sort', $display_id);
foreach ($sorts as $sort_name => $sort) {
if (!empty($config["sort"][$sort_name])) {
$sort['order'] = $config["sort"][$sort_name];
$this->view->setHandler($display_id, 'sort', $sort_name, $sort);
}
}
}
}
protected function getFilterOptionsValue(array $filter, array $config) {
$plugin_definition = \Drupal::service('plugin.manager.views.filter')->getDefinition($config['type']);
if (is_subclass_of($plugin_definition['class'], '\Drupal\views\Plugin\views\filter\InOperator')) {
return array_values($config['value']);
}
return $config['value'][$filter['expose']['identifier']];
}
/**
* {@inheritdoc}
*/
public function usesExposed() {
$filters = $this->getHandlers('filter');
foreach ($filters as $filter_name => $filter) {
if ($filter->isExposed() && !empty($filter->exposedInfo())) {
return TRUE;
}
}
return FALSE;
}
/**
* Exposed widgets typically only work with ajax in Drupal core, however
* #2605218 totally breaks the rest of the functionality in this display and
* in Core's Block display as well, so we allow non-ajax block views to use
* exposed filters and manually set the #action to the current request uri.
*/
public function elementPreRender(array $element) {
/** @var \Drupal\views\ViewExecutable $view */
$view = $element['#view'];
if (!empty($view->exposed_widgets['#action']) && !$view->ajaxEnabled()) {
$view->exposed_widgets['#action'] = \Drupal::request()->getRequestUri();
}
return parent::elementPreRender($element);
}
/**
* Sort field config array by weight.
*
* @param $a
* @param $b
* @return int
*/
public static function sortFieldsByWeight($a, $b) {
$a_weight = isset($a['weight']) ? $a['weight'] : 0;
$b_weight = isset($b['weight']) ? $b['weight'] : 0;
if ($a_weight == $b_weight) {
return 0;
}
return ($a_weight < $b_weight) ? -1 : 1;
}
}
@@ -0,0 +1,350 @@
<?php
namespace Drupal\ctools_views\Tests;
use Drupal\views_ui\Tests\UITestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
* Tests the ctools_views block display plugin
* overriding settings from a basic View.
*
* @group ctools_views
* @see \Drupal\ctools_views\Plugin\Display\Block
*/
class CToolsViewsBasicViewBlockTest extends UITestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('ctools_views', 'ctools_views_test_views');
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('ctools_views_test_view');
/**
* The block storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* @inheritdoc
*/
protected function setUp() {
parent::setUp();
ViewTestData::createTestViews(get_class($this), array('ctools_views_test_views'));
$this->storage = $this->container->get('entity.manager')->getStorage('block');
}
/**
* Test ctools_views "items_per_page" configuration.
*/
public function testItemsPerPage() {
$default_theme = $this->config('system.theme')->get('default');
// Get the "Configure block" form for our Views block.
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_pager/' . $default_theme);
$this->assertFieldByXPath('//input[@type="number" and @name="settings[override][items_per_page]"]', NULL, 'items_per_page setting is a number field');
// Add block to sidebar_first region with default settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][items_per_page]'] = 0;
$this->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_pager/' . $default_theme, $edit, $this->t('Save block'));
// Assert items per page default settings.
$this->drupalGet('<front>');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertEqual((string) $result[0], 'CTools Views Pager Block');
$this->assertRaw('Showing 3 records on page 1');
$this->assertEqual(3, count($this->xpath('//div[contains(@class, "view-display-id-block_pager")]//table/tbody/tr')));
// Override items per page settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][items_per_page]'] = 2;
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_pager', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_pager');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual(2, $config['items_per_page'], "'Items per page' is properly saved.");
// Assert items per page overridden settings.
$this->drupalGet('<front>');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertEqual((string) $result[0], 'CTools Views Pager Block');
$this->assertRaw('Showing 2 records on page 1');
$this->assertEqual(2, count($this->xpath('//div[contains(@class, "view-display-id-block_pager")]//table/tbody/tr')));
$this->assertEqual([1, 2], $this->xpath('//div[contains(@class, "view-display-id-block_pager")]//table//tr//td[contains(@class, "views-field-id")]'));
}
/**
* Test ctools_views "offset" configuration.
*/
public function testOffset() {
$default_theme = $this->config('system.theme')->get('default');
// Get the "Configure block" form for our Views block.
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_pager/' . $default_theme);
$this->assertFieldByXPath('//input[@type="number" and @name="settings[override][pager_offset]"]', NULL, 'items_per_page setting is a number field');
// Add block to sidebar_first region with default settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][items_per_page]'] = 0;
$this->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_pager/' . $default_theme, $edit, $this->t('Save block'));
// Assert pager offset default settings.
$this->drupalGet('<front>');
$this->assertEqual([1, 2, 3], $this->xpath('//div[contains(@class, "view-display-id-block_pager")]//table//tr//td[contains(@class, "views-field-id")]'));
// Override pager offset settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][items_per_page]'] = 0;
$edit['settings[override][pager_offset]'] = 1;
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_pager', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_pager');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual(1, $config['pager_offset'], "'Pager offset' is properly saved.");
// Assert pager offset overridden settings.
$this->drupalGet('<front>');
$this->assertEqual([2, 3, 4], $this->xpath('//div[contains(@class, "view-display-id-block_pager")]//table//tr//td[contains(@class, "views-field-id")]'));
}
/**
* Test ctools_views "pager" configuration.
*/
public function testPager() {
$default_theme = $this->config('system.theme')->get('default');
// Get the "Configure block" form for our Views block.
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_pager/' . $default_theme);
$this->assertFieldById('edit-settings-override-pager-view', 'view');
$this->assertFieldById('edit-settings-override-pager-some');
$this->assertFieldById('edit-settings-override-pager-none');
// Add block to sidebar_first region with default settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][items_per_page]'] = 0;
$this->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_pager/' . $default_theme, $edit, $this->t('Save block'));
// Assert pager default settings.
$this->drupalGet('<front>');
$this->assertText('Page 1');
$this->assertText('Next ');
// Override pager settings to 'some'.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][items_per_page]'] = 0;
$edit['settings[override][pager]'] = 'some';
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_pager', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_pager');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual('some', $config['pager'], "'Pager' setting is properly saved.");
// Assert pager overridden settings to 'some', showing no pager.
$this->drupalGet('<front>');
$this->assertEqual(3, count($this->xpath('//div[contains(@class, "view-display-id-block_pager")]//table/tbody/tr')));
$this->assertNoText('Page 1');
$this->assertNoText('Next ');
// Override pager settings to 'none'.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][items_per_page]'] = 0;
$edit['settings[override][pager]'] = 'none';
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_pager', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_pager');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual('none', $config['pager'], "'Pager' setting is properly saved.");
// Assert pager overridden settings to 'some', showing no pager.
$this->drupalGet('<front>');
$this->assertEqual(5, count($this->xpath('//div[contains(@class, "view-display-id-block_pager")]//table/tbody/tr')));
$this->assertNoText('Page 1');
$this->assertNoText('Next ');
}
/**
* Test ctools_views 'hide_fields' configuration.
*/
public function testHideFields() {
$default_theme = $this->config('system.theme')->get('default');
// Get the "Configure block" form for our Views block.
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_fields/' . $default_theme);
$this->assertFieldById('edit-settings-override-order-fields-id-hide');
// Add block to sidebar_first region with default settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$this->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_fields/' . $default_theme, $edit, $this->t('Save block'));
// Assert hide_fields default settings.
$this->drupalGet('<front>');
$this->assertEqual(5, count($this->xpath('//div[contains(@class, "view-display-id-block_fields")]//table//td[contains(@class, "views-field-id")]')));
// Override hide_fields settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][order_fields][id][hide]'] = 1;
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_fields', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_fields');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual(1, $config['fields']['id']['hide'], "'hide_fields' setting is properly saved.");
$this->assertEqual(0, $config['fields']['name']['hide'], "'hide_fields' setting is properly saved.");
// Assert hide_fields overridden settings.
$this->drupalGet('<front>');
$this->assertEqual(0, count($this->xpath('//div[contains(@class, "view-display-id-block_fields")]//table//td[contains(@class, "views-field-id")]')));
}
/**
* Test ctools_views 'sort_fields' configuration.
*/
public function testOrderFields() {
$default_theme = $this->config('system.theme')->get('default');
// Get the "Configure block" form for our Views block.
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_fields/' . $default_theme);
$this->assertFieldById('edit-settings-override-order-fields-id-weight', 0);
// Add block to sidebar_first region with default settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$this->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_fields/' . $default_theme, $edit, $this->t('Save block'));
// Assert sort_fields default settings.
$this->drupalGet('<front>');
// Check that the td with class "views-field-id" is the first td in the first tr element.
$this->assertEqual(0, count($this->xpath('count(//div[contains(@class, "view-display-id-block_fields")]//table//tr[1]//td[contains(@class, "views-field-id")]/preceding-sibling::td)')));
// Override sort_fields settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][order_fields][name][weight]'] = -50;
$edit['settings[override][order_fields][age][weight]'] = -49;
$edit['settings[override][order_fields][job][weight]'] = -48;
$edit['settings[override][order_fields][created][weight]'] = -47;
$edit['settings[override][order_fields][id][weight]'] = -46;
$edit['settings[override][order_fields][name_1][weight]'] = -45;
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_fields', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_fields');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual(-46, $config['fields']['id']['weight'], "'sort_fields' setting is properly saved.");
$this->assertEqual(-50, $config['fields']['name']['weight'], "'sort_fields' setting is properly saved.");
// Assert sort_fields overridden settings.
$this->drupalGet('<front>');
// Check that the td with class "views-field-id" is the 5th td in the first tr element.
$this->assertEqual(4, count($this->xpath('//div[contains(@class, "view-display-id-block_fields")]//table//tr[1]//td[contains(@class, "views-field-id")]/preceding-sibling::td')));
// Check that duplicate fields in the View produce expected outpu
$name1_element = $this->xpath('//div[contains(@class, "view-display-id-block_fields")]//table//tr[1]/td[contains(@class, "views-field-name")]/text()');
$name1 = (string) $name1_element[0];
$this->assertEqual("John", trim($name1));
$name2_element = $this->xpath('//div[contains(@class, "view-display-id-block_fields")]//table//tr[1]/td[contains(@class, "views-field-name-1")]/text()');
$name2 = (string) $name2_element[0];
$this->assertEqual("John", trim($name2));
}
/**
* Test ctools_views 'disable_filters' configuration.
*/
public function testDisableFilters() {
$default_theme = $this->config('system.theme')->get('default');
// Get the "Configure block" form for our Views block.
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_filter/' . $default_theme);
$this->assertFieldById('edit-settings-override-filters-status-disable');
$this->assertFieldById('edit-settings-override-filters-job-disable');
// Add block to sidebar_first region with default settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$this->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_filter/' . $default_theme, $edit, $this->t('Save block'));
// Assert disable_filters default settings.
$this->drupalGet('<front>');
// Check that the default settings show both filters
$this->assertFieldByXPath('//select[@name="status"]');
$this->assertFieldByXPath('//input[@name="job"]');
// Override disable_filters settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][filters][status][disable]'] = 1;
$edit['settings[override][filters][job][disable]'] = 1;
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_filter', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_filter');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual(1, $config['filter']['status']['disable'], "'disable_filters' setting is properly saved.");
$this->assertEqual(1, $config['filter']['job']['disable'], "'disable_filters' setting is properly saved.");
// Assert disable_filters overridden settings.
$this->drupalGet('<front>');
$this->assertNoFieldByXPath('//select[@name="status"]');
$this->assertNoFieldByXPath('//input[@name="job"]');
}
/**
* Test ctools_views 'configure_sorts' configuration.
*/
public function testConfigureSorts() {
$default_theme = $this->config('system.theme')->get('default');
// Get the "Configure block" form for our Views block.
$this->drupalGet('admin/structure/block/add/views_block:ctools_views_test_view-block_sort/' . $default_theme);
$this->assertFieldByXPath('//input[@name="settings[override][sort][id][order]"]');
// Add block to sidebar_first region with default settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$this->drupalPostForm('admin/structure/block/add/views_block:ctools_views_test_view-block_sort/' . $default_theme, $edit, $this->t('Save block'));
// Assert configure_sorts default settings.
$this->drupalGet('<front>');
// Check that the results are sorted ASC
$element = $this->xpath('//div[contains(@class, "view-display-id-block_sort")]//table//tr[1]/td[1]/text()');
$value = (string) $element[0];
$this->assertEqual("1", trim($value));
// Override configure_sorts settings.
$edit = array();
$edit['region'] = 'sidebar_first';
$edit['settings[override][sort][id][order]'] = "DESC";
$this->drupalPostForm('admin/structure/block/manage/views_block__ctools_views_test_view_block_sort', $edit, $this->t('Save block'));
$block = $this->storage->load('views_block__ctools_views_test_view_block_sort');
$config = $block->getPlugin()->getConfiguration();
$this->assertEqual("DESC", $config['sort']['id'], "'configure_sorts' setting is properly saved.");
// Assert configure_sorts overridden settings.
// Check that the results are sorted DESC
$this->drupalGet('<front>');
$element = $this->xpath('//div[contains(@class, "view-display-id-block_sort")]//table//tr[1]/td[1]/text()');
$value = (string) $element[0];
$this->assertEqual("5", trim($value));
}
}
@@ -0,0 +1,20 @@
name: 'CTools Views test views'
type: module
description: 'Provides default views for CTools Views tests.'
package: Testing
# core: 8.x
dependencies:
- views
- block
- entity_test
- ctools_views
- text
- user
- node
- taxonomy
# Information added by Drupal.org packaging script on 2017-04-28
version: '8.x-3.0'
core: '8.x'
project: 'ctools'
datestamp: 1493401747
@@ -0,0 +1,543 @@
langcode: en
status: true
dependencies:
config:
- node.type.ctools_views
- taxonomy.vocabulary.tags
module:
- datetime
- node
- options
- taxonomy
- user
id: ctools_views_entity_test
label: 'CTools Views Entity Test View'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: none
options:
offset: 0
style:
type: table
row:
type: fields
fields:
title:
id: title
table: node_field_data
field: title
entity_type: node
entity_field: title
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
label: Title
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
filters:
status:
value: true
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
ctools_views: ctools_views
entity_type: node
entity_field: type
plugin_id: bundle
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
title: 'CTools Views Entity Test View'
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- 'user.node_grants:view'
- user.permissions
tags: { }
block_filter_date:
display_plugin: block
id: block_filter_date
display_title: 'Date filter'
position: 4
display_options:
display_extenders: { }
display_description: ''
title: 'Date filter'
defaults:
title: false
filters: false
filter_groups: false
filters:
status:
value: true
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
ctools_views: ctools_views
entity_type: node
entity_field: type
plugin_id: bundle
group: 1
field_ctools_views_date_value:
id: field_ctools_views_date_value
table: node__field_ctools_views_date
field: field_ctools_views_date_value
relationship: none
group_type: group
admin_label: ''
operator: between
group: 1
exposed: true
expose:
operator_id: field_ctools_views_date_value_op
label: 'CTools Views Date (field_ctools_views_date)'
description: ''
use_operator: false
operator: field_ctools_views_date_value_op
identifier: field_ctools_views_date_value
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator1: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: datetime
filter_groups:
operator: AND
groups:
1: AND
allow:
items_per_page: false
offset: '0'
pager: '0'
hide_fields: '0'
sort_fields: '0'
disable_filters: '0'
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'user.node_grants:view'
- user.permissions
tags: { }
block_filter_list:
display_plugin: block
id: block_filter_list
display_title: 'List filter'
position: 3
display_options:
display_extenders: { }
display_description: ''
title: 'List filter'
defaults:
title: false
filters: false
filter_groups: false
filters:
status:
value: true
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
ctools_views: ctools_views
entity_type: node
entity_field: type
plugin_id: bundle
field_ctools_views_list_value:
id: field_ctools_views_list_value
table: node__field_ctools_views_list
field: field_ctools_views_list_value
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: true
expose:
operator_id: field_ctools_views_list_value_op
label: 'Ctools Views List (field_ctools_views_list)'
description: ''
use_operator: false
operator: field_ctools_views_list_value_op
identifier: field_ctools_views_list_value
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator1: '0'
administrator: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reduce_duplicates: false
plugin_id: list_field
filter_groups:
operator: AND
groups:
1: AND
allow:
items_per_page: false
offset: '0'
pager: '0'
hide_fields: '0'
sort_fields: '0'
disable_filters: '0'
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'user.node_grants:view'
- user.permissions
tags: { }
block_filter_tax:
display_plugin: block
id: block_filter_tax
display_title: 'Taxonomy filter'
position: 2
display_options:
display_extenders: { }
display_description: ''
title: 'Taxonomy filter'
defaults:
title: false
filters: false
filter_groups: false
filters:
status:
value: true
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
ctools_views: ctools_views
entity_type: node
entity_field: type
plugin_id: bundle
group: 1
field_ctools_views_tags_target_id:
id: field_ctools_views_tags_target_id
table: node__field_ctools_views_tags
field: field_ctools_views_tags_target_id
relationship: none
group_type: group
admin_label: ''
operator: or
value: { }
group: 1
exposed: true
expose:
operator_id: field_ctools_views_tags_target_id_op
label: 'Tags (field_ctools_views_tags)'
description: ''
use_operator: false
operator: field_ctools_views_tags_target_id_op
identifier: field_ctools_views_tags_target_id
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator1: '0'
administrator: '0'
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
reduce_duplicates: false
type: select
limit: true
vid: tags
hierarchy: false
error_message: true
plugin_id: taxonomy_index_tid
filter_groups:
operator: AND
groups:
1: AND
allow:
items_per_page: false
offset: '0'
pager: '0'
hide_fields: '0'
sort_fields: '0'
disable_filters: '0'
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- user
- 'user.node_grants:view'
- user.permissions
tags: { }
block_filter_text:
display_plugin: block
id: block_filter_text
display_title: 'Textfield filter'
position: 1
display_options:
display_extenders: { }
display_description: ''
title: 'Textfield filter'
defaults:
title: false
filters: false
filter_groups: false
filters:
status:
value: true
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
ctools_views: ctools_views
entity_type: node
entity_field: type
plugin_id: bundle
field_ctools_views_text_value:
id: field_ctools_views_text_value
table: node__field_ctools_views_text
field: field_ctools_views_text_value
relationship: none
group_type: group
admin_label: ''
operator: '='
value: ''
group: 1
exposed: true
expose:
operator_id: field_ctools_views_text_value_op
label: 'Text (field_ctools_views_text)'
description: ''
use_operator: false
operator: field_ctools_views_text_value_op
identifier: field_ctools_views_text_value
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator1: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
filter_groups:
operator: AND
groups:
1: AND
allow:
items_per_page: false
offset: '0'
pager: '0'
hide_fields: '0'
sort_fields: '0'
disable_filters: '0'
cache_metadata:
max-age: 0
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url
- 'user.node_grants:view'
- user.permissions
tags: { }
@@ -0,0 +1,949 @@
langcode: en
status: true
dependencies: { }
id: ctools_views_test_view
label: 'CTools Views Test View'
module: views
description: ''
tag: ''
base_table: views_test_data
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: none
options:
offset: 0
style:
type: table
options:
grouping: { }
row_class: ''
default_row_class: true
override: true
sticky: false
caption: ''
summary: ''
description: ''
columns:
id: id
age: age
created: created
id_1: id_1
job: job
name: name
info:
id:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
age:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
created:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
id_1:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
job:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
name:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
default: '-1'
empty_table: false
row:
type: fields
fields:
id:
id: id
table: views_test_data
field: id
relationship: none
group_type: group
admin_label: ''
label: ID
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
set_precision: false
precision: 0
decimal: .
separator: ''
format_plural: false
format_plural_string: "1\x03@count"
prefix: ''
suffix: ''
entity_type: null
entity_field: null
plugin_id: numeric
name:
id: name
table: views_test_data
field: name
relationship: none
group_type: group
admin_label: ''
label: Name
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: standard
age:
id: age
table: views_test_data
field: age
relationship: none
group_type: group
admin_label: ''
label: Age
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
set_precision: false
precision: 0
decimal: .
separator: ''
format_plural: false
format_plural_string: "1\x03@count"
prefix: ''
suffix: ''
plugin_id: numeric
job:
id: job
table: views_test_data
field: job
relationship: none
group_type: group
admin_label: ''
label: Job
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: standard
created:
id: created
table: views_test_data
field: created
relationship: none
group_type: group
admin_label: ''
label: Created
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: fallback
custom_date_format: ''
timezone: ''
plugin_id: date
filters: { }
sorts:
id:
id: id
table: views_test_data
field: id
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
plugin_id: standard
title: 'CTools Views Test View'
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
use_ajax: false
filter_groups:
operator: AND
groups: { }
cache_metadata:
max-age: 0
contexts:
- 'languages:language_interface'
tags: { }
block_fields:
display_plugin: block
id: block_fields
display_title: 'CTools Views Fields Block'
position: 2
display_options:
display_extenders: { }
block_category: 'CTools Views'
allow:
hide_fields: hide_fields
sort_fields: sort_fields
items_per_page: false
offset: '0'
pager: '0'
disable_filters: '0'
block_description: 'CTools Views Fields Block'
display_description: ''
pager:
type: none
options:
offset: 0
defaults:
pager: false
title: false
fields: false
title: 'CTools Views Fields Block'
fields:
id:
id: id
table: views_test_data
field: id
relationship: none
group_type: group
admin_label: ''
label: ID
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
set_precision: false
precision: 0
decimal: .
separator: ''
format_plural: false
format_plural_string: "1\x03@count"
prefix: ''
suffix: ''
entity_type: null
entity_field: null
plugin_id: numeric
name:
id: name
table: views_test_data
field: name
relationship: none
group_type: group
admin_label: ''
label: Name
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: standard
age:
id: age
table: views_test_data
field: age
relationship: none
group_type: group
admin_label: ''
label: Age
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
set_precision: false
precision: 0
decimal: .
separator: ''
format_plural: false
format_plural_string: "1\x03@count"
prefix: ''
suffix: ''
plugin_id: numeric
job:
id: job
table: views_test_data
field: job
relationship: none
group_type: group
admin_label: ''
label: Job
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: standard
created:
id: created
table: views_test_data
field: created
relationship: none
group_type: group
admin_label: ''
label: Created
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: fallback
custom_date_format: ''
timezone: ''
plugin_id: date
name_1:
id: name_1
table: views_test_data
field: name
relationship: none
group_type: group
admin_label: ''
label: '2nd name field'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: standard
cache_metadata:
max-age: 0
contexts:
- 'languages:language_interface'
tags: { }
block_filter:
display_plugin: block
id: block_filter
display_title: 'CTools Views Filter Block'
position: 3
display_options:
display_extenders: { }
display_description: ''
block_category: 'CTools Views'
block_description: 'CTools Views Filter Block'
allow:
disable_filters: disable_filters
items_per_page: false
offset: '0'
pager: '0'
hide_fields: '0'
sort_fields: '0'
filters:
status:
id: status
table: views_test_data
field: status
relationship: none
group_type: group
admin_label: ''
operator: '='
value: true
group: 1
exposed: true
expose:
operator_id: ''
label: Status
description: ''
use_operator: false
operator: status_op
identifier: status
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator1: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: boolean
job:
id: job
table: views_test_data
field: job
relationship: none
group_type: group
admin_label: ''
operator: '='
value: ''
group: 1
exposed: true
expose:
operator_id: job_op
label: Job
description: ''
use_operator: false
operator: job_op
identifier: job
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator1: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
defaults:
filters: false
filter_groups: false
title: false
filter_groups:
operator: AND
groups:
1: AND
title: 'CTools Views Filter Block'
cache_metadata:
max-age: 0
contexts:
- 'languages:language_interface'
- url
tags: { }
block_pager:
display_plugin: block
id: block_pager
display_title: 'CTools Views Pager Block'
position: 1
display_options:
display_extenders: { }
block_description: 'CTools Views Pager Block'
block_category: 'CTools Views'
allow:
items_per_page: true
offset: offset
pager: pager
hide_fields: '0'
sort_fields: '0'
disable_filters: '0'
display_description: ''
header:
result:
id: result
table: views
field: result
relationship: none
group_type: group
admin_label: ''
empty: false
content: "Displaying @start - @end of @total\nShowing @current_record_count records on page @current_page"
plugin_id: result
defaults:
header: false
pager: false
title: false
pager:
type: mini
options:
items_per_page: 3
offset: 0
id: 0
total_pages: null
tags:
previous: ' Previous'
next: 'Next '
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
title: 'CTools Views Pager Block'
cache_metadata:
max-age: 0
contexts:
- 'languages:language_interface'
- url.query_args
tags: { }
block_sort:
display_plugin: block
id: block_sort
display_title: 'CTools Views Sort Block'
position: 4
display_options:
display_extenders: { }
display_description: ''
title: 'CTools Views Sort Block'
defaults:
title: false
block_description: 'CTools Views Sort Block'
block_category: 'CTools Views'
allow:
configure_sorts: configure_sorts
items_per_page: false
offset: '0'
pager: '0'
hide_fields: '0'
sort_fields: '0'
disable_filters: '0'
cache_metadata:
max-age: 0
contexts:
- 'languages:language_interface'
tags: { }