diff --git a/composer.json b/composer.json index 61a74157167d60267801d134b60de727a5f587d6..16d38b0d150532a17623cba908af0f949d6cf4f8 100644 --- a/composer.json +++ b/composer.json @@ -171,7 +171,7 @@ "drupal/simplesamlphp_auth": "3.2", "drupal/smtp": "1.0", "drupal/social_media": "1.8", - "drupal/social_media_links": "^2.7", + "drupal/social_media_links": "^2.8", "drupal/superfish": "1.2", "drupal/svg_image": "1.14", "drupal/token": "1.9", diff --git a/composer.lock b/composer.lock index 67c9dbefa6446ce309776e167f47baa33ac845af..24c83e01f3237d1d6c70dd813c2339f864bbb508 100644 --- a/composer.lock +++ b/composer.lock @@ -7792,17 +7792,17 @@ }, { "name": "drupal/social_media_links", - "version": "2.7.0", + "version": "2.8.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/social_media_links.git", - "reference": "8.x-2.7" + "reference": "8.x-2.8" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/social_media_links-8.x-2.7.zip", - "reference": "8.x-2.7", - "shasum": "132db954d880c743bd6316f7fecd0b085bb73f91" + "url": "https://ftp.drupal.org/files/projects/social_media_links-8.x-2.8.zip", + "reference": "8.x-2.8", + "shasum": "7702fd4465c47767f6be0444015fa9bcdbfb1aa6" }, "require": { "drupal/core": "^8 || ^9" @@ -7810,8 +7810,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-2.7", - "datestamp": "1595616928", + "version": "8.x-2.8", + "datestamp": "1615222638", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" @@ -7832,8 +7832,9 @@ "role": "Maintainer" }, { - "name": "cbeier", - "homepage": "https://www.drupal.org/user/1500710" + "name": "Christian Beier", + "homepage": "https://www.drupal.org/u/cbeier", + "role": "Maintainer" } ], "description": "The module provides a block that display links (icons) to your profiles on various social networking sites.", diff --git a/web/modules/social_media_links/README.txt b/web/modules/social_media_links/README.txt index 4942b858c3cc7a93a55866bb05eda622ddcc4afa..10f0ec1242214209d317278364ed32a913bfc0ab 100755 --- a/web/modules/social_media_links/README.txt +++ b/web/modules/social_media_links/README.txt @@ -28,11 +28,12 @@ Install as normal (see http://drupal.org/documentation/install/modules-themes). CONFIGURATION -============ +------------ 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 + * Neslee Canil Pinto: https://www.drupal.org/u/neslee-canil-pinto + * Christian Beier: https://www.drupal.org/u/cbeier diff --git a/web/modules/social_media_links/composer.json b/web/modules/social_media_links/composer.json index d8ec9340f7ffb05b88d50fe7fe1bab6b2e1d69b0..04315ec360bbb319d13c666e23aa9d32f2a970ce 100644 --- a/web/modules/social_media_links/composer.json +++ b/web/modules/social_media_links/composer.json @@ -9,6 +9,11 @@ "name": "Neslee Canil Pinto", "homepage": "https://www.drupal.org/u/neslee-canil-pinto", "role": "Maintainer" + }, + { + "name": "Christian Beier", + "homepage": "https://www.drupal.org/u/cbeier", + "role": "Maintainer" } ], "support": { 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 845f399d6774c25f9e01b0b457643fdbaccd1c1c..672c6a45efbef6180768d433cf5867a813e9a4a0 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 @@ -7,7 +7,7 @@ core_version_requirement: ^8 || ^9 dependencies: - social_media_links:social_media_links -# Information added by Drupal.org packaging script on 2020-07-24 -version: '8.x-2.7' +# Information added by Drupal.org packaging script on 2021-03-08 +version: '8.x-2.8' project: 'social_media_links' -datestamp: 1595616930 +datestamp: 1615222641 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 74920d2bf92b32f60d11e374a0528a44add7a220..a384c3cfd2dd53f760f67e174c235507b9fc6d2f 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 @@ -109,7 +109,12 @@ protected static function platformElements(array $element, array $value) { '#default_value' => isset($value['value']) ? $value['value'] : '', '#field_prefix' => $selected_platform['instance']->getUrlPrefix(), '#field_suffix' => $selected_platform['instance']->getUrlSuffix(), - '#element_validate' => [[get_class($selected_platform['instance']), 'validateValue']], + '#element_validate' => [ + [ + get_class($selected_platform['instance']), + 'validateValue', + ], + ], ]; if (!empty($selected_platform['instance']->getFieldDescription())) { $element['value']['#description'] = $selected_platform['instance']->getFieldDescription(); 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 a34f4143e753069ae8aca6ff78bf77d79469aa2d..5403d1d95b499e99f5408e58f5236ceabf0d65ba 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 @@ -7,6 +7,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\social_media_links\IconsetBase; use Drupal\Core\Template\Attribute; +use Drupal\Core\StringTranslation\StringTranslationTrait; /** * Plugin implementation of the 'social_media_links_field_default' formatter. @@ -21,6 +22,8 @@ */ class SocialMediaLinksFieldDefaultFormatter extends FormatterBase { + use StringTranslationTrait; + /** * {@inheritdoc} */ @@ -149,11 +152,11 @@ public function settingsSummary() { $config['appearance']['show_name'] = 0; } - $orientation = $config['appearance']['orientation'] == 'v' ? t('vertical') : t('horizontal'); - $summary[] = t('Orientation: @orientation', ['@orientation' => $orientation]); + $orientation = $config['appearance']['orientation'] == 'v' ? $this->t('vertical') : $this->t('horizontal'); + $summary[] = $this->t('Orientation: @orientation', ['@orientation' => $orientation]); - $show_name = (isset($config['appearance']['show_name']) && $config['appearance']['show_name']) ? t('Yes') : t('No'); - $summary[] = t('Show name: @show_name', ['@show_name' => $show_name]); + $show_name = (isset($config['appearance']['show_name']) && $config['appearance']['show_name']) ? $this->t('Yes') : $this->t('No'); + $summary[] = $this->t('Show name: @show_name', ['@show_name' => $show_name]); return $summary; } @@ -176,7 +179,7 @@ protected function getPlatformsWithValues(FieldItemListInterface $items) { } $platforms = []; - foreach ($items as $delta => $item) { + foreach ($items as $item) { // 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 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 2b03da1a12fbc2d74c06af0292256eb85556ec14..fd12a19b033d7d7e023f5e82332c0755cc84b245 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 @@ -139,7 +139,10 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { '#title_display' => 'invisible', '#default_value' => $platform['weight'], '#attributes' => [ - 'class' => ['platform-order-weight', 'platform-order-weight-' . $platform_id], + 'class' => [ + 'platform-order-weight', + 'platform-order-weight-' . $platform_id, + ], ], // Delta: We need to use the max weight + number of platforms, // because if they get re-ordered it could start the count again from 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 2c74e0b0ed90d9e934345368fbb7e494ef34e04b..88e8c316565b29875977f4ebdd51fe04947955af 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 @@ -5,7 +5,7 @@ use Drupal\Core\Field\WidgetBase; /** - * Class SocialMediaLinksFieldBaseWidget. + * It allows to link social media. */ abstract class SocialMediaLinksFieldBaseWidget extends WidgetBase { @@ -54,7 +54,10 @@ protected function getAvailablePlatforms() { } } - uasort($available_platforms, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); + uasort($available_platforms, [ + 'Drupal\Component\Utility\SortArray', + 'sortByWeightElement', + ]); return $available_platforms; } 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 172f9778a243cced8afa563dacf3a6d1f0d10830..732ec5beccf492ccd39b9353213044359f182c96 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 @@ -23,7 +23,7 @@ class SocialMediaLinksFieldDefaultWidget extends SocialMediaLinksFieldBaseWidget */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $item = $items[$delta]; - $value = $item->getEntity()->isNew() ? [] : $item->toArray(); + $value = $item->toArray(); $element += [ '#type' => 'details', @@ -39,7 +39,12 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#default_value' => isset($value['platform_values'][$platform_id]['value']) ? $value['platform_values'][$platform_id]['value'] : '', '#field_prefix' => $platform['instance']->getUrlPrefix(), '#field_suffix' => $platform['instance']->getUrlSuffix(), - '#element_validate' => [[get_class($platform['instance']), 'validateValue']], + '#element_validate' => [ + [ + get_class($platform['instance']), + 'validateValue', + ], + ], ]; if (!empty($platform['instance']->getFieldDescription())) { $element['platform_values'][$platform_id]['value']['#description'] = $platform['instance']->getFieldDescription(); 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 28dd48c6b9a7624c6343f1d5a1024a5d6e5368ef..efe04842143c8b04bdc18da65cd23a97655f1ee2 100644 --- a/web/modules/social_media_links/social_media_links.info.yml +++ b/web/modules/social_media_links/social_media_links.info.yml @@ -4,7 +4,7 @@ type: module core: 8.x core_version_requirement: ^8 || ^9 -# Information added by Drupal.org packaging script on 2020-07-24 -version: '8.x-2.7' +# Information added by Drupal.org packaging script on 2021-03-08 +version: '8.x-2.8' project: 'social_media_links' -datestamp: 1595616930 +datestamp: 1615222641 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 cd2f249ee108760401d35681ed17f19abd0f029c..71ee867c15f62950d5374f812fe8f9a24aa81486 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 } + //maxcdn.bootstrapcdn.com/font-awesome/4.6.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 4286f20e0e608b2e437b7399b4ade6fa248fc966..48825f2024eec018b15cefdec34662dc19746337 100644 --- a/web/modules/social_media_links/social_media_links.module +++ b/web/modules/social_media_links/social_media_links.module @@ -21,6 +21,20 @@ function social_media_links_theme($existing, $type, $theme, $path) { ]; } +/** + * Implements hook_theme_suggestions_HOOK() for "social_media_links_platforms". + */ +function social_media_links_theme_suggestions_social_media_links_platforms(array $variables) { + $suggestions = []; + + // If there is a custom suggestion add it to our base suggestion. + if (!empty($variables['appearance']['suggestion'])) { + $suggestions[] = 'social_media_links_platforms__' . $variables['appearance']['suggestion']; + } + + return $suggestions; +} + /** * Implements hook_preprocess_HOOK() for block.html.twig. */ 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 9a8b61444b2a9f9cf836cd5f843b09b81d7c9d2d..ee03f5aa868ceeb899024644f8b8c9de144a3668 100755 --- a/web/modules/social_media_links/src/Plugin/Block/SocialMediaLinksBlock.php +++ b/web/modules/social_media_links/src/Plugin/Block/SocialMediaLinksBlock.php @@ -128,7 +128,12 @@ public function blockForm($form, FormStateInterface $form_state) { '#default_value' => isset($config['platforms'][$platform_id]['value']) ? $config['platforms'][$platform_id]['value'] : '', '#field_prefix' => $platform['instance']->getUrlPrefix(), '#field_suffix' => $platform['instance']->getUrlSuffix(), - '#element_validate' => [[get_class($platform['instance']), 'validateValue']], + '#element_validate' => [ + [ + get_class($platform['instance']), + 'validateValue', + ], + ], ]; if (!empty($platform['instance']->getFieldDescription())) { $form['platforms'][$platform_id]['value']['#description'] = $platform['instance']->getFieldDescription(); @@ -177,6 +182,18 @@ public function blockForm($form, FormStateInterface $form_state) { '#description' => $this->t('Show the platform name next to the icon.'), '#default_value' => isset($config['appearance']['show_name']) ? $config['appearance']['show_name'] : 0, ]; + $form['appearance']['suggestion'] = [ + '#type' => 'machine_name', + '#title' => $this->t('Theme hook suggestion'), + '#default_value' => isset($config['appearance']['suggestion']) ? $config['appearance']['suggestion'] : '', + '#required' => FALSE, + '#field_prefix' => '<code>social_media_links_platforms__</code>', + '#description' => $this->t('A theme hook suggestion can be used to override the default HTML and CSS found in <code>social-media-links-platforms.html</code>.'), + '#machine_name' => [ + 'error' => $this->t('The theme hook suggestion must contain only lowercase letters, numbers, and underscores.'), + 'exists' => [$this, 'suggestionExists'], + ], + ]; // Link Attributes. $form['link_attributes'] = [ @@ -291,7 +308,7 @@ public function blockForm($form, FormStateInterface $form_state) { foreach ($installDirs as $dir) { $installDirsIconset[] = $dir . '/' . $iconset_id; } - $examples .= '<br /><code>' . preg_replace('/,([^,]+) ?$/', " " . $this->t('or') . " $1", implode(',<br />', $installDirsIconset), 1) . '</code>'; + $examples .= '<br /><code>' . preg_replace('/,([^,]+) ?$/', " " . 'or' . " $1", implode(',<br />', $installDirsIconset), 1) . '</code>'; $installedIconsets[$iconset_id]['examples'] = [ '#markup' => $examples, @@ -303,7 +320,10 @@ public function blockForm($form, FormStateInterface $form_state) { } // Sort the array so that installed iconsets shown first. - uasort($installedIconsets, ['Drupal\Component\Utility\SortArray', 'sortByWeightProperty']); + uasort($installedIconsets, [ + 'Drupal\Component\Utility\SortArray', + 'sortByWeightProperty', + ]); $form['iconset']['installed_iconsets'] = [ '#type' => 'table', @@ -369,8 +389,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', $this->t($platform['instance']->getDescription())); - $platforms[$platform_id]['attributes']->setAttribute('title', $this->t(($platform['instance']->getDescription()))); + $platforms[$platform_id]['attributes']->setAttribute('aria-label', $platform['instance']->getDescription()); + $platforms[$platform_id]['attributes']->setAttribute('title', $platform['instance']->getDescription()); } } @@ -390,4 +410,14 @@ public function build() { return [$output]; } + /** + * Checks for an existing theme hook suggestion. + * + * @return bool + * Returns FALSE because there is no need of validation by unique value. + */ + public function suggestionExists() { + return FALSE; + } + } diff --git a/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/GitLab.php b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/GitLab.php new file mode 100644 index 0000000000000000000000000000000000000000..e1a215a48491356657c82f8bf1dde44912f36a94 --- /dev/null +++ b/web/modules/social_media_links/src/Plugin/SocialMediaLinks/Platform/GitLab.php @@ -0,0 +1,16 @@ +<?php + +namespace Drupal\social_media_links\Plugin\SocialMediaLinks\Platform; + +use Drupal\social_media_links\PlatformBase; + +/** + * Provides 'gitlab' platform. + * + * @Platform( + * id = "gitlab", + * name = @Translation("GitLab"), + * urlPrefix = "https://gitlab.com/", + * ) + */ +class GitLab extends PlatformBase {} diff --git a/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php b/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php index e60bf95610a12008d65b3ed7e1cb79aaf61eebd0..47b569e298e0f729dcfc4470dc40f8d7f8f8e5f5 100755 --- a/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php +++ b/web/modules/social_media_links/src/SocialMediaLinksPlatformManager.php @@ -69,7 +69,10 @@ public function getPlatformsSortedByWeight(array $settings) { $platforms[$platform_id]['weight'] = isset($settings['platforms'][$platform_id]['weight']) ? $settings['platforms'][$platform_id]['weight'] : $default_weight++; } - uasort($platforms, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); + uasort($platforms, [ + 'Drupal\Component\Utility\SortArray', + 'sortByWeightElement', + ]); return $platforms; } @@ -98,7 +101,10 @@ public function getPlatformsWithValue(array $platforms, $sort = TRUE) { } if ($sort) { - uasort($usedPlatforms, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); + uasort($usedPlatforms, [ + 'Drupal\Component\Utility\SortArray', + 'sortByWeightElement', + ]); } return $usedPlatforms;