diff --git a/VERSIONS_HOTLINE/124508 b/VERSIONS_HOTLINE/124508 new file mode 100644 index 0000000000000000000000000000000000000000..345ecf4cd5cd8cfb4030442cdca1e15382ebb8e9 --- /dev/null +++ b/VERSIONS_HOTLINE/124508 @@ -0,0 +1 @@ + - ticket #124508 : Magasin de thèmes : correction de l'affichage des carrousels embarqués dans des articles \ No newline at end of file diff --git a/library/Class/Systeme/Widget/Abstract.php b/library/Class/Systeme/Widget/Abstract.php index 4b7bfb90d012526ff8088c255d812f3d28dc461e..a29da821b763d22a3c20f85110ac585a47a9422d 100644 --- a/library/Class/Systeme/Widget/Abstract.php +++ b/library/Class/Systeme/Widget/Abstract.php @@ -33,7 +33,8 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity { protected $_cache_key, $_errors = [], - $_is_in_menu = false; + $_is_in_menu = false, + $_disable_fonction_admin = false; public function load() { @@ -90,12 +91,13 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity { public function loadFromSettings($settings) { return $this ->setProfileId(Class_Profil::getCurrentProfil()->getId()) - ->setId('no') + ->setId('no_' . uniqid()) ->init() ->_transmute($settings) ->setTitle($this->_getTitle()) ->setForm($this->_getForm()) - ->setViewHelper($this->_getViewHelper()); + ->setViewHelper($this->_getViewHelper()) + ->_disableFonctionAdmin(); } @@ -434,4 +436,15 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity { public function settitre($titre) { return $this->set('titre', $titre); } + + + protected function _disableFonctionAdmin() { + $this->_disable_fonction_admin = true; + return $this; + } + + + public function isFonctionAdminDisabled() { + return $this->_disable_fonction_admin; + } } diff --git a/library/ZendAfi/View/Helper/Article/RenderWidget.php b/library/ZendAfi/View/Helper/Article/RenderWidget.php index 744c40bfc2c66178dc4fb8491407f60faf103340..21e9006a9f534da66ba45ed614aa87e3b310ecb1 100644 --- a/library/ZendAfi/View/Helper/Article/RenderWidget.php +++ b/library/ZendAfi/View/Helper/Article/RenderWidget.php @@ -24,11 +24,17 @@ class ZendAfi_View_Helper_Article_RenderWidget extends ZendAfi_View_Helper_BaseH public function article_RenderWidget($code, $form) { $prefs = []; parse_str(html_entity_decode($form), $prefs); - $params = ['type_module'=> $code, - 'preferences' => $prefs]; + + return $this->_getHTMLWith(['type_module'=> $code, + 'preferences' => $prefs]); + } + + + protected function _getHTMLWith($params) { $helper = ZendAfi_View_Helper_Accueil_Base::getModuleHelperFromParams(null, $params, $this->view); + return $helper ->setFonctionAdminHelper(null) ->getBoite(); diff --git a/library/templates/Intonation/System/Abstract.php b/library/templates/Intonation/System/Abstract.php index 2092b0684154236de39d86342629e808e05002c4..028ce832f99f0dc9fc8d282ff689817a018bfc5b 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 ($this->_settings->isFonctionAdminDisabled()) + $widget->setFonctionAdminHelper(null); + return $base->wrap($widget); } diff --git a/library/templates/Intonation/View/Article/RenderWidget.php b/library/templates/Intonation/View/Article/RenderWidget.php new file mode 100644 index 0000000000000000000000000000000000000000..f3966a429a3d20b73b2319794e0723d44f756a5a --- /dev/null +++ b/library/templates/Intonation/View/Article/RenderWidget.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Intonation_View_Article_RenderWidget extends ZendAfi_View_Helper_Article_RenderWidget { + + protected function _getHTMLWith($params) { + $widget = ((new Class_Systeme_Widget_Widget) + ->loadFromSettings($params)); + + return Class_Template::current()->renderWidget($widget, $this->view); + } +} diff --git a/tests/scenarios/Templates/TemplatesArticlesTest.php b/tests/scenarios/Templates/TemplatesArticlesTest.php index 515f3ccffd8a240cb1721eb423236c7ed3117dc3..188c635a115ac66f4021cafb467e6a9a70279bb8 100644 --- a/tests/scenarios/Templates/TemplatesArticlesTest.php +++ b/tests/scenarios/Templates/TemplatesArticlesTest.php @@ -773,4 +773,70 @@ class TemplatesArticlesWidgetAjaxRenderingTest extends AbstractControllerTestCas public function exactly112ArticlesShouldHaveBeenCounted() { $this->assertXPathContentContains('//span', '112', $this->_response->getBody()); } -} \ No newline at end of file +} + + + + + +abstract class TemplatesArticlesWithWidgetRenderWallTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil(['id' => 32, + 'template' => 'MYBIBAPP']); + + $this->_logAdmin(); + + $this->fixture('Class_Article', [ 'id' => 55, + 'titre' => 'Mes dvds', + 'contenu' => '<img class="bokeh_kiosk" data-code="KIOSQUE" data-form="titre=&style_liste=mur&aleatoire=1&tri=1&boite=&">']); + + $this->dispatch('/cms/articleview/id/55'); + } + + + protected function _logAdmin() { + } +} + + + + +class TemplatesArticlesWithWidgetRenderWallNotLoggedTest + extends TemplatesArticlesWithWidgetRenderWallTestCase { + + /** @test */ + public function bokehKioskShouldBeRemoved() { + $this->assertNotXPath('//img[@class="bokeh_kiosk"]'); + } + + + /** @test */ + public function wallJSShouldBeCallWithId() { + $this->assertXPathContentContains('//script[contains(text(), \'$(function(){$("#no_\')]', '.parent().masonry();});'); + } +} + + + + +class TemplatesArticlesWithWidgetRenderWallLoggedAsAdminTest + extends TemplatesArticlesWithWidgetRenderWallTestCase { + + protected function _logAdmin() { + ZendAfi_Auth::getInstance() + ->logUser($this->fixture('Class_Users', + ['id' => 123, + 'login' => 'admin', + 'password' => 'auieauei', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN])); + } + + + /** @test */ + public function adminToolsShouldNotBePresent() { + $this->assertNotXPath('//a[contains(@href, "admin/widget/edit-widget/id/no_")]'); + } +}