2023-09-05 15:21:01 +02:00
< ? php
class layout extends common
{
private $core ;
public function __construct ( core $core )
{
parent :: __construct ();
$this -> core = $core ;
}
/**
* Affiche le consentement aux cookies
*/
public function showCookies ()
{
// La gestion des cookies est externalisée
if ( $this -> getData ([ 'config' , 'cookieConsent' ]) === false ) {
return ;
}
// Le cookie est déjà validé
if ( $this -> getInput ( 'ZWII_COOKIE_CONSENT' ) === 'true' ) {
return ;
}
$item = '<div id="cookieConsent">' ;
// Bouton de fermeture
$item .= '<div class="cookieClose">' ;
$item .= template :: ico ( 'cancel' );
$item .= '</div>' ;
// Texte de la popup
2023-09-05 15:31:35 +02:00
$item .= '<h3>' . $this -> getData ([ 'config' , 'cookies' , 'titleLabel' ]) . '</h3>' ;
$item .= '<p>' . $this -> getData ([ 'config' , 'cookies' , 'mainLabel' ]) . '</p>' ;
2023-09-05 15:21:01 +02:00
// Formulaire de réponse
if (
2023-09-30 13:35:20 +02:00
$this -> homePageId () === $this -> getUrl ( 0 )
2023-09-05 15:21:01 +02:00
) {
$item .= '<form method="POST" action="' . helper :: baseUrl ( false ) . '" id="cookieForm">' ;
} else {
$item .= '<form method="POST" action="' . helper :: baseUrl ( true ) . $this -> getUrl () . '" id="cookieForm">' ;
}
$item .= '<br><br>' ;
2023-09-05 15:31:35 +02:00
$item .= '<input type="submit" id="cookieConsentConfirm" value="' . $this -> getData ([ 'config' , 'cookies' , 'buttonValidLabel' ]) . '">' ;
2023-09-05 15:21:01 +02:00
$item .= '</form>' ;
// mentions légales si la page est définie
2023-09-05 15:31:35 +02:00
$legalPage = $this -> getData ([ 'config' , 'legalPageId' ]);
2023-09-05 15:21:01 +02:00
if ( $legalPage !== 'none' ) {
2023-09-05 15:31:35 +02:00
$item .= '<p><a href="' . helper :: baseUrl () . $legalPage . '">' . $this -> getData ([ 'config' , 'cookies' , 'linkLegalLabel' ]) . '</a></p>' ;
2023-09-05 15:21:01 +02:00
}
$item .= '</div>' ;
echo $item ;
}
/**
* Formate le contenu de la page selon les gabarits
* @ param Page par defaut
*/
public function showMain ()
{
2024-04-21 15:54:15 +02:00
echo '<main>' ;
2023-09-05 15:21:01 +02:00
// Récupérer la config de la page courante
$blocks = is_null ( $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'block' ])) ? '12' : $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'block' ]);
$blocks = explode ( '-' , $blocks );
// Initialiser
$blockleft = '' ;
$blockright = '' ;
switch ( sizeof ( $blocks )) {
case 1 : // une colonne
$content = 'col' . $blocks [ 0 ];
break ;
case 2 : // 2 blocs
if ( $blocks [ 0 ] < $blocks [ 1 ]) { // détermine la position de la colonne
$blockleft = 'col' . $blocks [ 0 ];
$content = 'col' . $blocks [ 1 ];
} else {
$content = 'col' . $blocks [ 0 ];
$blockright = 'col' . $blocks [ 1 ];
}
break ;
case 3 : // 3 blocs
$blockleft = 'col' . $blocks [ 0 ];
$content = 'col' . $blocks [ 1 ];
$blockright = 'col' . $blocks [ 2 ];
}
// Page pleine pour la configuration des modules et l'édition des pages sauf l'affichage d'un article de blog
$pattern = [ 'config' , 'edit' , 'add' , 'comment' , 'data' ];
if (
( sizeof ( $blocks ) === 1 ||
in_array ( $this -> getUrl ( 1 ), $pattern ))
) { // Pleine page en mode configuration
if ( $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navLeft' ]) === 'top' || $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navRight' ]) === 'top' ) {
$this -> showNavButtons ( 'top' );
}
$this -> showContent ();
if ( $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navLeft' ]) === 'bottom' || $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navRight' ]) === 'bottom' ) {
$this -> showNavButtons ( 'bottom' );
}
} else {
echo '<div class="row siteContainer">' ;
/**
* Barre gauche
*/
if ( $blockleft !== '' ) {
echo '<div class="' . $blockleft . '" id="contentLeft"><aside>' ;
// Détermine si le menu est présent
if ( $this -> getData ([ 'page' , $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'barLeft' ]), 'displayMenu' ]) === 'none' ) {
// Pas de menu
echo $this -> core -> output [ 'contentLeft' ];
} else {
// $mark contient 0 le menu est positionné à la fin du contenu
$contentLeft = str_replace ( '[]' , '[MENU]' , $this -> core -> output [ 'contentLeft' ]);
$contentLeft = str_replace ( '[menu]' , '[MENU]' , $contentLeft );
$mark = strrpos ( $contentLeft , '[MENU]' ) !== false ? strrpos ( $contentLeft , '[MENU]' ) : strlen ( $contentLeft );
echo substr ( $contentLeft , 0 , $mark );
echo '<div id="menuSideLeft">' ;
echo $this -> showMenuSide ( $this -> getData ([ 'page' , $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'barLeft' ]), 'displayMenu' ]) === 'parents' ? false : true );
echo '</div>' ;
echo substr ( $contentLeft , $mark + 6 , strlen ( $contentLeft ));
}
echo " </aside></div> " ;
}
/**
* Contenu de page
*/
echo '<div class="' . $content . '" id="contentSite">' ;
$this -> showNavButtons ( 'top' );
$this -> showContent ();
$this -> showNavButtons ( 'bottom' );
echo '</div>' ;
/**
* Barre droite
*/
if ( $blockright !== '' ) {
echo '<div class="' . $blockright . '" id="contentRight"><aside>' ;
// Détermine si le menu est présent
if ( $this -> getData ([ 'page' , $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'barRight' ]), 'displayMenu' ]) === 'none' ) {
// Pas de menu
echo $this -> core -> output [ 'contentRight' ];
} else {
// $mark contient 0 le menu est positionné à la fin du contenu
$contentRight = str_replace ( '[]' , '[MENU]' , $this -> core -> output [ 'contentRight' ]);
$contentRight = str_replace ( '[menu]' , '[MENU]' , $contentRight );
$mark = strrpos ( $contentRight , '[MENU]' ) !== false ? strrpos ( $contentRight , '[MENU]' ) : strlen ( $contentRight );
echo substr ( $contentRight , 0 , $mark );
echo '<div id="menuSideRight">' ;
echo $this -> showMenuSide ( $this -> getData ([ 'page' , $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'barRight' ]), 'displayMenu' ]) === 'parents' ? false : true );
echo '</div>' ;
echo substr ( $contentRight , $mark + 6 , strlen ( $contentRight ));
}
echo '</aside></div>' ;
}
echo '</div>' ;
}
2024-04-21 15:54:15 +02:00
echo '</main>' ;
2023-09-05 15:21:01 +02:00
}
/**
* Affiche le contenu
* @ param Page par défaut
*/
public function showContent ()
{
if (
$this -> core -> output [ 'title' ]
and ( $this -> getData ([ 'page' , $this -> getUrl ( 0 )]) === null
or $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'hideTitle' ]) === false
or $this -> getUrl ( 1 ) === 'config'
)
) {
echo '<h1 id="sectionTitle">' . $this -> core -> output [ 'title' ] . '</h1>' ;
}
echo $this -> core -> output [ 'content' ];
}
/**
* Affiche le pied de page
*/
public function showFooter ()
{
// Déterminer la position
$positionFixed = '' ;
if (
$this -> getData ([ 'theme' , 'footer' , 'position' ]) === 'site'
// Affiche toujours le pied de page pour l'édition du thème
or ( $this -> getData ([ 'theme' , 'footer' , 'position' ]) === 'hide'
and $this -> getUrl ( 0 ) === 'theme'
)
) {
$position = 'site' ;
} else {
$position = 'body' ;
if ( $this -> getData ([ 'theme' , 'footer' , 'fixed' ]) === true ) {
$positionFixed = ' footerbodyFixed' ;
}
// Sortir de la division précédente
echo '</div>' ;
}
echo $this -> getData ([ 'theme' , 'footer' , 'position' ]) === 'hide' ? '<footer class="displayNone">' : '<footer>' ;
echo ( $position === 'site' ) ? '<div class="container"><div class="row" id="footersite">' : '<div class="container-large' . $positionFixed . '"><div class="row" id="footerbody">' ;
/**
* Calcule la dimension des blocs selon la configuration
*/
switch ( $this -> getData ([ 'theme' , 'footer' , 'template' ])) {
case '1' :
$class [ 'left' ] = " displayNone " ;
$class [ 'center' ] = " col12 " ;
$class [ 'right' ] = " displayNone " ;
break ;
case '2' :
$class [ 'left' ] = " col6 " ;
$class [ 'center' ] = " displayNone " ;
$class [ 'right' ] = " col6 " ;
break ;
case '3' :
$class [ 'left' ] = " col4 " ;
$class [ 'center' ] = " col4 " ;
$class [ 'right' ] = " col4 " ;
break ;
case '4' :
$class [ 'left' ] = " col12 " ;
$class [ 'center' ] = " col12 " ;
$class [ 'right' ] = " col12 " ;
break ;
}
/**
* Affiche les blocs
*/
echo '<div class="' . $class [ 'left' ] . '" id="footer' . $position . 'Left">' ;
if ( $this -> getData ([ 'theme' , 'footer' , 'textPosition' ]) === 'left' ) {
$this -> showFooterText ();
}
if ( $this -> getData ([ 'theme' , 'footer' , 'socialsPosition' ]) === 'left' ) {
$this -> showSocials ();
}
if ( $this -> getData ([ 'theme' , 'footer' , 'copyrightPosition' ]) === 'left' ) {
$this -> showCopyright ();
}
echo '</div>' ;
echo '<div class="' . $class [ 'center' ] . '" id="footer' . $position . 'Center">' ;
if ( $this -> getData ([ 'theme' , 'footer' , 'textPosition' ]) === 'center' ) {
$this -> showFooterText ();
}
if ( $this -> getData ([ 'theme' , 'footer' , 'socialsPosition' ]) === 'center' ) {
$this -> showSocials ();
}
if ( $this -> getData ([ 'theme' , 'footer' , 'copyrightPosition' ]) === 'center' ) {
$this -> showCopyright ();
}
echo '</div>' ;
echo '<div class="' . $class [ 'right' ] . '" id="footer' . $position . 'Right">' ;
if ( $this -> getData ([ 'theme' , 'footer' , 'textPosition' ]) === 'right' ) {
$this -> showFooterText ();
}
if ( $this -> getData ([ 'theme' , 'footer' , 'socialsPosition' ]) === 'right' ) {
$this -> showSocials ();
}
if ( $this -> getData ([ 'theme' , 'footer' , 'copyrightPosition' ]) === 'right' ) {
$this -> showCopyright ();
}
echo '</div>' ;
// Fermeture du conteneur
echo '</div></div>' ;
echo '</footer>' ;
}
/**
* Affiche le texte du footer
*/
private function showFooterText ()
{
if ( $footerText = $this -> getData ([ 'theme' , 'footer' , 'text' ]) or $this -> getUrl ( 0 ) === 'theme' ) {
echo '<div id="footerText">' . $footerText . '</div>' ;
}
}
/**
* Affiche le copyright
*/
private function showCopyright ()
{
// Ouverture Bloc copyright
$items = '<div id="footerCopyright">' ;
$items .= '<span id="footerFontCopyright">' ;
// Affichage de motorisé par
$items .= '<span id="footerDisplayCopyright" ' ;
$items .= $this -> getData ([ 'theme' , 'footer' , 'displayCopyright' ]) === false ? 'class="displayNone"' : '' ;
2023-09-05 15:31:35 +02:00
$label = empty ( $this -> getData ([ 'config' , 'poweredPageLabel' ])) ? 'Motorisé par' : $this -> getData ([ 'config' , 'poweredPageLabel' ]);
2023-09-05 15:21:01 +02:00
$items .= '><wbr> ' . $label . ' </span>' ;
// Toujours afficher le nom du CMS
2024-01-13 21:58:21 +01:00
$items .= '<span id="footerZwiiCampus">' ;
$items .= '<a href="https://forge.chapril.org/fredtempez/ZwiiCampus" onclick="window.open(this.href);return false" >ZwiiCampus</a>' ;
2023-09-05 15:21:01 +02:00
$items .= '</span>' ;
// Affichage du numéro de version
$items .= '<span id="footerDisplayVersion"' ;
$items .= $this -> getData ([ 'theme' , 'footer' , 'displayVersion' ]) === false ? ' class="displayNone"' : '' ;
$items .= '><wbr> ' . common :: ZWII_VERSION ;
$items .= '</span>' ;
// Affichage du sitemap
$items .= '<span id="footerDisplaySiteMap"' ;
$items .= $this -> getData ([ 'theme' , 'footer' , 'displaySiteMap' ]) === false ? ' class="displayNone"' : '' ;
2023-11-15 18:06:49 +01:00
$label = ( $this -> getData ([ 'config' , 'sitemapPageLabel' ]) === 'none' ) ? 'Plan du contenu' : $this -> getData ([ 'config' , 'sitemapPageLabel' ]);
2023-09-05 15:21:01 +02:00
$items .= '><wbr> | <a href="' . helper :: baseUrl () . 'sitemap" >' . $label . '</a>' ;
$items .= '</span>' ;
// Affichage du module de recherche
$items .= '<span id="footerDisplaySearch"' ;
$items .= $this -> getData ([ 'theme' , 'footer' , 'displaySearch' ]) === false ? ' class="displayNone" >' : '>' ;
2023-09-05 15:31:35 +02:00
$label = empty ( $this -> getData ([ 'config' , 'searchPageLabel' ])) ? 'Rechercher' : $this -> getData ([ 'config' , 'searchPageLabel' ]);
if ( $this -> getData ([ 'config' , 'searchPageId' ]) !== 'none' ) {
$items .= '<wbr> | <a href="' . helper :: baseUrl () . $this -> getData ([ 'config' , 'searchPageId' ]) . '" >' . $label . '</a>' ;
2023-09-05 15:21:01 +02:00
}
$items .= '</span>' ;
// Affichage des mentions légales
$items .= '<span id="footerDisplayLegal"' ;
$items .= $this -> getData ([ 'theme' , 'footer' , 'displayLegal' ]) === false ? ' class="displayNone" >' : '>' ;
2023-09-05 15:31:35 +02:00
$label = empty ( $this -> getData ([ 'config' , 'legalPageLabel' ])) ? 'Mentions Légales' : $this -> getData ([ 'config' , 'legalPageLabel' ]);
if ( $this -> getData ([ 'config' , 'legalPageId' ]) !== 'none' ) {
$items .= '<wbr> | <a href="' . helper :: baseUrl () . $this -> getData ([ 'config' , 'legalPageId' ]) . '" >' . $label . '</a>' ;
2023-09-05 15:21:01 +02:00
}
$items .= '</span>' ;
// Affichage de la gestion des cookies
$items .= '<span id="footerDisplayCookie"' ;
$items .= ( $this -> getData ([ 'config' , 'cookieConsent' ]) === true && $this -> getData ([ 'theme' , 'footer' , 'displayCookie' ]) === true ) ? '>' : ' class="displayNone" >' ;
2023-09-05 15:31:35 +02:00
$label = empty ( $this -> getData ([ 'config' , 'cookies' , 'cookiesFooterText' ])) ? 'Cookies' : $this -> getData ([ 'config' , 'cookies' , 'cookiesFooterText' ]);
2023-09-05 15:21:01 +02:00
$items .= '<wbr> | <a href="javascript:void(0)" id="footerLinkCookie">' . $label . '</a>' ;
$items .= '</span>' ;
// Affichage du lien de connexion
if (
( $this -> getData ([ 'theme' , 'footer' , 'loginLink' ])
and $this -> getUser ( 'password' ) !== $this -> getInput ( 'ZWII_USER_PASSWORD' )
)
or $this -> getUrl ( 0 ) === 'theme'
) {
$items .= '<span id="footerLoginLink" ' .
( $this -> getUrl ( 0 ) === 'theme' ? 'class="displayNone">' : '>' ) .
'<wbr> | <wbr>' .
template :: ico ( 'login' , [
'href' => helper :: baseUrl () . 'user/login/' . strip_tags ( str_replace ( '/' , '_' , $this -> getUrl ())),
'attr' => 'rel="nofollow"' ,
'help' => 'Connexion'
]) . '</span>' ;
}
// Affichage de la barre de membre simple
if (
2023-09-22 15:19:18 +02:00
$this -> getUser ( 'group' ) >= self :: GROUP_MEMBER && $this -> getUser ( 'group' ) < self :: GROUP_ADMIN
2023-09-05 15:21:01 +02:00
&& $this -> getData ([ 'theme' , 'footer' , 'memberBar' ]) === true
) {
$items .= '<span id="footerDisplayMemberAccount"' ;
$items .= $this -> getData ([ 'theme' , 'footer' , 'displaymemberAccount' ]) === false ? ' class="displayNone">' : '>' ;
$items .= '<wbr> | ' ;
if (
2024-02-29 15:37:29 +01:00
$this -> getUser ( 'permission' , 'filemanager' ) === true
&& $this -> getUser ( 'permission' , 'folder' , ( self :: $siteContent === 'home' ? 'homePath' : 'coursePath' )) !== 'none'
2023-09-05 15:21:01 +02:00
) {
$items .= '<wbr>' . template :: ico ( 'folder' , [
2024-03-09 19:37:26 +01:00
'href' => helper :: baseUrl ( false ) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file ( self :: DATA_DIR . 'core.json' ) . '&lang=' . $this -> getData ([ 'user' , $this -> getUser ( 'id' ), 'language' ]) . '&fldr=/' . self :: $siteContent ,
2023-09-05 15:21:01 +02:00
'margin' => 'all' ,
'attr' => 'data-lity' ,
'help' => 'Fichiers du site'
]);
}
if (
$this -> getUser ( 'permission' , 'user' , 'edit' ) === true
) {
$items .= '<wbr>' . template :: ico ( 'user' , [
'margin' => 'all' ,
'help' => 'Mon compte' ,
'href' => helper :: baseUrl () . 'user/edit/' . $this -> getUser ( 'id' )
]);
}
$items .= '<wbr>' . template :: ico ( 'logout' , [
'margin' => 'all' ,
'help' => 'Déconnecter' ,
'href' => helper :: baseUrl () . 'user/logout'
]);
$items .= '</span>' ;
}
// Fermeture du bloc copyright
$items .= '</span></div>' ;
echo $items ;
}
/**
* Affiche les réseaux sociaux
*/
private function showSocials ()
{
$socials = '' ;
foreach ( $this -> getData ([ 'config' , 'social' ]) as $socialName => $socialId ) {
switch ( $socialName ) {
case 'facebookId' :
$socialUrl = 'https://www.facebook.com/' ;
$title = 'Facebook' ;
break ;
case 'linkedinId' :
$socialUrl = 'https://fr.linkedin.com/in/' ;
$title = 'Linkedin' ;
break ;
case 'instagramId' :
$socialUrl = 'https://www.instagram.com/' ;
$title = 'Instagram' ;
break ;
case 'pinterestId' :
$socialUrl = 'https://pinterest.com/' ;
$title = 'Pinterest' ;
break ;
case 'twitterId' :
$socialUrl = 'https://twitter.com/' ;
$title = 'Twitter' ;
break ;
case 'youtubeId' :
$socialUrl = 'https://www.youtube.com/channel/' ;
$title = 'Chaîne YouTube' ;
break ;
case 'youtubeUserId' :
$socialUrl = 'https://www.youtube.com/user/' ;
$title = 'YouTube' ;
break ;
case 'githubId' :
$socialUrl = 'https://www.github.com/' ;
$title = 'Github' ;
break ;
case 'redditId' :
$socialUrl = 'https://www.reddit.com/user/' ;
$title = 'Reddit' ;
break ;
case 'twitchId' :
$socialUrl = 'https://www.twitch.tv/' ;
$title = 'Twitch' ;
break ;
case 'vimeoId' :
$socialUrl = 'https://vimeo.com/' ;
$title = 'Vimeo' ;
break ;
case 'steamId' :
$socialUrl = 'https://steamcommunity.com/id/' ;
$title = 'Steam' ;
break ;
default :
$socialUrl = '' ;
}
if ( $socialId !== '' ) {
$socials .= '<a href="' . $socialUrl . $socialId . '" onclick="window.open(this.href);return false" data-tippy-content="' . $title . '" alt="' . $title . '">' . template :: ico ( substr ( str_replace ( 'User' , '' , $socialName ), 0 , - 2 )) . '</a>' ;
}
}
if ( $socials !== '' ) {
echo '<div id="footerSocials">' . $socials . '</div>' ;
}
}
/**
* Affiche le favicon
*/
public function showFavicon ()
{
// Light scheme
$favicon = $this -> getData ([ 'config' , 'favicon' ]);
if (
$favicon &&
file_exists ( self :: FILE_DIR . 'source/' . $favicon )
) {
echo '<link rel="shortcut icon" media="(prefers-color-scheme:light)" href="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $favicon . '">' ;
} else {
echo '<link rel="shortcut icon" media="(prefers-color-scheme:light)" href="' . helper :: baseUrl ( false ) . 'core/vendor/zwiico/ico/favicon.ico">' ;
}
// Dark scheme
$faviconDark = $this -> getData ([ 'config' , 'faviconDark' ]);
if (
! empty ( $faviconDark ) &&
file_exists ( self :: FILE_DIR . 'source/' . $faviconDark )
) {
echo '<link rel="shortcut icon" media="(prefers-color-scheme:dark)" href="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $faviconDark . '">' ;
echo '<script src="' . helper :: baseUrl ( false ) . 'core/vendor/favicon-switcher/favicon-switcher.js" crossorigin="anonymous"></script>' ;
}
}
/**
* Affiche le menu
*/
public function showMenu ()
{
// Met en forme les items du menu
$itemsLeft = $this -> formatMenu ( false );
// Menu extra
$itemsRight = $this -> formatMenu ( true );
2024-01-19 14:37:03 +01:00
/**
* Commandes pour les membres simples
* Affichage du sélecteur d ' espaces
2024-01-20 21:39:22 +01:00
*/
2023-09-05 15:21:01 +02:00
if (
2024-01-27 16:21:06 +01:00
$this -> getUser ( 'group' ) === self :: GROUP_MEMBER
2024-01-20 21:42:21 +01:00
&& $this -> getData ([ 'theme' , 'menu' , 'selectSpace' ]) === true
2023-09-05 15:21:01 +02:00
) {
2024-02-12 15:16:46 +01:00
if ( $this -> getCoursesByProfil ()) {
2024-01-20 21:22:16 +01:00
$itemsRight .= '<li><select id="menuSelectCourse" >' ;
2024-01-18 15:19:14 +01:00
$itemsRight .= '<option name="' . helper :: translate ( 'Accueil' ) . '" value="' . helper :: baseUrl ( true ) . 'course/swap/home" ' . ( 'home' === self :: $siteContent ? 'selected' : '' ) . '>' . helper :: translate ( 'Accueil' ) . '</option>' ;
2024-02-12 15:16:46 +01:00
foreach ( $this -> getCoursesByProfil () as $courseId => $value ) {
2024-01-18 15:19:14 +01:00
$itemsRight .= '<option name="' . $this -> getData ([ 'course' , $courseId , 'title' ]) . '" value="' . helper :: baseUrl ( true ) . 'course/swap/' . $courseId . '" ' . ( $courseId === self :: $siteContent ? 'selected' : '' ) . '>' . $this -> getData ([ 'course' , $courseId , 'title' ]) . '</option>' ;
}
$itemsRight .= '</select></li>' ;
}
2024-01-19 14:37:03 +01:00
}
2024-01-20 21:07:28 +01:00
2024-01-19 14:37:03 +01:00
/**
* Commandes pour les membres simples
* Affichage des boutons gestionnaire de fichiers et mon compte
2024-01-27 16:21:06 +01:00
*/
2024-01-19 14:37:03 +01:00
if (
$this -> getUser ( 'group' ) === self :: GROUP_MEMBER
&& $this -> getData ([ 'theme' , 'menu' , 'memberBar' ]) === true
) {
2024-01-27 16:21:06 +01:00
// Affiche l'icône RFM
2024-02-29 15:37:29 +01:00
if ( $this -> getUser ( 'permission' , 'filemanager' ) === true
&& $this -> getUser ( 'permission' , 'folder' , ( self :: $siteContent === 'home' ? 'homePath' : 'coursePath' )) !== 'none' ) {
2023-09-05 15:21:01 +02:00
$itemsRight .= '<li>' . template :: ico ( 'folder' , [
2024-03-09 19:37:26 +01:00
'href' => helper :: baseUrl ( false ) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file ( self :: DATA_DIR . 'core.json' ) . '&lang=' . $this -> getData ([ 'user' , $this -> getUser ( 'id' ), 'language' ]) . '&fldr=/' . self :: $siteContent ,
2023-09-05 15:21:01 +02:00
'attr' => 'data-lity' ,
'help' => 'Fichiers du site'
]) . '</li>' ;
}
2024-01-27 16:21:06 +01:00
// Affiche l'icône d'édition du compte
if ( $this -> getUser ( 'permission' , 'user' , 'edit' ) === true ) {
2023-09-05 15:21:01 +02:00
$itemsRight .= '<li>' . template :: ico ( 'user' , [
'help' => 'Mon compte' ,
'margin' => 'right' ,
'href' => helper :: baseUrl () . 'user/edit/' . $this -> getUser ( 'id' )
]) . '</li>' ;
}
$itemsRight .= '<li>' .
template :: ico ( 'logout' , [
'help' => 'Déconnecter' ,
'href' => helper :: baseUrl () . 'user/logout' ,
'id' => 'barLogout'
]) . '</li>' ;
}
2024-01-27 16:21:06 +01:00
// Lien de connexion
if (
( $this -> getData ([ 'theme' , 'menu' , 'loginLink' ])
and $this -> getUser ( 'password' ) !== $this -> getInput ( 'ZWII_USER_PASSWORD' )
)
or $this -> getUrl ( 0 ) === 'theme'
) {
$itemsRight .= '<li id="menuLoginLink" ' . ( $this -> getUrl ( 0 ) === 'theme' ? 'class="displayNone"' : '' ) . '>' .
template :: ico ( 'login' , [
'href' => helper :: baseUrl () . 'user/login/' . strip_tags ( str_replace ( '/' , '_' , $this -> getUrl ())),
'help' => " Connexion "
]) .
'</li>' ;
}
2023-09-05 15:21:01 +02:00
// Retourne les items du menu
echo '<ul class="navMain" id="menuLeft">' . $itemsLeft . '</ul><ul class="navMain" id="menuRight">' . $itemsRight ;
echo '</ul>' ;
}
/**
* Cette fonction est appelée par showMenu
* Elle permet de générer le menu selon qu 'il s' agisse du menu principal ou du petit menu
* @ param $menu bool false pour le menu principal , true pour le petit menu
*/
private function formatMenu ( $extra = false )
{
$items = '' ;
$currentPageId = $this -> getData ([ 'page' , $this -> getUrl ( 0 )]) ? $this -> getUrl ( 0 ) : $this -> getUrl ( 2 );
foreach ( $this -> getHierarchy () as $parentPageId => $childrenPageIds ) {
// Menu extra ou standard
if (
// Absence de la position extra, la page est toujours affichée à gauche.
( $this -> getData ([ 'page' , $parentPageId , 'extraPosition' ]) !== NULL || $extra === true )
&&
$this -> getData ([ 'page' , $parentPageId , 'extraPosition' ]) !== $extra
) {
continue ;
}
// Propriétés de l'item
$active = ( $parentPageId === $currentPageId or in_array ( $currentPageId , $childrenPageIds )) ? 'active ' : '' ;
$targetBlank = $this -> getData ([ 'page' , $parentPageId , 'targetBlank' ]) ? ' target="_blank"' : '' ;
// Mise en page de l'item
$items .= '<li id="' . $parentPageId . '">' ;
if (
( $this -> getData ([ 'page' , $parentPageId , 'disable' ]) === true
and $this -> getUser ( 'password' ) !== $this -> getInput ( 'ZWII_USER_PASSWORD' )
) or ( $this -> getData ([ 'page' , $parentPageId , 'disable' ]) === true
and $this -> getUser ( 'password' ) === $this -> getInput ( 'ZWII_USER_PASSWORD' )
2023-09-22 15:19:18 +02:00
and $this -> getUser ( 'group' ) < self :: GROUP_EDITOR
2023-09-05 15:21:01 +02:00
)
) {
2023-09-05 15:31:35 +02:00
$pageUrl = ( $this -> getData ([ 'config' , 'homePageId' ]) === $this -> getUrl ( 0 )) ? helper :: baseUrl ( false ) : helper :: baseUrl () . $this -> getUrl ( 0 );
2023-09-05 15:21:01 +02:00
$items .= '<a href="' . $pageUrl . '">' ;
} else {
2023-09-05 15:31:35 +02:00
$pageUrl = ( $this -> getData ([ 'config' , 'homePageId' ]) === $parentPageId ) ? helper :: baseUrl ( false ) : helper :: baseUrl () . $parentPageId ;
2023-09-05 15:21:01 +02:00
$items .= '<a class="' . $active . '" href="' . $pageUrl . '"' . $targetBlank . '>' ;
}
switch ( $this -> getData ([ 'page' , $parentPageId , 'typeMenu' ])) {
case '' :
$items .= $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]);
break ;
case 'text' :
$items .= $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]);
break ;
case 'icon' :
if ( $this -> getData ([ 'page' , $parentPageId , 'iconUrl' ]) != " " ) {
$items .= '<img alt="' . $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]) . '" src="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $this -> getData ([ 'page' , $parentPageId , 'iconUrl' ]) . '" />' ;
} else {
$items .= $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]);
}
break ;
case 'icontitle' :
if ( $this -> getData ([ 'page' , $parentPageId , 'iconUrl' ]) != " " ) {
$items .= '<img alt="' . $this -> getData ([ 'page' , $parentPageId , 'titlshortTitlee' ]) . '" src="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $this -> getData ([ 'page' , $parentPageId , 'iconUrl' ]) . '" data-tippy-content="' ;
$items .= $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]) . '"/>' ;
} else {
$items .= $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]);
}
break ;
}
// Cas où les pages enfants enfant sont toutes masquées dans le menu
// ne pas afficher de symbole lorsqu'il n'y a rien à afficher
$totalChild = 0 ;
$disableChild = 0 ;
foreach ( $childrenPageIds as $childKey ) {
$totalChild += 1 ;
}
if (
$childrenPageIds && $disableChild !== $totalChild &&
$this -> getdata ([ 'page' , $parentPageId , 'hideMenuChildren' ]) === false
) {
$items .= template :: ico ( 'down' , [ 'margin' => 'left' ]);
}
// ------------------------------------------------
$items .= '</a>' ;
if (
$this -> getdata ([ 'page' , $parentPageId , 'hideMenuChildren' ]) === true ||
empty ( $childrenPageIds )
) {
continue ;
}
$items .= '<ul class="navSub">' ;
foreach ( $childrenPageIds as $childKey ) {
// Propriétés de l'item
$active = ( $childKey === $currentPageId ) ? 'active ' : '' ;
$targetBlank = $this -> getData ([ 'page' , $childKey , 'targetBlank' ]) ? ' target="_blank"' : '' ;
// Mise en page du sous-item
$items .= '<li id=' . $childKey . '>' ;
if (
( $this -> getData ([ 'page' , $childKey , 'disable' ]) === true
and $this -> getUser ( 'password' ) !== $this -> getInput ( 'ZWII_USER_PASSWORD' )
) or ( $this -> getData ([ 'page' , $childKey , 'disable' ]) === true
and $this -> getUser ( 'password' ) === $this -> getInput ( 'ZWII_USER_PASSWORD' )
2023-09-22 15:19:18 +02:00
and $this -> getUser ( 'group' ) < self :: GROUP_EDITOR
2023-09-05 15:21:01 +02:00
)
) {
2023-09-05 15:31:35 +02:00
$pageUrl = ( $this -> getData ([ 'config' , 'homePageId' ]) === $this -> getUrl ( 0 )) ? helper :: baseUrl ( false ) : helper :: baseUrl () . $this -> getUrl ( 0 );
2023-09-05 15:21:01 +02:00
$items .= '<a href="' . $pageUrl . '">' ;
} else {
2023-09-05 15:31:35 +02:00
$pageUrl = ( $this -> getData ([ 'config' , 'homePageId' ]) === $childKey ) ? helper :: baseUrl ( false ) : helper :: baseUrl () . $childKey ;
2023-09-05 15:21:01 +02:00
$items .= '<a class="' . $active . ' ' . $parentPageId . '" href="' . $pageUrl . '"' . $targetBlank . '>' ;
}
switch ( $this -> getData ([ 'page' , $childKey , 'typeMenu' ])) {
case '' :
$items .= $this -> getData ([ 'page' , $childKey , 'shortTitle' ]);
break ;
case 'text' :
$items .= $this -> getData ([ 'page' , $childKey , 'shortTitle' ]);
break ;
case 'icon' :
if ( $this -> getData ([ 'page' , $childKey , 'iconUrl' ]) != " " ) {
$items .= '<img alt="' . $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]) . '" src="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $this -> getData ([ 'page' , $childKey , 'iconUrl' ]) . '" />' ;
} else {
$items .= $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]);
}
break ;
case 'icontitle' :
if ( $this -> getData ([ 'page' , $childKey , 'iconUrl' ]) != " " ) {
$items .= '<img alt="' . $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]) . '" src="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $this -> getData ([ 'page' , $childKey , 'iconUrl' ]) . '" data-tippy-content="' ;
$items .= $this -> getData ([ 'page' , $childKey , 'shortTitle' ]) . '"/>' ;
} else {
$items .= $this -> getData ([ 'page' , $childKey , 'shortTitle' ]);
}
break ;
case 'icontext' :
if ( $this -> getData ([ 'page' , $childKey , 'iconUrl' ]) != " " ) {
$items .= '<img alt="' . $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]) . '" src="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $this -> getData ([ 'page' , $childKey , 'iconUrl' ]) . '" />' ;
$items .= $this -> getData ([ 'page' , $childKey , 'shortTitle' ]);
} else {
$items .= $this -> getData ([ 'page' , $childKey , 'shortTitle' ]);
}
break ;
}
$items .= '</a></li>' ;
}
$items .= '</ul>' ;
}
return ( $items );
}
/**
* Générer un menu pour la barre latérale
* Uniquement texte
* @ param $onlyChildren n ' affiche les sous - pages de la page actuelle
*/
private function showMenuSide ( $onlyChildren = null )
{
// Met en forme les items du menu
$items = '' ;
// Nom de la page courante
$currentPageId = $this -> getData ([ 'page' , $this -> getUrl ( 0 )]) ? $this -> getUrl ( 0 ) : $this -> getUrl ( 2 );
// Nom de la page parente
$currentParentPageId = $this -> getData ([ 'page' , $currentPageId , 'parentPageId' ]);
// Détermine si on affiche uniquement le parent et les enfants
// Filtre contient le nom de la page parente
if ( $onlyChildren === true ) {
if ( empty ( $currentParentPageId )) {
$filterCurrentPageId = $currentPageId ;
} else {
$filterCurrentPageId = $currentParentPageId ;
}
} else {
$items .= '<ul class="menuSide">' ;
}
foreach ( $this -> getHierarchy () as $parentPageId => $childrenPageIds ) {
// Ne pas afficher les entrées masquées
if ( $this -> getData ([ 'page' , $parentPageId , 'hideMenuSide' ]) === true ) {
continue ;
}
// Filtre actif et nom de la page parente courante différente, on sort de la boucle
if ( $onlyChildren === true && $parentPageId !== $filterCurrentPageId ) {
continue ;
}
// Propriétés de l'item
$active = ( $parentPageId === $currentPageId or in_array ( $currentPageId , $childrenPageIds )) ? ' class="active"' : '' ;
$targetBlank = $this -> getData ([ 'page' , $parentPageId , 'targetBlank' ]) ? ' target="_blank" ' : '' ;
// Mise en page de l'item;
// Ne pas afficher le parent d'une sous-page quand l'option est sélectionnée.
if ( $onlyChildren === false ) {
$items .= '<li class="menuSideChild">' ;
if (
$this -> getData ([ 'page' , $parentPageId , 'disable' ]) === true
and $this -> getUser ( 'password' ) !== $this -> getInput ( 'ZWII_USER_PASSWORD' )
) {
$items .= '<a href="' . $this -> getUrl ( 1 ) . '">' ;
} else {
$items .= '<a href="' . helper :: baseUrl () . $parentPageId . '"' . $targetBlank . $active . '>' ;
}
$items .= $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]);
$items .= '</a>' ;
}
$itemsChildren = '' ;
foreach ( $childrenPageIds as $childKey ) {
// Passer les entrées masquées
if ( $this -> getData ([ 'page' , $childKey , 'hideMenuSide' ]) === true ) {
continue ;
}
// Propriétés de l'item
$active = ( $childKey === $currentPageId ) ? ' class="active"' : '' ;
$targetBlank = $this -> getData ([ 'page' , $childKey , 'targetBlank' ]) ? ' target="_blank"' : '' ;
// Mise en page du sous-item
$itemsChildren .= '<li class="menuSideChild">' ;
if (
$this -> getData ([ 'page' , $childKey , 'disable' ]) === true
and $this -> getUser ( 'password' ) !== $this -> getInput ( 'ZWII_USER_PASSWORD' )
) {
$itemsChildren .= '<a href="' . $this -> getUrl ( 1 ) . '">' ;
} else {
$itemsChildren .= '<a href="' . helper :: baseUrl () . $childKey . '"' . $targetBlank . $active . '>' ;
}
$itemsChildren .= $this -> getData ([ 'page' , $childKey , 'shortTitle' ]);
$itemsChildren .= '</a></li>' ;
}
// Concatène les items enfants
if ( ! empty ( $itemsChildren )) {
$items .= '<ul class="menuSideChild">' ;
$items .= $itemsChildren ;
$items .= '</ul>' ;
} else {
$items .= '</li>' ;
}
}
if ( $onlyChildren === false ) {
$items .= '</ul>' ;
}
// Retourne les items du menu
echo $items ;
}
/**
* Affiche le meta titre
*/
public function showMetaTitle ()
{
echo '<title>' . $this -> core -> output [ 'metaTitle' ] . '</title>' ;
echo '<meta property="og:title" content="' . $this -> core -> output [ 'metaTitle' ] . '" />' ;
if (
2023-09-30 13:35:20 +02:00
$this -> homePageId () === $this -> getUrl ( 0 )
2023-09-05 15:21:01 +02:00
) {
echo '<link rel="canonical" href="' . helper :: baseUrl ( false ) . '" />' ;
} else {
echo '<link rel="canonical" href="' . helper :: baseUrl ( true ) . $this -> getUrl () . '" />' ;
}
}
/**
* Affiche la meta description
*/
public function showMetaDescription ()
{
echo '<meta name="description" content="' . $this -> core -> output [ 'metaDescription' ] . '" />' ;
echo '<meta property="og:description" content="' . $this -> core -> output [ 'metaDescription' ] . '" />' ;
}
/**
* Affiche le meta type
*/
public function showMetaType ()
{
echo '<meta property="og:type" content="website" />' ;
}
/**
* Affiche la meta image ( site screenshot )
*/
public function showMetaImage ()
{
$imagePath = self :: FILE_DIR . 'source/' . $this -> getData ([ 'config' , 'seo' , 'openGraphImage' ]);
if (
$this -> getData ([ 'config' , 'seo' , 'openGraphImage' ])
&& file_exists ( $imagePath )
) {
$typeMime = exif_imagetype ( $imagePath );
switch ( $typeMime ) {
case IMAGETYPE_JPEG :
$typeMime = 'image/jpeg' ;
break ;
case IMAGETYPE_PNG :
$typeMime = 'image/png' ;
break ;
default :
// Type incorrect
return ;
}
$imageSize = getimagesize ( $imagePath );
$wide = $imageSize [ 0 ];
$height = $imageSize [ 1 ];
//Sortie
$items = '<meta property="og:image" content="' . helper :: baseUrl ( false ) . self :: FILE_DIR . 'source/' . $this -> getData ([ 'config' , 'seo' , 'openGraphImage' ]) . '" />' ;
$items .= '<meta property="og:image:type" content="' . $typeMime . '" />' ;
$items .= '<meta property="og:image:width" content="' . $wide . '" />' ;
$items .= '<meta property="og:image:height" content="' . $height . '" />' ;
echo $items ;
}
}
/**
* Affiche la notification
*/
public function showNotification ()
{
if ( common :: $importNotices ) {
$notification = common :: $importNotices [ 0 ];
$notificationClass = 'notificationSuccess' ;
}
if ( common :: $inputNotices ) {
$notification = 'Impossible de soumettre le formulaire, car il contient des erreurs' ;
$notificationClass = 'notificationError' ;
}
if ( common :: $coreNotices ) {
$notification = sprintf ( '%s <p> | ' , helper :: translate ( 'Restauration des bases de données absentes' ));
foreach ( common :: $coreNotices as $item )
$notification .= $item . ' | ' ;
$notificationClass = 'notificationError' ;
} elseif ( empty ( $_SESSION [ 'ZWII_NOTIFICATION_SUCCESS' ]) === false ) {
$notification = $_SESSION [ 'ZWII_NOTIFICATION_SUCCESS' ];
$notificationClass = 'notificationSuccess' ;
unset ( $_SESSION [ 'ZWII_NOTIFICATION_SUCCESS' ]);
} elseif ( empty ( $_SESSION [ 'ZWII_NOTIFICATION_ERROR' ]) === false ) {
$notification = $_SESSION [ 'ZWII_NOTIFICATION_ERROR' ];
$notificationClass = 'notificationError' ;
unset ( $_SESSION [ 'ZWII_NOTIFICATION_ERROR' ]);
} elseif ( empty ( $_SESSION [ 'ZWII_NOTIFICATION_OTHER' ]) === false ) {
$notification = $_SESSION [ 'ZWII_NOTIFICATION_OTHER' ];
$notificationClass = 'notificationOther' ;
unset ( $_SESSION [ 'ZWII_NOTIFICATION_OTHER' ]);
}
if ( isset ( $notification ) and isset ( $notificationClass )) {
echo '<div id="notification" class="' . $notificationClass . '">' . $notification . '<span id="notificationClose">' . template :: ico ( 'cancel' ) . '<!----></span><div id="notificationProgress"></div></div>' ;
}
}
/**
* Affiche la barre de membre
*/
public function showBar ()
{
if ( $this -> getUser ( 'password' ) === $this -> getInput ( 'ZWII_USER_PASSWORD' )) {
// Items de gauche
$leftItems = '' ;
2023-11-15 18:06:49 +01:00
// Sélecteur de contenu
2023-09-16 18:50:23 +02:00
/**
2024-02-08 09:51:44 +01:00
* Les admins voient tous les contenus
2023-11-19 21:07:22 +01:00
* Les enseignants les contenus dont ils sont auteurs
2023-09-16 18:50:23 +02:00
*/
2023-09-22 15:19:18 +02:00
if ( $this -> getUser ( 'group' ) >= self :: GROUP_EDITOR ) {
2024-02-22 13:16:18 +01:00
if ( is_array ( $this -> getCoursesByProfil ())) {
2023-09-16 18:50:23 +02:00
$leftItems .= '<li><select id="barSelectCourse" >' ;
$leftItems .= '<option name="' . helper :: translate ( 'Accueil' ) . '" value="' . helper :: baseUrl ( true ) . 'course/swap/home" ' . ( 'home' === self :: $siteContent ? 'selected' : '' ) . '>' . helper :: translate ( 'Accueil' ) . '</option>' ;
2024-02-12 15:16:46 +01:00
foreach ( $this -> getCoursesByProfil () as $courseId => $value ) {
2024-01-13 22:35:57 +01:00
$leftItems .= '<option name="' . $this -> getData ([ 'course' , $courseId , 'title' ]) . '" value="' . helper :: baseUrl ( true ) . 'course/swap/' . $courseId . '" ' . ( $courseId === self :: $siteContent ? 'selected' : '' ) . '>' . $this -> getData ([ 'course' , $courseId , 'title' ]) . '</option>' ;
2023-09-16 18:50:23 +02:00
}
$leftItems .= '</select></li>' ;
2024-02-13 10:28:30 +01:00
}
2024-02-22 13:16:18 +01:00
$leftItems .= '<li>' . template :: ico ( 'cubes' , [
'href' => helper :: baseUrl () . 'course' ,
'help' => 'Gérer les espaces'
]) . '</li>' ;
2023-11-26 14:44:28 +01:00
}
if ( $this -> getUser ( 'group' ) >= self :: GROUP_ADMIN ) {
2023-10-04 07:14:35 +02:00
$leftItems .= '<li>' . template :: ico ( 'brush' , [
'help' => 'Thème' ,
'href' => helper :: baseUrl () . 'theme'
]) . '</li>' ;
2023-09-16 17:27:22 +02:00
}
2024-02-08 09:51:44 +01:00
// Liste des pages et bouton de gestion interdit pour l'accueil sauf admin
2024-02-13 10:28:30 +01:00
if (
( $this -> getUser ( 'group' ) === self :: GROUP_EDITOR && self :: $siteContent != 'home' )
|| $this -> getUser ( 'group' ) === self :: GROUP_ADMIN
) {
2023-09-05 15:21:01 +02:00
$leftItems .= '<li><select id="barSelectPage">' ;
$leftItems .= '<option value="">' . helper :: translate ( 'Pages du site' ) . '</option>' ;
$leftItems .= '<optgroup label="' . helper :: translate ( 'Pages orphelines' ) . '">' ;
$orpheline = true ;
$currentPageId = $this -> getData ([ 'page' , $this -> getUrl ( 0 )]) ? $this -> getUrl ( 0 ) : $this -> getUrl ( 2 );
foreach ( $this -> getHierarchy ( null , false ) as $parentPageId => $childrenPageIds ) {
if (
$this -> getData ([ 'page' , $parentPageId , 'position' ]) !== 0 &&
$orpheline
) {
$orpheline = false ;
$leftItems .= '<optgroup label="' . helper :: translate ( 'Pages dans le menu' ) . '">' ;
}
// Exclure les barres
if ( $this -> getData ([ 'page' , $parentPageId , 'block' ]) !== 'bar' ) {
$leftItems .= '<option value="' .
helper :: baseUrl () .
$parentPageId . '"' .
( $parentPageId === $currentPageId ? ' selected' : false ) .
' class="' .
( $this -> getData ([ 'page' , $parentPageId , 'disable' ]) === true ? 'pageInactive' : '' ) .
( $this -> getData ([ 'page' , $parentPageId , 'position' ]) === 0 ? ' pageHidden' : '' ) .
'">' .
$this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]) .
'</option>' ;
foreach ( $childrenPageIds as $childKey ) {
$leftItems .= '<option value="' .
helper :: baseUrl () .
$childKey . '"' .
( $childKey === $currentPageId ? ' selected' : false ) .
' class="' .
( $this -> getData ([ 'page' , $childKey , 'disable' ]) === true ? 'pageInactive' : '' ) .
( $this -> getData ([ 'page' , $childKey , 'position' ]) === 0 ? ' pageHidden' : '' ) .
'"> ' .
$this -> getData ([ 'page' , $childKey , 'shortTitle' ]) .
'</option>' ;
}
}
}
$leftItems .= '</optgroup' >
// Afficher les barres
$leftItems .= '<optgroup label="' . helper :: translate ( 'Barres latérales' ) . '">' ;
foreach ( $this -> getHierarchy ( null , false , true ) as $parentPageId => $childrenPageIds ) {
$leftItems .= '<option value="' . helper :: baseUrl () . $parentPageId . '"' . ( $parentPageId === $currentPageId ? ' selected' : false ) . '>' . $this -> getData ([ 'page' , $parentPageId , 'shortTitle' ]) . '</option>' ;
foreach ( $childrenPageIds as $childKey ) {
$leftItems .= '<option value="' . helper :: baseUrl () . $childKey . '"' . ( $childKey === $currentPageId ? ' selected' : false ) . '> ' . $this -> getData ([ 'page' , $childKey , 'shortTitle' ]) . '</option>' ;
}
}
$leftItems .= '</optgroup>' ;
$leftItems .= '</select></li>' ;
// Bouton Ajouter une page
if ( $this -> getUser ( 'permission' , 'page' , 'add' )) {
$leftItems .= '<li>' . template :: ico ( 'plus' , [
'href' => helper :: baseUrl () . 'page/add' ,
'help' => 'Nouvelle page ou barre latérale'
]) . '</li>' ;
}
if (
// Sur un module de page qui autorise le bouton de modification de la page
$this -> core -> output [ 'showBarEditButton' ]
// Sur une page sans module
or $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'moduleId' ]) === ''
// Sur une page avec un module invalide
or ( ! is_null ( $this -> getData ([ 'page' , $this -> getUrl ( 2 ), 'moduleId' ])) &&
! class_exists ( $this -> getData ([ 'page' , $this -> getUrl ( 2 ), 'moduleId' ]))
)
// Sur une page d'accueil
or $this -> getUrl ( 0 ) === ''
) {
// Bouton Editer une page
if ( $this -> getUser ( 'permission' , 'page' , 'edit' )) {
$leftItems .= '<li>' . template :: ico ( 'pencil' , [
'href' => helper :: baseUrl () . 'page/edit/' . $this -> getUrl ( 0 ),
'help' => 'Éditer la page'
]) . '</li>' ;
}
// Bouton Editer le module d'une page
if (
$this -> getUser ( 'permission' , 'page' , 'module' )
&& $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'moduleId' ])
) {
$leftItems .= '<li>' . template :: ico ( 'gear' , [
'href' => helper :: baseUrl () . $this -> getUrl ( 0 ) . '/config' ,
'help' => 'Module de la page'
]) . '</li>' ;
}
// Bouton dupliquer une page
if (
$this -> getUser ( 'permission' , 'page' , 'duplicate' )
) {
$leftItems .= '<li>' . template :: ico ( 'clone' , [
'href' => helper :: baseUrl () . 'page/duplicate/' . $this -> getUrl ( 0 ),
'help' => 'Dupliquer la page'
])
. '</li>' ;
}
// Bouton Effacer une page
if (
$this -> getUser ( 'permission' , 'page' , 'delete' )
) {
$leftItems .= '<li>' . template :: ico ( 'trash' , [
'href' => helper :: baseUrl () . 'page/delete/' . $this -> getUrl ( 0 ),
'help' => 'Supprimer la page' ,
'id' => 'pageDelete'
])
. '</li>' ;
}
}
}
// Items de droite
$rightItems = '' ;
if (
2024-01-03 10:51:05 +01:00
(
2024-02-12 13:58:38 +01:00
$this -> getUser ( 'group' ) === self :: GROUP_EDITOR
2024-02-29 15:37:29 +01:00
&& $this -> getUser ( 'permission' , 'filemanager' ) === true
&& $this -> getUser ( 'permission' , 'folder' , ( self :: $siteContent === 'home' ? 'homePath' : 'coursePath' )) !== 'none'
2023-09-05 15:21:01 +02:00
)
2024-02-12 14:11:11 +01:00
|| $this -> getUser ( 'group' ) === self :: GROUP_ADMIN
2023-09-05 15:21:01 +02:00
) {
$rightItems .= '<li>' . template :: ico ( 'folder' , [
'help' => 'Fichiers' ,
2024-03-09 19:37:26 +01:00
'href' => helper :: baseUrl ( false ) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file ( self :: DATA_DIR . 'core.json' ) . '&lang=' . $this -> getData ([ 'user' , $this -> getUser ( 'id' ), 'language' ]) . '&fldr=/' . self :: $siteContent ,
2023-09-05 15:21:01 +02:00
'attr' => 'data-lity'
]) . '</li>' ;
}
2023-11-15 14:42:23 +01:00
if (
self :: $siteContent === 'home'
&& $this -> getUser ( 'group' ) >= self :: GROUP_ADMIN
) {
2023-09-05 15:21:01 +02:00
$rightItems .= '<li>' . template :: ico ( 'puzzle' , [
'help' => 'Modules' ,
'href' => helper :: baseUrl () . 'plugin'
]) . '</li>' ;
$rightItems .= '<li>' . template :: ico ( 'flag' , [
'help' => 'Langues' ,
'href' => helper :: baseUrl () . 'language'
]) . '</li>' ;
$rightItems .= '<li>' . template :: ico ( 'cog-alt' , [
'help' => 'Configuration' ,
'href' => helper :: baseUrl () . 'config'
]) . '</li>' ;
$rightItems .= '<li>' . template :: ico ( 'users' , [
'help' => 'Utilisateurs' ,
'href' => helper :: baseUrl () . 'user'
]) . '</li>' ;
// Mise à jour automatique
$today = mktime ( 0 , 0 , 0 );
$checkUpdate = $this -> getData ([ 'core' , 'lastAutoUpdate' ]);
// Recherche d'une mise à jour si active, si une mise à jour n'est pas déjà disponible et le délai journalier est dépassé.
if (
$this -> getData ([ 'config' , 'autoUpdate' ])
) {
if (
$today > $checkUpdate + $this -> getData ([ 'config' , 'autoUpdateDelay' , 86400 ])
) {
// Dernier auto controle
$this -> setData ([ 'core' , 'lastAutoUpdate' , $today ]);
if (
helper :: checkNewVersion ( common :: ZWII_UPDATE_CHANNEL )
2024-02-13 10:28:30 +01:00
) {
2023-09-05 15:21:01 +02:00
$this -> setData ([ 'core' , 'updateAvailable' , true ]);
}
}
}
// Afficher le bouton : Mise à jour détectée + activée
if ( $this -> getData ([ 'core' , 'updateAvailable' ])) {
$rightItems .= '<li><a href="' . helper :: baseUrl () . 'install/update" data-tippy-content="Mettre à jour Zwii ' . common :: ZWII_VERSION . ' vers ' . helper :: getOnlineVersion ( common :: ZWII_UPDATE_CHANNEL ) . '">' . template :: ico ( 'update colorRed' ) . '</a></li>' ;
}
}
if (
2023-09-22 15:19:18 +02:00
$this -> getUser ( 'group' ) >= self :: GROUP_EDITOR
2023-09-05 15:21:01 +02:00
&& $this -> getUser ( 'permission' , 'user' , 'edit' )
) {
$rightItems .= '<li><a href="' . helper :: baseUrl () . 'user/edit/' . $this -> getUser ( 'id' ) .
'" data-tippy-content="' . helper :: translate ( 'Configurer mon compte' ) . '">' .
template :: ico ( 'user' , [ 'margin' => 'right' ]) . '<span id="displayUsername">' . $this -> getUser ( 'firstname' ) . ' ' . $this -> getUser ( 'lastname' ) .
'</span></a></li>' ;
}
$rightItems .= '<li>' . template :: ico ( 'logout' , [
'help' => 'Déconnecter' ,
'href' => helper :: baseUrl () . 'user/logout' ,
'id' => 'barLogout'
]) . '</li>' ;
// Barre de membre
echo '<div id="bar"><div class="container"><ul id="barLeft">' . $leftItems . '</ul><ul id="barRight">' . $rightItems . '</ul></div></div>' ;
}
}
/**
* Affiche le script
*/
public function showScript ()
{
ob_start ();
require 'core/core.js.php' ;
$coreScript = ob_get_clean ();
$inlineScript = '' ;
if ( $this -> core -> output [ 'inlineScript' ]) {
$inlineScript = implode ( $this -> core -> output [ 'inlineScript' ]);
}
echo '<script defer>' . helper :: minifyJs ( $coreScript . $this -> core -> output [ 'script' ]) . '</script>' ;
echo '<script defer>' . helper :: minifyJs ( htmlspecialchars_decode ( $inlineScript )) . '</script>' ;
}
/**
* Affiche le style
*/
public function showStyle ()
{
// Import des styles liés à la page
if ( $this -> core -> output [ 'style' ]) {
echo '<base href="' . helper :: baseUrl ( true ) . '">' ;
if ( strpos ( $this -> core -> output [ 'style' ], 'admin.css' ) >= 1 ) {
echo '<link rel="stylesheet" href="' . self :: DATA_DIR . 'admin.css?' . md5_file ( self :: DATA_DIR . 'admin.css' ) . '">' ;
}
echo '<style type="text/css">' . helper :: minifyCss ( $this -> core -> output [ 'style' ]) . '</style>' ;
}
}
/**
* Affiche le style interne des pages
*/
public function showInlineStyle ()
{
// Import des styles liés à la page
if ( $this -> core -> output [ 'inlineStyle' ]) {
foreach ( $this -> core -> output [ 'inlineStyle' ] as $style ) {
if ( $style ) {
echo '<style type="text/css">' . helper :: minifyCss ( htmlspecialchars_decode ( $style )) . '</style>' ;
}
}
}
}
/**
* Importe les polices de caractères
*/
public function showFonts ()
{
// Import des fontes liées au thème
if ( file_exists ( self :: DATA_DIR . 'font/font.html' )) {
include_once ( self :: DATA_DIR . 'font/font.html' );
}
}
/**
* Affiche l ' import des librairies
*/
public function showVendor ()
{
// Variables partagées
$vars = 'var baseUrl = ' . json_encode ( helper :: baseUrl ( false )) . ';' ;
$vars .= 'var baseUrlQs = ' . json_encode ( helper :: baseUrl ()) . ';' ;
if (
$this -> getUser ( 'password' ) === $this -> getInput ( 'ZWII_USER_PASSWORD' )
2023-09-22 15:19:18 +02:00
and $this -> getUser ( 'group' ) >= self :: GROUP_EDITOR
2023-09-05 15:21:01 +02:00
) {
$vars .= 'var privateKey = ' . json_encode ( md5_file ( self :: DATA_DIR . 'core.json' )) . ';' ;
}
echo '<script defer >' . helper :: minifyJs ( $vars ) . '</script>' ;
// Librairies
$moduleId = $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'moduleId' ]);
foreach ( $this -> core -> output [ 'vendor' ] as $vendorName ) {
// Coeur
if ( file_exists ( 'core/vendor/' . $vendorName . '/inc.json' )) {
$vendorPath = 'core/vendor/' . $vendorName . '/' ;
}
// Module
elseif (
$moduleId
and in_array ( $moduleId , self :: $coreModuleIds ) === false
and file_exists ( self :: MODULE_DIR . $moduleId . '/vendor/' . $vendorName . '/inc.json' )
) {
$vendorPath = self :: MODULE_DIR . $moduleId . '/vendor/' . $vendorName . '/' ;
}
// Sinon continue
else {
continue ;
}
// Détermine le type d'import en fonction de l'extension de la librairie
$vendorFiles = json_decode ( file_get_contents ( $vendorPath . 'inc.json' ));
foreach ( $vendorFiles as $vendorFile ) {
switch ( pathinfo ( $vendorFile , PATHINFO_EXTENSION )) {
case 'css' :
// Force le rechargement lors d'une mise à jour du jeu d'icônes
$reload = $vendorPath === 'core/vendor/zwiico/'
? '?' . md5_file ( 'core/vendor/zwiico/css/zwiico-codes.css' )
: '' ;
echo '<link rel="stylesheet" href="' . helper :: baseUrl ( false ) . $vendorPath . $vendorFile . $reload . '">' ;
break ;
case 'js' :
echo '<script src="' . helper :: baseUrl ( false ) . $vendorPath . $vendorFile . '"></script>' ;
break ;
}
}
}
}
// Affiche une icône de navigation
// @param $position string 'top' or 'bottom
public function showNavButtons ( $position )
{
// Boutons par défaut
$leftButton = 'left' ;
$rightButton = 'right-dir' ;
// Déterminer la hiérarchie des pages
$hierarchy = array ();
foreach ( $this -> getHierarchy () as $parentKey => $parentValue ) {
$hierarchy [] = $parentKey ;
foreach ( $parentValue as $childKey ) {
$hierarchy [] = $childKey ;
}
}
// Parcourir la hiérarchie et rechercher les éléments avant et après
$elementToFind = $this -> getUrl ( 0 );
// Trouver la clé de l'élément recherché
$key = array_search ( $elementToFind , $hierarchy );
2023-11-15 14:42:23 +01:00
2023-10-20 17:09:29 +02:00
$previousPage = null ;
$nextPage = null ;
2023-09-05 15:21:01 +02:00
if ( $key !== false ) {
// Trouver l'élément précédent
$previousKey = ( $key > 0 ) ? $key - 1 : null ;
$previousValue = ( $previousKey !== null ) ? $hierarchy [ $previousKey ] : null ;
// Trouver l'élément suivant
$nextKey = ( $key < count ( $hierarchy ) - 1 ) ? $key + 1 : null ;
$nextValue = ( $nextKey !== null ) ? $hierarchy [ $nextKey ] : null ;
$previousPage = $previousValue ;
$nextPage = $nextValue ;
}
// Jeux d'icônes sinon celui par défaut
if ( $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navTemplate' ])) {
$leftButton = self :: $navIconTemplate [ $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navTemplate' ])][ 'left' ];
$rightButton = self :: $navIconTemplate [ $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navTemplate' ])][ 'right' ];
}
$items = '<div class="navButton">' ;
$items .= '<div class="row">' ;
$items .= '<div class="col1">' ;
if ( $previousPage !== null and $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navLeft' ]) === $position ) {
$items .= template :: button ( 'navPreviousButtonLeft' , [
'href' => helper :: baseUrl () . $previousPage ,
'value' => template :: ico ( $leftButton )
]);
}
$items .= '</div>' ;
$items .= '<div class="col1 offset10">' ;
if ( $nextPage !== null and $this -> getData ([ 'page' , $this -> getUrl ( 0 ), 'navRight' ]) === $position ) {
$items .= template :: button ( 'navNextButtonRight' , [
'href' => helper :: baseUrl () . $nextPage ,
'value' => template :: ico ( $rightButton )
]);
}
$items .= '</div></div></div>' ;
echo $items ;
}
}