updated contrib modules

This commit is contained in:
Bachir Soussi Chiadmi
2018-01-24 13:37:38 +01:00
parent f9374cf96d
commit c57b3644fe
126 changed files with 6835 additions and 905 deletions
@@ -1,3 +1,24 @@
Admin Toolbar 8.1.22, 2017-XX-XX
--------------------------------
Changes since 8.1.21:
- #2929061 by romainj, dsnopek, adriancid: admin_toolbar_links_access_filter
doesn't do anything unless admin_toolbar is enabled.
- #2928836 by eme: One extra pixel line under the admin toolbar.
- #2925501 by eme, adriancid, RumyanaRuseva: Menu does not take changes into
account (caching issue).
- #2927914 by adriancid: Parameter comment indentation must be 3 spaces.
- #2927911 by adriancid: Remove unused variables.
- #2927905 by adriancid: All dependencies must be prefixed with the project
name.
- #2925327 by Berdir, adriancid: Better check for is-link-in-admin-menu for
local task links.
- #2922046 by mikejw, adriancid, Berdir, BrianLewisDesign: Notice: Undefined
index: entity.eform_type.collection in
admin_toolbar_tools_menu_links_discovered_alter.
- #2925128 by adriancid: Create the module help page for the Admin Toolbar Links
Access Filter submodule.
Admin Toolbar 8.1.21, 2017-11-20
--------------------------------
Changes since 8.1.20:
@@ -6,10 +6,10 @@ type: module
# core: 8.x
dependencies:
- toolbar
- drupal:toolbar
# Information added by Drupal.org packaging script on 2017-11-20
version: '8.x-1.21'
# Information added by Drupal.org packaging script on 2018-01-02
version: '8.x-1.22'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1511190792
datestamp: 1514888588
@@ -27,7 +27,9 @@ https://www.drupal.org/node/296693 be solved, this module will be deprecated.
REQUIREMENTS
------------
No special requirements.
This module requires the following modules:
* Admin Toolbar (https://www.drupal.org/project/admin_toolbar)
RECOMMENDED MODULES
@@ -1,12 +1,13 @@
name: Admin Toolbar Links Access Filter
description: Provides a workaround for the common problem that users with 'Use the administration pages and help' permission see menu links they don't have access permission for. Once the issue <a href='https://www.drupal.org/node/296693'>https://www.drupal.org/node/296693</a> be solved, this module will be deprecated.
package: Administration
dependencies:
- admin_toolbar:admin_toolbar
type: module
# core: 8.x
# Information added by Drupal.org packaging script on 2017-11-20
version: '8.x-1.21'
# Information added by Drupal.org packaging script on 2018-01-02
version: '8.x-1.22'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1511190792
datestamp: 1514888588
@@ -9,6 +9,22 @@ use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\user\Entity\Role;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function admin_toolbar_links_access_filter_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help.
case 'help.page.admin_toolbar_links_access_filter':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t("The Admin Toolbar Links Access Filter module Provides a workaround for the common problem that users with <em>Use the administration pages and help</em> permission see menu links they don't have access permission for. Once the issue <a href='@url'>Hide empty admin categories</a> be solved, this module will be deprecated.", ['@url' => Url::fromUri('https://www.drupal.org/node/296693')->toString()]) . '</p>';
return $output;
}
}
/**
* Implements hook_preprocess_menu().
@@ -152,6 +168,7 @@ function admin_toolbar_links_access_filter_is_overview_page($route_name) {
return !empty($controller) && in_array($controller, $overview_page_controllers);
}
catch (RouteNotFoundException $ex) {
}
return FALSE;
}
@@ -6,10 +6,10 @@ type: module
# core: 8.x
dependencies:
- admin_toolbar
- admin_toolbar:admin_toolbar
# Information added by Drupal.org packaging script on 2017-11-20
version: '8.x-1.21'
# Information added by Drupal.org packaging script on 2018-01-02
version: '8.x-1.22'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1511190792
datestamp: 1514888588
@@ -12,6 +12,13 @@ system.admin_index:
parent: admin_toolbar_tools.help
weight: -100
system.run_cron:
title: 'Run cron'
route_name: admin_toolbar.run.cron
menu_name: admin
parent: admin_toolbar_tools.help
weight: -8
system.db_update:
title: 'Run updates'
route_name: system.db_update
@@ -25,6 +32,43 @@ system.modules_uninstall:
menu_name: admin
parent: system.modules_list
admin_toolbar_tools.flush:
title: 'Flush all caches'
route_name: admin_toolbar_tools.flush
weight: -9
parent: admin_toolbar_tools.help
menu_name: admin
admin_toolbar_tools.cssjs:
title: 'Flush CSS and Javascript'
route_name: admin_toolbar_tools.cssjs
parent: admin_toolbar_tools.flush
menu_name: admin
admin_toolbar_tools.plugin:
title: 'Flush plugins cache'
route_name: admin_toolbar_tools.plugin
parent: admin_toolbar_tools.flush
menu_name: admin
admin_toolbar_tools.flush_static:
title: 'Flush static cache'
route_name: admin_toolbar_tools.flush_static
parent: admin_toolbar_tools.flush
menu_name: admin
admin_toolbar_tools.flush_menu:
title: 'Flush routing and links cache'
route_name: admin_toolbar_tools.flush_menu
parent: admin_toolbar_tools.flush
menu_name: admin
admin_toolbar_tools.flush_rendercache:
title: 'Flush render cache'
route_name: admin_toolbar_tools.flush_rendercache
parent: admin_toolbar_tools.flush
menu_name: admin
admin_toolbar_tools.drupalorg:
title: 'Drupal.org'
weight: -5
@@ -28,17 +28,6 @@ function admin_toolbar_tools_toolbar() {
return $items;
}
/**
* Implements hook_toolbar_alter().
*/
function admin_toolbar_tools_toolbar_alter(&$items) {
// Use lazybuilder for links so the page is cacheable.
$items['administration']['tray']['toolbar_administration'] = [
'#lazy_builder' => ['admin_toolbar_tools.toolbar_handler:lazyBuilder', []],
'#create_placeholder' => TRUE,
];
}
/**
* Implements hook_help().
*/
@@ -88,8 +77,18 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
}
}
// Adding a menu link to clean the Views cache.
if ($moduleHandler->moduleExists('views')) {
$links['admin_toolbar_tools.flush_views'] = [
'title' => t('Flush views cache'),
'route_name' => 'admin_toolbar_tools.flush_views',
'menu_name' => 'admin',
'parent' => 'admin_toolbar_tools.flush',
];
}
// Adds common links to entities.
foreach ($content_entities as $module_name => $entities) {
foreach ($content_entities as $entities) {
$content_entity_bundle = $entities['content_entity_bundle'];
$content_entity = $entities['content_entity'];
foreach ($entityTypeManager->getStorage($content_entity_bundle)->loadMultiple() as $machine_name => $bundle) {
@@ -539,19 +538,45 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
$manager = \Drupal::service('plugin.manager.menu.local_task');
foreach ($links as $key => $link) {
// Ignore menu links that have no route name or are not in the admin menu.
// @todo Use configuration for admin menu name once added in
// https://www.drupal.org/node/1869638.
if (empty($link['route_name']) || !isset($link['menu_name']) || $link['menu_name'] !== 'admin') {
// Ignore menu links that have no route name.
if (empty($link['route_name'])) {
continue;
}
// Ignore links that are not in the admin menu, include parents in the
// check as they inherit the menu name from the parent if not set.
$link_to_check = $link;
do {
// @todo Use configuration for admin menu name once added in
// https://www.drupal.org/node/1869638.
if (isset($link_to_check['menu_name'])) {
// If the link belongs to the admin menu, then skip this loop and
// look for local tasks.
if ($link_to_check['menu_name'] === 'admin') {
break;
}
else {
// If it is explicitly not in the admin menu, skip.
continue 2;
}
}
if (!empty($link_to_check['parent']) && isset($links[$link_to_check['parent']])) {
$link_to_check = $links[$link_to_check['parent']];
}
else {
// No parent and we found no menu_name, skip.
continue 2;
}
} while ($link_to_check);
$route = $link['route_name'];
$route_local_tasks = $manager->getLocalTasksForRoute($route);
if (empty($route_local_tasks[0])) {
continue;
}
foreach ($route_local_tasks[0] as $plugin_id => $task_plugin) {
foreach ($route_local_tasks[0] as $task_plugin) {
$definition = $task_plugin->getPluginDefinition();
$local_route = $definition['route_name'];
if (empty($local_route)) {
@@ -596,7 +621,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
// "Content>Comment" also has "File" as a tab then we decide to
// set this one as parent of the added link if not the current tab
// will be the parent.
if (!empty($link['parent'])) {
if (!empty($link['parent']) && isset($links[$link['parent']])) {
$parentlink = $links[$link['parent']];
$parentlink_route = $parentlink['route_name'];
$parent_primary = $manager->getLocalTasks($parentlink_route, 0);
@@ -1,4 +0,0 @@
services:
admin_toolbar_tools.toolbar_handler:
class: Drupal\admin_toolbar_tools\ToolbarHandler
arguments: ['@module_handler']
@@ -44,7 +44,7 @@ class AdminToolbarToolsAlterTest extends WebTestBase {
*/
public function testAdminToolbarTools() {
// Assert that special menu items are present in the HTML.
$this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-help"');
$this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-flush"');
}
}
@@ -1,135 +0,0 @@
<?php
namespace Drupal\admin_toolbar_tools;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Toolbar integration handler.
*/
class ToolbarHandler implements ContainerInjectionInterface {
use StringTranslationTrait;
/**
* The module service.
*
* @var \Drupal\Core\Extension\ModuleHandler
*/
protected $moduleHandler;
/**
* ToolbarHandler constructor.
*
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* The module service.
*/
public function __construct(ModuleHandler $module_handler) {
$this->moduleHandler = $module_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('module_handler')
);
}
/**
* Lazy builder callback for the admin_toolbar_tool items.
*
* @return array
* A renderable array as expected by the renderer service.
*/
public function lazyBuilder() {
// Render the pre_render callback we disabled earlier.
$build = admin_toolbar_prerender_toolbar_administration_tray([]);
// Add links that are uncacheable.
// Core toolbar module calculates cachability in advance so we have to build
// a fake menu tree here, including access checks.
$tools_menu = &$build['administration_menu']['#items']['admin_toolbar_tools.help']['below'];
// Adding the 'Flush all caches' menu in the correct place.
$menu_render_array = $this->createMenuRenderArray('admin_toolbar_tools.flush', $this->t('Flush all caches'), TRUE);
$this->arrayInsert($tools_menu, 1, $menu_render_array);
// Adding the submenus to 'Flush all caches' menu.
if (!empty($tools_menu['admin_toolbar_tools.flush'])) {
$tools_sub_menu = &$tools_menu['admin_toolbar_tools.flush']['below'];
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.cssjs', $this->t('Flush CSS and Javascript'));
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.plugin', $this->t('Flush plugins cache'));
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_static', $this->t('Flush static cache'));
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_menu', $this->t('Flush routing and links cache'));
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_rendercache', $this->t('Flush render cache'));
// Adding a menu link to clean the Views cache.
if ($this->moduleHandler->moduleExists('views')) {
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_views', $this->t('Flush views cache'));
}
}
// Adding the 'Run Cron' menu in the correct place.
$menu_render_array = $this->createMenuRenderArray('system.run_cron', $this->t('Run cron'));
$this->arrayInsert($tools_menu, 3, $menu_render_array);
return $build;
}
/**
* Create the menu render array.
*
* @param string $route
* The route.
* @param string $title
* The menu title.
* @param bool $submenu
* Specify if the current menu element have a submenu.
*
* @return array
* A renderable array as expected by the renderer service.
*/
private function createMenuRenderArray($route, $title, $submenu = FALSE) {
$data = [];
$url = Url::fromRoute($route);
if ($url->access()) {
$data[$route] = [
'title' => $title,
'url' => $url,
'attributes' => new Attribute(['class' => ['menu-item'] + ($submenu ? ['menu-item--expanded'] : [])]),
];
if ($submenu) {
$data[$route]['below'] = [];
$data[$route]['is_expanded'] = TRUE;
}
}
return $data;
}
/**
* Insert an array in a given position of another array.
*
* @param array $array
* The array where we need to insert new elements.
* @param int $position
* The position where we will add the new array.
* @param array $insert_array
* The array that will be inserted.
*
* @see http://php.net/manual/en/function.array-splice.php#56794
*/
private function arrayInsert(array &$array, $position, array $insert_array) {
// Getting the first part of the array.
$first_array = array_splice($array, 0, $position);
// Inserting the new part in the desired position.
$array = array_merge($first_array, $insert_array, $array);
}
}
@@ -23,7 +23,7 @@
background-color: #f5f5f2;
}
.toolbar-tray-horizontal ul li.menu-item {
.toolbar-tray-horizontal ul li li.menu-item {
border-top: none transparent;
border-right: 1px solid #dddddd;
border-bottom: 1px solid #dddddd;
@@ -1,50 +1,53 @@
(function ($) {
$(document).ready(function () {
$('a.toolbar-icon').removeAttr('title');
Drupal.behaviors.adminToolbar = {
attach: function (context, settings) {
$('.toolbar-tray-horizontal li.menu-item--expanded, .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item').hoverIntent({
over: function () {
// At the current depth, we should delete all "hover-intent" classes.
// Other wise we get unwanted behaviour where menu items are expanded while already in hovering other ones.
$(this).parent().find('li').removeClass('hover-intent');
$(this).addClass('hover-intent');
},
out: function () {
$(this).removeClass('hover-intent');
},
timeout: 250
});
// Make the toolbar menu navigable with keyboard.
$('ul.toolbar-menu li.menu-item--expanded a').on('focusin', function () {
$('li.menu-item--expanded').removeClass('hover-intent');
$(this).parents('li.menu-item--expanded').addClass('hover-intent');
});
$('ul.toolbar-menu li.menu-item a').keydown(function (e) {
if ((e.shiftKey && (e.keyCode || e.which) == 9)) {
if ($(this).parent('.menu-item').prev().hasClass('menu-item--expanded')) {
$(this).parent('.menu-item').prev().addClass('hover-intent');
$('a.toolbar-icon', context).removeAttr('title');
$('.toolbar-tray-horizontal li.menu-item--expanded, .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item', context).hoverIntent({
over: function () {
// At the current depth, we should delete all "hover-intent" classes.
// Other wise we get unwanted behaviour where menu items are expanded while already in hovering other ones.
$(this).parent().find('li').removeClass('hover-intent');
$(this).addClass('hover-intent');
},
out: function () {
$(this).removeClass('hover-intent');
},
timeout: 250
});
// Make the toolbar menu navigable with keyboard.
$('ul.toolbar-menu li.menu-item--expanded a', context).on('focusin', function () {
$('li.menu-item--expanded', context).removeClass('hover-intent');
$(this).parents('li.menu-item--expanded').addClass('hover-intent');
});
$('ul.toolbar-menu li.menu-item a', context).keydown(function (e) {
if ((e.shiftKey && (e.keyCode || e.which) == 9)) {
if ($(this).parent('.menu-item').prev().hasClass('menu-item--expanded')) {
$(this).parent('.menu-item').prev().addClass('hover-intent');
}
}
}
});
});
$('.toolbar-menu:first-child > .menu-item:not(.menu-item--expanded) a, .toolbar-tab > a', context).on('focusin', function () {
$('.menu-item--expanded').removeClass('hover-intent');
});
$('.toolbar-menu:first-child > .menu-item', context).on('hover', function () {
$(this,'a').css("background: #fff;");
});
$('ul:not(.toolbar-menu)', context).on({
mousemove: function () {
$('li.menu-item--expanded').removeClass('hover-intent');
},
hover: function () {
$('li.menu-item--expanded').removeClass('hover-intent');
}
});
$('.toolbar-menu:first-child > .menu-item:not(.menu-item--expanded) a, .toolbar-tab > a').on('focusin', function () {
$('.menu-item--expanded').removeClass('hover-intent');
});
$('.toolbar-menu:first-child > .menu-item').on('hover', function () {
$(this,'a').css("background: #fff;");
});
$('ul:not(.toolbar-menu)').on({
mousemove: function () {
$('li.menu-item--expanded').removeClass('hover-intent');
},
hover: function () {
$('li.menu-item--expanded').removeClass('hover-intent');
}
});
});
}
};
})(jQuery);