dev004 Intégration des aides des icônes du core dans le template

This commit is contained in:
Fred Tempez 2022-08-28 19:37:58 +02:00
parent 3c8e438294
commit 967d8c929c
2 changed files with 120 additions and 33 deletions

View File

@ -417,10 +417,14 @@ class template {
/** /**
* Crée un icône * Crée un icône
* @Array :
* @param string $ico Classe de l'icône * @param string $ico Classe de l'icône
* @param string $margin Ajoute un margin autour de l'icône (choix : left, right, all) * @param string $margin Ajoute un margin autour de l'icône (choix : left, right, all)
* @param bool $animate Ajoute une animation à l'icône * @param bool $animate Ajoute une animation à l'icône
* @param string $fontSize Taille de la police * @param string $fontSize Taille de la police
* @param string $href lien vers une url
* @param string $help popup d'aide
* @param string $id de l'élement
* @return string * @return string
*/ */
// public static function ico($ico, $margin = '', $animate = false, $fontSize = '1em') { // public static function ico($ico, $margin = '', $animate = false, $fontSize = '1em') {
@ -428,10 +432,17 @@ class template {
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'margin' => '', 'margin' => '',
'animate' => false, 'animate' => false,
'fontSize' => '1em' 'fontSize' => '1em',
'href' => '',
'attr' => '',
'help' => '',
'id' => ''
], $attributes); ], $attributes);
return '<span class="zwiico-' . $ico . ($margin ? ' zwiico-margin-' . $margin : '') . ($animate ? ' animate-spin' : '') . '" style="font-size:' . $fontSize . '"><!----></span>'; $item = $attributes['href'] ? '<a data-tippy-content="' . $attributes['help'] . '" href="' . $attributes['href'] . '" ' . $attributes['attr']. ' >' : '';
$item .= '<span id="' . $attributes['id']. '" class="zwiico-' . $ico . ($attributes['margin'] ? ' zwiico-margin-' . $attributes['margin'] : '') . ($attributes['animate'] ? ' animate-spin' : '') . '" style="font-size:' . $attributes['fontSize'] . '"><!----></span>';
$item .= ($attributes['href']) ? '</a>' : '';
return $item;
} }
/** /**

View File

@ -1520,21 +1520,43 @@ class common {
) )
OR $this->getUrl(0) === 'theme' OR $this->getUrl(0) === 'theme'
) { ) {
$items .= '<span id="footerLoginLink" ' . $items .= '<span id="footerLoginLink" ' .
($this->getUrl(0) === 'theme' ? 'class="displayNone"' : '') . ($this->getUrl(0) === 'theme' ? 'class="displayNone">' : '>') .
'><wbr>&nbsp;|&nbsp;<a href="' . helper::baseUrl() . 'user/login/' . '<wbr>&nbsp;|&nbsp;<wbr>'.
strip_tags(str_replace('/', '_', $this->getUrl())) . template::ico('login', [
'" rel="nofollow">' . template::ico('login') .'</a></span>'; 'href' => helper::baseUrl() . 'user/login/' . strip_tags(str_replace('/', '_', $this->getUrl())) ,
'attr' => 'rel="nofollow"',
'help' => 'Connexion',
'fontSize' => '1.5em'
]) . '</span>';
} }
// Affichage de la barre de membre simple // Affichage de la barre de membre simple
if ( $this->getUser('group') === self::GROUP_MEMBER if ( $this->getUser('group') === self::GROUP_MEMBER
&& $this->getData(['theme','footer','memberBar']) === true && $this->getData(['theme','footer','memberBar']) === true
) { ) {
$items .= '<span id="footerDisplayMemberAccount"'; $items .= '<span id="footerDisplayMemberAccount"';
$items .= $this->getData(['theme','footer','displaymemberAccount']) === false ? ' class="displayNone"' : ''; $items .= $this->getData(['theme','footer','displaymemberAccount']) === false ? ' class="displayNone">' : '>';
$items .= '><wbr>&nbsp;|&nbsp;<a href="' . helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf'] . '" >' . template::ico('user', ['margin' => 'all']) . '</a>'; $items .= '<wbr>&nbsp;|&nbsp;' .
if( $this->getData(['user', $this->getUser('id') , 'files']) === true) $items .= '<wbr><a href="' . helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json') .'" data-lity>' . template::ico('folder') . '</a>'; template::ico('user', [
$items .= '<wbr><a id="barLogout" href="' . helper::baseUrl() . 'user/logout" >' . template::ico('logout',['margin' => 'left']) . '</a>'; 'margin' => 'all',
'help' => 'Mon compte',
'href' => helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf']
]);
if (
$this->getData(['user', $this->getUser('id') , 'files']) === true
) {
$items .= '<wbr>' . template::ico('folder', [
'href' => helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json'),
'margin' => 'all',
'attr' => 'data-lity',
'help' => 'Fichiers du site'
]);
}
$items .= '<wbr>'. template::ico('logout', [
'margin' => 'all',
'help' => 'Déconnecter',
'href' => helper::baseUrl() . 'user/logout'
]);
$items .= '</span>'; $items .= '</span>';
} }
// Fermeture du bloc copyright // Fermeture du bloc copyright
@ -1638,19 +1660,37 @@ class common {
) )
OR $this->getUrl(0) === 'theme' OR $this->getUrl(0) === 'theme'
) { ) {
$itemsRight .= '<li id="menuLoginLink" ' . $itemsRight .= '<li id="menuLoginLink" ' . ($this->getUrl(0) === 'theme' ? 'class="displayNone"' : '') . '>' .
($this->getUrl(0) === 'theme' ? 'class="displayNone"' : '') . template::ico('login', [
'><a href="' . helper::baseUrl() . 'user/login/' . 'href' => helper::baseUrl() . 'user/login/' . strip_tags(str_replace('/', '_', $this->getUrl())),
strip_tags(str_replace('/', '_', $this->getUrl())) . 'help' => "Connexion"
'">' . template::ico('login') .'</a></li>'; ]) .
'</li>';
} }
// Commandes pour les membres simples // Commandes pour les membres simples
if($this->getUser('group') == self::GROUP_MEMBER if($this->getUser('group') == self::GROUP_MEMBER
&& $this->getData(['theme','menu','memberBar']) === true && $this->getData(['theme','menu','memberBar']) === true
) { ) {
if( $this->getData(['user', $this->getUser('id') , 'files']) === true) $itemsRight .= '<li><a href="' . helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json') .'" data-tippy-content="Gérer les fichiers" data-lity>' . template::ico('folder') . '</a></li>'; if (
$itemsRight .= '<li><a href="' . helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf'] . '" data-tippy-content="Gérer mon compte">' . template::ico('user', ['margin' => 'right']) . '</a></li>'; $this->getData(['user', $this->getUser('id') , 'files']) === true
$itemsRight .= '<li><a id="barLogout" href="' . helper::baseUrl() . 'user/logout" data-tippy-content="Me déconnecter">' . template::ico('logout') . '</a></li>'; ) {
$itemsRight .= '<li>' . template::ico('folder', [
'href' => helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json'),
'attr' => 'data-lity',
'help' => 'Fichiers du site'
]). '</li>';
}
$itemsRight .= '<li>' . template::ico('user', [
'help' => 'Mon compte',
'margin' => 'right',
'href' => helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf']
]) . '</li>';
$itemsRight .= '<li>' .
template::ico('logout', [
'help' => 'Déconnecter',
'href' => helper::baseUrl() . 'user/logout',
'id' => 'barLogout'
]) . '</li>';
} }
// Retourne les items du menu // Retourne les items du menu
echo '<ul class="navMain" id="menuLeft">' . $itemsLeft . '</ul><ul class="navMain" id="menuRight">' . $itemsRight; echo '<ul class="navMain" id="menuLeft">' . $itemsLeft . '</ul><ul class="navMain" id="menuRight">' . $itemsRight;
@ -2018,7 +2058,10 @@ class common {
} }
$leftItems .= '</optgroup>'; $leftItems .= '</optgroup>';
$leftItems .= '</select></li>'; $leftItems .= '</select></li>';
$leftItems .= '<li><a href="' . helper::baseUrl() . 'page/add" data-tippy-content="Créer une page ou<br>une barre latérale">' . template::ico('plus') . '</a></li>'; $leftItems .= '<li>' . template::ico('plus', [
'href' => helper::baseUrl() . 'page/add',
'help' => 'Nouvelle page ou <br />nouvelle barre latérale'
]) . '</li>';
if( if(
// Sur un module de page qui autorise le bouton de modification de la page // Sur un module de page qui autorise le bouton de modification de la page
$this->output['showBarEditButton'] $this->output['showBarEditButton']
@ -2029,12 +2072,28 @@ class common {
// Sur une page d'accueil // Sur une page d'accueil
OR $this->getUrl(0) === '' OR $this->getUrl(0) === ''
) { ) {
$leftItems .= '<li><a href="' . helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '" data-tippy-content="Modifier la page">' . template::ico('pencil') . '</a></li>'; $leftItems .= '<li>' . template::ico('pencil', [
'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0),
'help' => 'Editer la page'
]) . '</li>';
if ($this->getData(['page', $this->getUrl(0),'moduleId'])) { if ($this->getData(['page', $this->getUrl(0),'moduleId'])) {
$leftItems .= '<li><a href="' . helper::baseUrl() . $this->getUrl(0) . '/config' . '" data-tippy-content="Configurer le module">' . template::ico('gear') . '</a></li>'; $leftItems .= '<li>' . template::ico('gear', [
'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
'help' => 'Module de la page'
]) . '</li>';
} }
$leftItems .= '<li><a id="pageDuplicate" href="' . helper::baseUrl() . 'page/duplicate/' . $this->getUrl(0) . '&csrf=' . $_SESSION['csrf'] . '" data-tippy-content="Dupliquer la page">' . template::ico('clone') . '</a></li>'; $leftItems .= '<li>' . template::ico('clone', [
$leftItems .= '<li><a id="pageDelete" href="' . helper::baseUrl() . 'page/delete/' . $this->getUrl(0) . '&csrf=' . $_SESSION['csrf'] . '" data-tippy-content="Effacer la page">' . template::ico('trash') . '</a></li>'; 'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(0) . '&csrf=' . $_SESSION['csrf'],
'help' => 'Cloner la page'
])
. '</li>';
$leftItems .= '<li>' . template::ico('trash', [
'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(0) . '&csrf=' . $_SESSION['csrf'],
'help' => 'Supprimer la page',
'id' => 'pageDelete'
])
. '</li>';
} }
} }
// Items de droite // Items de droite
@ -2043,13 +2102,26 @@ class common {
$rightItems .= '<li><a href="' . helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json') .'" data-tippy-content="Gérer les fichiers" data-lity>' . template::ico('folder') . '</a></li>'; $rightItems .= '<li><a href="' . helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json') .'" data-tippy-content="Gérer les fichiers" data-lity>' . template::ico('folder') . '</a></li>';
} }
if($this->getUser('group') >= self::GROUP_ADMIN) { if($this->getUser('group') >= self::GROUP_ADMIN) {
$rightItems .= '<li><a href="' . helper::baseUrl() . 'theme" data-tippy-content="Personnaliser les thèmes">' . template::ico('brush') . '</a></li>'; $rightItems .= '<li>' . template::ico('brush', [
$rightItems .= '<li><a href="' . helper::baseUrl() . 'plugin" data-tippy-content="Gérer les modules">' . template::ico('puzzle') . '</a></li>'; 'help' => 'Thème',
if ($this->getData(['config', 'i18n', 'enable']) === true) { 'href' => helper::baseUrl() . 'theme'
$rightItems .= '<li><a href="' . helper::baseUrl() . 'translate" data-tippy-content="Gestion des langues">' . template::ico('flag') . '</a></li>'; ]) . '</li>';
} $rightItems .= '<li>' . template::ico('puzzle', [
$rightItems .= '<li><a href="' . helper::baseUrl() . 'config" data-tippy-content="Configurer le site">' . template::ico('cog-alt') . '</a></li>'; 'help' => 'Gérer les modules',
$rightItems .= '<li><a href="' . helper::baseUrl() . 'user" data-tippy-content="Configurer les utilisateurs">' . template::ico('users') . '</a></li>'; 'href' => helper::baseUrl() . 'plugin'
]) . '</li>';
$rightItems .= '<li>' . template::ico('flag', [
'help' => 'Traduction',
'href' => helper::baseUrl() . 'translate'
]) . '</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 // Mise à jour automatique
$today = mktime(0, 0, 0); $today = mktime(0, 0, 0);
@ -2073,7 +2145,11 @@ class common {
if($this->getUser('group') >= self::GROUP_MODERATOR) { if($this->getUser('group') >= self::GROUP_MODERATOR) {
$rightItems .= '<li><a href="' . helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf'] . '" data-tippy-content="Configurer mon compte">' . template::ico('user', ['margin' => 'right']) . '<span id="displayUsername">' . $this->getUser('firstname') . ' ' . $this->getUser('lastname') . '</span></a></li>'; $rightItems .= '<li><a href="' . helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf'] . '" data-tippy-content="Configurer mon compte">' . template::ico('user', ['margin' => 'right']) . '<span id="displayUsername">' . $this->getUser('firstname') . ' ' . $this->getUser('lastname') . '</span></a></li>';
} }
$rightItems .= '<li><a id="barLogout" href="' . helper::baseUrl() . 'user/logout" data-tippy-content="Me déconnecter">' . template::ico('logout') . '</a></li>'; $rightItems .= '<li>' . template::ico('logout', [
'help' => 'Déconnecter',
'href' => helper::baseUrl() . 'user/logout',
'id' => 'barLogout'
]) . '</li>';
// Barre de membre // Barre de membre
echo '<div id="bar"><div class="container"><ul id="barLeft">' . $leftItems . '</ul><ul id="barRight">' . $rightItems . '</ul></div></div>'; echo '<div id="bar"><div class="container"><ul id="barLeft">' . $leftItems . '</ul><ul id="barRight">' . $rightItems . '</ul></div></div>';
} }