From cf4da62f7b6fa05ef04380b2ead81d639149ca6e Mon Sep 17 00:00:00 2001 From: Brian Canini <canini.16@osu.edu> Date: Wed, 5 Aug 2020 14:58:30 -0400 Subject: [PATCH] Updating drupal/social_media_links (2.6.0 => 2.7.0) --- composer.json | 2 +- composer.lock | 30 ++++++------ vendor/composer/installed.json | 30 ++++++------ web/modules/social_media_links/README.txt | 48 +++++++++++++------ web/modules/social_media_links/composer.json | 27 +++++++---- .../css/social_media_links.theme.css | 7 ++- .../social_media_links_field.info.yml | 13 ++--- .../src/Element/SocialMediaLinksPlatforms.php | 6 +-- .../SocialMediaLinksFieldDefaultFormatter.php | 28 +++++++---- .../FieldType/SocialMediaLinksFieldItem.php | 11 +++-- .../SocialMediaLinksFieldBaseWidget.php | 10 ++-- .../SocialMediaLinksFieldDefaultWidget.php | 3 +- .../SocialMediaLinksFieldSelectWidget.php | 2 +- .../social_media_links.info.yml | 11 +++-- .../social_media_links.libraries.yml | 2 +- .../social_media_links.module | 7 +++ .../social_media_links.services.yml | 2 +- .../social_media_links/src/IconsetBase.php | 7 +++ .../src/IconsetFinderService.php | 17 ++++++- .../social_media_links/src/PlatformBase.php | 17 ++++++- .../src/PlatformInterface.php | 2 +- .../Plugin/Block/SocialMediaLinksBlock.php | 24 +++++++++- .../SocialMediaLinks/Iconset/FontAwesome.php | 15 ++++-- .../SocialMediaLinks/Iconset/Webtoolkit.php | 40 ---------------- .../SocialMediaLinks/Platform/Drupal.php | 0 .../SocialMediaLinks/Platform/Email.php | 5 +- .../SocialMediaLinks/Platform/Website.php | 39 +++++++++++++++ .../SocialMediaLinks/Platform/Whatsapp.php | 16 +++++++ .../Plugin/SocialMediaLinks/Platform/Xing.php | 16 +++++++ .../src/SocialMediaLinksPlatformManager.php | 13 ++--- .../social-media-links-platforms.html.twig | 4 +- 31 files changed, 305 insertions(+), 149 deletions(-) delete mode 100644 web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/Webtoolkit.php mode change 100755 => 100644 web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Drupal.php create mode 100644 web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Website.php create mode 100644 web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Whatsapp.php create mode 100644 web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Xing.php diff --git a/composer.json b/composer.json index 2793757b25..c869eeb430 100644 --- a/composer.json +++ b/composer.json @@ -165,7 +165,7 @@ "drupal/simplesamlphp_auth": "3.1", "drupal/smtp": "1.x-dev#84f789cbba894290cf82ed2558c8a4e7e24f3c89", "drupal/social_media": "1.8", - "drupal/social_media_links": "2.6", + "drupal/social_media_links": "2.7", "drupal/superfish": "1.4", "drupal/svg_image": "1.14", "drupal/token": "1.7", diff --git a/composer.lock b/composer.lock index 02a1272989..92a4edf789 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c92fb7024043f565aa012508f5895e37", + "content-hash": "44d402bee9e41fa990e5a18ca2187129", "packages": [ { "name": "alchemy/zippy", @@ -7491,29 +7491,26 @@ }, { "name": "drupal/social_media_links", - "version": "2.6.0", + "version": "2.7.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/social_media_links.git", - "reference": "8.x-2.6" + "reference": "8.x-2.7" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/social_media_links-8.x-2.6.zip", - "reference": "8.x-2.6", - "shasum": "53462cb307b104552ae5370b917e55ca50fba526" + "url": "https://ftp.drupal.org/files/projects/social_media_links-8.x-2.7.zip", + "reference": "8.x-2.7", + "shasum": "132db954d880c743bd6316f7fecd0b085bb73f91" }, "require": { - "drupal/core": "~8.0" + "drupal/core": "^8 || ^9" }, "type": "drupal-module", "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - }, "drupal": { - "version": "8.x-2.6", - "datestamp": "1510489384", + "version": "8.x-2.7", + "datestamp": "1595616928", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -7522,9 +7519,14 @@ }, "notification-url": "https://packages.drupal.org/8/downloads", "license": [ - "GPL-2.0+" + "GPL-2.0-or-later" ], "authors": [ + { + "name": "Neslee Canil Pinto", + "homepage": "https://www.drupal.org/u/neslee-canil-pinto", + "role": "Maintainer" + }, { "name": "cbeier", "homepage": "https://www.drupal.org/user/1500710" @@ -7533,7 +7535,7 @@ "description": "The module provides a block that display links (icons) to your profiles on various social networking sites.", "homepage": "https://www.drupal.org/project/social_media_links", "support": { - "source": "http://cgit.drupalcode.org/social_media_links", + "source": "https://git.drupalcode.org/project/social_media_links", "issues": "https://www.drupal.org/project/issues/social_media_links" } }, diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e2bf6c5bc5..d288092e22 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -7722,30 +7722,27 @@ }, { "name": "drupal/social_media_links", - "version": "2.6.0", - "version_normalized": "2.6.0.0", + "version": "2.7.0", + "version_normalized": "2.7.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/social_media_links.git", - "reference": "8.x-2.6" + "reference": "8.x-2.7" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/social_media_links-8.x-2.6.zip", - "reference": "8.x-2.6", - "shasum": "53462cb307b104552ae5370b917e55ca50fba526" + "url": "https://ftp.drupal.org/files/projects/social_media_links-8.x-2.7.zip", + "reference": "8.x-2.7", + "shasum": "132db954d880c743bd6316f7fecd0b085bb73f91" }, "require": { - "drupal/core": "~8.0" + "drupal/core": "^8 || ^9" }, "type": "drupal-module", "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - }, "drupal": { - "version": "8.x-2.6", - "datestamp": "1510489384", + "version": "8.x-2.7", + "datestamp": "1595616928", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -7755,9 +7752,14 @@ "installation-source": "dist", "notification-url": "https://packages.drupal.org/8/downloads", "license": [ - "GPL-2.0+" + "GPL-2.0-or-later" ], "authors": [ + { + "name": "Neslee Canil Pinto", + "homepage": "https://www.drupal.org/u/neslee-canil-pinto", + "role": "Maintainer" + }, { "name": "cbeier", "homepage": "https://www.drupal.org/user/1500710" @@ -7766,7 +7768,7 @@ "description": "The module provides a block that display links (icons) to your profiles on various social networking sites.", "homepage": "https://www.drupal.org/project/social_media_links", "support": { - "source": "http://cgit.drupalcode.org/social_media_links", + "source": "https://git.drupalcode.org/project/social_media_links", "issues": "https://www.drupal.org/project/issues/social_media_links" } }, diff --git a/web/modules/social_media_links/README.txt b/web/modules/social_media_links/README.txt index 417d56266f..4942b858c3 100755 --- a/web/modules/social_media_links/README.txt +++ b/web/modules/social_media_links/README.txt @@ -1,20 +1,38 @@ -DESCRIPTION -=========== +CONTENTS OF THIS FILE +--------------------- + + * Introduction + * Requirements + * Installation + * Configuration + * Maintainers + + +INTRODUCTION +------------ The modules provides a configurable block that display links (icons) to your profiles on various popular networking sites. +With this module, a website can be quickly extended with a "Follow us" +functionality. Or you make the block available for your site editors, and they +can configure the social networks themselves. + + +REQUIREMENTS +------------ +This module does not have any dependency on any other module. + INSTALLATION +------------ +Install as normal (see http://drupal.org/documentation/install/modules-themes). + + +CONFIGURATION ============ -1. Install as usual, see https://www.drupal.org/docs/8/extending-drupal-8/installing-contributed-modules-find-import-enable-configure for further information. -2. The module has no special configuration. All settings are available in the - block settings: - /admin/structure/block - -INCLUDED ICON SETS -================== -The module contains a icon set, that the module is ready for use immediately -after the installation. - -MAINTAINER -========== -- cbeier (Christian Beier) +The module has no special configuration. All settings are available in the +block settings: /admin/structure/block + + +MAINTAINERS +----------- +Neslee Canil Pinto: https://www.drupal.org/u/neslee-canil-pinto diff --git a/web/modules/social_media_links/composer.json b/web/modules/social_media_links/composer.json index 2d341f808a..d8ec9340f7 100644 --- a/web/modules/social_media_links/composer.json +++ b/web/modules/social_media_links/composer.json @@ -1,10 +1,21 @@ { - "name": "drupal/social_media_links", - "description": "The module provides a block that display links (icons) to your profiles on various social networking sites.", - "type": "drupal-module", - "homepage": "https://www.drupal.org/project/social_media_links", - "support": { - "issues": "https://www.drupal.org/project/issues/social_media_links" - }, - "license": "GPL-2.0+" + "name": "drupal/social_media_links", + "description": "The module provides a block that display links (icons) to your profiles on various social networking sites.", + "type": "drupal-module", + "license": "GPL-2.0-or-later", + "homepage": "https://www.drupal.org/project/social_media_links", + "authors": [ + { + "name": "Neslee Canil Pinto", + "homepage": "https://www.drupal.org/u/neslee-canil-pinto", + "role": "Maintainer" + } + ], + "support": { + "issues": "https://www.drupal.org/project/issues/social_media_links", + "source": "https://git.drupalcode.org/project/social_media_links" + }, + "require": { + "drupal/core": "^8 || ^9" + } } diff --git a/web/modules/social_media_links/css/social_media_links.theme.css b/web/modules/social_media_links/css/social_media_links.theme.css index b6a90eea47..1c0e1d0967 100644 --- a/web/modules/social_media_links/css/social_media_links.theme.css +++ b/web/modules/social_media_links/css/social_media_links.theme.css @@ -10,10 +10,15 @@ .social-media-links--platforms.vertical li { list-style-type: none; - margin: 0 0 .5em 0 + margin: 0 0 .5em 0; } .social-media-links--platforms.vertical li a img { vertical-align: middle; margin-right: .5em; } + +.iconsets-wrapper { + display: inherit; + overflow-x: auto; +} diff --git a/web/modules/social_media_links/modules/social_media_links_field/social_media_links_field.info.yml b/web/modules/social_media_links/modules/social_media_links_field/social_media_links_field.info.yml index 9d0a912e95..845f399d67 100644 --- a/web/modules/social_media_links/modules/social_media_links_field/social_media_links_field.info.yml +++ b/web/modules/social_media_links/modules/social_media_links_field/social_media_links_field.info.yml @@ -1,12 +1,13 @@ name: Social Media Links Field description: The module provides a field type to capture social media profiles. type: module -# core: 8.x +core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - - social_media_links -# Information added by Drupal.org packaging script on 2017-11-12 -version: '8.x-2.6' -core: '8.x' + - social_media_links:social_media_links + +# Information added by Drupal.org packaging script on 2020-07-24 +version: '8.x-2.7' project: 'social_media_links' -datestamp: 1510489388 +datestamp: 1595616930 diff --git a/web/modules/social_media_links/modules/social_media_links_field/src/Element/SocialMediaLinksPlatforms.php b/web/modules/social_media_links/modules/social_media_links_field/src/Element/SocialMediaLinksPlatforms.php index 42b637adf0..74920d2bf9 100644 --- a/web/modules/social_media_links/modules/social_media_links_field/src/Element/SocialMediaLinksPlatforms.php +++ b/web/modules/social_media_links/modules/social_media_links_field/src/Element/SocialMediaLinksPlatforms.php @@ -5,7 +5,6 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Render\Element; use Drupal\Core\Render\Element\FormElement; /** @@ -61,7 +60,7 @@ public static function processElement(array &$element, FormStateInterface $form_ $element = [ '#tree' => TRUE, - '#prefix' => '<div id="' . $wrapper_id . '">', + '#prefix' => '<div id="' . $wrapper_id . '">', '#suffix' => '</div>', '#wrapper_id' => $wrapper_id, ] + $element; @@ -128,6 +127,7 @@ protected static function platformElements(array $element, array $value) { * The current state of the form. * * @return array + * $platform_field_element */ public static function ajaxRefresh(array $form, FormStateInterface $form_state) { $platform_element = $form_state->getTriggeringElement(); @@ -137,4 +137,4 @@ public static function ajaxRefresh(array $form, FormStateInterface $form_state) return $platform_field_element; } -} \ No newline at end of file +} diff --git a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldFormatter/SocialMediaLinksFieldDefaultFormatter.php b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldFormatter/SocialMediaLinksFieldDefaultFormatter.php index e8f30056c1..a34f4143e7 100644 --- a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldFormatter/SocialMediaLinksFieldDefaultFormatter.php +++ b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldFormatter/SocialMediaLinksFieldDefaultFormatter.php @@ -5,7 +5,6 @@ use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\social_media_links\IconsetBase; use Drupal\Core\Template\Attribute; @@ -34,9 +33,17 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $iconset_style = IconsetBase::explodeStyle($items->getSetting('iconset')); $iconset = $this->getIconset($iconset_style['iconset']); + $link_attributes = $this->getSetting('link_attributes'); + + foreach ($link_attributes as $key => $value) { + if ($value === '<none>') { + unset($link_attributes[$key]); + } + } + foreach ($platforms as $platform_id => $platform) { $platforms[$platform_id]['element'] = (array) $iconset['instance']->getIconElement($platform['instance'], $iconset_style['style']); - $platforms[$platform_id]['attributes'] = new Attribute(); + $platforms[$platform_id]['attributes'] = new Attribute($link_attributes); if (!empty($platform['instance']->getDescription())) { $platforms[$platform_id]['attributes']->setAttribute('aria-label', $platform['instance']->getDescription()); @@ -64,10 +71,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'appearance' => [], 'link_attributes' => [], - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -155,6 +162,7 @@ public function settingsSummary() { * Get the platforms that have values. * * @return array + * $platforms. */ protected function getPlatformsWithValues(FieldItemListInterface $items) { $platform_settings = $items->getSetting('platforms'); @@ -169,11 +177,12 @@ protected function getPlatformsWithValues(FieldItemListInterface $items) { $platforms = []; foreach ($items as $delta => $item) { - // We have two possible structures where the platform values can be stored. + // We have two possible structures where the platform values can be + // stored. // * If the select widget was used the values are saved in two fields - // (platform and value). + // (platform and value). // * If the default list widget was used the values are saved in a - // multidimensional array structure (platform_values). + // multidimensional array structure (platform_values). if (empty($item->platform_values)) { // Select widget fields handling. if ($all_platforms_available || isset($platform_settings[$item->platform]['enabled']) && $platform_settings[$item->platform]['enabled']) { @@ -206,14 +215,15 @@ protected function getPlatformsWithValues(FieldItemListInterface $items) { /** * Get the iconset. * - * @param string + * @param string $iconset * The iconset id. * * @return array + * $iconsets */ protected function getIconset($iconset) { $iconsets = \Drupal::service('plugin.manager.social_media_links.iconset')->getIconsets(); return $iconsets[$iconset]; } -} \ No newline at end of file +} diff --git a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldType/SocialMediaLinksFieldItem.php b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldType/SocialMediaLinksFieldItem.php index f20d6c118c..2b03da1a12 100644 --- a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldType/SocialMediaLinksFieldItem.php +++ b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldType/SocialMediaLinksFieldItem.php @@ -97,17 +97,18 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $this->t('Weight'), ], '#prefix' => '<h5>' . $this->t('Platforms') . '</h5>', - '#suffix' => '<div class="description">' . $this->t('The platforms that are allowed to be used in this field. Select none to allow all platforms.') .'</div>', + '#suffix' => '<div class="description">' . $this->t('The platforms that are allowed to be used in this field. Select none to allow all platforms.') . '</div>', '#tabledrag' => [[ 'action' => 'order', - 'relationship' => 'silbing', + 'relationship' => 'sibling', 'group' => 'platform-order-weight', - ]], + ], + ], ]; // Keep a note of the highest weight. $max_weight = 10; - $platforms = \Drupal::service('plugin.manager.social_media_links.platform')->getPlatformsSortedByWeight($this->getSetting('platforms')); + $platforms = \Drupal::service('plugin.manager.social_media_links.platform')->getPlatformsSortedByWeight(['platforms' => $this->getSetting('platforms')]); foreach ($platforms as $platform_id => $platform) { $element['platforms'][$platform_id]['#attributes']['class'][] = 'draggable'; $element['platforms'][$platform_id]['#weight'] = $platform['weight']; @@ -165,4 +166,4 @@ public function isEmpty() { return $value === NULL || $value === '' || $platform === NULL || $platform === ''; } -} \ No newline at end of file +} diff --git a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldBaseWidget.php b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldBaseWidget.php index 1cc5b578c5..2c74e0b0ed 100644 --- a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldBaseWidget.php +++ b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldBaseWidget.php @@ -3,16 +3,17 @@ namespace Drupal\social_media_links_field\Plugin\Field\FieldWidget; use Drupal\Core\Field\WidgetBase; -use Drupal\Core\Field\FieldItemListInterface; -use Drupal\Core\Form\FormStateInterface; -use Symfony\Component\Validator\ConstraintViolationInterface; +/** + * Class SocialMediaLinksFieldBaseWidget. + */ abstract class SocialMediaLinksFieldBaseWidget extends WidgetBase { /** * Returns the available platforms as options array. * * @return array + * $options. */ protected function getAvailablePlatformOptions() { $available_platforms = $this->getAvailablePlatforms(); @@ -29,6 +30,7 @@ protected function getAvailablePlatformOptions() { * Returns the list of platforms that was selected in field settings. * * @return array + * $available_platforms */ protected function getAvailablePlatforms() { $platforms = \Drupal::service('plugin.manager.social_media_links.platform')->getPlatforms(); @@ -57,4 +59,4 @@ protected function getAvailablePlatforms() { return $available_platforms; } -} \ No newline at end of file +} diff --git a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldDefaultWidget.php b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldDefaultWidget.php index 61756466da..172f9778a2 100644 --- a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldDefaultWidget.php +++ b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldDefaultWidget.php @@ -4,7 +4,6 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; -use Symfony\Component\Validator\ConstraintViolationInterface; /** * Plugin implementation of the 'social_media_links_field_default' widget. @@ -50,4 +49,4 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen return $element; } -} \ No newline at end of file +} diff --git a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldSelectWidget.php b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldSelectWidget.php index 3098ded82f..bbfdbd71f3 100644 --- a/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldSelectWidget.php +++ b/web/modules/social_media_links/modules/social_media_links_field/src/Plugin/Field/FieldWidget/SocialMediaLinksFieldSelectWidget.php @@ -70,4 +70,4 @@ public function massageFormValues(array $values, array $form, FormStateInterface return $new_values; } -} \ No newline at end of file +} diff --git a/web/modules/social_media_links/social_media_links.info.yml b/web/modules/social_media_links/social_media_links.info.yml index b4f4de5d85..28dd48c6b9 100644 --- a/web/modules/social_media_links/social_media_links.info.yml +++ b/web/modules/social_media_links/social_media_links.info.yml @@ -1,9 +1,10 @@ name: Social Media Links Block description: The module provides a block that display links (icons) to your profiles on various social networking sites. type: module -# core: 8.x -# Information added by Drupal.org packaging script on 2017-11-12 -version: '8.x-2.6' -core: '8.x' +core: 8.x +core_version_requirement: ^8 || ^9 + +# Information added by Drupal.org packaging script on 2020-07-24 +version: '8.x-2.7' project: 'social_media_links' -datestamp: 1510489388 +datestamp: 1595616930 diff --git a/web/modules/social_media_links/social_media_links.libraries.yml b/web/modules/social_media_links/social_media_links.libraries.yml index 2a378fc41e..cd2f249ee1 100644 --- a/web/modules/social_media_links/social_media_links.libraries.yml +++ b/web/modules/social_media_links/social_media_links.libraries.yml @@ -6,4 +6,4 @@ social_media_links.theme: fontawesome.component: css: component: - //maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css: { type: external } \ No newline at end of file + //maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css: { type: external } diff --git a/web/modules/social_media_links/social_media_links.module b/web/modules/social_media_links/social_media_links.module index a2cd1b6431..4286f20e0e 100644 --- a/web/modules/social_media_links/social_media_links.module +++ b/web/modules/social_media_links/social_media_links.module @@ -49,3 +49,10 @@ function social_media_links_help($route_name, RouteMatchInterface $route_match) return $output; } } + +/** + * Attaching css file. + */ +function social_media_links_page_attachments(array &$attachments) { + $attachments['#attached']['library'][] = 'social_media_links/social_media_links.theme'; +} diff --git a/web/modules/social_media_links/social_media_links.services.yml b/web/modules/social_media_links/social_media_links.services.yml index 6c6f74b4c8..ab6cdb8414 100755 --- a/web/modules/social_media_links/social_media_links.services.yml +++ b/web/modules/social_media_links/social_media_links.services.yml @@ -11,4 +11,4 @@ services: logger.channel.social_media_links: parent: logger.channel_base - arguments: ['social_media_links'] \ No newline at end of file + arguments: ['social_media_links'] diff --git a/web/modules/social_media_links/src/IconsetBase.php b/web/modules/social_media_links/src/IconsetBase.php index 5bbd7e715d..f20db4c28e 100755 --- a/web/modules/social_media_links/src/IconsetBase.php +++ b/web/modules/social_media_links/src/IconsetBase.php @@ -11,7 +11,14 @@ */ abstract class IconsetBase extends PluginBase implements IconsetInterface, ContainerFactoryPluginInterface { + /** + * {@inheritdoc} + */ protected $path = ''; + + /** + * {@inheritdoc} + */ protected $finder; /** diff --git a/web/modules/social_media_links/src/IconsetFinderService.php b/web/modules/social_media_links/src/IconsetFinderService.php index 462d75833c..4c347d7a97 100755 --- a/web/modules/social_media_links/src/IconsetFinderService.php +++ b/web/modules/social_media_links/src/IconsetFinderService.php @@ -9,9 +9,24 @@ */ class IconsetFinderService { + /** + * {@inheritdoc} + */ protected $installDirs = []; + + /** + * {@inheritdoc} + */ protected $searchDirs = []; + + /** + * {@inheritdoc} + */ protected $iconsets = []; + + /** + * {@inheritdoc} + */ protected $kernel; /** @@ -54,7 +69,7 @@ protected function setSearchDirs() { // Similar to 'modules' and 'themes' directories inside an installation // profile, installation profiles may want to place libraries into a // 'libraries' directory. - $profile = drupal_get_profile(); + $profile = \Drupal::installProfile(); if ($profile && strpos($profile, "core") === FALSE) { $profile_path = drupal_get_path('profile', $profile); $searchdirs[] = "$profile_path/libraries"; diff --git a/web/modules/social_media_links/src/PlatformBase.php b/web/modules/social_media_links/src/PlatformBase.php index 2a499be13a..6dc38a6ddf 100755 --- a/web/modules/social_media_links/src/PlatformBase.php +++ b/web/modules/social_media_links/src/PlatformBase.php @@ -2,6 +2,7 @@ namespace Drupal\social_media_links; +use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Component\Utility\Html; @@ -12,7 +13,14 @@ */ class PlatformBase extends PluginBase implements PlatformInterface { + /** + * {@inheritdoc} + */ protected $value; + + /** + * {@inheritdoc} + */ protected $description; /** @@ -95,6 +103,13 @@ public function setDescription($description) { /** * {@inheritdoc} */ - public static function validateValue(array &$element, FormStateInterface $form_state, array $form) {} + public static function validateValue(array &$element, FormStateInterface $form_state, array $form) { + // Do not allow a URL when the plugin already provides a URL prefix. + if (!empty($element['#value']) && !empty($element['#field_prefix'])) { + if (UrlHelper::isExternal($element['#value'])) { + $form_state->setError($element, t("The entered value %value is a URL. You should enter only the relative part, the URL prefix is automatically prepended.", ['%value' => $element['#value']])); + } + } + } } diff --git a/web/modules/social_media_links/src/PlatformInterface.php b/web/modules/social_media_links/src/PlatformInterface.php index 96b9822a9d..4a1d6f1150 100755 --- a/web/modules/social_media_links/src/PlatformInterface.php +++ b/web/modules/social_media_links/src/PlatformInterface.php @@ -85,7 +85,7 @@ public function getUrl(); /** * Generates the final url for the output. * - * @param Url $url + * @param \Drupal\Core\Url $url * A Url object with the full plattform url. * * @return string diff --git a/web/modules/social_media_links/src/Plugin/Block/SocialMediaLinksBlock.php b/web/modules/social_media_links/src/Plugin/Block/SocialMediaLinksBlock.php index 419a59753a..9a8b61444b 100755 --- a/web/modules/social_media_links/src/Plugin/Block/SocialMediaLinksBlock.php +++ b/web/modules/social_media_links/src/Plugin/Block/SocialMediaLinksBlock.php @@ -27,10 +27,29 @@ */ class SocialMediaLinksBlock extends BlockBase implements ContainerFactoryPluginInterface { + /** + * {@inheritdoc} + */ protected $platformManager; + + /** + * {@inheritdoc} + */ protected $iconsetManager; + + /** + * {@inheritdoc} + */ protected $iconsetFinderService; + + /** + * {@inheritdoc} + */ protected $renderer; + + /** + * {@inheritdoc} + */ protected $logger; /** @@ -194,6 +213,7 @@ public function blockForm($form, FormStateInterface $form_state) { '#type' => 'details', '#title' => $this->t('Icon Sets'), '#open' => TRUE, + '#attributes' => ['class' => ['iconsets-wrapper']], ]; $form['iconset']['style'] = [ '#type' => 'select', @@ -349,8 +369,8 @@ public function build() { $platforms[$platform_id]['attributes'] = new Attribute($config['link_attributes']); if (!empty($platform['instance']->getDescription())) { - $platforms[$platform_id]['attributes']->setAttribute('aria-label', $platform['instance']->getDescription()); - $platforms[$platform_id]['attributes']->setAttribute('title', $platform['instance']->getDescription()); + $platforms[$platform_id]['attributes']->setAttribute('aria-label', $this->t($platform['instance']->getDescription())); + $platforms[$platform_id]['attributes']->setAttribute('title', $this->t(($platform['instance']->getDescription()))); } } diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/FontAwesome.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/FontAwesome.php index 001df1729a..d293cb3f69 100755 --- a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/FontAwesome.php +++ b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/FontAwesome.php @@ -58,6 +58,10 @@ public function getIconElement($platform, $style) { case 'email': $icon_name = 'envelope'; break; + + case 'website': + $icon_name = 'home'; + break; } $icon = [ @@ -72,9 +76,14 @@ public function getIconElement($platform, $style) { * {@inheritdoc} */ public function getLibrary() { - return [ - 'social_media_links/fontawesome.component', - ]; + if (\Drupal::service('module_handler')->moduleExists('fontawesome')) { + return parent::getLibrary(); + } + else { + return [ + 'social_media_links/fontawesome.component', + ]; + } } /** diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/Webtoolkit.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/Webtoolkit.php deleted file mode 100644 index 80f17f9864..0000000000 --- a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Iconset/Webtoolkit.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -namespace Drupal\social_media_links\Plugin\SocialMediaLinks\Iconset; - -use Drupal\social_media_links\IconsetBase; -use Drupal\social_media_links\IconsetInterface; - -/** - * Provides 'webtoolkit' iconset. - * - * @Iconset( - * id = "webtoolkit", - * name = "webtoolkit Icon Set", - * publisher = "webtoolkit4.me", - * publisherUrl = "http://webtoolkit4.me", - * downloadUrl = "http://webtoolkit4.me/2008/09/05/webtoolkit4me-releases-the-first-icon-set", - * ) - */ -class Webtoolkit extends IconsetBase implements IconsetInterface { - - /** - * {@inheritdoc} - */ - public function getStyle() { - return [ - '24' => '24x24', - '32' => '32x32', - '48' => '48x48', - '62' => '62x62', - ]; - } - - /** - * {@inheritdoc} - */ - public function getIconPath($icon_name, $style) { - return $this->path . '/PNG/' . $icon_name . '.png'; - } - -} diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Drupal.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Drupal.php old mode 100755 new mode 100644 diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Email.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Email.php index 007e59fcd9..2926d47525 100755 --- a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Email.php +++ b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Email.php @@ -4,7 +4,6 @@ use Drupal\social_media_links\PlatformBase; use Drupal\Core\Form\FormStateInterface; -use Egulias\EmailValidator\EmailValidator; use Drupal\Core\Url; /** @@ -29,9 +28,9 @@ public function getUrl() { */ public static function validateValue(array &$element, FormStateInterface $form_state, array $form) { if (!empty($element['#value'])) { - $validator = new EmailValidator(); + $validator = \Drupal::service('email.validator'); - if (!$validator->isValid($element['#value'], TRUE)) { + if (!$validator->isValid($element['#value'])) { $form_state->setError($element, t('The entered email address is not valid.')); } } diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Website.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Website.php new file mode 100644 index 0000000000..c53fcfc159 --- /dev/null +++ b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Website.php @@ -0,0 +1,39 @@ +<?php + +namespace Drupal\social_media_links\Plugin\SocialMediaLinks\Platform; + +use Drupal\Component\Utility\UrlHelper; +use Drupal\Core\Form\FormStateInterface; +use Drupal\social_media_links\PlatformBase; + +/** + * Provides 'website' platform. + * + * @Platform( + * id = "website", + * name = @Translation("Website"), + * ) + */ +class Website extends PlatformBase { + + /** + * {@inheritdoc} + */ + public static function validateValue(array &$element, FormStateInterface $form_state, array $form) { + if (!empty($element['#value'])) { + $default_protocol = 'http://'; + $new_value = $element['#value']; + + // Append the default protocol in case the user didn't add it. + if (!preg_match('/^http(s)?:\/\//', $new_value)) { + $new_value = $default_protocol . $new_value; + $form_state->setValueForElement($element, $new_value); + } + + if (!UrlHelper::isValid($new_value, TRUE)) { + $form_state->setError($element, t('The website must be a valid URL')); + } + } + } + +} diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Whatsapp.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Whatsapp.php new file mode 100644 index 0000000000..d3cb677152 --- /dev/null +++ b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Whatsapp.php @@ -0,0 +1,16 @@ +<?php + +namespace Drupal\social_media_links\Plugin\SocialMediaLinks\Platform; + +use Drupal\social_media_links\PlatformBase; + +/** + * Provides 'whatsapp' platform. + * + * @Platform( + * id = "whatsapp", + * name = @Translation("Whatsapp"), + * urlPrefix = "https://api.whatsapp.com/send?phone=", + * ) + */ +class Whatsapp extends PlatformBase {} diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Xing.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Xing.php new file mode 100644 index 0000000000..046e0a334b --- /dev/null +++ b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/Xing.php @@ -0,0 +1,16 @@ +<?php + +namespace Drupal\social_media_links\Plugin\SocialMediaLinks\Platform; + +use Drupal\social_media_links\PlatformBase; + +/** + * Provides 'xing' platform. + * + * @Platform( + * id = "xing", + * name = @Translation("Xing"), + * urlPrefix = "https://www.xing.com/", + * ) + */ +class Xing extends PlatformBase {} diff --git a/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php b/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php index 9538a3a609..e60bf95610 100755 --- a/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php +++ b/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php @@ -51,8 +51,9 @@ public function getPlatforms() { } /** - * Get all platform plugins and sort it by weight from - * platform settings (e.g. block configuration, field settings). + * Get all platform plugins and sort it by weight from. + * + * Platform settings (e.g. block configuration, field settings). * * @param array $settings * The configuration with the 'weight'. @@ -60,7 +61,7 @@ public function getPlatforms() { * @return array * The platform plugins sorted by weight setting. */ - public function getPlatformsSortedByWeight($settings) { + public function getPlatformsSortedByWeight(array $settings) { $default_weight = -10; $platforms = $this->getPlatforms(); @@ -85,9 +86,9 @@ public function getPlatformsWithValue(array $platforms, $sort = TRUE) { if (!empty($platforms[$platform_id]['value'])) { $platform['instance']->setValue($platforms[$platform_id]['value']); - if (!empty($platforms[$platform_id]['description'])) { - $platform['instance']->setDescription($platforms[$platform_id]['description']); - } + if (!empty($platforms[$platform_id]['description'])) { + $platform['instance']->setDescription($platforms[$platform_id]['description']); + } $usedPlatforms[$platform_id] = $platform; diff --git a/web/modules/social_media_links/templates/social-media-links-platforms.html.twig b/web/modules/social_media_links/templates/social-media-links-platforms.html.twig index 4c626e5c17..29adeabeb3 100644 --- a/web/modules/social_media_links/templates/social-media-links-platforms.html.twig +++ b/web/modules/social_media_links/templates/social-media-links-platforms.html.twig @@ -15,7 +15,7 @@ <ul{{ attributes.addClass(classes) }}> {% for platform in platforms %} <li> - <a href="{{ platform.url }}" {{ platform.attributes}} > + <a class="social-media-link-icon--{{ platform.id }}" href="{{ platform.url }}" {{ platform.attributes }} > {{ platform.element }} </a> @@ -24,7 +24,7 @@ <br /> {% endif %} - <span><a href="{{ platform.url }}" {{ link_attributes }}>{{ platform.name }}</a></span> + <span><a class="social-media-link--{{ platform.id }}" href="{{ platform.url }}" {{ platform.attributes }}>{{ platform.name }}</a></span> {% endif %} </li> {% endfor %} -- GitLab