diff --git a/composer.json b/composer.json index 2793757b257629bb013c315f2ece2f7b5bb678c7..dcefedb6fbd9314023ba7cafca427a8c4289909b 100644 --- a/composer.json +++ b/composer.json @@ -129,7 +129,7 @@ "drupal/google_tag": "1.4", "drupal/honeypot": "1.30", "drupal/image_popup": "1.1", - "drupal/inline_entity_form": "1.0-rc6", + "drupal/inline_entity_form": "1.0-rc7", "drupal/libraries": "3.0.0-alpha1", "drupal/link_attributes": "1.10", "drupal/linkit": "5.0-beta11", @@ -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", @@ -173,7 +173,7 @@ "drupal/twitter_block": "3.0-alpha0", "drupal/userprotect": "1.1", "drupal/video_embed_field": "2.4", - "drupal/view_unpublished": "1.0-rc2", + "drupal/view_unpublished": "1.0-rc3", "drupal/views_accordion": "1.1", "drupal/views_ajax_history": "1.5", "drupal/views_autocomplete_filters": "1.3", diff --git a/composer.lock b/composer.lock index 02a1272989f72014f285d4ddbb20ef1445488a22..a1d683c8cd7b0129e8d536da6534b4f68f9ccf4e 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": "ddbe24a300d65c01135366f63acfe8fd", "packages": [ { "name": "alchemy/zippy", @@ -5313,17 +5313,17 @@ }, { "name": "drupal/inline_entity_form", - "version": "1.0.0-rc6", + "version": "1.0.0-rc7", "source": { "type": "git", "url": "https://git.drupalcode.org/project/inline_entity_form.git", - "reference": "8.x-1.0-rc6" + "reference": "8.x-1.0-rc7" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc6.zip", - "reference": "8.x-1.0-rc6", - "shasum": "9f7508f4cb88d5e7869c81b20b44d89bc1689fad" + "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc7.zip", + "reference": "8.x-1.0-rc7", + "shasum": "a11e59a8f3632728165170e9337cec9bc8eab870" }, "require": { "drupal/core": "^8.7.7 || ^9" @@ -5334,8 +5334,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0-rc6", - "datestamp": "1589280847", + "version": "8.x-1.0-rc7", + "datestamp": "1595545223", "security-coverage": { "status": "not-covered", "message": "RC releases are not covered by Drupal security advisories." @@ -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" } }, @@ -7934,17 +7936,17 @@ }, { "name": "drupal/view_unpublished", - "version": "1.0.0-rc2", + "version": "1.0.0-rc3", "source": { "type": "git", "url": "https://git.drupalcode.org/project/view_unpublished.git", - "reference": "8.x-1.0-rc2" + "reference": "8.x-1.0-rc3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.0-rc2.zip", - "reference": "8.x-1.0-rc2", - "shasum": "673b2a76176b68b5f27affd4c2a718c2eaa45764" + "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.0-rc3.zip", + "reference": "8.x-1.0-rc3", + "shasum": "6973708d48b76531fa9227d8b959a516e1cb9129" }, "require": { "drupal/core": "^8 || ^9" @@ -7952,8 +7954,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0-rc2", - "datestamp": "1593633641", + "version": "8.x-1.0-rc3", + "datestamp": "1595646359", "security-coverage": { "status": "not-covered", "message": "RC releases are not covered by Drupal security advisories." diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e2bf6c5bc53d1bce6fde88380f7b62e550cab7a4..79aaa30d67653b322fecf41e8126b48c9e22db11 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -5473,18 +5473,18 @@ }, { "name": "drupal/inline_entity_form", - "version": "1.0.0-rc6", - "version_normalized": "1.0.0.0-RC6", + "version": "1.0.0-rc7", + "version_normalized": "1.0.0.0-RC7", "source": { "type": "git", "url": "https://git.drupalcode.org/project/inline_entity_form.git", - "reference": "8.x-1.0-rc6" + "reference": "8.x-1.0-rc7" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc6.zip", - "reference": "8.x-1.0-rc6", - "shasum": "9f7508f4cb88d5e7869c81b20b44d89bc1689fad" + "url": "https://ftp.drupal.org/files/projects/inline_entity_form-8.x-1.0-rc7.zip", + "reference": "8.x-1.0-rc7", + "shasum": "a11e59a8f3632728165170e9337cec9bc8eab870" }, "require": { "drupal/core": "^8.7.7 || ^9" @@ -5495,8 +5495,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0-rc6", - "datestamp": "1589280847", + "version": "8.x-1.0-rc7", + "datestamp": "1595545223", "security-coverage": { "status": "not-covered", "message": "RC releases are not covered by Drupal security advisories." @@ -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" } }, @@ -8181,18 +8183,18 @@ }, { "name": "drupal/view_unpublished", - "version": "1.0.0-rc2", - "version_normalized": "1.0.0.0-RC2", + "version": "1.0.0-rc3", + "version_normalized": "1.0.0.0-RC3", "source": { "type": "git", "url": "https://git.drupalcode.org/project/view_unpublished.git", - "reference": "8.x-1.0-rc2" + "reference": "8.x-1.0-rc3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.0-rc2.zip", - "reference": "8.x-1.0-rc2", - "shasum": "673b2a76176b68b5f27affd4c2a718c2eaa45764" + "url": "https://ftp.drupal.org/files/projects/view_unpublished-8.x-1.0-rc3.zip", + "reference": "8.x-1.0-rc3", + "shasum": "6973708d48b76531fa9227d8b959a516e1cb9129" }, "require": { "drupal/core": "^8 || ^9" @@ -8200,8 +8202,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "8.x-1.0-rc2", - "datestamp": "1593633641", + "version": "8.x-1.0-rc3", + "datestamp": "1595646359", "security-coverage": { "status": "not-covered", "message": "RC releases are not covered by Drupal security advisories." diff --git a/web/modules/inline_entity_form/inline_entity_form.info.yml b/web/modules/inline_entity_form/inline_entity_form.info.yml index 5958676d6f4298b355c0bb242ac05628439bd386..666ff00c9c7068a419d2347cf8ff1525c4f30763 100644 --- a/web/modules/inline_entity_form/inline_entity_form.info.yml +++ b/web/modules/inline_entity_form/inline_entity_form.info.yml @@ -4,7 +4,7 @@ type: module package: Fields core_version_requirement: ^8.7.7 || ^9 -# Information added by Drupal.org packaging script on 2020-05-12 -version: '8.x-1.0-rc6' +# Information added by Drupal.org packaging script on 2020-07-23 +version: '8.x-1.0-rc7' project: 'inline_entity_form' -datestamp: 1589280849 +datestamp: 1595545225 diff --git a/web/modules/inline_entity_form/inline_entity_form.module b/web/modules/inline_entity_form/inline_entity_form.module index 7e1e50803e25e4851b2264c2ad599baab4d906e3..d535200ce717b0a883830e1d301c4dd12167037e 100644 --- a/web/modules/inline_entity_form/inline_entity_form.module +++ b/web/modules/inline_entity_form/inline_entity_form.module @@ -51,7 +51,6 @@ function inline_entity_form_theme() { return [ 'inline_entity_form_entity_table' => [ 'render element' => 'form', - 'function' => 'theme_inline_entity_form_entity_table', ], ]; } @@ -317,13 +316,15 @@ function inline_entity_form_get_element($form, FormStateInterface $form_state) { } /** - * Themes the table showing existing entity references in the widget. + * Prepares variables for inline_entity_form_entity_table form templates. + * + * Default template: inline-entity-form-entity-table.html.twig. * * @param array $variables - * Contains the form element data from $element['entities']. + * An associative array containing: + * - form: A render element representing the form. */ -function theme_inline_entity_form_entity_table($variables) { - $renderer = \Drupal::service('renderer'); +function template_preprocess_inline_entity_form_entity_table(array &$variables) { $form = $variables['form']; $entity_type = $form['#entity_type']; @@ -359,8 +360,8 @@ function theme_inline_entity_form_entity_table($variables) { $row_classes = ['ief-row-entity']; $cells = []; if ($has_tabledrag) { - $cells[] = ['data' => '', 'class' => ['ief-tabledrag-handle']]; - $cells[] = $renderer->render($form[$key]['delta']); + $cells[] = ['data' => ['#plain_text' => ''], '#wrapper_attributes' => ['class' => ['ief-tabledrag-handle']]]; + $cells[] = ['data' => $form[$key]['delta']]; $row_classes[] = 'draggable'; } // Add a special class to rows that have a form underneath, to allow @@ -371,7 +372,7 @@ function theme_inline_entity_form_entity_table($variables) { foreach ($fields as $field_name => $field) { if ($field['type'] == 'label') { - $data = $variables['form'][$key]['#label']; + $data = ['#markup' => $variables['form'][$key]['#label']]; } elseif ($field['type'] == 'field' && $entity->hasField($field_name)) { $display_options = ['label' => 'hidden']; @@ -390,24 +391,30 @@ function theme_inline_entity_form_entity_table($variables) { } $data = call_user_func_array($field['callback'], $arguments); + + // Backward compatibility for callbacks that just provide a string not an array. + if(!is_array($data)) { + $data = ['#markup' => $data]; + } } else { - $data = t('N/A'); + $data = ['#markup' => t('N/A')]; } - $cells[] = ['data' => $data, 'class' => ['inline-entity-form-' . $entity_type . '-' . $field_name]]; + $cells[$field_name] = array_merge($data, ['#wrapper_attributes' => ['class' => ['inline-entity-form-' . $entity_type . '-' . $field_name]]]); } - // Add the buttons belonging to the "Operations" column. - $cells[] = $renderer->render($form[$key]['actions']); + // Add the buttons belonging to the "Operations" column, when entity is not + // being displayed as a form. + if (empty($form[$key]['form'])) { + $cells['actions'] = $form[$key]['actions']; + } // Create the row. - $rows[] = ['data' => $cells, 'class' => $row_classes]; + $rows[] = $cells + ['#attributes' => ['class' => $row_classes]]; // If the current entity array specifies a form, output it in the next row. if (!empty($form[$key]['form'])) { - $row = [ - ['data' => $renderer->render($form[$key]['form']), 'colspan' => count($fields) + 1], - ]; - $rows[] = ['data' => $row, 'class' => ['ief-row-form'], 'no_striping' => TRUE]; + $row[] = $form[$key]['form'] + ['#wrapper_attributes' => ['colspan' => count($fields) + 1]]; + $rows[] = $row + ['#attributes' => ['class' => ['ief-row-form'], 'no_striping' => TRUE]]; } } @@ -423,17 +430,14 @@ function theme_inline_entity_form_entity_table($variables) { ]; } - $table = [ + $variables['table'] = [ '#type' => 'table', '#header' => $header, - '#rows' => $rows, '#attributes' => [ 'id' => 'ief-entity-table-' . $form['#id'], 'class' => ['ief-entity-table'], ], '#tabledrag' => $tabledrag, - ]; - - return $renderer->render($table); + ] + $rows; } } diff --git a/web/modules/inline_entity_form/src/InlineFormInterface.php b/web/modules/inline_entity_form/src/InlineFormInterface.php index f7b0b2a552cf7186a1931a803616b8d7072660db..5bbd02dba8453b6a178206ea1a96d3298004a526 100644 --- a/web/modules/inline_entity_form/src/InlineFormInterface.php +++ b/web/modules/inline_entity_form/src/InlineFormInterface.php @@ -60,7 +60,8 @@ public function getEntityLabel(EntityInterface $entity); * - 'field': A field value from the entity. The name of the field is * given by the key in this array. * - 'callback': A callback, given by the 'callback' property. - * See theme_inline_entity_form_entity_table() for the handling of these. + * @see template_preprocess_inline_entity_form_entity_table() for the + * handling of these. * - label: the title of the table field's column in the IEF table. * - weight: the sort order of the column in the IEF table. * - display_options: (optional) used for 'field' type table columns, an diff --git a/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php b/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php index a4b2c306b8ec9d6c5daa000a02f1c45972f93c14..39f1da583578e569b5e476336ab817b92f8a4251 100644 --- a/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php +++ b/web/modules/inline_entity_form/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php @@ -279,7 +279,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $weight_delta = max(ceil($entities_count * 1.2), 50); foreach ($entities as $key => $value) { - // Data used by theme_inline_entity_form_entity_table(). + // Data used by inline-entity-form-entity-table.html.twig. + // @see template_preprocess_inline_entity_form_entity_table() /** @var \Drupal\Core\Entity\EntityInterface $entity */ $entity = $value['entity']; $element['entities'][$key]['#label'] = $this->inlineFormHandler->getEntityLabel($value['entity']); diff --git a/web/modules/inline_entity_form/templates/inline-entity-form-entity-table.html.twig b/web/modules/inline_entity_form/templates/inline-entity-form-entity-table.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..67c1718f895face04b358fc3175820906514593c --- /dev/null +++ b/web/modules/inline_entity_form/templates/inline-entity-form-entity-table.html.twig @@ -0,0 +1,15 @@ +{# +/** + * @file + * Default theme implementation for a theme's inline_entity_form_entity_table form. + * + * Available variables: + * - form: Form elements for the inline_entity_form_entity_table form. + * - table: The table of referenced entities. + * + * @see template_preprocess_inline_entity_form_entity_table() + * + * @ingroup themeable + */ +#} +{{ table }} diff --git a/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml b/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml index 254568bd5a6c6e5d5d628a4b543dc7bf87973336..fdf1e3544acf4a98cb8773c4ea02b115cc96a924 100644 --- a/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml +++ b/web/modules/inline_entity_form/tests/modules/inline_entity_form_test/inline_entity_form_test.info.yml @@ -9,7 +9,7 @@ dependencies: - drupal:file - drupal:image -# Information added by Drupal.org packaging script on 2020-05-12 -version: '8.x-1.0-rc6' +# Information added by Drupal.org packaging script on 2020-07-23 +version: '8.x-1.0-rc7' project: 'inline_entity_form' -datestamp: 1589280849 +datestamp: 1595545225 diff --git a/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml b/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml index 8f46dfe35d24dd2c9cd624be009d12434e6e272e..372f1dd28011f506e2dd50cc1d7b8b4e7622da4a 100644 --- a/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml +++ b/web/modules/inline_entity_form/tests/modules/inline_entity_form_translation_test/inline_entity_form_translation_test.info.yml @@ -8,7 +8,7 @@ dependencies: - drupal:language - drupal:content_translation -# Information added by Drupal.org packaging script on 2020-05-12 -version: '8.x-1.0-rc6' +# Information added by Drupal.org packaging script on 2020-07-23 +version: '8.x-1.0-rc7' project: 'inline_entity_form' -datestamp: 1589280849 +datestamp: 1595545225 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 %} diff --git a/web/modules/view_unpublished/src/Plugin/views/filter/NodeStatus.php b/web/modules/view_unpublished/src/Plugin/views/filter/NodeStatus.php index 8fe9c814eead160ff821d63af91b2924c19244ce..073732894c644867d33b4a2ef3e158f5100b6089 100644 --- a/web/modules/view_unpublished/src/Plugin/views/filter/NodeStatus.php +++ b/web/modules/view_unpublished/src/Plugin/views/filter/NodeStatus.php @@ -4,7 +4,6 @@ use Drupal\node\Entity\NodeType; use Drupal\node\Plugin\views\filter\Status; -use Drupal\views\Annotation\ViewsFilter; /** * Filter by view all unpublished permissions granted by view_unpublished. @@ -12,8 +11,6 @@ * Takes over the Published or Admin filter query. * * @ingroup views_filter_handlers - * - * @ViewsFilter("view_unpublished_node_status") */ class NodeStatus extends Status { diff --git a/web/modules/view_unpublished/src/ViewUnpublishedInstallHelper.php b/web/modules/view_unpublished/src/ViewUnpublishedInstallHelper.php new file mode 100644 index 0000000000000000000000000000000000000000..de63ec48c550596828c92328b6ff6842de5445ee --- /dev/null +++ b/web/modules/view_unpublished/src/ViewUnpublishedInstallHelper.php @@ -0,0 +1,80 @@ +<?php + +namespace Drupal\view_unpublished; + +use Drupal\Core\Config\CachedStorage; +use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; + +/** + * Class ViewUnpublishedInstallHelper. + */ +class ViewUnpublishedInstallHelper { + + /** + * Drupal\Core\Config\ConfigFactoryInterface definition. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + + /** + * Drupal\Core\Config\CachedStorage definition. + * + * @var \Drupal\Core\Config\CachedStorage + */ + protected $configStorage; + + /** + * Drupal\Core\Entity\EntityTypeManagerInterface definition. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * Constructs a new ViewUnpublishedInstallHelper object. + * + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager service. + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory + * The config factory service. + * @param \Drupal\Core\Config\CachedStorage $config_storage + * The config storage service. + */ + public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, CachedStorage $config_storage) { + $this->entityTypeManager = $entity_type_manager; + $this->configFactory = $config_factory; + $this->configStorage = $config_storage; + } + + /** + * Helper that flags node_access to be rebuilt if unpublished nodes exist. + */ + public function flagRebuild() { + $query = $this->entityTypeManager->getStorage('node')->getQuery(); + $count_unpublished = (int) $query->condition('status', FALSE)->count()->execute(); + if ($count_unpublished > 0) { + node_access_needs_rebuild(TRUE); + } + } + + /** + * Remove the errant view_unpublished dependency from Views. + */ + public function removeDependency() { + + $view_names = $this->configStorage->listAll('views.view'); + foreach ($view_names as $name) { + $dependencies = $this->configFactory->get($name)->get('dependencies.module'); + if (!empty($dependencies) && array_key_exists('view_unpublished', array_flip($dependencies))) { + $dependencies = array_diff($dependencies, ['view_unpublished']); + $this->configFactory + ->getEditable($name) + ->set('dependencies.module', $dependencies) + ->save(TRUE); + } + } + } + +} diff --git a/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php b/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php index 6f553f9dca11b7b3cee51bff01840d0938f8aed0..f44640dc2507b24041767a2b44e8902e0f6d4deb 100644 --- a/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php +++ b/web/modules/view_unpublished/tests/src/Functional/ViewUnpublishedViewsTest.php @@ -46,10 +46,10 @@ protected function setUp() { */ public function testIt() { $page_node = $this->createNode(['type' => 'page']); - $page_node->setPublished(FALSE); + $page_node->setUnPublished(); $page_node->save(); $article_node = $this->createNode(['type' => 'article']); - $article_node->setPublished(FALSE); + $article_node->setUnPublished(); $article_node->save(); $this->drupalLogin($this->createUser(['view any unpublished content', 'access content overview'])); diff --git a/web/modules/view_unpublished/tests/src/Kernel/ViewUnpublishedDependencyTest.php b/web/modules/view_unpublished/tests/src/Kernel/ViewUnpublishedDependencyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b43938a72257a0a646238bb5fa6200f55000b404 --- /dev/null +++ b/web/modules/view_unpublished/tests/src/Kernel/ViewUnpublishedDependencyTest.php @@ -0,0 +1,69 @@ +<?php + +namespace Drupal\Tests\view_unpublished\Kernel; + +use Drupal\KernelTests\KernelTestBase; +use Drupal\views\Views; + +/** + * Tests the View Unpublished dependency issue. + * + * @group view_unpublished + */ +class ViewUnpublishedDependencyTest extends KernelTestBase { + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = [ + 'field', + 'node', + 'system', + 'text', + 'user', + 'view_unpublished', + 'views', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + $this->installEntitySchema('user'); + $this->installEntitySchema('node'); + $this->installConfig('node'); + } + + /** + * Tests view_unpublished not added as dependency of content view. + */ + public function testDependencyNotAdded() { + // Check dependency before saving. + $module_deps = $this->config('views.view.content')->get('dependencies.module'); + $this->assertArrayNotHasKey('view_unpublished', array_flip($module_deps)); + + // Save and check again. + $view = Views::getView('content'); + $view->save(); + $module_deps = $this->config('views.view.content')->get('dependencies.module'); + $this->assertArrayNotHasKey('view_unpublished', array_flip($module_deps)); + } + + /** + * Tests the remove dependency install helper. + */ + public function testDependencyRemoved() { + $module_deps = $this->config('views.view.content')->get('dependencies.module'); + $module_deps[] = 'view_unpublished'; + $this->config('views.view.content')->set('dependencies.module', $module_deps)->save(TRUE); + $this->container->get('view_unpublished.install_helper')->removeDependency(); + $module_deps = $this->config('views.view.content')->get('dependencies.module'); + $this->assertNotEmpty($module_deps); + $this->assertArrayNotHasKey('view_unpublished', array_flip($module_deps)); + } + +} diff --git a/web/modules/view_unpublished/view_unpublished.info.yml b/web/modules/view_unpublished/view_unpublished.info.yml index 1030f2667ba84f30ec0215cdd5a7a510a40f7975..ce33c2b77c31f57e39a9855ea3da7a695f66969c 100644 --- a/web/modules/view_unpublished/view_unpublished.info.yml +++ b/web/modules/view_unpublished/view_unpublished.info.yml @@ -7,7 +7,7 @@ type: module dependencies: - drupal:node -# Information added by Drupal.org packaging script on 2020-07-01 -version: '8.x-1.0-rc2' +# Information added by Drupal.org packaging script on 2020-07-25 +version: '8.x-1.0-rc3' project: 'view_unpublished' -datestamp: 1593633642 +datestamp: 1595646337 diff --git a/web/modules/view_unpublished/view_unpublished.install b/web/modules/view_unpublished/view_unpublished.install index d8cc7b703fd3a8b7f76ec9e72dc7ef4e1f448827..2792f8d2baf01d21310b693ca26ebb837dc9158a 100644 --- a/web/modules/view_unpublished/view_unpublished.install +++ b/web/modules/view_unpublished/view_unpublished.install @@ -11,25 +11,16 @@ * Implements hook_install(). */ function view_unpublished_install() { - _view_unpublished_flag_rebuild_if_needed(); + Drupal::service('view_unpublished.install_helper')->flagRebuild(); } /** * Implements hook_uninstall(). */ function view_unpublished_uninstall() { - _view_unpublished_flag_rebuild_if_needed(); -} - -/** - * Helper that flags node_access to be rebuilt if unpublished nodes exist. - */ -function _view_unpublished_flag_rebuild_if_needed() { - $query = \Drupal::entityTypeManager()->getStorage('node')->getQuery(); - $count_unpublished = (int) $query->condition('status', FALSE)->count()->execute(); - if ($count_unpublished > 0) { - node_access_needs_rebuild(TRUE); - } + Drupal::service('view_unpublished.install_helper')->flagRebuild(); + // Remove any errant view_unpublished dependency. + Drupal::service('view_unpublished.install_helper')->removeDependency(); } /** @@ -45,3 +36,10 @@ function view_unpublished_update_8001() { [':rebuild' => Url::fromRoute('node.configure_rebuild_confirm')->toString()] ); } + +/** + * Remove any view_unpublished dependency that may have been added to views. + */ +function view_unpublished_update_8002() { + Drupal::service('view_unpublished.install_helper')->removeDependency(); +} diff --git a/web/modules/view_unpublished/view_unpublished.permissions.yml b/web/modules/view_unpublished/view_unpublished.permissions.yml index 34690838f9f10561ddd32dd021ccfe49602122b5..f671132d0fe52e15075eb5d9c548a5db6a6064a2 100644 --- a/web/modules/view_unpublished/view_unpublished.permissions.yml +++ b/web/modules/view_unpublished/view_unpublished.permissions.yml @@ -2,4 +2,4 @@ view any unpublished content: title: 'View any unpublished content' permission_callbacks: - - Drupal\view_unpublished\ViewUnpublishedPermissions::permissions \ No newline at end of file + - Drupal\view_unpublished\ViewUnpublishedPermissions::permissions diff --git a/web/modules/view_unpublished/view_unpublished.services.yml b/web/modules/view_unpublished/view_unpublished.services.yml new file mode 100644 index 0000000000000000000000000000000000000000..b1f20653ad28528ad057d6a4a6783ce2b0796e9c --- /dev/null +++ b/web/modules/view_unpublished/view_unpublished.services.yml @@ -0,0 +1,7 @@ +services: + logger.channel.view_unpublished: + parent: logger.channel_base + arguments: ['view_unpublished'] + view_unpublished.install_helper: + class: Drupal\view_unpublished\ViewUnpublishedInstallHelper + arguments: ['@entity_type.manager', '@config.factory', '@config.storage'] diff --git a/web/modules/view_unpublished/view_unpublished.views.inc b/web/modules/view_unpublished/view_unpublished.views.inc index b8714d071908d1133e739aa834d3229120a970c6..0edfad6397f9f02957757697ffe3980b7cada11a 100644 --- a/web/modules/view_unpublished/view_unpublished.views.inc +++ b/web/modules/view_unpublished/view_unpublished.views.inc @@ -5,10 +5,12 @@ * Provide views data for view_unpublished.module. */ +use Drupal\view_unpublished\Plugin\views\filter\NodeStatus; + /** - * Implements hook_views_data_alter(). + * Implements hook_views_plugins_filter_alter(). */ -function view_unpublished_views_data_alter(array &$data) { - // The published status + extra handler is taken over by our handler. - $data['node_field_data']['status_extra']['filter']['id'] = 'view_unpublished_node_status'; +function view_unpublished_views_plugins_filter_alter(array &$plugins) { + // Change the 'status' handler class. + $plugins['node_status']['class'] = NodeStatus::class; } diff --git a/web/modules/view_unpublished/view_unpublished.views_execution.inc b/web/modules/view_unpublished/view_unpublished.views_execution.inc index 9df92816b8e0e6dd917c36222ef28037b6c53426..0ee308ce3236c1e05cb86640f3854da8ff80ee92 100644 --- a/web/modules/view_unpublished/view_unpublished.views_execution.inc +++ b/web/modules/view_unpublished/view_unpublished.views_execution.inc @@ -12,9 +12,6 @@ * Implements hook_views_query_substitutions(). */ function view_unpublished_views_query_substitutions(ViewExecutable $view) { - if ($view->id() != 'content' && !empty($view->filter['status']->value) && $view->filter['status']->value == 1) { - return; - } $account = \Drupal::currentUser(); $substitutions = []; foreach (NodeType::loadMultiple() as $type) {