upgraded contrib modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-21 12:03:46 +01:00
parent b32fe9ef14
commit 38f62621b1
217 changed files with 16074 additions and 217 deletions
@@ -0,0 +1,293 @@
Admin Toolbar 8.1.21, 2017-11-20
--------------------------------
Changes since 8.1.20:
- #2923580 by sylus, adriancid: Unsupported operand types in
ToolbarHandler::lazyBuilder().
- #2731369 by stefan.r, DuneBL, Berdir, kbasarab, joachim, adriancid: Local
tasks don't show in the toolbar.
- #2920793 by adriancid: Change the user TAKTAK by matio89 in the CHANGELOG.txt
file.
- #2873228 by smustgrave, adriancid, flocondetoile: Toolbar menu accessible and
navigable with keyboard.
- #2919775 by adriancid: Create the CHANGELOG.txt file.
- #2919772 by adriancid: Use the README.txt template.
- #2919769 by adriancid: Use the README.txt template for the admin_toolbar_tools
submodule.
- #2897309 by finne, adriancid, eme, rgpublic: admin_toolbar_tools module
makes all pages uncacheable.
- #2913299 by esod, Chi, adriancid, hudri, eme: CSS Z-Index of toolbar is
inappropriate.
- #2919390 by adriancid: Create the README.txt file for the admin toolbar links
access filter submodule.
- #2919367 by adriancid: Fix coding standard format.
- #2919346 by adriancid: Don't show menu links that you don't have access
permission for.
- #2917710: Create the .info.yml file for the admin_toolbar_links_access_filter
submodule.
- #2916064 by adriancid, eme, finne: Use in drupal.org links url parameter and
not route_name.
- #2916040 by adriancid, finne, eme: Remove unused route admin_development.
- #2915778 by finne, adriancid: Remove the _csrf_token from routes that don't
need it.
- #2909359 by adriancid, Musa.thomas: Add a menu link to clean the Views cache.
- #2910931 by adriancid: .info.yml files don't have the drupal version.
- #2759135 by Johnny vd Laar, miiimooo, romainj, chegor, adriancid, ckaotik,
bdominguez, SpadXIII, mrtndlmt: Content type, Vocabularies and Menus names are
not translated.
- #2909710 by adriancid, Musa.thomas: Fix coding standard format.
- #2910934 by adriancid, romainj: Error trying to clean the cache.
- #2910892 by adriancid: Delete the LICENSE.txt.
- #2909637 by bapi_22, Musa.thomas, adriancid: Avoid static call inside class
method.
- #2909003 by eme: fix z-index for CKEditor.
- #2504449 by robin.ingelbrecht, rwam, eme: Un-hover delay.
Admin Toolbar 8.1.20, 2017-09-07
--------------------------------
Changes since 8.1.19:
- #2887439 by romainj: Fix test.
- #2759135 by Johnny vd Laar, miiimooo, chegor, romainj: Content type,
Vocabularies and Menus names are not translated.
- #2894520 by romainj, bapi_22: Remove deprecated constant REQUEST_TIME from
code base.
- #2883098 by romainj, Alka Kumari: Admin Toolbar Extra Tools module display
theme machine names instead of labels.
- #2504449 by robin.ingelbrecht: Un-hover delay.
- #2838636 by ddrozdik, Fons Vandamme, kerby70, romainj: Issue with z-index of
dropdown in horizontal tray.
- #2838636 by Fons Vandamme, ddrozdik, romainj: Issue with z-index of dropdown
in horizontal tray.
- #2870404 by romainj: Add a link to the Webprofiler settings page.
- #2706643 by esod, romainj, Keenegan, DamienMcKenna: Use short array syntax.
Admin Toolbar 8.1.19, 2017-04-06
--------------------------------
Changes since 8.1.18:
- #2706643 by esod, romainj, Keenegan, DamienMcKenna: Use short array syntax.
- #2781745 by minakshiPh, eelkeblok, romainj, akhilavnair_zyxware: Drupal coding
standard issues found in most of the files.
- #2855720 by stefan.r, romainj: No logout link in admin toolbar anymore.
- #2841512 by Chi, romainj: User error: Redirects to external URLs are not
allowed by default.
Admin Toolbar 8.1.18, 2016-12-01
--------------------------------
Changes since 8.1.17:
- #2830677 by vaplas, romainj: z-index for sub menu.
- by romainj: Get rid of the Hello popup.
- #2805431 by marcusx: Accidentaly committed alert.
- #2630724 by squarecandy, romainj, reblutus, Hemangi Gokhale, jacoferg,
Balu Ertl, Jeff Burnz, Don Greco: Consider changes to link title parameter to
avoid tooltip visual conflict.
- #2518202 by james.williams, chegor, eme, romainj, DuneBL: Change default link
to taxonomy.
Admin Toolbar 8.1.17, 2016-08-19
--------------------------------
Changes since 8.1.16:
- #2779251 by romainj, DuneBL: Wrong integration of field_collection delete
form.
- #2776229 by Chi, romainj, mattlt: Chevron icons missing if Drupal is not in
document root.
- by romainj: CSS coding standard cleaning.
- #2781059 by mstrelan, romainj: Why is CRON in all caps?
- #2778935 by akhilavnair_zyxware, rjarraud: As per Drupal Standards each line
in documentation should not exceeds 80 characters.
- by romainj: Adds ending new line where required.
- #2776229 by Chi, rjarraud: Chevron icons missing if Drupal is not in document
root.
- by eme: Commiting again #2707611.
- #2757687 by neerajsingh: Remove usages of \Drupal::url().
- #2707747 by Balu Ertl, nevergone, eme, esod: D8 logo not rendered with smooth
antialiasing.
Admin Toolbar 8.1.16, 2016-07-28
--------------------------------
Changes since 8.1.15:
- #2723209 by andrewmacpherson, colan, mattshoaf: Enabling admin_toolbar_tools
causes Devel Settings to disappear from the main configuration page.
- #2759335 bycwells, jalpesh: fixes a mistaken link in hook_help().
- #2664564 by kolier, matio89, romainj and Michèle: auto-detect content entities
with Field UI route.
- #2735257 by colan, romainj, Balu Ertl: respect of coding standards in the
module README.txt file.
- #2735257 by colan, romainj, Balu Ertl: shortens the module README.txt
description text.
- by romainj: Fixes a problem with the link to the Admin menu overview page.
- #2735257 by Balu Ertl, colan, romainj: improves Admin Toolbar Extra Tools
description in the README.txt file.
- #2723381 by joachim, romainj: fieldable content entities are no more
hardcoded.
- #2735257 by Balu Ertl, colan, romainj: added some description details in the
README.txt files.
- by romainj: Menu link definitions updated.
- by romainj: Change routing permissions to follow Drupal default permissions
for administration pages.
- by romainj: Fixes issue #2737027.
- by romainj: fixes issue #2701825.
- by romainj: Adds the menu name for each menu item in
admin_toolbar_tools/admin_toolbar_tools.links.menu.yml file.
- #2735153 by Kionn: InvalidArgumentException: Cannot redirect to an empty URL.
в Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl().
- by matio89: correction InvalidArgumentException: Cannot redirect to an empty
URL. в Symfony\Component\HttpFoundation\RedirectResponse->setTargetUrl().
- by romainj: Add a new Render Cache shortcut on the admin menu.
- by romainj: Fixes issue #2731663 by canceling the move of the Logout menu
link.
Admin Toolbar 8.1.15, 2016-05-23
--------------------------------
Changes since 8.1.14:
- by matio89: add RTL in admin.toolbar.css.
- by romainj: Changes Devel menu item titles.
- by romainj: Fixes issue #2713899.
- by romainj: Minor code/typo cleaning.
- #2707611 by Balu Ertl: Add fine shadow under dropdown menus.
- #2707789 by esod: Fix Automated Tests.
- by romainj: Code cleaning.
- by romainj: Replace the deprecated entityManager() by entityTypeManager()
service.
- by romainj: Emptying menu cache with all link types.
- #2614962 by dbt102, seppelM, neha.gangwar, chegor: Correct text in
info.yml(s).
- by eme: Minor typo changes.
- by eme: Fix dependencies to core modules.
- by eme: Fix issue #2666964.
- by eme: Fix css background color level3.
- by eme: fix issue #2658896 and refactor and fix chevron-right.svg.
- by eme: fix Issue #2493037.
Admin Toolbar 8.1.14, 2016-02-08
--------------------------------
Changes since 8.1.13:
- by matio89: Correction differents bugs(problem white page when installing a
new module).
- #2643648 by Lord_of_Codes: Proposed README.txt file for Admin Toolbar.
- by matio89: resolving the dependecies problem(dependencies of others modules).
- by matio89: Correction route of entities.
Admin Toolbar 8.1.13, 2016-02-02
--------------------------------
Changes since 8.1.12:
- by matio89: Admin toolbar is compatible with 8.0.2.
- by matio89: Commmit dev version compatible with drupal 8.0.2.
- by matio89: New version of admin toolbar compatible with 8.0.2.
Admin Toolbar 8.1.12, 2016-01-15
--------------------------------
Changes since 8.1.11:
- by matio89: Correction AdminToolbaToolsAlterTest.
- #2493037 by mimran: Empty elements in #toolbar-bar.
- #2598136 by mimran, felribeiro: Menu items duplicated.
- #2635154 by Lukas von Blarer: Too general CSS selectors.
- by eme: Fix chevron right in local state.
Admin Toolbar 8.1.11, 2015-12-11
--------------------------------
Changes since 8.1.10:
- #2620430 by Vagelis, NarendraR: Typo.
- #2632888 by JamesK: Add dependency on node module.
- by eme: Fix admin toolbar test.
- #2552081 by jonhattan, bruvers: chevron-right.svg not found.
- by Vagelis: Minor typos.
- by eme: Refactor basic tests.
- #2613378 by chegor: Add basic test.
- #2612694 by chegor: Add new view.
- #2627918 by joe_carvajal: Version in info.yml files does Update Manager try to
update.
- by matio89: correction collapsible behaviour in vertical menu layout.
- #2582825 by Ben Coleman: Installing Admin Toolbar Tools loses anonymous user
login link.
- by matio89: Correction the login link on the site when in a logged-out state.
Admin Toolbar 8.1.10, 2015-08-07
--------------------------------
Changes since 8.1.9:
- #2546939 by jonhattan: Add dependency on toolbar module.
Admin Toolbar 8.1.9, 2015-07-22
-------------------------------
Changes since 8.1.8:
- #2537016 by matio89: Removing dependance for user & system.
- #2533420 by Dave Reid, twistor: Chase HEAD changes in toolbar.
- #2537016 by twistor: Rewrite admin_toolbar_tools.module
- by matio89: Correction all bugs and add new security features.
Admin Toolbar 8.1.8, 2015-06-22
-------------------------------
Changes since 8.1.7:
- correction not found route.
- #2493037 by bobrov1989: Empty elements in #toolbar-bar.
- by fethi: icones.
Admin Toolbar 8.1.7, 2015-06-22
-------------------------------
Changes since 8.1.6:
- correction not found route.
- #2493037 by bobrov1989: Empty elements in #toolbar-bar.
- by fethi: icones.
Admin Toolbar 8.1.6, 2015-06-03
-------------------------------
Changes since 8.1.5:
- by matio89: correction admin_toolbar.
Admin Toolbar 8.1.5, 2015-06-03
-------------------------------
Changes since 8.1.4:
- by matio89: test if module update exist or no to display install and update
module.
- by fethi: Change the colors used to match the Seven styleguide.
- by matio89: compatibility with Drupal 8 béta 11.
- by fethi: Change the colors used to match the Seven styleguide.
Admin Toolbar 8.1.4, 2015-05-20
-------------------------------
Changes since 8.1.3:
- by matio89: correction add/node.
Admin Toolbar 8.1.3, 2015-05-19
-------------------------------
Changes since 8.1.2:
- by matio89: add new functionalities.
- by matio89: add administration devel link.
- by matio89: correction reload page.
- by matio89: correction redirect to the same page.
Admin Toolbar 8.1.2, 2015-05-19
-------------------------------
Changes since 8.1.1:
- by matio89: add new functionalities.
- by matio89: add administration devel link.
- by matio89: correction reload page.
- by matio89: correction redirect to the same page.
Admin Toolbar 8.1.1, 2015-05-19
-------------------------------
Changes since 8.1.0:
- by matio89: add new functionalities.
Admin Toolbar 8.1.0, 2015-05-07
-------------------------------
- Initial release.
@@ -1,45 +1,69 @@
---SUMMARY---
CONTENTS OF THIS FILE
---------------------
Admin Toolbar intends to improve the default Drupal Toolbar to transformit into
* Introduction
* Requirements
* Recommended modules
* Installation
* Configuration
* Maintainers
INTRODUCTION
------------
Admin Toolbar intends to improve the default Drupal Toolbar to transform it into
a drop-down menu, providing a fast and full access to all administration links.
For a full description visit project page:
https://www.drupal.org/project/admin_toolbar
* For a full description of the module, visit the project page:
https://www.drupal.org/project/admin_toolbar
Bug reports, feature suggestions and latest developments:
http://drupal.org/project/issues/admin_toolbar
* To submit bug reports and feature suggestions, or to track changes:
https://www.drupal.org/project/issues/search/admin_toolbar
---REQUIREMENTS---
REQUIREMENTS
------------
No special requirements.
*None. (Other than a clean Drupal 8 installation)
RECOMMENDED MODULES
-------------------
* Admin Toolbar Extra Tools (https://www.drupal.org/project/admin_toolbar):
Provides menu links to administration pages or actions (eg. Flushing caches)
that are not generated by Drupal core.
* Admin Toolbar Links Access Filter (https://www.drupal.org/node/2474539):
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.
INSTALLATION
------------
* Install as you would normally install a contributed Drupal module.
See: https://www.drupal.org/node/895232 for further information.
---INSTALLATION---
CONFIGURATION
-------------
No configuration is needed.
Install as usual.
Place the entirety of this directory in the /modules folder of your Drupal
installation. Navigate to Administer > Extend. Check the 'Enabled' box next
to the 'Admin toolbar' and/or 'Admin toolbar Extra Tools' and then click
the 'Save Configuration' button at the bottom.
For help regarding installation, visit:
https://www.drupal.org/documentation/install/modules-themes/modules-8
---CONTACT---
Current Maintainers:
*Wilfrid Roze (eme) - https://www.drupal.org/u/eme
*Mohamed Anis Taktak (matio89) - https://www.drupal.org/u/matio89
MAINTAINERS
-----------
Current maintainers:
* Wilfrid Roze (eme) - https://www.drupal.org/u/eme
* Romain Jarraud (romainj) - https://www.drupal.org/u/romainj
* Adrian Cid Almaguer (adriancid) - https://www.drupal.org/u/adriancid
* Mohamed Anis Taktak (matio89) - https://www.drupal.org/u/matio89
This project has been sponsored by:
*emerya
Founded in 2009, emerya is a human-sized company, dedicated to the design
and implementation of web interfaces.
Visit: http://http://emerya.fr/ for more information.
* emerya
Founded in 2009, emerya is a human-sized company, dedicated to the design and
implementation of web interfaces. Visit: http://http://emerya.fr/ for more
information.
@@ -1,13 +1,15 @@
name: Admin Toolbar
# core: 8.x
description: Provides a drop-down menu interface to the core Drupal Toolbar.
package: Administration
type: module
# core: 8.x
dependencies:
- toolbar
# Information added by Drupal.org packaging script on 2017-09-12
version: '8.x-1.20'
# Information added by Drupal.org packaging script on 2017-11-20
version: '8.x-1.21'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1505199847
datestamp: 1511190792
@@ -23,9 +23,15 @@ function admin_toolbar_toolbar_alter(&$items) {
function admin_toolbar_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.admin_toolbar':
$variables = [
':toolbar' => Url::fromRoute('help.page', ['name' => 'toolbar'])->toString(),
':automated_cron' => (\Drupal::moduleHandler()->moduleExists('automated_cron')) ? Url::fromRoute('help.page', ['name' => 'automated_cron'])->toString() : '#',
':admin_toolbar_documentation' => 'https://www.drupal.org/node/2713693',
];
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar module enhances the <a href=":toolbar">Toolbar</a> module by providing fast access to all the administrative links at the top of your site. Admin Toolbar remains a very "lightweight" module by closely integrating with all Toolbar functionality. It can be used in conjunction with all the sub or complimentary modules, listed on <a href="https://www.drupal.org/project/admin_toolbar">Admin Toolbar</a>, for quick access to system commands such as Flush all caches, <a href=":automated_cron">Run cron</a>, Run Updates, etc... For more information, see <a href=":admin_toolbar_documentation">the online documentation for the Admin Toolbar module</a>.', [':toolbar' => Url::fromRoute('help.page', ['name' => 'toolbar'])->toString(), ':automated_cron' => (\Drupal::moduleHandler()->moduleExists('automated_cron')) ? Url::fromRoute('help.page', ['name' => 'automated_cron'])->toString() : '#', ':admin_toolbar_documentation' => 'https://www.drupal.org/node/2713693']) . '</p>';
$output .= '<p>' . t('The Admin Toolbar module enhances the <a href=":toolbar">Toolbar</a> module by providing fast access to all the administrative links at the top of your site. Admin Toolbar remains a very "lightweight" module by closely integrating with all Toolbar functionality. It can be used in conjunction with all the sub or complimentary modules, listed on <a href="https://www.drupal.org/project/admin_toolbar">Admin Toolbar</a>, for quick access to system commands such as Flush all caches, <a href=":automated_cron">Run cron</a>, Run Updates, etc... For more information, see <a href=":admin_toolbar_documentation">the online documentation for the Admin Toolbar module</a>.', $variables) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<p>' . t('The Admin Toolbar greatly improves the user experience for those who regularly interact with the Drupal Toolbar by providing fast, full access to all links in the Drupal Toolbar without having to click to get there.') . '</p>';
@@ -83,7 +89,8 @@ function toolbar_tools_menu_navigation_links(array $tree) {
$definition = $link->getPluginDefinition();
$element->options['attributes']['class'][] = 'toolbar-icon';
$element->options['attributes']['class'][] = 'toolbar-icon-' . strtolower(str_replace(['.', ' ', '_'], ['-', '-', '-'], $definition['id']));
$string = strtolower(str_replace(['.', ' ', '_'], ['-', '-', '-'], $definition['id']));
$element->options['attributes']['class'][] = 'toolbar-icon-' . $string;
$element->options['attributes']['title'] = $link->getDescription();
}
return $tree;
@@ -0,0 +1,61 @@
CONTENTS OF THIS FILE
---------------------
* Introduction
* Requirements
* Recommended modules
* Installation
* Configuration
* Maintainers
INTRODUCTION
------------
The Admin Toolbar Links Access Filter module 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
https://www.drupal.org/node/296693 be solved, this module will be deprecated.
* To know why we create this module check this issue:
https://www.drupal.org/node/2917704
* To submit bug reports and feature suggestions, or to track changes:
https://www.drupal.org/project/issues/search/admin_toolbar
REQUIREMENTS
------------
No special requirements.
RECOMMENDED MODULES
-------------------
* Admin Toolbar (https://www.drupal.org/project/admin_toolbar):
Improve the default Drupal Toolbar (the administration menu at the top of
your site) to transform it into a drop-down menu, providing a fast access to
all administration pages.
INSTALLATION
------------
* Install as you would normally install a contributed Drupal module.
See: https://www.drupal.org/node/895232 for further information.
CONFIGURATION
-------------
No configuration is needed.
MAINTAINERS
-----------
Current maintainers:
* Wilfrid Roze (eme) - https://www.drupal.org/u/eme
* Romain Jarraud (romainj) - https://www.drupal.org/u/romainj
* Adrian Cid Almaguer (adriancid) - https://www.drupal.org/u/adriancid
@@ -0,0 +1,12 @@
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
type: module
# core: 8.x
# Information added by Drupal.org packaging script on 2017-11-20
version: '8.x-1.21'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1511190792
@@ -0,0 +1,176 @@
<?php
/**
* @file
* This module don't show menu links that you don't have access permission for.
*/
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\user\Entity\Role;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
/**
* Implements hook_preprocess_menu().
*
* Hides links from admin menu, if user doesn't have access rights.
*/
function admin_toolbar_links_access_filter_preprocess_menu(&$variables) {
if (empty($variables['items'])) {
// Additional empty check to prevent exotic situations, where the preprocess
// function is entered even without items.
// @see https://www.drupal.org/node/2833885
return;
}
// Ensure that menu_name exists.
if (!isset($variables['menu_name'])) {
// In rare cases (for unknown reasons) menu_name may not be set.
// As fallback, we can fetch it from the first menu item.
$first_link = reset($variables['items']);
/** @var Drupal\Core\Menu\MenuLinkDefault $original_link */
// Fetch the menu_name from the original link.
$original_link = $first_link['original_link'];
$variables['menu_name'] = $original_link->getMenuName();
}
if ($variables['menu_name'] == 'admin') {
if (!admin_toolbar_links_access_filter_user_has_admin_role($variables['user'])) {
admin_toolbar_links_access_filter_filter_non_accessible_links($variables['items']);
}
}
}
/**
* Hides links from admin menu, if user doesn't have access rights.
*/
function admin_toolbar_links_access_filter_filter_non_accessible_links(array &$items) {
foreach ($items as $route => &$item) {
$route_name = $route;
$route_params = [];
if (!empty($item['original_link'])) {
/** @var \Drupal\Core\Menu\MenuLinkBase $original_link */
$original_link = $item['original_link'];
if ($original_link->getUrlObject()->isExternal()) {
// Do not filter external URL at all.
continue;
}
$route_name = $original_link->getRouteName();
$route_params = $original_link->getRouteParameters();
}
// Check, if user has access rights to the route.
if (!\Drupal::accessManager()->checkNamedRoute($route_name, $route_params)) {
unset($items[$route]);
}
else {
if (!empty($items[$route]['below'])) {
// Recursively call this function for the child items.
admin_toolbar_links_access_filter_filter_non_accessible_links($items[$route]['below']);
}
if (empty($items[$route]['below']) && \Drupal::moduleHandler()->moduleExists('admin_toolbar')) {
// Every child item has been cleared out.
// Now check, if the given route represents an overview page only,
// without having functionality on its own. In this case, we can safely
// unset this item, as there aren't any children left.
// This assumption is only valid, when the admin_toolbar module is
// installed because otherwise we won't have child items at all.
if (admin_toolbar_links_access_filter_is_overview_page($route)) {
unset($items[$route]);
}
else {
// Let's remove the expanded flag.
$items[$route]['is_expanded'] = FALSE;
}
}
}
}
}
/**
* Implements template_preprocess_admin_block_content().
*/
function admin_toolbar_links_access_filter_admin_block_content(&$variables) {
if (!admin_toolbar_links_access_filter_user_has_admin_role($variables['user'])) {
foreach ($variables['content'] as $key => &$item) {
if (isset($item['url']) && $item['url'] instanceof Url) {
/* @var \Drupal\Core\Url $url */
$url = $item['url'];
if ($url->access()) {
continue;
}
unset($variables['content'][$key]);
}
// The key is structured in the form: "ID title route",
// concatenated with spaces.
$key_parts = explode(' ', $key);
$route = end($key_parts);
// Special handling for Views pages, as they are not defined
// system routes.
// @TODO check the permission for Views + find a generic way for similar
// cases. Best way would be to get the link entity somehow to properly
// check permissions.
if (strpos($route, 'views_view:') === 0) {
continue;
}
// Check, if user has access rights to the route.
if (!\Drupal::accessManager()->checkNamedRoute($route)) {
unset($variables['content'][$key]);
}
}
}
}
/**
* Checks if the given route name is an overview page.
*
* Checks if the given route name matches a pure (admin) overview page that can
* be skipped, if there are no child items set. The typical example are routes
* having the SystemController::systemAdminMenuBlockPage() function as their
* controller callback set.
*
* @param string $route_name
* The route name to check.
*
* @return bool
* TRUE, if the given route name matches a pure admin overview page route,
* FALSE otherwise.
*/
function admin_toolbar_links_access_filter_is_overview_page($route_name) {
// @var \Drupal\Core\Routing\RouteProviderInterface $route_provider.
$route_provider = \Drupal::service('router.route_provider');
$overview_page_controllers = [
'\Drupal\system\Controller\AdminController::index',
'\Drupal\system\Controller\SystemController::overview',
'\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage',
];
try {
$route = $route_provider->getRouteByName($route_name);
$controller = $route->getDefault('_controller');
return !empty($controller) && in_array($controller, $overview_page_controllers);
}
catch (RouteNotFoundException $ex) {
}
return FALSE;
}
/**
* Checks, if the given user has admin rights.
*
* @param \Drupal\Core\Session\AccountInterface $account
* The account to check.
*
* @return bool
* TRUE, if the given user account has at least one role with admin rights
* assigned, FALSE otherwise.
*/
function admin_toolbar_links_access_filter_user_has_admin_role(AccountInterface $account) {
foreach ($account->getRoles() as $role_id) {
if (Role::load($role_id)->isAdmin()) {
return TRUE;
}
}
return FALSE;
}
@@ -1,45 +1,71 @@
---SUMMARY---
CONTENTS OF THIS FILE
---------------------
* Introduction
* Requirements
* Recommended modules
* Installation
* Configuration
* Maintainers
INTRODUCTION
------------
Admin Toolbar Extra Tools provides menu links to administration pages or actions
(eg. Flushing caches) that are not generated by Drupal core. It adds menu items
that are not generated by Drupal core. For example there are no menu items for
each content type by default or menu links to Manage fields on each entity types.
That's the purpose of Admin Toolbar Extra Tools to add them.
each content type by default or menu links to Manage fields on each entity
types. That's the purpose of Admin Toolbar Extra Tools to add them.
For a full description visit project page:
https://www.drupal.org/project/admin_toolbar
* For a full description of the module, visit the project page:
https://www.drupal.org/project/admin_toolbar
Bug reports, feature suggestions and latest developments:
http://drupal.org/project/issues/admin_toolbar
* To submit bug reports and feature suggestions, or to track changes:
https://www.drupal.org/project/issues/search/admin_toolbar
---REQUIREMENTS---
REQUIREMENTS
------------
*Admin Toolbar.
This module requires the following modules:
* Admin Toolbar (https://www.drupal.org/project/admin_toolbar)
---INSTALLATION---
RECOMMENDED MODULES
-------------------
Install as usual.
Place the entirety of this directory in the /modules folder of your Drupal
installation. Navigate to Administer > Extend. Check the 'Enabled' box next
'Admin toolbar Extra Tools' and then click the 'Save Configuration' button at
the bottom.
For help regarding installation, visit:
https://www.drupal.org/documentation/install/modules-themes/modules-8
* Admin Toolbar (https://www.drupal.org/project/admin_toolbar):
Improve the default Drupal Toolbar (the administration menu at the top of
your site) to transform it into a drop-down menu, providing a fast access to
all administration pages.
---CONTACT---
INSTALLATION
------------
Current Maintainers:
*Wilfrid Roze (eme) - https://www.drupal.org/u/eme
*Mohamed Anis Taktak (matio89) - https://www.drupal.org/u/matio89
* Install as you would normally install a contributed Drupal module.
See: https://www.drupal.org/node/895232 for further information.
CONFIGURATION
-------------
No configuration is needed.
MAINTAINERS
-----------
Current maintainers:
* Wilfrid Roze (eme) - https://www.drupal.org/u/eme
* Romain Jarraud (romainj) - https://www.drupal.org/u/romainj
* Adrian Cid Almaguer (adriancid) - https://www.drupal.org/u/adriancid
* Mohamed Anis Taktak (matio89) - https://www.drupal.org/u/matio89
This project has been sponsored by:
*emerya
Founded in 2009, emerya is a human-sized company, dedicated to the design and
implementation of web interfaces.
Visit: http://http://emerya.fr/ for more information.
* emerya
Founded in 2009, emerya is a human-sized company, dedicated to the design and
implementation of web interfaces. Visit: http://http://emerya.fr/ for more
information.
@@ -1,13 +1,15 @@
name: Admin Toolbar Extra Tools
# core: 8.x
description: Adds menu links to the Admin Toolbar.
package: Administration
type: module
# core: 8.x
dependencies:
- admin_toolbar
# Information added by Drupal.org packaging script on 2017-09-12
version: '8.x-1.20'
# Information added by Drupal.org packaging script on 2017-11-20
version: '8.x-1.21'
core: '8.x'
project: 'admin_toolbar'
datestamp: 1505199847
datestamp: 1511190792
@@ -12,13 +12,6 @@ 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
@@ -32,60 +25,23 @@ 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
route_name: admin_toolbar_tools.drupalorg
url: https://www.drupal.org
parent: admin_toolbar_tools.help
menu_name: admin
admin_toolbar_tools.listchanges:
title: 'Change records for Drupal core'
weight: -6
route_name: admin_toolbar_tools.listchanges
url: https://www.drupal.org/list-changes
parent: admin_toolbar_tools.drupalorg
menu_name: admin
admin_toolbar_tools.doc:
title: 'D8 API documentation'
weight: -5
route_name: admin_toolbar_tools.doc
url: https://api.drupal.org/api/drupal/8
parent: admin_toolbar_tools.drupalorg
menu_name: admin
@@ -5,7 +5,9 @@
* Provides extra menu links for the core drupal toolbar.
*/
use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* Implements hook_toolbar().
@@ -26,16 +28,38 @@ 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().
*/
function admin_toolbar_tools_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.admin_toolbar_tools':
$url = Url::fromUri('https://www.drupal.org/project/admin_toolbar');
$external_link = Link::fromTextAndUrl(t('Admin Toolbar'), $url);
$external_link2 = Link::fromTextAndUrl(t('Toolbar'), $url);
$url = Url::fromUri('https://www.drupal.org/node/2713693');
$external_link3 = Link::fromTextAndUrl(t('online documentation for Admin Toolbar'), $url);
$output = '';
$output .= '<p>' . t('The Admin Toolbar Extra Tools module comes packaged with the <a href="https://www.drupal.org/project/admin_toolbar"> Admin Toolbar</a> module and adds functionality to it. The additional functionality is accessed thru extra links on the main administration <a href="https://www.drupal.org/project/toolbar">Toolbar</a>. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page. For more information, see the <a href="https://www.drupal.org/node/2713693">online documentation for Admin Toolbar</a>') . '</p>';
$output .= '<p>';
$output .= t('The Admin Toolbar Extra Tools module comes packaged with the :link module and adds functionality to it. The additional functionality is accessed thru extra links on the main administration :link2. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page. For more information, see the :link3', [
':link' => $external_link,
':link2' => $external_link2,
':link3' => $external_link3,
]);
$output .= '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<p>' . t('To use Admin Toolbar Extra Tools just install it like any other module. There is no other configuration required. The Admin Toolbar functionality can be further extended by installing complimentary modules. See <a href="https://www.drupal.org/project/admin_toolbar">Admin Toolbar</a> for a complete listing of these complimentary modules.') . '</p>';
$output .= '<p>' . t('To use Admin Toolbar Extra Tools just install it like any other module. There is no other configuration required. The Admin Toolbar functionality can be further extended by installing complimentary modules. See :link for a complete listing of these complimentary modules.', [':link' => $external_link]) . '</p>';
return $output;
}
@@ -510,6 +534,97 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
];
}
}
// Add menu links for local tasks that sit below any admin menu link routes.
$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') {
continue;
}
$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) {
$definition = $task_plugin->getPluginDefinition();
$local_route = $definition['route_name'];
if (empty($local_route)) {
continue;
}
$exists = FALSE;
$param = FALSE;
if (isset($link['route_parameters'])) {
$param = $link['route_parameters'];
}
// Check if local task has an already registered link in toolbar.
foreach ($links as $link2) {
// Route_name that could be a 'class'.
if (!(isset($link2['route_name']) && ($link2['route_name'] == $local_route))) {
continue;
}
// If route are equal, the parameters could be different.
// @todo: check if this is true.
if ($param) {
if (isset($link2['route_parameters']) && ($param == $link2['route_parameters'])) {
$exists = TRUE;
break;
}
}
else {
$exists = TRUE;
break;
}
}
$parent = FALSE;
if ($exists) {
continue;
}
$title = $definition['title'];
$title = $param ? $title . ' ' . $link['title'] : $title;
// The following code is to choose the parent of the added link.
// If the parent of the current tab also has the tab as local task
// for example: "Content" has "File" as task" and and
// "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'])) {
$parentlink = $links[$link['parent']];
$parentlink_route = $parentlink['route_name'];
$parent_primary = $manager->getLocalTasks($parentlink_route, 0);
foreach ($parent_primary['tabs'] as $parent_tab) {
if ($parent_tab['#link']['url']) {
$parent_route = $parent_tab['#link']['url']->getRouteName();
if ($parent_route == $local_route) {
$parent = $link['parent'];
break;
}
}
}
}
$parent = $parent ? $parent : $key;
// Make sure the key of the route is unique.
$links[$key . '_' . $local_route] = [
'title' => $title,
'route_name' => $local_route,
'menu_name' => 'admin',
'parent' => $parent,
'att' => TRUE,
];
if ($param) {
$links[$key . '_' . $local_route]['route_parameters'] = $param;
}
}
}
}
/**
@@ -6,38 +6,43 @@ admin_toolbar_tools.flush:
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.cssjs:
path: '/admin/flush/cssjs'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flush_js_css'
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushJsCss'
_title: 'Flush Css and Javascript'
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.plugin:
path: '/admin/flush/plugin'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flush_plugins'
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushPlugins'
_title: 'Plugin'
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.flush_static:
path: '/admin/flush/static-caches'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flush_static'
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushStatic'
_title: 'Static caches'
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.flush_menu:
path: '/admin/flush/menu'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flush_menu'
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushMenu'
_title: 'Menu'
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.flush_rendercache:
path: '/admin/flush/rendercache'
defaults:
@@ -46,38 +51,16 @@ admin_toolbar_tools.flush_rendercache:
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar_tools.drupalorg:
path: '/admin/drupal8'
admin_toolbar_tools.flush_views:
path: '/admin/flush/views'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::drupal_org'
_title: 'Drupal'
requirements:
_permission: 'access administration pages'
_csrf_token: 'TRUE'
admin_toolbar_tools.listchanges:
path: '/admin/drupal/list-changes'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::list_changes'
_title: 'List changes'
requirements:
_permission: 'access administration pages'
_csrf_token: 'TRUE'
admin_toolbar_tools.doc:
path: '/admin/drupal/documentation'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::documentation'
_title: 'Documentation D8'
requirements:
_permission: 'access administration pages'
_csrf_token: 'TRUE'
admin_development:
path: '/admin/development'
defaults:
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::development'
_title: 'Development'
_controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushViews'
_title: 'Views'
requirements:
_permission: 'administer site configuration'
_csrf_token: 'TRUE'
admin_toolbar.run.cron:
path: '/run-cron'
defaults:
@@ -0,0 +1,4 @@
services:
admin_toolbar_tools.toolbar_handler:
class: Drupal\admin_toolbar_tools\ToolbarHandler
arguments: ['@module_handler']
@@ -2,43 +2,91 @@
namespace Drupal\admin_toolbar_tools\Controller;
use Drupal\Component\Datetime\Time;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\CronInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Component\Datetime\Time;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Core\Menu\ContextualLinkManager;
use Drupal\Core\Menu\LocalActionManager;
use Drupal\Core\Menu\LocalTaskManager;
use Drupal\Core\Menu\MenuLinkManager;
use Drupal\Core\Plugin\CachedDiscoveryClearerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Class ToolbarController
* Class ToolbarController.
*
* @package Drupal\admin_toolbar_tools\Controller
*/
class ToolbarController extends ControllerBase {
/**
* The cron service.
* A cron instance.
*
* @var $cron \Drupal\Core\CronInterface
* @var \Drupal\Core\CronInterface
*/
protected $cron;
/**
* A menu link manager instance.
*
* @var \Drupal\Core\Menu\MenuLinkManager
*/
protected $menuLinkManager;
/**
* A context link manager instance.
*
* @var \Drupal\Core\Menu\ContextualLinkManager
*/
protected $contextualLinkManager;
/**
* A local task manager instance.
*
* @var \Drupal\Core\Menu\LocalTaskManager
*/
protected $localTaskLinkManager;
/**
* A local action manager instance.
*
* @var \Drupal\Core\Menu\LocalActionManager
*/
protected $localActionLinkManager;
/**
* A cache backend interface instance.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
protected $cacheRender;
/**
* A date time instance.
*
* @var \Drupal\Component\Datetime\Time
*/
protected $time;
/**
* Constructs a CronController object.
* A request stack symfony instance.
*
* @param \Drupal\Core\CronInterface $cron
* The cron service.
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* A plugin cache clear instance.
*
* @var \Drupal\Core\Plugin\CachedDiscoveryClearerInterface
*/
protected $pluginCacheClearer;
/**
* {@inheritdoc}
*/
public function __construct(CronInterface $cron,
MenuLinkManager $menuLinkManager,
@@ -46,7 +94,9 @@ class ToolbarController extends ControllerBase {
LocalTaskManager $localTaskLinkManager,
LocalActionManager $localActionLinkManager,
CacheBackendInterface $cacheRender,
Time $time) {
Time $time,
RequestStack $request_stack,
CachedDiscoveryClearerInterface $plugin_cache_clearer) {
$this->cron = $cron;
$this->menuLinkManager = $menuLinkManager;
$this->contextualLinkManager = $contextualLinkManager;
@@ -54,6 +104,8 @@ class ToolbarController extends ControllerBase {
$this->localActionLinkManager = $localActionLinkManager;
$this->cacheRender = $cacheRender;
$this->time = $time;
$this->requestStack = $request_stack;
$this->pluginCacheClearer = $plugin_cache_clearer;
}
/**
@@ -67,15 +119,17 @@ class ToolbarController extends ControllerBase {
$container->get('plugin.manager.menu.local_task'),
$container->get('plugin.manager.menu.local_action'),
$container->get('cache.render'),
$container->get('datetime.time')
$container->get('datetime.time'),
$container->get('request_stack'),
$container->get('plugin.cache_clearer')
);
}
/**
* Reload the previous page.
*/
public function reload_page() {
$request = \Drupal::request();
public function reloadPage() {
$request = $this->requestStack->getCurrentRequest();
if ($request->server->get('HTTP_REFERER')) {
return $request->server->get('HTTP_REFERER');
}
@@ -90,83 +144,57 @@ class ToolbarController extends ControllerBase {
public function flushAll() {
drupal_flush_all_caches();
drupal_set_message($this->t('All caches cleared.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
/**
* Flushes css and javascript caches.
*/
public function flush_js_css() {
\Drupal::state()
public function flushJsCss() {
$this->state()
->set('system.css_js_query_string', base_convert($this->time->getCurrentTime(), 10, 36));
drupal_set_message($this->t('CSS and JavaScript cache cleared.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
/**
* Flushes plugins caches.
*/
public function flush_plugins() {
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
public function flushPlugins() {
$this->pluginCacheClearer->clearCachedDefinitions();
drupal_set_message($this->t('Plugins cache cleared.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
/**
* Resets all static caches.
*/
public function flush_static() {
public function flushStatic() {
drupal_static_reset();
drupal_set_message($this->t('Static cache cleared.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
/**
* Clears all cached menu data.
*/
public function flush_menu() {
public function flushMenu() {
menu_cache_clear_all();
$this->menuLinkManager->rebuild();
$this->contextualLinkManager->clearCachedDefinitions();
$this->localTaskLinkManager->clearCachedDefinitions();
$this->localActionLinkManager->clearCachedDefinitions();
drupal_set_message($this->t('Routing and links cache cleared.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
/**
* Links to drupal.org home page.
* Clears all cached views data.
*/
public function drupal_org() {
$response = new TrustedRedirectResponse("https://www.drupal.org");
$response->send();
return $response;
}
/**
* Displays the administration link Development.
*/
public function development() {
return new RedirectResponse('/admin/structure/menu/');
}
/**
* Access to Drupal 8 changes.
* (list changes of the different versions of drupal core).
*/
public function list_changes() {
$response = new TrustedRedirectResponse("https://www.drupal.org/list-changes");
$response->send();
return $response;
}
/**
* Adds a link to the Drupal 8 documentation.
*/
public function documentation() {
$response = new TrustedRedirectResponse("https://api.drupal.org/api/drupal/8");
$response->send();
return $response;
public function flushViews() {
views_invalidate_cache();
drupal_set_message($this->t('Views cache cleared.'));
return new RedirectResponse($this->reloadPage());
}
/**
@@ -175,7 +203,7 @@ class ToolbarController extends ControllerBase {
public function runCron() {
$this->cron->run();
drupal_set_message($this->t('Cron ran successfully.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
/**
@@ -184,7 +212,7 @@ class ToolbarController extends ControllerBase {
public function cacheRender() {
$this->cacheRender->invalidateAll();
drupal_set_message($this->t('Render cache cleared.'));
return new RedirectResponse($this->reload_page());
return new RedirectResponse($this->reloadPage());
}
}
@@ -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-flush"');
$this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-help"');
}
}
@@ -0,0 +1,135 @@
<?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);
}
}
@@ -1,15 +1,18 @@
/*---------------------- menu horizontal hover---- Krout Fethi FrontEnd Developer-----*/
#toolbar-bar {
z-index: 9999;
}
.toolbar-tray-horizontal .menu-item:hover {
background: #fff;
}
.toolbar-tray-horizontal .menu-item:focus {
.toolbar-tray-horizontal .menu-item a:focus {
background: #abeae4;
}
.toolbar-tray-horizontal .toolbar-menu:not(:first-child) li.menu-item--expanded > a:focus {
background-position: center right;
background-image: url('../misc/icons/0074bd/chevron-right.svg');
background-repeat: no-repeat;
}
.toolbar-tray-horizontal .menu-item--expanded .menu {
background: #fff;
width: auto;
@@ -82,6 +85,10 @@
margin: -40px 0 0 197px;
}
.toolbar-tray-horizontal li:hover ul li {
float: none;
}
.toolbar-tray-horizontal li.hover-intent ul li {
float: none;
}
@@ -110,6 +117,10 @@
float: none !important;
}
[dir="rtl"] .toolbar-tray-horizontal li:focus ul li {
float: none !important;
}
[dir="rtl"] .toolbar .toolbar-menu ul .toolbar-icon {
padding-left: 1.3333em;
}
@@ -118,6 +129,10 @@
margin: -40px 197px 0 0;
}
[dir="rtl"] .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item:focus ul {
margin: -40px 197px 0 0;
}
[dir="rtl"] .toolbar-tray-horizontal ul li.menu-item--expanded ul li.menu-item--expanded {
background-position: center left;
background-image: url('../misc/icons/0074bd/chevron-left.svg');
@@ -12,7 +12,39 @@
out: function () {
$(this).removeClass('hover-intent');
},
timeout: 500
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');
}
}
});
$('.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);
@@ -4,7 +4,6 @@ namespace Drupal\admin_toolbar\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Test the existence of Admin Toolbar module.
*
@@ -43,8 +42,9 @@ class AdminToolbarAlterTest extends WebTestBase {
/**
* Tests for a the hover of sub menus.
*/
function testAdminToolbar() {
public function testAdminToolbar() {
// Assert that expanded links are present in the HTML.
$this->assertRaw('class="toolbar-icon toolbar-icon-user-admin-index"');
}
}