Browse Source

updated contrib modules : migrate_tools, migrate_plus, piwik -> matomo, color_field, config_filter, admin_toolbar

Bachir Soussi Chiadmi 6 years ago
parent
commit
4caa864a8f
100 changed files with 5270 additions and 808 deletions
  1. 98 71
      sites/all/modules/contrib/admin/admin_toolbar/CHANGELOG.txt
  2. 4 4
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar.info.yml
  3. 0 1
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar.module
  4. 0 10
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/README.txt
  5. 3 3
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml
  6. 12 5
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module
  7. 38 0
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/composer.json
  8. 0 9
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/README.txt
  9. 4 3
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml
  10. 6 0
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml
  11. 12 13
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module
  12. 9 0
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.routing.yml
  13. 39 0
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/composer.json
  14. 47 16
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php
  15. 8 4
      sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/tests/src/Functional/AdminToolbarToolsAlterTest.php
  16. 26 8
      sites/all/modules/contrib/admin/admin_toolbar/composer.json
  17. 8 4
      sites/all/modules/contrib/admin/admin_toolbar/tests/src/Functional/AdminToolbarAlterTest.php
  18. 5 0
      sites/all/modules/contrib/admin/matomo/.eslintrc
  19. 339 0
      sites/all/modules/contrib/admin/matomo/LICENSE.txt
  20. 109 0
      sites/all/modules/contrib/admin/matomo/README.txt
  21. 22 0
      sites/all/modules/contrib/admin/matomo/composer.json
  22. 29 0
      sites/all/modules/contrib/admin/matomo/config/install/matomo.settings.yml
  23. 120 0
      sites/all/modules/contrib/admin/matomo/config/schema/matomo.schema.yml
  24. 141 0
      sites/all/modules/contrib/admin/matomo/js/matomo.admin.js
  25. 41 0
      sites/all/modules/contrib/admin/matomo/js/matomo.js
  26. 15 0
      sites/all/modules/contrib/admin/matomo/matomo.info.yml
  27. 54 0
      sites/all/modules/contrib/admin/matomo/matomo.install
  28. 15 0
      sites/all/modules/contrib/admin/matomo/matomo.libraries.yml
  29. 5 0
      sites/all/modules/contrib/admin/matomo/matomo.links.menu.yml
  30. 4 0
      sites/all/modules/contrib/admin/matomo/matomo.links.task.yml
  31. 732 0
      sites/all/modules/contrib/admin/matomo/matomo.module
  32. 14 0
      sites/all/modules/contrib/admin/matomo/matomo.permissions.yml
  33. 7 0
      sites/all/modules/contrib/admin/matomo/matomo.routing.yml
  34. 60 0
      sites/all/modules/contrib/admin/matomo/matomo.tokens.inc
  35. 70 0
      sites/all/modules/contrib/admin/matomo/migration_templates/d6_matomo_settings.yml
  36. 22 0
      sites/all/modules/contrib/admin/matomo/migration_templates/d6_matomo_user_settings.yml
  37. 77 0
      sites/all/modules/contrib/admin/matomo/migration_templates/d7_matomo_settings.yml
  38. 22 0
      sites/all/modules/contrib/admin/matomo/migration_templates/d7_matomo_user_settings.yml
  39. 43 0
      sites/all/modules/contrib/admin/matomo/src/Component/Render/MatomoJavaScriptSnippet.php
  40. 336 0
      sites/all/modules/contrib/admin/matomo/src/Form/MatomoAdminSettingsForm.php
  41. 27 0
      sites/all/modules/contrib/admin/matomo/src/Plugin/migrate/process/MatomoCustomVars.php
  42. 113 0
      sites/all/modules/contrib/admin/matomo/src/Plugin/migrate/process/MatomoVisibilityPages.php
  43. 87 0
      sites/all/modules/contrib/admin/matomo/src/Plugin/migrate/process/MatomoVisibilityRoles.php
  44. 222 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoBasicTest.php
  45. 59 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoCustomUrls.php
  46. 133 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoCustomVariablesTest.php
  47. 107 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoPhpFilterTest.php.php
  48. 107 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoRolesTest.php
  49. 98 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoSearchTest.php
  50. 69 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoStatusMessagesTest.php
  51. 78 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoUninstallTest.php
  52. 73 0
      sites/all/modules/contrib/admin/matomo/src/Tests/MatomoUserFieldsTest.php
  53. 11 0
      sites/all/modules/contrib/admin/matomo/tests/modules/matomo_test/matomo_test.info.yml
  54. 7 0
      sites/all/modules/contrib/admin/matomo/tests/modules/matomo_test/matomo_test.routing.yml
  55. 28 0
      sites/all/modules/contrib/admin/matomo/tests/modules/matomo_test/src/Controller/MatomoTestController.php
  56. 103 0
      sites/all/modules/contrib/admin/matomo/tests/src/Functional/AdminSettingsFormTest.php
  57. 3 1
      sites/all/modules/contrib/admin/piwik/composer.json
  58. 5 3
      sites/all/modules/contrib/admin/piwik/piwik.info.yml
  59. 104 12
      sites/all/modules/contrib/admin/piwik/piwik.install
  60. 3 3
      sites/all/modules/contrib/admin/piwik/tests/modules/piwik_test/piwik_test.info.yml
  61. 3 3
      sites/all/modules/contrib/dev/config_filter/config_filter.info.yml
  62. 5 10
      sites/all/modules/contrib/dev/config_filter/src/Config/FilteredStorage.php
  63. 46 0
      sites/all/modules/contrib/dev/config_filter/src/Config/GhostStorage.php
  64. 151 0
      sites/all/modules/contrib/dev/config_filter/src/Config/TransparentStorageFilterTrait.php
  65. 19 0
      sites/all/modules/contrib/dev/config_filter/src/Exception/InvalidStorageFilterException.php
  66. 2 132
      sites/all/modules/contrib/dev/config_filter/src/Plugin/ConfigFilterBase.php
  67. 100 5
      sites/all/modules/contrib/dev/config_filter/src/Tests/FilteredStorageTest.php
  68. 44 0
      sites/all/modules/contrib/dev/config_filter/src/Tests/GhostStorageTest.php
  69. 4 4
      sites/all/modules/contrib/dev/config_filter/tests/modules/config_filter_split_test/config_filter_split_test.info.yml
  70. 4 4
      sites/all/modules/contrib/dev/config_filter/tests/modules/config_filter_test/config_filter_test.info.yml
  71. 1 0
      sites/all/modules/contrib/fields/color_field/.gitignore
  72. 123 0
      sites/all/modules/contrib/fields/color_field/README.md
  73. 0 66
      sites/all/modules/contrib/fields/color_field/README.txt
  74. 0 26
      sites/all/modules/contrib/fields/color_field/color_field-2854199-7.patch
  75. 6 4
      sites/all/modules/contrib/fields/color_field/color_field.info.yml
  76. 53 0
      sites/all/modules/contrib/fields/color_field/color_field.install
  77. 1 0
      sites/all/modules/contrib/fields/color_field/color_field.module
  78. 37 0
      sites/all/modules/contrib/fields/color_field/color_field.post_update.php
  79. 36 0
      sites/all/modules/contrib/fields/color_field/composer.json
  80. 24 0
      sites/all/modules/contrib/fields/color_field/config/schema/color_field.schema.yml
  81. 4 3
      sites/all/modules/contrib/fields/color_field/css/color_field_formatter_swatch.css
  82. 14 16
      sites/all/modules/contrib/fields/color_field/css/color_field_widget_box.css
  83. 1 9
      sites/all/modules/contrib/fields/color_field/css/color_field_widget_grid.css
  84. 50 0
      sites/all/modules/contrib/fields/color_field/drupalci.yml
  85. 6 4
      sites/all/modules/contrib/fields/color_field/js/color_field_widget_box.jquery.js
  86. 25 28
      sites/all/modules/contrib/fields/color_field/js/color_field_widget_box.js
  87. 7 7
      sites/all/modules/contrib/fields/color_field/js/color_field_widget_grid.jquery.js
  88. 20 5
      sites/all/modules/contrib/fields/color_field/js/color_field_widget_spectrum.jquery.js
  89. 16 38
      sites/all/modules/contrib/fields/color_field/src/ColorBase.php
  90. 23 16
      sites/all/modules/contrib/fields/color_field/src/ColorCMY.php
  91. 33 20
      sites/all/modules/contrib/fields/color_field/src/ColorCMYK.php
  92. 5 5
      sites/all/modules/contrib/fields/color_field/src/ColorHex.php
  93. 23 10
      sites/all/modules/contrib/fields/color_field/src/ColorInterface.php
  94. 19 13
      sites/all/modules/contrib/fields/color_field/src/ColorRGB.php
  95. 102 45
      sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterCss.php
  96. 33 33
      sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php
  97. 20 18
      sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterText.php
  98. 67 56
      sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldType/ColorFieldType.php
  99. 61 0
      sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldWidget/ColorFieldWidgetBase.php
  100. 49 58
      sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php

+ 98 - 71
sites/all/modules/contrib/admin/admin_toolbar/CHANGELOG.txt

@@ -1,6 +1,33 @@
-Admin Toolbar 8.1.23, 2018-02-06
---------------------------------
-Changes since 8.1.22:
+Admin Toolbar 8.x-1.24, 2018-05-28
+----------------------------------
+Changes since 8.x-1.23:
+
+- #2973131 by adriancid: Don't refer to Drupal in the help page.
+- #2975170 by adriancid: Add composer.json file to submodules.
+- #2975165 by Gamewalker, adriancid: datetime.time services is not found in
+  ToolbarController.
+- #2971466 by recrit, adriancid, acbramley: Add media links incorrectly set to
+  "node.add.".
+- #2972553 by dww, adriancid: Add static cache to speed up
+  admin_toolbar_links_access_filter_user_has_admin_role().
+- #2971435 by adriancid: Module help page for Admin Toolbar Extra Tools module 
+  doesn't show the links.
+- #2971398 by adriancid: Add the docblock to the ToolbarController constructor.
+- #2969686 by adriancid, Vidushi Mehta: Add a menu link to clean the twig cache.
+- #2969325 by adriancid: Fix the module version in the CHANGELOG.txt.
+- #2961450 by adriancid: Convert the AdminToolbarAlterTest test class to
+  PHPUnit.
+- #2961445 by adriancid: Convert the AdminToolbarToolsAlterTest test class to
+  PHPUnit.
+- #2959684 by adriancid: Remove recommended modules section from README.txt.
+- #2959647 by adriancid: Use interfaces instead of classes to inject 
+  dependencies.
+- #2952643 by romainj, if-jds, adriancid: Add Item for Files under Content Menu.
+- #2944463 by adriancid: Update the composer.json file.
+
+Admin Toolbar 8.x-1.23, 2018-02-06
+----------------------------------
+Changes since 8.x-1.22:
 
 - #2924266 by sunlix, romainj, adriancid, samerali: Add a menu link for the
   media module.
@@ -19,9 +46,9 @@ Changes since 8.1.22:
   core/drupal library.
 - #2931503 by K3vin_nl: Admin toolbar generates invalid class names.
 
-Admin Toolbar 8.1.22, 2018-01-02
---------------------------------
-Changes since 8.1.21:
+Admin Toolbar 8.x-1.22, 2018-01-02
+----------------------------------
+Changes since 8.x-1.21:
 
 - #2929053 by kkuhnen, eme, adriancid: admin_toolbar.js should use Drupal
   behaviors.
@@ -42,9 +69,9 @@ Changes since 8.1.21:
 - #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:
+Admin Toolbar 8.x-1.21, 2017-11-20
+----------------------------------
+Changes since 8.x-1.20:
 
 - #2923580 by sylus, adriancid: Unsupported operand types in 
   ToolbarHandler::lazyBuilder().
@@ -87,9 +114,9 @@ Changes since 8.1.20:
 - #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:
+Admin Toolbar 8.x-1.20, 2017-09-07
+----------------------------------
+Changes since 8.x-1.19:
 
 - #2887439 by romainj: Fix test.
 - #2759135 by Johnny vd Laar, miiimooo, chegor, romainj: Content type, 
@@ -106,9 +133,9 @@ Changes since 8.1.19:
 - #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:
+Admin Toolbar 8.x-1.19, 2017-04-06
+----------------------------------
+Changes since 8.x-1.18:
 
 - #2706643 by esod, romainj, Keenegan, DamienMcKenna: Use short array syntax.
 - #2781745 by minakshiPh, eelkeblok, romainj, akhilavnair_zyxware: Drupal coding
@@ -117,9 +144,9 @@ Changes since 8.1.18:
 - #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:
+Admin Toolbar 8.x-1.18, 2016-12-01
+----------------------------------
+Changes since 8.x-1.17:
 
 - #2830677 by vaplas, romainj: z-index for sub menu.
 - by romainj: Get rid of the Hello popup.
@@ -130,9 +157,9 @@ Changes since 8.1.17:
 - #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:
+Admin Toolbar 8.x-1.17, 2016-08-19
+----------------------------------
+Changes since 8.x-1.16:
 
 - #2779251 by romainj, DuneBL: Wrong integration of field_collection delete 
   form.
@@ -150,9 +177,9 @@ Changes since 8.1.16:
 - #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:
+Admin Toolbar 8.x-1.16, 2016-07-28
+----------------------------------
+Changes since 8.x-1.15:
 
 - #2723209 by andrewmacpherson, colan, mattshoaf: Enabling admin_toolbar_tools
   causes Devel Settings to disappear from the main configuration page.
@@ -185,9 +212,9 @@ Changes since 8.1.15:
 - 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:
+Admin Toolbar 8.x-1.15, 2016-05-23
+----------------------------------
+Changes since 8.x-1.14:
 
 - by matio89: add RTL in admin.toolbar.css.
 - by romainj: Changes Devel menu item titles.
@@ -208,9 +235,9 @@ Changes since 8.1.14:
 - 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:
+Admin Toolbar 8.x-1.14, 2016-02-08
+----------------------------------
+Changes since 8.x-1.13:
 
 - by matio89: Correction differents bugs(problem white page when installing a
   new module).
@@ -218,17 +245,17 @@ Changes since 8.1.13:
 - 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:
+Admin Toolbar 8.x-1.13, 2016-02-02
+----------------------------------
+Changes since 8.x-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:
+Admin Toolbar 8.x-1.12, 2016-01-15
+----------------------------------
+Changes since 8.x-1.11:
 
 - by matio89: Correction AdminToolbaToolsAlterTest.
 - #2493037 by mimran: Empty elements in #toolbar-bar.
@@ -236,9 +263,9 @@ Changes since 8.1.11:
 - #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:
+Admin Toolbar 8.x-1.11, 2015-12-11
+----------------------------------
+Changes since 8.x-1.10:
 
 - #2620430 by Vagelis, NarendraR: Typo.
 - #2632888 by JamesK: Add dependency on node module.
@@ -255,46 +282,46 @@ Changes since 8.1.10:
   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:
+Admin Toolbar 8.x-1.10, 2015-08-07
+----------------------------------
+Changes since 8.x-1.9:
 
 - #2546939 by jonhattan: Add dependency on toolbar module.
 
-Admin Toolbar 8.1.9, 2015-07-22
--------------------------------
-Changes since 8.1.8:
+Admin Toolbar 8.x-1.9, 2015-07-22
+---------------------------------
+Changes since 8.x-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:
+Admin Toolbar 8.x-1.8, 2015-06-22
+---------------------------------
+Changes since 8.x-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:
+Admin Toolbar 8.x-1.7, 2015-06-22
+---------------------------------
+Changes since 8.x-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:
+Admin Toolbar 8.x-1.6, 2015-06-03
+---------------------------------
+Changes since 8.x-1.5:
 
 - by matio89: correction admin_toolbar.
 
-Admin Toolbar 8.1.5, 2015-06-03
--------------------------------
-Changes since 8.1.4:
+Admin Toolbar 8.x-1.5, 2015-06-03
+---------------------------------
+Changes since 8.x-1.4:
 
 - by matio89: test if module update exist or no to display install and update
   module.
@@ -302,36 +329,36 @@ Changes since 8.1.4:
 - 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:
+Admin Toolbar 8.x-1.4, 2015-05-20
+---------------------------------
+Changes since 8.x-1.3:
 
 - by matio89: correction add/node.
 
-Admin Toolbar 8.1.3, 2015-05-19
--------------------------------
-Changes since 8.1.2:
+Admin Toolbar 8.x-1.3, 2015-05-19
+---------------------------------
+Changes since 8.x-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:
+Admin Toolbar 8.x-1.2, 2015-05-19
+---------------------------------
+Changes since 8.x-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:
+Admin Toolbar 8.x-1.1, 2015-05-19
+---------------------------------
+Changes since 8.x-1.0:
 
 - by matio89: add new functionalities.
 
-Admin Toolbar 8.1.0, 2015-05-07
--------------------------------
+Admin Toolbar 8.x-1.0, 2015-05-07
+---------------------------------
 - Initial release.

+ 4 - 4
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar.info.yml

@@ -1,5 +1,5 @@
 name: Admin Toolbar
-description: Provides a drop-down menu interface to the core Drupal Toolbar.
+description: Provides a drop-down menu interface to the site Toolbar.
 package: Administration
 
 type: module
@@ -8,8 +8,8 @@ type: module
 dependencies:
   - drupal:toolbar
 
-# Information added by Drupal.org packaging script on 2018-02-06
-version: '8.x-1.23'
+# Information added by Drupal.org packaging script on 2018-05-28
+version: '8.x-1.24'
 core: '8.x'
 project: 'admin_toolbar'
-datestamp: 1517936588
+datestamp: 1527522484

File diff suppressed because it is too large
+ 0 - 1
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar.module


+ 0 - 10
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/README.txt

@@ -3,7 +3,6 @@ CONTENTS OF THIS FILE
 
  * Introduction
  * Requirements
- * Recommended modules
  * Installation
  * Configuration
  * Maintainers
@@ -32,15 +31,6 @@ This module requires the following modules:
  * Admin Toolbar (https://www.drupal.org/project/admin_toolbar)
 
 
-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
 ------------
 

+ 3 - 3
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.info.yml

@@ -8,8 +8,8 @@ type: module
 dependencies:
   - admin_toolbar:admin_toolbar
 
-# Information added by Drupal.org packaging script on 2018-02-06
-version: '8.x-1.23'
+# Information added by Drupal.org packaging script on 2018-05-28
+version: '8.x-1.24'
 core: '8.x'
 project: 'admin_toolbar'
-datestamp: 1517936588
+datestamp: 1527522484

+ 12 - 5
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module

@@ -20,7 +20,7 @@ function admin_toolbar_links_access_filter_help($route_name, RouteMatchInterface
     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>';
+      $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 done not have access permission for.') . '</p>';
 
       return $output;
   }
@@ -184,10 +184,17 @@ function admin_toolbar_links_access_filter_is_overview_page($route_name) {
  *   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;
+  static $user_has_admin_role = [];
+  $uid = $account->id();
+  if (!isset($user_has_admin_role[$uid])) {
+    $roles = Role::loadMultiple($account->getRoles());
+    foreach ($roles as $role) {
+      if ($role->isAdmin()) {
+        $user_has_admin_role[$uid] = TRUE;
+        break;
+      }
+      $user_has_admin_role[$uid] = FALSE;
     }
   }
-  return FALSE;
+  return $user_has_admin_role[$uid];
 }

+ 38 - 0
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_links_access_filter/composer.json

@@ -0,0 +1,38 @@
+{
+  "name": "drupal/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 https://www.drupal.org/node/296693 be solved, this module will be deprecated.",
+  "type": "drupal-module",
+  "keywords": ["Drupal", "Toolbar"],
+  "homepage": "http://drupal.org/project/admin_toolbar",
+  "license": "GPL-2.0+",
+  "authors": [
+    {
+      "name": "Wilfrid Roze (eme)",
+      "homepage": "https://www.drupal.org/u/eme",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Romain Jarraud (romainj)",
+      "homepage": "https://www.drupal.org/u/romainj",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Adrian Cid Almaguer (adriancid)",
+      "email": "adriancid@gmail.com",
+      "homepage": "https://www.drupal.org/u/adriancid",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Mohamed Anis Taktak (matio89)",
+      "homepage": "https://www.drupal.org/u/matio89",
+      "role": "Maintainer"
+    }    
+  ],
+  "support": {
+    "issues": "https://www.drupal.org/project/issues/admin_toolbar",
+    "source": "http://cgit.drupalcode.org/admin_toolbar"
+  },
+  "require": {
+    "drupal/admin_toolbar": "^1"
+  }
+}

+ 0 - 9
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/README.txt

@@ -33,15 +33,6 @@ This module requires the following modules:
  * Admin Toolbar (https://www.drupal.org/project/admin_toolbar)
 
 
-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
 ------------
 

+ 4 - 3
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.info.yml

@@ -7,9 +7,10 @@ type: module
 
 dependencies:
   - admin_toolbar:admin_toolbar
+  - drupal:system (>=8.3)
 
-# Information added by Drupal.org packaging script on 2018-02-06
-version: '8.x-1.23'
+# Information added by Drupal.org packaging script on 2018-05-28
+version: '8.x-1.24'
 core: '8.x'
 project: 'admin_toolbar'
-datestamp: 1517936588
+datestamp: 1527522484

+ 6 - 0
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.links.menu.yml

@@ -63,6 +63,12 @@ admin_toolbar_tools.flush_menu:
   parent: admin_toolbar_tools.flush
   menu_name: admin
 
+admin_toolbar_tools.flush_twig:
+  title: 'Flush twig cache'
+  route_name: admin_toolbar_tools.flush_twig
+  parent: admin_toolbar_tools.flush
+  menu_name: admin
+
 admin_toolbar_tools.flush_rendercache:
   title: 'Flush render cache'
   route_name: admin_toolbar_tools.flush_rendercache

+ 12 - 13
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module

@@ -5,7 +5,6 @@
  * Provides extra menu links for the core drupal toolbar.
  */
 
-use Drupal\Core\Link;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\Core\Url;
 
@@ -34,21 +33,12 @@ function admin_toolbar_tools_toolbar() {
 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>';
-      $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 .= t('The Admin Toolbar Extra Tools module comes packaged with the <a href=":admin-toolbar">Admin Toolbar</a> module and adds functionality to it. The additional functionality is accessed thru extra links on the main administration Toolbar. Some links to Admin Toolbar Extra Tools administration pages are located at the bottom of this page.</a>', [':admin-toolbar' => Url::fromRoute('help.page', ['name' => 'admin_toolbar'])->toString()]);
       $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 :link for a complete listing of these complimentary modules.', [':link' => $external_link]) . '</p>';
+      $output .= '<p>' . t('To use Admin Toolbar Extra Tools just install it like any other module. There is no other configuration required.') . '</p>';
 
       return $output;
   }
@@ -85,6 +75,15 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
       'menu_name' => 'admin',
       'parent' => 'admin_toolbar_tools.flush',
     ];
+    // Adding a menu link to Files.
+    if ($moduleHandler->moduleExists('file') && in_array('view.files.page_1', $routes)) {
+      $links['admin_toolbar_tools.view.files'] = [
+        'title' => t('Files'),
+        'route_name' => 'view.files.page_1',
+        'menu_name' => 'admin',
+        'parent' => 'system.admin_content',
+      ];
+    }
   }
 
   // Adds common links to entities.
@@ -568,7 +567,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
     ];
     // Add node links for each media type.
     foreach (\Drupal::entityTypeManager()->getStorage('media_type')->loadMultiple() as $type) {
-      $links['node.add.' . $type->id()] = [
+      $links['media.add.' . $type->id()] = [
         'title' => t($type->label()),
         'route_name' => 'entity.media.add_form',
         'parent' => 'admin_toolbar_tools.add_media',

+ 9 - 0
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.routing.yml

@@ -61,6 +61,15 @@ admin_toolbar_tools.flush_views:
     _permission: 'administer site configuration'
     _csrf_token: 'TRUE'
 
+admin_toolbar_tools.flush_twig:
+  path: '/admin/flush/twig'
+  defaults:
+    _controller: '\Drupal\admin_toolbar_tools\Controller\ToolbarController::flushTwig'
+    _title: 'Twig'
+  requirements:
+    _permission: 'administer site configuration'
+    _csrf_token: 'TRUE'
+
 admin_toolbar.run.cron:
   path: '/run-cron'
   defaults:

+ 39 - 0
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/composer.json

@@ -0,0 +1,39 @@
+{
+  "name": "drupal/admin_toolbar_tools",
+  "description": "Adds menu links to the Admin Toolbar.",
+  "type": "drupal-module",
+  "keywords": ["Drupal", "Toolbar"],
+  "homepage": "http://drupal.org/project/admin_toolbar",
+  "license": "GPL-2.0+",
+  "authors": [
+    {
+      "name": "Wilfrid Roze (eme)",
+      "homepage": "https://www.drupal.org/u/eme",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Romain Jarraud (romainj)",
+      "homepage": "https://www.drupal.org/u/romainj",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Adrian Cid Almaguer (adriancid)",
+      "email": "adriancid@gmail.com",
+      "homepage": "https://www.drupal.org/u/adriancid",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Mohamed Anis Taktak (matio89)",
+      "homepage": "https://www.drupal.org/u/matio89",
+      "role": "Maintainer"
+    }    
+  ],
+  "support": {
+    "issues": "https://www.drupal.org/project/issues/admin_toolbar",
+    "source": "http://cgit.drupalcode.org/admin_toolbar"
+  },
+  "require": {
+    "drupal/admin_toolbar": "^1",
+    "drupal/core": "~8.3"
+  }
+}

+ 47 - 16
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php

@@ -2,18 +2,19 @@
 
 namespace Drupal\admin_toolbar_tools\Controller;
 
-use Drupal\Component\Datetime\Time;
+use Drupal\Component\Datetime\TimeInterface;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\CronInterface;
-use Drupal\Core\Menu\ContextualLinkManager;
-use Drupal\Core\Menu\LocalActionManager;
-use Drupal\Core\Menu\LocalTaskManager;
-use Drupal\Core\Menu\MenuLinkManager;
+use Drupal\Core\Menu\ContextualLinkManagerInterface;
+use Drupal\Core\Menu\LocalActionManagerInterface;
+use Drupal\Core\Menu\LocalTaskManagerInterface;
+use Drupal\Core\Menu\MenuLinkManagerInterface;
 use Drupal\Core\Plugin\CachedDiscoveryClearerInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\RedirectResponse;
 use Symfony\Component\HttpFoundation\RequestStack;
+use Drupal\Core\PhpStorage\PhpStorageFactory;
 
 /**
  * Class ToolbarController.
@@ -32,28 +33,28 @@ class ToolbarController extends ControllerBase {
   /**
    * A menu link manager instance.
    *
-   * @var \Drupal\Core\Menu\MenuLinkManager
+   * @var \Drupal\Core\Menu\MenuLinkManagerInterface
    */
   protected $menuLinkManager;
 
   /**
    * A context link manager instance.
    *
-   * @var \Drupal\Core\Menu\ContextualLinkManager
+   * @var \Drupal\Core\Menu\ContextualLinkManagerInterface
    */
   protected $contextualLinkManager;
 
   /**
    * A local task manager instance.
    *
-   * @var \Drupal\Core\Menu\LocalTaskManager
+   * @var \Drupal\Core\Menu\LocalTaskManagerInterface
    */
   protected $localTaskLinkManager;
 
   /**
    * A local action manager instance.
    *
-   * @var \Drupal\Core\Menu\LocalActionManager
+   * @var \Drupal\Core\Menu\LocalActionManagerInterface
    */
   protected $localActionLinkManager;
 
@@ -67,7 +68,7 @@ class ToolbarController extends ControllerBase {
   /**
    * A date time instance.
    *
-   * @var \Drupal\Component\Datetime\Time
+   * @var \Drupal\Component\Datetime\TimeInterface
    */
   protected $time;
 
@@ -86,15 +87,34 @@ class ToolbarController extends ControllerBase {
   protected $pluginCacheClearer;
 
   /**
-   * {@inheritdoc}
+   * Constructs a ToolbarController object.
+   *
+   * @param \Drupal\Core\CronInterface $cron
+   *   A cron instance.
+   * @param \Drupal\Core\Menu\MenuLinkManagerInterface $menuLinkManager
+   *   A menu link manager instance.
+   * @param \Drupal\Core\Menu\ContextualLinkManagerInterface $contextualLinkManager
+   *   A context link manager instance.
+   * @param \Drupal\Core\Menu\LocalTaskManagerInterface $localTaskLinkManager
+   *   A local task manager instance.
+   * @param \Drupal\Core\Menu\LocalActionManagerInterface $localActionLinkManager
+   *   A local action manager instance.
+   * @param \Drupal\Core\Cache\CacheBackendInterface $cacheRender
+   *   A cache backend interface instance.
+   * @param \Drupal\Component\Datetime\TimeInterface $time
+   *   A date time instance.
+   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
+   *   A request stack symfony instance.
+   * @param \Drupal\Core\Plugin\CachedDiscoveryClearerInterface $plugin_cache_clearer
+   *   A plugin cache clear instance.
    */
   public function __construct(CronInterface $cron,
-                              MenuLinkManager $menuLinkManager,
-                              ContextualLinkManager $contextualLinkManager,
-                              LocalTaskManager $localTaskLinkManager,
-                              LocalActionManager $localActionLinkManager,
+                              MenuLinkManagerInterface $menuLinkManager,
+                              ContextualLinkManagerInterface $contextualLinkManager,
+                              LocalTaskManagerInterface $localTaskLinkManager,
+                              LocalActionManagerInterface $localActionLinkManager,
                               CacheBackendInterface $cacheRender,
-                              Time $time,
+                              TimeInterface $time,
                               RequestStack $request_stack,
                               CachedDiscoveryClearerInterface $plugin_cache_clearer) {
     $this->cron = $cron;
@@ -197,6 +217,17 @@ class ToolbarController extends ControllerBase {
     return new RedirectResponse($this->reloadPage());
   }
 
+  /**
+   * Clears the twig cache.
+   */
+  public function flushTwig() {
+    // @todo Update once Drupal 8.6 will be released.
+    // @see https://www.drupal.org/node/2908461
+    PhpStorageFactory::get('twig')->deleteAll();
+    drupal_set_message($this->t('Twig cache cleared.'));
+    return new RedirectResponse($this->reloadPage());
+  }
+
   /**
    * Run the cron.
    */

+ 8 - 4
sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php → sites/all/modules/contrib/admin/admin_toolbar/admin_toolbar_tools/tests/src/Functional/AdminToolbarToolsAlterTest.php

@@ -1,22 +1,26 @@
 <?php
 
-namespace Drupal\admin_toolbar_tools\Tests;
+namespace Drupal\Tests\admin_toolbar_tools\Functional;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 
 /**
  * Tests for the existence of Admin Toolbar tools new links.
  *
  * @group admin_toolbar
  */
-class AdminToolbarToolsAlterTest extends WebTestBase {
+class AdminToolbarToolsAlterTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
    *
    * @var array
    */
-  public static $modules = ['toolbar', 'admin_toolbar', 'admin_toolbar_tools'];
+  protected static $modules = [
+    'toolbar',
+    'admin_toolbar',
+    'admin_toolbar_tools',
+  ];
 
   /**
    * A test user with permission to access the administrative toolbar.

+ 26 - 8
sites/all/modules/contrib/admin/admin_toolbar/composer.json

@@ -1,17 +1,35 @@
 {
   "name": "drupal/admin_toolbar",
-  "description": "Admin Toolbar improve the default Drupal Toolbar, it lets the hover of sub menus.",
+  "description": "Provides a drop-down menu interface to the core Drupal Toolbar.",
   "type": "drupal-module",
+  "keywords": ["Drupal", "Toolbar"],
   "homepage": "http://drupal.org/project/admin_toolbar",
+  "license": "GPL-2.0+",
   "authors": [
     {
-      "name": "Mohamed Anis Taktak",
-      "homepage": "https://www.drupal.org/u/matio89"
-    }
+      "name": "Wilfrid Roze (eme)",
+      "homepage": "https://www.drupal.org/u/eme",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Romain Jarraud (romainj)",
+      "homepage": "https://www.drupal.org/u/romainj",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Adrian Cid Almaguer (adriancid)",
+      "email": "adriancid@gmail.com",
+      "homepage": "https://www.drupal.org/u/adriancid",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Mohamed Anis Taktak (matio89)",
+      "homepage": "https://www.drupal.org/u/matio89",
+      "role": "Maintainer"
+    }    
   ],
   "support": {
-    "issues": "https://www.drupal.org/project/issues/admin_toolbar"
-  },
-  "license": "GPL-2.0+",
-  "require": { }
+    "issues": "https://www.drupal.org/project/issues/admin_toolbar",
+    "source": "http://cgit.drupalcode.org/admin_toolbar"
+  }
 }

+ 8 - 4
sites/all/modules/contrib/admin/admin_toolbar/src/Tests/AdminToolbarAlterTest.php → sites/all/modules/contrib/admin/admin_toolbar/tests/src/Functional/AdminToolbarAlterTest.php

@@ -1,22 +1,26 @@
 <?php
 
-namespace Drupal\admin_toolbar\Tests;
+namespace Drupal\Tests\admin_toolbar\Functional;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 
 /**
  * Test the existence of Admin Toolbar module.
  *
  * @group admin_toolbar
  */
-class AdminToolbarAlterTest extends WebTestBase {
+class AdminToolbarAlterTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
    *
    * @var array
    */
-  public static $modules = ['toolbar', 'breakpoint', 'admin_toolbar'];
+  protected static $modules = [
+    'toolbar',
+    'breakpoint',
+    'admin_toolbar',
+  ];
 
   /**
    * A test user with permission to access the administrative toolbar.

+ 5 - 0
sites/all/modules/contrib/admin/matomo/.eslintrc

@@ -0,0 +1,5 @@
+{
+  "globals": {
+    "_paq": true
+  }
+}

+ 339 - 0
sites/all/modules/contrib/admin/matomo/LICENSE.txt

@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.

+ 109 - 0
sites/all/modules/contrib/admin/matomo/README.txt

@@ -0,0 +1,109 @@
+
+Module: Matomo Analytics
+Author: Alexander Hass <http://drupal.org/user/85918>
+
+
+Description
+===========
+Adds the Matomo tracking system to your website.
+
+Requirements
+============
+
+* Matomo installation
+* Matomo website ID
+
+
+Installation
+============
+* Copy the 'matomo' module directory in to your Drupal 'modules'
+directory as usual.
+
+
+Usage
+=====
+In the settings page enter your Matomo website ID.
+
+All pages will now have the required JavaScript added to the
+HTML footer can confirm this by viewing the page source from
+your browser.
+
+Page specific tracking
+====================================================
+The default is set to "Add to every page except the listed pages". By
+default the following pages are listed for exclusion:
+
+/admin
+/admin/*
+/batch
+/node/add*
+/node/*/*
+/user/*/*
+
+These defaults are changeable by the website administrator or any other
+user with 'Administer Matomo' permission.
+
+Like the blocks visibility settings in Drupal core, there is a choice for
+"Add if the following PHP code returns TRUE." Sample PHP snippets that can be
+used in this textarea can be found on the handbook page "Overview-approach to
+block visibility" at http://drupal.org/node/64135.
+
+Custom variables
+=================
+One example for custom variables tracking is the "User roles" tracking. Enter
+the below configuration data into the custom variables settings form under
+admin/config/system/matomo.
+
+Slot: 1
+Name: User roles
+Value: [current-user:matomo-role-names]
+Scope: Visitor
+
+Slot: 1
+Name: User ids
+Value: [current-user:matomo-role-ids]
+Scope: Visitor
+
+More details about custom variables can be found in the Matomo API documentation
+at http://matomo.org/docs/javascript-tracking/#toc-custom-variables.
+
+
+Advanced Settings
+=================
+You can include additional JavaScript snippets in the custom javascript
+code textarea. These can be found on various blog posts, or on the
+official Matomo pages. Support is not provided for any customisations
+you include.
+
+To speed up page loading you may also cache the Matomo "piwik.js"
+file locally.
+
+Known issues
+============
+Drupal requirements (http://drupal.org/requirements) tell you to configure 
+PHP with "session.save_handler = user", but your Matomo installation may
+not work with this configuration and gives you a server error 500.
+
+1. You are able to workaround with the PHP default in your php.ini:
+
+   [Session]
+   session.save_handler = files
+
+2. With Apache you may overwrite the PHP setting for the Matomo directory only.
+   If Matomo is installed in /matomo you are able to create a .htaccess file in
+   this directory with the below code:
+
+   # PHP 4, Apache 1.
+   <IfModule mod_php4.c>
+     php_value session.save_handler files
+   </IfModule>
+
+   # PHP 4, Apache 2.
+   <IfModule sapi_apache2.c>
+     php_value session.save_handler files
+   </IfModule>
+
+   # PHP 5, Apache 1 and 2.
+   <IfModule mod_php5.c>
+     php_value session.save_handler files
+   </IfModule>

+ 22 - 0
sites/all/modules/contrib/admin/matomo/composer.json

@@ -0,0 +1,22 @@
+{
+  "name": "drupal/matomo",
+  "description": "Adds Matomo javascript tracking code to all your site's pages",
+  "type": "drupal-module",
+  "homepage": "https://www.drupal.org/project/matomo",
+  "authors": [
+    {
+      "name": "hass",
+      "homepage": "https://www.drupal.org/u/hass"
+    },
+    {
+      "name": "See other contributors",
+      "homepage":"https://www.drupal.org/node/247808/committers"
+    }
+  ],
+  "support": {
+    "issues": "https://www.drupal.org/project/issues/matomo",
+    "source": "http://git.drupal.org/project/matomo.git"
+  },
+  "license": "GPL-2.0+",
+  "require": {}
+}

+ 29 - 0
sites/all/modules/contrib/admin/matomo/config/install/matomo.settings.yml

@@ -0,0 +1,29 @@
+site_id: ''
+url_http: ''
+url_https: ''
+domain_mode: 0
+visibility:
+  request_path_mode: 0
+  request_path_pages: "/admin\n/admin/*\n/batch\n/node/add*\n/node/*/*\n/user/*/*"
+  user_role_mode: 0
+  user_role_roles: {  }
+  user_account_mode: 1
+track:
+  mailto: true
+  files: true
+  files_extensions: '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip'
+  colorbox: true
+  userid: false
+  messages: {  }
+  site_search: false
+privacy:
+  donottrack: true
+custom:
+  variable: {  }
+codesnippet:
+  before: ''
+  after: ''
+translation_set: false
+cache: false
+page_title_hierarchy: false
+page_title_hierarchy_exclude_home: true

+ 120 - 0
sites/all/modules/contrib/admin/matomo/config/schema/matomo.schema.yml

@@ -0,0 +1,120 @@
+# Schema for the configuration files of the matomo module.
+
+matomo.settings:
+  type: config_object
+  label: 'Matomo settings'
+  mapping:
+    site_id:
+      type: string
+      label: 'Matomo site ID'
+    url_http:
+      type: string
+      label: 'Matomo HTTP URL'
+    url_https:
+      type: string
+      label: 'Matomo HTTPS URL'
+    domain_mode:
+      type: integer
+      label: 'What are you tracking?'
+    visibility:
+      type: mapping
+      label: 'Visibility'
+      mapping:
+        request_path_mode:
+          type: integer
+          label: 'Add tracking to specific pages'
+        request_path_pages:
+          type: string
+          label: 'Pages by their paths'
+        user_role_mode:
+          type: integer
+          label: 'Add tracking for specific roles'
+        user_role_roles:
+          type: sequence
+          label: 'Roles'
+          sequence:
+            type: string
+            label: 'Role'
+        user_account_mode:
+          type: integer
+          label: 'Allow users to customize tracking on their account page'
+    track:
+      type: mapping
+      label: 'Links and downloads'
+      mapping:
+        mailto:
+          type: boolean
+          label: 'Track clicks on mailto links'
+        files:
+          type: boolean
+          label: 'Track downloads'
+        files_extensions:
+          type: string
+          label: 'File extension list'
+        colorbox:
+          type: boolean
+          label: 'Track content in colorbox modal dialogs'
+        userid:
+          type: boolean
+          label: 'Track User ID'
+        messages:
+          type: sequence
+          label: 'Track messages of type'
+          sequence:
+            type: string
+            label: 'Message type'
+        site_search:
+          type: boolean
+          label: 'Track internal search'
+    privacy:
+      type: mapping
+      label: 'Privacy'
+      mapping:
+        donottrack:
+          type: boolean
+          label: 'Universal web tracking opt-out'
+    custom:
+      type: mapping
+      label: 'Custom variables'
+      mapping:
+        variable:
+          type: sequence
+          label: 'Custom variable'
+          sequence:
+            type: mapping
+            label: 'Variable'
+            mapping:
+              slot:
+                type: integer
+                label: 'Slot number'
+              name:
+                type: string
+                label: 'The custom variable name.'
+              value:
+                type: string
+                label: 'The custom variable value.'
+              scope:
+                type: string
+                label: 'The scope for the custom variable.'
+    codesnippet:
+      type: mapping
+      label: 'Custom code snippets'
+      mapping:
+        before:
+          type: string
+          label: 'Code snippet (before)'
+        after:
+          type: string
+          label: 'Code snippet (after)'
+    translation_set:
+      type: boolean
+      label: 'Track translation sets as one unit'
+    cache:
+      type: boolean
+      label: 'Locally cache tracking code file'
+    page_title_hierarchy:
+      type: boolean
+      label: 'Show page titles as hierarchy like breadcrumbs'
+    page_title_hierarchy_exclude_home:
+      type: boolean
+      label: 'Hide home page from hierarchy'

+ 141 - 0
sites/all/modules/contrib/admin/matomo/js/matomo.admin.js

@@ -0,0 +1,141 @@
+/**
+ * @file
+ * Matomo admin behaviors.
+ */
+
+(function ($) {
+
+  "use strict";
+
+  /**
+   * Provide the summary information for the tracking settings vertical tabs.
+   */
+  Drupal.behaviors.trackingSettingsSummary = {
+    attach: function () {
+      // Make sure this behavior is processed only if drupalSetSummary is defined.
+      if (typeof jQuery.fn.drupalSetSummary === 'undefined') {
+        return;
+      }
+
+      $('#edit-page-visibility-settings').drupalSetSummary(function (context) {
+        var $radio = $('input[name="matomo_visibility_request_path_mode"]:checked', context);
+        if ($radio.val() === '0') {
+          if (!$('textarea[name="matomo_visibility_request_path_pages"]', context).val()) {
+            return Drupal.t('Not restricted');
+          }
+          else {
+            return Drupal.t('All pages with exceptions');
+          }
+        }
+        else {
+          return Drupal.t('Restricted to certain pages');
+        }
+      });
+
+      $('#edit-role-visibility-settings').drupalSetSummary(function (context) {
+        var vals = [];
+        $('input[type="checkbox"]:checked', context).each(function () {
+          vals.push($.trim($(this).next('label').text()));
+        });
+        if (!vals.length) {
+          return Drupal.t('Not restricted');
+        }
+        else if ($('input[name="matomo_visibility_user_role_mode"]:checked', context).val() === '1') {
+          return Drupal.t('Excepted: @roles', {'@roles': vals.join(', ')});
+        }
+        else {
+          return vals.join(', ');
+        }
+      });
+
+      $('#edit-user-visibility-settings').drupalSetSummary(function (context) {
+        var $radio = $('input[name="matomo_visibility_user_account_mode"]:checked', context);
+        if ($radio.val() === '0') {
+          return Drupal.t('Not customizable');
+        }
+        else if ($radio.val() === '1') {
+          return Drupal.t('On by default with opt out');
+        }
+        else {
+          return Drupal.t('Off by default with opt in');
+        }
+      });
+
+      $('#edit-linktracking').drupalSetSummary(function (context) {
+        var vals = [];
+        if ($('input#edit-matomo-trackmailto', context).is(':checked')) {
+          vals.push(Drupal.t('Mailto links'));
+        }
+        if ($('input#edit-matomo-trackfiles', context).is(':checked')) {
+          vals.push(Drupal.t('Outbound links'));
+          vals.push(Drupal.t('Downloads'));
+        }
+        if ($('input#edit-matomo-trackcolorbox', context).is(':checked')) {
+          vals.push(Drupal.t('Colorbox'));
+        }
+        if (!vals.length) {
+          return Drupal.t('Not tracked');
+        }
+        return Drupal.t('@items enabled', {'@items': vals.join(', ')});
+      });
+
+      $('#edit-messagetracking').drupalSetSummary(function (context) {
+        var vals = [];
+        $('input[type="checkbox"]:checked', context).each(function () {
+          vals.push($.trim($(this).next('label').text()));
+        });
+        if (!vals.length) {
+          return Drupal.t('Not tracked');
+        }
+        return Drupal.t('@items enabled', {'@items': vals.join(', ')});
+      });
+
+      $('#edit-search').drupalSetSummary(function (context) {
+        var vals = [];
+        if ($('input#edit-matomo-site-search', context).is(':checked')) {
+          vals.push(Drupal.t('Site search'));
+        }
+        if (!vals.length) {
+          return Drupal.t('Not tracked');
+        }
+        return Drupal.t('@items enabled', {'@items': vals.join(', ')});
+      });
+
+      $('#edit-domain-tracking').drupalSetSummary(function (context) {
+        var $radio = $('input[name="matomo_domain_mode"]:checked', context);
+        if ($radio.val() === '0') {
+          return Drupal.t('A single domain');
+        }
+        else if ($radio.val() === '1') {
+          return Drupal.t('One domain with multiple subdomains');
+        }
+      });
+
+      $('#edit-page-title-hierarchy').drupalSetSummary(function (context) {
+        var vals = [];
+        if ($('input#edit-matomo-page-title-hierarchy', context).is(':checked')) {
+          vals.push(Drupal.t('Show page titles'));
+        }
+        if ($('input#edit-matomo-page-title-hierarchy-exclude-home', context).is(':checked')) {
+          vals.push(Drupal.t('Hide home page'));
+        }
+        if (!vals.length) {
+          return Drupal.t('Not tracked');
+        }
+        return Drupal.t('@items enabled', {'@items': vals.join(', ')});
+      });
+
+      $('#edit-privacy').drupalSetSummary(function (context) {
+        var vals = [];
+        if ($('input#edit-matomo-privacy-donottrack', context).is(':checked')) {
+          vals.push(Drupal.t('Universal web tracking opt-out'));
+        }
+        if (!vals.length) {
+          return Drupal.t('No privacy');
+        }
+        return Drupal.t('@items enabled', {'@items': vals.join(', ')});
+      });
+    }
+  };
+
+})(jQuery);

+ 41 - 0
sites/all/modules/contrib/admin/matomo/js/matomo.js

@@ -0,0 +1,41 @@
+/**
+ * @file
+ * Attaches several event listener to a web page.
+ */
+
+(function ($, drupalSettings) {
+
+  "use strict";
+
+  $(document).ready(function () {
+
+    // Attach mousedown, keyup, touchstart events to document only and catch
+    // clicks on all elements.
+    $(document.body).bind("mousedown keyup touchstart", function (event) {
+
+      // Catch the closest surrounding link of a clicked element.
+      $(event.target).closest("a,area").each(function () {
+
+        if (drupalSettings.matomo.trackMailto && $(this).is("a[href^='mailto:'],area[href^='mailto:']")) {
+          // Mailto link clicked.
+          _paq.push(["trackEvent", "Mails", "Click", this.href.substring(7)]);
+        }
+
+      });
+    });
+
+    // Colorbox: This event triggers when the transition has completed and the
+    // newly loaded content has been revealed.
+    if (drupalSettings.matomo.trackColorbox) {
+      $(document).bind("cbox_complete", function () {
+        var href = $.colorbox.element().attr("href");
+        if (href) {
+          _paq.push(["setCustomUrl", href]);
+          _paq.push(["trackPageView"]);
+        }
+      });
+    }
+
+  });
+
+})(jQuery, drupalSettings);

+ 15 - 0
sites/all/modules/contrib/admin/matomo/matomo.info.yml

@@ -0,0 +1,15 @@
+name: 'Matomo Analytics'
+type: module
+description: "Adds Matomo javascript tracking code to all your site's pages."
+package: Statistics
+# core: 8.x
+configure: matomo.admin_settings_form
+test_dependencies:
+  - php:php
+  - token:token
+
+# Information added by Drupal.org packaging script on 2018-07-13
+version: '8.x-1.7'
+core: '8.x'
+project: 'matomo'
+datestamp: 1531470224

+ 54 - 0
sites/all/modules/contrib/admin/matomo/matomo.install

@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * @file
+ * Installation file for Matomo Analytics module.
+ */
+
+use Drupal\Core\Url;
+use Drupal\user\Entity\Role;
+
+/**
+ * Implements hook_install().
+ */
+function matomo_install() {
+  // Make the default install more user and GDPR friendly.
+  $role = Role::load('authenticated');
+  $role->grantPermission('opt-in or out of matomo tracking');
+  $success = $role->save();
+  if ($success) {
+    drupal_set_message(t('Module %module granted %permission permission to authenticated users.', ['%module' => 'Matomo Analytics', '%permission' => t('Opt-in or out of tracking')]), 'status');
+  }
+}
+
+/**
+ * Implements hook_uninstall().
+ *
+ * Remove cache directory if module is uninstalled.
+ */
+function matomo_uninstall() {
+  matomo_clear_js_cache();
+}
+
+/**
+ * Implements hook_requirements().
+ */
+function matomo_requirements($phase) {
+  $requirements = [];
+
+  if ($phase == 'runtime') {
+    $config = \Drupal::config('matomo.settings');
+
+    // Raise warning if Matomo user account has not been set yet.
+    if (!preg_match('/^\d{1,}$/', $config->get('site_id'))) {
+      $requirements['matomo_site_id'] = [
+        'title' => t('Matomo module'),
+        'description' => t('Matomo module has not been configured yet. Please configure its settings from the <a href=":url">Matomo settings page</a>.', [':url' => Url::fromRoute('matomo.admin_settings_form')->toString()]),
+        'severity' => REQUIREMENT_WARNING,
+        'value' => t('Not configured'),
+      ];
+    }
+  }
+
+  return $requirements;
+}

+ 15 - 0
sites/all/modules/contrib/admin/matomo/matomo.libraries.yml

@@ -0,0 +1,15 @@
+matomo:
+  version: VERSION
+  js:
+    js/matomo.js: {}
+  dependencies:
+    - core/jquery
+    - core/drupalSettings
+
+matomo.admin:
+  version: VERSION
+  js:
+    js/matomo.admin.js: {}
+  dependencies:
+    - core/jquery
+    - core/drupal

+ 5 - 0
sites/all/modules/contrib/admin/matomo/matomo.links.menu.yml

@@ -0,0 +1,5 @@
+matomo.admin_settings_form:
+  title: 'Matomo Analytics'
+  parent: system.admin_config_system
+  description: 'Configure the settings used to generate your Matomo tracking code.'
+  route_name: matomo.admin_settings_form

+ 4 - 0
sites/all/modules/contrib/admin/matomo/matomo.links.task.yml

@@ -0,0 +1,4 @@
+matomo.admin_settings_form_tab:
+  route_name: matomo.admin_settings_form
+  title: Settings
+  base_route: matomo.admin_settings_form

+ 732 - 0
sites/all/modules/contrib/admin/matomo/matomo.module

@@ -0,0 +1,732 @@
+<?php
+
+/**
+ * @file
+ * Drupal Module: Matomo.
+ *
+ * Adds the required Javascript to all your Drupal pages to allow tracking by
+ * the Matomo statistics package.
+ *
+ * @author: Alexander Hass <http://drupal.org/user/85918>
+ */
+
+use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\Unicode;
+use Drupal\Component\Utility\UrlHelper;
+use Drupal\Core\Cache\Cache;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Site\Settings;
+use Drupal\Core\Url;
+use Drupal\node\NodeInterface;
+use GuzzleHttp\Exception\RequestException;
+use Drupal\matomo\Component\Render\MatomoJavaScriptSnippet;
+
+/**
+ * Define the default file extension list that should be tracked as download.
+ */
+define('MATOMO_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip');
+
+/**
+ * Implements hook_help().
+ */
+function matomo_help($route_name, RouteMatchInterface $route_match) {
+  switch ($route_name) {
+    case 'matomo.admin_settings_form':
+      return t('<a href=":pk_url">Matomo Analytics</a> is an open source (GPL license) web analytics software. It gives interesting reports on your website visitors, your popular pages, the search engines keywords they used, the language they speak... and so much more. Matomo aims to be an open source alternative to Google Analytics.', [':pk_url' => 'http://www.matomo.org/']);
+  }
+}
+
+/**
+ * Implements hook_page_attachments().
+ *
+ * Insert JavaScript to the appropriate scope/region of the page.
+ */
+function matomo_page_attachments(array &$page) {
+  $account = \Drupal::currentUser();
+  $config = \Drupal::config('matomo.settings');
+  $id = $config->get('site_id');
+  $request = \Drupal::request();
+
+  // Add module cache tags.
+  $page['#cache']['tags'] = Cache::mergeTags(isset($page['#cache']['tags']) ? $page['#cache']['tags'] : [], $config->getCacheTags());
+
+  // Get page http status code for visibility filtering.
+  $status = NULL;
+  if ($exception = $request->attributes->get('exception')) {
+    $status = $exception->getStatusCode();
+  }
+  $trackable_status_codes = [
+    // "Forbidden" status code.
+    '403',
+    // "Not Found" status code.
+    '404',
+  ];
+
+  // 1. Check if the matomo account number has a valid value.
+  // 2. Track page views based on visibility value.
+  // 3. Check if we should track the currently active user's role.
+  if (preg_match('/^\d{1,}$/', $id) && (_matomo_visibility_pages() || in_array($status, $trackable_status_codes)) && _matomo_visibility_user($account)) {
+
+    $url_http = $config->get('url_http');
+    $url_https = $config->get('url_https');
+
+    $set_custom_url = '';
+    $set_document_title = '';
+
+    // Add link tracking.
+    $link_settings = [];
+    $link_settings['trackMailto'] = $config->get('track.mailto');
+
+    if ((\Drupal::moduleHandler()->moduleExists('colorbox')) && $track_colorbox = $config->get('track.colorbox')) {
+      $link_settings['trackColorbox'] = $track_colorbox;
+    }
+
+    $page['#attached']['drupalSettings']['matomo'] = $link_settings;
+    $page['#attached']['library'][] = 'matomo/matomo';
+
+    // Matomo can show a tree view of page titles that represents the site
+    // structure if setDocumentTitle() provides the page titles as a "/"
+    // delimited list. This may makes it easier to browse through the statistics
+    // of page titles on larger sites.
+    if ($config->get('page_title_hierarchy') == TRUE) {
+      $titles = _matomo_get_hierarchy_titles();
+
+      // Remove all empty titles.
+      $titles = array_filter($titles);
+
+      if (!empty($titles)) {
+        // Encode title, at least to keep "/" intact.
+        $titles = array_map('rawurlencode', $titles);
+
+        $set_document_title = Json::encode(implode('/', $titles));
+      }
+    }
+
+    // Add messages tracking.
+    $message_events = '';
+    if ($message_types = $config->get('track.messages')) {
+      $message_types = array_values(array_filter($message_types));
+      $status_heading = [
+        'status' => t('Status message'),
+        'warning' => t('Warning message'),
+        'error' => t('Error message'),
+      ];
+
+      foreach (drupal_get_messages(NULL, FALSE) as $type => $messages) {
+        // Track only the selected message types.
+        if (in_array($type, $message_types)) {
+          foreach ($messages as $message) {
+            $message_events .= '_paq.push(["trackEvent", ' . Json::encode(t('Messages')) . ', ' . Json::encode($status_heading[$type]) . ', ' . Json::encode(strip_tags($message)) . ']);';
+          }
+        }
+      }
+    }
+
+    // If this node is a translation of another node, pass the original
+    // node instead.
+    if (\Drupal::moduleHandler()->moduleExists('content_translation') && $config->get('translation_set')) {
+      // Check if we have a node object, it has translation enabled, and its
+      // language code does not match its source language code.
+      if ($request->attributes->has('node')) {
+        $node = $request->attributes->get('node');
+        if ($node instanceof NodeInterface && \Drupal::service('entity.repository')->getTranslationFromContext($node) !== $node->getUntranslated()) {
+          $set_custom_url = Json::encode(Url::fromRoute('entity.node.canonical', ['node' => $node->id()], ['language' => $node->getUntranslated()->language()])->toString());
+        }
+      }
+    }
+
+    // Track access denied (403) and file not found (404) pages.
+    if ($status == '403') {
+      $set_document_title = '"403/URL = " + encodeURIComponent(document.location.pathname+document.location.search) + "/From = " + encodeURIComponent(document.referrer)';
+    }
+    elseif ($status == '404') {
+      $set_document_title = '"404/URL = " + encodeURIComponent(document.location.pathname+document.location.search) + "/From = " + encodeURIComponent(document.referrer)';
+    }
+
+    // #2693595: User has entered an invalid login and clicked on forgot
+    // password link. This link contains the username or email address and may
+    // get send to Matomo if we do not override it. Override only if 'name'
+    // query param exists. Last custom url condition, this need to win.
+    //
+    // URLs to protect are:
+    // - user/password?name=username
+    // - user/password?name=foo@example.com
+    if (\Drupal::routeMatch()->getRouteName() == 'user.pass' && $request->query->has('name')) {
+      $set_custom_url = Json::encode(Url::fromRoute('user.pass')->toString());
+    }
+
+    // Add custom variables.
+    $matomo_custom_vars = $config->get('custom.variable');
+    $custom_variable = '';
+    for ($i = 1; $i < 6; $i++) {
+      $custom_var_name = !empty($matomo_custom_vars[$i]['name']) ? $matomo_custom_vars[$i]['name'] : '';
+      if (!empty($custom_var_name)) {
+        $custom_var_value = !empty($matomo_custom_vars[$i]['value']) ? $matomo_custom_vars[$i]['value'] : '';
+        $custom_var_scope = !empty($matomo_custom_vars[$i]['scope']) ? $matomo_custom_vars[$i]['scope'] : 'visit';
+
+        $types = [];
+        if ($request->attributes->has('node')) {
+          $node = $request->attributes->get('node');
+          if ($node instanceof NodeInterface) {
+            $types += ['node' => $node];
+          }
+        }
+        $custom_var_name = \Drupal::token()->replace($custom_var_name, $types, ['clear' => TRUE]);
+        $custom_var_value = \Drupal::token()->replace($custom_var_value, $types, ['clear' => TRUE]);
+
+        // Suppress empty custom names and/or variables.
+        if (!Unicode::strlen(trim($custom_var_name)) || !Unicode::strlen(trim($custom_var_value))) {
+          continue;
+        }
+
+        // Custom variables names and values are limited to 200 characters in
+        // length. It is recommended to store values that are as small as
+        // possible to ensure that the Matomo Tracking request URL doesn't go
+        // over the URL limit for the webserver or browser.
+        $custom_var_name = rtrim(substr($custom_var_name, 0, 200));
+        $custom_var_value = rtrim(substr($custom_var_value, 0, 200));
+
+        // Add variables to tracker.
+        $custom_variable .= '_paq.push(["setCustomVariable", ' . Json::encode($i) . ', ' . Json::encode($custom_var_name) . ', ' . Json::encode($custom_var_value) . ', ' . Json::encode($custom_var_scope) . ']);';
+      }
+    }
+
+    // Add any custom code snippets if specified.
+    $codesnippet_before = $config->get('codesnippet.before');
+    $codesnippet_after = $config->get('codesnippet.after');
+
+    // Build tracker code.
+    // @see http://matomo.org/docs/javascript-tracking/#toc-asynchronous-tracking
+    $script = 'var _paq = _paq || [];';
+    $script .= '(function(){';
+    $script .= 'var u=(("https:" == document.location.protocol) ? "' . UrlHelper::filterBadProtocol($url_https) . '" : "' . UrlHelper::filterBadProtocol($url_http) . '");';
+    $script .= '_paq.push(["setSiteId", ' . Json::encode($id) . ']);';
+    $script .= '_paq.push(["setTrackerUrl", u+"piwik.php"]);';
+
+    // Track logged in users across all devices.
+    if ($config->get('track.userid') && $account->isAuthenticated()) {
+      $script .= '_paq.push(["setUserId", ' . Json::encode(matomo_user_id_hash($account->id())) . ']);';
+    }
+
+    // Set custom url.
+    if (!empty($set_custom_url)) {
+      $script .= '_paq.push(["setCustomUrl", ' . $set_custom_url . ']);';
+    }
+    // Set custom document title.
+    if (!empty($set_document_title)) {
+      $script .= '_paq.push(["setDocumentTitle", ' . $set_document_title . ']);';
+    }
+
+    // Custom file download extensions.
+    if ($config->get('track.files') && !($config->get('track.files_extensions') == MATOMO_TRACKFILES_EXTENSIONS)) {
+      $script .= '_paq.push(["setDownloadExtensions", ' . Json::encode($config->get('track.files_extensions')) . ']);';
+    }
+
+    // Disable tracking for visitors who have opted out from tracking via DNT
+    // (Do-Not-Track) header.
+    if ($config->get('privacy.donottrack')) {
+      $script .= '_paq.push(["setDoNotTrack", 1]);';
+    }
+
+    // Domain tracking type.
+    global $cookie_domain;
+    $domain_mode = $config->get('domain_mode');
+
+    // Per RFC 2109, cookie domains must contain at least one dot other than the
+    // first. For hosts such as 'localhost' or IP Addresses we don't set a
+    // cookie domain.
+    if ($domain_mode == 1 && count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
+      $script .= '_paq.push(["setCookieDomain", ' . Json::encode($cookie_domain) . ']);';
+    }
+
+    // Ordering $custom_variable before $codesnippet_before allows users to add
+    // custom code snippets that may use deleteCustomVariable() and/or
+    // getCustomVariable().
+    if (!empty($custom_variable)) {
+      $script .= $custom_variable;
+    }
+    if (!empty($codesnippet_before)) {
+      $script .= $codesnippet_before;
+    }
+
+    // Site search tracking support.
+    // NOTE: It's recommended not to call trackPageView() on the Site Search
+    // Result page.
+    if (\Drupal::moduleHandler()->moduleExists('search') && $config->get('track.site_search') && (strpos(\Drupal::routeMatch()->getRouteName(), 'search.view') === 0) && $keys = ($request->query->has('keys') ? trim($request->get('keys')) : '')) {
+      // Parameters:
+      // 1. Search keyword searched for. Example: "Banana"
+      // 2. Search category selected in your search engine. If you do not need
+      //    this, set to false. Example: "Organic Food"
+      // 3. Number of results on the Search results page. Zero indicates a
+      //    'No Result Search Keyword'. Set to false if you don't know.
+      //
+      // hook_preprocess_search_results() is not executed if search result is
+      // empty. Make sure the counter is set to 0 if there are no results.
+      $script .= '_paq.push(["trackSiteSearch", ' . Json::encode($keys) . ', false, (window.matomo_search_results) ? window.matomo_search_results : 0]);';
+    }
+    else {
+      $script .= '_paq.push(["trackPageView"]);';
+    }
+
+    // Add link tracking.
+    if ($config->get('track.files')) {
+      // Disable tracking of links with ".no-tracking" and ".colorbox" classes.
+      $ignore_classes = [
+        'no-tracking',
+        'colorbox',
+      ];
+      // Disable the download & outlink tracking for specific CSS classes.
+      // Custom code snippets with 'setIgnoreClasses' will override the value.
+      // @see http://developer.matomo.org/api-reference/tracking-javascript#disable-the-download-amp-outlink-tracking-for-specific-css-classes
+      $script .= '_paq.push(["setIgnoreClasses", ' . Json::encode($ignore_classes) . ']);';
+
+      // Enable download & outlink link tracking.
+      $script .= '_paq.push(["enableLinkTracking"]);';
+    }
+
+    if (!empty($message_events)) {
+      $script .= $message_events;
+    }
+    if (!empty($codesnippet_after)) {
+      $script .= $codesnippet_after;
+    }
+
+    $script .= 'var d=document,';
+    $script .= 'g=d.createElement("script"),';
+    $script .= 's=d.getElementsByTagName("script")[0];';
+    $script .= 'g.type="text/javascript";';
+    $script .= 'g.defer=true;';
+    $script .= 'g.async=true;';
+
+    // Should a local cached copy of the tracking code be used?
+    if ($config->get('cache') && $url = _matomo_cache($url_http . 'piwik.js')) {
+      // A dummy query-string is added to filenames, to gain control over
+      // browser-caching. The string changes on every update or full cache
+      // flush, forcing browsers to load a new copy of the files, as the
+      // URL changed.
+      $query_string = '?' . (\Drupal::state()->get('system.css_js_query_string') ?: '0');
+
+      $script .= 'g.src="' . $url . $query_string . '";';
+    }
+    else {
+      $script .= 'g.src=u+"piwik.js";';
+    }
+
+    $script .= 's.parentNode.insertBefore(g,s);';
+    $script .= '})();';
+
+    // Add tracker code.
+    $page['#attached']['html_head'][] = [
+      [
+        '#tag' => 'script',
+        '#value' => new MatomoJavaScriptSnippet($script),
+      ],
+      'matomo_tracking_script',
+    ];
+  }
+}
+
+/**
+ * Generate user id hash to implement USER_ID.
+ *
+ * The USER_ID value should be a unique, persistent, and non-personally
+ * identifiable string identifier that represents a user or signed-in
+ * account across devices.
+ *
+ * @param int $uid
+ *   User id.
+ *
+ * @return string
+ *   User id hash.
+ */
+function matomo_user_id_hash($uid) {
+  return Crypt::hmacBase64($uid, \Drupal::service('private_key')->get() . Settings::getHashSalt());
+}
+
+/**
+ * Implements hook_entity_extra_field_info().
+ */
+function matomo_entity_extra_field_info() {
+  $extra['user']['user']['form']['matomo'] = [
+    'label' => t('Matomo settings'),
+    'description' => t('Matomo module form element.'),
+    'weight' => 3,
+  ];
+
+  return $extra;
+}
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ *
+ * Allow users to decide if tracking code will be added to pages or not.
+ */
+function matomo_form_user_form_alter(&$form, FormStateInterface $form_state) {
+  $config = \Drupal::config('matomo.settings');
+  $account = $form_state->getFormObject()->getEntity();
+
+  if ($account->hasPermission('opt-in or out of matomo tracking') && ($visibility_users = $config->get('visibility.user_account_mode')) != 0 && _matomo_visibility_roles($account)) {
+    $account_data_matomo = \Drupal::service('user.data')->get('matomo', $account->id());
+
+    $form['matomo'] = [
+      '#type' => 'details',
+      '#title' => t('Matomo settings'),
+      '#weight' => 3,
+      '#open' => TRUE,
+    ];
+
+    switch ($visibility_users) {
+      case 1:
+        $description = t('Users are tracked by default, but you are able to opt out.');
+        break;
+
+      case 2:
+        $description = t('Users are <em>not</em> tracked by default, but you are able to opt in.');
+        break;
+    }
+
+    // Disable tracking for visitors who have opted out from tracking via DNT
+    // (Do-Not-Track) header.
+    $disabled = FALSE;
+    if ($config->get('privacy.donottrack') && !empty($_SERVER['HTTP_DNT'])) {
+      $disabled = TRUE;
+
+      // Override settings value.
+      $account_data_matomo['users'] = FALSE;
+
+      $description .= '<span class="admin-missing">';
+      $description .= ' ' . t('You have opted out from tracking via browser privacy settings.');
+      $description .= '</span>';
+    }
+
+    // Migrate old piwik settings to matomo.
+    $account_data_piwik = \Drupal::service('user.data')->get('piwik', $account->id());
+    if (isset($account_data_piwik['user_account_users'])) {
+      $account_data_matomo['user_account_users'] = $account_data_piwik['user_account_users'];
+    }
+
+    $form['matomo']['user_account_users'] = [
+      '#type' => 'checkbox',
+      '#title' => t('Enable user tracking'),
+      '#description' => $description,
+      '#default_value' => isset($account_data_matomo['user_account_users']) ? $account_data_matomo['user_account_users'] : ($visibility_users == 1),
+      '#disabled' => $disabled,
+    ];
+
+    // hook_user_update() is missing in D8, add custom submit handler.
+    $form['actions']['submit']['#submit'][] = 'matomo_user_profile_form_submit';
+  }
+}
+
+/**
+ * Submit callback for user profile form to save the Matomo setting.
+ */
+function matomo_user_profile_form_submit($form, FormStateInterface $form_state) {
+  $account = $form_state->getFormObject()->getEntity();
+  if ($account->id() && $form_state->hasValue('user_account_users')) {
+    \Drupal::service('user.data')->set('matomo', $account->id(), 'user_account_users', (int) $form_state->getValue('user_account_users'));
+  }
+
+  // Remove old piwik setting to complete migration to matomo.
+  $account_data_piwik = \Drupal::service('user.data')->get('piwik', $account->id());
+  if (isset($account_data_piwik)) {
+    \Drupal::service('user.data')->delete('piwik', $account->id());
+  }
+}
+
+/**
+ * Implements hook_cron().
+ */
+function matomo_cron() {
+  $config = \Drupal::config('matomo.settings');
+
+  // Regenerate the piwik.js every day.
+  if (REQUEST_TIME - \Drupal::state()->get('matomo.last_cache') >= 86400 && $config->get('cache')) {
+    _matomo_cache($config->get('url_http') . 'piwik.js', TRUE);
+    \Drupal::state()->set('matomo.last_cache', REQUEST_TIME);
+  }
+}
+
+/**
+ * Implements hook_preprocess_item_list__search_results().
+ *
+ * Collects and adds the number of search results to the head.
+ */
+function matomo_preprocess_item_list__search_results(&$variables) {
+  $config = \Drupal::config('matomo.settings');
+
+  // Only run on search results list.
+  if ($config->get('track.site_search')) {
+    // There is no search result $variable available that hold the number of
+    // items found. The variable $variables['items'] has the current page items
+    // only. But the pager item mumber can tell the number of search results.
+    global $pager_total_items;
+
+    $variables['#attached']['html_head'][] = [
+      [
+        '#tag' => 'script',
+        '#value' => 'window.matomo_search_results = ' . intval($pager_total_items[0]) . ';',
+        '#weight' => JS_LIBRARY - 1,
+      ],
+      'matomo_search_script',
+    ];
+  }
+}
+
+/**
+ * Download/Synchronize/Cache tracking code file locally.
+ *
+ * @param string $location
+ *   The full URL to the external javascript file.
+ * @param bool $synchronize
+ *   Synchronize to local cache if remote file has changed.
+ *
+ * @return mixed
+ *   The path to the local javascript file on success, boolean FALSE on failure.
+ */
+function _matomo_cache($location, $synchronize = FALSE) {
+  $path = 'public://matomo';
+  $file_destination = $path . '/' . basename($location);
+
+  if (!file_exists($file_destination) || $synchronize) {
+    // Download the latest tracking code.
+    try {
+      $data = \Drupal::httpClient()
+        ->get($location)
+        ->getBody(TRUE);
+
+      if (file_exists($file_destination)) {
+        // Synchronize tracking code and and replace local file if outdated.
+        $data_hash_local = Crypt::hashBase64(file_get_contents($file_destination));
+        $data_hash_remote = Crypt::hashBase64($data);
+        // Check that the files directory is writable.
+        if ($data_hash_local != $data_hash_remote && file_prepare_directory($path)) {
+          // Save updated tracking code file to disk.
+          file_unmanaged_save_data($data, $file_destination, FILE_EXISTS_REPLACE);
+          // Based on Drupal Core class AssetDumper.
+          if (extension_loaded('zlib') && \Drupal::config('system.performance')->get('js.gzip')) {
+            file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+          }
+          \Drupal::logger('matomo')->info('Locally cached tracking code file has been updated.');
+
+          // Change query-strings on css/js files to enforce reload for all
+          // users.
+          _drupal_flush_css_js();
+        }
+      }
+      else {
+        // Check that the files directory is writable.
+        if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
+          // There is no need to flush JS here as core refreshes JS caches
+          // automatically, if new files are added.
+          file_unmanaged_save_data($data, $file_destination, FILE_EXISTS_REPLACE);
+          // Based on Drupal Core class AssetDumper.
+          if (extension_loaded('zlib') && \Drupal::config('system.performance')->get('js.gzip')) {
+            file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+          }
+          \Drupal::logger('matomo')->info('Locally cached tracking code file has been saved.');
+
+          // Return the local JS file path.
+          return file_url_transform_relative(file_create_url($file_destination));
+        }
+      }
+    }
+    catch (RequestException $exception) {
+      watchdog_exception('matomo', $exception);
+    }
+  }
+  else {
+    // Return the local JS file path.
+    return file_url_transform_relative(file_create_url($file_destination));
+  }
+}
+
+/**
+ * Delete cached files and directory.
+ */
+function matomo_clear_js_cache() {
+  $path = 'public://matomo';
+  if (file_prepare_directory($path)) {
+    file_scan_directory($path, '/.*/', ['callback' => 'file_unmanaged_delete']);
+    \Drupal::service('file_system')->rmdir($path);
+
+    // Change query-strings on css/js files to enforce reload for all users.
+    _drupal_flush_css_js();
+
+    \Drupal::logger('matomo')->info('Local cache has been purged.');
+  }
+}
+
+/**
+ * Tracking visibility check for an user object.
+ *
+ * @param object $account
+ *   A user object containing an array of roles to check.
+ *
+ * @return bool
+ *   TRUE if the current user is being tracked by Matomo, otherwise FALSE.
+ */
+function _matomo_visibility_user($account) {
+  $config = \Drupal::config('matomo.settings');
+  $enabled = FALSE;
+
+  // Is current user a member of a role that should be tracked?
+  if (_matomo_visibility_roles($account)) {
+
+    // Use the user's block visibility setting, if necessary.
+    if (($visibility_user_account_mode = $config->get('visibility.user_account_mode')) != 0) {
+      $user_data_matomo = \Drupal::service('user.data')->get('matomo', $account->id());
+      if ($account->id() && isset($user_data_matomo['user_account_users'])) {
+        $enabled = $user_data_matomo['user_account_users'];
+      }
+      else {
+        $enabled = ($visibility_user_account_mode == 1);
+      }
+    }
+    else {
+      $enabled = TRUE;
+    }
+
+  }
+
+  return $enabled;
+}
+
+/**
+ * Tracking visibility check for user roles.
+ *
+ * Based on visibility setting this function returns TRUE if Matomo code should
+ * be added for the current role and otherwise FALSE.
+ *
+ * @param object $account
+ *   A user object containing an array of roles to check.
+ *
+ * @return bool
+ *   TRUE if JS code should be added for the current role and otherwise FALSE.
+ */
+function _matomo_visibility_roles($account) {
+  $config = \Drupal::config('matomo.settings');
+  $enabled = $visibility_user_role_mode = $config->get('visibility.user_role_mode');
+  $user_role_roles = $config->get('visibility.user_role_roles');
+
+  if (count($user_role_roles) > 0) {
+    // One or more roles are selected.
+    foreach (array_values($account->getRoles()) as $user_role) {
+      // Is the current user a member of one of these roles?
+      if (in_array($user_role, $user_role_roles)) {
+        // Current user is a member of a role that should be tracked/excluded
+        // from tracking.
+        $enabled = !$visibility_user_role_mode;
+        break;
+      }
+    }
+  }
+  else {
+    // No role is selected for tracking, therefore all roles should be tracked.
+    $enabled = TRUE;
+  }
+
+  return $enabled;
+}
+
+/**
+ * Tracking visibility check for pages.
+ *
+ * Based on visibility setting this function returns TRUE if JS code should
+ * be added to the current page and otherwise FALSE.
+ */
+function _matomo_visibility_pages() {
+  static $page_match;
+
+  // Cache visibility result if function is called more than once.
+  if (!isset($page_match)) {
+    $config = \Drupal::config('matomo.settings');
+    $visibility_request_path_mode = $config->get('visibility.request_path_mode');
+    $visibility_request_path_pages = $config->get('visibility.request_path_pages');
+
+    // Match path if necessary.
+    if (!empty($visibility_request_path_pages)) {
+      // Convert path to lowercase. This allows comparison of the same path
+      // with different case. Ex: /Page, /page, /PAGE.
+      $pages = Unicode::strtolower($visibility_request_path_pages);
+      if ($visibility_request_path_mode < 2) {
+        // Compare the lowercase path alias (if any) and internal path.
+        $path = \Drupal::service('path.current')->getPath();
+        $path_alias = Unicode::strtolower(\Drupal::service('path.alias_manager')->getAliasByPath($path));
+        $page_match = \Drupal::service('path.matcher')->matchPath($path_alias, $pages) || (($path != $path_alias) && \Drupal::service('path.matcher')->matchPath($path, $pages));
+        // When $visibility_request_path_mode has a value of 0, the tracking
+        // code is displayed on all pages except those listed in $pages. When
+        // set to 1, it is displayed only on those pages listed in $pages.
+        $page_match = !($visibility_request_path_mode xor $page_match);
+      }
+      elseif (\Drupal::moduleHandler()->moduleExists('php')) {
+        $page_match = php_eval($visibility_request_path_pages);
+      }
+      else {
+        $page_match = FALSE;
+      }
+    }
+    else {
+      $page_match = TRUE;
+    }
+
+  }
+  return $page_match;
+}
+
+/**
+ * Get the page titles trail for the current page.
+ *
+ * Based on menu_get_active_breadcrumb().
+ *
+ * @return array
+ *   All page titles, including current page.
+ */
+function _matomo_get_hierarchy_titles() {
+  $titles = [];
+  $path = Url::fromRoute('<current>')->toString();
+  $config = \Drupal::config('system.site');
+  $matomo_conf = \Drupal::config('matomo.settings');
+
+  // No breadcrumb for the front page.
+  if (($path === Url::fromUserInput($config->get('page.front'))->toString())) {
+    return $titles;
+  }
+
+  // Load up the menu tree.
+  // TODO: Check this is a sane approach.
+  $menu_tree = \Drupal::menuTree();
+  $menu_name = \Drupal::config('system.menu.main')->get('id');
+
+  // Build the typical default set of menu tree parameters.
+  $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
+
+  // Load the tree based on this set of parameters.
+  $tree = $menu_tree->load($menu_name, $parameters);
+
+  // Transform the tree using the manipulators.
+  $manipulators = [
+    // Only show links that are accessible for the current user.
+    ['callable' => 'menu.default_tree_manipulators:checkAccess'],
+    // Use the default sorting of menu links.
+    ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
+    // Fatten the menu.
+    ['callable' => 'menu.default_tree_manipulators:flatten'],
+  ];
+  $tree = $menu_tree->transform($tree, $manipulators);
+
+  if (!empty($tree)) {
+    foreach ($tree as $menu_item) {
+      // If the item is in the active trail and we don't have a front page link
+      // when we have set to exclude home from the breadcrumbs then add the
+      // title.
+      if ($menu_item->inActiveTrail && !($matomo_conf->get('page_title_hierarchy_exclude_home') && $menu_item->link->getRouteName() == '<front>')) {
+        $titles[] = $menu_item->link->getTitle();
+      }
+    }
+  }
+
+  return $titles;
+}

+ 14 - 0
sites/all/modules/contrib/admin/matomo/matomo.permissions.yml

@@ -0,0 +1,14 @@
+administer matomo:
+  title: 'Administer Matomo'
+  description: 'Perform maintenance tasks for Matomo.'
+opt-in or out of matomo tracking:
+  title: 'Opt-in or out of tracking'
+  description: 'Allow users to decide if tracking code will be added to pages or not.'
+use php for matomo tracking visibility:
+  title: 'Use PHP for tracking visibility'
+  description: 'Enter PHP code in the field for tracking visibility settings.'
+  restrict access: true
+add js snippets for matomo:
+  title: 'Add JavaScript snippets'
+  description: 'Enter JavaScript code snippets for advanced Matomo functionality.'
+  restrict access: true

+ 7 - 0
sites/all/modules/contrib/admin/matomo/matomo.routing.yml

@@ -0,0 +1,7 @@
+matomo.admin_settings_form:
+  path: '/admin/config/system/matomo'
+  defaults:
+    _form: '\Drupal\matomo\Form\MatomoAdminSettingsForm'
+    _title: 'Matomo Analytics'
+  requirements:
+    _permission: 'administer matomo'

+ 60 - 0
sites/all/modules/contrib/admin/matomo/matomo.tokens.inc

@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * @file
+ * Builds placeholder replacement tokens for user-related data.
+ */
+
+use Drupal\Component\Utility\Html;
+use Drupal\Core\Render\BubbleableMetadata;
+
+/**
+ * Implements hook_token_info().
+ */
+function matomo_token_info() {
+  $user['matomo-role-names'] = [
+    'name' => t('User role names'),
+    'description' => t('The role names the user account is a member of as comma separated list.'),
+    'needs-data' => 'user',
+  ];
+  $user['matomo-role-ids'] = [
+    'name' => t('User role ids'),
+    'description' => t('The role ids the user account is a member of as comma separated list.'),
+    'needs-data' => 'user',
+  ];
+
+  return [
+    'tokens' => ['user' => $user],
+  ];
+}
+
+/**
+ * Implements hook_tokens().
+ */
+function matomo_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
+  $sanitize = !empty($options['sanitize']);
+  $replacements = [];
+
+  if ($type == 'user' && !empty($data['user'])) {
+    $account = $data['user'];
+
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        // Basic user account information.
+        case 'matomo-role-names':
+          $names = implode(',', $account->getRoles());
+          $replacements[$original] = $sanitize ? Html::escape($names) : $names;
+          $bubbleable_metadata->addCacheableDependency($account);
+          break;
+
+        case 'matomo-role-ids':
+          $ids = implode(',', array_keys($account->getRoles()));
+          $replacements[$original] = $sanitize ? Html::escape($ids) : $ids;
+          $bubbleable_metadata->addCacheableDependency($account);
+          break;
+      }
+    }
+  }
+
+  return $replacements;
+}

+ 70 - 0
sites/all/modules/contrib/admin/matomo/migration_templates/d6_matomo_settings.yml

@@ -0,0 +1,70 @@
+id: d6_piwik_settings
+label: Piwik 6 configuration
+migration_tags:
+  - Drupal 6
+  - Configuration
+source:
+  plugin: variable
+  variables:
+    - piwik_cache
+    - piwik_codesnippet_after
+    - piwik_codesnippet_before
+    - piwik_custom
+    - piwik_domain_mode
+    - piwik_pages
+    - piwik_privacy_donottrack
+    - piwik_roles
+    - piwik_site_id
+    - piwik_site_search
+    - piwik_trackmessages
+    - piwik_track
+    - piwik_trackfiles_extensions
+    - piwik_trackmailto
+    - piwik_trackuserid
+    - piwik_translation_set
+    - piwik_url_http
+    - piwik_url_https
+    - piwik_visibility_pages
+    - piwik_visibility_roles
+    - piwik_page_title_hierarchy
+    - piwik_page_title_hierarchy_exclude_home
+  source_module: piwik
+process:
+  cache: piwik_cache
+  'codesnippet/after': piwik_codesnippet_after
+  'codesnippet/before': piwik_codesnippet_before
+  domain_mode: piwik_domain_mode
+  'privacy/donottrack': piwik_privacy_donottrack
+  site_id: piwik_site_id
+  'track/files': piwik_track
+  'track/files_extensions': piwik_trackfiles_extensions
+  'track/mailto': piwik_trackmailto
+  'track/messages': piwik_trackmessages
+  'track/site_search': piwik_site_search
+  'track/userid': piwik_trackuserid
+  'translation_set': piwik_translation_set
+  url_http: piwik_url_http
+  url_https: piwik_url_https
+  'visibility/user_account_mode': piwik_custom
+  'visibility/request_path_mode': piwik_visibility_pages
+  'visibility/request_path_pages':
+    plugin: matomo_visibility_pages
+    source:
+      - piwik_visibility_pages
+      - piwik_pages
+    # If Piwik uses PHP visibility, don't migrate it unless the PHP module is
+    # enabled.
+    skip_php: true
+  'visibility/user_role_mode': piwik_visibility_roles
+  'visibility/user_role_roles':
+    plugin: matomo_visibility_roles
+    source:
+      - piwik_roles
+  page_title_hierarchy: piwik_page_title_hierarchy
+  page_title_hierarchy_exclude_home: piwik_page_title_hierarchy_exclude_home
+destination:
+  plugin: config
+  config_name: matomo.settings
+migration_dependencies:
+  optional:
+    - d6_user_role

+ 22 - 0
sites/all/modules/contrib/admin/matomo/migration_templates/d6_matomo_user_settings.yml

@@ -0,0 +1,22 @@
+id: d6_piwik_user_settings
+label: Piwik user settings
+migration_tags:
+  - Drupal 6
+source:
+  plugin: d6_user
+  constants:
+    key: user_account_users
+    module: piwik
+process:
+  uid: uid
+  key: 'constants/key'
+  module: 'constants/module'
+  settings:
+    plugin: skip_row_if_not_set
+    index: 'custom'
+    source: data/piwik
+destination:
+  plugin: user_data
+migration_dependencies:
+  required:
+    - d6_user

+ 77 - 0
sites/all/modules/contrib/admin/matomo/migration_templates/d7_matomo_settings.yml

@@ -0,0 +1,77 @@
+id: d7_matomo_settings
+label: Matomo 7 configuration
+migration_tags:
+  - Drupal 7
+  - Configuration
+source:
+  plugin: variable
+  variables:
+    - matomo_cache
+    - matomo_codesnippet_after
+    - matomo_codesnippet_before
+    - matomo_custom
+    - matomo_custom_var
+    - matomo_domain_mode
+    - matomo_pages
+    - matomo_privacy_donottrack
+    - matomo_roles
+    - matomo_site_id
+    - matomo_site_search
+    - matomo_track
+    - matomo_trackcolorbox
+    - matomo_trackfiles_extensions
+    - matomo_trackmailto
+    - matomo_trackmessages
+    - matomo_trackuserid
+    - matomo_translation_set
+    - matomo_url_http
+    - matomo_url_https
+    - matomo_visibility_pages
+    - matomo_visibility_roles
+    - matomo_page_title_hierarchy
+    - matomo_page_title_hierarchy_exclude_home
+  source_module: matomo
+process:
+  cache: matomo_cache
+  'codesnippet/after': matomo_codesnippet_after
+  'codesnippet/before': matomo_codesnippet_before
+  'custom/variable':
+    plugin: matomo_custom_vars
+    source:
+      - matomo_custom_var
+  domain_mode: matomo_domain_mode
+  'privacy/donottrack': matomo_privacy_donottrack
+  site_id: matomo_site_id
+  'track/colorbox': matomo_trackcolorbox
+  'track/files': matomo_track
+  'track/files_extensions': matomo_trackfiles_extensions
+  'track/mailto': matomo_trackmailto
+  'track/messages': matomo_trackmessages
+  'track/site_search': matomo_site_search
+  'track/userid': matomo_trackuserid
+  'translation_set': matomo_translation_set
+  url_http: matomo_url_http
+  url_https: matomo_url_https
+  'visibility/user_account_mode': matomo_custom
+  'visibility/request_path_mode': matomo_visibility_pages
+  'visibility/request_path_pages':
+    plugin: matomo_visibility_pages
+    source:
+      - matomo_visibility_pages
+      - matomo_pages
+    # If Matomo uses PHP visibility, don't migrate it unless the PHP module is
+    # enabled.
+    skip_php: true
+  'visibility/user_role_mode': matomo_visibility_roles
+  'visibility/user_role_roles':
+    plugin: matomo_visibility_roles
+    source:
+      - matomo_roles
+  page_title_hierarchy: matomo_page_title_hierarchy
+  page_title_hierarchy_exclude_home: matomo_page_title_hierarchy_exclude_home
+destination:
+  plugin: config
+  config_name: matomo.settings
+migration_dependencies:
+  optional:
+    - d7_user_role

+ 22 - 0
sites/all/modules/contrib/admin/matomo/migration_templates/d7_matomo_user_settings.yml

@@ -0,0 +1,22 @@
+id: d7_matomo_user_settings
+label: Matomo user settings
+migration_tags:
+  - Drupal 7
+source:
+  plugin: d7_user
+  constants:
+    key: user_account_users
+    module: matomo
+process:
+  uid: uid
+  key: 'constants/key'
+  module: 'constants/module'
+  settings:
+    plugin: skip_row_if_not_set
+    index: 'custom'
+    source: data/matomo
+destination:
+  plugin: user_data
+migration_dependencies:
+  required:
+    - d7_user

+ 43 - 0
sites/all/modules/contrib/admin/matomo/src/Component/Render/MatomoJavaScriptSnippet.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace Drupal\matomo\Component\Render;
+
+use Drupal\Component\Render\MarkupInterface;
+
+/**
+ * Formats a string for JavaScript display.
+ */
+class MatomoJavaScriptSnippet implements MarkupInterface {
+
+  /**
+   * The string to escape.
+   *
+   * @var string
+   */
+  protected $string;
+
+  /**
+   * Constructs an HtmlEscapedText object.
+   *
+   * @param string $string
+   *   The string to escape. This value will be cast to a string.
+   */
+  public function __construct($string) {
+    $this->string = (string) $string;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __toString() {
+    return $this->string;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function jsonSerialize() {
+    return $this->__toString();
+  }
+
+}

File diff suppressed because it is too large
+ 336 - 0
sites/all/modules/contrib/admin/matomo/src/Form/MatomoAdminSettingsForm.php


+ 27 - 0
sites/all/modules/contrib/admin/matomo/src/Plugin/migrate/process/MatomoCustomVars.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace Drupal\matomo\Plugin\migrate\process;
+
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\Row;
+
+/**
+ * This plugin flattens the custom variables array.
+ *
+ * @MigrateProcessPlugin(
+ *   id = "matomo_custom_vars"
+ * )
+ */
+class MatomoCustomVars extends ProcessPluginBase {
+
+  /**
+   * Flatten custom vars array.
+   */
+  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+    list($matomo_custom_vars) = $value;
+
+    return isset($matomo_custom_vars['slots']) ? $matomo_custom_vars['slots'] : [];
+  }
+
+}

+ 113 - 0
sites/all/modules/contrib/admin/matomo/src/Plugin/migrate/process/MatomoVisibilityPages.php

@@ -0,0 +1,113 @@
+<?php
+
+namespace Drupal\matomo\Plugin\migrate\process;
+
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\MigrateSkipRowException;
+use Drupal\migrate\Plugin\MigrateProcessInterface;
+use Drupal\migrate\Plugin\MigrationInterface;
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\Row;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Prefixes paths with a slash.
+ *
+ * @MigrateProcessPlugin(
+ *   id = "matomo_visibility_pages"
+ * )
+ */
+class MatomoVisibilityPages extends ProcessPluginBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * The module handler.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
+  /**
+   * The migration process plugin, configured for lookups in the d6_user_role
+   * and d7_user_role migrations.
+   *
+   * @var \Drupal\migrate\Plugin\MigrateProcessInterface
+   */
+  protected $migrationPlugin;
+
+  /**
+   * Whether or not to skip Matomo that use PHP for visibility. Only applies if
+   * the PHP module is not enabled.
+   *
+   * @var bool
+   */
+  protected $skipPHP = FALSE;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, MigrateProcessInterface $migration_plugin) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->moduleHandler = $module_handler;
+    $this->migrationPlugin = $migration_plugin;
+
+    if (isset($configuration['skip_php'])) {
+      $this->skipPHP = $configuration['skip_php'];
+    }
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
+    $migration_configuration = [
+      'migration' => [
+        'd6_user_role',
+        'd7_user_role',
+      ],
+    ];
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('module_handler'),
+      $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration)
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+    list($old_visibility, $pages) = $value;
+
+    $request_path_pages = '';
+
+    if ($pages) {
+      // 2 == BLOCK_VISIBILITY_PHP in Drupal 6 and 7.
+      if ($old_visibility == 2) {
+        // If the PHP module is present, migrate the visibility code unaltered.
+        if ($this->moduleHandler->moduleExists('php')) {
+          $request_path_pages = $pages;
+        }
+        // Skip the row if we're configured to. If not, we don't need to do
+        // anything else -- the block will simply have no PHP or request_path
+        // visibility configuration.
+        elseif ($this->skipPHP) {
+          throw new MigrateSkipRowException();
+        }
+      }
+      else {
+        $paths = preg_split("(\r\n?|\n)", $pages);
+        foreach ($paths as $key => $path) {
+          $paths[$key] = $path === '<front>' ? $path : '/' . ltrim($path, '/');
+        }
+        $request_path_pages = implode("\n", $paths);
+      }
+    }
+
+    return $request_path_pages;
+  }
+
+}

+ 87 - 0
sites/all/modules/contrib/admin/matomo/src/Plugin/migrate/process/MatomoVisibilityRoles.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace Drupal\matomo\Plugin\migrate\process;
+
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\Plugin\MigrateProcessInterface;
+use Drupal\migrate\Plugin\MigrationInterface;
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\Row;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Converts D7 role ids to D8 role names.
+ *
+ * @MigrateProcessPlugin(
+ *   id = "matomo_visibility_roles"
+ * )
+ */
+class MatomoVisibilityRoles extends ProcessPluginBase implements ContainerFactoryPluginInterface {
+
+  /**
+   * The module handler.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
+  /**
+   * The migration process plugin, configured for lookups in the d6_user_role
+   * and d7_user_role migrations.
+   *
+   * @var \Drupal\migrate\Plugin\MigrateProcessInterface
+   */
+  protected $migrationPlugin;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, MigrateProcessInterface $migration_plugin) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->moduleHandler = $module_handler;
+    $this->migrationPlugin = $migration_plugin;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
+    $migration_configuration = [
+      'migration' => [
+        'd6_user_role',
+        'd7_user_role',
+      ],
+    ];
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('module_handler'),
+      $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration)
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+    list($roles) = $value;
+
+    // Remove role IDs disabled in D6/D7.
+    $roles = array_filter($roles);
+
+    $user_role_roles = [];
+
+    if ($roles) {
+      foreach ($roles as $key => $role_id) {
+        $roles[$key] = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property);
+      }
+      $user_role_roles = array_combine($roles, $roles);
+    }
+
+    return $user_role_roles;
+  }
+
+}

+ 222 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoBasicTest.php

@@ -0,0 +1,222 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\Core\Session\AccountInterface;
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test basic functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoBasicTest extends WebTestBase {
+
+  /**
+   * User without permissions to use snippets.
+   *
+   * @var \Drupal\user\UserInterface
+   */
+  protected $noSnippetUser;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+    ];
+
+    // User to set up matomo.
+    $this->noSnippetUser = $this->drupalCreateUser($permissions);
+    $permissions[] = 'add js snippets for matomo';
+    $this->admin_user = $this->drupalCreateUser($permissions);
+    $this->drupalLogin($this->admin_user);
+  }
+
+  /**
+   * Tests if configuration is possible.
+   */
+  public function testMatomoConfiguration() {
+    // Check for setting page's presence.
+    $this->drupalGet('admin/config/system/matomo');
+    $this->assertRaw(t('Matomo site ID'), '[testMatomoConfiguration]: Settings page displayed.');
+
+    // Check for account code validation.
+    $edit['matomo_site_id'] = $this->randomMachineName(2);
+    $edit['matomo_url_http'] = 'http://www.example.com/matomo/';
+    $this->drupalPostForm('admin/config/system/matomo', $edit, 'Save configuration');
+    $this->assertRaw(t('A valid Matomo site ID is an integer only.'), '[testMatomoConfiguration]: Invalid Matomo site ID number validated.');
+
+    // Verify that invalid URLs throw a form error.
+    $edit = [];
+    $edit['matomo_site_id'] = 1;
+    $edit['matomo_url_http'] = 'http://www.example.com/matomo/';
+    $edit['matomo_url_https'] = 'https://www.example.com/matomo/';
+    $this->drupalPostForm('admin/config/system/matomo', $edit, t('Save configuration'));
+    $this->assertRaw('The validation of "http://www.example.com/matomo/piwik.php" failed with an exception', '[testMatomoConfiguration]: HTTP URL exception shown.');
+    $this->assertRaw('The validation of "https://www.example.com/matomo/piwik.php" failed with an exception', '[testMatomoConfiguration]: HTTPS URL exception shown.');
+
+    // User should have access to code snippets.
+    $this->assertFieldByName('matomo_codesnippet_before');
+    $this->assertFieldByName('matomo_codesnippet_after');
+    $this->assertNoFieldByXPath("//textarea[@name='matomo_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.');
+    $this->assertNoFieldByXPath("//textarea[@name='matomo_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.');
+
+    // Login as user without JS permissions.
+    $this->drupalLogin($this->noSnippetUser);
+    $this->drupalGet('admin/config/system/matomo');
+
+    // User should *not* have access to snippets, but create fields.
+    $this->assertFieldByName('matomo_codesnippet_before');
+    $this->assertFieldByName('matomo_codesnippet_after');
+    $this->assertFieldByXPath("//textarea[@name='matomo_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.');
+    $this->assertFieldByXPath("//textarea[@name='matomo_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.');
+  }
+
+  /**
+   * Tests if page visibility works.
+   */
+  public function testMatomoPageVisibility() {
+    $site_id = '1';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Show tracking on "every page except the listed pages".
+    $this->config('matomo.settings')->set('visibility.request_path_mode', 0)->save();
+    // Disable tracking one "admin*" pages only.
+    $this->config('matomo.settings')->set('visibility.request_path_pages', "/admin\n/admin/*")->save();
+    // Enable tracking only for authenticated users only.
+    $this->config('matomo.settings')->set('visibility.user_role_roles', [AccountInterface::AUTHENTICATED_ROLE => AccountInterface::AUTHENTICATED_ROLE])->save();
+
+    // Check tracking code visibility.
+    $this->drupalGet('');
+    $this->assertRaw('/matomo/js/matomo.js', '[testMatomoPageVisibility]: Custom tracking script is is displayed for authenticated users.');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is displayed for authenticated users.');
+
+    // Test whether tracking code is not included on pages to omit.
+    $this->drupalGet('admin');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is not displayed on admin page.');
+    $this->drupalGet('admin/config/system/matomo');
+    // Checking for tracking URI here, as $site_id is displayed in the form.
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is not displayed on admin subpage.');
+
+    // Test whether tracking code display is properly flipped.
+    $this->config('matomo.settings')->set('visibility.request_path_mode', 1)->save();
+    $this->drupalGet('admin');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is displayed on admin page.');
+    $this->drupalGet('admin/config/system/matomo');
+    // Checking for tracking URI here, as $site_id is displayed in the form.
+    $this->assertRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is displayed on admin subpage.');
+    $this->drupalGet('');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is NOT displayed on front page.');
+
+    // Test whether tracking code is not display for anonymous.
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoPageVisibility]: Tracking code is NOT displayed for anonymous.');
+
+    // Switch back to every page except the listed pages.
+    $this->config('matomo.settings')->set('visibility.request_path_mode', 0)->save();
+    // Enable tracking code for all user roles.
+    $this->config('matomo.settings')->set('visibility.user_role_roles', [])->save();
+
+    // Test whether 403 forbidden tracking code is shown if user has no access.
+    $this->drupalGet('admin');
+    $this->assertRaw('"403/URL = "', '[testMatomoPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
+
+    // Test whether 404 not found tracking code is shown on non-existent pages.
+    $this->drupalGet($this->randomMachineName(64));
+    $this->assertRaw('"404/URL = "', '[testMatomoPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
+  }
+
+  /**
+   * Tests if tracking code is properly added to the page.
+   */
+  public function testMatomoTrackingCode() {
+    $site_id = '2';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Show tracking code on every page except the listed pages.
+    $this->config('matomo.settings')->set('visibility.request_path_mode', 0)->save();
+    // Enable tracking code for all user roles.
+    $this->config('matomo.settings')->set('visibility.user_role_roles', [])->save();
+
+    /* Sample JS code as added to page:
+    <script type="text/javascript">
+    var _paq = _paq || [];
+    (function(){
+        var u=(("https:" == document.location.protocol) ? "https://{$MATOMO_URL}" : "http://{$MATOMO_URL}");
+        _paq.push(['setSiteId', {$IDSITE}]);
+        _paq.push(['setTrackerUrl', u+'piwik.php']);
+        _paq.push(['trackPageView']);
+        var d=document,
+            g=d.createElement('script'),
+            s=d.getElementsByTagName('script')[0];
+            g.type='text/javascript';
+            g.defer=true;
+            g.async=true;
+            g.src=u+'piwik.js';
+            s.parentNode.insertBefore(g,s);
+    })();
+    </script>
+    */
+
+    // Test whether tracking code uses latest JS.
+    $this->config('matomo.settings')->set('cache', 0)->save();
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoTrackingCode]: Latest tracking code used.');
+
+    // Test if tracking of User ID is enabled.
+    $this->config('matomo.settings')->set('track.userid', 1)->save();
+    $this->drupalGet('');
+    $this->assertRaw('_paq.push(["setUserId", ', '[testMatomoTrackingCode]: Tracking code for User ID is enabled.');
+
+    // Test if tracking of User ID is disabled.
+    $this->config('matomo.settings')->set('track.userid', 0)->save();
+    $this->drupalGet('');
+    $this->assertNoRaw('_paq.push(["setUserId", ', '[testMatomoTrackingCode]: Tracking code for User ID is disabled.');
+
+    // Test whether single domain tracking is active.
+    $this->drupalGet('');
+    $this->assertNoRaw('_paq.push(["setCookieDomain"', '[testMatomoTrackingCode]: Single domain tracking is active.');
+
+    // Enable "One domain with multiple subdomains".
+    $this->config('matomo.settings')->set('domain_mode', 1)->save();
+    $this->drupalGet('');
+
+    // Test may run on localhost, an ipaddress or real domain name.
+    // TODO: Workaround to run tests successfully. This feature cannot tested
+    // reliable.
+    global $cookie_domain;
+    if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
+      $this->assertRaw('_paq.push(["setCookieDomain"', '[testMatomoTrackingCode]: One domain with multiple subdomains is active on real host.');
+    }
+    else {
+      // Special cases, Localhost and IP addresses don't show 'setCookieDomain'.
+      $this->assertNoRaw('_paq.push(["setCookieDomain"', '[testMatomoTrackingCode]: One domain with multiple subdomains may be active on localhost (test result is not reliable).');
+    }
+
+    // Test whether the BEFORE and AFTER code is added to the tracker.
+    $this->config('matomo.settings')->set('codesnippet.before', '_paq.push(["setLinkTrackingTimer", 250]);')->save();
+    $this->config('matomo.settings')->set('codesnippet.after', '_paq.push(["t2.setSiteId", 2]);if(1 == 1 && 2 < 3 && 2 > 1){console.log("Matomo: Custom condition works.");}_gaq.push(["t2.trackPageView"]);')->save();
+    $this->drupalGet('');
+    $this->assertRaw('setLinkTrackingTimer', '[testMatomoTrackingCode]: Before codesnippet has been found with "setLinkTrackingTimer" set.');
+    $this->assertRaw('t2.trackPageView', '[testMatomoTrackingCode]: After codesnippet with "t2" tracker has been found.');
+    $this->assertRaw('if(1 == 1 && 2 < 3 && 2 > 1){console.log("Matomo: Custom condition works.");}', '[testMatomoTrackingCode]: JavaScript code is not HTML escaped.');
+  }
+
+}

+ 59 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoCustomUrls.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\simpletest\WebTestBase;
+use Drupal\Component\Serialization\Json;
+
+/**
+ * Test custom url functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoCustomUrls extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+      'administer modules',
+      'administer site configuration',
+    ];
+
+    // User to set up matomo.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+  }
+
+  /**
+   * Tests if user password page urls are overridden.
+   */
+  public function testMatomoUserPasswordPage() {
+    $base_path = base_path();
+    $site_id = '1';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    $this->drupalGet('user/password', ['query' => ['name' => 'foo']]);
+    $this->assertRaw('_paq.push(["setCustomUrl", ' . Json::encode($base_path . 'user/password') . ']);');
+
+    $this->drupalGet('user/password', ['query' => ['name' => 'foo@example.com']]);
+    $this->assertRaw('_paq.push(["setCustomUrl", ' . Json::encode($base_path . 'user/password') . ']);');
+
+    $this->drupalGet('user/password');
+    $this->assertNoRaw('_paq.push(["setCustomUrl", "', '[testMatomoCustomUrls]: Custom url not set.');
+  }
+
+}

+ 133 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoCustomVariablesTest.php

@@ -0,0 +1,133 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\Component\Serialization\Json;
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test custom variables functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoCustomVariablesTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo', 'token'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+    ];
+
+    // User to set up matomo.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+  }
+
+  /**
+   * Tests if custom variables are properly added to the page.
+   */
+  public function testMatomoCustomVariables() {
+    $site_id = '3';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Basic test if the feature works.
+    $custom_vars = [
+      1 => [
+        'slot' => 1,
+        'name' => 'Foo 1',
+        'value' => 'Bar 1',
+        'scope' => 'visit',
+      ],
+      2 => [
+        'slot' => 2,
+        'name' => 'Foo 2',
+        'value' => 'Bar 2',
+        'scope' => 'page',
+      ],
+      3 => [
+        'slot' => 3,
+        'name' => 'Foo 3',
+        'value' => 'Bar 3',
+        'scope' => 'page',
+      ],
+      4 => [
+        'slot' => 4,
+        'name' => 'Foo 4',
+        'value' => 'Bar 4',
+        'scope' => 'visit',
+      ],
+      5 => [
+        'slot' => 5,
+        'name' => 'Foo 5',
+        'value' => 'Bar 5',
+        'scope' => 'visit',
+      ],
+    ];
+    $this->config('matomo.settings')->set('custom.variable', $custom_vars)->save();
+    $this->drupalGet('');
+
+    foreach ($custom_vars as $slot) {
+      $this->assertRaw('_paq.push(["setCustomVariable", ' . Json::encode($slot['slot']) . ', ' . Json::encode($slot['name']) . ', ' . Json::encode($slot['value']) . ', ' . Json::encode($slot['scope']) . ']);', '[testMatomoCustomVariables]: setCustomVariable ' . $slot['slot'] . ' is shown.');
+    }
+
+    // Test whether tokens are replaced in custom variable names.
+    $site_slogan = $this->randomMachineName(16);
+    $this->config('system.site')->set('slogan', $site_slogan)->save();
+
+    $custom_vars = [
+      1 => [
+        'slot' => 1,
+        'name' => 'Name: [site:slogan]',
+        'value' => 'Value: [site:slogan]',
+        'scope' => 'visit',
+      ],
+      2 => [
+        'slot' => 2,
+        'name' => '',
+        'value' => $this->randomMachineName(16),
+        'scope' => 'page',
+      ],
+      3 => [
+        'slot' => 3,
+        'name' => $this->randomMachineName(16),
+        'value' => '',
+        'scope' => 'visit',
+      ],
+      4 => [
+        'slot' => 4,
+        'name' => '',
+        'value' => '',
+        'scope' => 'page',
+      ],
+      5 => [
+        'slot' => 5,
+        'name' => '',
+        'value' => '',
+        'scope' => 'visit',
+      ],
+    ];
+    $this->config('matomo.settings')->set('custom.variable', $custom_vars)->save();
+    $this->verbose('<pre>' . print_r($custom_vars, TRUE) . '</pre>');
+
+    $this->drupalGet('');
+    $this->assertRaw('_paq.push(["setCustomVariable", 1, ' . Json::encode("Name: $site_slogan") . ', ' . Json::encode("Value: $site_slogan") . ', "visit"]', '[testMatomoCustomVariables]: Tokens have been replaced in custom variable.');
+    $this->assertNoRaw('_paq.push(["setCustomVariable", 2,', '[testMatomoCustomVariables]: Value with empty name is not shown.');
+    $this->assertNoRaw('_paq.push(["setCustomVariable", 3,', '[testMatomoCustomVariables]: Name with empty value is not shown.');
+    $this->assertNoRaw('_paq.push(["setCustomVariable", 4,', '[testMatomoCustomVariables]: Empty name and value is not shown.');
+    $this->assertNoRaw('_paq.push(["setCustomVariable", 5,', '[testMatomoCustomVariables]: Empty name and value is not shown.');
+  }
+
+}

+ 107 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoPhpFilterTest.php.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\Component\Utility\Html;
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test php filter functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoPhpFilterTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo', 'php'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Administrator with all permissions.
+    $permissions_admin_user = [
+      'access administration pages',
+      'administer matomo',
+      'use php for matomo tracking visibility',
+    ];
+    $this->admin_user = $this->drupalCreateUser($permissions_admin_user);
+
+    // Administrator who cannot configure tracking visibility with PHP.
+    $permissions_delegated_admin_user = [
+      'access administration pages',
+      'administer matomo',
+    ];
+    $this->delegated_admin_user = $this->drupalCreateUser($permissions_delegated_admin_user);
+  }
+
+  /**
+   * Tests if PHP module integration works.
+   */
+  public function testMatomoPhpFilter() {
+    $site_id = '1';
+    $this->drupalLogin($this->admin_user);
+
+    $edit = [];
+    $edit['matomo_site_id'] = $site_id;
+    $edit['matomo_url_http'] = 'http://www.example.com/matomo/';
+    $edit['matomo_url_https'] = 'https://www.example.com/matomo/';
+    // Skip url check errors in automated tests.
+    $edit['matomo_url_skiperror'] = TRUE;
+    $edit['matomo_visibility_request_path_mode'] = 2;
+    $edit['matomo_visibility_request_path_pages'] = '<?php return 0; ?>';
+    $this->drupalPostForm('admin/config/system/matomo', $edit, t('Save configuration'));
+
+    // Compare saved setting with posted setting.
+    $matomo_visibility_request_path_pages = \Drupal::config('matomo.settings')->get('visibility.request_path_pages');
+    $this->assertEqual('<?php return 0; ?>', $matomo_visibility_request_path_pages, '[testMatomoPhpFilter]: PHP code snippet is intact.');
+
+    // Check tracking code visibility.
+    $this->config('matomo.settings')->set('visibility.request_path_pages', '<?php return TRUE; ?>')->save();
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoPhpFilter]: Tracking is displayed on frontpage page.');
+    $this->drupalGet('admin');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoPhpFilter]: Tracking is displayed on admin page.');
+
+    $this->config('matomo.settings')->set('visibility.request_path_pages', '<?php return FALSE; ?>')->save();
+    $this->drupalGet('');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoPhpFilter]: Tracking is not displayed on frontpage page.');
+
+    // Test administration form.
+    $this->config('matomo.settings')->set('visibility.request_path_pages', '<?php return TRUE; ?>')->save();
+    $this->drupalGet('admin/config/system/matomo');
+    $this->assertRaw(t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'), '[testMatomoPhpFilter]: Permission to administer PHP for tracking visibility.');
+    $this->assertRaw(Html::escape('<?php return TRUE; ?>'), '[testMatomoPhpFilter]: PHP code snippted is displayed.');
+
+    // Login the delegated user and check if fields are visible.
+    $this->drupalLogin($this->delegated_admin_user);
+    $this->drupalGet('admin/config/system/matomo');
+    $this->assertNoRaw(t('Pages on which this PHP code returns <code>TRUE</code> (experts only)'), '[testMatomoPhpFilter]: No permission to administer PHP for tracking visibility.');
+    $this->assertRaw(Html::escape('<?php return TRUE; ?>'), '[testMatomoPhpFilter]: No permission to view PHP code snippted.');
+
+    // Set a different value and verify that this is still the same after the
+    // post.
+    $this->config('matomo.settings')->set('visibility.request_path_pages', '<?php return 0; ?>')->save();
+
+    $edit = [];
+    $edit['matomo_site_id'] = $site_id;
+    $edit['matomo_url_http'] = 'http://www.example.com/matomo/';
+    $edit['matomo_url_https'] = 'https://www.example.com/matomo/';
+    // Required for testing only.
+    $edit['matomo_url_skiperror'] = TRUE;
+    $this->drupalPostForm('admin/config/system/matomo', $edit, t('Save configuration'));
+
+    // Compare saved setting with posted setting.
+    $matomo_visibility_request_path_mode = $this->config('matomo.settings')->get('visibility.request_path_mode');
+    $matomo_visibility_request_path_pages = $this->config('matomo.settings')->get('visibility.request_path_pages');
+    $this->assertEqual(2, $matomo_visibility_request_path_mode, '[testMatomoPhpFilter]: Pages on which this PHP code returns TRUE is selected.');
+    $this->assertEqual('<?php return 0; ?>', $matomo_visibility_request_path_pages, '[testMatomoPhpFilter]: PHP code snippet is intact.');
+  }
+
+}

+ 107 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoRolesTest.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\Core\Session\AccountInterface;
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test roles functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoRolesTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+    ];
+
+    // User to set up matomo.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+  }
+
+  /**
+   * Tests if roles based tracking works.
+   */
+  public function testMatomoRolesTracking() {
+    $site_id = '1';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Test if the default settings are working as expected.
+    // Add to the selected roles only.
+    $this->config('matomo.settings')->set('visibility.user_role_mode', 0)->save();
+    // Enable tracking for all users.
+    $this->config('matomo.settings')->set('visibility.user_role_roles', [])->save();
+
+    // Check tracking code visibility.
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for anonymous users on frontpage with default settings.');
+    $this->drupalGet('admin');
+    $this->assertRaw('"403/URL = "', '[testMatomoRoleVisibility]: 403 Forbidden tracking code is displayed for anonymous users in admin section with default settings.');
+
+    $this->drupalLogin($this->admin_user);
+
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for authenticated users on frontpage with default settings.');
+    $this->drupalGet('admin');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed for authenticated users in admin section with default settings.');
+
+    // Test if the non-default settings are working as expected.
+    // Enable tracking only for authenticated users.
+    $this->config('matomo.settings')->set('visibility.user_role_roles', [AccountInterface::AUTHENTICATED_ROLE => AccountInterface::AUTHENTICATED_ROLE])->save();
+
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed for authenticated users only on frontpage.');
+
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed for anonymous users on frontpage.');
+
+    // Add to every role except the selected ones.
+    $this->config('matomo.settings')->set('visibility.user_role_mode', 1)->save();
+    // Enable tracking for all users.
+    $this->config('matomo.settings')->set('visibility.user_role_roles', [])->save();
+
+    // Check tracking code visibility.
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and displayed for anonymous users.');
+    $this->drupalGet('admin');
+    $this->assertRaw('"403/URL = "', '[testMatomoRoleVisibility]: 403 Forbidden tracking code is shown for anonymous users if every role except the selected ones is selected.');
+
+    $this->drupalLogin($this->admin_user);
+
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and displayed on frontpage for authenticated users.');
+    $this->drupalGet('admin');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is added to every role and NOT displayed in admin section for authenticated users.');
+
+    // Disable tracking for authenticated users.
+    $this->config('matomo.settings')->set('visibility.user_role_roles', [AccountInterface::AUTHENTICATED_ROLE => AccountInterface::AUTHENTICATED_ROLE])->save();
+
+    $this->drupalGet('');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed on frontpage for excluded authenticated users.');
+    $this->drupalGet('admin');
+    $this->assertNoRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is NOT displayed in admin section for excluded authenticated users.');
+
+    $this->drupalLogout();
+    $this->drupalGet('');
+    $this->assertRaw('u+"piwik.php"', '[testMatomoRoleVisibility]: Tracking code is displayed on frontpage for included anonymous users.');
+  }
+
+}

+ 98 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoSearchTest.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test search functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoSearchTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo', 'search', 'node'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+      'search content',
+      'create page content',
+      'edit own page content',
+    ];
+
+    // User to set up matomo.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+    $this->drupalLogin($this->admin_user);
+  }
+
+  /**
+   * Tests if search tracking is properly added to the page.
+   */
+  public function testMatomoSearchTracking() {
+    $site_id = '1';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Check tracking code visibility.
+    $this->drupalGet('');
+    $this->assertRaw($site_id, '[testMatomoSearch]: Tracking code is displayed for authenticated users.');
+
+    $this->drupalGet('search/node');
+    $this->assertNoRaw('_paq.push(["trackSiteSearch", ', '[testMatomoSearch]: Search tracker not added to page.');
+
+    // Enable site search support.
+    $this->config('matomo.settings')->set('track.site_search', 1)->save();
+
+    // Search for random string.
+    $search = [];
+    $search['keys'] = $this->randomMachineName(8);
+
+    // Create a node to search for.
+    // Create a node.
+    $edit = [];
+    $edit['title[0][value]'] = 'This is a test title';
+    $edit['body[0][value]'] = 'This test content contains ' . $search['keys'] . ' string.';
+
+    // Fire a search, it's expected to get 0 results.
+    $this->drupalPostForm('search/node', $search, t('Search'));
+    $this->assertRaw('_paq.push(["trackSiteSearch", ', '[testMatomoSearch]: Search results tracker is displayed.');
+    $this->assertRaw('window.matomo_search_results = 0;', '[testMatomoSearch]: Search yielded no results.');
+
+    // Save the node.
+    $this->drupalPostForm('node/add/page', $edit, t('Save'));
+    $this->assertText(t('@type @title has been created.', ['@type' => 'Basic page', '@title' => $edit['title[0][value]']]), 'Basic page created.');
+
+    // Index the node or it cannot found.
+    $this->cronRun();
+
+    $this->drupalPostForm('search/node', $search, t('Search'));
+    $this->assertRaw('_paq.push(["trackSiteSearch", ', '[testMatomoSearch]: Search results tracker is displayed.');
+    $this->assertRaw('window.matomo_search_results = 1;', '[testMatomoSearch]: One search result found.');
+
+    $this->drupalPostForm('node/add/page', $edit, t('Save'));
+    $this->assertText(t('@type @title has been created.', ['@type' => 'Basic page', '@title' => $edit['title[0][value]']]), 'Basic page created.');
+
+    // Index the node or it cannot found.
+    $this->cronRun();
+
+    $this->drupalPostForm('search/node', $search, t('Search'));
+    $this->assertRaw('_paq.push(["trackSiteSearch", ', '[testMatomoSearch]: Search results tracker is displayed.');
+    $this->assertRaw('window.matomo_search_results = 2;', '[testMatomoSearch]: Two search results found.');
+  }
+
+}

+ 69 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoStatusMessagesTest.php

@@ -0,0 +1,69 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test status messages functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoStatusMessagesTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo', 'matomo_test'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+    ];
+
+    // User to set up matomo.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+  }
+
+  /**
+   * Tests if status messages tracking is properly added to the page.
+   */
+  public function testMatomoStatusMessages() {
+    $site_id = '1';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Enable logging of errors only.
+    $this->config('matomo.settings')->set('track.messages', ['error' => 'error'])->save();
+
+    $this->drupalPostForm('user/login', [], t('Log in'));
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Username field is required."]);', '[testMatomoStatusMessages]: trackEvent "Username field is required." is shown.');
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Password field is required."]);', '[testMatomoStatusMessages]: trackEvent "Password field is required." is shown.');
+
+    // Testing this Drupal::messenger() requires an extra test module.
+    $this->drupalGet('matomo-test/drupal-messenger-add-message');
+    $this->assertNoRaw('_paq.push(["trackEvent", "Messages", "Status message", "Example status message."]);', '[testMatomoStatusMessages]: Example status message is not enabled for tracking.');
+    $this->assertNoRaw('_paq.push(["trackEvent", "Messages", "Warning message", "Example warning message."]);', '[testMatomoStatusMessages]: Example warning message is not enabled for tracking.');
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Example error message."]);', '[testMatomoStatusMessages]: Example error message is shown.');
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Example error message with html tags and link."]);', '[testMatomoStatusMessages]: HTML has been stripped successful from Example error message with html tags and link.');
+
+    // Enable logging of status, warnings and errors.
+    $this->config('matomo.settings')->set('track.messages', ['status' => 'status', 'warning' => 'warning', 'error' => 'error'])->save();
+
+    $this->drupalGet('matomo-test/drupal-messenger-add-message');
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Status message", "Example status message."]);', '[testMatomoStatusMessages]: Example status message is enabled for tracking.');
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Warning message", "Example warning message."]);', '[testMatomoStatusMessages]: Example warning message is enabled for tracking.');
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Example error message."]);', '[testMatomoStatusMessages]: Example error message is shown.');
+    $this->assertRaw('_paq.push(["trackEvent", "Messages", "Error message", "Example error message with html tags and link."]);', '[testMatomoStatusMessages]: HTML has been stripped successful from Example error message with html tags and link.');
+  }
+
+}

+ 78 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoUninstallTest.php

@@ -0,0 +1,78 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test uninstall functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoUninstallTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+      'administer modules',
+    ];
+
+    // User to set up matomo.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+    $this->drupalLogin($this->admin_user);
+  }
+
+  /**
+   * Tests if the module cleans up the disk on uninstall.
+   */
+  public function testMatomoUninstall() {
+    $cache_path = 'public://matomo';
+    $site_id = '1';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Enable local caching of piwik.js.
+    $this->config('matomo.settings')->set('cache', 1)->save();
+
+    // Load front page to get the piwik.js downloaded into local cache. But
+    // loading the piwik.js is not possible as "url_http" is a test dummy only.
+    // Create a dummy file to complete the rest of the tests.
+    file_prepare_directory($cache_path, FILE_CREATE_DIRECTORY);
+    $data = $this->randomMachineName(128);
+    $file_destination = $cache_path . '/piwik.js';
+    file_unmanaged_save_data($data, $file_destination);
+    file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+
+    // Test if the directory and piwik.js exists.
+    $this->assertTrue(file_prepare_directory($cache_path), 'Cache directory "public://matomo" has been found.');
+    $this->assertTrue(file_exists($cache_path . '/piwik.js'), 'Cached piwik.js tracking file has been found.');
+    $this->assertTrue(file_exists($cache_path . '/piwik.js.gz'), 'Cached piwik.js.gz tracking file has been found.');
+
+    // Uninstall the module.
+    $edit = [];
+    $edit['uninstall[matomo]'] = TRUE;
+    $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
+    $this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.');
+    $this->drupalPostForm(NULL, NULL, t('Uninstall'));
+    $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
+
+    // Test if the directory and all files have been removed.
+    $this->assertFalse(file_scan_directory($cache_path, '/.*/'), 'Cached JavaScript files have been removed.');
+    $this->assertFalse(file_prepare_directory($cache_path), 'Cache directory "public://matomo" has been removed.');
+  }
+
+}

+ 73 - 0
sites/all/modules/contrib/admin/matomo/src/Tests/MatomoUserFieldsTest.php

@@ -0,0 +1,73 @@
+<?php
+
+namespace Drupal\matomo\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Test user fields functionality of Matomo module.
+ *
+ * @group Matomo
+ */
+class MatomoUserFieldsTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = ['matomo', 'field_ui'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer user form display',
+      'opt-in or out of matomo tracking',
+    ];
+
+    // User to set up matomo.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+    $this->drupalLogin($this->admin_user);
+  }
+
+  /**
+   * Tests if "allow users to customize tracking on their account page" works.
+   */
+  public function testMatomoUserFields() {
+    $site_id = '1';
+    $this->config('matomo.settings')->set('site_id', $site_id)->save();
+    $this->config('matomo.settings')->set('url_http', 'http://www.example.com/matomo/')->save();
+    $this->config('matomo.settings')->set('url_https', 'https://www.example.com/matomo/')->save();
+
+    // Check if the pseudo field is shown on account forms.
+    $this->drupalGet('admin/config/people/accounts/form-display');
+    $this->assertResponse(200);
+    $this->assertRaw(t('Matomo settings'), '[testMatomoUserFields]: Matomo settings field exists on Manage form display.');
+
+    // No customization allowed.
+    $this->config('matomo.settings')->set('visibility.user_account_mode', 0)->save();
+    $this->drupalGet('user/' . $this->admin_user->id() . '/edit');
+    $this->assertResponse(200);
+    $this->assertNoRaw(t('Matomo settings'), '[testMatomoUserFields]: Matomo settings field does not exist on user edit page.');
+
+    // Tracking on by default, users with opt-in or out of matomo tracking permission
+    // can opt out.
+    $this->config('matomo.settings')->set('visibility.user_account_mode', 1)->save();
+    $this->drupalGet('user/' . $this->admin_user->id() . '/edit');
+    $this->assertResponse(200);
+    $this->assertRaw(t('Users are tracked by default, but you are able to opt out.'), '[testMatomoUserFields]: Matomo settings field exists on on user edit page');
+
+    // Tracking off by default, users with opt-in or out of matomo tracking permission
+    // can opt in.
+    $this->config('matomo.settings')->set('visibility.user_account_mode', 2)->save();
+    $this->drupalGet('user/' . $this->admin_user->id() . '/edit');
+    $this->assertResponse(200);
+    $this->assertRaw(t('Users are <em>not</em> tracked by default, but you are able to opt in.'), '[testMatomoUserFields]: Matomo settings field exists on on user edit page.');
+  }
+
+}

+ 11 - 0
sites/all/modules/contrib/admin/matomo/tests/modules/matomo_test/matomo_test.info.yml

@@ -0,0 +1,11 @@
+name: 'Matomo test'
+type: module
+description: 'Support module for Matomo testing.'
+package: Testing
+# core: 8.x
+
+# Information added by Drupal.org packaging script on 2018-07-13
+version: '8.x-1.7'
+core: '8.x'
+project: 'matomo'
+datestamp: 1531470224

+ 7 - 0
sites/all/modules/contrib/admin/matomo/tests/modules/matomo_test/matomo_test.routing.yml

@@ -0,0 +1,7 @@
+matomo_test.drupal_messenger_add_message:
+  path: '/matomo-test/drupal-messenger-add-message'
+  defaults:
+    _title: 'Add messages with Drupal::messenger()'
+    _controller: '\Drupal\matomo_test\Controller\MatomoTestController::drupalAddMessageTest'
+  requirements:
+    _access: 'TRUE'

+ 28 - 0
sites/all/modules/contrib/admin/matomo/tests/modules/matomo_test/src/Controller/MatomoTestController.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\matomo_test\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+
+/**
+ * Controller routines for system_test routes.
+ */
+class MatomoTestController extends ControllerBase {
+
+  /**
+   * Tests setting messages and removing one before it is displayed.
+   *
+   * @return array
+   *   Empty array, we just test the setting of messages.
+   */
+  public function drupalAddMessageTest() {
+    // Set some messages.
+    drupal_set_message($this->t('Example status message.'), 'status');
+    drupal_set_message($this->t('Example warning message.'), 'warning');
+    drupal_set_message($this->t('Example error message.'), 'error');
+    drupal_set_message($this->t('Example error <em>message</em> with html tags and <a href="http://example.com/">link</a>.'), 'error');
+
+    return [];
+  }
+
+}

+ 103 - 0
sites/all/modules/contrib/admin/matomo/tests/src/Functional/AdminSettingsFormTest.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace Drupal\Tests\matomo\Functional;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Tests the configuration form.
+ *
+ * @group matomo
+ */
+class AdminSettingsFormTest extends BrowserTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['matomo'];
+
+  /**
+   * A test administrator.
+   *
+   * @var \Drupal\user\Entity\User
+   */
+  protected $adminUser;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $permissions = [
+      'access administration pages',
+      'administer matomo',
+    ];
+
+    $this->adminUser = $this->drupalCreateUser($permissions);
+    $this->drupalLogin($this->adminUser);
+  }
+
+  /**
+   * Tests the fields that allow to configure tracking of specific pages.
+   *
+   * @param string $pages
+   *   A list of pages that should be tracked. One page per line.
+   * @param bool $validation_error_expected
+   *   TRUE if a validation error should be thrown. FALSE otherwise.
+   *
+   * @dataProvider pageTrackingProvider
+   */
+  public function testPageTracking($pages, $validation_error_expected) {
+    $edit = [
+      'matomo_visibility_request_path_mode' => 0,
+      'matomo_visibility_request_path_pages' => $pages,
+    ];
+    $this->drupalPostForm('admin/config/system/matomo', $edit, t('Save configuration'));
+    $has_validation_error = (bool) $this->getSession()->getPage()->find('css', '#edit-matomo-visibility-request-path-pages.error');
+    $this->assertEquals($validation_error_expected, $has_validation_error);
+  }
+
+  /**
+   * Provides test data for ::testPageTracking().
+   *
+   * @return array
+   *   An array of test cases, each test case is an array with two values:
+   *   0. A string containing a list of pages to track.
+   *   1. A boolean indicating whether or not a validation error is expected to
+   *      be thrown.
+   */
+  public function pageTrackingProvider() {
+    return [
+      [
+        // No validation error should be thrown for an empty page list.
+        '',
+        FALSE,
+      ],
+      [
+        // No validation error should be thrown for a list of valid pages.
+        <<<TXT
+/node/1
+/blog/*/view
+/shop
+<front>
+TXT
+        ,
+        FALSE,
+      ],
+      [
+        // A validation error should be thrown if one of the pages doesn't start
+        // with a slash.
+        <<<TXT
+/node/1
+/blog/*/view
+shop
+<front>
+TXT
+        ,
+        TRUE,
+      ],
+    ];
+  }
+
+}

+ 3 - 1
sites/all/modules/contrib/admin/piwik/composer.json

@@ -18,5 +18,7 @@
     "source": "http://git.drupal.org/project/piwik.git"
   },
   "license": "GPL-2.0+",
-  "require": {}
+  "require": {
+    "drupal/matomo": "^1.0"
+  }
 }

+ 5 - 3
sites/all/modules/contrib/admin/piwik/piwik.info.yml

@@ -7,9 +7,11 @@ configure: piwik.admin_settings_form
 test_dependencies:
   - php:php
   - token:token
+dependencies:
+  - matomo
 
-# Information added by Drupal.org packaging script on 2017-11-11
-version: '8.x-1.2'
+# Information added by Drupal.org packaging script on 2018-06-08
+version: '8.x-1.4'
 core: '8.x'
 project: 'piwik'
-datestamp: 1510404815
+datestamp: 1528483684

+ 104 - 12
sites/all/modules/contrib/admin/piwik/piwik.install

@@ -22,19 +22,111 @@ function piwik_uninstall() {
 function piwik_requirements($phase) {
   $requirements = [];
 
-  if ($phase == 'runtime') {
-    $config = \Drupal::config('piwik.settings');
-
-    // Raise warning if Piwik user account has not been set yet.
-    if (!preg_match('/^\d{1,}$/', $config->get('site_id'))) {
-      $requirements['piwik_site_id'] = [
-        'title' => t('Piwik module'),
-        'description' => t('Piwik module has not been configured yet. Please configure its settings from the <a href=":url">Piwik settings page</a>.', [':url' => Url::fromRoute('piwik.admin_settings_form')->toString()]),
-        'severity' => REQUIREMENT_WARNING,
-        'value' => t('Not configured'),
-      ];
-    }
+  switch ($phase) {
+    case 'install':
+      if (\Drupal::moduleHandler()->moduleExists('matomo')) {
+        // https://matomo.org/blog/2018/01/piwik-is-now-matomo/
+        $requirements['piwik_matomo_is_installed'] = array(
+          'title' => t('Piwik is now Matomo!'),
+          'value' => t('Fails'),
+          'severity' => REQUIREMENT_ERROR,
+          'description' => t('Piwik has been renamed to Matomo Analytics. Piwik module is blocked now and cannot re-enabled! Please remove piwik module from your system. It is no longer used.'),
+        );
+      }
+      break;
+
+    case 'runtime':
+      $config = \Drupal::config('piwik.settings');
+
+      // Raise warning if Piwik user account has not been set yet.
+      if (!preg_match('/^\d{1,}$/', $config->get('site_id'))) {
+        $requirements['piwik_site_id'] = [
+          'title' => t('Piwik module'),
+          'description' => t('Piwik module has not been configured yet. Please configure its settings from the <a href=":url">Piwik settings page</a>.', [':url' => Url::fromRoute('piwik.admin_settings_form')->toString()]),
+          'severity' => REQUIREMENT_WARNING,
+          'value' => t('Not configured'),
+        ];
+      }
+      break;
   }
 
   return $requirements;
 }
+
+/**
+ * Install Matomo module and migrate all settings.
+ */
+function piwik_update_8200() {
+  // Make the update hook failing so it can re-run later again.
+  if (!module_load_include('module', 'matomo', 'matomo')) {
+    throw new DrupalUpdateException(t('Matomo module is missing. Download it and re-run update.php'));
+  }
+
+  $module_enabled = \Drupal::service('module_installer')->install(array('matomo'));
+  if ($module_enabled) {
+    $messages[] = t('Successfully installed matomo module.');
+
+    $piwik_config = \Drupal::configFactory()->getEditable('piwik.settings');
+    $matomo_config = \Drupal::configFactory()->getEditable('matomo.settings');
+    $matomo_config
+      ->set('site_id', $piwik_config->get('site_id'))
+      ->set('url_http', $piwik_config->get('url_http'))
+      ->set('url_https', $piwik_config->get('url_https'))
+      ->set('codesnippet.before', $piwik_config->get('codesnippet.before'))
+      ->set('codesnippet.after', $piwik_config->get('codesnippet.after'))
+      ->set('custom.variable', $piwik_config->get('custom.variable'))
+      ->set('domain_mode', $piwik_config->get('domain_mode'))
+      ->set('track.files', $piwik_config->get('track.files'))
+      ->set('track.files_extensions', $piwik_config->get('track.files_extensions'))
+      ->set('track.colorbox', $piwik_config->get('track.colorbox'))
+      ->set('track.userid', $piwik_config->get('track.userid'))
+      ->set('track.mailto', $piwik_config->get('track.mailto'))
+      ->set('track.messages', $piwik_config->get('track.messages'))
+      ->set('track.site_search', $piwik_config->get('track.site_search'))
+      ->set('translation_set', $piwik_config->get('translation_set'))
+      ->set('privacy.donottrack', $piwik_config->get('privacy.donottrack'))
+      ->set('cache', $piwik_config->get('cache'))
+      ->set('visibility.request_path_mode', $piwik_config->get('visibility.request_path_mode'))
+      ->set('visibility.request_path_pages', $piwik_config->get('visibility.request_path_pages'))
+      ->set('visibility.user_account_mode', $piwik_config->get('visibility.user_account_mode'))
+      ->set('visibility.user_role_mode', $piwik_config->get('visibility.user_role_mode'))
+      ->set('visibility.user_role_roles', $piwik_config->get('visibility.user_role_roles'))
+      ->save();
+    $messages[] = t('Copied settings from piwik to matomo module.');
+
+    // Migrate piwik permissions to matomo.
+    $permissions = array(
+      'administer piwik' => 'administer matomo',
+      'opt-in or out of piwik tracking' => 'opt-in or out of matomo tracking',
+      'use PHP for piwik tracking visibility' => 'use php for matomo tracking visibility',
+      'add JS snippets for piwik' => 'add js snippets for matomo',
+    );
+    foreach (user_roles(FALSE) as $rid => $name) {
+      $role = \Drupal\user\Entity\Role::load($rid);
+      foreach ($permissions as $permission_old_key => $permission_new_key) {
+        if ($role->hasPermission($permission_old_key)) {
+          $role->grantPermission($permission_new_key);
+          $messages[] = t('Role "@rid" has permission "@permission_old_key" and "@permission_new_key" granted.', array('@rid' => $rid, '@permission_old_key' => $permission_old_key, '@permission_new_key' => $permission_new_key));
+        }
+      }
+      $role->save();
+    }
+    $messages[] = t('Copied piwik permissions to matomo module.');
+
+    // Uninstall piwik module.
+    $module_uninstalled = \Drupal::service('module_installer')->uninstall(array('piwik'), FALSE);
+    if ($module_uninstalled) {
+      $messages[] = t('Successfully uninstalled piwik module. Please remove piwik from your system.');
+      drupal_set_message('Piwik is now Matomo! Matomo has been installed. Please remove Piwik module from your system.', 'warning');
+    }
+    else {
+      $messages[] = t('FAILED to uninstall piwik module.');
+
+      // Unconfigure piwik to remove piwik tracking code; if piwik module may failed to disable.
+      $piwik_config->set('site_id', '');
+      $messages[] = t('Unconfigured site_id in piwik module to disable double tracking.');
+    }
+  }
+
+  return empty($messages) ? t('FAILED to migrate piwik to matomo module. Please uninstall piwik module and install matomo module manually!') : implode(' ', $messages);
+}

+ 3 - 3
sites/all/modules/contrib/admin/piwik/tests/modules/piwik_test/piwik_test.info.yml

@@ -4,8 +4,8 @@ description: 'Support module for Piwik testing.'
 package: Testing
 # core: 8.x
 
-# Information added by Drupal.org packaging script on 2017-11-11
-version: '8.x-1.2'
+# Information added by Drupal.org packaging script on 2018-06-08
+version: '8.x-1.4'
 core: '8.x'
 project: 'piwik'
-datestamp: 1510404815
+datestamp: 1528483684

+ 3 - 3
sites/all/modules/contrib/dev/config_filter/config_filter.info.yml

@@ -4,8 +4,8 @@ description: Config Filter allows other modules to interact with a ConfigStorage
 # core: 8.x
 package: Config
 
-# Information added by Drupal.org packaging script on 2017-11-27
-version: '8.x-1.1'
+# Information added by Drupal.org packaging script on 2018-04-05
+version: '8.x-1.2'
 core: '8.x'
 project: 'config_filter'
-datestamp: 1511779987
+datestamp: 1522943894

+ 5 - 10
sites/all/modules/contrib/dev/config_filter/src/Config/FilteredStorage.php

@@ -2,6 +2,7 @@
 
 namespace Drupal\config_filter\Config;
 
+use Drupal\config_filter\Exception\InvalidStorageFilterException;
 use Drupal\Core\Config\StorageInterface;
 
 /**
@@ -43,6 +44,9 @@ class FilteredStorage implements FilteredStorageInterface {
 
     // Set the storage to all the filters.
     foreach ($this->filters as $filter) {
+      if (!$filter instanceof StorageFilterInterface) {
+        throw new InvalidStorageFilterException();
+      }
       $filter->setSourceStorage(new ReadOnlyStorage($storage));
       $filter->setFilteredStorage($this);
     }
@@ -209,16 +213,7 @@ class FilteredStorage implements FilteredStorageInterface {
       }
     }
 
-    $storage = $this->storage->createCollection($collection);
-    $filtered = new static($storage, $filters);
-
-    // Set the storage to all the filters.
-    foreach ($filters as $filter) {
-      $filter->setSourceStorage(new ReadOnlyStorage($storage));
-      $filter->setFilteredStorage($filtered);
-    }
-
-    return $filtered;
+    return new static($this->storage->createCollection($collection), $filters);
   }
 
   /**

+ 46 - 0
sites/all/modules/contrib/dev/config_filter/src/Config/GhostStorage.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace Drupal\config_filter\Config;
+
+use Drupal\Core\Config\StorageInterface;
+
+/**
+ * Class GhostStorage.
+ *
+ * A GhostStorage acts like the normal Storage it wraps. All reading operations
+ * return the values of the decorated storage but write operations are silently
+ * ignored and the ghost pretends that the operation was successful.
+ *
+ * @package Drupal\config_filter\Config
+ */
+class GhostStorage extends ReadOnlyStorage implements StorageInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function write($name, array $data) {
+    return TRUE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function delete($name) {
+    return TRUE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function rename($name, $new_name) {
+    return TRUE;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function deleteAll($prefix = '') {
+    return TRUE;
+  }
+
+}

+ 151 - 0
sites/all/modules/contrib/dev/config_filter/src/Config/TransparentStorageFilterTrait.php

@@ -0,0 +1,151 @@
+<?php
+
+namespace Drupal\config_filter\Config;
+
+use Drupal\Core\Config\StorageInterface;
+
+/**
+ * Trait TransparentStorageFilterTrait.
+ *
+ * Use this trait or ConfigFilterBase to implement a config storage filter.
+ * Filters do not need to be plugins but it is probably the most convenient way
+ * to create them. Use this trait to ensure compatibility in case the interface
+ * ever needs to change for some reason.
+ *
+ * @package Drupal\config_filter\Config
+ */
+trait TransparentStorageFilterTrait {
+
+  /**
+   * The read-only source storage on which the filter operations are performed.
+   *
+   * @var \Drupal\Core\Config\StorageInterface
+   */
+  protected $source;
+
+  /**
+   * The wrapped storage which calls the filter.
+   *
+   * @var \Drupal\Core\Config\StorageInterface
+   */
+  protected $filtered;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setSourceStorage(StorageInterface $storage) {
+    $this->source = $storage;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setFilteredStorage(StorageInterface $storage) {
+    $this->filtered = $storage;
+  }
+
+  /**
+   * Get the read-only source Storage.
+   *
+   * @return \Drupal\Core\Config\StorageInterface
+   *   The source storage.
+   */
+  protected function getSourceStorage() {
+    return $this->source;
+  }
+
+  /**
+   * Get the decorator storage which applies the filters.
+   *
+   * @return \Drupal\Core\Config\StorageInterface
+   *   The filtered decorator storage.
+   */
+  protected function getFilteredStorage() {
+    return $this->filtered;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterRead($name, $data) {
+    return $data;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterWrite($name, array $data) {
+    return $data;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterWriteEmptyIsDelete($name) {
+    return NULL;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterExists($name, $exists) {
+    return $exists;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterDelete($name, $delete) {
+    return $delete;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterReadMultiple(array $names, array $data) {
+    return $data;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterRename($name, $new_name, $rename) {
+    return $rename;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterListAll($prefix, array $data) {
+    return $data;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterDeleteAll($prefix, $delete) {
+    return $delete;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterCreateCollection($collection) {
+    return clone $this;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterGetAllCollectionNames(array $collections) {
+    return $collections;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function filterGetCollectionName($collection) {
+    return $collection;
+  }
+
+}

+ 19 - 0
sites/all/modules/contrib/dev/config_filter/src/Exception/InvalidStorageFilterException.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace Drupal\config_filter\Exception;
+
+use Drupal\config_filter\Config\StorageFilterInterface;
+
+/**
+ * Thrown when a StorageFilterInterface is expected but not present.
+ */
+class InvalidStorageFilterException extends \InvalidArgumentException {
+
+  /**
+   * InvalidStorageFilterException constructor.
+   */
+  public function __construct() {
+    parent::__construct("An argument does not implement " . StorageFilterInterface::class);
+  }
+
+}

+ 2 - 132
sites/all/modules/contrib/dev/config_filter/src/Plugin/ConfigFilterBase.php

@@ -3,143 +3,13 @@
 namespace Drupal\config_filter\Plugin;
 
 use Drupal\Component\Plugin\PluginBase;
-use Drupal\Core\Config\StorageInterface;
+use Drupal\config_filter\Config\TransparentStorageFilterTrait;
 
 /**
  * Base class for Config filter plugin plugins.
  */
 abstract class ConfigFilterBase extends PluginBase implements ConfigFilterInterface {
 
-  /**
-   * The read-only source storage on which the filter operations are performed.
-   *
-   * @var \Drupal\Core\Config\StorageInterface
-   */
-  protected $source;
-
-  /**
-   * The wrapped storage which calls the filter.
-   *
-   * @var \Drupal\Core\Config\StorageInterface
-   */
-  protected $filtered;
-
-  /**
-   * {@inheritdoc}
-   */
-  public function setSourceStorage(StorageInterface $storage) {
-    $this->source = $storage;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function setFilteredStorage(StorageInterface $storage) {
-    $this->filtered = $storage;
-  }
-
-  /**
-   * Get the read-only source Storage.
-   *
-   * @return \Drupal\Core\Config\StorageInterface
-   *   The source storage.
-   */
-  protected function getSourceStorage() {
-    return $this->source;
-  }
-
-  /**
-   * Get the decorator storage which applies the filters.
-   *
-   * @return \Drupal\Core\Config\StorageInterface
-   *   The filtered decorator storage.
-   */
-  protected function getFilteredStorage() {
-    return $this->filtered;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterRead($name, $data) {
-    return $data;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterWrite($name, array $data) {
-    return $data;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterWriteEmptyIsDelete($name) {
-    return NULL;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterExists($name, $exists) {
-    return $exists;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterDelete($name, $delete) {
-    return $delete;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterReadMultiple(array $names, array $data) {
-    return $data;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterRename($name, $new_name, $rename) {
-    return $rename;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterListAll($prefix, array $data) {
-    return $data;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterDeleteAll($prefix, $delete) {
-    return $delete;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterCreateCollection($collection) {
-    return clone $this;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterGetAllCollectionNames(array $collections) {
-    return $collections;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function filterGetCollectionName($collection) {
-    return $collection;
-  }
+  use TransparentStorageFilterTrait;
 
 }

+ 100 - 5
sites/all/modules/contrib/dev/config_filter/src/Tests/FilteredStorageTest.php

@@ -3,8 +3,10 @@
 namespace Drupal\config_filter\Tests;
 
 use Drupal\config_filter\Config\FilteredStorage;
+use Drupal\config_filter\Config\FilteredStorageInterface;
 use Drupal\config_filter\Config\ReadOnlyStorage;
 use Drupal\config_filter\Config\StorageFilterInterface;
+use Drupal\config_filter\Exception\InvalidStorageFilterException;
 use Drupal\Core\Config\CachedStorage;
 use Drupal\Core\Config\StorageInterface;
 use Drupal\KernelTests\Core\Config\Storage\CachedStorageTest;
@@ -31,12 +33,8 @@ class FilteredStorageTest extends CachedStorageTest {
    * Test that the storage is set on the filters.
    */
   public function testSettingStorages() {
-    $filterReflection = new \ReflectionClass(FilteredStorage::class);
-    $filtersProperty = $filterReflection->getProperty('filters');
-    $filtersProperty->setAccessible(TRUE);
-
     /** @var \Drupal\config_filter\Tests\TransparentFilter[] $filters */
-    $filters = $filtersProperty->getValue($this->storage);
+    $filters = static::getProtectedFilters($this->storage);
     foreach ($filters as $filter) {
       // Test that the source storage is a ReadonlyStorage and wraps the cached
       // storage from the inherited test.
@@ -53,6 +51,69 @@ class FilteredStorageTest extends CachedStorageTest {
     }
   }
 
+  /**
+   * Test that creating collections keeps filters set to the correct storages.
+   */
+  public function testCollectionStorages() {
+    $collection = $this->randomString();
+
+    // The storage is in its default state.
+    $this->assertEquals(StorageInterface::DEFAULT_COLLECTION, $this->storage->getCollectionName());
+
+    /** @var \Drupal\config_filter\Tests\TransparentFilter[] $filters */
+    $filters = static::getProtectedFilters($this->storage);
+    foreach ($filters as $filter) {
+      // Test that the filters have the correct storage set.
+      $this->assertEquals($this->storage, $filter->getPrivateFilteredStorage());
+      $this->assertEquals(StorageInterface::DEFAULT_COLLECTION, $filter->getPrivateSourceStorage()->getCollectionName());
+    }
+
+    // Create a collection which creates a clone of the storage and filters.
+    $collectionStorage = $this->storage->createCollection($collection);
+    $this->assertInstanceOf(FilteredStorageInterface::class, $collectionStorage);
+
+    /** @var \Drupal\config_filter\Tests\TransparentFilter[] $collectionFilters */
+    $collectionFilters = static::getProtectedFilters($collectionStorage);
+    foreach ($collectionFilters as $filter) {
+      // Test that the cloned filter has the correct storage set.
+      $this->assertEquals($collectionStorage, $filter->getPrivateFilteredStorage());
+      $this->assertEquals($collection, $filter->getPrivateSourceStorage()->getCollectionName());
+    }
+
+    /** @var \Drupal\config_filter\Tests\TransparentFilter[] $filters */
+    $filters = static::getProtectedFilters($this->storage);
+    foreach ($filters as $filter) {
+      // Test that the filters on the original storage are still correctly set.
+      $this->assertEquals($this->storage, $filter->getPrivateFilteredStorage());
+      $this->assertEquals(StorageInterface::DEFAULT_COLLECTION, $filter->getPrivateSourceStorage()->getCollectionName());
+    }
+  }
+
+  /**
+   * Test setting up filters in FilteredStorage::createCollection().
+   */
+  public function testCreateCollectionFilter() {
+    $collection = $this->randomString();
+    $filteredCollection = $this->randomString();
+
+    $filter = $this->prophesizeFilter();
+    $filterC = $this->prophesizeFilter();
+    $filterC->filterGetCollectionName($collection)->willReturn($filteredCollection);
+    $filter->filterCreateCollection($collection)->willReturn($filterC->reveal());
+
+    $source = $this->prophesize(StorageInterface::class);
+    $sourceC = $this->prophesize(StorageInterface::class);
+    $sourceC->getCollectionName()->willReturn($collection);
+    $source->createCollection($collection)->willReturn($sourceC->reveal());
+
+    $storage = new FilteredStorage($source->reveal(), [$filter->reveal()]);
+    // Creating a collection makes sure the filters were correctly set up.
+    $storageC = $storage->createCollection($collection);
+
+    // Test that the collection is filtered in the collection storage.
+    $this->assertEquals($filteredCollection, $storageC->getCollectionName());
+  }
+
   /**
    * Test the read methods invokes the correct filter methods.
    *
@@ -278,6 +339,23 @@ class FilteredStorageTest extends CachedStorageTest {
     ];
   }
 
+  /**
+   * Test that an exception is thrown when invalid arguments are passed.
+   */
+  public function testInvalidStorageFilterArgument() {
+    $source = $this->prophesize(StorageInterface::class);
+
+    // We would do this with $this->expectException but alas drupal is stuck on
+    // phpunit 4 and we try not to add deprecated code.
+    try {
+      new FilteredStorage($source->reveal(), [new \stdClass()]);
+      $this->fail('An exception should have been thrown.');
+    }
+    catch (InvalidStorageFilterException $exception) {
+      $this->assertTrue(TRUE);
+    }
+  }
+
   /**
    * Prophesize a StorageFilter.
    */
@@ -288,6 +366,23 @@ class FilteredStorageTest extends CachedStorageTest {
     return $filter;
   }
 
+  /**
+   * Get the filters from a FilteredStorageInterface.
+   *
+   * @param \Drupal\Core\Config\StorageInterface $storage
+   *   The storage with the protected filters property.
+   *
+   * @return \Drupal\config_filter\Config\StorageFilterInterface[]
+   *   The array of filters.
+   */
+  protected static function getProtectedFilters(StorageInterface $storage) {
+    $filterReflection = new \ReflectionClass(FilteredStorage::class);
+    $filtersProperty = $filterReflection->getProperty('filters');
+    $filtersProperty->setAccessible(TRUE);
+
+    return $filtersProperty->getValue($storage);
+  }
+
   /**
    * Create a random array.
    */

+ 44 - 0
sites/all/modules/contrib/dev/config_filter/src/Tests/GhostStorageTest.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace Drupal\config_filter\Tests;
+
+use Drupal\config_filter\Config\GhostStorage;
+use Drupal\Core\Config\StorageInterface;
+use Prophecy\Argument;
+
+/**
+ * Tests GhostStorage operations.
+ *
+ * @group config_filter
+ */
+class GhostStorageTest extends ReadonlyStorageTest {
+
+  /**
+   * Override the storage decorating.
+   *
+   * @param \Drupal\Core\Config\StorageInterface $source
+   *   The storage to decorate.
+   *
+   * @return \Drupal\config_filter\Config\GhostStorage
+   *   The storage to test.
+   */
+  protected function getStorage(StorageInterface $source) {
+    return new GhostStorage($source);
+  }
+
+  /**
+   * Override the dataprovider for write methods.
+   *
+   * @dataProvider writeMethodsProvider
+   */
+  public function testWriteOperations($method, $arguments) {
+    $source = $this->prophesize(StorageInterface::class);
+    $source->$method(Argument::any())->shouldNotBeCalled();
+
+    $storage = $this->getStorage($source->reveal());
+
+    $actual = call_user_func_array([$storage, $method], $arguments);
+    $this->assertTrue($actual);
+  }
+
+}

+ 4 - 4
sites/all/modules/contrib/dev/config_filter/tests/modules/config_filter_split_test/config_filter_split_test.info.yml

@@ -3,10 +3,10 @@ type: module
 # core: 8.x
 package: Testing
 dependencies:
-  - drupal:config_filter
+  - config_filter:config_filter
 
-# Information added by Drupal.org packaging script on 2017-11-27
-version: '8.x-1.1'
+# Information added by Drupal.org packaging script on 2018-04-05
+version: '8.x-1.2'
 core: '8.x'
 project: 'config_filter'
-datestamp: 1511779987
+datestamp: 1522943894

+ 4 - 4
sites/all/modules/contrib/dev/config_filter/tests/modules/config_filter_test/config_filter_test.info.yml

@@ -3,10 +3,10 @@ type: module
 # core: 8.x
 package: Testing
 dependencies:
-  - drupal:config_filter
+  - config_filter:config_filter
 
-# Information added by Drupal.org packaging script on 2017-11-27
-version: '8.x-1.1'
+# Information added by Drupal.org packaging script on 2018-04-05
+version: '8.x-1.2'
 core: '8.x'
 project: 'config_filter'
-datestamp: 1511779987
+datestamp: 1522943894

+ 1 - 0
sites/all/modules/contrib/fields/color_field/.gitignore

@@ -0,0 +1 @@
+.idea/

+ 123 - 0
sites/all/modules/contrib/fields/color_field/README.md

@@ -0,0 +1,123 @@
+# Color Field - Drupal 8
+
+## ABOUT & FEATURES
+
+### Formatters
+
+  Plain text HEX code (#FFFFFF)
+  Css Declaration (color/background-color)
+
+### Widgets
+
+- *Color Boxes*: Provides a row of colored boxes to select from a configured
+list of colors. If enabled, opacity is a number field.
+- *Color Default*: Textbox to put in a hex value. If enabled, opacity is a
+number field.
+- *Color Grid*: Uses [jQuery Simple Color](https://github.com/recurser/jquery-simple-color)
+to provide a pop up grid of color options. If enabled, opacity is a number
+field.
+- *Color HTML5*: Uses the color HTML5 input type to render in a browser/system
+native manner. If enabled, opacity is a number field.
+- *Color Spectrum*: Uses [Spectrum](https://github.com/bgrins/spectrum) to
+provide a user friendly color palette to choose the correct color. This has an
+integrated slider for opacity (if opacity is enabled).
+
+## ROAD MAP
+
+1) Make this module a base that could be used by any color picker.
+2) include http://www.eyecon.ro/colorpicker/
+3) include http://www.dematte.at/colorPicker/
+4) include http://acko.net/blog/farbtastic-jquery-color-picker-plug-in/
+
+## INSTALLATION
+
+Install as you would normally install a contributed Drupal module. See also
+[Core Documentation](https://www.drupal.org/docs/8/extending-drupal-8/installing-modules)
+
+### DEPENDENCIES
+There are JavaScript libraries required for a couple of the field widgets. If
+you are not actively using those field widgets, you can skip their installation
+if desired.
+
+#### COMPOSER
+If you installed color field via [Composer](https://getcomposer.org), the
+packages will have been suggested but not automatically installed. If you have
+Asset Packagist already configured - as most Commerce users will - skip to just
+requiring the desired package(s).
+```bash
+composer require bower-asset/jquery-simple-color bower-asset/spectrum
+``` 
+
+Otherwise, to install them you will need to add
+[Asset Packagist](https://asset-packagist.org) to your composer.json and
+do some and make a couple other changes to your `composer.json`. Specifically,
+in the `extra` key add/adjust current values:
+```json
+"installer-types": [
+  "npm-asset",
+  "bower-asset"
+],
+"installer-paths": {
+  "web/core": [
+    "type:drupal-core"
+  ],
+  "web/libraries/{$name}": [
+    "type:bower-asset",
+    "type:npm-asset",
+    "type:drupal-library"
+  ],
+  "web/modules/contrib/{$name}": [
+    "type:drupal-module"
+  ],
+  "web/profiles/contrib/{$name}": [
+    "type:drupal-profile"
+  ],
+  "web/themes/contrib/{$name}": [
+    "type:drupal-theme"
+  ],
+  "drush/contrib/{$name}": [
+    "type:drupal-drush"
+  ]
+},
+```
+
+then run
+```bash
+composer require oomphinc/composer-installers-extender
+composer require bower-asset/jquery-simple-color bower-asset/spectrum
+```
+
+#### MANUAL
+If you are not using Composer, you will need to manually install them.
+
+- [jQuery Simple Color](https://github.com/recurser/jquery-simple-color)
+copy to `/libraries/jquery-simple-color` so that `jquery.simple-color.min.js`
+is in that folder. Required for the Color Grid widget.
+- [Spectrum](https://github.com/bgrins/spectrum) copy to `/libraries/spectrum`
+so that `spectrum.js` exists in that folder. Required for the Spectrum widget.
+
+## USAGE
+
+Field
+1. Add the field to an node/entity
+2. Select the 'Color Field' field type
+3. Select the 'Color' widget you want
+
+## CREDIT
+
+Original Creator: [targoo](https://www.drupal.org/u/targoo).
+
+Maintainers:
+  - [targoo](https://www.drupal.org/u/targoo)
+  - [Nick Wilde](https://www.drupal.org/u/nickwilde)
+
+Original development sponsored by Marique Calcus and written by Calcus David.
+For professional support and development services contact targoo@gmail.com.
+
+## More info
+
+http://www.w3.org/TR/css3-color/#color
+https://github.com/mikeemoo/ColorJizz-PHP
+http://www.colorhexa.com/ff0000
+https://github.com/PrimalPHP/Color/blob/master/lib/Primal/Color/Parser.php
+https://github.com/matthewbaggett/php-color/blob/master/Color.php

+ 0 - 66
sites/all/modules/contrib/fields/color_field/README.txt

@@ -1,66 +0,0 @@
------------------------------------------------------------------------------
-CURRENT FEATURES
------------------------------------------------------------------------------
-Formatter
-
-  Plain text HEX code (#FFFFFF)
-  Css Declaration (color/background-color)
-
-Widget
-
-  Plain Text
-  Pre-selected Color Boxes
-  Simple Query Color 
-  (http://recursive-design.com/projects/jquery-simple-color/)
-
------------------------------------------------------------------------------
-ROAD MAP
------------------------------------------------------------------------------
-1) Make this module a base that could be used by any color picker.
-2) include http://www.eyecon.ro/colorpicker/
-3) include http://www.dematte.at/colorPicker/
-4) include http://acko.net/blog/farbtastic-jquery-color-picker-plug-in/
------------------------------------------------------------------------------
-REQUIREMENTS
------------------------------------------------------------------------------
-No specific requirement
-
------------------------------------------------------------------------------
-INSTALLATION
------------------------------------------------------------------------------
-To use this module, simply enable it.
-
------------------------------------------------------------------------------
-INSTALLATION - jQuery simple color
------------------------------------------------------------------------------
-If you want to use the jquery simple color plugin you need to download it and 
-place it in your libraries folder (this will usually be "sites/all/libraries/").
-You can download the plugin by using the following links or by Drush.
-
-  http://recursive-design.com/projects/jquery-simple-color/
-  https://github.com/recurser/jquery-simple-color
-
------------------------------------------------------------------------------
-USAGE
------------------------------------------------------------------------------
-Field
-1. Add the field to an node/entity
-2. Select the 'Color Field' field type
-3. Select the 'Color' widget you want
-
------------------------------------------------------------------------------
-CREDIT
------------------------------------------------------------------------------
-Maintainer and developer: targoo
-
-Development sponsored by Marique Calcus and written by Calcus David. 
-For professional support and development services contact targoo@gmail.com.
-
------------------------------------------------------------------------------
-More info
------------------------------------------------------------------------------
-http://www.w3.org/TR/css3-color/#color
-https://github.com/mikeemoo/ColorJizz-PHP
-http://www.colorhexa.com/ff0000
-https://github.com/PrimalPHP/Color/blob/master/lib/Primal/Color/Parser.php
-https://github.com/matthewbaggett/php-color/blob/master/Color.php

+ 0 - 26
sites/all/modules/contrib/fields/color_field/color_field-2854199-7.patch

@@ -1,26 +0,0 @@
-From ef19dd13dceeb972e9b0fe1920d846901a076dd4 Mon Sep 17 00:00:00 2001
-From: kristiaanvandeneynde <kristiaanvandeneynde@1345130.no-reply.drupal.org>
-Date: Thu, 26 Oct 2017 14:24:28 +0200
-Subject: [PATCH] Issue #2854199 by pclaitte, kristiaanvandeneynde: Color Boxes
- Widget default values doesn't works
-
----
- src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php b/src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php
-index 8268704..ad05958 100644
---- a/src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php
-+++ b/src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php
-@@ -96,7 +96,7 @@ class ColorFieldWidgetBox extends WidgetBase {
-     $default_colors = $this->getSetting('default_colors');
-     preg_match_all("/#[0-9a-fA-F]{6}/", $default_colors, $default_colors, PREG_SET_ORDER);
-     foreach ($default_colors as $color) {
--      $settings['palette'][] = $color[0];
-+      $settings['default_colors'][] = $color[0];
-     }
-     $element['#attached']['drupalSettings']['color_field']['color_field_widget_box']['settings'] = $settings;
- 
--- 
-2.4.9 (Apple Git-60)
-

+ 6 - 4
sites/all/modules/contrib/fields/color_field/color_field.info.yml

@@ -4,10 +4,12 @@ description: 'Provides a color field type to store the color value and opacity'
 # core: 8.x
 package: Field types
 dependencies:
-  - field
+  - drupal:field
+test_dependencies:
+  - token:token
 
-# Information added by Drupal.org packaging script on 2017-04-13
-version: '8.x-2.0-rc1+11-dev'
+# Information added by Drupal.org packaging script on 2018-09-05
+version: '8.x-2.0'
 core: '8.x'
 project: 'color_field'
-datestamp: 1492097733
+datestamp: 1536168814

+ 53 - 0
sites/all/modules/contrib/fields/color_field/color_field.install

@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * @file
+ * Install, update and uninstall functions for the Color Fields module.
+ */
+
+/**
+ * If the JavaScript Libraries don't exist, show a warning on the status page.
+ */
+function color_field_requirements($phase) {
+  $requirements = [];
+  if ($phase === 'runtime') {
+    if (!file_exists(DRUPAL_ROOT . '/libraries/jquery-simple-color/jquery.simple-color.js')) {
+      $requirements['color_field_simple'] = [
+        'title' => t('Color Field library: jQuery Simple Color'),
+        'value' => t('Missing'),
+        'description' => t('Download the <a href=":url">jQuery Simple Color library</a> and copy it to :library', [
+          ':url' => 'https://github.com/recurser/jquery-simple-color',
+          ':library' => DRUPAL_ROOT . '/libraries/jquery-simple-color/',
+        ]),
+        'severity' => REQUIREMENT_WARNING,
+      ];
+    }
+    else {
+      $requirements['color_field_simple'] = [
+        'title' => t('Color Field library: jQuery Simple Color'),
+        'value' => t('Installed'),
+        'severity' => REQUIREMENT_OK,
+      ];
+    }
+    if (!file_exists(DRUPAL_ROOT . '/libraries/spectrum/spectrum.js')) {
+      $requirements['color_field_spectrum'] = [
+        'title' => t('Color Field library: Spectrum'),
+        'value' => t('Missing'),
+        'description' => t('Download the <a href=":url">Spectrum library</a> and copy it to :library', [
+          ':url' => 'https://github.com/bgrins/spectrum',
+          ':library' => DRUPAL_ROOT . '/libraries/spectrum/',
+        ]),
+        'severity' => REQUIREMENT_WARNING,
+      ];
+    }
+    else {
+      $requirements['color_field_spectrum'] = [
+        'title' => t('Color Field library: Spectrum'),
+        'value' => t('Installed'),
+        'severity' => REQUIREMENT_OK,
+      ];
+    }
+  }
+
+  return $requirements;
+}

File diff suppressed because it is too large
+ 1 - 0
sites/all/modules/contrib/fields/color_field/color_field.module


+ 37 - 0
sites/all/modules/contrib/fields/color_field/color_field.post_update.php

@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * @file
+ * Contains post update functionality for the color field module.
+ */
+
+use Drupal\Core\Entity\Entity\EntityFormDisplay;
+
+/**
+ * Update spectrum widget configuration to allow multiple palettes.
+ */
+function color_field_post_update_spectrum_palette() {
+  /** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $entity_form_display */
+  foreach (EntityFormDisplay::loadMultiple() as $entity_form_display) {
+    $changed = FALSE;
+    foreach ($entity_form_display->getComponents() as $name => $options) {
+      if (isset($options['type']) && $options['type'] === 'color_field_widget_spectrum') {
+        if ($options['settings']['palette']) {
+          $palette = explode(',', $options['settings']['palette']);
+          foreach ($palette as &$color) {
+            $color = '"' . trim($color) . '"';
+          }
+          $options['settings']['palette'] = '[' . implode(',', $palette) . ']';
+          $entity_form_display->setComponent($name, $options);
+          $changed = TRUE;
+        }
+      }
+    }
+
+    if ($changed) {
+      $entity_form_display->save();
+    }
+  }
+
+  return t('The new palette format for spectrum color field widgets has been applied.');
+}

+ 36 - 0
sites/all/modules/contrib/fields/color_field/composer.json

@@ -0,0 +1,36 @@
+{
+  "name": "drupal/color_field",
+  "require": {
+    "drupal/core": "*"
+  },
+  "require-dev": {
+    "drupal/token": "~1.3"
+  },
+  "suggest": {
+    "bower-asset/jquery-simple-color": "^v1.2.2: Provides JavaScript library necessary for the Color Grid widget",
+    "bower-asset/spectrum": "^1.8: Provides JavaScript library necessary for Spectrum widget."
+  },
+  "type": "drupal-module",
+  "notification-url": "https://packages.drupal.org/8/downloads",
+  "license": [
+    "GPL-2.0-or-later"
+  ],
+  "authors": [
+    {
+      "name": "targoo",
+      "homepage": "https://www.drupal.org/user/431910",
+      "role": "Maintainer"
+    },
+    {
+      "name": "Nick Wilde",
+      "homepage": "https://www.drupal.org/user/nickwilde",
+      "role": "Maintainer"
+    }
+  ],
+  "description": "Provides a color field type to store the color value and opacity",
+  "homepage": "https://www.drupal.org/project/color_field",
+  "support": {
+    "issues": "https://www.drupal.org/project/issues/color_field?version=8.x",
+    "source": "http://cgit.drupalcode.org/color_field"
+  }
+}

+ 24 - 0
sites/all/modules/contrib/fields/color_field/config/schema/color_field.schema.yml

@@ -1,5 +1,29 @@
 # Schema for the configuration files of the color field module.
 
+field.storage_settings.color_field_type:
+  type: mapping
+  mapping:
+    format:
+      type: label
+      label: 'Format'
+
+field.field_settings.color_field_type:
+  type: mapping
+  mapping:
+    opacity:
+      type: integer
+      label: 'Display opacity'
+
+field.value.color_field_type:
+  type: mapping
+  mapping:
+    color:
+      type: string
+      label: 'The hex color code'
+    opacity:
+      type: float
+      label: 'The opacity'
+
 field.formatter.settings.color_field_formatter_text:
   type: mapping
   label: 'Color text format settings'

+ 4 - 3
sites/all/modules/contrib/fields/color_field/css/color_field_formatter_swatch.css

@@ -1,7 +1,7 @@
-.color_field {}
-.color_field__swatch {}
-.color_field__swatch--square {
+.color_field__swatch {
+  display: inline-block;
 }
+
 .color_field__swatch--circle {
   -moz-border-radius: 50%;
   -webkit-border-radius: 50%;
@@ -12,4 +12,5 @@
   -webkit-transform: skew(20deg);
   -moz-transform: skew(20deg);
   -o-transform: skew(20deg);
+  transform: skew(20deg);
 }

+ 14 - 16
sites/all/modules/contrib/fields/color_field/css/color_field_widget_box.css

@@ -1,32 +1,30 @@
-.color_field_widget_box {
-}
-
 .color_field_widget_box__square {
-  border: 1px solid #ffffff;
-  cursor: pointer;
-  font-family: monospace;
-  font-size: 1.2em;
-  margin: 0 3px;
-  padding: 1px 8px;
+  border: 1px solid #000;
+  box-shadow: 0 0 1px #000;
+  height: 16px;
+  margin: 2px;
+  width: 16px;
 }
 
 .color_field_widget_box__square.active,
 .color_field_widget_box__square:hover {
-  padding: 9px 16px;
+  height: 32px;
+  width: 32px;
 }
 
 .color_field_widget_box__square--transparent {
   background-image: url("../images/transparent_box16.gif");
-  background-position: 0 3px;
   background-repeat: no-repeat;
-  margin: 0 3px;
-  padding: 2px 8px;
+  border: 1px solid #000;
+  box-shadow: 0 0 1px #000;
+  height: 16px;
+  margin: 2px;
+  width: 16px;
 }
 
 .color_field_widget_box__square--transparent.active,
 .color_field_widget_box__square--transparent:hover {
   background-image: url(../images/transparent_box32.gif);
-  background-position: 0 3px;
-  background-repeat: no-repeat;
-  padding: 10px 16px;
+  height: 32px;
+  width: 32px;
 }

+ 1 - 9
sites/all/modules/contrib/fields/color_field/css/color_field_widget_grid.css

@@ -1,12 +1,4 @@
-.simpleColorDisplay {
-  float: left;
-}
-
-.simpleColorContainer {
-  float: left;
-}
-
 .simpleColorChooser {
   z-index: 1;
+  max-width: 100%;
 }
-

+ 50 - 0
sites/all/modules/contrib/fields/color_field/drupalci.yml

@@ -0,0 +1,50 @@
+build:
+  assessment:
+    validate_codebase:
+      phplint: {  }
+      container_composer: {  }
+      container_command:
+        commands:
+          - cd ${SOURCE_DIR}
+          - sudo -u www-data composer config repositories.asset {"composer","https://asset-packagist.org"}
+          - sudo -u www-data composer config extra.installer-types.0 "npm-asset"
+          - sudo -u www-data composer config extra.installer-types.1 "bower-asset"
+          - sudo -u www-data composer config extra.installer-paths.libraries\/\{\$name\} "[type:bower-asset]"
+          - sudo -u www-data sed -i 's/"\[type:bower-asset\]"/\["type:bower-asset"\]/' composer.json
+          - sudo -u www-data composer require "oomphinc/composer-installers-extender:^1.1"
+          - sudo -u www-data composer require "bower-asset/spectrum:^1.8" "bower-asset/jquery-simple-color:^v1.2.2"
+          - dir libraries
+      csslint:
+        halt-on-fail: false
+      eslint:
+        halt-on-fail: false
+      phpcs:
+        sniff-all-files: false
+        halt-on-fail: false
+        coder-version: ^8.2@stable
+    testing:
+      run_tests.standard:
+        types: 'Simpletest,PHPUnit-Unit,PHPUnit-Kernel,PHPUnit-Functional'
+        testgroups: '--all'
+        color: true
+        die-on-fail: false
+        keep-results: true
+        keep-results-table: false
+        verbose: false
+        concurrency: 0
+        halt-on-fail: false
+        repeat: 1
+        suppress-deprecations: true
+      run_tests.js:
+        concurrency: 1
+        types: PHPUnit-FunctionalJavascript
+        testgroups: '--all'
+        color: true
+        die-on-fail: false
+        keep-results: true
+        keep-results-table: false
+        verbose: false
+        halt-on-fail: false
+        repeat: 1
+        suppress-deprecations: true
+      nightwatchjs: {  }

+ 6 - 4
sites/all/modules/contrib/fields/color_field/js/color_field_widget_box.jquery.js

@@ -20,17 +20,19 @@
 
             var $context = $(context);
 
-            var default_colors = settings.color_field.color_field_widget_box.settings.default_colors;
-
             $context.find('.color-field-widget-box-form').each(function (index, element) {
                 var $element = $(element);
                 var $input = $element.prev().find('input');
+                $input.hide();
+                var props = settings.color_field.color_field_widget_box.settings[$element.prop('id')];
+
                 $element.empty().addColorPicker({
                     currentColor: $input.val(),
-                    colors: default_colors,
+                    colors: props.palette,
                     blotchClass:'color_field_widget_box__square',
                     blotchTransparentClass:'color_field_widget_box__square--transparent',
-                    clickCallback: function(color) {
+                    addTransparentBlotch: !props.required,
+                    clickCallback: function (color) {
                         $input.val(color).trigger('change');
                     }
                 });

+ 25 - 28
sites/all/modules/contrib/fields/color_field/js/color_field_widget_box.js

@@ -1,16 +1,25 @@
 /**
- * Color Field jQuery
+ * @file
+ * Color Field jQuery.
  */
+
 (function ($) {
+
 jQuery.fn.addColorPicker = function (props) {
-  if (!props) { props = []; }
+
+  'use strict';
+
+  if (!props) {
+    props = [];
+  }
 
   props = jQuery.extend({
     currentColor:'',
-    blotchElemType: 'span',
+    blotchElemType: 'button',
     blotchClass:'colorBox',
     blotchTransparentClass:'transparentBox',
-    clickCallback: function(ignoredColor) {},
+    addTransparentBlotch: true,
+    clickCallback: function (ignoredColor) {},
     iterationCallback: null,
     fillString: '&nbsp;',
     fillStringX: '?',
@@ -23,20 +32,20 @@ jQuery.fn.addColorPicker = function (props) {
     ]
   }, props);
 
-  var count = props.colors.length;
-  for (var i = 0; i < count; ++i) {
-    var color = props.colors[i];
+  this.addBlotchElement = function(color, blotchClass) {
     var elem = jQuery('<' + props.blotchElemType + '/>')
-      .addClass(props.blotchClass)
+      .addClass(blotchClass)
       .attr('color',color)
+      .attr('title', color)
       .css('background-color',color);
-    // jq bug: chaining here fails if color is null b/c .css() returns (new String('transparent'))!
+    // Jq bug: chaining here fails if color is null b/c .css() returns (new String('transparent'))!
     if (props.currentColor == color) {
       elem.addClass('active');
     }
     if (props.clickCallback) {
-      elem.click(function() {
-        jQuery(this).parent().children('.' + props.blotchClass).removeClass('active');
+      elem.click(function (event) {
+        event.preventDefault();
+        jQuery(this).parent().children().removeClass('active');
         jQuery(this).addClass('active');
         props.clickCallback(jQuery(this).attr('color'));
       });
@@ -47,25 +56,13 @@ jQuery.fn.addColorPicker = function (props) {
     }
   }
 
-  var elem = jQuery('<' + props.blotchElemType + '/>')
-    .addClass(props.blotchTransparentClass)
-    .attr('color', '')
-    .css('background-color', '');
-
-  if (props.currentColor == '') {
-    elem.addClass('active');
+  for (var i = 0; i < props.colors.length; ++i) {
+    var color = props.colors[i];
+    this.addBlotchElement(color, props.blotchClass);
   }
 
-  if (props.clickCallback) {
-    elem.click(function() {
-      jQuery(this).parent().children('.' + props.blotchClass).removeClass('active');
-      jQuery(this).addClass('active');
-      props.clickCallback(jQuery(this).attr('color'));
-    });
-  }
-  this.append(elem);
-  if (props.iterationCallback) {
-    props.iterationCallback(this, elem, color, i);
+  if (props.addTransparentBlotch) {
+    this.addBlotchElement('', props.blotchTransparentClass);
   }
 
   return this;

+ 7 - 7
sites/all/modules/contrib/fields/color_field/js/color_field_widget_grid.jquery.js

@@ -2,6 +2,7 @@
  * @file
  * Javascript for Color Field.
  */
+
 (function ($, Drupal) {
 
   'use strict';
@@ -17,19 +18,18 @@
   Drupal.behaviors.color_field_jquery_simple_color = {
     attach: function (context, settings) {
       var $context = $(context);
-      var settings = settings.color_field.color_field_widget_grid;
 
       $context.find('.js-color-field-widget-grid__color').each(function (index, element) {
         var $element = $(element);
+        var widgetSettings = settings.color_field.color_field_widget_grid[$(this).attr('id')];
 
         $element.simpleColor({
-          cellWidth: settings.cell_width,
-          cellHeight: settings.cell_height,
-          cellMargin: settings.cell_margin,
-          boxWidth: settings.box_width,
-          boxHeight: settings.box_height
+          cellWidth: widgetSettings.cell_width,
+          cellHeight: widgetSettings.cell_height,
+          cellMargin: widgetSettings.cell_margin,
+          boxWidth: widgetSettings.box_width,
+          boxHeight: widgetSettings.box_height
         });
-
       });
 
     }

+ 20 - 5
sites/all/modules/contrib/fields/color_field/js/color_field_widget_spectrum.jquery.js

@@ -2,6 +2,7 @@
  * @file
  * Javascript for Color Field.
  */
+
 (function ($, Drupal) {
 
   'use strict';
@@ -19,12 +20,18 @@
 
       var $context = $(context);
 
-      var spectrum_settings = settings.color_field.color_field_widget_spectrum;
 
       $context.find('.js-color-field-widget-spectrum').each(function (index, element) {
         var $element = $(element);
         var $element_color = $element.find('.js-color-field-widget-spectrum__color');
         var $element_opacity = $element.find('.js-color-field-widget-spectrum__opacity');
+        var spectrum_settings = settings.color_field.color_field_widget_spectrum[$element.attr('id')];
+
+        // Hide the widget labels if the widgets are being shown.
+        if (!spectrum_settings.show_input) {
+          $('.js-color-field-widget-spectrum').find('label').hide();
+          $element_opacity.hide();
+        }
 
         $element_color.spectrum({
           showInitial: true,
@@ -32,14 +39,22 @@
           showInput: spectrum_settings.show_input,
           showAlpha: spectrum_settings.show_alpha,
           showPalette: spectrum_settings.show_palette,
-          showPaletteOnly: !!spectrum_settings.show_palette_only,
-          palette: [spectrum_settings.palette],
+          showPaletteOnly: spectrum_settings.show_palette_only,
+          palette: JSON.parse('[' + spectrum_settings.palette + ']'),
           showButtons: spectrum_settings.show_buttons,
           allowEmpty: spectrum_settings.allow_empty,
 
           change: function(tinycolor) {
-            $element_color.val(tinycolor.toHexString());
-            $element_opacity.val(tinycolor._roundA);
+            var hexColor = '';
+            var opacity = '';
+
+            if (tinycolor) {
+              hexColor = tinycolor.toHexString();
+              opacity = tinycolor._roundA;
+            }
+
+            $element_color.val(hexColor);
+            $element_opacity.val(opacity);
           }
 
         });

+ 16 - 38
sites/all/modules/contrib/fields/color_field/src/ColorBase.php

@@ -2,58 +2,36 @@
 
 namespace Drupal\color_field;
 
+/**
+ * Base color class to ease implementations.
+ */
 abstract class ColorBase implements ColorInterface {
 
   /**
-   * @var
-   */
-  protected $opacity;
-
-  /**
-   * Convert the color to Hex format
-   *
-   * @return ColorHex
-   *  The color in Hex format.
-   */
-  abstract function toHex();
-
-  /**
-   * Convert the color to RGB format
+   * The opacity of the color.
    *
-   * @return ColorRGB
-   *  The color in RGB format.
+   * @var float
    */
-  abstract function toRGB();
-
-  /**
-   * Convert the color to a string format
-   *
-   * @return String
-   *  The color in string format.
-   */
-  abstract function toString();
+  protected $opacity;
 
   /**
-   * Get the opacity
+   * Get the opacity.
    *
    * @return float
-   *  The opacity value between 0 and 1.
+   *   The opacity value between 0 and 1.
    */
   public function getOpacity() {
-    return $this->opacity;;
+    return $this->opacity;
   }
 
   /**
-   * Set the opacity
-   *
-   * @return float
-   *  The opacity value between 0 and 1.
+   * Set the opacity.
    */
   public function setOpacity($opacity) {
     $this->opacity = $opacity;
   }
 
-  static $patterns = array(
+  public static $patterns = [
     'cmyk'  => '/^(?:device-)?cmyk\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d+(?:\.\d+)?|\.\d+)\s*\)/',
     'rgba'  => '/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d+(?:\.\d+)?|\.\d+)\s*\)/',
     'rgb' => '/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/',
@@ -62,10 +40,10 @@ abstract class ColorBase implements ColorInterface {
     'hsva'  => '/^hsva\((\d{1,3}),\s*(\d{1,3})%,\s*(\d{1,3})%,\s*(\d+(?:\.\d+)?|\.\d+)\s*\)$/',
     'hsv' => '/^hsv\((\d{1,3}),\s*(\d{1,3})%,\s*(\d{1,3})%\)$/',
     'hex6'  => '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/',
-    'hex3'  => '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/'
-  );
+    'hex3'  => '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/',
+  ];
 
-  static $named_colors = array(
+  public static $namedColors = [
     "aliceblue" => "f0f8ff",
     "antiquewhite" => "faebd7",
     "aqua" => "00ffff",
@@ -208,7 +186,7 @@ abstract class ColorBase implements ColorInterface {
     "white" => "ffffff",
     "whitesmoke" => "f5f5f5",
     "yellow" => "ffff00",
-    "yellowgreen" => "9acd32"
-  );
+    "yellowgreen" => "9acd32",
+  ];
 
 }

+ 23 - 16
sites/all/modules/contrib/fields/color_field/src/ColorCMY.php

@@ -8,34 +8,37 @@ namespace Drupal\color_field;
 class ColorCMY extends ColorBase {
 
   /**
-   * The cyan
+   * The cyan.
+   *
    * @var float
    */
   private $cyan;
 
   /**
-   * The magenta
+   * The magenta.
+   *
    * @var float
    */
   private $magenta;
 
   /**
-   * The yellow
+   * The yellow.
+   *
    * @var float
    */
   private $yellow;
 
   /**
-   * Create a new CMYK color
+   * Create a new CMYK color.
    *
    * @param float $cyan
-   *  The cyan
+   *   The cyan.
    * @param float $magenta
-   *  The magenta
+   *   The magenta.
    * @param float $yellow
-   *  The yellow
+   *   The yellow.
    * @param float $opacity
-   *  The opacity
+   *   The opacity.
    */
   public function __construct($cyan, $magenta, $yellow, $opacity) {
     $this->cyan = $cyan;
@@ -45,42 +48,46 @@ class ColorCMY extends ColorBase {
   }
 
   /**
-   * Get the amount of Cyan
+   * Get the amount of Cyan.
    *
-   * @return int The amount of cyan
+   * @return int
+   *   The amount of cyan.
    */
   public function getCyan() {
     return $this->cyan;
   }
 
   /**
-   * Get the amount of Magenta
+   * Get the amount of Magenta.
    *
-   * @return int The amount of magenta
+   * @return int
+   *   The amount of magenta.
    */
   public function getMagenta() {
     return $this->magenta;
   }
 
   /**
-   * Get the amount of Yellow
+   * Get the amount of Yellow.
    *
-   * @return int The amount of yellow
+   * @return int
+   *   The amount of yellow.
    */
   public function getYellow() {
     return $this->yellow;
   }
 
   /**
-   * A string representation of this color in the current format
+   * A string representation of this color in the current format.
    *
    * @param bool $opacity
    *   Whether or not to display the opacity.
    *
    * @return string
-   *   The color in format: #RRGGBB
+   *   The color in format: #RRGGBB.
    */
   public function toString($opacity = TRUE) {
+    return $this->toHex()->toString($opacity);
   }
 
   /**

+ 33 - 20
sites/all/modules/contrib/fields/color_field/src/ColorCMYK.php

@@ -8,38 +8,46 @@ namespace Drupal\color_field;
 class ColorCMYK extends ColorBase {
 
   /**
-   * The cyan
+   * The cyan.
+   *
    * @var float
    */
   private $cyan;
 
   /**
-   * The magenta
+   * The magenta.
+   *
    * @var float
    */
   private $magenta;
 
   /**
-   * The yellow
+   * The yellow.
+   *
    * @var float
    */
   private $yellow;
 
   /**
-   * The key (black)
+   * The key (black).
+   *
    * @var float
    */
   private $key;
 
   /**
-   * Create a new CMYK color
+   * Create a new CMYK color.
    *
-   * @param float $cyan The cyan
-   * @param float $magenta The magenta
-   * @param float $yellow The yellow
-   * @param float $key The key (black)
+   * @param float $cyan
+   *   The cyan.
+   * @param float $magenta
+   *   The magenta.
+   * @param float $yellow
+   *   The yellow.
+   * @param float $key
+   *   The key (black).
    * @param float $opacity
-   *  The opacity
+   *   The opacity.
    */
   public function __construct($cyan, $magenta, $yellow, $key, $opacity) {
     $this->cyan = $cyan;
@@ -50,51 +58,56 @@ class ColorCMYK extends ColorBase {
   }
 
   /**
-   * Get the amount of Cyan
+   * Get the amount of Cyan.
    *
-   * @return int The amount of cyan
+   * @return int
+   *   The amount of cyan.
    */
   public function getCyan() {
     return $this->cyan;
   }
 
   /**
-   * Get the amount of Magenta
+   * Get the amount of Magenta.
    *
-   * @return int The amount of magenta
+   * @return int
+   *   The amount of magenta.
    */
   public function getMagenta() {
     return $this->magenta;
   }
 
   /**
-   * Get the amount of Yellow
+   * Get the amount of Yellow.
    *
-   * @return int The amount of yellow
+   * @return int
+   *   The amount of yellow.
    */
   public function getYellow() {
     return $this->yellow;
   }
 
   /**
-   * Get the key (black)
+   * Get the key (black).
    *
-   * @return int The amount of black
+   * @return int
+   *   The amount of black.
    */
   public function getKey() {
     return $this->key;
   }
 
   /**
-   * A string representation of this color in the current format
+   * A string representation of this color in the current format.
    *
    * @param bool $opacity
    *   Whether or not to display the opacity.
    *
    * @return string
-   *   The color in format: #RRGGBB
+   *   The color in format: #RRGGBB.
    */
   public function toString($opacity = TRUE) {
+    return $this->toHex()->toString($opacity);
   }
 
   /**

+ 5 - 5
sites/all/modules/contrib/fields/color_field/src/ColorHex.php

@@ -3,12 +3,13 @@
 namespace Drupal\color_field;
 
 /**
- * Hex represents the Hex color format
+ * Hex represents the Hex color format.
  */
 class ColorHex extends ColorBase {
 
   /**
    * The Hex triplet of the color.
+   *
    * @var int
    */
   private $color;
@@ -20,8 +21,7 @@ class ColorHex extends ColorBase {
    *   The string hex value (i.e. "FFFFFF").
    * @param string $opacity
    *   The opacity value.
-   * @return ColorHex
-   *   The ColorHex object.
+   *
    * @throws Exception
    */
   public function __construct($color, $opacity) {
@@ -46,13 +46,13 @@ class ColorHex extends ColorBase {
   }
 
   /**
-   * A string representation of this color in the current format
+   * A string representation of this color in the current format.
    *
    * @param bool $opacity
    *   Whether or not to display the opacity.
    *
    * @return string
-   *   The color in format: #RRGGBB
+   *   The color in format: #RRGGBB.
    */
   public function toString($opacity = TRUE) {
     $rgb = $this->toRGB();

+ 23 - 10
sites/all/modules/contrib/fields/color_field/src/ColorInterface.php

@@ -7,20 +7,33 @@ namespace Drupal\color_field;
  */
 interface ColorInterface {
 
+  /**
+   * Get the color as a string.
+   *
+   * @return string
+   *   The color as a string.
+   */
   public function toString();
 
+  /**
+   * Get the color as a hex instance.
+   *
+   * @return \Drupal\color_field\ColorHex
+   *   The color as a hex instance.
+   */
   public function toHex();
 
+  /**
+   * Get the color as a RGB instance.
+   *
+   * @return \Drupal\color_field\ColorRGB
+   *   The color as a RGB instance.
+   */
   public function toRGB();
 
-  //public function toHSV();
-
-  //public function toHSL();
-
-  //public function toRGB();
-
-  //public function toCMYK();
-
-  //public function toCSS();
-
+  // Public function toHSV();
+  // public function toHSL();
+  // public function toRGB();
+  // public function toCMYK();
+  // public function toCSS();
 }

+ 19 - 13
sites/all/modules/contrib/fields/color_field/src/ColorRGB.php

@@ -3,30 +3,33 @@
 namespace Drupal\color_field;
 
 /**
- * RGB represents the RGB color format
+ * RGB represents the RGB color format.
  */
 class ColorRGB extends ColorBase {
 
   /**
-   * The red value (0-255)
+   * The red value (0-255).
+   *
    * @var float
    */
   private $red;
 
   /**
-   * The green value (0-255)
+   * The green value (0-255).
+   *
    * @var float
    */
   private $green;
 
   /**
-   * The blue value (0-255)
+   * The blue value (0-255).
+   *
    * @var float
    */
   private $blue;
 
   /**
-   * Create a new RGB color
+   * Create a new RGB color.
    *
    * @param int $red
    *   The red (0-255)
@@ -35,7 +38,7 @@ class ColorRGB extends ColorBase {
    * @param int $blue
    *   The blue (0-255)
    * @param float $opacity
-   *   The opacity
+   *   The opacity.
    *
    * @throws Exception
    */
@@ -58,34 +61,37 @@ class ColorRGB extends ColorBase {
   }
 
   /**
-   * Get the red value (rounded)
+   * Get the red value (rounded).
    *
-   * @return int The red value
+   * @return int
+   *   The red value
    */
   public function getRed() {
     return (0.5 + $this->red) | 0;
   }
 
   /**
-   * Get the green value (rounded)
+   * Get the green value (rounded).
    *
-   * @return int The green value
+   * @return int
+   *   The green value
    */
   public function getGreen() {
     return (0.5 + $this->green) | 0;
   }
 
   /**
-   * Get the blue value (rounded)
+   * Get the blue value (rounded).
    *
-   * @return int The blue value
+   * @return int
+   *   The blue value
    */
   public function getBlue() {
     return (0.5 + $this->blue) | 0;
   }
 
   /**
-   * A string representation of this color in the current format
+   * A string representation of this color in the current format.
    *
    * @param bool $opacity
    *   Whether or not to display the opacity.

+ 102 - 45
sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterCss.php

@@ -1,17 +1,16 @@
 <?php
 
-/**
- * @file
- * Contains Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterCss.
- */
-
 namespace Drupal\color_field\Plugin\Field\FieldFormatter;
 
+use Drupal\color_field\ColorHex;
 use Drupal\color_field\Plugin\Field\FieldType\ColorFieldType;
-use Drupal\Core\Field\FormatterBase;
+use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\FormatterBase;
 use Drupal\Core\Form\FormStateInterface;
-use Drupal\color_field\ColorHex;
+use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
+use Drupal\Core\Utility\Token;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Plugin implementation of the color_field css declaration formatter.
@@ -25,66 +24,110 @@ use Drupal\color_field\ColorHex;
  *   }
  * )
  */
-class ColorFieldFormatterCss extends FormatterBase {
+class ColorFieldFormatterCss extends FormatterBase implements ContainerFactoryPluginInterface {
+  /**
+   * The token service.
+   *
+   * @var \Drupal\token\TokenInterface
+   */
+  protected $tokenService;
+
+  /**
+   * Constructs an ColorFieldFormatterCss object.
+   *
+   * @param string $plugin_id
+   *   The plugin_id for the formatter.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
+   *   The definition of the field to which the formatter is associated.
+   * @param array $settings
+   *   The formatter settings.
+   * @param string $label
+   *   The formatter label display setting.
+   * @param string $view_mode
+   *   The view mode.
+   * @param array $third_party_settings
+   *   Any third party settings.
+   * @param \Drupal\Core\Utility\Token $token_service
+   *   The token service.
+   */
+  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, Token $token_service) {
+    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
+    $this->tokenService = $token_service;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    // @see \Drupal\Core\Field\FormatterPluginManager::createInstance().
+    return new static(
+      $plugin_id,
+      $plugin_definition,
+      $configuration['field_definition'],
+      $configuration['settings'],
+      $configuration['label'],
+      $configuration['view_mode'],
+      $configuration['third_party_settings'],
+      $container->get('token')
+    );
+  }
 
   /**
    * {@inheritdoc}
    */
   public static function defaultSettings() {
-    return array(
+    return [
       'selector' => 'body',
       'property' => 'background-color',
       'important' => TRUE,
       'opacity' => TRUE,
-    ) + parent::defaultSettings();
+    ] + parent::defaultSettings();
   }
 
   /**
    * {@inheritdoc}
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
-    $opacity = $this->getFieldSetting('opacity');
-
     $elements = [];
 
-    $elements['selector'] = array(
-      '#title' => t('Selector'),
-      '#description' => t('A valid CSS selector such as <code>.links > li > a, #logo</code>.'),
+    $elements['selector'] = [
+      '#title' => $this->t('Selector'),
+      '#description' => $this->t('A valid CSS selector such as <code>.links > li > a, #logo</code>.'),
       '#type' => 'textarea',
       '#rows' => '1',
       '#default_value' => $this->getSetting('selector'),
       '#required' => TRUE,
       '#placeholder' => 'body > div > a',
-    );
-    //$element['token'] = array(
-    //  '#theme' => 'token_tree',
-    //  '#token_types' => array($instance['entity_type']),
-    //  '#dialog' => TRUE,
-    //);
-    $elements['property'] = array(
-      '#title' => t('Property'),
-      '#description' => t(''),
+    ];
+    $elements['token_help'] = [
+      '#theme' => 'token_tree_link',
+      '#token_types' => [$this->fieldDefinition->getTargetEntityTypeId()],
+    ];
+    $elements['property'] = [
+      '#title' => $this->t('Property'),
       '#type' => 'select',
       '#default_value' => $this->getSetting('property'),
       '#required' => TRUE,
-      '#options' => array(
-        'background-color' => t('Background color'),
-        'color' => t('Text color'),
-      ),
-    );
-    $elements['important'] = array(
-      '#title' => t('Important'),
-      '#description' => t('Whenever this declaration is more important than others.'),
+      '#options' => [
+        'background-color' => $this->t('Background color'),
+        'color' => $this->t('Text color'),
+      ],
+    ];
+    $elements['important'] = [
+      '#title' => $this->t('Important'),
+      '#description' => $this->t('Whenever this declaration is more important than others.'),
       '#type' => 'checkbox',
       '#default_value' => $this->getSetting('important'),
-    );
+    ];
 
-    if ($opacity) {
-      $elements['opacity'] = array(
+    if ($this->getFieldSetting('opacity')) {
+      $elements['opacity'] = [
         '#type' => 'checkbox',
-        '#title' => t('Display opacity'),
+        '#title' => $this->t('Display opacity'),
         '#default_value' => $this->getSetting('opacity'),
-      );
+      ];
     }
 
     return $elements;
@@ -99,12 +142,18 @@ class ColorFieldFormatterCss extends FormatterBase {
 
     $summary = [];
 
-    $summary[] = t('CSS selector : @css_selector', array('@css_selector' => $settings['selector']));
-    $summary[] = t('CSS property : @css_property', array('@css_property' => $settings['property']));
-    $summary[] = t('!important declaration : @important_declaration', array('@important_declaration' => (($settings['important']) ? t('Yes') : t('No'))));
+    $summary[] = $this->t('CSS selector : @css_selector', [
+      '@css_selector' => $settings['selector'],
+    ]);
+    $summary[] = $this->t('CSS property : @css_property', [
+      '@css_property' => $settings['property'],
+    ]);
+    $summary[] = $this->t('!important declaration : @important_declaration', [
+      '@important_declaration' => (($settings['important']) ? $this->t('Yes') : $this->t('No')),
+    ]);
 
     if ($opacity && $settings['opacity']) {
-      $summary[] = t('Display with opacity.');
+      $summary[] = $this->t('Display with opacity.');
     }
 
     return $summary;
@@ -118,10 +167,16 @@ class ColorFieldFormatterCss extends FormatterBase {
 
     $elements = [];
 
+    $entity = $items->getEntity();
+    $tokens = [
+      $entity->getEntityType()->id() => $entity,
+    ];
     foreach ($items as $delta => $item) {
-
       $value = $this->viewValue($item);
-      $selector = $settings['selector'];
+      $selector = $this->tokenService->replace(
+        $settings['selector'],
+        $tokens
+      );
       $important = ($settings['important']) ? ' !important' : '';
       $property = $settings['property'];
 
@@ -133,7 +188,8 @@ class ColorFieldFormatterCss extends FormatterBase {
       $elements['#attached']['html_head'][] = [[
         '#tag' => 'style',
         '#value' => $inline_css,
-      ], 'colorfield_css'];
+      ], sha1($inline_css),
+      ];
     }
 
     return $elements;
@@ -150,7 +206,8 @@ class ColorFieldFormatterCss extends FormatterBase {
 
     if ($opacity && $settings['opacity']) {
       $rgbtext = $color_hex->toRGB()->toString(TRUE);
-    } else {
+    }
+    else {
       $rgbtext = $color_hex->toRGB()->toString(FALSE);
     }
 

+ 33 - 33
sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterSwatch.php

@@ -1,15 +1,9 @@
 <?php
 
-/**
- * @file
- * Contains Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterSwatch.
- */
-
 namespace Drupal\color_field\Plugin\Field\FieldFormatter;
 
 use Drupal\color_field\Plugin\Field\FieldType\ColorFieldType;
 use Drupal\Core\Field\FormatterBase;
-use Drupal\Core\Field\FieldItemInterface;
 use Drupal\Core\Field\FieldItemListInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\color_field\ColorHex;
@@ -32,12 +26,12 @@ class ColorFieldFormatterSwatch extends FormatterBase {
    * {@inheritdoc}
    */
   public static function defaultSettings() {
-    return array(
+    return [
       'shape' => 'square',
       'width' => 50,
       'height' => 50,
       'opacity' => TRUE,
-    ) + parent::defaultSettings();
+    ] + parent::defaultSettings();
   }
 
   /**
@@ -48,42 +42,47 @@ class ColorFieldFormatterSwatch extends FormatterBase {
 
     $elements = [];
 
-    $elements['shape'] = array(
+    $elements['shape'] = [
       '#type' => 'select',
-      '#title' => t('Shape'),
+      '#title' => $this->t('Shape'),
       '#options' => $this->getShape(),
       '#default_value' => $this->getSetting('shape'),
-      '#description' => t(''),
-    );
-    $elements['width'] = array(
+      '#description' => '',
+    ];
+    $elements['width'] = [
       '#type' => 'number',
-      '#title' => t('Width'),
+      '#title' => $this->t('Width'),
       '#default_value' => $this->getSetting('width'),
       '#min' => 1,
-      '#description' => t(''),
-    );
-    $elements['height'] = array(
+      '#description' => '',
+    ];
+    $elements['height'] = [
       '#type' => 'number',
-      '#title' => t('Height'),
+      '#title' => $this->t('Height'),
       '#default_value' => $this->getSetting('height'),
       '#min' => 1,
-      '#description' => t(''),
-    );
+      '#description' => '',
+    ];
 
     if ($opacity) {
-      $elements['opacity'] = array(
+      $elements['opacity'] = [
         '#type' => 'checkbox',
-        '#title' => t('Display opacity'),
+        '#title' => $this->t('Display opacity'),
         '#default_value' => $this->getSetting('opacity'),
-      );
+      ];
     }
 
     return $elements;
   }
 
   /**
-   * @param string $shape
+   * This is used to get the shape.
+   *
+   * @param string|null $shape
+   *   The specific shape name to get.
+   *
    * @return array|string
+   *   An array of shape ids/names or translated name of the specified shape.
    */
   protected function getShape($shape = NULL) {
     $formats = [];
@@ -106,17 +105,17 @@ class ColorFieldFormatterSwatch extends FormatterBase {
 
     $summary = [];
 
-    $summary[] = t('@shape', array(
+    $summary[] = $this->t('@shape', [
       '@shape' => $this->getShape($settings['shape']),
-    ));
+    ]);
 
-    $summary[] = t('Width: @width Height: @height', array(
+    $summary[] = $this->t('Width: @width Height: @height', [
       '@width' => $settings['width'],
-      '@height' => $settings['height']
-    ));
+      '@height' => $settings['height'],
+    ]);
 
     if ($opacity && $settings['opacity']) {
-      $summary[] = t('Display with opacity.');
+      $summary[] = $this->t('Display with opacity.');
     }
 
     return $summary;
@@ -133,13 +132,13 @@ class ColorFieldFormatterSwatch extends FormatterBase {
     $elements['#attached']['library'][] = 'color_field/color-field-formatter-swatch';
 
     foreach ($items as $delta => $item) {
-      $elements[$delta] = array(
+      $elements[$delta] = [
         '#theme' => 'color_field_formatter_swatch',
         '#color' => $this->viewValue($item),
         '#shape' => $settings['shape'],
         '#width' => $settings['width'],
         '#height' => $settings['height'],
-      );
+      ];
     }
 
     return $elements;
@@ -156,7 +155,8 @@ class ColorFieldFormatterSwatch extends FormatterBase {
 
     if ($opacity && $settings['opacity']) {
       $rgbtext = $color_hex->toRGB()->toString(TRUE);
-    } else {
+    }
+    else {
       $rgbtext = $color_hex->toRGB()->toString(FALSE);
     }
 

+ 20 - 18
sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldFormatter/ColorFieldFormatterText.php

@@ -1,10 +1,5 @@
 <?php
 
-/**
- * @file
- * Contains Drupal\color_field\Plugin\Field\FieldFormatter\ColorFieldFormatterText.
- */
-
 namespace Drupal\color_field\Plugin\Field\FieldFormatter;
 
 use Drupal\color_field\Plugin\Field\FieldType\ColorFieldType;
@@ -31,10 +26,10 @@ class ColorFieldFormatterText extends FormatterBase {
    * {@inheritdoc}
    */
   public static function defaultSettings() {
-    return array(
+    return [
       'format' => 'hex',
       'opacity' => TRUE,
-    ) + parent::defaultSettings();
+    ] + parent::defaultSettings();
   }
 
   /**
@@ -45,27 +40,32 @@ class ColorFieldFormatterText extends FormatterBase {
 
     $elements = [];
 
-    $elements['format'] = array(
+    $elements['format'] = [
       '#type' => 'select',
-      '#title' => t('Format'),
+      '#title' => $this->t('Format'),
       '#options' => $this->getColorFormat(),
       '#default_value' => $this->getSetting('format'),
-    );
+    ];
 
     if ($opacity) {
-      $elements['opacity'] = array(
+      $elements['opacity'] = [
         '#type' => 'checkbox',
-        '#title' => t('Display opacity'),
+        '#title' => $this->t('Display opacity'),
         '#default_value' => $this->getSetting('opacity'),
-      );
+      ];
     }
 
     return $elements;
   }
 
   /**
+   * This function is used to get the color format.
+   *
    * @param string $format
+   *   Format is of string type.
+   *
    * @return array|string
+   *   Returns array or string.
    */
   protected function getColorFormat($format = NULL) {
     $formats = [];
@@ -87,12 +87,12 @@ class ColorFieldFormatterText extends FormatterBase {
 
     $summary = [];
 
-    $summary[] = t('@format', array(
+    $summary[] = $this->t('@format', [
       '@format' => $this->getColorFormat($settings['format']),
-    ));
+    ]);
 
     if ($opacity && $settings['opacity']) {
-      $summary[] = t('Display with opacity.');
+      $summary[] = $this->t('Display with opacity.');
     }
 
     return $summary;
@@ -124,7 +124,8 @@ class ColorFieldFormatterText extends FormatterBase {
       case 'hex':
         if ($opacity && $settings['opacity']) {
           $output = $color_hex->toString(TRUE);
-        } else {
+        }
+        else {
           $output = $color_hex->toString(FALSE);
         }
         break;
@@ -132,7 +133,8 @@ class ColorFieldFormatterText extends FormatterBase {
       case 'rgb':
         if ($opacity && $settings['opacity']) {
           $output = $color_hex->toRGB()->toString(TRUE);
-        } else {
+        }
+        else {
           $output = $color_hex->toRGB()->toString(FALSE);
         }
         break;

+ 67 - 56
sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldType/ColorFieldType.php

@@ -1,10 +1,5 @@
 <?php
 
-/**
- * @file
- * Contains Drupal\color_field\Plugin\Field\FieldType\ColorFieldType.
- */
-
 namespace Drupal\color_field\Plugin\Field\FieldType;
 
 use Drupal\Core\Field\FieldDefinitionInterface;
@@ -13,7 +8,6 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\Core\TypedData\DataDefinition;
-use Drupal\color_field\ColorHex;
 
 /**
  * Plugin implementation of the 'color_type' field type.
@@ -28,22 +22,29 @@ use Drupal\color_field\ColorHex;
  */
 class ColorFieldType extends FieldItemBase {
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function mainPropertyName() {
+    return 'color';
+  }
+
   /**
    * {@inheritdoc}
    */
   public static function defaultFieldSettings() {
-    return array(
+    return [
       'opacity' => TRUE,
-    ) + parent::defaultFieldSettings();
+    ] + parent::defaultFieldSettings();
   }
 
   /**
    * {@inheritdoc}
    */
   public static function defaultStorageSettings() {
-    return array(
+    return [
       'format' => '#HEXHEX',
-    ) + parent::defaultStorageSettings();
+    ] + parent::defaultStorageSettings();
   }
 
   /**
@@ -52,18 +53,18 @@ class ColorFieldType extends FieldItemBase {
   public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
     $element = [];
 
-    $element['format'] = array(
+    $element['format'] = [
       '#type' => 'select',
-      '#title' => t('Format storage'),
-      '#description' => t('Choose how to store the color.'),
+      '#title' => $this->t('Format storage'),
+      '#description' => $this->t('Choose how to store the color.'),
       '#default_value' => $this->getSetting('format'),
-      '#options' => array(
-        '#HEXHEX' => t('#123ABC'),
-        'HEXHEX' => t('123ABC'),
-        '#hexhex' => t('#123abc'),
-        'hexhex' => t('123abc'),
-      ),
-    );
+      '#options' => [
+        '#HEXHEX' => $this->t('#123ABC'),
+        'HEXHEX' => $this->t('123ABC'),
+        '#hexhex' => $this->t('#123abc'),
+        'hexhex' => $this->t('123abc'),
+      ],
+    ];
 
     $element += parent::storageSettingsForm($form, $form_state, $has_data);
 
@@ -76,12 +77,12 @@ class ColorFieldType extends FieldItemBase {
   public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
     $element = [];
 
-    $element['opacity'] = array(
+    $element['opacity'] = [
       '#type' => 'checkbox',
-      '#title' => t('Record opacity'),
-      '#description' => t('Whether or not to record.'),
+      '#title' => $this->t('Record opacity'),
+      '#description' => $this->t('Whether or not to record.'),
       '#default_value' => $this->getSetting('opacity'),
-    );
+    ];
 
     return $element;
   }
@@ -91,26 +92,26 @@ class ColorFieldType extends FieldItemBase {
    */
   public static function schema(FieldStorageDefinitionInterface $field_definition) {
     $format = $field_definition->getSetting('format');
-    $color_length = isset($format) ? strlen($format) : 7 ;
-    return array(
-      'columns' => array(
-        'color' => array(
+    $color_length = isset($format) ? strlen($format) : 7;
+    return [
+      'columns' => [
+        'color' => [
           'description' => 'The color value',
           'type' => 'varchar',
           'length' => $color_length,
           'not null' => FALSE,
-        ),
-        'opacity' => array(
+        ],
+        'opacity' => [
           'description' => 'The opacity/alphavalue property',
           'type' => 'float',
           'size' => 'tiny',
           'not null' => FALSE,
-        ),
-      ),
-      'indexes' => array(
-        'color' => array('color'),
-      ),
-    );
+        ],
+      ],
+      'indexes' => [
+        'color' => ['color'],
+      ],
+    ];
   }
 
   /**
@@ -144,34 +145,34 @@ class ColorFieldType extends FieldItemBase {
 
     $label = $this->getFieldDefinition()->getLabel();
 
-    $constraints[] = $constraint_manager->create('ComplexData', array(
-      'color' => array(
-        'Regex' => array(
+    $constraints[] = $constraint_manager->create('ComplexData', [
+      'color' => [
+        'Regex' => [
           'pattern' => '/^#?(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$/i',
-        )
-      ),
-    ));
+        ],
+      ],
+    ]);
 
     if ($opacity = $this->getSetting('opacity')) {
       $min = 0;
-      $constraints[] = $constraint_manager->create('ComplexData', array(
-        'opacity' => array(
-          'Range' => array(
+      $constraints[] = $constraint_manager->create('ComplexData', [
+        'opacity' => [
+          'Range' => [
             'min' => $min,
-            'minMessage' => t('%name: the opacity may be no less than %min.', array('%name' => $label, '%min' => $min)),
-          )
-        ),
-      ));
+            'minMessage' => $this->t('%name: the opacity may be no less than %min.', ['%name' => $label, '%min' => $min]),
+          ],
+        ],
+      ]);
 
       $max = 1;
-      $constraints[] = $constraint_manager->create('ComplexData', array(
-        'opacity' => array(
-          'Range' => array(
+      $constraints[] = $constraint_manager->create('ComplexData', [
+        'opacity' => [
+          'Range' => [
             'max' => $max,
-            'maxMessage' => t('%name: the opacity may be no greater than %max.', array('%name' => $label, '%max' => $max)),
-          )
-        ),
-      ));
+            'maxMessage' => $this->t('%name: the opacity may be no greater than %max.', ['%name' => $label, '%max' => $max]),
+          ],
+        ],
+      ]);
     }
 
     return $constraints;
@@ -188,12 +189,15 @@ class ColorFieldType extends FieldItemBase {
         case '#HEXHEX':
           $values['color'] = '#111AAA';
           break;
+
         case 'HEXHEX':
           $values['color'] = '111111';
           break;
+
         case '#hexhex':
           $values['color'] = '#111aaa';
           break;
+
         case 'hexhex':
           $values['color'] = '111111';
           break;
@@ -225,12 +229,15 @@ class ColorFieldType extends FieldItemBase {
         case '#HEXHEX':
           $color = '#' . strtoupper($color);
           break;
+
         case 'HEXHEX':
           $color = strtoupper($color);
           break;
+
         case '#hexhex':
           $color = '#' . strtolower($color);
           break;
+
         case 'hexhex':
           $color = strtolower($color);
           break;
@@ -238,6 +245,10 @@ class ColorFieldType extends FieldItemBase {
 
       $this->color = $color;
     }
+
+    if (!$this->getSetting('opacity')) {
+      unset($this->opacity);
+    }
   }
 
 }

+ 61 - 0
sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldWidget/ColorFieldWidgetBase.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace Drupal\color_field\Plugin\Field\FieldWidget;
+
+use Drupal\Component\Utility\Html;
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\WidgetBase;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Base class for color_field widgets.
+ */
+abstract class ColorFieldWidgetBase extends WidgetBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
+    $element['#uid'] = Html::getUniqueId('color-field-' . $this->fieldDefinition->getName());
+
+    // Prepare color.
+    $color = NULL;
+    if (isset($items[$delta]->color)) {
+      $color = $items[$delta]->color;
+      if (substr($color, 0, 1) !== '#') {
+        $color = '#' . $color;
+      }
+    }
+
+    $input = [
+      '#type' => 'textfield',
+      '#maxlength' => 7,
+      '#size' => 7,
+      '#required' => $element['#required'],
+      '#default_value' => $color,
+    ];
+
+    if ($this->getFieldSetting('opacity')) {
+      $element['color'] = $input;
+      $element['color']['#title'] = $this->t('Color');
+      $element['#type'] = 'fieldset';
+
+      $element['opacity'] = [
+        '#title' => $this->t('Opacity'),
+        '#type' => 'number',
+        '#min' => 0,
+        '#max' => 1,
+        '#step' => 0.01,
+        '#required' => $element['#required'],
+        '#default_value' => isset($items[$delta]->opacity) ? $items[$delta]->opacity : NULL,
+        '#placeholder' => $this->getSetting('placeholder_opacity'),
+      ];
+    }
+    else {
+      $element['color'] = $element + $input;
+    }
+
+    return $element;
+  }
+
+}

+ 49 - 58
sites/all/modules/contrib/fields/color_field/src/Plugin/Field/FieldWidget/ColorFieldWidgetBox.php

@@ -1,14 +1,8 @@
 <?php
 
-/**
- * @file
- * Contains Drupal\color_field\Plugin\Field\FieldWidget\ColorFieldWidgetBox.
- */
-
 namespace Drupal\color_field\Plugin\Field\FieldWidget;
 
 use Drupal\Core\Field\FieldItemListInterface;
-use Drupal\Core\Field\WidgetBase;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
@@ -23,36 +17,62 @@ use Drupal\Core\Form\FormStateInterface;
  *   }
  * )
  */
-class ColorFieldWidgetBox extends WidgetBase {
+class ColorFieldWidgetBox extends ColorFieldWidgetBase {
 
   /**
    * {@inheritdoc}
    */
   public static function defaultSettings() {
-    return array(
+    return [
       'default_colors' => '
 #AC725E,#D06B64,#F83A22,#FA573C,#FF7537,#FFAD46
 #42D692,#16A765,#7BD148,#B3DC6C,#FBE983
 #92E1C0,#9FE1E7,#9FC6E7,#4986E7,#9A9CFF
 #B99AFF,#C2C2C2,#CABDBF,#CCA6AC,#F691B2
 #CD74E6,#A47AE2',
-    ) + parent::defaultSettings();
+    ] + parent::defaultSettings();
   }
 
   /**
    * {@inheritdoc}
    */
   public function settingsForm(array $form, FormStateInterface $form_state) {
-    $element['default_colors'] = array(
+    $element['default_colors'] = [
       '#type' => 'textarea',
-      '#title' => t('Default colors'),
+      '#title' => $this->t('Default colors'),
       '#default_value' => $this->getSetting('default_colors'),
       '#required' => TRUE,
-      '#description' => t('Default colors for pre-selected color boxes'),
-    );
+      '#element_validate' => [
+        [$this, 'settingsColorValidate'],
+      ],
+      '#description' => $this->t('Default colors for pre-selected color boxes. Enter as 6 digit upper case hex - such as #FF0000.'),
+    ];
     return $element;
   }
 
+  /**
+   * Use element validator to make sure that hex values are in correct format.
+   *
+   * @param array $element
+   *   The Default colors element.
+   * @param \Drupal\Core\Form\FormStateInterface $form_state
+   *   The current state of the form.
+   */
+  public function settingsColorValidate(array $element, FormStateInterface $form_state) {
+    $default_colors = $form_state->getValue($element['#parents']);
+    $colors = '';
+    if (!empty($default_colors)) {
+      preg_match_all("/#[0-9a-fA-F]{6}/", $default_colors, $default_colors, PREG_SET_ORDER);
+      foreach ($default_colors as $color) {
+        if (!empty($colors)) {
+          $colors .= ',';
+        }
+        $colors .= strtoupper($color[0]);
+      }
+    }
+    $form_state->setValue($element['#parents'], $colors);
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -62,7 +82,7 @@ class ColorFieldWidgetBox extends WidgetBase {
     $default_colors = $this->getSetting('default_colors');
 
     if (!empty($default_colors)) {
-      preg_match_all("/#[0-9a-fA-F]{6}/", $default_colors, $default_colors, PREG_SET_ORDER);
+      preg_match_all("/#[0-9A-F]{6}/", $default_colors, $default_colors, PREG_SET_ORDER);
       foreach ($default_colors as $color) {
         $colors = $color[0];
         $summary[] = $colors;
@@ -70,7 +90,7 @@ class ColorFieldWidgetBox extends WidgetBase {
     }
 
     if (empty($summary)) {
-      $summary[] = t('No default colors');
+      $summary[] = $this->t('No default colors');
     }
 
     return $summary;
@@ -80,58 +100,29 @@ class ColorFieldWidgetBox extends WidgetBase {
    * {@inheritdoc}
    */
   public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
-    // We are nesting some sub-elements inside the parent, so we need a wrapper.
-    // We also need to add another #title attribute at the top level for ease in
-    // identifying this item in error messages. We do not want to display this
-    // title because the actual title display is handled at a higher level by
-    // the Field module.
-
-    $element['#theme_wrappers'] = array('color_field_widget_box');
-    $element['#attributes']['class'][] = 'container-inline';
+    $element = parent::formElement($items, $delta, $element, $form, $form_state);
+    // Ensure the default value is the required format.
+    if ($element['color']['#default_value']) {
+      $element['color']['#default_value'] = strtoupper($element['color']['#default_value']);
+      if (strlen($element['color']['#default_value']) === 6) {
+        $element['color']['#default_value'] = '#' . $element['color']['#default_value'];
+      }
+    }
 
     $element['#attached']['library'][] = 'color_field/color-field-widget-box';
 
     // Set Drupal settings.
-    $settings = [];
+    $settings[$element['#uid']] = [
+      'required' => $this->fieldDefinition->isRequired(),
+    ];
     $default_colors = $this->getSetting('default_colors');
-    preg_match_all("/#[0-9a-fA-F]{6}/", $default_colors, $default_colors, PREG_SET_ORDER);
+    preg_match_all("/#[0-9A-F]{6}/", $default_colors, $default_colors, PREG_SET_ORDER);
     foreach ($default_colors as $color) {
-      $settings['default_colors'][] = $color[0];
+      $settings[$element['#uid']]['palette'][] = $color[0];
     }
     $element['#attached']['drupalSettings']['color_field']['color_field_widget_box']['settings'] = $settings;
 
-    // Retrieve field label and description.
-    $element['#title'] = $this->fieldDefinition->getLabel();;
-    $element['#description'] = $this->fieldDefinition->getDescription();
-
-    // Prepare color.
-    $color = NULL;
-    if (isset($items[$delta]->color)) {
-      $color = $items[$delta]->color;
-      if (substr($color, 0, 1) !== '#') {
-        $color = '#' . $color;
-      }
-    }
-
-    $element['color'] = array(
-      '#maxlength' => 7,
-      '#size' => 7,
-      '#type' => 'textfield',
-      '#default_value' => $color,
-      '#attributes' => array('class' => array('visually-hidden')),
-   );
-    $element['color']['#suffix'] = "<div class='color-field-widget-box-form'></div>";
-
-    if ($this->getFieldSetting('opacity')) {
-      $element['opacity'] = array(
-        '#title' => t('Opacity'),
-        '#type' => 'textfield',
-        '#maxlength' => 4,
-        '#size' => 4,
-        '#default_value' => isset($items[$delta]->opacity) ? $items[$delta]->opacity : NULL,
-        '#placeholder' => $this->getSetting('placeholder_opacity'),
-      );
-    }
+    $element['color']['#suffix'] = "<div class='color-field-widget-box-form' id='" . $element['#uid'] . "'></div>";
 
     return $element;
   }

Some files were not shown because too many files changed in this diff