Browse Source

Merge branch 'master' of figureslibres.io:bachir/popsu-d9

armansansd 3 years ago
parent
commit
f10b8e3199

+ 1 - 0
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",

+ 59 - 1
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,

+ 1 - 0
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

+ 21 - 6
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

+ 11 - 0
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

+ 2 - 2
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

+ 22 - 0
config/sync/perimeter.settings.yml

@@ -0,0 +1,22 @@
+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\\/*/\r"
+  - "/\\/bafnshop\\/*/\r"
+  - '/\/baf.+shop\/*/'
+_core:
+  default_config_hash: xRKQpemYizW_6JE8p1XI9VvGW0AANmWsJwrCXlEDixo
+langcode: fr

+ 13 - 0
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: "<p><a class=\"ressources-link\" href=\"/centre-de-ressources\">Voir toutes les ressources</a></p>\r\n"
+          summary: ''
+          format: wysiwyg
   -
     info: 'logo gouv cartouche'
     langcode: fr

+ 45 - 7
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;
   }