From d2e12df992a911581a16100284c5a5148fb40d7e Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Fri, 24 Sep 2021 09:33:10 +0200
Subject: [PATCH] hotline MT #140494 fix admin links in render menu entry
 action

---
 VERSIONS_HOTLINE/140494                       |   1 +
 library/Class/Systeme/Widget/Abstract.php     |  20 +
 library/ZendAfi/View/Helper/Accueil/Base.php  |   3 +
 library/ZendAfi/View/Helper/TagEditMenu.php   |   7 +
 .../templates/Intonation/System/Abstract.php  |   3 +
 library/templates/Intonation/Template.php     |   6 +-
 ...u_with_articles_with_widget_rendering.json | 689 ++++++++++++++++++
 .../scenarios/Templates/TemplatesMenuTest.php |  32 +
 8 files changed, 760 insertions(+), 1 deletion(-)
 create mode 100644 VERSIONS_HOTLINE/140494
 create mode 100644 tests/scenarios/Templates/140494_profile_with_menu_with_articles_with_widget_rendering.json

diff --git a/VERSIONS_HOTLINE/140494 b/VERSIONS_HOTLINE/140494
new file mode 100644
index 00000000000..bf0a478ce66
--- /dev/null
+++ b/VERSIONS_HOTLINE/140494
@@ -0,0 +1 @@
+ - ticket #140494 : Magasin de thèmes : Correction du lien de configuration des pages affichant le contenu des "liens vers une selection d'articles".
\ No newline at end of file
diff --git a/library/Class/Systeme/Widget/Abstract.php b/library/Class/Systeme/Widget/Abstract.php
index 9d95ce834ee..59eba39c4c0 100644
--- a/library/Class/Systeme/Widget/Abstract.php
+++ b/library/Class/Systeme/Widget/Abstract.php
@@ -447,6 +447,26 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity {
   }
 
 
+
+  public function setAdminLinksHelper($helper) {
+    return $this->set('AdminLinksHelper', $helper);
+  }
+
+
+  public function setMenuAdminLinksHelper($view) {
+    if (Class_Systeme_Widget_Menu::class != get_class($this))
+      return $this;
+
+    $helper = (new ZendAfi_View_Helper_TagEditMenu)->setView($view);
+    return $this->setAdminLinksHelper($helper);
+  }
+
+
+  public function getAdminLinksHelper() {
+    return $this->get('AdminLinksHelper');
+  }
+
+
   protected function _disableFonctionAdmin() {
     $this->_disable_fonction_admin = true;
     return $this;
diff --git a/library/ZendAfi/View/Helper/Accueil/Base.php b/library/ZendAfi/View/Helper/Accueil/Base.php
index 1a8f9e7de0b..b96559f7f19 100644
--- a/library/ZendAfi/View/Helper/Accueil/Base.php
+++ b/library/ZendAfi/View/Helper/Accueil/Base.php
@@ -182,6 +182,9 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac
     if (!$this->_fonction_admin_helper)
       return '';
 
+    if (is_object($this->_fonction_admin_helper))
+      return $this->_fonction_admin_helper->renderAdminLinks($this);
+
     $helper = $this->view->getHelper($this->_fonction_admin_helper);
     return $helper->fonctionsAdmin($this->id_module,
                                    $this->type_module,
diff --git a/library/ZendAfi/View/Helper/TagEditMenu.php b/library/ZendAfi/View/Helper/TagEditMenu.php
index 7604506abec..0d8be786def 100644
--- a/library/ZendAfi/View/Helper/TagEditMenu.php
+++ b/library/ZendAfi/View/Helper/TagEditMenu.php
@@ -21,6 +21,13 @@
 
 
 class ZendAfi_View_Helper_TagEditMenu extends ZendAfi_View_Helper_BaseHelper {
+  public function renderAdminLinks($menu) {
+    return $this->tagEditMenu($menu->getId(),
+                              $menu->getProfileId(),
+                              $menu->getParent());
+  }
+
+
   public function tagEditMenu($menu_id, $profile_id, $parent_id = null, $params = []) {
     if (!Class_Users::isCurrentUserAllowedToEditProfile(Class_Profil::find($profile_id)))
       return '';
diff --git a/library/templates/Intonation/System/Abstract.php b/library/templates/Intonation/System/Abstract.php
index d92e336cd2d..2255ad1bfd1 100644
--- a/library/templates/Intonation/System/Abstract.php
+++ b/library/templates/Intonation/System/Abstract.php
@@ -67,6 +67,9 @@ abstract class Intonation_System_Abstract {
                                                           $this->forForm(),
                                                           $view);
 
+    if ($helper = $this->_settings->getAdminLinksHelper())
+      $widget->setFonctionAdminHelper($helper);
+
     if ($this->_settings->isFonctionAdminDisabled())
       $widget->setFonctionAdminHelper(null);
 
diff --git a/library/templates/Intonation/Template.php b/library/templates/Intonation/Template.php
index e1c0f5e7fc1..3822aa35086 100644
--- a/library/templates/Intonation/Template.php
+++ b/library/templates/Intonation/Template.php
@@ -54,7 +54,11 @@ class Intonation_Template extends Class_Template {
 
   public function renderWidget($widget, $view) {
     Class_AnchorTarget::setTarget($widget->getAnchorTarget());
-    $widget->setSection(new Class_Entity);
+
+    $widget
+      ->setMenuAdminLinksHelper($view)
+      ->setSection(new Class_Entity);
+
     return $this->renderWidgetOn((new Intonation_System_Widget)->setSettings($widget), $view);
   }
 
diff --git a/tests/scenarios/Templates/140494_profile_with_menu_with_articles_with_widget_rendering.json b/tests/scenarios/Templates/140494_profile_with_menu_with_articles_with_widget_rendering.json
new file mode 100644
index 00000000000..3016304d53c
--- /dev/null
+++ b/tests/scenarios/Templates/140494_profile_with_menu_with_articles_with_widget_rendering.json
@@ -0,0 +1,689 @@
+{
+    "id": 1,
+    "id_profil": 1,
+    "browser": "opac",
+    "libelle": "Le r\u00e9seau",
+    "titre_site": "M\u00e9diath\u00e8que Al\u00e8s Agglom\u00e9ration - Le r\u00e9seau",
+    "cfg_accueil": {
+        "modules": {
+            "24": {
+                "division": "4",
+                "type_module": "NAV",
+                "preferences": {
+                    "titre": "Menu principal haut",
+                    "menu": "1-0",
+                    "boite": [
+                        "admin_tools_invert_colors",
+                        "fond-sombre",
+                        "justify-content-center",
+                        "m-auto",
+                        "no_border",
+                        "no_border_radius",
+                        "no_shadow",
+                        "text-center"
+                    ],
+                    "id_module": "6",
+                    "profile_id": "7",
+                    "MuscleExpandBreakpoint": "sm",
+                    "MuscleWidthXsmall": "12",
+                    "MuscleWidthXlarge": "12",
+                    "MuscleVisibilityIndex": "1",
+                    "MuscleVisibilityRecherche": "1",
+                    "MuscleVisibilityAbonne": "1",
+                    "MuscleVisibilityCms": "1",
+                    "MuscleVisibilityBlog": "1",
+                    "MuscleVisibilityAuth": "1"
+                }
+            },
+            "29": {
+                "division": "6",
+                "type_module": "MENU",
+                "preferences": {
+                    "titre": "Boite menu",
+                    "menu": "1-3",
+                    "layout": "horizontal",
+                    "boite": [
+                        "fond-sombre",
+                        "justify-content-center",
+                        "no_border",
+                        "no_border_radius",
+                        "no_shadow"
+                    ],
+                    "id_module": "13",
+                    "profile_id": "1",
+                    "MuscleWidthXsmall": "12",
+                    "MuscleVisibilityIndex": "1",
+                    "MuscleVisibilityRecherche": "1",
+                    "MuscleVisibilityAbonne": "1",
+                    "MuscleVisibilityCms": "1",
+                    "MuscleVisibilityBlog": "1",
+                    "MuscleVisibilityAuth": "1"
+                }
+            }
+	}
+    },
+    "cfg_menus": {
+        "0": {
+            "type_menu": "MENU",
+            "libelle": "Menu",
+            "preferences": [],
+            "menus": {
+                "0": {
+                    "type_menu": "ACCUEIL",
+                    "libelle": "Accueil",
+                    "preferences": {
+                        "use_profil": "1"
+                    }
+                },
+                "1": {
+                    "type_menu": "MENU",
+                    "libelle": "Pratique",
+                    "preferences": [],
+                    "children": "2;3;4;5;6;7;",
+                    "sous_menus": {
+                        "2": {
+                            "type_menu": "PROFIL",
+                            "libelle": "M\u00e9diath\u00e8ques et horaires",
+                            "preferences": {
+                                "clef_profil": "19"
+                            }
+                        },
+                        "3": {
+                            "type_menu": "NEWS",
+                            "libelle": "S'inscrire et emprunter",
+                            "preferences": {
+                                "id_items": "13",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "3",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "S'inscrire et emprunter",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowFooter": "1"
+                            }
+                        },
+                        "4": {
+                            "type_menu": "NEWS",
+                            "libelle": "La MAD",
+                            "preferences": {
+                                "id_items": "12",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "3",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "La MAD",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowFooter": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "5": {
+                            "type_menu": "NEWS",
+                            "libelle": "Chartes et r\u00e8glement",
+                            "preferences": {
+                                "id_items": "15",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Chartes et r\u00e8glement",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "6": {
+                            "type_menu": "NEWS",
+                            "libelle": "Foire aux questions",
+                            "preferences": {
+                                "id_items": "50",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Foire aux questions",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "7": {
+                            "type_menu": "FORM_CONTACT",
+                            "libelle": "Nous contacter",
+                            "preferences": {
+                                "barre_nav": "Lien vers le formulaire de contact"
+                            }
+                        }
+                    }
+                },
+                "9": {
+                    "type_menu": "MENU",
+                    "libelle": "Services",
+                    "preferences": [],
+                    "children": "10;11;12;15;13;14;16;17;18;19;",
+                    "sous_menus": {
+                        "10": {
+                            "type_menu": "NEWS",
+                            "libelle": "Pr\u00e9-inscription en ligne",
+                            "preferences": {
+                                "id_items": "28",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Pr\u00e9-inscription en ligne",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "11": {
+                            "type_menu": "NEWS",
+                            "libelle": "Boutique",
+                            "preferences": {
+                                "id_items": "29",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Boutique",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "12": {
+                            "type_menu": "NEWS",
+                            "libelle": "Suggestion d'achat",
+                            "preferences": {
+                                "id_items": "35",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Suggestion d'achat",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "13": {
+                            "type_menu": "NEWS",
+                            "libelle": "Jeux vid\u00e9o",
+                            "preferences": {
+                                "id_items": "101",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Jeux vid\u00e9o",
+                                "order": "Selection",
+                                "boite": [],
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "14": {
+                            "type_menu": "NEWS",
+                            "libelle": "Ludoth\u00e8que",
+                            "preferences": {
+                                "id_items": "102",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Ludoth\u00e8que ",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "15": {
+                            "type_menu": "NEWS",
+                            "libelle": "Malles Jeux",
+                            "preferences": {
+                                "id_items": "34",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Malles Jeux",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "16": {
+                            "type_menu": "NEWS",
+                            "libelle": "Espace num\u00e9rique",
+                            "preferences": {
+                                "id_items": "36",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Espace num\u00e9rique",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "17": {
+                            "type_menu": "NEWS",
+                            "libelle": "Scans, photocopies et impressions",
+                            "preferences": {
+                                "id_items": "40",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Scans, photocopies et impressions",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "18": {
+                            "type_menu": "NEWS",
+                            "libelle": "R\u00e9server une salle",
+                            "preferences": {
+                                "id_items": "37",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "R\u00e9server une salle",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        },
+                        "19": {
+                            "type_menu": "NEWS",
+                            "libelle": "Inscription \u00e0 notre lettre d'informations",
+                            "preferences": {
+                                "id_items": "39",
+                                "nb_aff": "5",
+                                "nb_analyse": "10",
+                                "display_order": "DateCreationDesc",
+                                "display_mode": "Submenu",
+                                "summary_content": "FullContent",
+                                "layout": "list",
+                                "rendering": "page",
+                                "size": "20",
+                                "all_layout": "list",
+                                "all_rendering": "card-horizontal",
+                                "description_length": "20",
+                                "titre": "Inscription \u00e0 notre lettre d'informations",
+                                "order": "Selection",
+                                "boite": [
+                                    "no_background",
+                                    "no_border",
+                                    "no_border_radius",
+                                    "no_shadow",
+                                    "py-5"
+                                ],
+                                "MuscleShowHeader": "1",
+                                "MuscleShowContent": "1"
+                            }
+                        }
+                    }
+                },
+                "21": {
+                    "type_menu": "MENU",
+                    "libelle": "En rayon",
+                    "preferences": [],
+                    "children": "22;23;24;PROFIL;35;36;",
+                    "sous_menus": {
+                        "22": {
+                            "type_menu": "PROFIL",
+                            "libelle": "Nouveaut\u00e9s",
+                            "preferences": {
+                                "clef_profil": "24"
+                            }
+                        },
+                        "23": {
+                            "type_menu": "PROFIL",
+                            "libelle": "Vos avis et critiques",
+                            "preferences": {
+                                "clef_profil": "32"
+                            }
+                        },
+                        "24": {
+                            "type_menu": "MENU",
+                            "libelle": "Collections",
+                            "preferences": [],
+                            "children": "24;25;PROFIL;26;27;28;29;30;",
+                            "sous_menus": {
+                                "25": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "BD & mangas",
+                                    "preferences": {
+                                        "clef_profil": "26"
+                                    }
+                                },
+                                "26": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "Cin\u00e9ma",
+                                    "preferences": {
+                                        "clef_profil": "29"
+                                    }
+                                },
+                                "27": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "Documentaires",
+                                    "preferences": {
+                                        "clef_profil": "56"
+                                    }
+                                },
+                                "28": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "Enfance",
+                                    "preferences": {
+                                        "clef_profil": "55"
+                                    }
+                                },
+                                "29": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "Jeux de soci\u00e9t\u00e9",
+                                    "preferences": {
+                                        "clef_profil": "41"
+                                    }
+                                },
+                                "30": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "Jeux vid\u00e9o",
+                                    "preferences": {
+                                        "clef_profil": "31"
+                                    }
+                                },
+                                "31": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "Litt\u00e9rature",
+                                    "preferences": {
+                                        "clef_profil": "25"
+                                    }
+                                },
+                                "32": {
+                                    "type_menu": "PROFIL",
+                                    "libelle": "Musique",
+                                    "preferences": {
+                                        "clef_profil": "30"
+                                    }
+                                }
+                            }
+                        },
+                        "34": {
+                            "type_menu": "PROFIL",
+                            "libelle": "Facile \u00e0 lire",
+                            "preferences": {
+                                "clef_profil": "58"
+                            }
+                        },
+                        "35": {
+                            "type_menu": "PROFIL",
+                            "libelle": "Handicap",
+                            "preferences": {
+                                "clef_profil": "43"
+                            }
+                        },
+                        "36": {
+                            "type_menu": "CATALOGUE",
+                            "libelle": "Patrimoine",
+                            "preferences": {
+                                "tri": "1",
+                                "titre": "Patrimoine",
+                                "nb_notices": "20",
+                                "nb_analyse": "50",
+                                "id_catalogue": "96"
+                            }
+                        }
+                    }
+                },
+                "38": {
+                    "type_menu": "PROFIL",
+                    "libelle": "Offre num\u00e9rique",
+                    "preferences": {
+                        "clef_profil": "36"
+                    }
+                },
+                "39": {
+                    "type_menu": "PROFIL",
+                    "libelle": "Rendez-vous",
+                    "preferences": {
+                        "clef_profil": "20"
+                    }
+                },
+                "40": {
+                    "type_menu": "PROFIL",
+                    "libelle": "Espace pro",
+                    "preferences": {
+                        "clef_profil": "33"
+                    }
+                }
+            },
+            "children": "0;1;10;21;32;33;34"
+        },
+        "3": {
+            "type_menu": "MENU",
+            "libelle": "Menu cr\u00e9dits",
+            "preferences": [],
+            "menus": [
+                {
+                    "type_menu": "URL",
+                    "libelle": "Contact",
+                    "preferences": {
+                        "target": "1",
+                        "url": "\/index\/formulairecontact"
+                    }
+                },
+                {
+                    "type_menu": "NEWS",
+                    "libelle": "Mentions l\u00e9gales",
+                    "preferences": {
+                        "id_items": "59",
+                        "nb_aff": "5",
+                        "nb_analyse": "10",
+                        "display_order": "DateCreationDesc",
+                        "display_mode": "Submenu",
+                        "summary_content": "FullContent"
+                    }
+                },
+                {
+                    "type_menu": "NEWS",
+                    "libelle": "Donn\u00e9es personnelles",
+                    "preferences": {
+                        "id_items": "56",
+                        "nb_aff": "5",
+                        "nb_analyse": "10",
+                        "display_order": "DateCreationDesc",
+                        "display_mode": "Submenu",
+                        "summary_content": "FullContent"
+                    }
+                }
+            ],
+            "children": "0;1;2;"
+        }
+    },
+    "cfg_modules": {
+    },
+    "cfg_notice": "",
+    "rewrite_url": "le-reseau",
+    "domain_ids": null,
+    "template": "MUSCLE"
+}
diff --git a/tests/scenarios/Templates/TemplatesMenuTest.php b/tests/scenarios/Templates/TemplatesMenuTest.php
index eb5f8fc5f30..888b6aea01b 100644
--- a/tests/scenarios/Templates/TemplatesMenuTest.php
+++ b/tests/scenarios/Templates/TemplatesMenuTest.php
@@ -599,3 +599,35 @@ class TemplatesMenuDisplayWithArticlesListTest extends Admin_AbstractControllerT
     $this->assertXPathContentContains('//a[@href="/widget/render-menu-entry/parent/3/menu_profil/1/menu/13/id_profil/146"]', 'Ressources en ligne');
   }
 }
+
+
+
+
+class TemplatesMenuWithArticlesByPreferencesAndWidgetRenderingTest extends Admin_AbstractControllerTestCase {
+  protected $_storm_default_to_volatile = true;
+
+
+  public function setUp() {
+    parent::setUp();
+    $profile = $this->_buildTemplateProfil(['id' => 1,
+                                            'template' => 'MUSCLE']);
+
+    (new Class_Profil_Import($profile))
+      ->import(__DIR__ . '/140494_profile_with_menu_with_articles_with_widget_rendering.json');
+
+
+    $this->dispatch('/widget/render-menu-entry/parent/0/menu_profil/1/menu/10/id_profil/1');
+  }
+
+
+  /** @test */
+  public function editWidgetLinkShouldNotBePresent() {
+    $this->assertNotXPath('//main//div[contains(@class, "section_configuration")]//a[contains(@href, "/admin/widget/edit-widget/id/10/id_profil/1")]');
+  }
+
+
+  /** @test */
+  public function editRenderMenuEntryLinkShouldBePresent() {
+    $this->assertXPath('//main//div[contains(@class, "boite news")]/a[contains(@class, "edit_menu")][contains(@href, "/admin/widget/edit-menu/id/10/id_profil/1/parent/0")]');
+  }
+}
\ No newline at end of file
-- 
GitLab