Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (7)
Showing
with 546 additions and 391 deletions
- ticket #134990 : Magasin de thèmes : Ajout de classes sur les éléments de la liste de la boite de connexion. Tous les themes peuvent utiliser les menus dans la boite de connexion. Cette fonctionnalité n'est plus réservée au thème Chili.
\ No newline at end of file
- ticket #140745 : Administration : Correction de liens incompatibles avec une installation de Bokeh dans un sous-répertoire du serveur web
\ No newline at end of file
......@@ -23,6 +23,11 @@ class ZendAfi_Form_Configuration_Widget_Login extends ZendAfi_Form_Configuration
public function init() {
parent::init();
Class_ScriptLoader::getInstance()
->addJQueryReady('radioToggleVisibilityForElement("input[name=\'' . Class_Template::current()->withNameSpace('form_style') . '\']", $("#authenticated_menu, #not_authenticated_menu").closest("tr"), ["toggle"]);');
$menus = (new Class_Systeme_ModulesAccueil_MenuVertical())->getMenus();
$this
->addElement('text',
'titre_connecte',
......@@ -89,6 +94,18 @@ class ZendAfi_Form_Configuration_Widget_Login extends ZendAfi_Form_Configuration
'empty_option' => true,
'order' => 4])
->addElement('select',
'authenticated_menu',
['label' => $this->_('Menu à afficher en étant connecté'),
'registerInArrayValidator' => false,
'multiOptions' => $menus])
->addElement('select',
'not_authenticated_menu',
['label' => $this->_('Menu à afficher en mode déconnecté'),
'registerInArrayValidator' => false,
'multiOptions' => $menus])
->addToDisplaySettingsGroup(['titre_connecte',
'message_connecte',
'identifiant',
......@@ -110,6 +127,9 @@ class ZendAfi_Form_Configuration_Widget_Login extends ZendAfi_Form_Configuration
parent::custompopulate($datas, $form);
return $this
->addToDisplayGroup(['authenticated_menu',
'not_authenticated_menu'],
Class_Template::current()->withNameSpace('group'))
->addToStyleGroup(['autocomplete_off'])
->addToHeadGroup(['profil_redirect',
'profil_logout_redirect']);
......
......@@ -55,7 +55,7 @@ class ZendAfi_View_Helper_Admin_FrontNavEntries extends ZendAfi_View_Helper_Base
protected function _adminLinks() {
$links = [$this->_item('/admin',
$links = [$this->_item(Class_Url::absolute('/admin'),
$this->_('Accès pro.'),
$this->_('Accéder à l\'interface d\'administration'),
'home')];
......@@ -67,26 +67,26 @@ class ZendAfi_View_Helper_Admin_FrontNavEntries extends ZendAfi_View_Helper_Base
'redmine');
if ($this->_isAllowed('cms', 'index'))
$links[] = $this->_item('/admin/cms/',
$links[] = $this->_item(Class_Url::absolute('/admin/cms/'),
$this->_('Articles'),
$this->_('Accéder aux articles dans l\'interface d\'administration'),
'articles');
if ($this->_isAllowed('catalogue', 'index'))
$links[] = $this->_item('/admin/catalogue/',
$links[] = $this->_item(Class_Url::absolute('/admin/catalogue/'),
$this->_('Domaines'),
$this->_('Accéder aux domaines dans l\'interface d\'administration'),
'domains');
if ($this->_isAllowed('file-manager', 'index'))
$links[] = $this->_item('/admin/file-manager/',
$links[] = $this->_item(Class_Url::absolute('/admin/file-manager/'),
$this->_('Explorateur de fichiers'),
$this->_('Accéder à l\'explorateur de fichiers dans un nouvel onglet'),
'filebrowser',
['target' => '_blank']);
if ($this->_isAllowed('users', 'index'))
$links[] = $this->_item('/admin/users',
$links[] = $this->_item(Class_Url::absolute('/admin/users'),
$this->_('Utilisateurs'),
$this->_('Accéder aux utilisateurs dans l\'interface d\'administration'),
'users');
......@@ -120,7 +120,7 @@ class ZendAfi_View_Helper_Admin_FrontNavEntries extends ZendAfi_View_Helper_Base
protected function _itemPopup($url, $label, $title, $icon, $attribs=[]) {
return $this->_item($url, $label, $title, $icon,
return $this->_item(Class_Url::absolute($url), $label, $title, $icon,
array_merge(['data-popup' => 'true'], $attribs));
}
......@@ -145,7 +145,7 @@ class ZendAfi_View_Helper_Admin_FrontNavEntries extends ZendAfi_View_Helper_Base
&& Class_Users::isCurrentUserAllowedToEditProfile($this->_profile))
$actions = $this->_profileActions($actions);
$actions []= $this->_item('/admin/index/clearcache/',
$actions []= $this->_item(Class_Url::absolute('/admin/index/clearcache/'),
$this->_('Vider le cache'),
$this->_('Vider le cache de Bokeh'),
'delete');
......@@ -273,7 +273,7 @@ class ZendAfi_View_Helper_Admin_FrontNavEntries extends ZendAfi_View_Helper_Base
'showAmberIDE();$("#amber").show();',
'$("#amber").hide();');
$tools[] = $this->_item('/admin/profil/export/id_profil/' . $this->_profile_id,
$tools[] = $this->_item(Class_Url::absolute('/admin/profil/export/id_profil/') . $this->_profile_id,
$this->_('Exporter le profil courant'),
$this->_('Exporter le profil "%s" au format JSON',
$this->_profile_label),
......
......@@ -22,35 +22,47 @@ class ZendAfi_View_Helper_FicheAbonneLinks extends ZendAfi_View_Helper_BaseHelpe
public function ficheAbonneLinks($nb_prets, $nb_retards, $nb_reservations) {
$html = [];
if ($nb_prets)
$html [] = $this->view->tagAnchor(['controller' => 'abonne',
'action' => 'prets'],
$this->view->_plural($nb_prets,
"",
"%d prêt en cours",
"%d prêts en cours",
$nb_prets).
$this->view->_plural($nb_retards,
"",
", %d en retard",
", %d en retard",
$nb_retards),
['class' => 'account-loans']);
if ($nb_retards)
$html = [$this->_tag('span',
implode($html),
['class' => 'pret_en_retard'])];
if ($nb_prets || $nb_retards)
$html [] = $this->_getLoansCount($nb_prets, $nb_retards);
if ($nb_reservations)
$html [] = $this->view->tagAnchor(['controller' => 'abonne',
'action' => 'reservations'],
$this->view->_plural($nb_reservations,
"",
"%d réservation",
"%d réservations",
$nb_reservations),
['class'=>'account-booking']);
$html [] = $this->_getHoldsCount($nb_reservations);
return $html;
}
protected function _getLoansCount($nb_prets, $nb_retards) {
$loans = $this->view->tagAnchor(['controller' => 'abonne',
'action' => 'prets'],
$this->view->_plural($nb_prets,
"",
"%d prêt en cours",
"%d prêts en cours",
$nb_prets).
$this->view->_plural($nb_retards,
"",
", %d en retard",
", %d en retard",
$nb_retards),
['class' => 'account-loans']);
return $nb_retards
? $this->_tag('span',
$loans,
['class' => 'pret_en_retard'])
: $loans;
}
protected function _getHoldsCount($nb_reservations) {
return $this->view->tagAnchor(['controller' => 'abonne',
'action' => 'reservations'],
$this->view->_plural($nb_reservations,
"",
"%d réservation",
"%d réservations",
$nb_reservations),
['class'=>'account-booking']);
}
}
\ No newline at end of file
......@@ -100,22 +100,6 @@ class Chili_Template extends Intonation_Template {
}
public function customLoginForm($form) {
return (new Chili_Library_FormCustomizer_Login($this, $form))->getForm();
}
public function getWidgets() {
if ($this->_widgets_cache)
return $this->_widgets_cache;
parent::getWidgets();
$this->_widgets_cache[Intonation_Library_Widget_Login_Definition::CODE] = new Chili_Library_Widget_Login_Definition;
return $this->_widgets_cache;
}
public function customUserRichContents($sections) {
unset($sections[Intonation_Library_View_Wrapper_User_RichContent::HOME]);
array_unshift($sections, 'Chili_Library_Wrapper_User_RichContent_Home');
......
......@@ -308,6 +308,9 @@ class Intonation_Library_Settings extends Intonation_System_Abstract {
'div class library_opening_hours' => 'col-12 d-none',
'div class menu_with_carousel_layout' => 'overflow-visible',
'div class record_no_thumbnail' => 'card card-img-overlay',
'a class account-link' => 'btn btn-sm btn-primary',
'a class account-disconnect' => 'btn btn-sm btn-secondary',
'span class user_notifications' => 'btn btn-sm list-group-item-danger',
],
'icons_map_doc_types' => [],
......
......@@ -32,6 +32,11 @@ class Intonation_Library_View_Wrapper_MenuEntry extends Intonation_Library_View_
}
public function getClass() {
return $this->_model->getModuleType(). '_' . $this->_model->getParent() . '_' . $this->_model->getId();
}
public function getMainLink() {
return '';
}
......
<?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
*/
abstract class Intonation_Library_Widget_Login_RenderAbstract {
use Trait_Translator;
protected
$_view,
$_settings,
$_user;
abstract public function renderLogged();
public function __construct($view, $settings, $user) {
$this->_view = $view;
$this->_settings = $settings;
$this->_user = $user;
}
public function renderLogin() {
$form = $this->_getLoginForm();
$show_password_button =
$this->_view->tag('div',
Class_Template::current()
->getIco($this->_view,
'eye',
'utils'),
['onclick' => "$(this).parent().find('input').attr('type', function(index, attr) {return attr == 'password' ? 'text' : 'password';});",
'class' => 'password_toggle']);
$show_password_js = sprintf('$("#password").parent().append("%s"); $("#password").parent().attr("style", "position: relative;");',
str_replace('"', '\"', $show_password_button));
Class_ScriptLoader::getInstance()
->addJQueryReady($show_password_js);
return $this->_renderForm($form);
}
protected function _getLoginForm() {
$options = [];
foreach($this->_settings->toArray() as $key => $value)
if (is_string($value) || is_int($value))
$options [Storm_Inflector::underscorize($key)] = $value;
$form = ZendAfi_Form_Login::newWithOptions(['data' => $options]);
$action = $this->_settings->getClearAction()
? ''
: $this->_view->url(['controller' => 'auth',
'action' => 'login',
'redirect' => $this->_redirectUrl($options)]);
$form
->setAction($action);
$form->removeElement('loginlink');
$form->getElement('username')->setOrder(1);
$form->getElement('password')->setOrder(2);
$form->getElement('login')->setOrder(3);
$form->getElement('lostpass')->setOrder(4);
if (Class_AdminVar::isEnregUtilAllowed())
$form->getElement('register')->setOrder(5);
return $form;
}
protected function _redirectUrl($options) {
if ( isset($options['redirect_url']))
return $options['redirect_url'];
return ($profile_id = $this->_settings->getProfilRedirect())
? Class_Url::absolute(['id_profil' => $profile_id])
: Class_Url::absolute();
}
protected function _htmlForLoggedLinks() {
$links = $this->_getLoggedLinks();
$html = array_map(function($link)
{
return $this->_view->tag('li', $this->_view->tagAction($link), ['class' => 'wrapper_' . $link->getClass() . $this->_getLinksClass()]);
}, $links);
return $this->_view->tag('ul', implode($html), ['class' => $this->_getUnorderedListClass()]);
}
protected function _getLoggedLinks() {
$links = [$this->_accountPageLink()];
$links [] = $this->_logoutLink();
$links = $this->_addCardsLinksTo($links);
$links = $this->_addNotificationsLinksTo($links);
return $links;
}
protected function _accountPageLink() {
$url = $this->_view->url(['controller' => 'abonne',
'action' => 'fiche',
'id_profil' => ($this->_settings->getProfilRedirect() > 0
? $this->_settings->getProfilRedirect()
: Class_Profil::getCurrentProfil()->getId())],
null, true);
return (new Intonation_Library_Link)
->setUrl($url)
->setText($this->_view->abonne_Name($this->_user))
->setTitle($this->_('Accéder à l\'interface de gestion de %s.', $this->_user->getNomComplet()))
->setAttrib('class', 'account-link')
->beNotResponsiveText();
}
protected function _logoutLink() {
return (new Intonation_Library_Link)
->setUrl($this->_view->url(['controller'=>'auth',
'action'=>'logout'], null, true))
->setText($this->_settings->getLienDeconnection())
->setTitle($this->_('Se déconnecter de la session %s', $this->_user->getNomComplet()))
->setAttrib('class', 'account-disconnect')
->beNotResponsiveText();
}
protected function _addCardsLinksTo($links) {
$cards = new Class_User_Cards($this->_user);
if ( $cards->isEmpty())
return $links;
if ($cards->hasPagedLoans()) {
$links [] = (new Intonation_Library_Link)
->setUrl($this->_view->url(['controller'=>'abonne',
'action'=>'prets',
'pages' => 'all']))
->setText($this->_view->_('Voir tous mes prêts'))
->setTitle($this->_('Voir tous les prêts de %s', $this->_user->getNomComplet()))
->setAttrib('class', 'account-loans')
->beNotResponsiveText();
return $links;
}
return array_merge($links,
$this->_view->User_BorrowerLinks($cards));
}
protected function _addNotificationsLinksTo($links) {
return ($notifications = $this->_view->User_RenderNotifications($this->_user))
? array_merge($links, $notifications)
: $links;
}
protected function _getLinksClass() {
return '';
}
protected function _getUnorderedListClass() {
return '';
}
protected function _renderForm($form) {
return $this->_view->renderForm($form);
}
}
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
* 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
......@@ -20,30 +20,32 @@
*/
class Chili_Library_FormCustomizer_Login extends Intonation_Library_FormCustomizer_Abstract {
class Intonation_Library_Widget_Login_RenderDefault extends Intonation_Library_Widget_Login_RenderAbstract {
public function getForm() {
Class_ScriptLoader::getInstance()
->addJQueryReady('radioToggleVisibilityForElement("input[name=\'' . Class_Template::current()->withNameSpace('form_style') . '\']", $("#authenticated_menu, #not_authenticated_menu").closest("tr"), ["toggle"]);');
public function renderLogged() {
$html =
$this->_view->tag('p',
$this->_settings->getMessageConnecte()
. ' '
. $this->_view->abonne_NamesOrLogin($this->_user),
['class' => 'default_login_connected_message']);
$menus = (new Class_Systeme_ModulesAccueil_MenuVertical())->getMenus();
return $this->_view->div(['class' => 'default_login'],
$html . $this->_htmlForLoggedLinks());
}
$this->_form
->addElement('select',
'authenticated_menu',
['label' => $this->_('Menu à afficher en étant connecté'),
'registerInArrayValidator' => false,
'multiOptions' => $menus])
->addElement('select',
'not_authenticated_menu',
['label' => $this->_('Menu à afficher en mode déconnecté'),
'registerInArrayValidator' => false,
'multiOptions' => $menus])
protected function _accountPageLink() {
$page_link = parent::_accountPageLink();
return $page_link->setText($this->_settings->getLienCompte());
}
->addToDisplayGroup(['authenticated_menu', 'not_authenticated_menu'],
Class_Template::current()->withNameSpace('group'));
return $this;
protected function _getLoggedLinks() {
$links = [$this->_accountPageLink()];
$links = $this->_addCardsLinksTo($links);
$links = $this->_addNotificationsLinksTo($links);
$links [] = $this->_logoutLink();
return $links;
}
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
* 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
......@@ -20,9 +20,25 @@
*/
class Chili_Library_Widget_Login_Definition extends Intonation_Library_Widget_Login_Definition {
public function __construct() {
parent::__construct();
$this->_view_helper = Chili_Library_Widget_Login_View::class;
class Intonation_Library_Widget_Login_RenderInline extends Intonation_Library_Widget_Login_RenderAbstract {
public function renderLogged() {
return $this->_view->div(['class' => 'inline_login'],
$this->_htmlForLoggedLinks());
}
protected function _getLinksClass() {
return ' list-inline-item';
}
protected function _getUnorderedListClass() {
return ' list-inline';
}
protected function _renderForm($form) {
return $this->_view->renderInlineForm($form);
}
}
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
* 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
......@@ -20,43 +20,64 @@
*/
class Chili_Library_Widget_Login_View extends Intonation_Library_Widget_Login_View {
protected function _getRenderStrategy() {
if ('toggle' == $this->_settings->getFormStyle())
return new ChililLoginRenderToggle($this->view, $this->_settings, $this->_user);
class Intonation_Library_Widget_Login_RenderToggle extends Intonation_Library_Widget_Login_RenderAbstract {
return parent::_getRenderStrategy();
public function renderLogged() {
$html = ($menu = $this->_withIdMenuRender($this->_settings->getAuthenticatedMenu()))
? $this->_htmlWithMenu($menu)
: $this->_htmlWithoutMenu();
return $this->_view->renderDropdown($html,
$this->_view->abonne_Name($this->_user),
'',
'dropdown-menu-right');
}
}
protected function _htmlWithMenu($menu) {
return $this->_view->tag('h1',
$this->_user->getNomAff(),
['class' => 'widget-header'])
. $menu;
}
protected function _htmlWithoutMenu() {
return $this->_view->div([], $this->_htmlForLoggedLinks());
}
protected function _getLinksClass() {
return ' mb-1';
}
public function renderLogin() {
return $this->_view->renderDropdown($this->_parentRenderLogin(),
$this->_settings->getTitre(),
'',
'dropdown-menu-right');
}
class ChililLoginRenderToggle extends IntonationLoginRenderToggle {
protected function _parentRenderLogin() {
return
parent::_parentRenderLogin()
parent::renderLogin()
. $this->_withIdMenuRender($this->_settings->getNotAuthenticatedMenu());
}
public function renderLogged() {
$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');
protected function _renderForm($form) {
return $this->_view->renderStackedForm($form);
}
protected function _withIdMenuRender($id_menu) {
if ( ! $id_menu)
return '';
$helper = new Intonation_Library_Widget_Carousel_Menu_View(md5($id_menu),
['type_module' => 'MENU',
'preferences' => ['menu' => $id_menu]]);
......@@ -66,4 +87,15 @@ class ChililLoginRenderToggle extends IntonationLoginRenderToggle {
return $helper->getContent();
}
protected function _accountPageLink() {
$page_link = parent::_accountPageLink();
$text = ($text = $this->_settings->getTitreConnecte())
? $text
: $this->_settings->getLienCompte();
return $page_link->setText($text);
}
}
......@@ -52,12 +52,12 @@ class Intonation_Library_Widget_Login_View extends Zendafi_View_Helper_Accueil_B
$form_style = $this->_settings->getFormStyle();
if('inline' == $form_style)
return new IntonationLoginRenderInline($this->view, $this->_settings, $this->_user);
return new Intonation_Library_Widget_Login_RenderInline($this->view, $this->_settings, $this->_user);
if('toggle' == $form_style)
return new IntonationLoginRenderToggle($this->view, $this->_settings, $this->_user);
return new Intonation_Library_Widget_Login_RenderToggle($this->view, $this->_settings, $this->_user);
return new IntonationLoginRenderDefault($this->view, $this->_settings, $this->_user);
return new Intonation_Library_Widget_Login_RenderDefault($this->view, $this->_settings, $this->_user);
}
......@@ -69,321 +69,4 @@ class Intonation_Library_Widget_Login_View extends Zendafi_View_Helper_Accueil_B
protected function _renderLogin() {
return $this->_render_strategy->renderLogin();
}
}
abstract class IntonationLoginRenderAbstract {
use Trait_Translator;
protected
$_view,
$_settings,
$_user;
public function __construct($view, $settings, $user) {
$this->_view = $view;
$this->_settings = $settings;
$this->_user = $user;
}
protected function _getLoginForm() {
$options = [];
foreach($this->_settings->toArray() as $key => $value)
if (is_string($value) || is_int($value))
$options [Storm_Inflector::underscorize($key)] = $value;
$form = ZendAfi_Form_Login::newWithOptions(['data' => $options]);
$action = $this->_settings->getClearAction()
? ''
: $this->_view->url(['controller' => 'auth',
'action' => 'login',
'redirect' => $this->_redirectUrl($options)]);
$form
->setAction($action);
$form->removeElement('loginlink');
$form->getElement('username')->setOrder(1);
$form->getElement('password')->setOrder(2);
$form->getElement('login')->setOrder(3);
$form->getElement('lostpass')->setOrder(4);
if (Class_AdminVar::isEnregUtilAllowed())
$form->getElement('register')->setOrder(5);
return $form;
}
protected function _redirectUrl($options) {
if ( isset($options['redirect_url']))
return $options['redirect_url'];
return ($profile_id = $this->_settings->getProfilRedirect())
? Class_Url::absolute(['id_profil' => $profile_id])
: Class_Url::absolute();
}
abstract function renderLogged();
public function renderLogin() {
$form = $this->_getLoginForm();
$show_password_button =
$this->_view->tag('div',
Class_Template::current()
->getIco($this->_view,
'eye',
'utils'),
['onclick' => "$(this).parent().find('input').attr('type', function(index, attr) {return attr == 'password' ? 'text' : 'password';});",
'class' => 'password_toggle']);
$show_password_js = sprintf('$("#password").parent().append("%s"); $("#password").parent().attr("style", "position: relative;");',
str_replace('"', '\"', $show_password_button));
Class_ScriptLoader::getInstance()
->addJQueryReady($show_password_js);
return $this->_renderForm($form);
}
protected function _getLinkAttribs() {
return [];
}
protected function _getLinksListAttribs() {
return [];
}
protected function _renderForm($form) {
return $this->_view->renderForm($form);
}
}
class IntonationLoginRenderDefault extends IntonationLoginRenderAbstract {
public function renderLogged() {
$user = $this->_user;
$html = [$this->_view->tag('p',
$this->_settings->getMessageConnecte() . ' ' . $this->_view->abonne_NamesOrLogin($user))];
$user_url = $this->_view->url(['controller' => 'abonne',
'action' => 'fiche',
'id_profil' => $this->_settings->getProfilRedirect() > 0 ? $this->_settings->getProfilRedirect() : Class_Profil::getCurrentProfil()->getId()],
null, true);
$links = [$this->_view->tagAnchor($user_url,
$this->_settings->getLienCompte(),
['title' => $this->_('Accéder à l\'interface de gestion de %s.', $user->getNomComplet()),
'class' => 'account-link'])];
$cards = new Class_User_Cards($user);
if (!$cards->isEmpty()) {
$loans = $cards->hasPagedLoans()
? [$this->_view->tagAnchor(['controller' => 'abonne',
'action' => 'prets',
'pages' => 'all'],
$this->view->_('Voir tous mes prêts'),
['class' => 'account-loans'])]
: $this->_view->ficheAbonneLinks($cards->getLoansCount(),
$cards->getLateLoansCount(),
$cards->getHoldsCount());
$links = array_merge($links,$loans);
}
if($notifications = $this->_view->renderNotifications($user))
$links = array_merge($links, $notifications);
$links [] = $this->_view->tag('a', $this->_settings->getLienDeconnection(),
['title' => $this->_('Se déconnecter de la session %s', $user->getNomComplet()),
'href' => $this->_view->url(['controller'=>'auth',
'action'=>'logout'],
null, true),
'class' => 'account-disconnect']);
$links = array_filter($links);
$links = array_map(function($link)
{
return $this->_view->tag('li', $link);
}, $links);
$links = $this->_view->tag('ul',
implode($links));
return $this->_view->tag('div',
implode($html)
. $links);
}
}
class IntonationLoginRenderInline extends IntonationLoginRenderAbstract {
public function renderLogged() {
$user = $this->_user;
$user_url = $this->_view->url(['controller' => 'abonne',
'action' => 'fiche',
'id_profil' => ($this->_settings->getProfilRedirect() > 0
? $this->_settings->getProfilRedirect()
: Class_Profil::getCurrentProfil()->getId())],
null, true);
$links = [$this->_view
->button((new Class_Button)
->setUrl($user_url)
->setText($this->_view->abonne_Name($user))
->setTitle($this->_('Accéder à l\'interface de gestion de %s.',
$user->getNomComplet()))
->setAttrib('class', 'btn btn-sm btn-primary'))];
if ($logout = $this->_settings->getLienDeconnection())
$links [] = $this->_view
->button((new Class_Button)
->setText($logout)
->setTitle($this->_('Se déconnecter de la session %s', $user->getNomComplet()))
->setAttrib('class', 'btn btn-sm btn-danger')
->setUrl($this->_view->url(['controller' => 'auth',
'action' => 'logout'],
null, true)));
$cards = new Class_User_Cards($user);
if (!$cards->isEmpty()) {
$loans = $cards->hasPagedLoans()
? [$this->_view->tagAnchor(['controller' => 'abonne',
'action' => 'prets',
'pages' => 'all'],
$this->view->_('Voir tous mes prêts'),
['class' => 'account-loans'])]
: $this->_view->ficheAbonneLinks($cards->getLoansCount(),
$cards->getLateLoansCount(),
$cards->getHoldsCount());
$links = array_merge($links,$loans);
}
if($notifications = $this->_view->renderNotifications($user))
$links = array_merge($links, $notifications);
$links = array_filter($links);
$links = array_map(function($link)
{
return $this->_view->tag('li', $link, ['class' => 'list-inline-item']);
}, $links);
return $this->_view->div([],
$this->_view->tag('ul',
implode($links),
$this->_getLinksListAttribs()));
}
protected function _getLinkAttribs() {
return ['class' => 'list-inline-item small'];
}
protected function _getLinksListAttribs() {
return ['class' => 'list-inline'];
}
protected function _renderForm($form) {
return $this->_view->renderInlineForm($form);
}
}
class IntonationLoginRenderToggle extends IntonationLoginRenderAbstract {
public function renderLogin() {
return $this->_view->renderDropdown($this->_parentRenderLogin(), $this->_settings->getTitre(), '', 'dropdown-menu-right');
}
protected function _parentRenderLogin() {
return parent::renderLogin();
}
public function renderLogged() {
$user_url = $this->_view->url(['controller' => 'abonne',
'action' => 'fiche',
'id_profil' => $this->_settings->getProfilRedirect() > 0 ? $this->_settings->getProfilRedirect() : Class_Profil::getCurrentProfil()->getId()],
null, true);
$links = [$this->_view->tagAction((new Intonation_Library_Link)
->setUrl($user_url)
->setText($this->_settings->getTitreConnecte()
? $this->_settings->getTitreConnecte()
: $this->_settings->getLienCompte())
->setTitle($this->_('Accéder à l\'interface de gestion de %s.',
$this->_user->getNomComplet()))
->setClass('btn btn-sm btn-primary')),
$this->_view->tagAction((new Intonation_Library_Link)
->setUrl($this->_view->url(['controller'=>'auth',
'action'=>'logout'],
null, true))
->setText($this->_settings->getLienDeconnection())
->setTitle($this->_('Se déconnecter de la session %s',
$this->_user->getNomComplet()))
->setClass('btn btn-sm btn-secondary'))];
$cards = new Class_User_Cards($this->_user);
if (!$cards->isEmpty()) {
$loans = $cards->hasPagedLoans()
? [$this->_view->tagAnchor(['controller' => 'abonne',
'action' => 'prets',
'pages' => 'all'],
$this->view->_('Voir tous mes prêts'),
['class' => 'account-loans'])]
: $this->_view->ficheAbonneLinks($cards->getLoansCount(),
$cards->getLateLoansCount(),
$cards->getHoldsCount());
$links = array_merge($links,$loans);
}
if($notifications = $this->_view->renderNotifications($this->_user))
$links = array_merge($links, $notifications);
$links = array_filter($links);
$links = array_map(function($link)
{
return $this->_view->tag('li', $link, ['class' => 'mb-1']);
}, $links);
$html = $this->_view->div([],
$this->_view->tag('ul',
implode($links),
$this->_getLinksListAttribs()));
return $this->_view->renderDropdown($html,
$this->_view->abonne_Name($this->_user),
'',
'dropdown-menu-right');
}
protected function _renderForm($form) {
return $this->_view->renderStackedForm($form);
}
}
}
\ No newline at end of file
......@@ -38,7 +38,7 @@ abstract class Intonation_View_Menu_Abstract extends ZendAfi_View_Helper_BaseHel
$html = '';
foreach ( $collection as $menu)
$html .= $this->_tag('li', $callback($menu), ['class' => 'nav-item'. (($menu->isMenu())
$html .= $this->_tag('li', $callback($menu), ['class' => 'nav-item menu_entry_' . $menu->getClass(). (($menu->isMenu())
? ' dropdown'
: '')]);
......
......@@ -76,7 +76,11 @@ class Intonation_View_RenderMenuEntry extends ZendAfi_View_Helper_BaseHelper {
$html[] = $this->_tag('li',
$this->_renderMenuEntry($menu_entry_child, $use_menu_layout),
['class' => 'nav-item' . (($menu_entry_child->isMenu())
['class' => sprintf('nav-item menu_entry_%s_%s_%s',
$menu_entry_child->getModuleType(),
$menu_entry_child->getParent(),
$menu_entry_child->getId()) . (($menu_entry_child->isMenu())
? ' dropdown'
: '')]);
}
......
......@@ -65,9 +65,13 @@ class Intonation_View_TagAction extends ZendAfi_View_Helper_BaseHelper {
'class' => implode(' ', $classes)],
$attribs);
$tag = ($element = $action->getElement())
? $element
: 'a';
return ($url = $action->getUrl())
? $this->view->tagAnchor($url, $content, $attribs)
: $this->_tag('a', (string) $content, $attribs);
: $this->_tag($tag, (string) $content, $attribs);
}
......
<?php
/**
* Copyright (c) 2012, 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_User_BorrowerLinks extends ZendAfi_View_Helper_FicheAbonneLinks {
public function User_BorrowerLinks($cards) {
$loans_count = $cards->getLoansCount();
$late_loans_count = $cards->getLateLoansCount();
$holds_count = $cards->getHoldsCount();
return parent::ficheAbonneLinks($loans_count, $late_loans_count, $holds_count);
}
protected function _getLoansCount($nb_prets, $nb_retards) {
return (new Intonation_Library_Link)
->setText($this->view->_plural($nb_prets,
"",
"%d prêt en cours",
"%d prêts en cours",
$nb_prets).
$this->view->_plural($nb_retards,
"",
", %d en retard",
", %d en retard",
$nb_retards))
->setAttrib('class', 'account-loans' . ( $nb_retards ? ' pret_en_retard' : ''))
->setUrl($this->view->url(['controller' => 'abonne',
'action' => 'prets'], null, true));
}
protected function _getHoldsCount($nb_reservations) {
return (new Intonation_Library_Link)
->setText($this->view->_plural($nb_reservations,
"",
"%d réservation",
"%d réservations",
$nb_reservations))
->setAttrib('class', 'account-booking')
->setUrl($this->view->url(['controller' => 'abonne',
'action' => 'reservations'],
null, true));
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
* 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
......@@ -20,11 +20,19 @@
*/
class Intonation_View_RenderNotifications extends ZendAfi_View_Helper_RenderNotifications {
class Intonation_View_User_RenderNotifications extends ZendAfi_View_Helper_RenderNotifications {
public function User_RenderNotifications($user) {
return parent::renderNotifications($user);
}
protected function _renderNotifications() {
return array_map(function($message)
return array_map(function($notification)
{
return $this->_tag('span', $message , ['class' => 'btn btn-sm list-group-item-danger']);
return (new Intonation_Library_Link)
->setText($notification)
->setElement('span')
->setAttrib('class', 'user_notifications');
}, $this->_messages);
}
}
\ No newline at end of file
......@@ -212,7 +212,7 @@ class ChiliLoginWidgetFrontTest extends ChiliLoginWidgetTestCase {
/** @test */
public function menuCardsShouldDisplayBadgeEndValidity14122021() {
$this->assertXPathContentContains('//a[contains(@class, "nav-link")][contains(@href, "/abonne/cards")]//span[contains(@class, "badge_tag")]','14/12/2021');
$this->assertXPathContentContains('//li[@class="nav-item menu_entry_ABON_CARDS_0_4"]//a[contains(@class, "nav-link")][contains(@href, "/abonne/cards")]//span[contains(@class, "badge_tag")]','14/12/2021');
}
......@@ -228,7 +228,7 @@ class ChiliLoginWidgetFrontTest extends ChiliLoginWidgetTestCase {
/** @test */
public function loginWidgetShouldContainsLastNewsLink() {
$this->assertXPathContentContains('//div[contains(@class, "dropdown-menu-right")]//a[@href="/widget/render-menu-entry/id_menu/0/menu_profil/4/id_submenu/6"]', 'Latest news');
$this->assertXPathContentContains('//div[contains(@class, "dropdown-menu-right")]//li[@class= "nav-item menu_entry_NEWS_0_6"]//a[@href="/widget/render-menu-entry/id_menu/0/menu_profil/4/id_submenu/6"]', 'Latest news');
}
}
......@@ -247,7 +247,7 @@ class ChiliLoginNotLoggedTest extends ChiliLoginWidgetTestCase {
/** @test */
public function formActionShouldContainsRedircetToFirstProfile() {
$this->assertXPath('//div//form[contains(@action, "/auth/login/id_profil/4/redirect/")][contains(@action, "%2Findex%2Findex%2Fid_profil%2F1")]', $this->_response->getBody());
$this->assertXPath('//div//form[contains(@action, "/auth/login/id_profil/4/redirect/")][contains(@action, "%2Findex%2Findex%2Fid_profil%2F1")]');
}
}
......
......@@ -135,13 +135,13 @@ class TemplatesMenuDispatchIndexTest extends TemplatesIntonationTestCase {
/** @test */
public function navDropdownAnchorShouldHaveOnclichReturnFalse() {
$this->assertXPath('//li[@class="nav-item dropdown"]/a[@onclick="return false;"]');
$this->assertXPath('//li[@class="nav-item menu_entry_MENU_H_0 dropdown"]/a[@onclick="return false;"]');
}
/** @test */
public function allNavItemShouldNotHaveDropdownClass() {
$this->assertXPath('//li[@class="nav-item"]');
$this->assertXPath('//li[@class="nav-item menu_entry_PROFIL_H_1"]');
}
}
......@@ -521,12 +521,12 @@ class TemplatesMenuWithSubmenuTest extends TemplatesMenuTestCase {
/** @test */
public function liShouldHaveClassNavItemDropdown() {
$this->assertXPath('//li[@class="nav-item dropdown"]/a[@onclick="return false;"]');
$this->assertXPath('//li[@class="nav-item menu_entry_MENU_0_1 dropdown"]/a[@onclick="return false;"]');
}
/** @test */
public function allNavItemShouldNotHaveDropdownClass() {
$this->assertXPath('//li[@class="nav-item dropdown"]//li[@class="nav-item"]/a');
$this->assertXPath('//li[@class="nav-item menu_entry_MENU_0_1 dropdown"]//li[@class="nav-item menu_entry_URL_0_2"]/a');
}
}