From 6b4e101f844288afeea560540b1a7f060718bc01 Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 14 Sep 2021 10:37:17 +0200 Subject: [PATCH 1/5] added ressources link block in programme's bottom --- ...ger.page_variant.node-panels_variant-0.yml | 11 ++++ .../src/Plugin/Block/ProgRessourceLink.php | 52 ++++++++++++++++--- 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/config/sync/page_manager.page_variant.node-panels_variant-0.yml b/config/sync/page_manager.page_variant.node-panels_variant-0.yml index aa02d9ee..0622f349 100644 --- a/config/sync/page_manager.page_variant.node-panels_variant-0.yml +++ b/config/sync/page_manager.page_variant.node-panels_variant-0.yml @@ -116,6 +116,7 @@ variant_settings: weight: 0 uuid: 9c5741a0-e8e2-4895-88a7-c36d3825e33c context_mapping: { } + link_title: Ressources c80f54a0-8f21-4c56-8341-eab59b009329: id: 'entity_field:node:field_document' label: 'Pour aller plus loin' @@ -133,6 +134,16 @@ variant_settings: uuid: c80f54a0-8f21-4c56-8341-eab59b009329 context_mapping: entity: node + f5f0169e-5c85-4b7e-b726-abd246152f83: + id: prog_ressource_link + label: 'Prog ressource link' + provider: popsu_link_block + label_display: '0' + region: bottom + weight: 0 + uuid: f5f0169e-5c85-4b7e-b726-abd246152f83 + context_mapping: { } + link_title: 'voir toutes les ressources de [node:title]' id: panels_variant uuid: 9752d3e8-fdc6-419d-95bb-079a2c3088b3 label: null diff --git a/web/modules/custom/popsu_link_block/src/Plugin/Block/ProgRessourceLink.php b/web/modules/custom/popsu_link_block/src/Plugin/Block/ProgRessourceLink.php index 4cff6e8e..610c3eec 100644 --- a/web/modules/custom/popsu_link_block/src/Plugin/Block/ProgRessourceLink.php +++ b/web/modules/custom/popsu_link_block/src/Plugin/Block/ProgRessourceLink.php @@ -3,8 +3,10 @@ namespace Drupal\popsu_link_block\Plugin\Block; use Drupal\Core\Block\BlockBase; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\Core\Link; +// use Drupal\Core\Utility\Token; /** * Provides a 'ProgRessourceLink' block. @@ -16,27 +18,63 @@ use Drupal\Core\Link; */ class ProgRessourceLink extends BlockBase { + public function blockForm($form, FormStateInterface $form_state) { + $form = parent::blockForm($form, $form_state); + + $config = $this->getConfiguration(); + + $form['link_title_wrapper'] = [ + '#type' => 'container' + ]; + + $form['link_title_wrapper']['link_title'] = [ + '#type' => 'textfield', + '#title' => 'Link title', + '#default_value' => isset($config['link_title']) ? $config['link_title'] : "Ressources", + '#element_validate' => array('token_element_validate'), + '#token_types' => array('node'), + ]; + + $form['link_title_wrapper']['token_tree'] = array( + '#theme' => 'token_tree_link', + '#token_types' => array('node'), + '#show_restricted' => TRUE, + '#global_types' => FALSE, + '#weight' => 90, + ); + + return $form; + } + + public function blockSubmit($form, FormStateInterface $form_state) + { + parent::blockSubmit($form, $form_state); + $values = $form_state->getValues(); + $link_title = $values['link_title_wrapper']['link_title']; + $this->configuration['link_title'] = $link_title; + } + + /** * {@inheritdoc} */ public function build() { + $config = $this->getConfiguration(); $build = []; $node = \Drupal::routeMatch()->getParameter('node'); if ($node instanceof \Drupal\node\Entity\Node) { - // You can get nid and anything else you need from the node object. $nid = $node->id(); - + // $title = $config["link_title"]; + $token_service = \Drupal::token(); + $title = $token_service->replace($config["link_title"], array('node' => $node)); $url = Url::fromRoute("view.centre_de_ressources.page_1"); $url->setRouteParameter("programme", $nid); $url->setOption('attributes', array("class"=>array('prog-ressources-link'))); $build['prog_ressource_link'] = array( - '#title' => "Ressources", + '#title' => $title, '#type' => 'link', - '#url' => $url, + '#url' => $url ); - - $t="t"; - } return $build; } From e33d2ce02238598b43a2b0d0dc58c888e55df8be Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 14 Sep 2021 11:09:43 +0200 Subject: [PATCH 2/5] added perimter defense --- composer.json | 1 + composer.lock | 60 +++++++++++++++++++++++++++++- config/sync/core.extension.yml | 1 + config/sync/perimeter.settings.yml | 20 ++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 config/sync/perimeter.settings.yml diff --git a/composer.json b/composer.json index 6ac3c3a5..896460d0 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ "drupal/panelizer": "^4.4", "drupal/panels": "^4.6", "drupal/paragraphs": "1.x-dev@dev", + "drupal/perimeter": "2.0.x-dev@dev", "drupal/role_delegation": "^1.1", "drupal/selective_better_exposed_filters": "2.x-dev@dev", "drupal/smart_date": "^3.1", diff --git a/composer.lock b/composer.lock index e611d545..830c3c2e 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": "30be06897e716bde6a8c2d049891ae62", + "content-hash": "6d3f1f661a6cbcda066d714f4c72c06b", "packages": [ { "name": "ajgl/breakpoint-twig-extension", @@ -8202,6 +8202,63 @@ "source": "https://git.drupalcode.org/project/pathologic" } }, + { + "name": "drupal/perimeter", + "version": "dev-2.0.x", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/perimeter.git", + "reference": "1673ef93d1d34561762feb5977b4f5a42b9a03c8" + }, + "require": { + "drupal/core": "^8 || ^9" + }, + "type": "drupal-module", + "extra": { + "branch-alias": { + "dev-2.0.x": "2.0.x-dev" + }, + "drupal": { + "version": "2.0.0-rc2+0-dev", + "datestamp": "1608735016", + "security-coverage": { + "status": "not-covered", + "message": "Dev releases are not covered by Drupal security advisories." + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Anybody", + "homepage": "https://www.drupal.org/user/291091" + }, + { + "name": "CiviFirst John", + "homepage": "https://www.drupal.org/user/3393940" + }, + { + "name": "alayham", + "homepage": "https://www.drupal.org/user/34525" + }, + { + "name": "nord102", + "homepage": "https://www.drupal.org/user/3471419" + }, + { + "name": "thomas.frobieter", + "homepage": "https://www.drupal.org/user/409335" + } + ], + "description": "Immediately ban hackers when they try to scan the site.", + "homepage": "https://www.drupal.org/project/perimeter", + "support": { + "source": "https://git.drupalcode.org/project/perimeter" + } + }, { "name": "drupal/persistent_login", "version": "1.3.0", @@ -15758,6 +15815,7 @@ "drupal/migrate_tools": 20, "drupal/page_manager": 20, "drupal/paragraphs": 20, + "drupal/perimeter": 20, "drupal/selective_better_exposed_filters": 20, "drupal/autocomplete_deluxe": 5, "drupal/bulkdelete": 20, diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index b9e5bb76..7149f86d 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -109,6 +109,7 @@ module: path_alias: 0 path_alias_xt: 0 pathologic: 0 + perimeter: 0 persistent_login: 0 popsu_link_block: 0 popsu_migrate: 0 diff --git a/config/sync/perimeter.settings.yml b/config/sync/perimeter.settings.yml new file mode 100644 index 00000000..fb368051 --- /dev/null +++ b/config/sync/perimeter.settings.yml @@ -0,0 +1,20 @@ +not_found_exception_patterns: + - "/.*\\.aspx/\r" + - "/.*\\.asp/\r" + - "/.*\\.jsp/\r" + - "/\\/blog_edit\\.php/\r" + - "/\\/blogs\\.php/\r" + - "/\\/wp-admin.*/\r" + - "/\\/wp-login.*/\r" + - "/\\/wp-includes\\/*/\r" + - "/\\/my_blogs/\r" + - "/\\/system\\/.*\\.php/\r" + - "/.*systopice.*/\r" + - "/.*login.json/\r" + - "/\\/episerver.*/\r" + - "/\\/bafeshop\\/*/\r" + - "/\\/bafyshop\\/*/\r" + - '/\/bafoshop\/*/' +_core: + default_config_hash: xRKQpemYizW_6JE8p1XI9VvGW0AANmWsJwrCXlEDixo +langcode: fr From d6b767a2396ae90ca99ab397b3fef88d73b364da Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 14 Sep 2021 11:54:09 +0200 Subject: [PATCH 3/5] added perimter defense --- config/sync/perimeter.settings.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/sync/perimeter.settings.yml b/config/sync/perimeter.settings.yml index fb368051..ef9f6c26 100644 --- a/config/sync/perimeter.settings.yml +++ b/config/sync/perimeter.settings.yml @@ -14,7 +14,9 @@ not_found_exception_patterns: - "/\\/episerver.*/\r" - "/\\/bafeshop\\/*/\r" - "/\\/bafyshop\\/*/\r" - - '/\/bafoshop\/*/' + - "/\\/bafoshop\\/*/\r" + - "/\\/bafnshop\\/*/\r" + - '/\/baf.+shop\/*/' _core: default_config_hash: xRKQpemYizW_6JE8p1XI9VvGW0AANmWsJwrCXlEDixo langcode: fr From c0435b0e8cb962066e853fffe9e60351cf24a280 Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 14 Sep 2021 12:09:02 +0200 Subject: [PATCH 4/5] added voir toutes les ressources block on home --- ...ger.page_variant.home-panels_variant-0.yml | 27 ++++++++++++++----- config/sync/structure_sync.data.yml | 13 +++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/config/sync/page_manager.page_variant.home-panels_variant-0.yml b/config/sync/page_manager.page_variant.home-panels_variant-0.yml index eb76811f..ac9e400b 100644 --- a/config/sync/page_manager.page_variant.home-panels_variant-0.yml +++ b/config/sync/page_manager.page_variant.home-panels_variant-0.yml @@ -8,7 +8,10 @@ dependencies: - views.view.home_themes - views.view.programmes - views.view.projets + content: + - 'block_content:custom:1911abcd-dd85-403d-8e6e-8621c9f2045a' module: + - block_content - panels - views id: home-panels_variant-0 @@ -24,7 +27,7 @@ variant_settings: views_label: '' items_per_page: none region: content - weight: -2 + weight: -3 uuid: e5f452c9-14a6-49a2-b5ab-028e1246ec29 context_mapping: { } c460a8dc-20aa-4d12-8382-48d03a96eae3: @@ -35,7 +38,7 @@ variant_settings: views_label: '' items_per_page: none region: content - weight: -1 + weight: -2 uuid: c460a8dc-20aa-4d12-8382-48d03a96eae3 context_mapping: { } 323f250e-52aa-455a-be5b-82737e7558a4: @@ -46,7 +49,7 @@ variant_settings: views_label: '' items_per_page: none region: content - weight: 3 + weight: 2 uuid: 323f250e-52aa-455a-be5b-82737e7558a4 context_mapping: { } 02736330-658c-4ab2-8bdb-bd164841a070: @@ -57,7 +60,7 @@ variant_settings: views_label: '' items_per_page: none region: content - weight: 1 + weight: 0 uuid: 02736330-658c-4ab2-8bdb-bd164841a070 context_mapping: { } 04cbbff9-0519-47e7-8eba-9376abe616ef: @@ -68,7 +71,7 @@ variant_settings: views_label: '' items_per_page: none region: content - weight: 0 + weight: -1 uuid: 04cbbff9-0519-47e7-8eba-9376abe616ef context_mapping: { } 69a489a1-0246-4026-80a0-9b636402ee16: @@ -79,9 +82,21 @@ variant_settings: views_label: '' items_per_page: none region: content - weight: 2 + weight: 1 uuid: 69a489a1-0246-4026-80a0-9b636402ee16 context_mapping: { } + 42cf96f9-73eb-415f-9447-c23a209a91d5: + id: 'block_content:1911abcd-dd85-403d-8e6e-8621c9f2045a' + label: 'Ressources link' + provider: block_content + label_display: '0' + status: true + info: '' + view_mode: full + region: content + weight: 3 + uuid: 42cf96f9-73eb-415f-9447-c23a209a91d5 + context_mapping: { } id: panels_variant uuid: 3093fbf1-47e3-46ba-9bf2-84a715779a13 label: null diff --git a/config/sync/structure_sync.data.yml b/config/sync/structure_sync.data.yml index 3d5f751f..da29c5a1 100644 --- a/config/sync/structure_sync.data.yml +++ b/config/sync/structure_sync.data.yml @@ -121,6 +121,19 @@ menus: langcode: fr uuid: f42e04af-950b-4207-88d9-49e364e5270f blocks: + - + info: 'Ressources link' + langcode: fr + uuid: 1911abcd-dd85-403d-8e6e-8621c9f2045a + bundle: custom + revision_id: null + rev_id_current: null + fields: + body: + - + value: "

Voir toutes les ressources

\r\n" + summary: '' + format: wysiwyg - info: 'logo gouv cartouche' langcode: fr From 79d966ca8912cafb3b7a6f010c10f5658eff9379 Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 14 Sep 2021 12:12:41 +0200 Subject: [PATCH 5/5] #1498 --- .../sync/page_manager.page_variant.node-panels_variant-1.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/sync/page_manager.page_variant.node-panels_variant-1.yml b/config/sync/page_manager.page_variant.node-panels_variant-1.yml index 1308eeb6..e336e840 100644 --- a/config/sync/page_manager.page_variant.node-panels_variant-1.yml +++ b/config/sync/page_manager.page_variant.node-panels_variant-1.yml @@ -97,7 +97,7 @@ variant_settings: id: 'entity_field:node:field_partenaires' label: Partenaires provider: ctools_block - label_display: visible + label_display: '0' formatter: label: hidden type: entity_reference_revisions_entity_view @@ -114,7 +114,7 @@ variant_settings: id: 'entity_field:node:field_equipes' label: Équipes provider: ctools_block - label_display: visible + label_display: '0' formatter: label: hidden type: entity_reference_revisions_entity_view