diff --git a/composer.json b/composer.json index 2793757b257629bb013c315f2ece2f7b5bb678c7..c869eeb430e5b7f185c7ab2f3e874d69cd8be6d1 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 02a1272989f72014f285d4ddbb20ef1445488a22..92a4edf7899aec518376953cfa888175bad1cbb7 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 e2bf6c5bc53d1bce6fde88380f7b62e550cab7a4..d288092e22f27f6bdf6f903d4875e756e11220c8 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 417d56266f46bce41e7df9867128b6902c61058a..4942b858c3cc7a93a55866bb05eda622ddcc4afa 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 2d341f808a773ed61167b1a65b2c24ffadcb7a8b..d8ec9340f7ffb05b88d50fe7fe1bab6b2e1d69b0 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 b6a90eea47c07ade8385d0cce15242ce818ad1df..1c0e1d0967f3fc97db1a1c08f2925777ce4d06a7 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 9d0a912e959a668106e2b6540c5e20674998176e..845f399d6774c25f9e01b0b457643fdbaccd1c1c 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 42b637adf0d7892d9fea67ace0a7788006511b50..74920d2bf92b32f60d11e374a0528a44add7a220 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 e8f30056c1b3493c8af6dd17013be6174c086d65..a34f4143e753069ae8aca6ff78bf77d79469aa2d 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 f20d6c118cd00eee1aeb2087ced4b3fa5687c944..2b03da1a12fbc2d74c06af0292256eb85556ec14 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 1cc5b578c593a5a4aee068cc564439574fe312d7..2c74e0b0ed90d9e934345368fbb7e494ef34e04b 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 61756466da4e38dcdac3718a982a8f1fb080154b..172f9778a243cced8afa563dacf3a6d1f0d10830 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 3098ded82fa16a81b577f0528b297f7573217c2c..bbfdbd71f3f0467dda4fbce37282269042bcff4c 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 b4f4de5d85a0f8ca045ebb4a6b7fda81caa6bed6..28dd48c6b9a7624c6343f1d5a1024a5d6e5368ef 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 2a378fc41eda931530b62431654e4d7ebeb9a5be..cd2f249ee108760401d35681ed17f19abd0f029c 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 a2cd1b64310bcc8fa4881222d112fc13c240179f..4286f20e0e608b2e437b7399b4ade6fa248fc966 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 6c6f74b4c82a809f81127b008c0102596688af49..ab6cdb8414c9a65072bf08b2201e75f98b7d36fc 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 5bbd7e715db4acd9a1610ace7fa508bbdf05df39..f20db4c28e409ab4165ee08e510884359f9194c7 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 462d75833ce0317f75dc07c2ad90b8fa2fa07bda..4c347d7a979a456d1af8bd92e5d93d42c160b84b 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 2a499be13a2cc722bd2b36e4f40e5d34f54d8da5..6dc38a6ddf6a69864a7028e5b01727a24ef5dd3e 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 96b9822a9da6e7564798a3c76b673f61132173d0..4a1d6f1150bb536e7352472f44aa915956c22f24 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 419a59753a0f865b7142ec2f3bd2a7d7966a3180..9a8b61444b2a9f9cf836cd5f843b09b81d7c9d2d 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 001df1729a19be2b623109f5b79faddef0005341..d293cb3f69c3a1d0e44b9b1602435081a3b08f8c 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 80f17f9864fe11d21c9be59f3e78bd956c4e9e87..0000000000000000000000000000000000000000 --- 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 007e59fcd95004e171c95fd30787eb89566abe0b..2926d47525badfb65ff2d5f34a399298b2599675 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 0000000000000000000000000000000000000000..c53fcfc15914c0df947f0d38622f66b4218d5890 --- /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 0000000000000000000000000000000000000000..d3cb6771522c0a9707d176d265e034ff2df276cf --- /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 0000000000000000000000000000000000000000..046e0a334b12265c2da5b74bce9defcca4cffbde --- /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 9538a3a6096efcf0772912ded9a4772b9b67a017..e60bf95610a12008d65b3ed7e1cb79aaf61eebd0 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 4c626e5c17b60bcf7bdd0192c578f656141eef3c..29adeabeb3f729c06818267945e0fcfa077b76cb 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 %}