updated contrib modules : translation_views, views_bulk_edit, views_bulk_operations, workflow, addtoany, redis, url_to_video_filter

This commit is contained in:
2018-09-12 14:51:18 +02:00
parent 4caa864a8f
commit b8e8cc8cee
99 changed files with 4762 additions and 954 deletions
@@ -7,8 +7,8 @@ dependencies:
- drupal:node
configure: addtoany.admin_settings
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.x-1.9'
# Information added by Drupal.org packaging script on 2018-07-03
version: '8.x-1.10'
core: '8.x'
project: 'addtoany'
datestamp: 1520385667
datestamp: 1530656924
@@ -11,6 +11,7 @@ use Drupal\Core\Render\Markup;
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;
use Drupal\node\Entity\Node;
use Drupal\addtoany\Form\AddToAnySettingsForm;
/**
* Implements hook_theme().
@@ -58,20 +59,25 @@ function addtoany_theme_suggestions_addtoany_standard(array $variables) {
*/
function addtoany_entity_extra_field_info() {
$extra = [];
$types = ['node', 'comment', 'media'];
$entityTypes = AddToAnySettingsForm::getContentEntities();
$config = Drupal::config('addtoany.settings');
// Allow modules to alter the entity types.
\Drupal::moduleHandler()->alter('addtoany_entity_types', $types);
\Drupal::moduleHandler()->alter('addtoany_entity_types', $entityTypes);
foreach ($types as $type) {
$bundles = Drupal::service('entity_type.bundle.info')->getBundleInfo($type);
foreach ($bundles as $bundle => $bundle_data) {
$extra[$type][$bundle]['display']['addtoany'] = [
'label' => t('AddToAny'),
'description' => t('Share buttons by AddToAny'),
'weight' => 5,
'visible' => FALSE,
];
foreach ($entityTypes as $type) {
$entityTypeId = $type->id();
$isAllowed = $config->get("entities.{$entityTypeId}");
if ($isAllowed) {
$bundles = Drupal::service('entity_type.bundle.info')->getBundleInfo($entityTypeId);
foreach ($bundles as $bundle => $bundle_data) {
$extra[$entityTypeId][$bundle]['display']['addtoany'] = [
'label' => t('AddToAny'),
'description' => t('Share buttons by AddToAny'),
'weight' => 5,
'visible' => FALSE,
];
}
}
}
@@ -83,19 +89,23 @@ function addtoany_entity_extra_field_info() {
*/
function addtoany_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($display->getComponent('addtoany')) {
$data = addtoany_create_entity_data($entity);
$build['addtoany'] = [
'#addtoany_html' => \Drupal::token()->replace($data['addtoany_html'], ['node' => $entity]),
'#link_url' => $data['link_url'],
'#link_title' => $data['link_title'],
'#button_setting' => $data['button_setting'],
'#button_image' => $data['button_image'],
'#universal_button_placement' => $data['universal_button_placement'],
'#buttons_size' => $data['buttons_size'],
'#entity_type' => $entity->getEntityType()->id(),
'#bundle' => $entity->bundle(),
'#theme' => 'addtoany_standard',
];
$config = Drupal::config('addtoany.settings');
$isAllowed = $config->get("entities.{$entity->getEntityTypeId()}");
if ($isAllowed) {
$data = addtoany_create_entity_data($entity);
$build['addtoany'] = [
'#addtoany_html' => \Drupal::token()->replace($data['addtoany_html'], ['node' => $entity]),
'#link_url' => $data['link_url'],
'#link_title' => $data['link_title'],
'#button_setting' => $data['button_setting'],
'#button_image' => $data['button_image'],
'#universal_button_placement' => $data['universal_button_placement'],
'#buttons_size' => $data['buttons_size'],
'#entity_type' => $entity->getEntityType()->id(),
'#bundle' => $entity->bundle(),
'#theme' => 'addtoany_standard',
];
}
}
}
@@ -9,3 +9,7 @@ universal_button: default
custom_universal_button: ''
universal_button_placement: before
no_3p: false
entities:
media: 1
node: 1
comment: 1
@@ -1,3 +1,12 @@
.addtoany-entity-checkbox ~ .description {
display: inline;
}
.addtoany-entity-checkbox ~ .description a {
margin: 0 3px;
white-space: nowrap;
}
.addtoany-round-icon {
border-radius: 14%;
}
@@ -5,7 +5,10 @@ namespace Drupal\addtoany\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\ContentEntityType;
use Drupal\Core\Link;
/**
* Configure AddToAny settings for this site.
@@ -191,6 +194,69 @@ class AddToAnySettingsForm extends ConfigFormBase {
];
}
$form['addtoany_entity_settings'] = [
'#type' => 'details',
'#title' => $this->t('Entities'),
];
$form['addtoany_entity_settings']['addtoany_entity_tip_1'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('AddToAny is available on the "Manage display" pages of enabled entities, e.g. Structure > Content types > Article > Manage display.'),
];
$entities = self::getContentEntities();
// Allow modules to alter the entity types.
\Drupal::moduleHandler()->alter('addtoany_entity_types', $entities);
// Whitelist the entity IDs that let us link to each bundle's Manage Display page.
$linkableEntities = [
'block_content', 'comment', 'commerce_product', 'commerce_store',
'contact_message', 'media', 'node', 'paragraph',
];
foreach ($entities as $entity) {
$entityId = $entity->id();
$entityType = $entity->getBundleEntityType();
// Get all available bundles for the current entity.
$bundles = \Drupal::service('entity.manager')->getBundleInfo($entityId);
$links = [];
foreach($bundles as $machine_name => $bundle) {
$label = $bundle['label'];
// Some labels are TranslatableMarkup objects (such as the File entity).
if ($label instanceof TranslatableMarkup) {
$label = $label->render();
}
// Link to the bundle's Manage Display page if the entity ID supports the route pattern.
if (in_array($entityId, $linkableEntities) && $entityType) {
$links[] = Link::createFromRoute(t($label), "entity.entity_view_display.{$entityId}.default", [
$entityType => $machine_name,
])->toString();
}
}
$description = empty($links) ? '' : '( ' . implode(' | ', $links) . ' )';
$form['addtoany_entity_settings'][$entityId] = [
'#type' => 'checkbox',
'#title' => $this->t('@entity', ['@entity' => $entity->getLabel()]),
'#default_value' => $addtoany_settings->get("entities.{$entityId}"),
'#description' => $description,
'#attributes' => ['class' => ['addtoany-entity-checkbox']]
];
}
$form['addtoany_entity_settings']['addtoany_entity_tip_2'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this->t('A cache rebuild may be required before changes take effect.'),
];
return parent::buildForm($form, $form_state);
}
@@ -207,10 +273,33 @@ class AddToAnySettingsForm extends ConfigFormBase {
->set('custom_universal_button', $values['addtoany_custom_universal_button'])
->set('universal_button', $values['addtoany_universal_button'])
->set('universal_button_placement', $values['addtoany_universal_button_placement'])
->set('no_3p', $values['addtoany_no_3p'])
->save();
->set('no_3p', $values['addtoany_no_3p']);
foreach(self::getContentEntities() as $entity) {
$entityId = $entity->id();
$this->config('addtoany.settings')
->set("entities.{$entityId}", $values[$entityId]);
}
$this->config('addtoany.settings')->save();
parent::submitForm($form, $form_state);
}
/**
* Get all available content entities in the environment.
* @return array
*/
public static function getContentEntities() {
$content_entity_types = [];
$entity_type_definitions = \Drupal::entityTypeManager()->getDefinitions();
/* @var $definition EntityTypeInterface */
foreach ($entity_type_definitions as $definition) {
if ($definition instanceof ContentEntityType) {
$content_entity_types[] = $definition;
}
}
return $content_entity_types;
}
}