Commit b6235149 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline MT #136539 menu widget use carousel layouts

parent abaf16d8
- ticket #136539 : Magasin de thèmes : Les boites menus partagent maintenant les représentations des listes des boites de type carrousel.
\ No newline at end of file
......@@ -484,4 +484,14 @@ abstract class Class_Systeme_Widget_Abstract extends Class_Entity {
public function getAvailableOrders() {
return $this->getFormInstance()->getOrders();
}
public function setChildren($children) {
return $this->set('Children', $children);
}
public function getChildren() {
return $this->get('Children');
}
}
......@@ -22,6 +22,9 @@
class Class_Systeme_Widget_Menu extends Class_Systeme_Widget_Abstract {
protected $_sub_menus = [];
public static function findAllAsArray($id_profil) {
if(!$profil = Class_Profil::find($id_profil))
return [];
......@@ -39,6 +42,65 @@ class Class_Systeme_Widget_Menu extends Class_Systeme_Widget_Abstract {
}
public static function loadFromWidgetPreferences($preferences) {
if ( ! isset($preferences['menu']))
return null;
$menu_id = $preferences['menu'];
if ( '' === $menu_id)
return null;
$profile_id = static::extractProfileIdFromMenu($menu_id);
$menu_id = static::extractMenuIdFromMenu($menu_id);
if( ! $menu = (new Class_Systeme_Widget_Menu)
->setId($menu_id)
->setProfileId($profile_id)
->load())
return null;
return $menu->loadSubMenus();
}
public static function extractProfileIdFromMenu($menu) {
return static::_extractFromMenuWith($menu,
function()
{
return Class_Profil::getCurrentProfil()->getId();
},
function($menu_as_array)
{
return array_shift($menu_as_array);
});
}
public static function extractMenuIdFromMenu($menu) {
return static::_extractFromMenuWith($menu,
function() use ($menu)
{
return $menu;
},
function($menu_as_array)
{
return array_pop($menu_as_array);
});
}
protected static function _extractFromMenuWith($menu, $callback, $callback_with_separator) {
if (false === strpos($menu, Class_Systeme_ModulesMenu::MENU_CONFIG_PROFIL_SEPARATOR))
return $callback();
$menu_as_array = explode(Class_Systeme_ModulesMenu::MENU_CONFIG_PROFIL_SEPARATOR, $menu);
return $callback_with_separator($menu_as_array);
}
protected function _load() {
return $this->_transmute($this->find());
}
......@@ -245,4 +307,50 @@ class Class_Systeme_Widget_Menu extends Class_Systeme_Widget_Abstract {
public function getLocalSettings() {
return $this->get('LocalSettings');
}
public function loadSubMenus() {
if ( $this->getSubMenus())
return $this;
$menu_settings = $this->getLocalSettings();
if ( ! isset($menu_settings['menus']))
return $this;
foreach ($menu_settings['menus'] as $sub_menu)
$this->addSubMenu($sub_menu);
return $this;
}
public function addSubMenu($sub_menu) {
if ( ! isset($sub_menu['id_module']))
return $this;
if ( ! $menu = (new Class_Systeme_Widget_Menu)
->setId($sub_menu['id_module'])
->setProfileId($this->getProfileId())
->setParent($this->getId())
->load())
return $this;
$sub_menus = ( $sub_menus = $this->getSubMenus())
? $sub_menus
: [];
$this->_sub_menus [] = $menu;
return $this;
}
public function setSubMenus($submenus) {
$this->_sub_menus = $submenus;
return $this;
}
public function getSubMenus() {
return $this->_sub_menus;
}
}
......@@ -586,4 +586,8 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac
return $this->_template_context->isInMenu();
}
public function getSettings() {
return $this->_settings;
}
}
......@@ -333,7 +333,7 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher {
$this->_template->withNameSpace('show_content') => 0,
$this->_template->withNameSpace('show_footer') => 0])
->_addWidget(Intonation_Library_Widget_Menu_Definition::CODE,
->_addWidget(Intonation_Library_Widget_Carousel_Menu_Definition::CODE,
Class_Profil::DIV_BANNIERE,
['titre' => $this->_('Menu recherche'),
'boite' => ['chili_fixed_top','no_border', 'no_border_radius', 'no_shadow', 'position_fixed_top', 'w-100'],
......@@ -490,7 +490,7 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher {
$this->_template->withNameSpace('show_content') => 0,
$this->_template->withNameSpace('show_footer') => 0])
->_addWidget(Intonation_Library_Widget_Menu_Definition::CODE,
->_addWidget(Intonation_Library_Widget_Carousel_Menu_Definition::CODE,
Class_Profil::DIV_FOOTER,
['titre' => $this->_('Menu réseau'),
'boite' => ['no_border', 'no_border_radius', 'no_shadow', 'admin_tools_invert_colors'],
......@@ -503,7 +503,7 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher {
$this->_template->withNameSpace('show_content') => 0,
$this->_template->withNameSpace('show_footer') => 0])
->_addWidget(Intonation_Library_Widget_Menu_Definition::CODE,
->_addWidget(Intonation_Library_Widget_Carousel_Menu_Definition::CODE,
Class_Profil::DIV_FOOTER,
['titre' => $this->_('Plan du site'),
'boite' => ['no_border', 'no_border_radius', 'no_shadow', 'admin_tools_invert_colors', 'chili_footer_widget', 'px-3'],
......@@ -526,7 +526,7 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher {
$this->_template->withNameSpace('show_content') => 0,
$this->_template->withNameSpace('show_footer') => 0])
->_addWidget(Intonation_Library_Widget_Menu_Definition::CODE,
->_addWidget(Intonation_Library_Widget_Carousel_Menu_Definition::CODE,
Class_Profil::DIV_FOOTER,
['titre' => $this->_('Mentions légales'),
'boite' => ['no_border', 'no_border_radius', 'no_shadow', 'admin_tools_invert_colors', 'chili_footer_widget', 'px-3'],
......
......@@ -34,34 +34,36 @@ class Chili_Library_Widget_Login_View extends Intonation_Library_Widget_Login_Vi
class ChililLoginRenderToggle extends IntonationLoginRenderToggle {
protected function _parentRenderLogin() {
$form_html = parent::_parentRenderLogin();
$id_menu = $this->_settings->getNotAuthenticatedMenu();
$helper = new Intonation_Library_Widget_Menu_View(1, ['type_module' => 'MENU',
'preferences' => ['menu' => $id_menu]]);
$helper->setView($this->_view);
$menu_html = $helper->getContent();
return $form_html . $menu_html;
protected function _parentRenderLogin() {
return
parent::_parentRenderLogin()
. $this->_withIdMenuRender($this->_settings->getNotAuthenticatedMenu());
}
public function renderLogged() {
$id_menu = $this->_settings->getAuthenticatedMenu();
$html = $this->_view->tag('h1',
$this->_user->getNomAff(),
['class' => 'widget-header'])
. $this->_withIdMenuRender($this->_settings->getAuthenticatedMenu());
return
$this->_view->renderDropdown($html,
$this->_view->abonne_Name($this->_user),
'',
'dropdown-menu-right');
}
$helper = new Intonation_Library_Widget_Menu_View(1, ['type_module' => 'MENU',
'preferences' => ['menu' => $id_menu]]);
$helper->setView($this->_view);
return $this->_view->renderDropdown($this->_view->tag('h1',
$this->_user->getNomAff(),
['class' => 'widget-header'])
.
$helper->getContent(),
protected function _withIdMenuRender($id_menu) {
$helper = new Intonation_Library_Widget_Carousel_Menu_View(md5($id_menu),
['type_module' => 'MENU',
'preferences' => ['menu' => $id_menu]]);
$helper
->setView($this->_view)
->getHtml();
$this->_view->abonne_Name($this->_user),
'',
'dropdown-menu-right');
return $helper->getContent();
}
}
......@@ -646,6 +646,10 @@ dl.row {
right: 0 !important;
}
.card-deck {
margin: 0;
}
.card_grid > .card,
.card-deck > .card,
.card-columns > .card {
......
......@@ -22,6 +22,10 @@
class Intonation_Library_FormCustomizer_Menu extends Intonation_Library_FormCustomizer_Abstract {
public function getForm() {
$this->_form->removeElement('order');
$this->_form->removeElement('size');
$this->_form->removeElement('rendering');
return $this->_addExpandBreakpoint();
}
}
......@@ -305,6 +305,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'div class library_horaire' => 'col-12',
'div class library_opening' => 'col-12',
'div class library_opening_hours' => 'col-12 d-none',
'div class menu_with_carousel_layout' => 'overflow-visible',
],
'icons_map_doc_types' => [],
......
<?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_Library_View_Wrapper_MenuEntry extends Intonation_Library_View_Wrapper_Abstract {
public function getMainTitle() {
return $this->_model->getLabel();
}
public function getMainLink() {
return '';
}
public function getEmbedMedia() {
return '';
}
public function getHtmlPicture() {
return '';
}
public function getPicture() {
return '';
}
public function getPictureAction() {
return null;
}
/** @return string */
public function getSecondaryTitle() {
return '';
}
/** @return Intonation_Library_Link */
public function getSecondaryLink() {
return null;
}
/** @return string icon html */
public function getSecondaryIco() {
return '';
}
/** @return array of Intonation_Library_Link */
public function getActions() {
return [];
}
/** @return string html */
public function getDescription() {
return '';
}
/** @return string html */
public function getFullDescription() {
return '';
}
/** @return string */
public function getDescriptionTitle() {
return '';
}
/** @return html */
public function getBadges() {
return '';
}
/** @return string */
public function getDocType() {
return '';
}
/** @return string */
public function getDocTypeLabel() {
return '';
}
/** @return Intonation_Library_OsmData */
public function getOsmData() {
return null;
}
}
......@@ -83,6 +83,32 @@ class Intonation_Library_Widget_Carousel_Definition extends Class_Systeme_Module
'layout' => $layout,
'boite' => $styles_callback()]];
}
public function getOrderedLayouts($layouts) {
asort($layouts, SORT_NATURAL | SORT_FLAG_CASE);
return $layouts;
}
public function getLayoutsList() {
return array_merge([static::ACCORDION_CAROUSEL => $this->_('Accordéon'),
static::CAROUSEL => $this->_('Carousel'),
static::MULTIPLE_CAROUSEL => $this->_('Carousel à 3 colonnes'),
static::MULTIPLE_CAROUSEL_PLUS => $this->_('Carousel à 5 colonnes'),
static::GRID => $this->_('Grille'),
static::HORIZONTAL_LISTING => $this->_('Liste horizontale'),
static::LISTING => $this->_('Liste verticale'),
static::LISTING_WITH_OPTIONS => $this->_('Liste verticale à interactions'),
static::WALL => $this->_('Mur'),
static::MAP => $this->_('Carte géographique')],
Class_Template::current()->getCarouselLayouts());
}
public function getLayouts() {
return $this->getOrderedLayouts($this->getLayoutsList());
}
}
......
......@@ -142,21 +142,7 @@ abstract class Intonation_Library_Widget_Carousel_Form extends ZendAfi_Form_Conf
public function getLayouts() {
$layouts = array_merge([Intonation_Library_Widget_Carousel_Definition::ACCORDION_CAROUSEL => $this->_('Accordéon'),
Intonation_Library_Widget_Carousel_Definition::CAROUSEL => $this->_('Carousel'),
Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL => $this->_('Carousel à 3 colonnes'),
Intonation_Library_Widget_Carousel_Definition::MULTIPLE_CAROUSEL_PLUS => $this->_('Carousel à 5 colonnes'),
Intonation_Library_Widget_Carousel_Definition::GRID => $this->_('Grille'),
Intonation_Library_Widget_Carousel_Definition::HORIZONTAL_LISTING => $this->_('Liste horizontale'),
Intonation_Library_Widget_Carousel_Definition::LISTING => $this->_('Liste verticale'),
Intonation_Library_Widget_Carousel_Definition::LISTING_WITH_OPTIONS => $this->_('Liste verticale à interactions'),
Intonation_Library_Widget_Carousel_Definition::WALL => $this->_('Mur'),
Intonation_Library_Widget_Carousel_Definition::MAP => $this->_('Carte géographique')],
Class_Template::current()->getCarouselLayouts());
asort($layouts, SORT_NATURAL | SORT_FLAG_CASE);
return $layouts;
return (new Intonation_Library_Widget_Carousel_Definition)->getLayouts();
}
......
......@@ -20,7 +20,7 @@
*/
class Intonation_Library_Widget_Menu_Definition extends Class_Systeme_ModulesAccueil_Null {
class Intonation_Library_Widget_Carousel_Menu_Definition extends Class_Systeme_ModulesAccueil_Null {
use Intonation_Library_Widget_TemplatesAwareNoHeader;
const
......@@ -32,10 +32,11 @@ class Intonation_Library_Widget_Menu_Definition extends Class_Systeme_ModulesAcc
$_group = Class_Systeme_ModulesAccueil::GROUP_SITE,
$_isPhone = false;
public function __construct() {
$this->_libelle = $this->_('Boite menu');
$this->_form = 'Intonation_Library_Widget_Menu_Form';
$this->_view_helper = 'Intonation_Library_Widget_Menu_View';
$this->_form = Intonation_Library_Widget_Carousel_Menu_Form::class;
$this->_view_helper = Intonation_Library_Widget_Carousel_Menu_View::class;
$this->_defaultValues = ['titre' => $this->_libelle,
'menu' => '',
'layout' => static::LAYOUT_HORIZONTAL,
......@@ -46,4 +47,31 @@ class Intonation_Library_Widget_Menu_Definition extends Class_Systeme_ModulesAcc
protected function _templateTitle() {
return $this->_('Menu');
}
public function getMenuLayouts() {
return [static::LAYOUT_HORIZONTAL => $this->_('Menu horizontal'),
static::LAYOUT_VERTICAL => $this->_('Menu vertical')];
}
public function getLayoutsList() {
$layouts = array_merge((new Intonation_Library_Widget_Carousel_Definition)
->getLayoutsList(),
$this->getMenuLayouts());
unset($layouts[Intonation_Library_Widget_Carousel_Definition::ACCORDION_CAROUSEL]);
unset($layouts[Intonation_Library_Widget_Carousel_Definition::MAP]);
unset($layouts[Intonation_Library_Widget_Carousel_Definition::LISTING]);
unset($layouts[Intonation_Library_Widget_Carousel_Definition::LISTING_WITH_OPTIONS]);
return $layouts;
}
public function getLayouts() {
return (new Intonation_Library_Widget_Carousel_Definition)
->getOrderedLayouts($this->getLayoutsList());
}
}
\ No newline at end of file
......@@ -20,25 +20,36 @@
*/
class Intonation_Library_Widget_Menu_Form extends ZendAfi_Form_Configuration_Widget_Base {
class Intonation_Library_Widget_Carousel_Menu_Form extends Intonation_Library_Widget_Carousel_Form {
public function init() {
parent::init();
$this
->addElement('select',
'menu',
['label' => $this->_('Menu utilisé'),
'registerInArrayValidator' => false,
'multiOptions' => (new Class_Systeme_ModulesAccueil_MenuVertical())->getMenus()])
->addElement('select',
'layout',
['label' => $this->_('Disposition'),
'multiOptions' => [Intonation_Library_Widget_Menu_Definition::LAYOUT_HORIZONTAL => $this->_('horizontale'),
Intonation_Library_Widget_Menu_Definition::LAYOUT_VERTICAL => $this->_('verticale')]])
->addToSelectionGroup(['menu'])
Class_Template::current()->customMenuForm($this);
}
public function customPopulate($datas, $form = null) {
parent::customPopulate($datas);
return $this
->replaceWith('data_sources',
['select',
'menu',
['label' => $this->_('Menu utilisé'),
'registerInArrayValidator' => false,
'multiOptions' => (new Class_Systeme_ModulesAccueil_MenuVertical())->getMenus()]])
->addToDisplaySettingsGroup(['layout']);
}
Class_Template::current()->customMenuForm($this);
public function getOrders() {
return [];
}
public function getLayouts() {
return
(new Intonation_Library_Widget_Carousel_Menu_Definition)
->getLayouts();
}
}
\ No newline at end of file
<?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_Library_Widget_Carousel_Menu_View extends Intonation_Library_Widget_Carousel_View {