Normalisation + bugs de variables

This commit is contained in:
Fred Tempez 2022-09-29 08:45:59 +02:00
parent 32b4f3b7de
commit 469581e37f
62 changed files with 5060 additions and 4849 deletions

View File

@ -1,22 +1,25 @@
<?php <?php
class template { class template
{
/** /**
* retourne un texte traduit * retourne un texte traduit
*/ */
public static function topic($text) { public static function topic($text)
{
$text = helper::translate($text); $text = helper::translate($text);
return $text ; return $text;
} }
/** /**
* Crée un bouton * Crée un bouton
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function button($nameId, array $attributes = []) { public static function button($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'class' => '', 'class' => '',
@ -40,18 +43,19 @@ class template {
$attributes['disabled'] ? 'disabled' : '', $attributes['disabled'] ? 'disabled' : '',
$attributes['class'], $attributes['class'],
$attributes['uniqueSubmission'] ? 'uniqueSubmission' : '', $attributes['uniqueSubmission'] ? 'uniqueSubmission' : '',
$attributes['help'] ? ' title="' . $attributes['help'] . '" ': '', $attributes['help'] ? ' title="' . $attributes['help'] . '" ' : '',
($attributes['ico'] ? template::ico($attributes['ico'], ['margin' => 'right']) : '') . $attributes['value'] ($attributes['ico'] ? template::ico($attributes['ico'], ['margin' => 'right']) : '') . $attributes['value']
); );
} }
/** /**
* Crée un champ captcha * Crée un champ captcha
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function captcha($nameId, array $attributes = []) { public static function captcha($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'class' => '', 'class' => '',
@ -61,32 +65,32 @@ class template {
'name' => $nameId, 'name' => $nameId,
'value' => '', 'value' => '',
'limit' => false, // captcha simple 'limit' => false, // captcha simple
'type'=> 'alpha' // num(érique) ou alpha(bétique) 'type' => 'alpha' // num(érique) ou alpha(bétique)
], $attributes); ], $attributes);
// Traduction de l'aide et de l'étiquette // Traduction de l'aide et de l'étiquette
// $attributes['value'] = helper::translate($attributes['value']); // $attributes['value'] = helper::translate($attributes['value']);
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
// Captcha quatre opérations // Captcha quatre opérations
// Limite addition et soustraction selon le type de captcha // Limite addition et soustraction selon le type de captcha
$numbers = [0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20]; $numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20];
$letters = ['u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a']; $letters = ['u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'];
$limit = $attributes['limit'] ? count($letters)-1 : 10; $limit = $attributes['limit'] ? count($letters) - 1 : 10;
// Tirage de l'opération // Tirage de l'opération
mt_srand((float) microtime()*1000000); mt_srand((float) microtime() * 1000000);
// Captcha simple limité à l'addition // Captcha simple limité à l'addition
$operator = $attributes['limit'] ? mt_rand (1, 4) : 1; $operator = $attributes['limit'] ? mt_rand(1, 4) : 1;
// Limite si multiplication ou division // Limite si multiplication ou division
if ($operator > 2) { if ($operator > 2) {
$limit = 10; $limit = 10;
} }
// Tirage des nombres // Tirage des nombres
mt_srand((float) microtime()*1000000); mt_srand((float) microtime() * 1000000);
$firstNumber = mt_rand (1, $limit); $firstNumber = mt_rand(1, $limit);
mt_srand((float) microtime()*1000000); mt_srand((float) microtime() * 1000000);
$secondNumber = mt_rand (1, $limit); $secondNumber = mt_rand(1, $limit);
// Permutation si addition ou soustraction // Permutation si addition ou soustraction
if (($operator < 3) and ($firstNumber < $secondNumber)) { if (($operator < 3) and ($firstNumber < $secondNumber)) {
@ -113,38 +117,41 @@ class template {
$operator = template::ico('divide'); $operator = template::ico('divide');
$limit2 = [10, 10, 6, 5, 4, 3, 2, 2, 2, 2]; $limit2 = [10, 10, 6, 5, 4, 3, 2, 2, 2, 2];
for ($i = 1; $i <= $firstNumber; $i++) { for ($i = 1; $i <= $firstNumber; $i++) {
$limit = $limit2[$i-1]; $limit = $limit2[$i - 1];
} }
mt_srand((float) microtime()*1000000); mt_srand((float) microtime() * 1000000);
$secondNumber = mt_rand(1, $limit); $secondNumber = mt_rand(1, $limit);
$firstNumber = $firstNumber * $secondNumber; $firstNumber = $firstNumber * $secondNumber;
$result = $firstNumber / $secondNumber; $result = $firstNumber / $secondNumber;
break; break;
} }
// Hashage du résultat // Hashage du résultat
$result = password_hash($result, PASSWORD_BCRYPT); $result = password_hash($result, PASSWORD_BCRYPT);
// Codage des valeurs de l'opération // Codage des valeurs de l'opération
$firstLetter = uniqid(); $firstLetter = uniqid();
$secondLetter = uniqid(); $secondLetter = uniqid();
// Masquage image source pour éviter un décodage // Masquage image source pour éviter un décodage
copy ('core/vendor/zwiico/png/' . $attributes['type'] . '/' . $letters[$firstNumber] . '.png', 'site/tmp/' . $firstLetter . '.png'); copy('core/vendor/zwiico/png/' . $attributes['type'] . '/' . $letters[$firstNumber] . '.png', 'site/tmp/' . $firstLetter . '.png');
copy ('core/vendor/zwiico/png/' . $attributes['type'] . '/' . $letters[$secondNumber] . '.png', 'site/tmp/' . $secondLetter . '.png'); copy('core/vendor/zwiico/png/' . $attributes['type'] . '/' . $letters[$secondNumber] . '.png', 'site/tmp/' . $secondLetter . '.png');
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="captcha inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="captcha inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
$html .= self::label($attributes['id'], $html .= self::label(
'<img class="captcha' . ucFirst($attributes['type']) . '" src="' . helper::baseUrl(false) . 'site/tmp/' . $firstLetter . '.png" />&nbsp;<strong>' . $operator . '</strong>&nbsp;<img class="captcha' . ucFirst($attributes['type']) . '" src="' . helper::baseUrl(false) . 'site/tmp/' . $secondLetter . '.png" /> en chiffres ?', [ $attributes['id'],
'help' => $attributes['help'] '<img class="captcha' . ucFirst($attributes['type']) . '" src="' . helper::baseUrl(false) . 'site/tmp/' . $firstLetter . '.png" />&nbsp;<strong>' . $operator . '</strong>&nbsp;<img class="captcha' . ucFirst($attributes['type']) . '" src="' . helper::baseUrl(false) . 'site/tmp/' . $secondLetter . '.png" /> en chiffres ?',
]); [
'help' => $attributes['help']
]
);
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
@ -170,14 +177,15 @@ class template {
} }
/** /**
* Crée une case à cocher à sélection multiple * Crée une case à cocher à sélection multiple
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param string $value Valeur de la case à cocher * @param string $value Valeur de la case à cocher
* @param string $label Label de la case à cocher * @param string $label Label de la case à cocher
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function checkbox($nameId, $value, $label, array $attributes = []) { public static function checkbox($nameId, $value, $label, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'before' => true, 'before' => true,
@ -193,14 +201,14 @@ class template {
$label = helper::translate($label); $label = helper::translate($label);
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['checked'] = (bool) common::$inputBefore[$attributes['id']]; $attributes['checked'] = (bool) common::$inputBefore[$attributes['id']];
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
@ -222,12 +230,13 @@ class template {
} }
/** /**
* Crée un champ date * Crée un champ date
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function date($nameId, array $attributes = []) { public static function date($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'autocomplete' => 'on', 'autocomplete' => 'on',
@ -249,23 +258,22 @@ class template {
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
//$attributes['placeholder'] = helper::translate($attributes['placeholder']); //$attributes['placeholder'] = helper::translate($attributes['placeholder']);
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['value'] = common::$inputBefore[$attributes['id']]; $attributes['value'] = common::$inputBefore[$attributes['id']];
} } else {
else {
$attributes['value'] = ($attributes['value'] ? helper::filter($attributes['value'], helper::FILTER_TIMESTAMP) : ''); $attributes['value'] = ($attributes['value'] ? helper::filter($attributes['value'], helper::FILTER_TIMESTAMP) : '');
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
if($attributes['label']) { if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [ $html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
} }
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
@ -290,12 +298,13 @@ class template {
} }
/** /**
* Crée un champ d'upload de fichier * Crée un champ d'upload de fichier
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function file($nameId, array $attributes = []) { public static function file($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'before' => true, 'before' => true,
@ -316,20 +325,20 @@ class template {
$attributes['value'] = helper::translate($attributes['value']); $attributes['value'] = helper::translate($attributes['value']);
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['value'] = common::$inputBefore[$attributes['id']]; $attributes['value'] = common::$inputBefore[$attributes['id']];
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
$html .= self::notice($attributes['id'], $notice); $html .= self::notice($attributes['id'], $notice);
// Label // Label
if($attributes['label']) { if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [ $html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
@ -346,12 +355,12 @@ class template {
$html .= sprintf( $html .= sprintf(
'<a '<a
href="' . href="' .
helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php' . helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php' .
'?relative_url=1' . '?relative_url=1' .
'&field_id=' . $attributes['id'] . '&field_id=' . $attributes['id'] .
'&type=' . $attributes['type'] . '&type=' . $attributes['type'] .
'&akey=' . md5_file(core::DATA_DIR.'core.json') . '&akey=' . md5_file(core::DATA_DIR . 'core.json') .
($attributes['extensions'] ? '&extensions=' . $attributes['extensions'] : '') ($attributes['extensions'] ? '&extensions=' . $attributes['extensions'] : '')
. '" . '"
class="inputFile %s %s" class="inputFile %s %s"
%s %s
@ -377,19 +386,21 @@ class template {
} }
/** /**
* Ferme un formulaire * Ferme un formulaire
* @return string * @return string
*/ */
public static function formClose() { public static function formClose()
{
return '</form>'; return '</form>';
} }
/** /**
* Ouvre un formulaire protégé par CSRF * Ouvre un formulaire protégé par CSRF
* @param string $id Id du formulaire * @param string $id Id du formulaire
* @return string * @return string
*/ */
public static function formOpen($id) { public static function formOpen($id)
{
// Ouverture formulaire // Ouverture formulaire
$html = '<form id="' . $id . '" method="post">'; $html = '<form id="' . $id . '" method="post">';
// Stock le token CSRF // Stock le token CSRF
@ -403,21 +414,23 @@ class template {
/** /**
* Crée une aide qui s'affiche au survole * Crée une aide qui s'affiche au survole
* @param string $text Texte de l'aide * @param string $text Texte de l'aide
* @return string * @return string
*/ */
public static function help($text) { public static function help($text)
{
return '<span class="helpButton" data-tippy-content="' . $text . '">' . self::ico('help') . '<!----></span>'; return '<span class="helpButton" data-tippy-content="' . $text . '">' . self::ico('help') . '<!----></span>';
} }
/** /**
* Crée un champ caché * Crée un champ caché
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function hidden($nameId, array $attributes = []) { public static function hidden($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'before' => true, 'before' => true,
@ -429,7 +442,7 @@ class template {
'value' => '' 'value' => ''
], $attributes); ], $attributes);
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['value'] = common::$inputBefore[$attributes['id']]; $attributes['value'] = common::$inputBefore[$attributes['id']];
} }
// Texte // Texte
@ -439,19 +452,20 @@ class template {
} }
/** /**
* Crée un icône * Crée un icône
* @Array : * @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 $href lien vers une url
* @param string $help popup d'aide * @param string $help popup d'aide
* @param string $id de l'élement * @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') {
public static function ico($ico, array $attributes = []) { public static function ico($ico, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'margin' => '', 'margin' => '',
@ -465,62 +479,64 @@ class template {
// Traduction de l'aide // Traduction de l'aide
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
// Contenu de l'icône // Contenu de l'icône
$item = $attributes['href'] ? '<a id="' . $attributes['id']. '" data-tippy-content="' . $attributes['help'] . '" href="' . $attributes['href'] . '" ' . $attributes['attr']. ' >' : ''; $item = $attributes['href'] ? '<a id="' . $attributes['id'] . '" data-tippy-content="' . $attributes['help'] . '" href="' . $attributes['href'] . '" ' . $attributes['attr'] . ' >' : '';
$item .= '<span class="zwiico-' . $ico . ($attributes['margin'] ? ' zwiico-margin-' . $attributes['margin'] : '') . ($attributes['animate'] ? ' animate-spin' : '') . '" style="font-size:' . $attributes['fontSize'] . '"><!----></span>'; $item .= '<span class="zwiico-' . $ico . ($attributes['margin'] ? ' zwiico-margin-' . $attributes['margin'] : '') . ($attributes['animate'] ? ' animate-spin' : '') . '" style="font-size:' . $attributes['fontSize'] . '"><!----></span>';
$item .= ($attributes['href']) ? '</a>' : ''; $item .= ($attributes['href']) ? '</a>' : '';
return $item; return $item;
} }
/** /**
* Crée un drapeau du site courante * Crée un drapeau du site courante
* @param string $langId Id de la langue à affiche ou selected pour la langue courante * @param string $langId Id de la langue à affiche ou selected pour la langue courante
* @param string size en pixels ou en rem * @param string size en pixels ou en rem
* @return string * @return string
*/ */
public static function flag($langId, $size = 'auto') { public static function flag($langId, $size = 'auto')
{
switch ($langId) { switch ($langId) {
case '': case '':
$lang = 'fr_FR'; $lang = 'fr_FR';
break; break;
case in_array($langId,core::$languages): case in_array($langId, core::$languages):
$lang = $langId; $lang = $langId;
break; break;
case 'selected': case 'selected':
if ( isset($_COOKIE['ZWII_I18N_SITE']) if (isset($_COOKIE['ZWII_I18N_SITE'])) {
) {
$lang = $_COOKIE['ZWII_I18N_SITE']; $lang = $_COOKIE['ZWII_I18N_SITE'];
} else { } else {
$lang = 'fr_FR'; $lang = 'fr_FR';
} }
} }
return '<img class="flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $langId . '.png" return '<img class="flag" src="' . helper::baseUrl(false) . 'core/vendor/i18n/png/' . $langId . '.png"
width="' . $size .'" width="' . $size . '"
height="' . $size .'" height="' . $size . '"
title="' . $langId .'" title="' . $langId . '"
alt="(' . $langId . ')"/>'; alt="(' . $langId . ')"/>';
} }
/** /**
* Crée un label * Crée un label
* @param string $for For du label * @param string $for For du label
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @param string $text Texte du label * @param string $text Texte du label
* @return string * @return string
*/ */
public static function label($for, $text, array $attributes = []) { public static function label($for, $text, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'class' => '', 'class' => '',
'for' => $for, 'for' => $for,
'help' => '' 'help' => ''
], $attributes); ], $attributes);
// Traduction de l'étiquette si déjà appelée par une fonction de template // Traduction de l'étiquette si déjà appelée par une fonction de template
; if ( ;
if (
get_called_class() !== 'template' get_called_class() !== 'template'
) { ) {
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
} }
if($attributes['help'] !== '') { if ($attributes['help'] !== '') {
$text = $text . self::help($attributes['help']); $text = $text . self::help($attributes['help']);
} }
// Retourne le html // Retourne le html
@ -532,12 +548,13 @@ class template {
} }
/** /**
* Crée un champ mail * Crée un champ mail
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function mail($nameId, array $attributes = []) { public static function mail($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'autocomplete' => 'on', 'autocomplete' => 'on',
@ -560,20 +577,20 @@ class template {
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
//$attributes['placeholder'] = helper::translate($attributes['placeholder']); //$attributes['placeholder'] = helper::translate($attributes['placeholder']);
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['value'] = common::$inputBefore[$attributes['id']]; $attributes['value'] = common::$inputBefore[$attributes['id']];
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
if($attributes['label']) { if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [ $html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
} }
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
@ -590,22 +607,24 @@ class template {
} }
/** /**
* Crée une notice * Crée une notice
* @param string $id Id du champ * @param string $id Id du champ
* @param string $notice Notice * @param string $notice Notice
* @return string * @return string
*/ */
public static function notice($id, $notice) { public static function notice($id, $notice)
{
return ' <span id="' . $id . 'Notice" class="notice ' . ($notice ? '' : 'displayNone') . '">' . $notice . '</span>'; return ' <span id="' . $id . 'Notice" class="notice ' . ($notice ? '' : 'displayNone') . '">' . $notice . '</span>';
} }
/** /**
* Crée un champ mot de passe * Crée un champ mot de passe
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function password($nameId, array $attributes = []) { public static function password($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'autocomplete' => 'on', 'autocomplete' => 'on',
@ -628,14 +647,14 @@ class template {
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
if($attributes['label']) { if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [ $html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
} }
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
@ -652,13 +671,14 @@ class template {
} }
/** /**
* Crée un champ sélection * Crée un champ sélection
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $options Liste des options du champ de sélection ($value => $text) * @param array $options Liste des options du champ de sélection ($value => $text)
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function select($nameId, array $options, array $attributes = []) { public static function select($nameId, array $options, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'before' => true, 'before' => true,
@ -682,43 +702,44 @@ class template {
$attributes['fonts'] = []; $attributes['fonts'] = [];
} }
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['selected'] = common::$inputBefore[$attributes['id']]; $attributes['selected'] = common::$inputBefore[$attributes['id']];
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
if($attributes['label']) { if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [ $html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
} }
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
$html .= self::notice($attributes['id'], $notice); $html .= self::notice($attributes['id'], $notice);
// Début sélection // Début sélection
$html .= sprintf('<select %s>', $html .= sprintf(
'<select %s>',
helper::sprintAttributes($attributes) helper::sprintAttributes($attributes)
); );
foreach($options as $value => $text) { foreach ($options as $value => $text) {
// Select des liste de fontes // Select des liste de fontes
$html .= isset($fonts) ? sprintf( $html .= isset($fonts) ? sprintf(
'<option value="%s"%s style="font-family: %s;">%s</option>', '<option value="%s"%s style="font-family: %s;">%s</option>',
$value, $value,
$attributes['selected'] == $value ? ' selected' : '', // Double == pour ignorer le type de variable car $_POST change les types en string $attributes['selected'] == $value ? ' selected' : '', // Double == pour ignorer le type de variable car $_POST change les types en string
$fonts[$value], $fonts[$value],
$text $text
// Select standard // Select standard
) : sprintf( ) : sprintf(
'<option value="%s"%s>%s</option>', '<option value="%s"%s>%s</option>',
$value, $value,
$attributes['selected'] == $value ? ' selected' : '', // Double == pour ignorer le type de variable car $_POST change les types en string $attributes['selected'] == $value ? ' selected' : '', // Double == pour ignorer le type de variable car $_POST change les types en string
$text $text
); );
} }
// Fin sélection // Fin sélection
$html .= '</select>'; $html .= '</select>';
@ -729,21 +750,23 @@ class template {
} }
/** /**
* Crée une bulle de dialogue * Crée une bulle de dialogue
* @param string $text Texte de la bulle * @param string $text Texte de la bulle
* @return string * @return string
*/ */
public static function speech($text) { public static function speech($text)
return '<div class="speech"><div class="speechBubble">' . $text . '</div>' . template::ico('mimi speechMimi', ['fontSize'=> '7em']) . '</div>'; {
return '<div class="speech"><div class="speechBubble">' . $text . '</div>' . template::ico('mimi speechMimi', ['fontSize' => '7em']) . '</div>';
} }
/** /**
* Crée un bouton validation * Crée un bouton validation
* @param string $nameId Nom & id du bouton validation * @param string $nameId Nom & id du bouton validation
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function submit($nameId, array $attributes = []) { public static function submit($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'class' => '', 'class' => '',
@ -767,74 +790,76 @@ class template {
} }
/** /**
* Crée un tableau * Crée un tableau
* @param array $cols Cols des colonnes (format: [col colonne1, col colonne2, etc]) * @param array $cols Cols des colonnes (format: [col colonne1, col colonne2, etc])
* @param array $body Contenu (format: [[contenu1, contenu2, etc], [contenu1, contenu2, etc]]) * @param array $body Contenu (format: [[contenu1, contenu2, etc], [contenu1, contenu2, etc]])
* @param array $head Entêtes (format : [[titre colonne1, titre colonne2, etc]) * @param array $head Entêtes (format : [[titre colonne1, titre colonne2, etc])
* @param array $rowsId Id pour la numérotation des rows (format : [id colonne1, id colonne2, etc]) * @param array $rowsId Id pour la numérotation des rows (format : [id colonne1, id colonne2, etc])
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function table(array $cols = [], array $body = [], array $head = [], array $attributes = [], array $rowsId = []) { public static function table(array $cols = [], array $body = [], array $head = [], array $attributes = [], array $rowsId = [])
// Attributs par défaut {
$attributes = array_merge([ // Attributs par défaut
'class' => '', $attributes = array_merge([
'classWrapper' => '', 'class' => '',
'id' => '' 'classWrapper' => '',
], $attributes); 'id' => ''
], $attributes);
// Traduction de l'aide et de l'étiquette // Traduction de l'aide et de l'étiquette
foreach($head as $value) { foreach ($head as $value) {
$head[array_search($value,$head)] = helper::translate($value); $head[array_search($value, $head)] = helper::translate($value);
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="tableWrapper ' . $attributes['classWrapper']. '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="tableWrapper ' . $attributes['classWrapper'] . '">';
// Début tableau // Début tableau
$html .= '<table id="' . $attributes['id'] . '" class="table ' . $attributes['class']. '">'; $html .= '<table id="' . $attributes['id'] . '" class="table ' . $attributes['class'] . '">';
// Entêtes // Entêtes
if($head) { if ($head) {
// Début des entêtes // Début des entêtes
$html .= '<thead>'; $html .= '<thead>';
$html .= '<tr class="nodrag">'; $html .= '<tr class="nodrag">';
$i = 0; $i = 0;
foreach($head as $th) { foreach ($head as $th) {
$html .= '<th class="col' . $cols[$i++] . '">' . $th . '</th>'; $html .= '<th class="col' . $cols[$i++] . '">' . $th . '</th>';
} }
// Fin des entêtes // Fin des entêtes
$html .= '</tr>'; $html .= '</tr>';
$html .= '</thead>'; $html .= '</thead>';
} }
// Pas de tableau d'Id transmis, générer une numérotation // Pas de tableau d'Id transmis, générer une numérotation
if (empty($rowsId)) { if (empty($rowsId)) {
$rowsId = range(0,count($body)); $rowsId = range(0, count($body));
} }
// Début contenu // Début contenu
$j = 0; $j = 0;
foreach($body as $tr) { foreach ($body as $tr) {
// Id de ligne pour les tableaux drag and drop // Id de ligne pour les tableaux drag and drop
$html .= '<tr id="' . $rowsId[$j++] . '">'; $html .= '<tr id="' . $rowsId[$j++] . '">';
$i = 0; $i = 0;
foreach($tr as $td) { foreach ($tr as $td) {
$html .= '<td class="col' . $cols[$i++] . '">' . $td . '</td>'; $html .= '<td class="col' . $cols[$i++] . '">' . $td . '</td>';
} }
$html .= '</tr>'; $html .= '</tr>';
} }
// Fin contenu // Fin contenu
$html .= '</tbody>'; $html .= '</tbody>';
// Fin tableau // Fin tableau
$html .= '</table>'; $html .= '</table>';
// Fin container // Fin container
$html .= '</div>'; $html .= '</div>';
// Retourne le html // Retourne le html
return $html; return $html;
} }
/** /**
* Crée un champ texte court * Crée un champ texte court
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function text($nameId, array $attributes = []) { public static function text($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'autocomplete' => 'on', 'autocomplete' => 'on',
@ -857,20 +882,20 @@ class template {
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
//$attributes['placeholder'] = helper::translate($attributes['placeholder']); //$attributes['placeholder'] = helper::translate($attributes['placeholder']);
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['value'] = common::$inputBefore[$attributes['id']]; $attributes['value'] = common::$inputBefore[$attributes['id']];
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
if($attributes['label']) { if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [ $html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
} }
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }
@ -887,12 +912,13 @@ class template {
} }
/** /**
* Crée un champ texte long * Crée un champ texte long
* @param string $nameId Nom et id du champ * @param string $nameId Nom et id du champ
* @param array $attributes Attributs ($key => $value) * @param array $attributes Attributs ($key => $value)
* @return string * @return string
*/ */
public static function textarea($nameId, array $attributes = []) { public static function textarea($nameId, array $attributes = [])
{
// Attributs par défaut // Attributs par défaut
$attributes = array_merge([ $attributes = array_merge([
'before' => true, 'before' => true,
@ -912,20 +938,20 @@ class template {
$attributes['label'] = helper::translate($attributes['label']); $attributes['label'] = helper::translate($attributes['label']);
$attributes['help'] = helper::translate($attributes['help']); $attributes['help'] = helper::translate($attributes['help']);
// Sauvegarde des données en cas d'erreur // Sauvegarde des données en cas d'erreur
if($attributes['before'] AND array_key_exists($attributes['id'], common::$inputBefore)) { if ($attributes['before'] and array_key_exists($attributes['id'], common::$inputBefore)) {
$attributes['value'] = common::$inputBefore[$attributes['id']]; $attributes['value'] = common::$inputBefore[$attributes['id']];
} }
// Début du wrapper // Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">'; $html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
// Label // Label
if($attributes['label']) { if ($attributes['label']) {
$html .= self::label($attributes['id'], $attributes['label'], [ $html .= self::label($attributes['id'], $attributes['label'], [
'help' => $attributes['help'] 'help' => $attributes['help']
]); ]);
} }
// Notice // Notice
$notice = ''; $notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) { if (array_key_exists($attributes['id'], common::$inputNotices)) {
$notice = common::$inputNotices[$attributes['id']]; $notice = common::$inputNotices[$attributes['id']];
$attributes['class'] .= ' notice'; $attributes['class'] .= ' notice';
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -14,12 +14,13 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
class config extends common { class config extends common
{
public static $actions = [ public static $actions = [
'backup' => self::GROUP_ADMIN, 'backup' => self::GROUP_ADMIN,
'copyBackups'=> self::GROUP_ADMIN, 'copyBackups' => self::GROUP_ADMIN,
'delBackups'=> self::GROUP_ADMIN, 'delBackups' => self::GROUP_ADMIN,
'configMetaImage' => self::GROUP_ADMIN, 'configMetaImage' => self::GROUP_ADMIN,
'siteMap' => self::GROUP_ADMIN, 'siteMap' => self::GROUP_ADMIN,
'index' => self::GROUP_ADMIN, 'index' => self::GROUP_ADMIN,
@ -27,7 +28,7 @@ class config extends common {
'updateBaseUrl' => self::GROUP_ADMIN, 'updateBaseUrl' => self::GROUP_ADMIN,
'script' => self::GROUP_ADMIN, 'script' => self::GROUP_ADMIN,
'logReset' => self::GROUP_ADMIN, 'logReset' => self::GROUP_ADMIN,
'logDownload'=> self::GROUP_ADMIN, 'logDownload' => self::GROUP_ADMIN,
'blacklistReset' => self::GROUP_ADMIN, 'blacklistReset' => self::GROUP_ADMIN,
'blacklistDownload' => self::GROUP_ADMIN 'blacklistDownload' => self::GROUP_ADMIN
]; ];
@ -201,7 +202,8 @@ class config extends common {
* Sitemap compressé et non compressé * Sitemap compressé et non compressé
* Robots.txt * Robots.txt
*/ */
public function siteMap() { public function siteMap()
{
// Mettre à jour le site map // Mettre à jour le site map
$successSitemap = $this->createSitemap(); $successSitemap = $this->createSitemap();
@ -218,18 +220,19 @@ class config extends common {
/** /**
* Sauvegarde des données * Sauvegarde des données
*/ */
public function backup() { public function backup()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Creation du ZIP // Creation du ZIP
$filter = $this->getInput('configBackupOption',helper::FILTER_BOOLEAN) === true ? ['backup','tmp'] : ['backup','tmp','file']; $filter = $this->getInput('configBackupOption', helper::FILTER_BOOLEAN) === true ? ['backup', 'tmp'] : ['backup', 'tmp', 'file'];
$fileName = helper::autoBackup(self::TEMP_DIR,$filter); $fileName = helper::autoBackup(self::TEMP_DIR, $filter);
// Créer le répertoire manquant // Créer le répertoire manquant
if (!is_dir(self::FILE_DIR.'source/backup')) { if (!is_dir(self::FILE_DIR . 'source/backup')) {
mkdir(self::FILE_DIR.'source/backup', 0755); mkdir(self::FILE_DIR . 'source/backup', 0755);
} }
// Copie dans les fichiers // Copie dans les fichiers
$success = copy (self::TEMP_DIR . $fileName , self::FILE_DIR.'source/backup/' . $fileName); $success = copy(self::TEMP_DIR . $fileName, self::FILE_DIR . 'source/backup/' . $fileName);
// Détruire le temporaire // Détruire le temporaire
unlink(self::TEMP_DIR . $fileName); unlink(self::TEMP_DIR . $fileName);
// Valeurs en sortie // Valeurs en sortie
@ -249,9 +252,10 @@ class config extends common {
/** /**
* Réalise une copie d'écran du site * Réalise une copie d'écran du site
*/ */
public function configMetaImage() { public function configMetaImage()
{
// fonction désactivée pour un site local // fonction désactivée pour un site local
if ( strpos(helper::baseUrl(false),'localhost') > 0 OR strpos(helper::baseUrl(false),'127.0.0.1') > 0) { if (strpos(helper::baseUrl(false), 'localhost') > 0 or strpos(helper::baseUrl(false), '127.0.0.1') > 0) {
$site = 'https://zwiicms.fr/'; $site = 'https://zwiicms.fr/';
} else { } else {
$site = helper::baseUrl(false); $site = helper::baseUrl(false);
@ -265,9 +269,9 @@ class config extends common {
$data = false; $data = false;
// lire l'API si le token est fourni // lire l'API si le token est fourni
if (!empty($token) ) { if (!empty($token)) {
// Tente de connecter 5 fois l'API // Tente de connecter 5 fois l'API
for ($i=0; $i < 5 ; $i++) { for ($i = 0; $i < 5; $i++) {
$data = helper::getUrlContents('https://shot.screenshotapi.net/screenshot?token=' . $token . '&url=' . $site . '&width=1200&height=627&output=json&file_type=jpeg&no_cookie_banners=true&wait_for_event=load'); $data = helper::getUrlContents('https://shot.screenshotapi.net/screenshot?token=' . $token . '&url=' . $site . '&width=1200&height=627&output=json&file_type=jpeg&no_cookie_banners=true&wait_for_event=load');
if ($data !== false) { if ($data !== false) {
break; break;
@ -278,41 +282,42 @@ class config extends common {
// Traitement des données reçues valides. // Traitement des données reçues valides.
if ( !empty($token) && $data !== false) { if (!empty($token) && $data !== false) {
$data = json_decode($data, true); $data = json_decode($data, true);
$img = $data['screenshot']; $img = $data['screenshot'];
// Effacer l'image et la miniature png // Effacer l'image et la miniature png
if (file_exists(self::FILE_DIR .'thumb/screenshot.jpg')) { if (file_exists(self::FILE_DIR . 'thumb/screenshot.jpg')) {
unlink (self::FILE_DIR .'thumb/screenshot.jpg'); unlink(self::FILE_DIR . 'thumb/screenshot.jpg');
} }
if (file_exists(self::FILE_DIR .'source/screenshot.jpg')) { if (file_exists(self::FILE_DIR . 'source/screenshot.jpg')) {
unlink (self::FILE_DIR .'source/screenshot.jpg'); unlink(self::FILE_DIR . 'source/screenshot.jpg');
} }
$success = copy ($img, self::FILE_DIR .'source/screenshot.jpg'); $success = copy($img, self::FILE_DIR . 'source/screenshot.jpg');
} }
$notification = empty($token) $notification = empty($token)
? 'La clé de l\'API ne peut pas être vide' ? 'La clé de l\'API ne peut pas être vide'
: ($success === false ? 'Problème avec le service en ligne' : 'Capture d\'écran générée avec succès'); : ($success === false ? 'Problème avec le service en ligne' : 'Capture d\'écran générée avec succès');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
'notification' => $notification, 'notification' => $notification,
'state' => ($success === false OR empty($token)) ? false : true 'state' => ($success === false or empty($token)) ? false : true
]); ]);
} }
/** /**
* Procédure d'importation * Procédure d'importation
*/ */
public function restore() { public function restore()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost() ) { if ($this->isPost()) {
$success = false; $success = false;
if ($this->getInput('configRestoreImportFile', null, true) ) { if ($this->getInput('configRestoreImportFile', null, true)) {
$fileZip = $this->getInput('configRestoreImportFile'); $fileZip = $this->getInput('configRestoreImportFile');
$file_parts = pathinfo($fileZip); $file_parts = pathinfo($fileZip);
@ -325,7 +330,7 @@ class config extends common {
'view' => 'restore', 'view' => 'restore',
'notification' => 'Le fichier n\'est pas une archive valide', 'notification' => 'Le fichier n\'est pas une archive valide',
'state' => false 'state' => false
]); ]);
} }
$successOpen = $zip->open(self::FILE_DIR . 'source/' . $fileZip); $successOpen = $zip->open(self::FILE_DIR . 'source/' . $fileZip);
if ($successOpen === FALSE) { if ($successOpen === FALSE) {
@ -335,23 +340,23 @@ class config extends common {
'view' => 'restore', 'view' => 'restore',
'notification' => 'Impossible de lire l\'archive', 'notification' => 'Impossible de lire l\'archive',
'state' => false 'state' => false
]); ]);
} }
// Lire le contenu de l'archive dans le tableau files // Lire le contenu de l'archive dans le tableau files
for( $i = 0; $i < $zip->numFiles; $i++ ){ for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex( $i ); $stat = $zip->statIndex($i);
$files [] = ( basename( $stat['name'] )); $files[] = (basename($stat['name']));
} }
// Lire la dataversion // Lire la dataversion
$tmpDir = uniqid(4); $tmpDir = uniqid(4);
$success = $zip->extractTo( self::TEMP_DIR . $tmpDir ); $success = $zip->extractTo(self::TEMP_DIR . $tmpDir);
$data = file_get_contents( self::TEMP_DIR . $tmpDir . '/data/core.json'); $data = file_get_contents(self::TEMP_DIR . $tmpDir . '/data/core.json');
$obj = json_decode($data); $obj = json_decode($data);
$dataVersion = strval ($obj->core->dataVersion); $dataVersion = strval($obj->core->dataVersion);
switch (strlen($dataVersion)) { switch (strlen($dataVersion)) {
case 4: case 4:
if (substr($dataVersion,0,1) === '9' ) { if (substr($dataVersion, 0, 1) === '9') {
// Valeurs en sortie erreur // Valeurs en sortie erreur
$this->addOutput([ $this->addOutput([
'title' => 'Restaurer', 'title' => 'Restaurer',
@ -364,49 +369,53 @@ class config extends common {
} }
break; break;
case 5: case 5:
$version = substr($dataVersion,0,2); $version = substr($dataVersion, 0, 2);
break; break;
default: default:
$version = 0; $version = 0;
break; break;
} }
$this->removeDir(self::TEMP_DIR . $tmpDir ); $this->removeDir(self::TEMP_DIR . $tmpDir);
if ($version >= 10 ) { if ($version >= 10) {
// Option active, les users sont stockées // Option active, les users sont stockées
if ($this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true ) { if ($this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true) {
$users = $this->getData(['user']); $users = $this->getData(['user']);
} }
} elseif ($version === 0) { // Version invalide } elseif ($version === 0) { // Version invalide
// Valeurs en sortie erreur // Valeurs en sortie erreur
$this->addOutput([ $this->addOutput([
'title' => 'Restaurer', 'title' => 'Restaurer',
'view' => 'restore', 'view' => 'restore',
'notification' => 'Cette archive n\'est pas une sauvegarde valide', 'notification' => 'Cette archive n\'est pas une sauvegarde valide',
'state' => false 'state' => false
]); ]);
} }
// Extraire le zip ou 'site/' // Extraire le zip ou 'site/'
$this->removeDir(self::DATA_DIR); $this->removeDir(self::DATA_DIR);
$success = $zip->extractTo( 'site/' ); $success = $zip->extractTo('site/');
// Fermer l'archive // Fermer l'archive
$zip->close(); $zip->close();
// Restaurer les users originaux d'une v10 si option cochée // Restaurer les users originaux d'une v10 si option cochée
if (!empty($users) && if (
!empty($users) &&
$version >= 10 && $version >= 10 &&
$this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true) { $this->getInput('configRestoreImportUser', helper::FILTER_BOOLEAN) === true
$this->setData(['user',$users]); ) {
$this->setData(['user', $users]);
} }
} }
// Conversion vers des Url relatives // Conversion vers des Url relatives
/*
if ($this->getData(['core', 'baseUrl'])) { if ($this->getData(['core', 'baseUrl'])) {
$url = str_replace('?','',$this->getData(['core', 'baseUrl'])); $url = str_replace('?', '', $this->getData(['core', 'baseUrl']));
// Suppresion de la base Url // Suppression de la base Url
$this->updateBaseUrl($url); $this->updateBaseUrl($url);
// Effacer la baseUrl // Effacer la baseUrl
$this->deleteData(['core', 'baseUrl']); $this->deleteData(['core', 'baseUrl']);
} }*/
// Message de notification // Message de notification
$notification = $success === true ? 'Restaurer effectuée avec succès' : 'Erreur inconnue'; $notification = $success === true ? 'Restaurer effectuée avec succès' : 'Erreur inconnue';
@ -432,15 +441,18 @@ class config extends common {
/** /**
* Configuration * Configuration
*/ */
public function index() { public function index()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Basculement en mise à jour auto, remise à 0 du compteur // Basculement en mise à jour auto, remise à 0 du compteur
if ($this->getData(['config','autoUpdate']) === false && if (
$this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN) === true) { $this->getData(['config', 'autoUpdate']) === false &&
$this->setData(['core','lastAutoUpdate',0]); $this->getInput('configAutoUpdate', helper::FILTER_BOOLEAN) === true
} ) {
$this->setData(['core', 'lastAutoUpdate', 0]);
}
// Sauvegarder la configuration // Sauvegarder la configuration
@ -457,7 +469,7 @@ class config extends common {
'cookieConsent' => $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN), 'cookieConsent' => $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN),
'proxyType' => $this->getInput('configProxyType'), 'proxyType' => $this->getInput('configProxyType'),
'proxyUrl' => $this->getInput('configProxyUrl'), 'proxyUrl' => $this->getInput('configProxyUrl'),
'proxyPort' => $this->getInput('configProxyPort',helper::FILTER_INT), 'proxyPort' => $this->getInput('configProxyPort', helper::FILTER_INT),
'social' => [ 'social' => [
'facebookId' => $this->getInput('socialFacebookId'), 'facebookId' => $this->getInput('socialFacebookId'),
'linkedinId' => $this->getInput('socialLinkedinId'), 'linkedinId' => $this->getInput('socialLinkedinId'),
@ -469,30 +481,30 @@ class config extends common {
'githubId' => $this->getInput('socialGithubId') 'githubId' => $this->getInput('socialGithubId')
], ],
'smtp' => [ 'smtp' => [
'enable' => $this->getInput('smtpEnable',helper::FILTER_BOOLEAN), 'enable' => $this->getInput('smtpEnable', helper::FILTER_BOOLEAN),
'host' => $this->getInput('smtpHost',helper::FILTER_STRING_SHORT,$this->getInput('smtpEnable',helper::FILTER_BOOLEAN)), 'host' => $this->getInput('smtpHost', helper::FILTER_STRING_SHORT, $this->getInput('smtpEnable', helper::FILTER_BOOLEAN)),
'port' => $this->getInput('smtpPort',helper::FILTER_INT,$this->getInput('smtpEnable',helper::FILTER_BOOLEAN)), 'port' => $this->getInput('smtpPort', helper::FILTER_INT, $this->getInput('smtpEnable', helper::FILTER_BOOLEAN)),
'auth' => $this->getInput('smtpAuth',helper::FILTER_BOOLEAN), 'auth' => $this->getInput('smtpAuth', helper::FILTER_BOOLEAN),
'secure' => $this->getInput('smtpSecure',helper::FILTER_BOOLEAN), 'secure' => $this->getInput('smtpSecure', helper::FILTER_BOOLEAN),
'username' => $this->getInput('smtpUsername',helper::FILTER_STRING_SHORT,$this->getInput('smtpAuth',helper::FILTER_BOOLEAN)), 'username' => $this->getInput('smtpUsername', helper::FILTER_STRING_SHORT, $this->getInput('smtpAuth', helper::FILTER_BOOLEAN)),
'password' =>helper::encrypt($this->getData(['config','smtp','username']),$this->getInput('smtpPassword',null,$this->getInput('smtpAuth',helper::FILTER_BOOLEAN))), 'password' => helper::encrypt($this->getData(['config', 'smtp', 'username']), $this->getInput('smtpPassword', null, $this->getInput('smtpAuth', helper::FILTER_BOOLEAN))),
'sender' => $this->getInput('smtpSender',helper::FILTER_MAIL) 'sender' => $this->getInput('smtpSender', helper::FILTER_MAIL)
], ],
'seo' => [ 'seo' => [
'robots' => $this->getInput('seoRobots',helper::FILTER_BOOLEAN), 'robots' => $this->getInput('seoRobots', helper::FILTER_BOOLEAN),
'keyApi' => $this->getInput('seoKeyApi',helper::FILTER_STRING_SHORT), 'keyApi' => $this->getInput('seoKeyApi', helper::FILTER_STRING_SHORT),
], ],
'connect' => [ 'connect' => [
'attempt' => $this->getInput('connectAttempt',helper::FILTER_INT), 'attempt' => $this->getInput('connectAttempt', helper::FILTER_INT),
'timeout' => $this->getInput('connectTimeout',helper::FILTER_INT), 'timeout' => $this->getInput('connectTimeout', helper::FILTER_INT),
'log' => $this->getInput('connectLog',helper::FILTER_BOOLEAN), 'log' => $this->getInput('connectLog', helper::FILTER_BOOLEAN),
'anonymousIp' => $this->getInput('connectAnonymousIp',helper::FILTER_INT), 'anonymousIp' => $this->getInput('connectAnonymousIp', helper::FILTER_INT),
'captcha' => $this->getInput('connectCaptcha',helper::FILTER_BOOLEAN), 'captcha' => $this->getInput('connectCaptcha', helper::FILTER_BOOLEAN),
'captchaStrong' => $this->getInput('connectCaptchaStrong',helper::FILTER_BOOLEAN), 'captchaStrong' => $this->getInput('connectCaptchaStrong', helper::FILTER_BOOLEAN),
'autoDisconnect' => $this->getInput('connectAutoDisconnect',helper::FILTER_BOOLEAN), 'autoDisconnect' => $this->getInput('connectAutoDisconnect', helper::FILTER_BOOLEAN),
'captchaType' => $this->getInput('connectCaptchaType'), 'captchaType' => $this->getInput('connectCaptchaType'),
'showPassword' => $this->getInput('connectShowPassword',helper::FILTER_BOOLEAN), 'showPassword' => $this->getInput('connectShowPassword', helper::FILTER_BOOLEAN),
'redirectLogin' => $this->getInput('connectRedirectLogin',helper::FILTER_BOOLEAN) 'redirectLogin' => $this->getInput('connectRedirectLogin', helper::FILTER_BOOLEAN)
] ]
] ]
]); ]);
@ -500,9 +512,8 @@ class config extends common {
// Efface les fichiers de backup lorsque l'option est désactivée // Efface les fichiers de backup lorsque l'option est désactivée
if ($this->getInput('configFileBackup', helper::FILTER_BOOLEAN) === false) { if ($this->getInput('configFileBackup', helper::FILTER_BOOLEAN) === false) {
$path = realpath('site/data'); $path = realpath('site/data');
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) {
{ if (strpos($filename, 'backup.json')) {
if (strpos($filename,'backup.json')) {
unlink($filename); unlink($filename);
} }
} }
@ -511,25 +522,25 @@ class config extends common {
touch('site/data/.backup'); touch('site/data/.backup');
} }
// Notice // Notice
if(self::$inputNotices === []) { if (self::$inputNotices === []) {
// Active la réécriture d'URL // Active la réécriture d'URL
$rewrite = $this->getInput('configRewrite', helper::FILTER_BOOLEAN); $rewrite = $this->getInput('configRewrite', helper::FILTER_BOOLEAN);
if( if (
$rewrite $rewrite
AND helper::checkRewrite() === false and helper::checkRewrite() === false
) { ) {
// Ajout des lignes dans le .htaccess // Ajout des lignes dans le .htaccess
$fileContent = file_get_contents('.htaccess'); $fileContent = file_get_contents('.htaccess');
$rewriteData = PHP_EOL . $rewriteData = PHP_EOL .
'# URL rewriting' . PHP_EOL . '# URL rewriting' . PHP_EOL .
'<IfModule mod_rewrite.c>' . PHP_EOL . '<IfModule mod_rewrite.c>' . PHP_EOL .
"\tRewriteEngine on" . PHP_EOL . "\tRewriteEngine on" . PHP_EOL .
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL . "\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL . "\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL . "\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL . "\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
'</IfModule>'. PHP_EOL . '</IfModule>' . PHP_EOL .
'# URL rewriting' . PHP_EOL ; '# URL rewriting' . PHP_EOL;
$fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent); $fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent);
file_put_contents( file_put_contents(
'.htaccess', '.htaccess',
@ -539,9 +550,9 @@ class config extends common {
helper::$rewriteStatus = true; helper::$rewriteStatus = true;
} }
// Désactive la réécriture d'URL // Désactive la réécriture d'URL
elseif( elseif (
$rewrite === false $rewrite === false
AND helper::checkRewrite() and helper::checkRewrite()
) { ) {
// Suppression des lignes dans le .htaccess // Suppression des lignes dans le .htaccess
$fileContent = file_get_contents('.htaccess'); $fileContent = file_get_contents('.htaccess');
@ -561,7 +572,7 @@ class config extends common {
$this->addOutput([ $this->addOutput([
'title' => 'Configuration du site', 'title' => 'Configuration du site',
'view' => 'index', 'view' => 'index',
'notification' => 'Modifications enregistrées ' , 'notification' => 'Modifications enregistrées ',
'state' => true 'state' => true
]); ]);
} }
@ -569,7 +580,7 @@ class config extends common {
// Variable de version // Variable de version
self::$onlineVersion = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/version'); self::$onlineVersion = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/version');
if (self::$onlineVersion > common::ZWII_VERSION) { if (self::$onlineVersion > common::ZWII_VERSION) {
self::$updateButtonText = "Mettre à jour" ; self::$updateButtonText = "Mettre à jour";
} }
// Valeurs en sortie // Valeurs en sortie
@ -580,19 +591,20 @@ class config extends common {
} }
public function script() { public function script()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Ecrire les fichiers de script // Ecrire les fichiers de script
if ($this->geturl(2) === 'head') { if ($this->geturl(2) === 'head') {
file_put_contents(self::DATA_DIR . 'head.inc.html',$this->getInput('configScriptHead',null)); file_put_contents(self::DATA_DIR . 'head.inc.html', $this->getInput('configScriptHead', null));
} }
if ($this->geturl(2) === 'body') { if ($this->geturl(2) === 'body') {
file_put_contents(self::DATA_DIR . 'body.inc.html',$this->getInput('configScriptBody',null)); file_put_contents(self::DATA_DIR . 'body.inc.html', $this->getInput('configScriptBody', null));
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Éditeur de script dans ' . ucfirst($this->geturl(2)) , 'title' => 'Éditeur de script dans ' . ucfirst($this->geturl(2)),
'vendor' => [ 'vendor' => [
'codemirror' 'codemirror'
], ],
@ -602,7 +614,7 @@ class config extends common {
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Éditeur de script dans ' . ucfirst($this->geturl(2)) , 'title' => 'Éditeur de script dans ' . ucfirst($this->geturl(2)),
'vendor' => [ 'vendor' => [
'codemirror' 'codemirror'
], ],
@ -615,14 +627,15 @@ class config extends common {
* Vider le fichier de log * Vider le fichier de log
*/ */
public function logReset() { public function logReset()
if ( file_exists(self::DATA_DIR . 'journal.log') ) { {
if (file_exists(self::DATA_DIR . 'journal.log')) {
unlink(self::DATA_DIR . 'journal.log'); unlink(self::DATA_DIR . 'journal.log');
// Créer les en-têtes des journaux // Créer les en-têtes des journaux
$d = 'Date;Heure;IP;Id;Action' . PHP_EOL; $d = 'Date;Heure;IP;Id;Action' . PHP_EOL;
file_put_contents(self::DATA_DIR . 'journal.log',$d); file_put_contents(self::DATA_DIR . 'journal.log', $d);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Configuration du site', 'title' => 'Configuration du site',
'view' => 'index', 'view' => 'index',
'notification' => 'Journal réinitialisé avec succès', 'notification' => 'Journal réinitialisé avec succès',
@ -637,15 +650,15 @@ class config extends common {
'state' => false 'state' => false
]); ]);
} }
}
}
/** /**
* Télécharger le fichier de log * Télécharger le fichier de log
*/ */
public function logDownload() { public function logDownload()
{
$fileName = self::DATA_DIR . 'journal.log'; $fileName = self::DATA_DIR . 'journal.log';
if (file_exists($fileName)) { if (file_exists($fileName)) {
ob_start(); ob_start();
@ -654,7 +667,7 @@ class config extends common {
header('Content-Length: ' . filesize($fileName)); header('Content-Length: ' . filesize($fileName));
ob_clean(); ob_clean();
ob_end_flush(); ob_end_flush();
readfile( $fileName); readfile($fileName);
exit(); exit();
} else { } else {
// Valeurs en sortie // Valeurs en sortie
@ -670,27 +683,28 @@ class config extends common {
/** /**
* Tableau des IP blacklistés * Tableau des IP blacklistés
*/ */
public function blacklistDownload () { public function blacklistDownload()
{
ob_start(); ob_start();
$fileName = self::TEMP_DIR . 'blacklist.log'; $fileName = self::TEMP_DIR . 'blacklist.log';
$d = 'Date dernière tentative;Heure dernière tentative;Id;Adresse IP;Nombre d\'échecs' . PHP_EOL; $d = 'Date dernière tentative;Heure dernière tentative;Id;Adresse IP;Nombre d\'échecs' . PHP_EOL;
file_put_contents($fileName,$d); file_put_contents($fileName, $d);
if ( file_exists($fileName) ) { if (file_exists($fileName)) {
$d = $this->getData(['blacklist']); $d = $this->getData(['blacklist']);
$data = ''; $data = '';
foreach ($d as $key => $item) { foreach ($d as $key => $item) {
$data .= mb_detect_encoding(strftime('%d/%m/%y',$item['lastFail']), 'UTF-8', true) $data .= mb_detect_encoding(strftime('%d/%m/%y', $item['lastFail']), 'UTF-8', true)
? strftime('%d/%m/%y',$item['lastFail']) . ';' . utf8_encode(strftime('%R',$item['lastFail'])) . ';' ? strftime('%d/%m/%y', $item['lastFail']) . ';' . utf8_encode(strftime('%R', $item['lastFail'])) . ';'
: utf8_encode(strftime('%d/%m/%y',$item['lastFail'])) . ';' . utf8_encode(strftime('%R',$item['lastFail'])) . ';' ; : utf8_encode(strftime('%d/%m/%y', $item['lastFail'])) . ';' . utf8_encode(strftime('%R', $item['lastFail'])) . ';';
$data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL; $data .= $key . ';' . $item['ip'] . ';' . $item['connectFail'] . PHP_EOL;
} }
file_put_contents($fileName,$data,FILE_APPEND); file_put_contents($fileName, $data, FILE_APPEND);
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Content-Disposition: attachment; filename="' . $fileName . '"');
header('Content-Length: ' . filesize($fileName)); header('Content-Length: ' . filesize($fileName));
ob_clean(); ob_clean();
ob_end_flush(); ob_end_flush();
readfile( $fileName); readfile($fileName);
unlink(self::TEMP_DIR . 'blacklist.log'); unlink(self::TEMP_DIR . 'blacklist.log');
exit(); exit();
} else { } else {
@ -708,11 +722,12 @@ class config extends common {
* Réinitialiser les ip blacklistées * Réinitialiser les ip blacklistées
*/ */
public function blacklistReset() { public function blacklistReset()
if ( file_exists(self::DATA_DIR . 'blacklist.json') ) { {
$this->setData(['blacklist',[]]); if (file_exists(self::DATA_DIR . 'blacklist.json')) {
$this->setData(['blacklist', []]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Configuration du site', 'title' => 'Configuration du site',
'view' => 'index', 'view' => 'index',
'notification' => 'Liste noire réinitialisée avec succès', 'notification' => 'Liste noire réinitialisée avec succès',
@ -732,9 +747,10 @@ class config extends common {
/** /**
* Récupération des backups auto dans le gestionnaire de fichiers * Récupération des backups auto dans le gestionnaire de fichiers
*/ */
public function copyBackups() { public function copyBackups()
{
$success = $this->copyDir(self::BACKUP_DIR, self::FILE_DIR . 'source/backup' ); $success = $this->copyDir(self::BACKUP_DIR, self::FILE_DIR . 'source/backup');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -748,15 +764,15 @@ class config extends common {
/** /**
* Vider le dosser des sauvegardes automatisées * Vider le dosser des sauvegardes automatisées
*/ */
public function delBackups() { public function delBackups()
{
$path = realpath(self::BACKUP_DIR); $path = realpath(self::BACKUP_DIR);
$success = $fail = 0; $success = $fail = 0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $filename) {
{ if (strpos($filename, '.zip')) {
if (strpos($filename,'.zip')) {
$r = unlink($filename); $r = unlink($filename);
$success = $r === true ? $succes + 1 : $success; $success = $r === true ? $success + 1 : $success;
$fail = $r === false ? $fail + 1 : $fail; $fail = $r === false ? $fail + 1 : $fail;
} }
} }
@ -768,7 +784,4 @@ class config extends common {
'state' => true 'state' => true
]); ]);
} }
} }

View File

@ -10,8 +10,8 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
$( document).ready(function() { $(document).ready(function () {
$("#configBackupForm").submit( function(e){ $("#configBackupForm").submit(function (e) {
//$("#configBackupSubmit").addClass("disabled").prop("disabled", true); //$("#configBackupSubmit").addClass("disabled").prop("disabled", true);
e.preventDefault(); e.preventDefault();
var url = "<?php echo helper::baseUrl() . $this->getUrl(0); ?>/backup"; var url = "<?php echo helper::baseUrl() . $this->getUrl(0); ?>/backup";
@ -22,15 +22,15 @@ $( document).ready(function() {
type: "POST", type: "POST",
url: url, url: url,
data: $("form").serialize(), data: $("form").serialize(),
success: function(data){ success: function (data) {
$('body, .button').css('cursor', 'default'); $('body, .button').css('cursor', 'default');
core.alert(message_success); core.alert(message_success);
}, },
error: function(data){ error: function (data) {
$('body, .button').css('cursor', 'default'); $('body, .button').css('cursor', 'default');
core.alert(message_error); core.alert(message_error);
}, },
complete: function(){ complete: function () {
$("#configBackupSubmit").removeClass("disabled").prop("disabled", false); $("#configBackupSubmit").removeClass("disabled").prop("disabled", false);
$("#configBackupSubmit").removeClass("uniqueSubmission").prop("uniqueSubmission", false); $("#configBackupSubmit").removeClass("uniqueSubmission").prop("uniqueSubmission", false);
$("#configBackupSubmit span").removeClass("zwiico-spin animate-spin"); $("#configBackupSubmit span").removeClass("zwiico-spin animate-spin");
@ -43,10 +43,10 @@ $( document).ready(function() {
/** /**
* Confirmation de sauvegarde complète * Confirmation de sauvegarde complète
*/ */
$("#configBackupSubmit").on("click", function() { $("#configBackupSubmit").on("click", function () {
if ($("input[name=configBackupOption]").is(':checked')) { if ($("input[name=configBackupOption]").is(':checked')) {
var message_warning = "<?php echo template::topic('La sauvegarde des fichiers peut prendre du temps. Continuer ?'); ?>"; var message_warning = "<?php echo template::topic('La sauvegarde des fichiers peut prendre du temps. Continuer ?'); ?>";
return core.confirm(message_warning, function() { return core.confirm(message_warning, function () {
//$(location).attr("href", _this.attr("href")); //$(location).attr("href", _this.attr("href"));
$('body, .button').css('cursor', 'wait'); $('body, .button').css('cursor', 'wait');
$('form#configBackupForm').submit(); $('form#configBackupForm').submit();

View File

@ -2,13 +2,13 @@
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('configBackupBack', [ <?php echo template::button('configBackupBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'config', 'href' => helper::baseUrl() . 'config',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col2 offset9"> <div class="col2 offset9">
<?php echo template::submit('configBackupSubmit',[ <?php echo template::submit('configBackupSubmit', [
'value' => 'Sauvegarder', 'value' => 'Sauvegarder',
'uniqueSubmission' => true 'uniqueSubmission' => true
]); ?> ]); ?>
@ -28,10 +28,10 @@
]); ?> ]); ?>
</div> </div>
<div class="col12"> <div class="col12">
<em>L'archive est générée dans <a href="<?php echo helper::baseUrl(false); ?>core/vendor/filemanager/dialog.php?fldr=backup&type=0&akey=<?php echo md5_file(self::DATA_DIR.'core.json'); ?>" data-lity>le dossier Backup</a> du gestionnaire de fichiers.</em> <em>L'archive est générée dans <a href="<?php echo helper::baseUrl(false); ?>core/vendor/filemanager/dialog.php?fldr=backup&type=0&akey=<?php echo md5_file(self::DATA_DIR . 'core.json'); ?>" data-lity>le dossier Backup</a> du gestionnaire de fichiers.</em>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -2,10 +2,10 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4><?php echo template::topic('Sécurité de la connexion');?> <h4><?php echo template::topic('Sécurité de la connexion'); ?>
<span id="specialeHelpButton" class="helpDisplayButton"> <span id="specialeHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/connexion" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/connexion" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
@ -32,13 +32,13 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::select('connectAttempt', $module::$connectAttempt , [ <?php echo template::select('connectAttempt', $module::$connectAttempt, [
'label' => 'Limitation des tentatives', 'label' => 'Limitation des tentatives',
'selected' => $this->getData(['config', 'connect', 'attempt']) 'selected' => $this->getData(['config', 'connect', 'attempt'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('connectTimeout', $module::$connectTimeout , [ <?php echo template::select('connectTimeout', $module::$connectTimeout, [
'label' => 'Blocage après échecs', 'label' => 'Blocage après échecs',
'selected' => $this->getData(['config', 'connect', 'timeout']) 'selected' => $this->getData(['config', 'connect', 'timeout'])
]); ?> ]); ?>
@ -46,8 +46,9 @@
<div class="col3 verticalAlignBottom"> <div class="col3 verticalAlignBottom">
<label id="helpBlacklist">Liste noire : <label id="helpBlacklist">Liste noire :
<?php echo template::help( <?php echo template::help(
'La liste noire énumère les tentatives de connexion à partir de comptes inexistants. Sont stockés : la date, l\'heure, le nom du compte et l\'IP. 'La liste noire énumère les tentatives de connexion à partir de comptes inexistants. Sont stockés : la date, l\'heure, le nom du compte et l\'IP.
Après le nombre de tentatives autorisées, l\'IP et le compte sont bloqués.'); Après le nombre de tentatives autorisées, l\'IP et le compte sont bloqués.'
);
?> ?>
</label> </label>
<?php echo template::button('ConnectBlackListDownload', [ <?php echo template::button('ConnectBlackListDownload', [
@ -67,21 +68,21 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::checkbox('connectCaptcha', true, 'Captcha à la connexion', [ <?php echo template::checkbox('connectCaptcha', true, 'Captcha à la connexion', [
'checked' => $this->getData(['config', 'connect','captcha']) 'checked' => $this->getData(['config', 'connect', 'captcha'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::checkbox('connectCaptchaStrong', true, 'Captcha complexe', [ <?php echo template::checkbox('connectCaptchaStrong', true, 'Captcha complexe', [
'checked' => $this->getData(['config', 'connect', 'captchaStrong']), 'checked' => $this->getData(['config', 'connect', 'captchaStrong']),
'help' => 'Option recommandée pour sécuriser la connexion. S\'applique à tous les captchas du site. Le captcha simple se limite à une addition de nombres de 0 à 10. Le captcha complexe utilise quatre opérations de nombres de 0 à 20. Activation recommandée.' 'help' => 'Option recommandée pour sécuriser la connexion. S\'applique à tous les captchas du site. Le captcha simple se limite à une addition de nombres de 0 à 10. Le captcha complexe utilise quatre opérations de nombres de 0 à 20. Activation recommandée.'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('connectCaptchaType', $module::$captchaTypes , [ <?php echo template::select('connectCaptchaType', $module::$captchaTypes, [
'label' => 'Type de captcha', 'label' => 'Type de captcha',
'selected' => $this->getData(['config', 'connect', 'captchaType']) 'selected' => $this->getData(['config', 'connect', 'captchaType'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -90,10 +91,10 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4><?php echo template::topic('Journalisation');?> <h4><?php echo template::topic('Journalisation'); ?>
<span id="specialeHelpButton" class="helpDisplayButton"> <span id="specialeHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/journalisation" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/journalisation" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
@ -108,7 +109,7 @@
'label' => 'Anonymat des adresses IP', 'label' => 'Anonymat des adresses IP',
'selected' => $this->getData(['config', 'connect', 'anonymousIp']), 'selected' => $this->getData(['config', 'connect', 'anonymousIp']),
'help' => 'La règlementation française impose un anonymat de niveau 2' 'help' => 'La règlementation française impose un anonymat de niveau 2'
]); ?> ]); ?>
</div> </div>
<div class="col3 verticalAlignBottom"> <div class="col3 verticalAlignBottom">
<?php echo template::button('ConfigLogDownload', [ <?php echo template::button('ConfigLogDownload', [

View File

@ -34,7 +34,7 @@
text-align: center; text-align: center;
} }
.tab ~ .tabContent { .tab~.tabContent {
margin-top: -10px; margin-top: -10px;
} }
@ -52,4 +52,4 @@
.activeButton { .activeButton {
background-color: #00BFFF; background-color: #00BFFF;
} }

View File

@ -1,24 +1,24 @@
<?php echo template::formOpen('configForm');?> <?php echo template::formOpen('configForm'); ?>
<div class="row"> <div class="row">
<div class="col1">
<?php echo template::button('configBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl(false),
'value' => template::ico('home')
]); ?>
</div>
<div class="col1"> <div class="col1">
<?php /**echo template::button('configHelp', [ <?php echo template::button('configBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl(false),
'value' => template::ico('home')
]); ?>
</div>
<div class="col1">
<?php /**echo template::button('configHelp', [
'class' => 'buttonHelp', 'class' => 'buttonHelp',
'href' => 'https://doc.zwiicms.fr/configuration-du-site', 'href' => 'https://doc.zwiicms.fr/configuration-du-site',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'help' => 'Consulter l\'aide en ligne' 'help' => 'Consulter l\'aide en ligne'
]); */?> ]); */ ?>
</div> </div>
<div class="col2 offset8"> <div class="col2 offset8">
<?php echo template::submit('Submit'); ?> <?php echo template::submit('Submit'); ?>
</div> </div>
</div> </div>
<div class="tab"> <div class="tab">
@ -42,8 +42,8 @@
]); ?> ]); ?>
</div> </div>
<?php include ('core/module/config/view/setup/setup.php') ?> <?php include('core/module/config/view/setup/setup.php') ?>
<?php include ('core/module/config/view/social/social.php') ?> <?php include('core/module/config/view/social/social.php') ?>
<?php include ('core/module/config/view/connect/connect.php') ?> <?php include('core/module/config/view/connect/connect.php') ?>
<?php include ('core/module/config/view/network/network.php') ?> <?php include('core/module/config/view/network/network.php') ?>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -2,10 +2,10 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4><?php echo template::topic('Paramètres');?> <h4><?php echo template::topic('Paramètres'); ?>
<span id="specialeHelpButton" class="helpDisplayButton"> <span id="specialeHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/reseau" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/reseau" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
@ -14,16 +14,16 @@
<?php echo template::select('configProxyType', $module::$proxyType, [ <?php echo template::select('configProxyType', $module::$proxyType, [
'label' => 'Type de proxy', 'label' => 'Type de proxy',
'selected' => $this->getData(['config', 'proxyType']) 'selected' => $this->getData(['config', 'proxyType'])
]); ?> ]); ?>
</div> </div>
<div class="col8"> <div class="col8">
<?php echo template::text('configProxyUrl', [ <?php echo template::text('configProxyUrl', [
'label' => 'Adresse du proxy', 'label' => 'Adresse du proxy',
'placeholder' => 'cache.proxy.fr', 'placeholder' => 'cache.proxy.fr',
'value' => $this->getData(['config', 'proxyUrl']) 'value' => $this->getData(['config', 'proxyUrl'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::text('configProxyPort', [ <?php echo template::text('configProxyPort', [
'label' => 'Port du proxy', 'label' => 'Port du proxy',
'placeholder' => '6060', 'placeholder' => '6060',
@ -37,19 +37,19 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4><?php echo template::topic('SMTP');?> <h4><?php echo template::topic('SMTP'); ?>
<span id="specialeHelpButton" class="helpDisplayButton"> <span id="specialeHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/smtp" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/smtp" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::checkbox('smtpEnable', true, 'Activer SMTP', [ <?php echo template::checkbox('smtpEnable', true, 'Activer SMTP', [
'checked' => $this->getData(['config', 'smtp','enable']), 'checked' => $this->getData(['config', 'smtp', 'enable']),
'help' => 'Paramètres à utiliser lorsque votre hébergeur ne propose pas la fonctionnalité d\'envoi de mail.' 'help' => 'Paramètres à utiliser lorsque votre hébergeur ne propose pas la fonctionnalité d\'envoi de mail.'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div id="smtpParam"> <div id="smtpParam">
@ -58,42 +58,42 @@
<?php echo template::text('smtpHost', [ <?php echo template::text('smtpHost', [
'label' => 'Adresse SMTP', 'label' => 'Adresse SMTP',
'placeholder' => 'smtp.fr', 'placeholder' => 'smtp.fr',
'value' => $this->getData(['config', 'smtp','host']) 'value' => $this->getData(['config', 'smtp', 'host'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::text('smtpPort', [ <?php echo template::text('smtpPort', [
'label' => 'Port SMTP', 'label' => 'Port SMTP',
'placeholder' => '589', 'placeholder' => '589',
'value' => $this->getData(['config', 'smtp','port']) 'value' => $this->getData(['config', 'smtp', 'port'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::select('smtpAuth', $module::$SMTPauth, [ <?php echo template::select('smtpAuth', $module::$SMTPauth, [
'label' => 'Authentification', 'label' => 'Authentification',
'selected' => $this->getData(['config', 'smtp','auth']) 'selected' => $this->getData(['config', 'smtp', 'auth'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div id="smtpAuthParam"> <div id="smtpAuthParam">
<div class="row"> <div class="row">
<div class="col5"> <div class="col5">
<?php echo template::text('smtpUsername', [ <?php echo template::text('smtpUsername', [
'label' => 'Nom utilisateur', 'label' => 'Nom utilisateur',
'value' => $this->getData(['config', 'smtp','username' ]) 'value' => $this->getData(['config', 'smtp', 'username'])
]); ?> ]); ?>
</div> </div>
<div class="col5"> <div class="col5">
<?php echo template::password('smtpPassword', [ <?php echo template::password('smtpPassword', [
'label' => 'Mot de passe', 'label' => 'Mot de passe',
'autocomplete' => 'off', 'autocomplete' => 'off',
'value' => $this->getData(['config', 'smtp','username' ]) ? helper::decrypt ($this->getData(['config', 'smtp','username' ]),$this->getData(['config','smtp','password'])) : '' 'value' => $this->getData(['config', 'smtp', 'username']) ? helper::decrypt($this->getData(['config', 'smtp', 'username']), $this->getData(['config', 'smtp', 'password'])) : ''
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::select('smtpSecure', $module::$SMTPEnc , [ <?php echo template::select('smtpSecure', $module::$SMTPEnc, [
'label' => 'Sécurité', 'label' => 'Sécurité',
'selected' => $this->getData(['config', 'smtp','secure']) 'selected' => $this->getData(['config', 'smtp', 'secure'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -102,4 +102,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -9,7 +9,7 @@
]); ?> ]); ?>
</div> </div>
<div class="col2 offset8"> <div class="col2 offset8">
<?php echo template::submit('configRestoreSubmit',[ <?php echo template::submit('configRestoreSubmit', [
'value' => 'Restaurer', 'value' => 'Restaurer',
'uniqueSubmission' => true, 'uniqueSubmission' => true,
]); ?> ]); ?>
@ -19,7 +19,7 @@
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Archive à restaurer');?> <?php echo template::topic('Archive à restaurer'); ?>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col10 offset1"> <div class="col10 offset1">
@ -40,4 +40,4 @@
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,38 +1,38 @@
<?php echo template::formOpen('configScript'); ?> <?php echo template::formOpen('configScript'); ?>
<div class="row"> <div class="row">
<div class="col2"> <div class="col2">
<?php echo template::button('configManageBack', [ <?php echo template::button('configManageBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'config', 'href' => helper::baseUrl() . 'config',
'ico' => 'left', 'ico' => 'left',
'value' => 'Retour' 'value' => 'Retour'
]); ?> ]); ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('configManageSubmit',[
'value' => 'Valider',
'ico' => 'check'
]); ?>
</div>
</div> </div>
<?php if ($this->geturl(2) === 'head'): ?> <div class="col2 offset8">
<?php echo template::submit('configManageSubmit', [
'value' => 'Valider',
'ico' => 'check'
]); ?>
</div>
</div>
<?php if ($this->geturl(2) === 'head') : ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::textarea('configScriptHead', [ <?php echo template::textarea('configScriptHead', [
'value' => file_exists( self::DATA_DIR . 'head.inc.html') ? file_get_contents (self::DATA_DIR . 'head.inc.html') : '' , 'value' => file_exists(self::DATA_DIR . 'head.inc.html') ? file_get_contents(self::DATA_DIR . 'head.inc.html') : '',
'class' => 'editor' 'class' => 'editor'
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php endif ?> <?php endif ?>
<?php if ($this->geturl(2) === 'body'): ?> <?php if ($this->geturl(2) === 'body') : ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::textarea('configScriptBody', [ <?php echo template::textarea('configScriptBody', [
'value' => file_exists( self::DATA_DIR . 'body.inc.html') ? file_get_contents (self::DATA_DIR . 'body.inc.html') : '' , 'value' => file_exists(self::DATA_DIR . 'body.inc.html') ? file_get_contents(self::DATA_DIR . 'body.inc.html') : '',
'class' => 'editor' 'class' => 'editor'
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php endif ?> <?php endif ?>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -2,10 +2,10 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4><?php echo template::topic('Paramétres');?> <h4><?php echo template::topic('Paramétres'); ?>
<span id="setupHelpButton" class="helpDisplayButton"> <span id="setupHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/parametres" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/parametres" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
@ -36,10 +36,10 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('configCookieConsent', true, 'Message de consentement aux cookies', [ <?php echo template::checkbox('configCookieConsent', true, 'Message de consentement aux cookies', [
'checked' => $this->getData(['config', 'cookieConsent']), 'checked' => $this->getData(['config', 'cookieConsent']),
'help' => 'Activation obligatoire selon les lois françaises sauf si vous utilisez votre propre système de consentement.' 'help' => 'Activation obligatoire selon les lois françaises sauf si vous utilisez votre propre système de consentement.'
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::checkbox('configRewrite', true, 'Apache URL intelligentes', [ <?php echo template::checkbox('configRewrite', true, 'Apache URL intelligentes', [
@ -56,33 +56,33 @@
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Mise à jour automatisée');?> <?php echo template::topic('Mise à jour automatisée'); ?>
<span id="updateHelpButton" class="helpDisplayButton"> <span id="updateHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/mise-a-jour" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/mise-a-jour" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('configAutoUpdate', true, 'Rechercher une mise à jour en ligne', [ <?php echo template::checkbox('configAutoUpdate', true, 'Rechercher une mise à jour en ligne', [
'checked' => $this->getData(['config', 'autoUpdate']), 'checked' => $this->getData(['config', 'autoUpdate']),
'help' => 'La vérification est quotidienne. Option désactivée si la configuration du serveur ne le permet pas.', 'help' => 'La vérification est quotidienne. Option désactivée si la configuration du serveur ne le permet pas.',
'disabled' => !$module::$onlineVersion 'disabled' => !$module::$onlineVersion
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::checkbox('configAutoUpdateHtaccess', true, 'Préserver le fichier htaccess racine', [ <?php echo template::checkbox('configAutoUpdateHtaccess', true, 'Préserver le fichier htaccess racine', [
'checked' => $this->getData(['config', 'autoUpdateHtaccess']), 'checked' => $this->getData(['config', 'autoUpdateHtaccess']),
'help' => 'Lors d\'une mise à jour automatique, conserve le fichier htaccess de la racine du site.', 'help' => 'Lors d\'une mise à jour automatique, conserve le fichier htaccess de la racine du site.',
'disabled' => !$module::$onlineVersion 'disabled' => !$module::$onlineVersion
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo '<pre>Version installée : <strong>' . common::ZWII_VERSION . '</strong></pre>' ; ?> <?php echo '<pre>Version installée : <strong>' . common::ZWII_VERSION . '</strong></pre>'; ?>
<?php echo $module::$onlineVersion ? '<pre>Version en ligne : <strong>' . $module::$onlineVersion . '</strong></pre>' : '' ;?> <?php echo $module::$onlineVersion ? '<pre>Version en ligne : <strong>' . $module::$onlineVersion . '</strong></pre>' : ''; ?>
</div> </div>
<div class="col4 verticalAlignBottom"> <div class="col4 verticalAlignBottom">
<?php echo template::button('configUpdateForced', [ <?php echo template::button('configUpdateForced', [
@ -102,17 +102,17 @@
<div class="block"> <div class="block">
<h4>Maintenance <h4>Maintenance
<span id="maintenanceHelpButton" class="helpDisplayButton"> <span id="maintenanceHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/mode-maintenance" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/mode-maintenance" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('configAutoBackup', true, 'Sauvegarde automatique quotidienne du site', [ <?php echo template::checkbox('configAutoBackup', true, 'Sauvegarde automatique quotidienne du site', [
'checked' => $this->getData(['config', 'autoBackup']), 'checked' => $this->getData(['config', 'autoBackup']),
'help' => 'Une archive contenant le dossier /site/data est copiée dans le dossier \'site/backup\'. La sauvegarde est conservée pendant 30 jours.</p><p>Les fichiers du site ne sont pas sauvegardés automatiquement. Activation recommandée.' 'help' => 'Une archive contenant le dossier /site/data est copiée dans le dossier \'site/backup\'. La sauvegarde est conservée pendant 30 jours.</p><p>Les fichiers du site ne sont pas sauvegardés automatiquement. Activation recommandée.'
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::checkbox('configMaintenance', true, 'Site en maintenance', [ <?php echo template::checkbox('configMaintenance', true, 'Site en maintenance', [
@ -161,8 +161,8 @@
<div class="block"> <div class="block">
<h4>Scripts externes <h4>Scripts externes
<span id="specialeHelpButton" class="helpDisplayButton"> <span id="specialeHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/scripts-externes" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/scripts-externes" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
@ -179,10 +179,10 @@
'href' => helper::baseUrl() . 'config/script/body', 'href' => helper::baseUrl() . 'config/script/body',
'value' => 'Script dans body', 'value' => 'Script dans body',
'ico' => 'pencil' 'ico' => 'pencil'
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,10 +3,10 @@
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Capture d\'écran Open Graph');?> <?php echo template::topic('Capture d\'écran Open Graph'); ?>
<span id="specialeHelpButton" class="helpDisplayButton"> <span id="specialeHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/referencement" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/referencement" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
@ -24,20 +24,20 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::button('socialMetaImage', [ <?php echo template::button('socialMetaImage', [
'href' => helper::baseUrl() . 'config/configMetaImage', 'href' => helper::baseUrl() . 'config/configMetaImage',
'value' => 'Générer une capture Open Graph' 'value' => 'Générer une capture Open Graph'
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
<div class="col6 offset1"> <div class="col6 offset1">
<?php if (file_exists(self::FILE_DIR.'source/screenshot.jpg')): ?> <?php if (file_exists(self::FILE_DIR . 'source/screenshot.jpg')) : ?>
<div class="row"> <div class="row">
<div class="col8 offset2 textAlignCenter"> <div class="col8 offset2 textAlignCenter">
<img src="<?php echo helper::baseUrl(false) . self::FILE_DIR.'source/screenshot.jpg';?>" data-tippy-content="Cette capture d'écran est nécessaire aux partages sur les réseaux sociaux. Elle est régénérée lorsque le fichier 'screenshot.jpg' est effacé du gestionnaire de fichiers." /> <img src="<?php echo helper::baseUrl(false) . self::FILE_DIR . 'source/screenshot.jpg'; ?>" data-tippy-content="Cette capture d'écran est nécessaire aux partages sur les réseaux sociaux. Elle est régénérée lorsque le fichier 'screenshot.jpg' est effacé du gestionnaire de fichiers." />
</div> </div>
</div> </div>
<?php endif;?> <?php endif; ?>
</div> </div>
</div> </div>
</div> </div>
@ -47,7 +47,7 @@
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Référencement');?> <?php echo template::topic('Référencement'); ?>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col4 offset1"> <div class="col4 offset1">
@ -58,7 +58,7 @@
</div> </div>
<div class="col4 offset1"> <div class="col4 offset1">
<?php echo template::checkbox('seoRobots', true, 'Autoriser les robots à référencer le site', [ <?php echo template::checkbox('seoRobots', true, 'Autoriser les robots à référencer le site', [
'checked' => $this->getData(['config', 'seo','robots']) 'checked' => $this->getData(['config', 'seo', 'robots'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -69,10 +69,10 @@
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Réseaux sociaux');?> <?php echo template::topic('Réseaux sociaux'); ?>
<span id="specialeHelpButton" class="helpDisplayButton"> <span id="specialeHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/reseaux-sociaux" target="_blank" title="Cliquer pour consulter l'aide en ligne"> <a href="https://doc.zwiicms.fr/reseaux-sociaux" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
@ -108,9 +108,9 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::text('socialTwitterId', [ <?php echo template::text('socialTwitterId', [
'help' => 'Saisissez votre ID : https://twitter.com/[ID].', 'help' => 'Saisissez votre ID : https://twitter.com/[ID].',
'label' => 'Twitter', 'label' => 'Twitter',
'value' => $this->getData(['config', 'social', 'twitterId']) 'value' => $this->getData(['config', 'social', 'twitterId'])
]); ?> ]); ?>
</div> </div>
@ -129,14 +129,14 @@
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::text('socialGithubId', [ <?php echo template::text('socialGithubId', [
'help' => 'Saisissez votre ID Github : https://github.com/[ID].', 'help' => 'Saisissez votre ID Github : https://github.com/[ID].',
'label' => 'Github', 'label' => 'Github',
'value' => $this->getData(['config', 'social', 'githubId']) 'value' => $this->getData(['config', 'social', 'githubId'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -14,7 +14,8 @@
*/ */
class install extends common { class install extends common
{
public static $actions = [ public static $actions = [
'index' => self::GROUP_VISITOR, 'index' => self::GROUP_VISITOR,
@ -41,9 +42,10 @@ class install extends common {
/** /**
* Pré-installation - choix de la langue * Pré-installation - choix de la langue
*/ */
public function index() { public function index()
{
// Accès refusé // Accès refusé
if($this->getData(['user']) !== []) { if ($this->getData(['user']) !== []) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
@ -52,7 +54,7 @@ class install extends common {
// Accès autorisé // Accès autorisé
else { else {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
self::$i18nUI = $this->getInput('installLanguage'); self::$i18nUI = $this->getInput('installLanguage');
$this->setData(['config', 'i18n', 'interface', self::$i18nUI]); $this->setData(['config', 'i18n', 'interface', self::$i18nUI]);
// Valeurs en sortie // Valeurs en sortie
@ -68,7 +70,7 @@ class install extends common {
chdir(self::I18N_DIR); chdir(self::I18N_DIR);
$files = glob('*.json'); $files = glob('*.json');
// Ajouter une clé au tableau avec le code de langue // Ajouter une clé au tableau avec le code de langue
foreach( $files as $file) { foreach ($files as $file) {
// La langue est-elle référencée ? // La langue est-elle référencée ?
if (array_key_exists(basename($file, '.json'), self::$languages)) { if (array_key_exists(basename($file, '.json'), self::$languages)) {
self::$i18nFiles[basename($file, '.json')] = self::$languages[basename($file, '.json')]; self::$i18nFiles[basename($file, '.json')] = self::$languages[basename($file, '.json')];
@ -87,9 +89,10 @@ class install extends common {
/** /**
* post Installation * post Installation
*/ */
public function postInstall() { public function postInstall()
{
// Accès refusé // Accès refusé
if($this->getData(['user']) !== []) { if ($this->getData(['user']) !== []) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
@ -98,10 +101,10 @@ class install extends common {
// Accès autorisé // Accès autorisé
else { else {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
$success = true; $success = true;
// Double vérification pour le mot de passe // Double vérification pour le mot de passe
if($this->getInput('installPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('installConfirmPassword', helper::FILTER_STRING_SHORT, true)) { if ($this->getInput('installPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('installConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
self::$inputNotices['installConfirmPassword'] = 'Incorrect'; self::$inputNotices['installConfirmPassword'] = 'Incorrect';
$success = false; $success = false;
} }
@ -132,92 +135,93 @@ class install extends common {
// Compte créé, envoi du mail et création des données du site // Compte créé, envoi du mail et création des données du site
if ($success) { // Formulaire complété envoi du mail if ($success) { // Formulaire complété envoi du mail
// Envoie le mail // Envoie le mail
// Sent contient true si réussite sinon code erreur d'envoi en clair // Sent contient true si réussite sinon code erreur d'envoi en clair
$sent = $this->sendMail( $sent = $this->sendMail(
$userMail, $userMail,
'Installation de votre site', 'Installation de votre site',
'Bonjour' . ' <strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' . 'Bonjour' . ' <strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' .
'Voici les détails de votre installation.<br><br>' . 'Voici les détails de votre installation.<br><br>' .
'<strong>URL du site :</strong> <a href="' . helper::baseUrl(false) . '" target="_blank">' . helper::baseUrl(false) . '</a><br>' . '<strong>URL du site :</strong> <a href="' . helper::baseUrl(false) . '" target="_blank">' . helper::baseUrl(false) . '</a><br>' .
'<strong>Identifiant du compte :</strong> ' . $this->getInput('installId') . '<br>', '<strong>Identifiant du compte :</strong> ' . $this->getInput('installId') . '<br>',
null null
); );
// Nettoyer les cookies de langue d'une précédente installation // Nettoyer les cookies de langue d'une précédente installation
helper::deleteCookie('ZWII_I18N_SITE'); helper::deleteCookie('ZWII_I18N_SITE');
// Créer le contenu dans la langue sélectionnée // Créer le contenu dans la langue sélectionnée
self::$i18nContent = substr(self::$i18nUI, 0, 2); self::$i18nContent = substr(self::$i18nUI, 0, 2);
// Effacer le dossier de contenu fr créé par défaut si la langue est différente. // Effacer le dossier de contenu fr créé par défaut si la langue est différente.
if (self::$i18nContent !== 'fr_FR' if (
&& is_dir('site/data/fr') self::$i18nContent !== 'fr_FR'
) { && is_dir('site/data/fr')
$this->removeDir('site/data/fr'); ) {
} $this->removeDir('site/data/fr');
// Installation du site de test
if ($this->getInput('installDefaultData',helper::FILTER_BOOLEAN) === FALSE) {
$this->initData('page', self::$i18nContent, true);
$this->initData('module',self::$i18nContent, true);
$this->setData(['module', 'blog', 'posts', 'mon-premier-article', 'userId', $userId]);
$this->setData(['module', 'blog', 'posts', 'mon-deuxieme-article', 'userId', $userId]);
$this->setData(['module', 'blog', 'posts', 'mon-troisieme-article', 'userId', $userId]);
}
// Sauvegarder la configuration du Proxy
$this->setData(['config', 'proxyType', $this->getInput('installProxyType') ]);
$this->setData(['config', 'proxyUrl', $this->getInput('installProxyUrl') ]);
$this->setData(['config', 'proxyPort', $this->getInput('installProxyPort', helper::FILTER_INT)]);
// Images exemples livrées dans tous les cas
try {
// Décompression dans le dossier de fichier temporaires
if (file_exists(self::TEMP_DIR . 'files.tar.gz')) {
unlink(self::TEMP_DIR . 'files.tar.gz');
} }
if (file_exists(self::TEMP_DIR . 'files.tar')) {
unlink(self::TEMP_DIR . 'files.tar');
}
copy('core/module/install/ressource/files.tar.gz', self::TEMP_DIR . 'files.tar.gz');
$pharData = new PharData(self::TEMP_DIR . 'files.tar.gz');
$pharData->decompress();
// Installation
$pharData->extractTo(__DIR__ . '/../../../', null, true);
} catch (Exception $e) {
$success = $e->getMessage();
}
unlink(self::TEMP_DIR . 'files.tar.gz');
unlink(self::TEMP_DIR . 'files.tar');
// Créer le dossier des fontes
if (!is_dir(self::DATA_DIR . 'fonts')) {
mkdir(self::DATA_DIR . 'fonts');
}
// Installation du thème sélectionné // Installation du site de test
$dataThemes = file_get_contents('core/module/install/ressource/themes/themes.json'); if ($this->getInput('installDefaultData', helper::FILTER_BOOLEAN) === FALSE) {
$dataThemes = json_decode($dataThemes, true); $this->initData('page', self::$i18nContent, true);
$themeId = $dataThemes [$this->getInput('installTheme', helper::FILTER_STRING_SHORT)]['filename']; $this->initData('module', self::$i18nContent, true);
if ($themeId !== 'default' ) { $this->setData(['module', 'blog', 'posts', 'mon-premier-article', 'userId', $userId]);
$this->setData(['module', 'blog', 'posts', 'mon-deuxieme-article', 'userId', $userId]);
$this->setData(['module', 'blog', 'posts', 'mon-troisieme-article', 'userId', $userId]);
}
// Sauvegarder la configuration du Proxy
$this->setData(['config', 'proxyType', $this->getInput('installProxyType')]);
$this->setData(['config', 'proxyUrl', $this->getInput('installProxyUrl')]);
$this->setData(['config', 'proxyPort', $this->getInput('installProxyPort', helper::FILTER_INT)]);
// Images exemples livrées dans tous les cas
try {
// Décompression dans le dossier de fichier temporaires
if (file_exists(self::TEMP_DIR . 'files.tar.gz')) {
unlink(self::TEMP_DIR . 'files.tar.gz');
}
if (file_exists(self::TEMP_DIR . 'files.tar')) {
unlink(self::TEMP_DIR . 'files.tar');
}
copy('core/module/install/ressource/files.tar.gz', self::TEMP_DIR . 'files.tar.gz');
$pharData = new PharData(self::TEMP_DIR . 'files.tar.gz');
$pharData->decompress();
// Installation
$pharData->extractTo(__DIR__ . '/../../../', null, true);
} catch (Exception $e) {
$success = $e->getMessage();
}
unlink(self::TEMP_DIR . 'files.tar.gz');
unlink(self::TEMP_DIR . 'files.tar');
// Créer le dossier des fontes
if (!is_dir(self::DATA_DIR . 'fonts')) {
mkdir(self::DATA_DIR . 'fonts');
}
// Installation du thème sélectionné
$dataThemes = file_get_contents('core/module/install/ressource/themes/themes.json');
$dataThemes = json_decode($dataThemes, true);
$themeId = $dataThemes[$this->getInput('installTheme', helper::FILTER_STRING_SHORT)]['filename'];
if ($themeId !== 'default') {
$theme = new theme; $theme = new theme;
$theme->import('core/module/install/ressource/themes/' . $themeId); $theme->import('core/module/install/ressource/themes/' . $themeId);
} }
// Copie des thèmes dans les fichiers // Copie des thèmes dans les fichiers
if (!is_dir(self::FILE_DIR . 'source/theme' )) { if (!is_dir(self::FILE_DIR . 'source/theme')) {
mkdir(self::FILE_DIR . 'source/theme'); mkdir(self::FILE_DIR . 'source/theme');
} }
$this->copyDir('core/module/install/ressource/themes', self::FILE_DIR . 'source/theme'); $this->copyDir('core/module/install/ressource/themes', self::FILE_DIR . 'source/theme');
unlink(self::FILE_DIR . 'source/theme/themes.json'); unlink(self::FILE_DIR . 'source/theme/themes.json');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl(false), 'redirect' => helper::baseUrl(false),
'notification' => $sent === true ? 'Installation terminée' : $sent, 'notification' => $sent === true ? 'Installation terminée' : $sent,
'state' => ($sent === true && $success === true) ? true : null 'state' => ($sent === true && $success === true) ? true : null
]); ]);
} }
} }
@ -245,25 +249,26 @@ class install extends common {
/** /**
* Étapes de mise à jour * Étapes de mise à jour
*/ */
public function steps() { public function steps()
switch($this->getInput('step', helper::FILTER_INT)) { {
// Préparation switch ($this->getInput('step', helper::FILTER_INT)) {
// Préparation
case 1: case 1:
$success = true; $success = true;
// RAZ la mise à jour auto // RAZ la mise à jour auto
$this->setData(['core','updateAvailable', false]); $this->setData(['core', 'updateAvailable', false]);
// Backup du dossier Data // Backup du dossier Data
helper::autoBackup(self::BACKUP_DIR,['backup','tmp','file']); helper::autoBackup(self::BACKUP_DIR, ['backup', 'tmp', 'file']);
// Sauvegarde htaccess // Sauvegarde htaccess
if ($this->getData(['config','autoUpdateHtaccess'])) { if ($this->getData(['config', 'autoUpdateHtaccess'])) {
$success = copy('.htaccess', '.htaccess' . '.bak'); $success = copy('.htaccess', '.htaccess' . '.bak');
} }
// Nettoyage des fichiers d'installation précédents // Nettoyage des fichiers d'installation précédents
if(file_exists(self::TEMP_DIR.'update.tar.gz') && $success) { if (file_exists(self::TEMP_DIR . 'update.tar.gz') && $success) {
$success = unlink(self::TEMP_DIR.'update.tar.gz'); $success = unlink(self::TEMP_DIR . 'update.tar.gz');
} }
if(file_exists(self::TEMP_DIR.'update.tar') && $success) { if (file_exists(self::TEMP_DIR . 'update.tar') && $success) {
$success = unlink(self::TEMP_DIR.'update.tar'); $success = unlink(self::TEMP_DIR . 'update.tar');
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -274,12 +279,12 @@ class install extends common {
] ]
]); ]);
break; break;
// Téléchargement // Téléchargement
case 2: case 2:
file_put_contents(self::TEMP_DIR.'update.tar.gz', helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz')); file_put_contents(self::TEMP_DIR . 'update.tar.gz', helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.tar.gz'));
$md5origin = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.md5'); $md5origin = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/update.md5');
$md5origin = (explode(' ',$md5origin)); $md5origin = (explode(' ', $md5origin));
$md5target = md5_file(self::TEMP_DIR.'update.tar.gz'); $md5target = md5_file(self::TEMP_DIR . 'update.tar.gz');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'display' => self::DISPLAY_JSON, 'display' => self::DISPLAY_JSON,
@ -289,7 +294,7 @@ class install extends common {
] ]
]); ]);
break; break;
// Installation // Installation
case 3: case 3:
$success = true; $success = true;
// Check la réécriture d'URL avant d'écraser les fichiers // Check la réécriture d'URL avant d'écraser les fichiers
@ -297,7 +302,7 @@ class install extends common {
// Décompression et installation // Décompression et installation
try { try {
// Décompression dans le dossier de fichier temporaires // Décompression dans le dossier de fichier temporaires
$pharData = new PharData(self::TEMP_DIR.'update.tar.gz'); $pharData = new PharData(self::TEMP_DIR . 'update.tar.gz');
$pharData->decompress(); $pharData->decompress();
// Installation // Installation
$pharData->extractTo(__DIR__ . '/../../../', null, true); $pharData->extractTo(__DIR__ . '/../../../', null, true);
@ -305,11 +310,11 @@ class install extends common {
$success = $e->getMessage(); $success = $e->getMessage();
} }
// Nettoyage du dossier // Nettoyage du dossier
if(file_exists(self::TEMP_DIR.'update.tar.gz')) { if (file_exists(self::TEMP_DIR . 'update.tar.gz')) {
unlink(self::TEMP_DIR.'update.tar.gz'); unlink(self::TEMP_DIR . 'update.tar.gz');
} }
if(file_exists(self::TEMP_DIR.'update.tar')) { if (file_exists(self::TEMP_DIR . 'update.tar')) {
unlink(self::TEMP_DIR.'update.tar'); unlink(self::TEMP_DIR . 'update.tar');
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -320,7 +325,7 @@ class install extends common {
] ]
]); ]);
break; break;
// Configuration // Configuration
case 4: case 4:
$success = true; $success = true;
$rewrite = $this->getInput('data'); $rewrite = $this->getInput('data');
@ -328,15 +333,15 @@ class install extends common {
if ($rewrite === "true") { // Ajout des lignes dans le .htaccess if ($rewrite === "true") { // Ajout des lignes dans le .htaccess
$fileContent = file_get_contents('.htaccess'); $fileContent = file_get_contents('.htaccess');
$rewriteData = PHP_EOL . $rewriteData = PHP_EOL .
'# URL rewriting' . PHP_EOL . '# URL rewriting' . PHP_EOL .
'<IfModule mod_rewrite.c>' . PHP_EOL . '<IfModule mod_rewrite.c>' . PHP_EOL .
"\tRewriteEngine on" . PHP_EOL . "\tRewriteEngine on" . PHP_EOL .
"\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL . "\tRewriteBase " . helper::baseUrl(false, false) . PHP_EOL .
"\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL . "\tRewriteCond %{REQUEST_FILENAME} !-f" . PHP_EOL .
"\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL . "\tRewriteCond %{REQUEST_FILENAME} !-d" . PHP_EOL .
"\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL . "\tRewriteRule ^(.*)$ index.php?$1 [L]" . PHP_EOL .
'</IfModule>'. PHP_EOL . '</IfModule>' . PHP_EOL .
'# URL rewriting' . PHP_EOL ; '# URL rewriting' . PHP_EOL;
$fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent); $fileContent = str_replace('# URL rewriting', $rewriteData, $fileContent);
file_put_contents( file_put_contents(
'.htaccess', '.htaccess',
@ -344,13 +349,14 @@ class install extends common {
); );
} }
// Recopie htaccess // Recopie htaccess
if ($this->getData(['config','autoUpdateHtaccess']) && if (
$success && file_exists( '.htaccess.bak') $this->getData(['config', 'autoUpdateHtaccess']) &&
$success && file_exists('.htaccess.bak')
) { ) {
// L'écraser avec le backup // L'écraser avec le backup
$success = copy( '.htaccess.bak' ,'.htaccess' ); $success = copy('.htaccess.bak', '.htaccess');
// Effacer le backup // Effacer le backup
unlink('.htaccess.bak'); unlink('.htaccess.bak');
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -367,7 +373,8 @@ class install extends common {
/** /**
* Mise à jour * Mise à jour
*/ */
public function update() { public function update()
{
// Nouvelle version // Nouvelle version
self::$newVersion = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/version'); self::$newVersion = helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/version');
// Valeurs en sortie // Valeurs en sortie
@ -377,6 +384,4 @@ class install extends common {
'view' => 'update' 'view' => 'update'
]); ]);
} }
}
}

View File

@ -13,7 +13,8 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
class maintenance extends common { class maintenance extends common
{
public static $actions = [ public static $actions = [
'index' => self::GROUP_VISITOR 'index' => self::GROUP_VISITOR
@ -22,24 +23,27 @@ class maintenance extends common {
/** /**
* Maintenance * Maintenance
*/ */
public function index() { public function index()
{
// Redirection vers l'accueil après rafraîchissement et que la maintenance est terminée. // Redirection vers l'accueil après rafraîchissement et que la maintenance est terminée.
if($this->getData(['config', 'maintenance']) == False){ if ($this->getData(['config', 'maintenance']) == False) {
header('Location:' . helper::baseUrl()); header('Location:' . helper::baseUrl());
exit(); exit();
} }
// Page perso définie et existante // Page perso définie et existante
if ($this->getData(['locale','page302']) !== 'none' if (
AND $this->getData(['page',$this->getData(['locale','page302'])]) ) { $this->getData(['locale', 'page302']) !== 'none'
$this->addOutput([ and $this->getData(['page', $this->getData(['locale', 'page302'])])
'display' => self::DISPLAY_LAYOUT_LIGHT, ) {
'title' => $this->getData(['page',$this->getData(['locale','page302']),'hideTitle']) $this->addOutput([
? '' 'display' => self::DISPLAY_LAYOUT_LIGHT,
: $this->getData(['page',$this->getData(['locale','page302']),'title']), 'title' => $this->getData(['page', $this->getData(['locale', 'page302']), 'hideTitle'])
//'content' => $this->getdata(['page',$this->getData(['locale','page302']),'content']), ? ''
'content' => $this->getPage($this->getData(['locale','page302']), self::$i18nContent), : $this->getData(['page', $this->getData(['locale', 'page302']), 'title']),
'view' => 'index' //'content' => $this->getdata(['page',$this->getData(['locale','page302']),'content']),
]); 'content' => $this->getPage($this->getData(['locale', 'page302']), self::$i18nContent),
'view' => 'index'
]);
} else { } else {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -49,5 +53,4 @@ class maintenance extends common {
]); ]);
} }
} }
}
}

View File

@ -14,7 +14,8 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
class page extends common { class page extends common
{
public static $actions = [ public static $actions = [
'add' => self::GROUP_MODERATOR, 'add' => self::GROUP_MODERATOR,
@ -68,24 +69,24 @@ class page extends common {
/** /**
* Duplication * Duplication
*/ */
public function duplicate() { public function duplicate()
{
// Adresse sans le token // Adresse sans le token
$url = explode('&',$this->getUrl(2)); $url = explode('&', $this->getUrl(2));
// La page n'existe pas // La page n'existe pas
if($this->getData(['page', $url[0]]) === null) { if ($this->getData(['page', $url[0]]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
} // Jeton incorrect } // Jeton incorrect
elseif(!isset($_GET['csrf'])) { elseif (!isset($_GET['csrf'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Jeton invalide' 'notification' => 'Jeton invalide'
]); ]);
} } elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
@ -93,7 +94,7 @@ class page extends common {
]); ]);
} }
// Duplication de la page // Duplication de la page
$pageTitle = $this->getData(['page',$url[0],'title']); $pageTitle = $this->getData(['page', $url[0], 'title']);
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page'])); $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
$pageId = helper::increment($pageId, self::$coreModuleIds); $pageId = helper::increment($pageId, self::$coreModuleIds);
$pageId = helper::increment($pageId, self::$moduleIds); $pageId = helper::increment($pageId, self::$moduleIds);
@ -102,16 +103,16 @@ class page extends common {
$url[0] $url[0]
]); ]);
// Ecriture // Ecriture
$this->setData (['page',$pageId,$data]); $this->setData(['page', $pageId, $data]);
$notification = 'La page a été dupliquée'; $notification = 'La page a été dupliquée';
// Duplication du module présent // Duplication du module présent
if ($this->getData(['page',$url[0],'moduleId'])) { if ($this->getData(['page', $url[0], 'moduleId'])) {
$data = $this->getData([ $data = $this->getData([
'module', 'module',
$url[0] $url[0]
]); ]);
// Ecriture // Ecriture
$this->setData (['module',$pageId,$data]); $this->setData(['module', $pageId, $data]);
$notification = 'La page et son module ont été dupliqués'; $notification = 'La page et son module ont été dupliqués';
} }
// Valeurs en sortie // Valeurs en sortie
@ -126,7 +127,8 @@ class page extends common {
/** /**
* Création * Création
*/ */
public function add() { public function add()
{
$pageTitle = 'Nouvelle page'; $pageTitle = 'Nouvelle page';
$pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page'])); $pageId = helper::increment(helper::filter($pageTitle, helper::FILTER_ID), $this->getData(['page']));
$this->setData([ $this->setData([
@ -135,7 +137,7 @@ class page extends common {
[ [
'typeMenu' => 'text', 'typeMenu' => 'text',
'iconUrl' => '', 'iconUrl' => '',
'disable' => false, 'disable' => false,
'content' => $pageId . '.html', 'content' => $pageId . '.html',
'hideTitle' => false, 'hideTitle' => false,
'breadCrumb' => false, 'breadCrumb' => false,
@ -181,24 +183,24 @@ class page extends common {
/** /**
* Suppression * Suppression
*/ */
public function delete() { public function delete()
{
// $url prend l'adresse sans le token // $url prend l'adresse sans le token
$url = explode('&',$this->getUrl(2)); $url = explode('&', $this->getUrl(2));
// La page n'existe pas // La page n'existe pas
if($this->getData(['page', $url[0]]) === null) { if ($this->getData(['page', $url[0]]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
]); ]);
} // Jeton incorrect } // Jeton incorrect
elseif(!isset($_GET['csrf'])) { elseif (!isset($_GET['csrf'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Jeton invalide' 'notification' => 'Jeton invalide'
]); ]);
} } elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
@ -206,7 +208,7 @@ class page extends common {
]); ]);
} }
// Impossible de supprimer la page d'accueil // Impossible de supprimer la page d'accueil
elseif($url[0] === $this->getData(['locale', 'homePageId'])) { elseif ($url[0] === $this->getData(['locale', 'homePageId'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
@ -214,7 +216,7 @@ class page extends common {
]); ]);
} }
// Impossible de supprimer la page de recherche affectée // Impossible de supprimer la page de recherche affectée
elseif($url[0] === $this->getData(['locale', 'searchPageId'])) { elseif ($url[0] === $this->getData(['locale', 'searchPageId'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
@ -222,7 +224,7 @@ class page extends common {
]); ]);
} }
// Impossible de supprimer la page des mentions légales affectée // Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['locale', 'legalPageId'])) { elseif ($url[0] === $this->getData(['locale', 'legalPageId'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
@ -230,7 +232,7 @@ class page extends common {
]); ]);
} }
// Impossible de supprimer la page des mentions légales affectée // Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['locale', 'page404'])) { elseif ($url[0] === $this->getData(['locale', 'page404'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
@ -238,7 +240,7 @@ class page extends common {
]); ]);
} }
// Impossible de supprimer la page des mentions légales affectée // Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['locale', 'page403'])) { elseif ($url[0] === $this->getData(['locale', 'page403'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
@ -246,7 +248,7 @@ class page extends common {
]); ]);
} }
// Impossible de supprimer la page des mentions légales affectée // Impossible de supprimer la page des mentions légales affectée
elseif($url[0] === $this->getData(['locale', 'page302'])) { elseif ($url[0] === $this->getData(['locale', 'page302'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'config', 'redirect' => helper::baseUrl() . 'config',
@ -254,14 +256,13 @@ class page extends common {
]); ]);
} }
// Jeton incorrect // Jeton incorrect
elseif(!isset($_GET['csrf'])) { elseif (!isset($_GET['csrf'])) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
'notification' => 'Jeton invalide' 'notification' => 'Jeton invalide'
]); ]);
} } elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
elseif ($_GET['csrf'] !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
@ -269,7 +270,7 @@ class page extends common {
]); ]);
} }
// Impossible de supprimer une page contenant des enfants // Impossible de supprimer une page contenant des enfants
elseif($this->getHierarchy($url[0],null)) { elseif ($this->getHierarchy($url[0], null)) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'page/edit/' . $url[0], 'redirect' => helper::baseUrl() . 'page/edit/' . $url[0],
@ -280,12 +281,13 @@ class page extends common {
else { else {
// Effacer le dossier du module // Effacer le dossier du module
$moduleId = $this->getData(['page',$url[0],'moduleId']); $moduleId = $this->getData(['page', $url[0], 'moduleId']);
$modulesData = helper::getModules(); $modulesData = helper::getModules();
if ( array_key_exists($moduleId, $modulesData) if (
array_key_exists($moduleId, $modulesData)
&& is_dir($modulesData[$moduleId]['dataDirectory'] . $url[0]) && is_dir($modulesData[$moduleId]['dataDirectory'] . $url[0])
) { ) {
$this->removeDir( $modulesData[$moduleId]['dataDirectory']. $url[0] ); $this->removeDir($modulesData[$moduleId]['dataDirectory'] . $url[0]);
} }
// Effacer la page // Effacer la page
$this->deleteData(['page', $url[0]]); $this->deleteData(['page', $url[0]]);
@ -310,9 +312,10 @@ class page extends common {
/** /**
* Édition * Édition
*/ */
public function edit() { public function edit()
{
// La page n'existe pas // La page n'existe pas
if($this->getData(['page', $this->getUrl(2)]) === null) { if ($this->getData(['page', $this->getUrl(2)]) === null) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'access' => false 'access' => false
@ -321,11 +324,11 @@ class page extends common {
// La page existe // La page existe
else { else {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire // Si le Title n'est pas vide, premier test pour positionner la notification du champ obligatoire
if( $this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '' ){ if ($this->getInput('pageEditTitle', helper::FILTER_ID, true) !== null && $this->getInput('pageEditTitle') !== '') {
// Génére l'ID si le titre de la page a changé // Génére l'ID si le titre de la page a changé
if ( $this->getInput('pageEditTitle') !== $this->getData(['page',$this->getUrl(2),'title']) ) { if ($this->getInput('pageEditTitle') !== $this->getData(['page', $this->getUrl(2), 'title'])) {
$pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true); $pageId = $this->getInput('pageEditTitle', helper::FILTER_ID, true);
} else { } else {
$pageId = $this->getUrl(2); $pageId = $this->getUrl(2);
@ -337,76 +340,76 @@ class page extends common {
// Si l'id a changée // Si l'id a changée
if ($pageId !== $this->getUrl(2)) { if ($pageId !== $this->getUrl(2)) {
// Incrémente le nouvel id de la page // Incrémente le nouvel id de la page
$pageId = helper::increment($pageId, $this->getData(['page'])); $pageId = helper::increment($pageId, $this->getData(['page']));
$pageId = helper::increment($pageId, self::$coreModuleIds); $pageId = helper::increment($pageId, self::$coreModuleIds);
$pageId = helper::increment($pageId, self::$moduleIds); $pageId = helper::increment($pageId, self::$moduleIds);
// Met à jour les enfants // Met à jour les enfants
foreach($this->getHierarchy($this->getUrl(2),null) as $childrenPageId) { foreach ($this->getHierarchy($this->getUrl(2), null) as $childrenPageId) {
$this->setData(['page', $childrenPageId, 'parentPageId', $pageId]); $this->setData(['page', $childrenPageId, 'parentPageId', $pageId]);
} }
// Change l'id de page dans les données des modules // Change l'id de page dans les données des modules
if ($this->getData(['module', $this->getUrl(2)]) !== null ) { if ($this->getData(['module', $this->getUrl(2)]) !== null) {
$this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]); $this->setData(['module', $pageId, $this->getData(['module', $this->getUrl(2)])]);
$this->deleteData(['module', $this->getUrl(2)]); $this->deleteData(['module', $this->getUrl(2)]);
// Renommer le dossier du module // Renommer le dossier du module
$moduleId = $this->getData(['page',$this->getUrl(2),'moduleId']); $moduleId = $this->getData(['page', $this->getUrl(2), 'moduleId']);
$modulesData = helper::getModules(); $modulesData = helper::getModules();
if (is_dir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2))) { if (is_dir($modulesData[$moduleId]['dataDirectory'] . $this->getUrl(2))) {
// Placer la feuille de style dans un dossier au nom de la nouvelle instance // Placer la feuille de style dans un dossier au nom de la nouvelle instance
mkdir( $modulesData[$moduleId]['dataDirectory']. $pageId, 0755 ); mkdir($modulesData[$moduleId]['dataDirectory'] . $pageId, 0755);
copy( $modulesData[$moduleId]['dataDirectory']. $this->getUrl(2), $modulesData[$moduleId]['dataDirectory']. $pageId); copy($modulesData[$moduleId]['dataDirectory'] . $this->getUrl(2), $modulesData[$moduleId]['dataDirectory'] . $pageId);
$this->removeDir($modulesData[$moduleId]['dataDirectory']. $this->getUrl(2)); $this->removeDir($modulesData[$moduleId]['dataDirectory'] . $this->getUrl(2));
// Mettre à jour le nom de la feuille de style // Mettre à jour le nom de la feuille de style
$this->setData(['module',$pageId,'theme','style', $modulesData[$moduleId]['dataDirectory']. $pageId]); $this->setData(['module', $pageId, 'theme', 'style', $modulesData[$moduleId]['dataDirectory'] . $pageId]);
} }
} }
// Si la page correspond à la page d'accueil, change l'id dans la configuration du site // Si la page correspond à la page d'accueil, change l'id dans la configuration du site
if($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) { if ($this->getData(['locale', 'homePageId']) === $this->getUrl(2)) {
$this->setData(['locale', 'homePageId', $pageId]); $this->setData(['locale', 'homePageId', $pageId]);
} }
} }
// Supprime les données du module en cas de changement de module // Supprime les données du module en cas de changement de module
if($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) { if ($this->getInput('pageEditModuleId') !== $this->getData(['page', $this->getUrl(2), 'moduleId'])) {
$this->deleteData(['module', $pageId]); $this->deleteData(['module', $pageId]);
} }
// Supprime l'ancienne page si l'id a changée // Supprime l'ancienne page si l'id a changée
if($pageId !== $this->getUrl(2)) { if ($pageId !== $this->getUrl(2)) {
$this->deleteData(['page', $this->getUrl(2)]); $this->deleteData(['page', $this->getUrl(2)]);
if (file_exists(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getUrl(2) . '.html')) { if (file_exists(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getUrl(2) . '.html')) {
unlink (self::DATA_DIR . self::$i18nContent . '/content/' . $this->getUrl(2) . '.html'); unlink(self::DATA_DIR . self::$i18nContent . '/content/' . $this->getUrl(2) . '.html');
} }
} }
// Traitement des pages spéciales affectées dans la config : // Traitement des pages spéciales affectées dans la config :
if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId']) ) { if ($this->getUrl(2) === $this->getData(['locale', 'legalPageId'])) {
$this->setData(['locale','legalPageId', $pageId]); $this->setData(['locale', 'legalPageId', $pageId]);
} }
if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId']) ) { if ($this->getUrl(2) === $this->getData(['locale', 'searchPageId'])) {
$this->setData(['locale','searchPageId', $pageId]); $this->setData(['locale', 'searchPageId', $pageId]);
} }
if ($this->getUrl(2) === $this->getData(['locale', 'page404']) ) { if ($this->getUrl(2) === $this->getData(['locale', 'page404'])) {
$this->setData(['locale','page404', $pageId]); $this->setData(['locale', 'page404', $pageId]);
} }
if ($this->getUrl(2) === $this->getData(['locale', 'page403']) ) { if ($this->getUrl(2) === $this->getData(['locale', 'page403'])) {
$this->setData(['locale','page403', $pageId]); $this->setData(['locale', 'page403', $pageId]);
} }
if ($this->getUrl(2) === $this->getData(['locale', 'page302']) ) { if ($this->getUrl(2) === $this->getData(['locale', 'page302'])) {
$this->setData(['locale','page302', $pageId]); $this->setData(['locale', 'page302', $pageId]);
} }
// Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents // Si la page est une page enfant, actualise les positions des autres enfants du parent, sinon actualise les pages sans parents
$lastPosition = 1; $lastPosition = 1;
$hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy()); $hierarchy = $this->getInput('pageEditParentPageId') ? $this->getHierarchy($this->getInput('pageEditParentPageId')) : array_keys($this->getHierarchy());
$position = $this->getInput('pageEditPosition', helper::FILTER_INT); $position = $this->getInput('pageEditPosition', helper::FILTER_INT);
$extraPosition = $this->getinput('pageEditExtraPosition', helper::FILTER_BOOLEAN); $extraPosition = $this->getinput('pageEditExtraPosition', helper::FILTER_BOOLEAN);
foreach($hierarchy as $hierarchyPageId) { foreach ($hierarchy as $hierarchyPageId) {
// Ne traite que les pages du menu sélectionné // Ne traite que les pages du menu sélectionné
if ($this->getData(['page', $hierarchyPageId, 'extraPosition']) === $extraPosition ) { if ($this->getData(['page', $hierarchyPageId, 'extraPosition']) === $extraPosition) {
// Ignore la page en cours de modification // Ignore la page en cours de modification
if($hierarchyPageId === $this->getUrl(2) ) { if ($hierarchyPageId === $this->getUrl(2)) {
continue; continue;
} }
// Incrémente de +1 pour laisser la place à la position de la page en cours de modification // Incrémente de +1 pour laisser la place à la position de la page en cours de modification
if($lastPosition === $position) { if ($lastPosition === $position) {
$lastPosition++; $lastPosition++;
} }
// Change la position // Change la position
@ -414,13 +417,11 @@ class page extends common {
// Incrémente pour la prochaine position // Incrémente pour la prochaine position
$lastPosition++; $lastPosition++;
} }
} }
if ($this->getinput('pageEditBlock') !== 'bar') { if ($this->getinput('pageEditBlock') !== 'bar') {
$barLeft = $this->getinput('pageEditBarLeft'); $barLeft = $this->getinput('pageEditBarLeft');
$barRight = $this->getinput('pageEditBarRight'); $barRight = $this->getinput('pageEditBarRight');
$hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN); $hideTitle = $this->getInput('pageEditHideTitle', helper::FILTER_BOOLEAN);
} else { } else {
// Une barre ne peut pas avoir de barres // Une barre ne peut pas avoir de barres
$barLeft = ""; $barLeft = "";
@ -430,33 +431,33 @@ class page extends common {
$hideTitle = true; $hideTitle = true;
} }
// Une page parent devient orpheline, les pages enfants le devienne pour éviter une incohérence // Une page parent devient orpheline, les pages enfants le devienne pour éviter une incohérence
if ( if (
$position === 0 && $position === 0 &&
$position !== $this->getData(['page', $this->getUrl(2), 'position']) && $position !== $this->getData(['page', $this->getUrl(2), 'position']) &&
$this->getinput('pageEditBlock') !== 'bar' $this->getinput('pageEditBlock') !== 'bar'
) { ) {
foreach ($this->getHierarchy($pageId) as $parentId=>$childId) { foreach ($this->getHierarchy($pageId) as $parentId => $childId) {
if ($this->getData(['page',$childId,'parentPageId']) === $pageId) { if ($this->getData(['page', $childId, 'parentPageId']) === $pageId) {
$this->setData(['page',$childId,'position', 0]); $this->setData(['page', $childId, 'position', 0]);
}
} }
}
} }
// La page est une barre latérale qui a été renommée : changer le nom de la barre dans les pages qui l'utilisent // La page est une barre latérale qui a été renommée : changer le nom de la barre dans les pages qui l'utilisent
if ($this->getinput('pageEditBlock') === 'bar') { if ($this->getinput('pageEditBlock') === 'bar') {
foreach ($this->getHierarchy() as $eachPageId=>$parentId) { foreach ($this->getHierarchy() as $eachPageId => $parentId) {
if ($this->getData(['page',$eachPageId,'barRight']) === $this->getUrl(2)) { if ($this->getData(['page', $eachPageId, 'barRight']) === $this->getUrl(2)) {
$this->setData(['page',$eachPageId,'barRight',$pageId]); $this->setData(['page', $eachPageId, 'barRight', $pageId]);
} }
if ($this->getData(['page',$eachPageId,'barLeft']) === $this->getUrl(2)) { if ($this->getData(['page', $eachPageId, 'barLeft']) === $this->getUrl(2)) {
$this->setData(['page',$eachPageId,'barLeft',$pageId]); $this->setData(['page', $eachPageId, 'barLeft', $pageId]);
} }
foreach ($parentId as $childId) { foreach ($parentId as $childId) {
if ($this->getData(['page',$childId,'barRight']) === $this->getUrl(2)) { if ($this->getData(['page', $childId, 'barRight']) === $this->getUrl(2)) {
$this->setData(['page',$childId,'barRight',$pageId]); $this->setData(['page', $childId, 'barRight', $pageId]);
} }
if ($this->getData(['page',$childId,'barLeft']) === $this->getUrl(2)) { if ($this->getData(['page', $childId, 'barLeft']) === $this->getUrl(2)) {
$this->setData(['page',$childId,'barLeft',$pageId]); $this->setData(['page', $childId, 'barLeft', $pageId]);
} }
} }
} }
@ -468,7 +469,7 @@ class page extends common {
[ [
'typeMenu' => $this->getinput('pageTypeMenu'), 'typeMenu' => $this->getinput('pageTypeMenu'),
'iconUrl' => $this->getinput('pageIconUrl'), 'iconUrl' => $this->getinput('pageIconUrl'),
'disable'=> $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN), 'disable' => $this->getinput('pageEditDisable', helper::FILTER_BOOLEAN),
'content' => $pageId . '.html', 'content' => $pageId . '.html',
'hideTitle' => $hideTitle, 'hideTitle' => $hideTitle,
'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN), 'breadCrumb' => $this->getInput('pageEditbreadCrumb', helper::FILTER_BOOLEAN),
@ -500,7 +501,7 @@ class page extends common {
mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755); mkdir(self::DATA_DIR . self::$i18nContent . '/content', 0755);
} }
$content = empty($this->getInput('pageEditContent', null)) ? '<p></p>' : str_replace('<p></p>', '<p>&nbsp;</p>', $this->getInput('pageEditContent', null)); $content = empty($this->getInput('pageEditContent', null)) ? '<p></p>' : str_replace('<p></p>', '<p>&nbsp;</p>', $this->getInput('pageEditContent', null));
$this->setPage($pageId , $content, self::$i18nContent); $this->setPage($pageId, $content, self::$i18nContent);
// Met à jour le site map // Met à jour le site map
$this->createSitemap('all'); $this->createSitemap('all');
@ -508,16 +509,16 @@ class page extends common {
$this->listPages(); $this->listPages();
// Redirection vers la configuration // Redirection vers la configuration
if( if (
$this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN) $this->getInput('pageEditModuleRedirect', helper::FILTER_BOOLEAN)
) { ) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $pageId . '/config', 'redirect' => helper::baseUrl() . $pageId . '/config',
'state' => true 'state' => true
]); ]);
// Redirection vers la page // Redirection vers la page
} else { } else {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $pageId, 'redirect' => helper::baseUrl() . $pageId,
@ -527,18 +528,20 @@ class page extends common {
} }
} }
} }
self::$moduleIds = array_merge( ['' => 'Aucun'] , helper::arrayColumn(helper::getModules(),'realName','SORT_ASC')); // Pages sans parent self::$moduleIds = array_merge(['' => 'Aucun'], helper::arrayColumn(helper::getModules(), 'realName', 'SORT_ASC')); // Pages sans parent
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { foreach ($this->getHierarchy() as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2)) { if ($parentPageId !== $this->getUrl(2)) {
self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); self::$pagesNoParentId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
} }
} }
// Pages barre latérales // Pages barre latérales
foreach($this->getHierarchy(null,false,true) as $parentPageId => $childrenPageIds) { foreach ($this->getHierarchy(null, false, true) as $parentPageId => $childrenPageIds) {
if($parentPageId !== $this->getUrl(2) && if (
$this->getData(['page', $parentPageId, 'block']) === 'bar') { $parentPageId !== $this->getUrl(2) &&
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']); $this->getData(['page', $parentPageId, 'block']) === 'bar'
} ) {
self::$pagesBarId[$parentPageId] = $this->getData(['page', $parentPageId, 'title']);
}
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -554,11 +557,13 @@ class page extends common {
/** /**
* Éditeur de feuille de style * Éditeur de feuille de style
*/ */
public function cssEditor() { public function cssEditor()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Enregistre le CSS // Enregistre le CSS
$this->setData(['page', $this->getUrl(2), 'css', $this->setData([
'page', $this->getUrl(2), 'css',
$this->getInput('pageCssEditorContent', null) $this->getInput('pageCssEditorContent', null)
]); ]);
// Valeurs en sortie // Valeurs en sortie
@ -578,15 +583,17 @@ class page extends common {
]); ]);
} }
/** /**
* Éditeur de feuille de style * Éditeur de feuille de style
*/ */
public function jsEditor() { public function jsEditor()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Enregistre le JS // Enregistre le JS
$this->setData(['page', $this->getUrl(2), 'js', $this->setData([
$this->getInput('pageJsEditorContent', null) 'page', $this->getUrl(2), 'js',
$this->getInput('pageJsEditorContent', null)
]); ]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -604,5 +611,4 @@ class page extends common {
'view' => 'jsEditor' 'view' => 'jsEditor'
]); ]);
} }
} }

View File

@ -1,22 +1,22 @@
<?php echo template::formOpen('pageCssEditorForm'); ?> <?php echo template::formOpen('pageCssEditorForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('pageCssEditorBack', [ <?php echo template::button('pageCssEditorBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2), 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2),
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('pageCssEditorSubmit'); ?>
</div>
</div> </div>
<div class="row"> <div class="col2 offset9">
<div class="col12"> <?php echo template::submit('pageCssEditorSubmit'); ?>
<?php echo template::textarea('pageCssEditorContent', [
'value' => empty($this->getData(['page', $this->getUrl(2), 'css' ])) ? '' : $this->getData(['page', $this->getUrl(2), 'css' ]),
'class' => 'editor'
]); ?>
</div>
</div> </div>
</div>
<div class="row">
<div class="col12">
<?php echo template::textarea('pageCssEditorContent', [
'value' => empty($this->getData(['page', $this->getUrl(2), 'css'])) ? '' : $this->getData(['page', $this->getUrl(2), 'css']),
'class' => 'editor'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,277 +1,169 @@
<?php echo template::formOpen('pageEditForm'); ?> <?php echo template::formOpen('pageEditForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php $href = helper::baseUrl() . $this->getUrl(2); ?> <?php $href = helper::baseUrl() . $this->getUrl(2); ?>
<?php if ($this->getData(['page', $this->getUrl(2), 'moduleId']) === 'redirection' || 'code')$href = helper::baseUrl(); ?> <?php if ($this->getData(['page', $this->getUrl(2), 'moduleId']) === 'redirection' || 'code') $href = helper::baseUrl(); ?>
<?php echo template::button('pageEditBack', [ <?php echo template::button('pageEditBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => $href, 'href' => $href,
'value' => template::ico('home') 'value' => template::ico('home')
]); ?> ]); ?>
</div> </div>
<div class="col1"> <div class="col1">
<?php /**echo template::button('pageEditHelp', [ <?php /**echo template::button('pageEditHelp', [
'href' => 'https://doc.zwiicms.fr/edition-des-pages', 'href' => 'https://doc.zwiicms.fr/edition-des-pages',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'class' => 'buttonHelp', 'class' => 'buttonHelp',
'help' => 'Consulter l\'aide en ligne' 'help' => 'Consulter l\'aide en ligne'
]); */?> ]); */ ?>
</div>
<div class="col1 offset6">
<?php echo template::button('pageEditDelete', [
'class' => 'buttonRed',
'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
'value' => template::ico('trash'),
'help' => 'Effacer la page'
]); ?>
</div>
<div class="col1">
<?php echo template::button('pageEditDuplicate', [
'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
'value' => template::ico('clone'),
'help' => 'Dupliquer la page'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('pageEditSubmit', [
'uniqueSubmission' => true
]); ?>
</div>
</div>
<div class="tab">
<?php echo template::button('pageEditContentButton', [
'value' => 'Contenu',
'class' => 'buttonTab'
]); ?>
<?php echo template::button('PageEditPositionButton', [
'value' => 'Menu',
'class' => 'buttonTab'
]); ?>
<?php echo template::button('pageEditExtensionButton', [
'value' => 'Extension',
'class' => 'buttonTab'
]); ?>
<?php echo template::button('pageEditLayoutButton', [
'value' => 'Mise en page',
'class' => 'buttonTab'
]); ?>
<?php echo template::button('pageEditPermissionButton', [
'value' => 'Permission',
'class' => 'buttonTab'
]); ?>
</div>
<div id="pageEditContentContainer" class="tabContent">
<div class="row">
<div class="col12">
<div class="block">
<h4>Titres
<span id="infoHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/informations-generales" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']); ?>
</a>
</span>
</h4>
<div class="row">
<div class="col8">
<?php echo template::text('pageEditTitle', [
'label' => 'Titre',
'value' => $this->getData(['page', $this->getUrl(2), 'title'])
]); ?>
</div>
<div class="col4">
<?php echo template::text('pageEditShortTitle', [
'label' => 'Titre court',
'value' => $this->getData(['page', $this->getUrl(2), 'shortTitle']),
'help' => 'Le titre court est affiché dans les menus. Il peut être identique au titre de la page.'
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('pageEditHideTitle', true, 'Titre masqué dans la page', [
'checked' => $this->getData(['page', $this->getUrl(2), 'hideTitle'])
]); ?>
</div>
<div class="col6">
<?php echo template::checkbox('pageEditbreadCrumb', true, 'Fil d\'Ariane dans le titre', [
'checked' => $this->getData(['page', $this->getUrl(2), 'breadCrumb']),
'help' => 'Affiche le nom de la page parente suivi du nom de la page, le titre ne doit pas être masqué.'
]); ?>
</div>
</div>
</div>
</div> </div>
<div class="col1 offset6"> </div>
<?php echo template::button('pageEditDelete', [ <div class="row">
'class' => 'buttonRed', <div class="col12">
'href' => helper::baseUrl() . 'page/delete/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'], <?php echo template::textarea('pageEditContent', [
'value' => template::ico('trash'), 'class' => 'editorWysiwyg',
'help' => 'Effacer la page' 'value' => $this->getPage($this->getUrl(2), self::$i18nContent)
]); ?>
</div>
<div class="col1">
<?php echo template::button('pageEditDuplicate', [
'href' => helper::baseUrl() . 'page/duplicate/' . $this->getUrl(2) . '&csrf=' . $_SESSION['csrf'],
'value' => template::ico('clone'),
'help' => 'Dupliquer la page'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('pageEditSubmit', [
'uniqueSubmission' => true
]); ?> ]); ?>
</div> </div>
</div> </div>
</div>
<div class="tab"> <div id="pageEditPositionContainer" class="tabContent">
<?php echo template::button('pageEditContentButton', [ <div class="row">
'value' => 'Contenu', <div class="col12">
'class' => 'buttonTab' <div class="block">
]); ?> <h4>Emplacement dans le menu
<?php echo template::button('PageEditPositionButton', [ <span id="positionHelpButton" class="helpDisplayButton">
'value' => 'Menu', <a href="https://doc.zwiicms.fr/emplacement-dans-le-menu" target="_blank" title="Cliquer pour consulter l'aide en ligne">
'class' => 'buttonTab' <?php echo template::ico('help', ['margin' => 'left']); ?>
]); ?> </a>
<?php echo template::button('pageEditExtensionButton', [ </span>
'value' => 'Extension', </h4>
'class' => 'buttonTab' <div class="blockContainer">
]); ?>
<?php echo template::button('pageEditLayoutButton', [
'value' => 'Mise en page',
'class' => 'buttonTab'
]); ?>
<?php echo template::button('pageEditPermissionButton', [
'value' => 'Permission',
'class' => 'buttonTab'
]); ?>
</div>
<div id="pageEditContentContainer" class="tabContent">
<div class="row">
<div class="col12">
<div class="block">
<h4>Titres
<span id="infoHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/informations-generales" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?>
</a>
</span>
</h4>
<div class="row"> <div class="row">
<div class="col8"> <div class="col4">
<?php echo template::text('pageEditTitle', [ <?php echo template::select('pageEditPosition', [], [
'label' => 'Titre', 'label' => 'Position',
'value' => $this->getData(['page', $this->getUrl(2), 'title']) 'help' => '\'Ne pas afficher\' crée une page orpheline non accessible par le biais des menus.'
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::text('pageEditShortTitle', [ <?php if ($this->getHierarchy($this->getUrl(2), false)) : ?>
'label' => 'Titre court', <?php echo template::hidden('pageEditParentPageId', [
'value' => $this->getData(['page', $this->getUrl(2), 'shortTitle']), 'value' => $this->getData(['page', $this->getUrl(2), 'parentPageId'])
'help' => 'Le titre court est affiché dans les menus. Il peut être identique au titre de la page.' ]); ?>
<?php else : ?>
<?php echo template::select('pageEditParentPageId', $module::$pagesNoParentId, [
'label' => 'Page parent',
'selected' => $this->getData(['page', $this->getUrl(2), 'parentPageId'])
]); ?>
<?php endif; ?>
</div>
<div class="col4">
<?php echo template::select('pageEditExtraPosition', $module::$extraPosition, [
'label' => 'Emplacement :',
'selected' => $this->getData(['page', $this->getUrl(2), 'extraPosition']),
'help' => 'Le petit accessoire est aligné à droite de la barre de menu, c\'est un emplacement réservé aux drapeaux et au bouton de connexion.'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::checkbox('pageEditHideTitle', true, 'Titre masqué dans la page', [ <?php echo template::checkbox('pageEditDisable', true, 'Page non cliquable', [
'checked' => $this->getData(['page', $this->getUrl(2), 'hideTitle']) 'checked' => $this->getData(['page', $this->getUrl(2), 'disable']),
]); ?> 'help' => 'Option active en mode déconnecté uniquement, les pages enfants sont visibles et accessibles.'
]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::checkbox('pageEditbreadCrumb', true, 'Fil d\'Ariane dans le titre', [ <?php echo template::checkbox('pageEditTargetBlank', true, 'S\'ouvre dans un nouvel onglet', [
'checked' => $this->getData(['page', $this->getUrl(2), 'breadCrumb']), 'checked' => $this->getData(['page', $this->getUrl(2), 'targetBlank'])
'help' => 'Affiche le nom de la page parente suivi du nom de la page, le titre ne doit pas être masqué.'
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::textarea('pageEditContent', [
'class' => 'editorWysiwyg',
'value' => $this->getPage($this->getUrl(2), self::$i18nContent)
]); ?>
</div>
</div>
</div>
<div id="pageEditPositionContainer" class="tabContent">
<div class="row">
<div class="col12">
<div class="block">
<h4>Emplacement dans le menu
<span id="positionHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/emplacement-dans-le-menu" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?>
</a>
</span>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col4">
<?php echo template::select('pageEditPosition', [], [
'label' => 'Position',
'help' => '\'Ne pas afficher\' crée une page orpheline non accessible par le biais des menus.'
]); ?>
</div>
<div class="col4">
<?php if($this->getHierarchy($this->getUrl(2), false)): ?>
<?php echo template::hidden('pageEditParentPageId', [
'value' => $this->getData(['page', $this->getUrl(2), 'parentPageId'])
]); ?>
<?php else: ?>
<?php echo template::select('pageEditParentPageId', $module::$pagesNoParentId, [
'label' => 'Page parent',
'selected' => $this->getData(['page', $this->getUrl(2), 'parentPageId'])
]); ?>
<?php endif; ?>
</div>
<div class="col4">
<?php echo template::select('pageEditExtraPosition', $module::$extraPosition, [
'label' => 'Emplacement :',
'selected' => $this->getData(['page', $this->getUrl(2), 'extraPosition']),
'help' => 'Le petit accessoire est aligné à droite de la barre de menu, c\'est un emplacement réservé aux drapeaux et au bouton de connexion.'
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('pageEditDisable', true, 'Page non cliquable', [
'checked' => $this->getData(['page', $this->getUrl(2), 'disable']),
'help' => 'Option active en mode déconnecté uniquement, les pages enfants sont visibles et accessibles.'
]); ?>
</div>
<div class="col6">
<?php echo template::checkbox('pageEditTargetBlank', true, 'S\'ouvre dans un nouvel onglet', [
'checked' => $this->getData(['page', $this->getUrl(2), 'targetBlank'])
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Options avancées
<span id="advancedHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/options-d-emplacement-avancee" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?>
</a>
</span>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col3">
<?php echo template::select('pageTypeMenu', $module::$typeMenu,[
'label' => 'Apparence',
'selected' => $this->getData(['page', $this->getUrl(2), 'typeMenu'])
]); ?>
</div>
<div class="col9">
<?php echo template::file('pageIconUrl', [
'help' => 'Sélectionnez une image ou une icône de petite dimension',
'label' => 'Icône',
'value' => $this->getData(['page', $this->getUrl(2), 'iconUrl'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('pageEditHideMenuChildren', true, 'Masquer les pages enfants dans le menu horizontal', [
'checked' => $this->getData(['page', $this->getUrl(2), 'hideMenuChildren'])
]); ?>
</div>
<div class="col6">
<?php echo template::checkbox('pageEditHideMenuSide', true, 'Masquer la page et les pages enfants dans le menu d\'une barre latérale' , [
'checked' => $this->getData(['page', $this->getUrl(2), 'hideMenuSide']),
'help' => 'La page est affichée dans un menu horizontal mais pas dans le menu vertical d\'une barre latérale.'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="pageEditExtensionContainer" class="tabContent">
<div class="row">
<div class="col6">
<div class="block">
<h4>Module</h4>
<div class="row">
<div class="col10">
<?php echo template::hidden('pageEditModuleRedirect'); ?>
<?php echo template::select('pageEditModuleId', $module::$moduleIds, [
'help' => 'En cas de changement de module, les données du module précédent seront supprimées.',
'label' => 'Module',
'selected' => $this->getData(['page', $this->getUrl(2), 'moduleId'])
]); ?>
<?php echo template::hidden('pageEditModuleIdOld',['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
<?php echo template::hidden('pageEditModuleIdOldText',[
'value' => array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']),$module::$moduleIds)? $module::$moduleIds[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId']))
]); ?>
</div>
<div class="col2 verticalAlignBottom">
<?php echo template::button('pageEditModuleConfig', [
'disabled' => (bool) $this->getData(['page', $this->getUrl(2), 'moduleId']) === false,
'uniqueSubmission' => true,
'value' => template::ico('gear')
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::select('pageModulePosition', $module::$modulePosition,[
'help' => 'En position libre ajoutez le module en plaçant [MODULE] à l\'endroit voulu dans votre page.',
'label' => 'Position du module',
'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition'])
]); ?>
</div>
</div>
</div>
</div>
<div class="col6">
<div class="block">
<h4>Contenu avancé</h4>
<div class="row">
<div class="col6 offset3">
<?php echo template::button('pageEditCssEditor', [
'href' => helper::baseUrl() . 'page/cssEditor/' . $this->getUrl(2),
'value' => 'Éditeur CSS',
'help' => 'Feuille de style spécifique à la page.'
]); ?>
</div>
</div>
<div class="row">
<div class="col6 offset3">
<?php echo template::button('pageEditJsEditor', [
'href' => helper::baseUrl() . 'page/jsEditor/' . $this->getUrl(2),
'value' => 'Éditeur JS',
'help' => 'Instructions JS ou jquery spécifiques à la page.'
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -279,101 +171,209 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div id="pageEditLayoutContainer" class="tabContent"> <div class="col12">
<div class="row"> <div class="block">
<div class="col12"> <h4>Options avancées
<div class="block"> <span id="advancedHelpButton" class="helpDisplayButton">
<h4>Mise en page <a href="https://doc.zwiicms.fr/options-d-emplacement-avancee" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<span id="layoutHelpButton" class="helpDisplayButton"> <?php echo template::ico('help', ['margin' => 'left']); ?>
<a href="https://doc.zwiicms.fr/mise-en-page-2" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?>
</a>
</span>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col6">
<div class="row">
<div class="col12">
<?php echo template::select('pageEditBlock', $module::$pageBlocks, [
'label' => 'Gabarits de page / Barre latérale',
'help' => 'Pour définir la page comme barre latérale, choisissez l\'option dans la liste.',
'selected' => $this->getData(['page', $this->getUrl(2) , 'block'])
]); ?>
</div>
</div>
</div>
<div class="col6">
<!-- Sélection des barres latérales -->
<?php if($this->getHierarchy($this->getUrl(2),false,true)): ?>
<?php echo template::hidden('pageEditBarLeft', [
'value' => $this->getData(['page', $this->getUrl(2), 'barLeft'])
]); ?>
<?php else: ?>
<?php echo template::select('pageEditBarLeft', $module::$pagesBarId, [
'label' => 'Barre latérale gauche :',
'selected' => $this->getData(['page', $this->getUrl(2), 'barLeft'])
]); ?>
<?php endif; ?>
<?php if($this->getHierarchy($this->getUrl(2),false,true)): ?>
<?php echo template::hidden('pageEditBarRight', [
'value' => $this->getData(['page', $this->getUrl(2), 'barRight'])
]); ?>
<?php else: ?>
<?php echo template::select('pageEditBarRight', $module::$pagesBarId, [
'label' => 'Barre latérale droite :',
'selected' => $this->getData(['page', $this->getUrl(2), 'barRight'])
]); ?>
<?php endif; ?>
<?php echo template::select('pageEditDisplayMenu', $module::$displayMenu, [
'label' => 'Contenu du menu vertical',
'selected' => $this->getData(['page', $this->getUrl(2), 'displayMenu']),
'help' => 'Par défaut le menu est affiché APRES le contenu de la page. Pour le positionner à un emplacement précis, insérez [MENU] dans le contenu de la page.'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="pageEditPermissionContainer" class="tabContent">
<div class="row">
<div class="col12">
<div class="block">
<h4>Permission et référencement
<span id="seoHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/permission-et-referencement" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?>
</a> </a>
</span> </span>
</h4> </h4>
<div class="blockContainer"> <div class="blockContainer">
<div class="row"> <div class="row">
<div class='col6'> <div class="col3">
<?php echo template::select('pageEditGroup', self::$groupPublics, [ <?php echo template::select('pageTypeMenu', $module::$typeMenu, [
'label' => 'Groupe requis pour accéder à la page :', 'label' => 'Apparence',
'selected' => $this->getData(['page', $this->getUrl(2), 'group']) 'selected' => $this->getData(['page', $this->getUrl(2), 'typeMenu'])
]); ?> ]); ?>
</div> </div>
<div class='col12'> <div class="col9">
<?php echo template::text('pageEditMetaTitle', [ <?php echo template::file('pageIconUrl', [
'label' => 'Méta-titre', 'help' => 'Sélectionnez une image ou une icône de petite dimension',
'value' => $this->getData(['page', $this->getUrl(2), 'metaTitle']) 'label' => 'Icône',
]); ?> 'value' => $this->getData(['page', $this->getUrl(2), 'iconUrl'])
<?php echo template::textarea('pageEditMetaDescription', [ ]); ?>
'label' => 'Méta-description', </div>
//'maxlength' => '500', </div>
'value' => $this->getData(['page', $this->getUrl(2), 'metaDescription']) <div class="row">
]); ?> <div class="col6">
</div> <?php echo template::checkbox('pageEditHideMenuChildren', true, 'Masquer les pages enfants dans le menu horizontal', [
'checked' => $this->getData(['page', $this->getUrl(2), 'hideMenuChildren'])
]); ?>
</div>
<div class="col6">
<?php echo template::checkbox('pageEditHideMenuSide', true, 'Masquer la page et les pages enfants dans le menu d\'une barre latérale', [
'checked' => $this->getData(['page', $this->getUrl(2), 'hideMenuSide']),
'help' => 'La page est affichée dans un menu horizontal mais pas dans le menu vertical d\'une barre latérale.'
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <div id="pageEditExtensionContainer" class="tabContent">
<div class="row">
<div class="col6">
<div class="block">
<h4>Module</h4>
<div class="row">
<div class="col10">
<?php echo template::hidden('pageEditModuleRedirect'); ?>
<?php echo template::select('pageEditModuleId', $module::$moduleIds, [
'help' => 'En cas de changement de module, les données du module précédent seront supprimées.',
'label' => 'Module',
'selected' => $this->getData(['page', $this->getUrl(2), 'moduleId'])
]); ?>
<?php echo template::hidden('pageEditModuleIdOld', ['value' => $this->getData(['page', $this->getUrl(2), 'moduleId'])]); ?>
<?php echo template::hidden('pageEditModuleIdOldText', [
'value' => array_key_exists($this->getData(['page', $this->getUrl(2), 'moduleId']), $module::$moduleIds) ? $module::$moduleIds[$this->getData(['page', $this->getUrl(2), 'moduleId'])] : ucfirst($this->getData(['page', $this->getUrl(2), 'moduleId']))
]); ?>
</div>
<div class="col2 verticalAlignBottom">
<?php echo template::button('pageEditModuleConfig', [
'disabled' => (bool) $this->getData(['page', $this->getUrl(2), 'moduleId']) === false,
'uniqueSubmission' => true,
'value' => template::ico('gear')
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::select('pageModulePosition', $module::$modulePosition, [
'help' => 'En position libre ajoutez le module en plaçant [MODULE] à l\'endroit voulu dans votre page.',
'label' => 'Position du module',
'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition'])
]); ?>
</div>
</div>
</div>
</div>
<div class="col6">
<div class="block">
<h4>Contenu avancé</h4>
<div class="row">
<div class="col6 offset3">
<?php echo template::button('pageEditCssEditor', [
'href' => helper::baseUrl() . 'page/cssEditor/' . $this->getUrl(2),
'value' => 'Éditeur CSS',
'help' => 'Feuille de style spécifique à la page.'
]); ?>
</div>
</div>
<div class="row">
<div class="col6 offset3">
<?php echo template::button('pageEditJsEditor', [
'href' => helper::baseUrl() . 'page/jsEditor/' . $this->getUrl(2),
'value' => 'Éditeur JS',
'help' => 'Instructions JS ou jquery spécifiques à la page.'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="pageEditLayoutContainer" class="tabContent">
<div class="row">
<div class="col12">
<div class="block">
<h4>Mise en page
<span id="layoutHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/mise-en-page-2" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']); ?>
</a>
</span>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col6">
<div class="row">
<div class="col12">
<?php echo template::select('pageEditBlock', $module::$pageBlocks, [
'label' => 'Gabarits de page / Barre latérale',
'help' => 'Pour définir la page comme barre latérale, choisissez l\'option dans la liste.',
'selected' => $this->getData(['page', $this->getUrl(2), 'block'])
]); ?>
</div>
</div>
</div>
<div class="col6">
<!-- Sélection des barres latérales -->
<?php if ($this->getHierarchy($this->getUrl(2), false, true)) : ?>
<?php echo template::hidden('pageEditBarLeft', [
'value' => $this->getData(['page', $this->getUrl(2), 'barLeft'])
]); ?>
<?php else : ?>
<?php echo template::select('pageEditBarLeft', $module::$pagesBarId, [
'label' => 'Barre latérale gauche :',
'selected' => $this->getData(['page', $this->getUrl(2), 'barLeft'])
]); ?>
<?php endif; ?>
<?php if ($this->getHierarchy($this->getUrl(2), false, true)) : ?>
<?php echo template::hidden('pageEditBarRight', [
'value' => $this->getData(['page', $this->getUrl(2), 'barRight'])
]); ?>
<?php else : ?>
<?php echo template::select('pageEditBarRight', $module::$pagesBarId, [
'label' => 'Barre latérale droite :',
'selected' => $this->getData(['page', $this->getUrl(2), 'barRight'])
]); ?>
<?php endif; ?>
<?php echo template::select('pageEditDisplayMenu', $module::$displayMenu, [
'label' => 'Contenu du menu vertical',
'selected' => $this->getData(['page', $this->getUrl(2), 'displayMenu']),
'help' => 'Par défaut le menu est affiché APRES le contenu de la page. Pour le positionner à un emplacement précis, insérez [MENU] dans le contenu de la page.'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="pageEditPermissionContainer" class="tabContent">
<div class="row">
<div class="col12">
<div class="block">
<h4>Permission et référencement
<span id="seoHelpButton" class="helpDisplayButton">
<a href="https://doc.zwiicms.fr/permission-et-referencement" target="_blank" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']); ?>
</a>
</span>
</h4>
<div class="blockContainer">
<div class="row">
<div class='col6'>
<?php echo template::select('pageEditGroup', self::$groupPublics, [
'label' => 'Groupe requis pour accéder à la page :',
'selected' => $this->getData(['page', $this->getUrl(2), 'group'])
]); ?>
</div>
<div class='col12'>
<?php echo template::text('pageEditMetaTitle', [
'label' => 'Méta-titre',
'value' => $this->getData(['page', $this->getUrl(2), 'metaTitle'])
]); ?>
<?php echo template::textarea('pageEditMetaDescription', [
'label' => 'Méta-description',
//'maxlength' => '500',
'value' => $this->getData(['page', $this->getUrl(2), 'metaDescription'])
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -1,22 +1,22 @@
<?php echo template::formOpen('pageJsEditorForm'); ?> <?php echo template::formOpen('pageJsEditorForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('pageJsEditorBack', [ <?php echo template::button('pageJsEditorBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2), 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(2),
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('pageJsEditorSubmit'); ?>
</div>
</div> </div>
<div class="row"> <div class="col2 offset9">
<div class="col12"> <?php echo template::submit('pageJsEditorSubmit'); ?>
<?php echo template::textarea('pageJsEditorContent', [
'value' => empty($this->getData(['page', $this->getUrl(2), 'js' ])) ? '': $this->getData(['page', $this->getUrl(2), 'js' ]),
'class' => 'editor'
]); ?>
</div>
</div> </div>
</div>
<div class="row">
<div class="col12">
<?php echo template::textarea('pageJsEditorContent', [
'value' => empty($this->getData(['page', $this->getUrl(2), 'js'])) ? '' : $this->getData(['page', $this->getUrl(2), 'js']),
'class' => 'editor'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -9,12 +9,13 @@
* @author Rémi Jean <remi.jean@outlook.com> * @author Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean * @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com> * @author Frédéric Tempez <frederic.tempez@outlook.com>
* @copyright Copyright (C) 2018-2022, Frédéric Tempez * @copyright Copyright (C) 2018-2022, Frédéric Tempez
* @license GNU General Public License, version 3 * @license GNU General Public License, version 3
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
class plugin extends common { class plugin extends common
{
public static $actions = [ public static $actions = [
'index' => self::GROUP_ADMIN, 'index' => self::GROUP_ADMIN,
@ -26,7 +27,7 @@ class plugin extends common {
'store' => self::GROUP_ADMIN, 'store' => self::GROUP_ADMIN,
'item' => self::GROUP_ADMIN, // détail d'un objet 'item' => self::GROUP_ADMIN, // détail d'un objet
'upload' => self::GROUP_ADMIN, // Téléverser catalogue 'upload' => self::GROUP_ADMIN, // Téléverser catalogue
'uploadItem'=> self::GROUP_ADMIN // Téléverser par archive 'uploadItem' => self::GROUP_ADMIN // Téléverser par archive
]; ];
// URL des modules // URL des modules
@ -52,7 +53,8 @@ class plugin extends common {
/* /*
* Effacement d'un module installé et non utilisé * Effacement d'un module installé et non utilisé
*/ */
public function delete() { public function delete()
{
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(3) !== $_SESSION['csrf']) { if ($this->getUrl(3) !== $_SESSION['csrf']) {
@ -62,25 +64,23 @@ class plugin extends common {
'state' => false, 'state' => false,
'notification' => 'Action non autorisée' 'notification' => 'Action non autorisée'
]); ]);
} } else {
else{
// Suppression des dossiers // Suppression des dossiers
$infoModules = helper::getModules(); $infoModules = helper::getModules();
$module = $this->getUrl(2); $module = $this->getUrl(2);
//Liste des dossiers associés au module non effacés //Liste des dossiers associés au module non effacés
if( $this->removeDir('./module/'.$module ) === true ){ if ($this->removeDir('./module/' . $module) === true) {
$success = true; $success = true;
$notification = 'Module '. $module .' désinstallé'; $notification = 'Module ' . $module . ' désinstallé';
if(($infoModules[$this->getUrl(2)]['dataDirectory']) ) { if (($infoModules[$this->getUrl(2)]['dataDirectory'])) {
if ( if (
is_dir($infoModules[$this->getUrl(2)]['dataDirectory']) is_dir($infoModules[$this->getUrl(2)]['dataDirectory'])
&& !$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory']) && !$this->removeDir($infoModules[$this->getUrl(2)]['dataDirectory'])
){ ) {
$notification = 'Module '.$module .' désinstallé, il reste des données dans ' . $infoModules[$this->getUrl(2)]['dataDirectory']; $notification = 'Module ' . $module . ' désinstallé, il reste des données dans ' . $infoModules[$this->getUrl(2)]['dataDirectory'];
} }
} }
} } else {
else{
$success = false; $success = false;
$notification = 'La suppression a échouée'; $notification = 'La suppression a échouée';
} }
@ -98,7 +98,8 @@ class plugin extends common {
* Installation d'un module * Installation d'un module
* Fonction utilisée par upload et storeUpload * Fonction utilisée par upload et storeUpload
*/ */
private function install($moduleFileName, $checkValid){ private function install($moduleFileName, $checkValid)
{
// Dossier temporaire // Dossier temporaire
$tempFolder = uniqid() . '/'; $tempFolder = uniqid() . '/';
@ -112,10 +113,10 @@ class plugin extends common {
//Création du dossier temporaire et extraction //Création du dossier temporaire et extraction
if (!is_dir (self::TEMP_DIR . $tempFolder) ) { if (!is_dir(self::TEMP_DIR . $tempFolder)) {
mkdir (self::TEMP_DIR . $tempFolder, 0755); mkdir(self::TEMP_DIR . $tempFolder, 0755);
} }
$zip->extractTo(self::TEMP_DIR . $tempFolder ); $zip->extractTo(self::TEMP_DIR . $tempFolder);
/** /**
* Lecture du descripteur de ressource * Lecture du descripteur de ressource
@ -127,17 +128,16 @@ class plugin extends common {
* 'download" => 'module/download' * 'download" => 'module/download'
*/ */
if (file_exists(self::TEMP_DIR . $tempFolder . 'desc.json') if (file_exists(self::TEMP_DIR . $tempFolder . 'desc.json')) {
) { $module = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . 'desc.json'), true);
$module = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . 'desc.json'), true); } else {
} else { // Message de retour
// Message de retour $this->removeDir(self::TEMP_DIR . $tempFolder);
$this->removeDir(self::TEMP_DIR . $tempFolder); $zip->close();
$zip->close(); return ([
return([ 'success' => false,
'success' => false, 'notification' => 'Archive invalide, le descripteur est absent.'
'notification'=> 'Archive invalide, le descripteur est absent.' ]);
]);
} }
/** /**
@ -145,23 +145,23 @@ class plugin extends common {
*/ */
foreach ($module['dirs'] as $src => $dest) { foreach ($module['dirs'] as $src => $dest) {
// Vérification de la présence des dossier décrits // Vérification de la présence des dossier décrits
if ( !is_dir (self::TEMP_DIR . $tempFolder . $src )) { if (!is_dir(self::TEMP_DIR . $tempFolder . $src)) {
// Message de retour // Message de retour
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
$zip->close(); $zip->close();
return([ return ([
'success' => false, 'success' => false,
'notification'=> 'Archive invalide, les dossiers ne correspondent pas au descripteur.' 'notification' => 'Archive invalide, les dossiers ne correspondent pas au descripteur.'
]); ]);
} }
// Interdire l'écriture dans le dossier core // Interdire l'écriture dans le dossier core
if ( strstr($dest, 'core') !== false ) { if (strstr($dest, 'core') !== false) {
// Message de retour // Message de retour
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
$zip->close(); $zip->close();
return([ return ([
'success' => false, 'success' => false,
'notification'=> 'Archive invalide, l\'écriture dans le dossier core est interdite' 'notification' => 'Archive invalide, l\'écriture dans le dossier core est interdite'
]); ]);
} }
} }
@ -169,13 +169,13 @@ class plugin extends common {
/** /**
* Validation de la présence du fichier de base du module * Validation de la présence du fichier de base du module
*/ */
if ( !file_exists(self::TEMP_DIR . $tempFolder . $module['name'] . '/' . $module['name'] . '.php')) { if (!file_exists(self::TEMP_DIR . $tempFolder . $module['name'] . '/' . $module['name'] . '.php')) {
// Message de retour // Message de retour
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
$zip->close(); $zip->close();
return([ return ([
'success' => false, 'success' => false,
'notification'=> 'Cette archive est invalide, le fichier de classe est absent.' 'notification' => 'Cette archive est invalide, le fichier de classe est absent.'
]); ]);
} }
@ -184,7 +184,7 @@ class plugin extends common {
* Le module est-il déjà installé ? * Le module est-il déjà installé ?
* Si oui lire le numéro de version et le stocker dans $versionInstalled * Si oui lire le numéro de version et le stocker dans $versionInstalled
*/ */
if (is_file( self::MODULE_DIR . $module['name'] . '/' . $module['name'] . '.php') ) { if (is_file(self::MODULE_DIR . $module['name'] . '/' . $module['name'] . '.php')) {
$c = helper::getModules(); $c = helper::getModules();
if (array_key_exists($module['name'], $c)) { if (array_key_exists($module['name'], $c)) {
$versionInstalled = $c[$module['name']]['version']; $versionInstalled = $c[$module['name']]['version'];
@ -193,12 +193,12 @@ class plugin extends common {
// Le module est installé, contrôle de la version // Le module est installé, contrôle de la version
$installOk = false; $installOk = false;
if ( isset($versionInstalled) === false ) { if (isset($versionInstalled) === false) {
$installOk = true; $installOk = true;
} elseif ( version_compare($module['version'], $versionInstalled) >= 0 ) { } elseif (version_compare($module['version'], $versionInstalled) >= 0) {
$installOk = true; $installOk = true;
} else { } else {
if (version_compare($module['version'], $versionInstalled) === -1 ) { if (version_compare($module['version'], $versionInstalled) === -1) {
// Contrôle du forçage // Contrôle du forçage
if ($this->getInput('configModulesCheck', helper::FILTER_BOOLEAN) === true) { if ($this->getInput('configModulesCheck', helper::FILTER_BOOLEAN) === true) {
$installOk = true; $installOk = true;
@ -206,9 +206,9 @@ class plugin extends common {
// Message de retour // Message de retour
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
$zip->close(); $zip->close();
return([ return ([
'success' => false, 'success' => false,
'notification'=> 'La version installée est plus récente.' 'notification' => 'La version installée est plus récente.'
]); ]);
} }
} }
@ -218,23 +218,24 @@ class plugin extends common {
if ($installOk) { if ($installOk) {
// Copie récursive des dossiers // Copie récursive des dossiers
foreach ($module['dirs'] as $src => $dest) { foreach ($module['dirs'] as $src => $dest) {
if (!is_dir (self::TEMP_DIR . $tempFolder . $src)) { if (!is_dir(self::TEMP_DIR . $tempFolder . $src)) {
mkdir(self::TEMP_DIR . $tempFolder . $src); mkdir(self::TEMP_DIR . $tempFolder . $src);
} }
$success = $this->copyDir( self::TEMP_DIR . $tempFolder . $src, $dest ); $success = $this->copyDir(self::TEMP_DIR . $tempFolder . $src, $dest);
} }
// Message de retour // Message de retour
$t = isset($versionInstalled) ? ' actualisé' : 'installé'; $t = isset($versionInstalled) ? ' actualisé' : 'installé';
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
$zip->close(); $zip->close();
return(['success' => $success, return ([
'notification'=> $success ? 'Le module '.$module['name'].' a été ' . $t 'success' => $success,
: 'Erreur inconnue, le module n\'est pas installé' 'notification' => $success ? 'Le module ' . $module['name'] . ' a été ' . $t
: 'Erreur inconnue, le module n\'est pas installé'
]); ]);
} else { } else {
return([ return ([
'success' => false, 'success' => false,
'notification'=> 'Une erreur inconnue s\est produite !' 'notification' => 'Une erreur inconnue s\est produite !'
]); ]);
// Supprimer le dossier temporaire // Supprimer le dossier temporaire
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
@ -242,28 +243,29 @@ class plugin extends common {
} }
} else { } else {
// Message de retour // Message de retour
return(['success' => $success, return ([
'notification'=> 'Impossible d\'ouvrir l\'archive' 'success' => false,
'notification' => 'Impossible d\'ouvrir l\'archive'
]); ]);
} }
} }
/*** /***
* Installation d'un module à partir du gestionnaire de fichier * Installation d'un module à partir du gestionnaire de fichier
*/ */
public function upload() { public function upload()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Installation d'un module // Installation d'un module
$checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN); $checkValidMaj = $this->getInput('configModulesCheck', helper::FILTER_BOOLEAN);
$zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT); $zipFilename = $this->getInput('configModulesInstallation', helper::FILTER_STRING_SHORT);
if( $zipFilename !== ''){ if ($zipFilename !== '') {
$success = [ $success = [
'success' => false, 'success' => false,
'notification'=> '' 'notification' => ''
]; ];
$state = $this->install(self::FILE_DIR.'source/'.$zipFilename, $checkValidMaj); $state = $this->install(self::FILE_DIR . 'source/' . $zipFilename, $checkValidMaj);
} }
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'plugin', 'redirect' => helper::baseUrl() . 'plugin',
@ -281,7 +283,8 @@ class plugin extends common {
/*** /***
* Installation d'un module depuis le catalogue * Installation d'un module depuis le catalogue
*/ */
public function uploadItem() { public function uploadItem()
{
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(3) !== $_SESSION['csrf']) { if ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
@ -300,17 +303,17 @@ class plugin extends common {
// Télécharger le fichier // Télécharger le fichier
$moduleData = helper::getUrlContents(self::BASEURL_STORE . self::FILE_DIR . 'source/' . $moduleFilePath); $moduleData = helper::getUrlContents(self::BASEURL_STORE . self::FILE_DIR . 'source/' . $moduleFilePath);
// Extraire de l'arborescence // Extraire de l'arborescence
$d = explode('/',$moduleFilePath); $d = explode('/', $moduleFilePath);
$moduleFile = $d[count($d)-1]; $moduleFile = $d[count($d) - 1];
// Créer le dossier modules // Créer le dossier modules
if (!is_dir(self::FILE_DIR . 'source/modules')) { if (!is_dir(self::FILE_DIR . 'source/modules')) {
mkdir (self::FILE_DIR . 'source/modules', 0755); mkdir(self::FILE_DIR . 'source/modules', 0755);
} }
// Sauver les données du fichiers // Sauver les données du fichiers
file_put_contents(self::FILE_DIR . 'source/modules/' . $moduleFile, $moduleData); file_put_contents(self::FILE_DIR . 'source/modules/' . $moduleFile, $moduleData);
// Installation directe // Installation directe
if ( file_exists(self::FILE_DIR . 'source/modules/' . $moduleFile) ) { if (file_exists(self::FILE_DIR . 'source/modules/' . $moduleFile)) {
$r = $this->install(self::FILE_DIR . 'source/modules/' . $moduleFile, false); $r = $this->install(self::FILE_DIR . 'source/modules/' . $moduleFile, false);
} else { } else {
$r['notification'] = 'Un problème est survenu, le module n\'est pas installé'; $r['notification'] = 'Un problème est survenu, le module n\'est pas installé';
@ -333,48 +336,49 @@ class plugin extends common {
/** /**
* Catalogue des modules sur le site ZwiiCMS.fr * Catalogue des modules sur le site ZwiiCMS.fr
*/ */
public function store() { public function store()
{
$store = json_decode(helper::getUrlContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true); $store = json_decode(helper::getUrlContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
if ($store) { if ($store) {
// Modules installés // Modules installés
$infoModules = helper::getModules(); $infoModules = helper::getModules();
// Clés moduleIds dans les pages // Clés moduleIds dans les pages
$inPages = helper::arrayColumn($this->getData(['page']),'moduleId', 'SORT_DESC'); $inPages = helper::arrayColumn($this->getData(['page']), 'moduleId', 'SORT_DESC');
foreach( $inPages as $key=>$value){ foreach ($inPages as $key => $value) {
$pagesInfos[ $this->getData(['page', $key, 'title' ]) ] = $value; $pagesInfos[$this->getData(['page', $key, 'title'])] = $value;
} }
// Parcourir les données des modules // Parcourir les données des modules
foreach ($store as $key=>$value) { foreach ($store as $key => $value) {
// Module non installé // Module non installé
$ico = template::ico('download'); $ico = template::ico('download');
$class = ''; $class = '';
$help = 'Télécharger le module dans le gestionnaire de fichiers'; $help = 'Télécharger le module dans le gestionnaire de fichiers';
// Le module est installé // Le module est installé
if (array_key_exists($key,$infoModules) === true) { if (array_key_exists($key, $infoModules) === true) {
$class = 'buttonGreen'; $class = 'buttonGreen';
$ico = template::ico('update'); $ico = template::ico('update');
$help = 'Mettre à jour le module orphelin'; $help = 'Mettre à jour le module orphelin';
} }
// Le module est installé et utilisé // Le module est installé et utilisé
if (in_array($key,$inPages) === true) { if (in_array($key, $inPages) === true) {
$class = 'buttonRed'; $class = 'buttonRed';
$ico = template::ico('update'); $ico = template::ico('update');
$help = 'Mettre à jour le module attaché, une sauvegarde des données de module est recommandée !'; $help = 'Mettre à jour le module attaché, une sauvegarde des données de module est recommandée !';
} }
self::$storeList [] = [ self::$storeList[] = [
$store[$key]['category'], $store[$key]['category'],
'<a href="' . self::BASEURL_STORE . self::MODULE_STORE . $key . '" target="_blank" >'.$store[$key]['title'].'</a>', '<a href="' . self::BASEURL_STORE . self::MODULE_STORE . $key . '" target="_blank" >' . $store[$key]['title'] . '</a>',
$store[$key]['version'], $store[$key]['version'],
mb_detect_encoding(strftime('%d %B %Y', $store[$key]['versionDate']), 'UTF-8', true) mb_detect_encoding(strftime('%d %B %Y', $store[$key]['versionDate']), 'UTF-8', true)
? strftime('%d %B %Y', $store[$key]['versionDate']) ? strftime('%d %B %Y', $store[$key]['versionDate'])
: utf8_encode(strftime('%d %B %Y', $store[$key]['versionDate'])), : utf8_encode(strftime('%d %B %Y', $store[$key]['versionDate'])),
implode(', ', array_keys($pagesInfos,$key)), implode(', ', array_keys($pagesInfos, $key)),
template::button('moduleExport' . $key, [ template::button('moduleExport' . $key, [
'class' => $class, 'class' => $class,
'href' => helper::baseUrl(). $this->getUrl(0) . '/uploadItem/' . $key.'/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre 'href' => helper::baseUrl() . $this->getUrl(0) . '/uploadItem/' . $key . '/' . $_SESSION['csrf'], // appel de fonction vaut exécution, utiliser un paramètre
'value' => $ico, 'value' => $ico,
'help' => $help 'help' => $help
]) ])
]; ];
} }
} }
@ -389,15 +393,16 @@ class plugin extends common {
/** /**
* Détail d'un objet du catalogue * Détail d'un objet du catalogue
*/ */
public function item() { public function item()
{
$store = json_decode(helper::getUrlContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true); $store = json_decode(helper::getUrlContents(self::BASEURL_STORE . self::MODULE_STORE . 'list'), true);
self::$storeItem = $store [$this->getUrl(2)] ; self::$storeItem = $store[$this->getUrl(2)];
self::$storeItem ['fileDate'] = mb_detect_encoding(strftime('%d %B %Y',self::$storeItem ['fileDate']), 'UTF-8', true) self::$storeItem['fileDate'] = mb_detect_encoding(strftime('%d %B %Y', self::$storeItem['fileDate']), 'UTF-8', true)
? strftime('%d %B %Y', self::$storeItem ['fileDate']) ? strftime('%d %B %Y', self::$storeItem['fileDate'])
: utf8_encode(strftime('%d %B %Y', self::$storeItem ['fileDate'])); : utf8_encode(strftime('%d %B %Y', self::$storeItem['fileDate']));
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' =>'Module ' . self::$storeItem['title'], 'title' => 'Module ' . self::$storeItem['title'],
'view' => 'item' 'view' => 'item'
]); ]);
} }
@ -405,12 +410,15 @@ class plugin extends common {
/** /**
* Gestion des modules * Gestion des modules
*/ */
public function index() { public function index()
{
// Tableau des langues rédigées // Tableau des langues rédigées
foreach (self::$languages as $key => $value) { foreach (self::$languages as $key => $value) {
if ($this->getData(['config','i18n', $key]) === 'site' || if (
$key === 'fr_FR') { $this->getData(['config', 'i18n', $key]) === 'site' ||
$key === 'fr_FR'
) {
$i18nSites[$key] = $value; $i18nSites[$key] = $value;
} }
} }
@ -418,35 +426,34 @@ class plugin extends common {
$infoModules = helper::getModules(); $infoModules = helper::getModules();
// Parcourir les langues du site traduit et recherche les modules affectés à des pages // Parcourir les langues du site traduit et recherche les modules affectés à des pages
foreach ($i18nSites as $keyi18n=>$valuei18n) { foreach ($i18nSites as $keyi18n => $valuei18n) {
// Clés moduleIds dans les pages de la langue // Clés moduleIds dans les pages de la langue
$pages = json_decode(file_get_contents(self::DATA_DIR . $keyi18n . '/' . 'page.json'), true); $pages = json_decode(file_get_contents(self::DATA_DIR . $keyi18n . '/' . 'page.json'), true);
// Extraire les clés des modules // Extraire les clés des modules
$pagesModules [$keyi18n] = array_filter(helper::arrayColumn($pages['page'],'moduleId', 'SORT_DESC'), 'strlen'); $pagesModules[$keyi18n] = array_filter(helper::arrayColumn($pages['page'], 'moduleId', 'SORT_DESC'), 'strlen');
// Générer ls liste des pages avec module pour la sauvegarde ou le backup // Générer ls liste des pages avec module pour la sauvegarde ou le backup
foreach( $pagesModules [$keyi18n] as $key=>$value ) { foreach ($pagesModules[$keyi18n] as $key => $value) {
if (!empty($value)) { if (!empty($value)) {
$pagesInfos [$keyi18n] [$key] ['pageId'] = $key ; $pagesInfos[$keyi18n][$key]['pageId'] = $key;
$pagesInfos [$keyi18n] [$key] ['title'] = $this->getData(['page', $key, 'title' ]) ; $pagesInfos[$keyi18n][$key]['title'] = $this->getData(['page', $key, 'title']);
$pagesInfos [$keyi18n] [$key] ['moduleId'] = $value; $pagesInfos[$keyi18n][$key]['moduleId'] = $value;
} }
} }
} }
// Recherche des modules orphelins dans toutes les langues // Recherche des modules orphelins dans toutes les langues
$orphans = $installed = array_flip(array_keys ($infoModules)); $orphans = $installed = array_flip(array_keys($infoModules));
foreach ($i18nSites as $keyi18n=>$valuei18n) { foreach ($i18nSites as $keyi18n => $valuei18n) {
// Générer la liste des modules orphelins // Générer la liste des modules orphelins
foreach ($infoModules as $key=>$value) { foreach ($infoModules as $key => $value) {
// Supprimer les éléments affectés // Supprimer les éléments affectés
if (array_search($key, $pagesModules[$keyi18n]) ) { if (array_search($key, $pagesModules[$keyi18n])) {
unset($orphans [$key]); unset($orphans[$key]);
} }
} }
} }
$orphans = array_flip($orphans); $orphans = array_flip($orphans);
@ -455,18 +462,18 @@ class plugin extends common {
if (isset($orphans)) { if (isset($orphans)) {
foreach ($orphans as $key) { foreach ($orphans as $key) {
// Construire le tableau de sortie // Construire le tableau de sortie
self::$modulesOrphan [] = [ self::$modulesOrphan[] = [
$infoModules [$key] ['realName'], $infoModules[$key]['realName'],
$key, $key,
$infoModules [$key] ['version'], $infoModules[$key]['version'],
'', '',
$infoModules[$key] ['delete'] === true $infoModules[$key]['delete'] === true
? template::button('moduleDelete' . $key, [ ? template::button('moduleDelete' . $key, [
'class' => 'moduleDelete buttonRed', 'class' => 'moduleDelete buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' .$key . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $key . '/' . $_SESSION['csrf'],
'value' => template::ico('trash'), 'value' => template::ico('trash'),
'help' => 'Supprimer le module' 'help' => 'Supprimer le module'
]) ])
: '', : '',
]; ];
@ -478,18 +485,18 @@ class plugin extends common {
if (isset($installed)) { if (isset($installed)) {
foreach (array_flip($installed) as $key) { foreach (array_flip($installed) as $key) {
// Construire le tableau de sortie // Construire le tableau de sortie
self::$modulesInstalled [] = [ self::$modulesInstalled[] = [
$infoModules [$key] ['realName'], $infoModules[$key]['realName'],
$key, $key,
$infoModules [$key] ['version'], $infoModules[$key]['version'],
'', '',
template::button('moduleSave' . $key, [ template::button('moduleSave' . $key, [
'href' => helper::baseUrl() . $this->getUrl(0) . '/save/filemanager/' .$key . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/save/filemanager/' . $key . '/' . $_SESSION['csrf'],
'value' => template::ico('download-cloud'), 'value' => template::ico('download-cloud'),
'help' => 'Sauvegarder le module dans le gestionnaire de fichiers' 'help' => 'Sauvegarder le module dans le gestionnaire de fichiers'
]), ]),
template::button('moduleDownload' . $key, [ template::button('moduleDownload' . $key, [
'href' => helper::baseUrl() . $this->getUrl(0) . '/save/download/' .$key . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/save/download/' . $key . '/' . $_SESSION['csrf'],
'value' => template::ico('download'), 'value' => template::ico('download'),
'help' => 'Sauvegarder et télécharger le module' 'help' => 'Sauvegarder et télécharger le module'
]) ])
@ -503,30 +510,30 @@ class plugin extends common {
// Avec les commandes de sauvegarde et de restauration // Avec les commandes de sauvegarde et de restauration
$keyi18n = self::$i18nContent; $keyi18n = self::$i18nContent;
if (isset($pagesInfos) && if (
is_array($pagesInfos[self::$i18nContent]) ) isset($pagesInfos) &&
{ is_array($pagesInfos[self::$i18nContent])
foreach ($pagesInfos[self::$i18nContent] as $keyPage=>$value) { ) {
if (isset($infoModules[$pagesInfos[$keyi18n][$keyPage]['moduleId']])) foreach ($pagesInfos[self::$i18nContent] as $keyPage => $value) {
{ if (isset($infoModules[$pagesInfos[$keyi18n][$keyPage]['moduleId']])) {
// Co[nstruire le tableau de sortie // Co[nstruire le tableau de sortie
self::$modulesData[] = [ self::$modulesData[] = [
$infoModules[$pagesInfos[$keyi18n][$keyPage]['moduleId']] ['realName'], $infoModules[$pagesInfos[$keyi18n][$keyPage]['moduleId']]['realName'],
$pagesInfos[$keyi18n][$keyPage]['moduleId'], $pagesInfos[$keyi18n][$keyPage]['moduleId'],
$infoModules[$pagesInfos [$keyi18n][$keyPage]['moduleId']] ['version'], $infoModules[$pagesInfos[$keyi18n][$keyPage]['moduleId']]['version'],
//template::flag($keyi18n, '20px'), //template::flag($keyi18n, '20px'),
'<a href ="' . helper::baseUrl() . $keyPage . '" target="_blank">' . $pagesInfos [$keyi18n][$keyPage]['title'] . ' (' .$keyPage . ')</a>', '<a href ="' . helper::baseUrl() . $keyPage . '" target="_blank">' . $pagesInfos[$keyi18n][$keyPage]['title'] . ' (' . $keyPage . ')</a>',
template::button('dataExport' . $keyPage, [ template::button('dataExport' . $keyPage, [
'href' => helper::baseUrl(). $this->getUrl(0) . '/dataExport/' . $keyi18n . '/' . $pagesInfos[$keyi18n][$keyPage]['moduleId'] . '/' . $keyPage . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre 'href' => helper::baseUrl() . $this->getUrl(0) . '/dataExport/' . $keyi18n . '/' . $pagesInfos[$keyi18n][$keyPage]['moduleId'] . '/' . $keyPage . '/' . $_SESSION['csrf'], // appel de fonction vaut exécution, utiliser un paramètre
'value' => template::ico('download'), 'value' => template::ico('download'),
'help' => 'Exporter les données du module' 'help' => 'Exporter les données du module'
]), ]),
template::button('dataDelete' . $keyPage, [ template::button('dataDelete' . $keyPage, [
'href' => helper::baseUrl(). $this->getUrl(0) . '/dataDelete/' . $keyi18n . '/' . $pagesInfos[$keyi18n][$keyPage]['moduleId'] . '/' . $keyPage . '/' . $_SESSION['csrf'],// appel de fonction vaut exécution, utiliser un paramètre 'href' => helper::baseUrl() . $this->getUrl(0) . '/dataDelete/' . $keyi18n . '/' . $pagesInfos[$keyi18n][$keyPage]['moduleId'] . '/' . $keyPage . '/' . $_SESSION['csrf'], // appel de fonction vaut exécution, utiliser un paramètre
'value' => template::ico('trash'), 'value' => template::ico('trash'),
'class' => 'buttonRed dataDelete', 'class' => 'buttonRed dataDelete',
'help' => 'Détacher le module de la page', 'help' => 'Détacher le module de la page',
]) ])
]; ];
} else { } else {
self::$modulesData[] = []; self::$modulesData[] = [];
@ -548,7 +555,8 @@ class plugin extends common {
* Sauvegarde un module sans les données * Sauvegarde un module sans les données
*/ */
public function save() { public function save()
{
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(4) !== $_SESSION['csrf']) { if ($this->getUrl(4) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
@ -567,14 +575,14 @@ class plugin extends common {
//Nom de l'archive //Nom de l'archive
$fileName = $this->getUrl(3) . '.zip'; $fileName = $this->getUrl(3) . '.zip';
$this->makeZip ($tmpFolder . '/' . $fileName, self::MODULE_DIR . $this->getUrl(3)); $this->makeZip($tmpFolder . '/' . $fileName, self::MODULE_DIR . $this->getUrl(3));
switch ($this->getUrl(2)) { switch ($this->getUrl(2)) {
case 'filemanager': case 'filemanager':
if (!file_exists(self::FILE_DIR . 'source/modules')) { if (!file_exists(self::FILE_DIR . 'source/modules')) {
mkdir(self::FILE_DIR . 'source/modules'); mkdir(self::FILE_DIR . 'source/modules');
} }
$success = copy($tmpFolder . '/' . $fileName , self::FILE_DIR . 'source/modules/' . $this->getUrl(3) . '.zip' ); $success = copy($tmpFolder . '/' . $fileName, self::FILE_DIR . 'source/modules/' . $this->getUrl(3) . '.zip');
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -590,7 +598,7 @@ class plugin extends common {
header('Content-Length: ' . filesize($tmpFolder . '/' . $fileName)); header('Content-Length: ' . filesize($tmpFolder . '/' . $fileName));
ob_clean(); ob_clean();
ob_end_flush(); ob_end_flush();
readfile( $tmpFolder . '/' .$fileName); readfile($tmpFolder . '/' . $fileName);
exit(); exit();
break; break;
} }
@ -598,7 +606,7 @@ class plugin extends common {
unlink($tmpFolder . '/' . $fileName); unlink($tmpFolder . '/' . $fileName);
$this->removeDir($tmpFolder); $this->removeDir($tmpFolder);
} }
} }
/* /*
@ -608,7 +616,8 @@ class plugin extends common {
* 4 : pageId * 4 : pageId
* 5 : CSRF * 5 : CSRF
*/ */
public function dataDelete() { public function dataDelete()
{
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(5) !== $_SESSION['csrf']) { if ($this->getUrl(5) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
@ -623,12 +632,10 @@ class plugin extends common {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'plugin', 'redirect' => helper::baseUrl() . 'plugin',
'notification' => 'Le module ' . $this->getUrl(3) . ' de la page '. $this->getUrl(4) . ' a été supprimé.', 'notification' => 'Le module ' . $this->getUrl(3) . ' de la page ' . $this->getUrl(4) . ' a été supprimé.',
'state' => true 'state' => true
]); ]);
} }
} }
@ -640,7 +647,8 @@ class plugin extends common {
* 4 : pageId * 4 : pageId
* 5 : CSRF * 5 : CSRF
*/ */
public function dataExport() { public function dataExport()
{
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(5) !== $_SESSION['csrf']) { if ($this->getUrl(5) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
@ -659,26 +667,25 @@ class plugin extends common {
// Copie des infos sur le module // Copie des infos sur le module
$modulesData = json_decode(file_get_contents(self::DATA_DIR . $this->getUrl(2) . '/module.json' ), true); $modulesData = json_decode(file_get_contents(self::DATA_DIR . $this->getUrl(2) . '/module.json'), true);
$moduleData = $modulesData['module'] [$this->getUrl(4)]; $moduleData = $modulesData['module'][$this->getUrl(4)];
$success = file_put_contents ($tmpFolder . '/module.json', json_encode($moduleData)); $success = file_put_contents($tmpFolder . '/module.json', json_encode($moduleData));
// Le dossier du module s'il existe // Le dossier du module s'il existe
if (is_dir(self::DATA_DIR . $this->getUrl(3) . '/' . $this->getUrl(4) ) ) { if (is_dir(self::DATA_DIR . $this->getUrl(3) . '/' . $this->getUrl(4))) {
// Copier le dossier des données // Copier le dossier des données
$success .= $this->copyDir(self::DATA_DIR . $this->getUrl(3) . '/' . $this->getUrl(4), $tmpFolder); $success .= $this->copyDir(self::DATA_DIR . $this->getUrl(3) . '/' . $this->getUrl(4), $tmpFolder);
} }
// Descripteur de l'archive // Descripteur de l'archive
$infoModule = helper::getModules(); $infoModule = helper::getModules();
$success .= file_put_contents ($tmpFolder . '/descripteur.json', json_encode( [$this->getUrl(3) => $infoModule [$this->getUrl(3)]] )); $success .= file_put_contents($tmpFolder . '/descripteur.json', json_encode([$this->getUrl(3) => $infoModule[$this->getUrl(3)]]));
// création du zip // création du zip
if ($success) if ($success) {
{
$fileName = $this->getUrl(2) . '-' . $this->getUrl(3) . '-' . $this->getUrl(4) . '.zip'; $fileName = $this->getUrl(2) . '-' . $this->getUrl(3) . '-' . $this->getUrl(4) . '.zip';
$this->makeZip ($fileName, $tmpFolder); $this->makeZip($fileName, $tmpFolder);
if (file_exists($fileName)) { if (file_exists($fileName)) {
ob_start(); ob_start();
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
@ -686,7 +693,7 @@ class plugin extends common {
header('Content-Length: ' . filesize($fileName)); header('Content-Length: ' . filesize($fileName));
ob_clean(); ob_clean();
ob_end_flush(); ob_end_flush();
readfile( $fileName); readfile($fileName);
unlink($fileName); unlink($fileName);
$this->removeDir($tmpFolder); $this->removeDir($tmpFolder);
exit(); exit();
@ -705,31 +712,32 @@ class plugin extends common {
/* /*
* Importer des données d'un module externes ou interne à module.json * Importer des données d'un module externes ou interne à module.json
*/ */
public function dataImport(){ public function dataImport()
{
// Soumission du formulaire d'importation du module dans une page libre // Soumission du formulaire d'importation du module dans une page libre
if($this->isPost()) { if ($this->isPost()) {
// Récupérer le fichier et le décompacter // Récupérer le fichier et le décompacter
$zipFilename = $this->getInput('pluginImportFile', helper::FILTER_STRING_SHORT, true); $zipFilename = $this->getInput('pluginImportFile', helper::FILTER_STRING_SHORT, true);
$targetPage = $this->getInput('pluginImportPage', helper::FILTER_STRING_SHORT, true); $targetPage = $this->getInput('pluginImportPage', helper::FILTER_STRING_SHORT, true);
$tempFolder = uniqid(); $tempFolder = uniqid();
// Extraction dans un dossier temporaire // Extraction dans un dossier temporaire
mkdir (self::TEMP_DIR . $tempFolder, 0755); mkdir(self::TEMP_DIR . $tempFolder, 0755);
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open(self::FILE_DIR . 'source/' . $zipFilename) === TRUE) { if ($zip->open(self::FILE_DIR . 'source/' . $zipFilename) === TRUE) {
$zip->extractTo(self::TEMP_DIR . $tempFolder ); $zip->extractTo(self::TEMP_DIR . $tempFolder);
} }
// Lire le descripteur // Lire le descripteur
$descripteur = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/descripteur.json'), true); $descripteur = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/descripteur.json'), true);
// Lecture des données du module // Lecture des données du module
$moduleData = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/module.json'), true ); $moduleData = json_decode(file_get_contents(self::TEMP_DIR . $tempFolder . '/module.json'), true);
// Chargement des données du module importé // Chargement des données du module importé
$this->setData(['module', $targetPage, $moduleData ]); $this->setData(['module', $targetPage, $moduleData]);
// Intégration des données du module importé dans la page // Intégration des données du module importé dans la page
$this->setData(['page', $targetPage ,'moduleId', array_key_first($descripteur) ]); $this->setData(['page', $targetPage, 'moduleId', array_key_first($descripteur)]);
// Supprimer le dossier temporaire // Supprimer le dossier temporaire
$this->removeDir(self::TEMP_DIR . $tempFolder); $this->removeDir(self::TEMP_DIR . $tempFolder);
@ -745,16 +753,16 @@ class plugin extends common {
]); ]);
} }
// Bouton d'importation des données d'un module spécifique // Bouton d'importation des données d'un module spécifique
if (count(explode('/',$this->getUrl())) === 6) { if (count(explode('/', $this->getUrl())) === 6) {
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(3) !== $_SESSION['csrf']) { if ($this->getUrl(3) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'plugin', 'redirect' => helper::baseUrl() . 'plugin',
'state' => false, 'state' => false,
'notification' => 'Action non autorisée' 'notification' => 'Action non autorisée'
]); ]);
} }
// Traitement // Traitement
@ -772,10 +780,11 @@ class plugin extends common {
* et ne sont pas des barres latérales * et ne sont pas des barres latérales
*/ */
self::$pagesList = $this->getHierarchy(null, null, null); self::$pagesList = $this->getHierarchy(null, null, null);
foreach(self::$pagesList as $page => $pageId) { foreach (self::$pagesList as $page => $pageId) {
if ($this->getData(['page',$page,'block']) === 'bar' || if (
$this->getData(['page', $page, 'block']) === 'bar' ||
//$this->getData(['page',$page,'disable']) === true || //$this->getData(['page',$page,'disable']) === true ||
$this->getData(['page',$page,'moduleId']) !== '' $this->getData(['page', $page, 'moduleId']) !== ''
) { ) {
unset(self::$pagesList[$page]); unset(self::$pagesList[$page]);
} }
@ -788,7 +797,4 @@ class plugin extends common {
'view' => 'dataImport' 'view' => 'dataImport'
]); ]);
} }
} }

View File

@ -4,7 +4,7 @@
<?php echo template::button('pluginImportBack', [ <?php echo template::button('pluginImportBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'plugin', 'href' => helper::baseUrl() . 'plugin',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col2 offset9"> <div class="col2 offset9">
@ -22,14 +22,14 @@
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::file('pluginImportFile', [ <?php echo template::file('pluginImportFile', [
'label' => 'Archive ZIP :', 'label' => 'Archive ZIP :',
'type' => 2 'type' => 2
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('pluginImportPage', $module::$pagesList, [ <?php echo template::select('pluginImportPage', $module::$pagesList, [
'label' => 'Importer le module dans la page ' . template::flag('selected', '20px') 'label' => 'Importer le module dans la page ' . template::flag('selected', '20px')
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>

View File

@ -41,63 +41,63 @@
]); ?> ]); ?>
</div> </div>
<div class="tabContent" id="moduleContainer"> <div class="tabContent" id="moduleContainer">
<?php if($module::$modulesInstalled): ?> <?php if ($module::$modulesInstalled) : ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Sauvegarde'); ?> <?php echo template::topic('Sauvegarde'); ?>
</h4> </h4>
<?php echo template::table([2, 2, 1, 5, 1, 1], $module::$modulesInstalled, [ 'Module', 'Identifiant', 'Version', '', '', '']); ?> <?php echo template::table([2, 2, 1, 5, 1, 1], $module::$modulesInstalled, ['Module', 'Identifiant', 'Version', '', '', '']); ?>
</div>
</div> </div>
</div> </div>
</div> <?php else : ?>
<?php else: ?> <?php echo template::speech('Aucun module installé.'); ?>
<?php echo template::speech('Aucun module installé.'); ?>
<?php endif; ?> <?php endif; ?>
<?php if($module::$modulesOrphan): ?> <?php if ($module::$modulesOrphan) : ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Modules orphelins'); ?> <?php echo template::topic('Modules orphelins'); ?>
</h4> </h4>
<?php echo template::table([2, 2, 1, 6, 1], $module::$modulesOrphan, [ 'Module', 'Identifiant', 'Version', '', '']); ?> <?php echo template::table([2, 2, 1, 6, 1], $module::$modulesOrphan, ['Module', 'Identifiant', 'Version', '', '']); ?>
</div>
</div> </div>
</div> </div>
</div> <?php else : ?>
<?php else: ?> <?php echo template::speech('Aucun module orphelin.'); ?>
<?php echo template::speech('Aucun module orphelin.'); ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="tabContent displayNone" id="dataContainer"> <div class="tabContent displayNone" id="dataContainer">
<?php if($module::$modulesData): ?> <?php if ($module::$modulesData) : ?>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Modules configurés'); ?> <?php echo template::topic('Modules configurés'); ?>
&nbsp; &nbsp;
<?php echo template::flag( self::$i18nContent, '20px'); ?> <?php echo template::flag(self::$i18nContent, '20px'); ?>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col1 offset11"> <div class="col1 offset11">
<?php echo template::button('configModuledataImport', [ <?php echo template::button('configModuledataImport', [
'href' => helper::baseUrl() . 'plugin/dataImport', 'href' => helper::baseUrl() . 'plugin/dataImport',
'value' => template::ico('upload'), 'value' => template::ico('upload'),
"help" => 'Importer des données de module dans une page libre' "help" => 'Importer des données de module dans une page libre'
]); ?> ]); ?>
</div>
</div> </div>
</div> <div class="row">
<div class="row"> <div class="col12">
<div class="col12"> <?php echo template::table([2, 2, 1, 5, 1, 1], $module::$modulesData, ['Module', 'Identifiant', 'Version', 'Page', '', '']); ?>
<?php echo template::table([2, 2, 1, 5, 1, 1], $module::$modulesData, [ 'Module', 'Identifiant', 'Version', 'Page', '', '']); ?> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> <?php else : ?>
<?php else: ?> <?php echo template::speech('Aucune donnée de module.'); ?>
<?php echo template::speech('Aucune donnée de module.'); ?>
<?php endif; ?> <?php endif; ?>
</div> </div>

View File

@ -1,15 +1,15 @@
<div class="row"> <div class="row">
<div class="col9"> <div class="col9">
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo $module::$storeItem['content']; ?> <?php echo $module::$storeItem['content']; ?>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php <?php
echo '<img class="downloadItemPicture" src="' . $module::BASEURL_STORE . 'site/file/source/' . $module::$storeItem['picture'] . echo '<img class="downloadItemPicture" src="' . $module::BASEURL_STORE . 'site/file/source/' . $module::$storeItem['picture'] .
'" alt="' . $module::$storeItem['picture'] . '">'; '" alt="' . $module::$storeItem['picture'] . '">';
?> ?>
</div> </div>

View File

@ -7,8 +7,8 @@
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php if($module::$storeList): ?> <?php if ($module::$storeList) : ?>
<?php echo template::table([2, 2, 1, 2, 2, 1], $module::$storeList, ['Catégorie', 'Module', 'Version', 'Date', 'Page', '']); ?> <?php echo template::table([2, 2, 1, 2, 2, 1], $module::$storeList, ['Catégorie', 'Module', 'Version', 'Date', 'Page', '']); ?>
<?php else: ?> <?php else : ?>
<?php echo template::speech('Le catalogue est vide.'); ?> <?php echo template::speech('Le catalogue est vide.'); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -1,51 +1,51 @@
<?php echo template::formOpen('configModulesUpload'); ?> <?php echo template::formOpen('configModulesUpload'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('configModulesBack', [ <?php echo template::button('configModulesBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'plugin', 'href' => helper::baseUrl() . 'plugin',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col1"> <div class="col1">
<?php /**echo template::button('pluginIndexHelp', [ <?php /**echo template::button('pluginIndexHelp', [
'href' => 'https://doc.zwiicms.fr/installation-d-un-module', 'href' => 'https://doc.zwiicms.fr/installation-d-un-module',
'target' => '_blank', 'target' => '_blank',
'class' => 'buttonHelp', 'class' => 'buttonHelp',
'value' => template::ico('help'), 'value' => template::ico('help'),
'help' => 'Consulter l\'aide en ligne' 'help' => 'Consulter l\'aide en ligne'
]);*/ ?> ]);*/ ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('configModulesSubmit',[
'value' => 'Valider',
'ico' => 'check'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col2 offset8">
<div class="col12"> <?php echo template::submit('configModulesSubmit', [
<div class="block"> 'value' => 'Valider',
<h4> 'ico' => 'check'
<?php echo template::topic('Installer ou mettre à jour un module téléchargé'); ?> ]); ?>
</h4> </div>
<div class="row"> </div>
<div class="col6 offset3"> <div class="row">
<?php echo template::file('configModulesInstallation', [ <div class="col12">
'label' => 'Archive ZIP :', <div class="block">
'type' => 2 <h4>
]); ?> <?php echo template::topic('Installer ou mettre à jour un module téléchargé'); ?>
</div> </h4>
</div> <div class="row">
<div class="row"> <div class="col6 offset3">
<div class="col4 offset3"> <?php echo template::file('configModulesInstallation', [
<?php echo template::checkbox('configModulesCheck', true, 'Mise à jour forcée', [ 'label' => 'Archive ZIP :',
'checked' => false, 'type' => 2
'help' => 'Permet de forcer une mise à jour même si la version du module est inférieure ou égale à celle du module installé.', ]); ?>
]); ?> </div>
</div> </div>
</div> <div class="row">
</div> <div class="col4 offset3">
</div> <?php echo template::checkbox('configModulesCheck', true, 'Mise à jour forcée', [
</div> 'checked' => false,
<?php echo template::formClose(); ?> 'help' => 'Permet de forcer une mise à jour même si la version du module est inférieure ou égale à celle du module installé.',
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -19,7 +19,7 @@ class sitemap extends common
'index' => self::GROUP_VISITOR 'index' => self::GROUP_VISITOR
]; ];
public static $siteMap = ''; public static $siteMap = '';
/** /**
* Plan du site * Plan du site
@ -29,21 +29,61 @@ class sitemap extends common
$items = '<ul>'; $items = '<ul>';
foreach ($this->getHierarchy(null, true, null) as $parentId => $childIds) { foreach ($this->getHierarchy(null, true, null) as $parentId => $childIds) {
$items .= ' <li>'; $items .= ' <li>';
if ($this->getData(['page', $parentId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) { if ($this->getData(['page', $parentId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) {
$pageUrl = ($parentId !== $this->getData(['locale', 'homePageId'])) ? helper::baseUrl() . $parentId : helper::baseUrl(false); $pageUrl = ($parentId !== $this->getData(['locale', 'homePageId'])) ? helper::baseUrl() . $parentId : helper::baseUrl(false);
$items .= '<a href="' . $pageUrl .'">' .$this->getData(['page', $parentId, 'title']) . '</a>'; $items .= '<a href="' . $pageUrl . '">' . $this->getData(['page', $parentId, 'title']) . '</a>';
} else {
// page désactivée
$items .= $this->getData(['page', $parentId, 'title']);
}
// ou articles d'un blog
if (
$this->getData(['page', $parentId, 'moduleId']) === 'blog' &&
!empty($this->getData(['module', $parentId, 'posts']))
) {
$items .= '<ul>';
// Ids des articles par ordre de publication
$articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $parentId, 'posts']), 'publishedOn', 'SORT_DESC');
$articleIdsStates = helper::arrayColumn($this->getData(['module', $parentId, 'posts']), 'state', 'SORT_DESC');
$articleIds = [];
foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) {
$articleIds[] = $articleId;
}
}
foreach ($articleIds as $articleId => $article) {
if ($this->getData(['module', $parentId, 'posts', $article, 'state']) === true) {
$items .= ' <li>';
$items .= '<a href="' . helper::baseUrl() . $parentId . '/' . $article . '">' . $this->getData(['module', $parentId, 'posts', $article, 'title']) . '</a>';
$items .= '</li>';
}
}
$items .= '</ul>';
}
foreach ($childIds as $childId) {
$items .= '<ul>';
// Sous-page
$items .= ' <li>';
if ($this->getData(['page', $childId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) {
$pageUrl = ($childId !== $this->getData(['locale', 'homePageId'])) ? helper::baseUrl() . $childId : helper::baseUrl(false);
$items .= '<a href="' . $pageUrl . '">' . $this->getData(['page', $childId, 'title']) . '</a>';
} else { } else {
// page désactivée // page désactivée
$items .= $this->getData(['page', $parentId, 'title']); $items .= $this->getData(['page', $childId, 'title']);
} }
// ou articles d'un blog $items .= '</li>';
if ($this->getData(['page', $parentId, 'moduleId']) === 'blog' && // Articles d'une sous-page blog
!empty($this->getData(['module',$parentId, 'posts' ]))) { if (
$items .= '<ul>'; $this->getData(['page', $childId, 'moduleId']) === 'blog' &&
!empty($this->getData(['module', $childId, 'posts']))
) {
$items .= '<ul>';
// Ids des articles par ordre de publication // Ids des articles par ordre de publication
$articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $parentId,'posts']), 'publishedOn', 'SORT_DESC'); $articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $childId, 'posts']), 'publishedOn', 'SORT_DESC');
$articleIdsStates = helper::arrayColumn($this->getData(['module', $parentId, 'posts']), 'state', 'SORT_DESC'); $articleIdsStates = helper::arrayColumn($this->getData(['module', $childId, 'posts']), 'state', 'SORT_DESC');
$articleIds = []; $articleIds = [];
foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) { foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) { if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) {
@ -51,57 +91,21 @@ class sitemap extends common
} }
} }
foreach ($articleIds as $articleId => $article) { foreach ($articleIds as $articleId => $article) {
if ($this->getData(['module',$parentId,'posts',$article,'state']) === true) { if ($this->getData(['module', $childId, 'posts', $article, 'state']) === true) {
$items .= ' <li>'; $items .= ' <li>';
$items .= '<a href="' . helper::baseUrl() . $parentId. '/' . $article . '">' . $this->getData(['module',$parentId,'posts',$article,'title']) . '</a>'; $items .= '<a href="' . helper::baseUrl() . $childId . '/' . $article . '">' . $this->getData(['module', $childId, 'posts', $article, 'title']) . '</a>';
$items .= '</li>'; $items .= '</li>';
} }
} }
$items .= '</ul>'; $items .= '</ul>';
}
foreach ($childIds as $childId) {
$items .= '<ul>';
// Sous-page
$items .= ' <li>';
if ($this->getData(['page', $childId, 'disable']) === false && $this->getUser('group') >= $this->getData(['page', $parentId, 'group'])) {
$pageUrl = ($childId !== $this->getData(['locale', 'homePageId'])) ? helper::baseUrl() . $childId : helper::baseUrl(false) ;
$items .= '<a href="' . $pageUrl . '">' . $this->getData(['page', $childId, 'title']) . '</a>';
} else {
// page désactivée
$items .= $this->getData(['page', $childId, 'title']);
}
$items .= '</li>';
// Articles d'une sous-page blog
if ($this->getData(['page', $childId, 'moduleId']) === 'blog' &&
!empty($this->getData(['module', $childId, 'posts' ]))) {
$items .= '<ul>';
// Ids des articles par ordre de publication
$articleIdsPublishedOns = helper::arrayColumn($this->getData(['module', $childId,'posts']), 'publishedOn', 'SORT_DESC');
$articleIdsStates = helper::arrayColumn($this->getData(['module', $childId, 'posts']), 'state', 'SORT_DESC');
$articleIds = [];
foreach ($articleIdsPublishedOns as $articleId => $articlePublishedOn) {
if ($articlePublishedOn <= time() and $articleIdsStates[$articleId]) {
$articleIds[] = $articleId;
}
}
foreach ($articleIds as $articleId => $article) {
if ($this->getData(['module',$childId,'posts',$article,'state']) === true) {
$items .= ' <li>';
$items .= '<a href="' . helper::baseUrl() . $childId . '/' . $article . '">' . $this->getData(['module',$childId,'posts',$article,'title']) . '</a>';
$items .= '</li>';
}
}
$items .= '</ul>';
}
$items .= '</ul>';
} }
$items .= '</ul>';
}
$items .= '</li>'; $items .= '</li>';
} }
// Fin du grand bloc // Fin du grand bloc
$items .= '</ul>'; $items .= '</ul>';
self::$siteMap = $items; self::$siteMap = $items;
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([

View File

@ -1,4 +1,4 @@
<?php <?php
echo "<div id='siteMap'>"; echo "<div id='siteMap'>";
echo $module::$siteMap; echo $module::$siteMap;
echo "</div>"; echo "</div>";

View File

@ -14,7 +14,8 @@
* @copyright Copyright (C) 2018-2022, Frédéric Tempez * @copyright Copyright (C) 2018-2022, Frédéric Tempez
*/ */
class theme extends common { class theme extends common
{
public static $actions = [ public static $actions = [
'advanced' => self::GROUP_ADMIN, 'advanced' => self::GROUP_ADMIN,
@ -51,21 +52,25 @@ class theme extends common {
public static $footerblocks = [ public static $footerblocks = [
1 => [ 1 => [
'hide' => 'Masqué', 'hide' => 'Masqué',
'center' => 'Affiché' ], 'center' => 'Affiché'
],
2 => [ 2 => [
'hide' => 'Masqué', 'hide' => 'Masqué',
'left' => 'À gauche', 'left' => 'À gauche',
'right' => 'À droite' ], 'right' => 'À droite'
],
3 => [ 3 => [
'hide' => 'Masqué', 'hide' => 'Masqué',
'left' => 'À gauche', 'left' => 'À gauche',
'center' => 'Au centre', 'center' => 'Au centre',
'right' => 'À droite' ], 'right' => 'À droite'
],
4 => [ 4 => [
'hide' => 'Masqué', 'hide' => 'Masqué',
'left' => 'En haut', 'left' => 'En haut',
'center' => 'Au milieu', 'center' => 'Au milieu',
'right' => 'En bas' ] 'right' => 'En bas'
]
]; ];
public static $fontWeights = [ public static $fontWeights = [
@ -232,7 +237,7 @@ class theme extends common {
// Variable pour construire la liste des pages du site // Variable pour construire la liste des pages du site
public static $pagesList = []; public static $pagesList = [];
// Variable pour construire la liste des fontes installées // Variable pour construire la liste des fontes installées
public static $fontsNames= []; public static $fontsNames = [];
public static $fonts = []; public static $fonts = [];
// Variable pour détailler les fontes installées // Variable pour détailler les fontes installées
public static $fontsDetail = []; public static $fontsDetail = [];
@ -240,9 +245,10 @@ class theme extends common {
/** /**
* Thème des écrans d'administration * Thème des écrans d'administration
*/ */
public function admin() { public function admin()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
$this->setData(['admin', [ $this->setData(['admin', [
'backgroundColor' => $this->getInput('adminBackgroundColor'), 'backgroundColor' => $this->getInput('adminBackgroundColor'),
'colorTitle' => $this->getInput('adminColorTitle'), 'colorTitle' => $this->getInput('adminColorTitle'),
@ -251,8 +257,8 @@ class theme extends common {
'backgroundColorButton' => $this->getInput('adminColorButton'), 'backgroundColorButton' => $this->getInput('adminColorButton'),
'backgroundColorButtonGrey' => $this->getInput('adminColorGrey'), 'backgroundColorButtonGrey' => $this->getInput('adminColorGrey'),
'backgroundColorButtonRed' => $this->getInput('adminColorRed'), 'backgroundColorButtonRed' => $this->getInput('adminColorRed'),
'backgroundColorButtonGreen'=> $this->getInput('adminColorGreen'), 'backgroundColorButtonGreen' => $this->getInput('adminColorGreen'),
'backgroundColorButtonHelp'=> $this->getInput('adminColorHelp'), 'backgroundColorButtonHelp' => $this->getInput('adminColorHelp'),
'fontText' => $this->getInput('adminFontText'), 'fontText' => $this->getInput('adminFontText'),
'fontSize' => $this->getInput('adminFontTextSize'), 'fontSize' => $this->getInput('adminFontTextSize'),
'fontTitle' => $this->getInput('adminFontTitle'), 'fontTitle' => $this->getInput('adminFontTitle'),
@ -283,11 +289,12 @@ class theme extends common {
/** /**
* Mode avancé * Mode avancé
*/ */
public function advanced() { public function advanced()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Enregistre le CSS // Enregistre le CSS
file_put_contents(self::DATA_DIR.'custom.css', $this->getInput('themeAdvancedCss', null)); file_put_contents(self::DATA_DIR . 'custom.css', $this->getInput('themeAdvancedCss', null));
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Modifications enregistrées', 'notification' => 'Modifications enregistrées',
@ -308,9 +315,10 @@ class theme extends common {
/** /**
* Options de l'arrière plan * Options de l'arrière plan
*/ */
public function body() { public function body()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
$this->setData(['theme', 'body', [ $this->setData(['theme', 'body', [
'backgroundColor' => $this->getInput('themeBodyBackgroundColor'), 'backgroundColor' => $this->getInput('themeBodyBackgroundColor'),
'image' => $this->getInput('themeBodyImage'), 'image' => $this->getInput('themeBodyImage'),
@ -341,12 +349,15 @@ class theme extends common {
/** /**
* Options du pied de page * Options du pied de page
*/ */
public function footer() { public function footer()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
if ( $this->getInput('themeFooterCopyrightPosition') === 'hide' && if (
$this->getInput('themeFooterSocialsPosition') === 'hide' && $this->getInput('themeFooterCopyrightPosition') === 'hide' &&
$this->getInput('themeFooterTextPosition') === 'hide' ) { $this->getInput('themeFooterSocialsPosition') === 'hide' &&
$this->getInput('themeFooterTextPosition') === 'hide'
) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Sélectionnez au moins un contenu à afficher', 'notification' => 'Sélectionnez au moins un contenu à afficher',
@ -379,13 +390,13 @@ class theme extends common {
'displayCookie' => $this->getInput('themefooterDisplayCookie', helper::FILTER_BOOLEAN), 'displayCookie' => $this->getInput('themefooterDisplayCookie', helper::FILTER_BOOLEAN),
'displayLegal' => $this->getInput('themeFooterDisplayLegal', helper::FILTER_BOOLEAN), 'displayLegal' => $this->getInput('themeFooterDisplayLegal', helper::FILTER_BOOLEAN),
'displaySearch' => $this->getInput('themeFooterDisplaySearch', helper::FILTER_BOOLEAN), 'displaySearch' => $this->getInput('themeFooterDisplaySearch', helper::FILTER_BOOLEAN),
'memberBar'=> $this->getInput('themeFooterMemberBar', helper::FILTER_BOOLEAN), 'memberBar' => $this->getInput('themeFooterMemberBar', helper::FILTER_BOOLEAN),
'template' => $this->getInput('themeFooterTemplate') 'template' => $this->getInput('themeFooterTemplate')
]]); ]]);
// Sauvegarder la configuration localisée // Sauvegarder la configuration localisée
$this->setData(['locale','legalPageId', $this->getInput('configLegalPageId')]); $this->setData(['locale', 'legalPageId', $this->getInput('configLegalPageId')]);
$this->setData(['locale','searchPageId', $this->getInput('configSearchPageId')]); $this->setData(['locale', 'searchPageId', $this->getInput('configSearchPageId')]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -398,9 +409,11 @@ class theme extends common {
// Liste des pages // Liste des pages
self::$pagesList = $this->getData(['page']); self::$pagesList = $this->getData(['page']);
foreach(self::$pagesList as $page => $pageId) { foreach (self::$pagesList as $page => $pageId) {
if ($this->getData(['page',$page,'block']) === 'bar' || if (
$this->getData(['page',$page,'disable']) === true) { $this->getData(['page', $page, 'block']) === 'bar' ||
$this->getData(['page', $page, 'disable']) === true
) {
unset(self::$pagesList[$page]); unset(self::$pagesList[$page]);
} }
} }
@ -422,21 +435,22 @@ class theme extends common {
/** /**
* Options de la bannière * Options de la bannière
*/ */
public function header() { public function header()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Modification des URL des images dans la bannière perso // Modification des URL des images dans la bannière perso
$featureContent = $this->getInput('themeHeaderText', null); $featureContent = $this->getInput('themeHeaderText', null);
/** /**
* Stocker les images incluses dans la bannière perso dans un tableau * Stocker les images incluses dans la bannière perso dans un tableau
*/ */
$files = []; $files = [];
preg_match_all('/<img[^>]+>/i',$featureContent, $results); preg_match_all('/<img[^>]+>/i', $featureContent, $results);
foreach($results[0] as $value) { foreach ($results[0] as $value) {
// Lire le contenu XML // Lire le contenu XML
$sx = simplexml_load_string($value); $sx = simplexml_load_string($value);
// Élément à remplacer // Élément à remplacer
$files [] = str_replace('./site/file/source/','',(string) $sx[0]['src']); $files[] = str_replace('./site/file/source/', '', (string) $sx[0]['src']);
} }
// Sauvegarder // Sauvegarder
@ -456,7 +470,7 @@ class theme extends common {
'textColor' => $this->getInput('themeHeaderTextColor'), 'textColor' => $this->getInput('themeHeaderTextColor'),
'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN), 'textHide' => $this->getInput('themeHeaderTextHide', helper::FILTER_BOOLEAN),
'textTransform' => $this->getInput('themeHeaderTextTransform'), 'textTransform' => $this->getInput('themeHeaderTextTransform'),
'linkHomePage' => $this->getInput('themeHeaderlinkHomePage',helper::FILTER_BOOLEAN), 'linkHomePage' => $this->getInput('themeHeaderlinkHomePage', helper::FILTER_BOOLEAN),
'imageContainer' => $this->getInput('themeHeaderImageContainer'), 'imageContainer' => $this->getInput('themeHeaderImageContainer'),
'tinyHidden' => $this->getInput('themeHeaderTinyHidden', helper::FILTER_BOOLEAN), 'tinyHidden' => $this->getInput('themeHeaderTinyHidden', helper::FILTER_BOOLEAN),
'feature' => $this->getInput('themeHeaderFeature'), 'feature' => $this->getInput('themeHeaderFeature'),
@ -464,19 +478,18 @@ class theme extends common {
'featureFiles' => $files 'featureFiles' => $files
]]); ]]);
// Modification de la position du menu selon la position de la bannière // Modification de la position du menu selon la position de la bannière
if ( $this->getData(['theme','header','position']) == 'site' ) if ($this->getData(['theme', 'header', 'position']) == 'site') {
{ $this->setData(['theme', 'menu', 'position', str_replace('body-', 'site-', $this->getData(['theme', 'menu', 'position']))]);
$this->setData(['theme', 'menu', 'position',str_replace ('body-','site-',$this->getData(['theme','menu','position']))]);
} }
if ( $this->getData(['theme','header','position']) == 'body') if ($this->getData(['theme', 'header', 'position']) == 'body') {
{ $this->setData(['theme', 'menu', 'position', str_replace('site-', 'body-', $this->getData(['theme', 'menu', 'position']))]);
$this->setData(['theme', 'menu', 'position',str_replace ('site-','body-',$this->getData(['theme','menu','position']))]);
} }
// Menu accroché à la bannière qui devient cachée // Menu accroché à la bannière qui devient cachée
if ( $this->getData(['theme','header','position']) == 'hide' && if (
in_array( $this->getData(['theme','menu','position']) , ['body-first', 'site-first', 'body-first' , 'site-second']) $this->getData(['theme', 'header', 'position']) == 'hide' &&
) { in_array($this->getData(['theme', 'menu', 'position']), ['body-first', 'site-first', 'body-first', 'site-second'])
$this->setData(['theme', 'menu', 'position','site']); ) {
$this->setData(['theme', 'menu', 'position', 'site']);
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -503,7 +516,8 @@ class theme extends common {
/** /**
* Accueil de la personnalisation * Accueil de la personnalisation
*/ */
public function index() { public function index()
{
// Restaurer les fontes utilisateurs // Restaurer les fontes utilisateurs
$this->setFonts('user'); $this->setFonts('user');
@ -518,9 +532,10 @@ class theme extends common {
/** /**
* Options du menu * Options du menu
*/ */
public function menu() { public function menu()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
$this->setData(['theme', 'menu', [ $this->setData(['theme', 'menu', [
'backgroundColor' => $this->getInput('themeMenuBackgroundColor'), 'backgroundColor' => $this->getInput('themeMenuBackgroundColor'),
'backgroundColorSub' => $this->getInput('themeMenuBackgroundColorSub'), 'backgroundColorSub' => $this->getInput('themeMenuBackgroundColorSub'),
@ -569,27 +584,28 @@ class theme extends common {
/** /**
* Options des fontes * Options des fontes
*/ */
public function fonts() { public function fonts()
{
// Toutes les fontes installées sont chargées // Toutes les fontes installées sont chargées
$this->setFonts('all'); $this->setFonts('all');
// Polices liées au thème // Polices liées au thème
$used = [ $used = [
'Bannière' => $this->getData (['theme', 'header', 'font']), 'Bannière' => $this->getData(['theme', 'header', 'font']),
'Menu' => $this->getData (['theme', 'menu', 'font']), 'Menu' => $this->getData(['theme', 'menu', 'font']),
'Titre ' => $this->getData (['theme', 'title', 'font']), 'Titre ' => $this->getData(['theme', 'title', 'font']),
'Texte' => $this->getData (['theme', 'text', 'font']), 'Texte' => $this->getData(['theme', 'text', 'font']),
'Pied de page' => $this->getData (['theme', 'footer', 'font']), 'Pied de page' => $this->getData(['theme', 'footer', 'font']),
'Titre (admin)' => $this->getData (['admin', 'fontTitle' ]), 'Titre (admin)' => $this->getData(['admin', 'fontTitle']),
'Admin (texte)' => $this->getData (['admin', 'fontText' ]) 'Admin (texte)' => $this->getData(['admin', 'fontText'])
]; ];
// Récupérer le détail des fontes installées // Récupérer le détail des fontes installées
//$f = $this->getFonts(); //$f = $this->getFonts();
$f ['files'] = $this->getData(['fonts', 'files']); $f['files'] = $this->getData(['fonts', 'files']);
$f ['imported'] = $this->getData(['fonts', 'imported']); $f['imported'] = $this->getData(['fonts', 'imported']);
$f ['websafe'] = self::$fontsWebSafe; $f['websafe'] = self::$fontsWebSafe;
// Parcourir les fontes disponibles et construire le tableau pour le formulaire // Parcourir les fontes disponibles et construire le tableau pour le formulaire
foreach ($f as $type => $typeValue) { foreach ($f as $type => $typeValue) {
@ -598,30 +614,30 @@ class theme extends common {
// Fontes utilisées par les thèmes // Fontes utilisées par les thèmes
$fontUsed[$fontId] = ''; $fontUsed[$fontId] = '';
foreach ($used as $key => $value) { foreach ($used as $key => $value) {
if ( $value === $fontId) { if ($value === $fontId) {
$fontUsed[$fontId] .= $key . '<br/>'; $fontUsed[$fontId] .= $key . '<br/>';
} }
} }
self::$fontsDetail [] = [ self::$fontsDetail[] = [
$fontId, $fontId,
'<span style="font-family:' . $f[$type][$fontId]['font-family'] . '">' . $f[$type][$fontId]['name'] . '</span>' , '<span style="font-family:' . $f[$type][$fontId]['font-family'] . '">' . $f[$type][$fontId]['name'] . '</span>',
$f[$type][$fontId]['font-family'], $f[$type][$fontId]['font-family'],
$fontUsed[$fontId], $fontUsed[$fontId],
$type, $type,
$type !== 'websafe' ? template::button('themeFontEdit' . $fontId, [ $type !== 'websafe' ? template::button('themeFontEdit' . $fontId, [
'class' => 'themeFontEdit', 'class' => 'themeFontEdit',
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontEdit/' . $type . '/' . $fontId . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/fontEdit/' . $type . '/' . $fontId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil'), 'value' => template::ico('pencil'),
'disabled' => !empty($fontUsed[$fontId]) 'disabled' => !empty($fontUsed[$fontId])
]) ])
: '', : '',
$type !== 'websafe' ? template::button('themeFontDelete' . $fontId, [ $type !== 'websafe' ? template::button('themeFontDelete' . $fontId, [
'class' => 'themeFontDelete buttonRed', 'class' => 'themeFontDelete buttonRed',
'href' => helper::baseUrl() . $this->getUrl(0) . '/fontDelete/' . $type . '/' . $fontId . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/fontDelete/' . $type . '/' . $fontId . '/' . $_SESSION['csrf'],
'value' => template::ico('cancel'), 'value' => template::ico('cancel'),
'disabled' => !empty($fontUsed[$fontId]) 'disabled' => !empty($fontUsed[$fontId])
]) ])
: '' : ''
]; ];
} }
} }
@ -637,14 +653,15 @@ class theme extends common {
/** /**
* Ajouter une fonte * Ajouter une fonte
*/ */
public function fontAdd() { public function fontAdd()
{
// Soumission du formulaire // Soumission du formulaire
if ($this->isPost()) { if ($this->isPost()) {
// Type d'import en ligne ou local // Type d'import en ligne ou local
$type = $this->getInput('fontAddFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; $type = $this->getInput('fontAddFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files';
$typeFlip = $type === 'files' ? 'imported' : 'files'; $typeFlip = $type === 'files' ? 'imported' : 'files';
$ressource = $type === 'imported' ? $this->getInput('fontAddUrl', null) : $this->getInput('fontAddFile', null); $ressource = $type === 'imported' ? $this->getInput('fontAddUrl', null) : $this->getInput('fontAddFile', null);
if (!empty($ressource) ) { if (!empty($ressource)) {
$fontId = $this->getInput('fontAddFontId', null, true); $fontId = $this->getInput('fontAddFontId', null, true);
$fontName = $this->getInput('fontAddFontName', null, true); $fontName = $this->getInput('fontAddFontName', null, true);
$fontFamilyName = $this->getInput('fontAddFontFamilyName', null, true); $fontFamilyName = $this->getInput('fontAddFontFamilyName', null, true);
@ -653,24 +670,27 @@ class theme extends common {
$fontFamilyName = str_replace('"', '\'', $fontFamilyName); $fontFamilyName = str_replace('"', '\'', $fontFamilyName);
// Supprime la fonte si elle existe dans le type inverse // Supprime la fonte si elle existe dans le type inverse
if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) { if (is_array($this->getData(['fonts', $typeFlip, $fontId]))) {
$this->deleteData(['fonts', $typeFlip, $fontId ]); $this->deleteData(['fonts', $typeFlip, $fontId]);
} }
// Stocker la fonte // Stocker la fonte
$this->setData(['fonts', $this->setData([
$type, 'fonts',
$fontId, [ $type,
'name' => $fontName, $fontId, [
'font-family' => $fontFamilyName, 'name' => $fontName,
'resource' => $ressource 'font-family' => $fontFamilyName,
]]); 'resource' => $ressource
]
]);
// Copier la fonte si le nom du fichier est fourni // Copier la fonte si le nom du fichier est fourni
if ( $type === 'files' && if (
file_exists(self::FILE_DIR . 'source/' . $ressource) $type === 'files' &&
file_exists(self::FILE_DIR . 'source/' . $ressource)
) { ) {
copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource ); copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource);
} }
// Valeurs en sortie // Valeurs en sortie
@ -699,7 +719,8 @@ class theme extends common {
/** /**
* Ajouter une fonte * Ajouter une fonte
*/ */
public function fontEdit() { public function fontEdit()
{
// Soumission du formulaire // Soumission du formulaire
if ($this->isPost()) { if ($this->isPost()) {
// Type d'import en ligne ou local // Type d'import en ligne ou local
@ -707,29 +728,32 @@ class theme extends common {
$typeFlip = $type === 'files' ? 'imported' : 'files'; $typeFlip = $type === 'files' ? 'imported' : 'files';
$ressource = $type === 'imported' ? $this->getInput('fontEditUrl', null) : $this->getInput('fontEditFile', null); $ressource = $type === 'imported' ? $this->getInput('fontEditUrl', null) : $this->getInput('fontEditFile', null);
$fontId = $this->getInput('fontEditFontId', null, true); $fontId = $this->getInput('fontEditFontId', null, true);
$fontName = $this->getInput('fontEditFontName', null , true); $fontName = $this->getInput('fontEditFontName', null, true);
$fontFamilyName = $this->getInput('fontEditFontFamilyName', null, true); $fontFamilyName = $this->getInput('fontEditFontFamilyName', null, true);
// Remplace les doubles quotes par des simples quotes // Remplace les doubles quotes par des simples quotes
$fontFamilyName = str_replace('"', '\'', $fontFamilyName); $fontFamilyName = str_replace('"', '\'', $fontFamilyName);
// Supprime la fonte si elle existe dans le type inverse // Supprime la fonte si elle existe dans le type inverse
if (is_array($this->getData(['fonts', $typeFlip, $fontId])) ) { if (is_array($this->getData(['fonts', $typeFlip, $fontId]))) {
$this->deleteData(['fonts', $typeFlip, $fontId ]); $this->deleteData(['fonts', $typeFlip, $fontId]);
} }
// Stocker les fontes // Stocker les fontes
$this->setData(['fonts', $this->setData([
$type, 'fonts',
$fontId, [ $type,
'name' => $fontName, $fontId, [
'font-family' => $fontFamilyName, 'name' => $fontName,
'resource' => $ressource 'font-family' => $fontFamilyName,
]]); 'resource' => $ressource
]
]);
// Copier la fonte si le nom du fichier est fourni // Copier la fonte si le nom du fichier est fourni
if ( $type === 'files' && if (
file_exists(self::FILE_DIR . 'source/' . $ressource) $type === 'files' &&
file_exists(self::FILE_DIR . 'source/' . $ressource)
) { ) {
copy ( self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource ); copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'fonts/' . $ressource);
} }
// Valeurs en sortie // Valeurs en sortie
@ -749,7 +773,8 @@ class theme extends common {
/** /**
* Effacer une fonte * Effacer une fonte
*/ */
public function fontDelete() { public function fontDelete()
{
// Jeton incorrect // Jeton incorrect
if ($this->getUrl(4) !== $_SESSION['csrf']) { if ($this->getUrl(4) !== $_SESSION['csrf']) {
// Valeurs en sortie // Valeurs en sortie
@ -765,8 +790,10 @@ class theme extends common {
$this->deleteData(['fonts', $this->getUrl(2), $this->getUrl(3)]); $this->deleteData(['fonts', $this->getUrl(2), $this->getUrl(3)]);
// Effacer le fichier existant // Effacer le fichier existant
if ( $this->getUrl(2) === 'file' && if (
file_exists(self::DATA_DIR . $this->getUrl(2)) ) { $this->getUrl(2) === 'file' &&
file_exists(self::DATA_DIR . $this->getUrl(2))
) {
unlink(self::DATA_DIR . $this->getUrl(2)); unlink(self::DATA_DIR . $this->getUrl(2));
} }
@ -783,15 +810,17 @@ class theme extends common {
/** /**
* Réinitialisation de la personnalisation avancée * Réinitialisation de la personnalisation avancée
*/ */
public function reset() { public function reset()
{
// $url prend l'adresse sans le token // $url prend l'adresse sans le token
$url = explode('&',$this->getUrl(2)); $url = explode('&', $this->getUrl(2));
if ( isset($_GET['csrf']) if (
AND $_GET['csrf'] === $_SESSION['csrf'] isset($_GET['csrf'])
) { and $_GET['csrf'] === $_SESSION['csrf']
) {
// Réinitialisation // Réinitialisation
$redirect =''; $redirect = '';
switch ($url[0]) { switch ($url[0]) {
case 'admin': case 'admin':
$this->initData('admin', self::$i18nUI); $this->initData('admin', self::$i18nUI);
@ -802,10 +831,10 @@ class theme extends common {
$redirect = helper::baseUrl() . 'theme/manage'; $redirect = helper::baseUrl() . 'theme/manage';
break; break;
case 'custom': case 'custom':
unlink(self::DATA_DIR.'custom.css'); unlink(self::DATA_DIR . 'custom.css');
$redirect = helper::baseUrl() . 'theme/advanced'; $redirect = helper::baseUrl() . 'theme/advanced';
break; break;
default : default:
$redirect = helper::baseUrl() . 'theme'; $redirect = helper::baseUrl() . 'theme';
} }
@ -827,9 +856,10 @@ class theme extends common {
/** /**
* Options du site * Options du site
*/ */
public function site() { public function site()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
$this->setData(['theme', 'title', [ $this->setData(['theme', 'title', [
'font' => $this->getInput('themeTitleFont'), 'font' => $this->getInput('themeTitleFont'),
'textColor' => $this->getInput('themeTitleTextColor'), 'textColor' => $this->getInput('themeTitleTextColor'),
@ -840,14 +870,14 @@ class theme extends common {
'font' => $this->getInput('themeTextFont'), 'font' => $this->getInput('themeTextFont'),
'fontSize' => $this->getInput('themeTextFontSize'), 'fontSize' => $this->getInput('themeTextFontSize'),
'textColor' => $this->getInput('themeTextTextColor'), 'textColor' => $this->getInput('themeTextTextColor'),
'linkColor'=> $this->getInput('themeTextLinkColor') 'linkColor' => $this->getInput('themeTextLinkColor')
]]); ]]);
$this->setData(['theme', 'site', [ $this->setData(['theme', 'site', [
'backgroundColor' => $this->getInput('themeSiteBackgroundColor'), 'backgroundColor' => $this->getInput('themeSiteBackgroundColor'),
'radius' => $this->getInput('themeSiteRadius'), 'radius' => $this->getInput('themeSiteRadius'),
'shadow' => $this->getInput('themeSiteShadow'), 'shadow' => $this->getInput('themeSiteShadow'),
'width' => $this->getInput('themeSiteWidth'), 'width' => $this->getInput('themeSiteWidth'),
'margin' => $this->getInput('themeSiteMargin',helper::FILTER_BOOLEAN) 'margin' => $this->getInput('themeSiteMargin', helper::FILTER_BOOLEAN)
]]); ]]);
$this->setData(['theme', 'button', [ $this->setData(['theme', 'button', [
'backgroundColor' => $this->getInput('themeButtonBackgroundColor') 'backgroundColor' => $this->getInput('themeButtonBackgroundColor')
@ -881,11 +911,12 @@ class theme extends common {
/** /**
* Import du thème * Import du thème
*/ */
public function manage() { public function manage()
if($this->isPost() ) { {
if ($this->isPost()) {
$zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true); $zipFilename = $this->getInput('themeManageImport', helper::FILTER_STRING_SHORT, true);
$data = $this->import(self::FILE_DIR.'source/' . $zipFilename); $data = $this->import(self::FILE_DIR . 'source/' . $zipFilename);
if ($data['success']) { if ($data['success']) {
header("Refresh:0"); header("Refresh:0");
} else { } else {
@ -911,10 +942,13 @@ class theme extends common {
* @param @return array contenant $success = true ou false ; $ notification string message à afficher * @param @return array contenant $success = true ou false ; $ notification string message à afficher
*/ */
public function import($zipName = '') { public function import($zipName = '')
{
if ($zipName !== '' && if (
file_exists($zipName)) { $zipName !== '' &&
file_exists($zipName)
) {
// Init variables de retour // Init variables de retour
$success = false; $success = false;
$notification = ''; $notification = '';
@ -923,26 +957,24 @@ class theme extends common {
// Ouvrir le zip // Ouvrir le zip
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open($zipName) === TRUE) { if ($zip->open($zipName) === TRUE) {
mkdir (self::TEMP_DIR . $tempFolder, 0755); mkdir(self::TEMP_DIR . $tempFolder, 0755);
$zip->extractTo(self::TEMP_DIR . $tempFolder ); $zip->extractTo(self::TEMP_DIR . $tempFolder);
$modele = ''; $modele = '';
// Archive de thème ? // Archive de thème ?
if ( if (
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css') file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css')
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css') and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css')
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json') and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json')
) { ) {
$modele = 'theme'; $modele = 'theme';
} }
if( if (
file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json') file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.json')
AND file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css') and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/admin.css')
) { ) {
$modele = 'admin'; $modele = 'admin';
} }
if (!empty($modele) if (!empty($modele)) {
) {
// traiter l'archive // traiter l'archive
$success = $zip->extractTo('.'); $success = $zip->extractTo('.');
@ -950,26 +982,26 @@ class theme extends common {
if ($modele = 'theme') { if ($modele = 'theme') {
$c = $this->subFonts(self::DATA_DIR . 'theme.json'); $c = $this->subFonts(self::DATA_DIR . 'theme.json');
// Un remplacement nécessite la régénération de la feuille de style // Un remplacement nécessite la régénération de la feuille de style
if ($c > 0 if (
AND file_exists(self::DATA_DIR . 'theme.css') $c > 0
and file_exists(self::DATA_DIR . 'theme.css')
) { ) {
unlink(self::DATA_DIR . 'theme.css'); unlink(self::DATA_DIR . 'theme.css');
} }
} }
if ($modele = 'admin') { if ($modele = 'admin') {
$c = $this->subFonts(self::DATA_DIR . 'admin.json'); $c = $this->subFonts(self::DATA_DIR . 'admin.json');
// Un remplacement nécessite la régénération de la feuille de style // Un remplacement nécessite la régénération de la feuille de style
if ($c > 0 if (
AND file_exists(self::DATA_DIR . 'admin.css') $c > 0
) { and file_exists(self::DATA_DIR . 'admin.css')
unlink(self::DATA_DIR . 'admin.css'); ) {
unlink(self::DATA_DIR . 'admin.css');
} }
} }
// traitement d'erreur // traitement d'erreur
$notification = $success ? 'Le thème a été importé' : 'Erreur lors de l\'extraction, vérifiez les permissions.'; $notification = $success ? 'Le thème a été importé' : 'Erreur lors de l\'extraction, vérifiez les permissions.';
} else { } else {
// pas une archive de thème // pas une archive de thème
$success = false; $success = false;
@ -994,37 +1026,39 @@ class theme extends common {
/** /**
* Export du thème * Export du thème
*/ */
public function export() { public function export()
{
// Make zip // Make zip
$zipFilename = $this->zipTheme($this->getUrl(2)); $zipFilename = $this->zipTheme($this->getUrl(2));
// Téléchargement du ZIP // Téléchargement du ZIP
header('Content-Description: File Transfer'); header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary'); header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $zipFilename . '"'); header('Content-Disposition: attachment; filename="' . $zipFilename . '"');
header('Content-Length: ' . filesize(self::TEMP_DIR . $zipFilename)); header('Content-Length: ' . filesize(self::TEMP_DIR . $zipFilename));
readfile(self::TEMP_DIR . $zipFilename); readfile(self::TEMP_DIR . $zipFilename);
// Nettoyage du dossier // Nettoyage du dossier
unlink (self::TEMP_DIR . $zipFilename); unlink(self::TEMP_DIR . $zipFilename);
exit(); exit();
} }
/** /**
* Export du thème * Export du thème
*/ */
public function save() { public function save()
{
// Make zip // Make zip
$zipFilename = $this->zipTheme($this->getUrl(2)); $zipFilename = $this->zipTheme($this->getUrl(2));
// Téléchargement du ZIP // Téléchargement du ZIP
if (!is_dir(self::FILE_DIR.'source/theme')) { if (!is_dir(self::FILE_DIR . 'source/theme')) {
mkdir(self::FILE_DIR.'source/theme', 0755); mkdir(self::FILE_DIR . 'source/theme', 0755);
} }
copy (self::TEMP_DIR . $zipFilename , self::FILE_DIR.'source/theme/' . $zipFilename); copy(self::TEMP_DIR . $zipFilename, self::FILE_DIR . 'source/theme/' . $zipFilename);
// Nettoyage du dossier // Nettoyage du dossier
unlink (self::TEMP_DIR . $zipFilename); unlink(self::TEMP_DIR . $zipFilename);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Archive <b>'.$zipFilename.'</b> sauvegardée avec succès', 'notification' => 'Archive <b>' . $zipFilename . '</b> sauvegardée avec succès',
'redirect' => helper::baseUrl() . 'theme/manage', 'redirect' => helper::baseUrl() . 'theme/manage',
'state' => true 'state' => true
]); ]);
@ -1034,58 +1068,63 @@ class theme extends common {
* construction du zip Fonction appelée par export() et save() * construction du zip Fonction appelée par export() et save()
* @param string $modele theme ou admin * @param string $modele theme ou admin
*/ */
private function zipTheme($modele) { private function zipTheme($modele)
{
// Creation du dossier // Creation du dossier
$zipFilename = $modele . date('Y-m-d-H-i-s', time()) . '.zip'; $zipFilename = $modele . date('Y-m-d-H-i-s', time()) . '.zip';
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE ) === TRUE) { if ($zip->open(self::TEMP_DIR . $zipFilename, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
switch ($modele) { switch ($modele) {
case 'admin': case 'admin':
$zip->addFile(self::DATA_DIR.'admin.json',self::DATA_DIR.'admin.json'); $zip->addFile(self::DATA_DIR . 'admin.json', self::DATA_DIR . 'admin.json');
$zip->addFile(self::DATA_DIR.'admin.css',self::DATA_DIR.'admin.css'); $zip->addFile(self::DATA_DIR . 'admin.css', self::DATA_DIR . 'admin.css');
// Ajoute les fontes // Ajoute les fontes
$zip->addEmptyDir(self::DATA_DIR .'fonts'); $zip->addEmptyDir(self::DATA_DIR . 'fonts');
$fonts = $this->getData(['fonts', 'files']); $fonts = $this->getData(['fonts', 'files']);
foreach ($fonts as $fontId => $fontName) { foreach ($fonts as $fontId => $fontName) {
$zip->addFile(self::DATA_DIR .'fonts/' . $fontName, self::DATA_DIR.'fonts/' . $fontName); $zip->addFile(self::DATA_DIR . 'fonts/' . $fontName, self::DATA_DIR . 'fonts/' . $fontName);
} }
if (file_exists(self::DATA_DIR .'fonts/fonts.html')) { if (file_exists(self::DATA_DIR . 'fonts/fonts.html')) {
$zip->addFile(self::DATA_DIR .'fonts/fonts.html', self::DATA_DIR .'fonts/fonts.html'); $zip->addFile(self::DATA_DIR . 'fonts/fonts.html', self::DATA_DIR . 'fonts/fonts.html');
} }
break; break;
case 'theme': case 'theme':
$zip->addFile(self::DATA_DIR.'theme.json',self::DATA_DIR.'theme.json'); $zip->addFile(self::DATA_DIR . 'theme.json', self::DATA_DIR . 'theme.json');
$zip->addFile(self::DATA_DIR.'theme.css',self::DATA_DIR.'theme.css'); $zip->addFile(self::DATA_DIR . 'theme.css', self::DATA_DIR . 'theme.css');
$zip->addFile(self::DATA_DIR.'custom.css',self::DATA_DIR.'custom.css'); $zip->addFile(self::DATA_DIR . 'custom.css', self::DATA_DIR . 'custom.css');
// Traite l'image dans le body // Traite l'image dans le body
if ($this->getData(['theme','body','image']) !== '' ) { if ($this->getData(['theme', 'body', 'image']) !== '') {
$zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','body','image']), $zip->addFile(
self::FILE_DIR.'source/'.$this->getData(['theme','body','image']) self::FILE_DIR . 'source/' . $this->getData(['theme', 'body', 'image']),
); self::FILE_DIR . 'source/' . $this->getData(['theme', 'body', 'image'])
);
} }
// Traite l'image dans le header // Traite l'image dans le header
if ($this->getData(['theme','header','image']) !== '' ) { if ($this->getData(['theme', 'header', 'image']) !== '') {
$zip->addFile(self::FILE_DIR.'source/'.$this->getData(['theme','header','image']), $zip->addFile(
self::FILE_DIR.'source/'.$this->getData(['theme','header','image']) self::FILE_DIR . 'source/' . $this->getData(['theme', 'header', 'image']),
); self::FILE_DIR . 'source/' . $this->getData(['theme', 'header', 'image'])
);
} }
// Traite les images du header perso // Traite les images du header perso
if (!empty($this->getData(['theme','header','featureFiles'])) ) { if (!empty($this->getData(['theme', 'header', 'featureFiles']))) {
foreach($this->getData(['theme','header','featureFiles']) as $value) { foreach ($this->getData(['theme', 'header', 'featureFiles']) as $value) {
$zip->addFile(self::FILE_DIR . 'source/' . $value, $zip->addFile(
self::FILE_DIR . 'source/' . $value ); self::FILE_DIR . 'source/' . $value,
self::FILE_DIR . 'source/' . $value
);
} }
} }
// Ajoute les fontes // Ajoute les fontes
$zip->addEmptyDir(self::DATA_DIR .'fonts'); $zip->addEmptyDir(self::DATA_DIR . 'fonts');
$fonts = $this->getData(['fonts', 'files']); $fonts = $this->getData(['fonts', 'files']);
foreach ($fonts as $fontId => $fontName) { foreach ($fonts as $fontId => $fontName) {
$zip->addFile(self::DATA_DIR .'fonts/' . $fontName, self::DATA_DIR.'fonts/' . $fontName); $zip->addFile(self::DATA_DIR . 'fonts/' . $fontName, self::DATA_DIR . 'fonts/' . $fontName);
} }
if (file_exists(self::DATA_DIR .'fonts/fonts.html')) { if (file_exists(self::DATA_DIR . 'fonts/fonts.html')) {
$zip->addFile(self::DATA_DIR .'fonts/fonts.html', self::DATA_DIR .'fonts/fonts.html'); $zip->addFile(self::DATA_DIR . 'fonts/fonts.html', self::DATA_DIR . 'fonts/fonts.html');
} }
break; break;
} }
@ -1100,7 +1139,8 @@ class theme extends common {
* @param string $file, nom du fichier json à convertir * @param string $file, nom du fichier json à convertir
* @return int nombre de substitution effectuées * @return int nombre de substitution effectuées
*/ */
private function subFonts($file) { private function subFonts($file)
{
// Tableau de substitution des fontes // Tableau de substitution des fontes
$fonts = [ $fonts = [
'Abril+Fatface' => 'abril-fatface', 'Abril+Fatface' => 'abril-fatface',
@ -1113,19 +1153,19 @@ class theme extends common {
'Droid+Serif' => 'droid-serif-2', 'Droid+Serif' => 'droid-serif-2',
'Fira+Sans' => 'fira-sans', 'Fira+Sans' => 'fira-sans',
'Inconsolata' => 'inconsolata-2', 'Inconsolata' => 'inconsolata-2',
'Indie+Flower' =>'indie-flower', 'Indie+Flower' => 'indie-flower',
'Josefin+Slab' => 'josefin-sans-std', 'Josefin+Slab' => 'josefin-sans-std',
'Lobster' => 'lobster-2', 'Lobster' => 'lobster-2',
'Lora' => 'lora', 'Lora' => 'lora',
'Lato' =>'lato', 'Lato' => 'lato',
'Marvel' => 'montserrat-ace', 'Marvel' => 'montserrat-ace',
'Old+Standard+TT' => 'old-standard-tt-3', 'Old+Standard+TT' => 'old-standard-tt-3',
'Open+Sans' =>'open-sans', 'Open+Sans' => 'open-sans',
// Corriger l'erreur de nom de police installée par défaut, il manquait un O en majuscule // Corriger l'erreur de nom de police installée par défaut, il manquait un O en majuscule
'open+Sans' =>'open-sans', 'open+Sans' => 'open-sans',
'Oswald' =>'oswald-4', 'Oswald' => 'oswald-4',
'PT+Mono' => 'pt-mono', 'PT+Mono' => 'pt-mono',
'PT+Serif' =>'pt-serif', 'PT+Serif' => 'pt-serif',
'Raleway' => 'raleway-5', 'Raleway' => 'raleway-5',
'Rancho' => 'rancho', 'Rancho' => 'rancho',
'Roboto' => 'Roboto', 'Roboto' => 'Roboto',
@ -1136,7 +1176,7 @@ class theme extends common {
$data = file_get_contents($file); $data = file_get_contents($file);
$count = 0; $count = 0;
foreach ($fonts as $oldId => $newId){ foreach ($fonts as $oldId => $newId) {
$data = str_replace($oldId, $newId, $data, $c); $data = str_replace($oldId, $newId, $data, $c);
$count = $count + (int) $c; $count = $count + (int) $c;
} }
@ -1151,19 +1191,20 @@ class theme extends common {
// Retourne un tableau simple des fonts installées idfont avec le nom // Retourne un tableau simple des fonts installées idfont avec le nom
// Cette fonction est utile aux sélecteurs de fonts dans les formulaires. // Cette fonction est utile aux sélecteurs de fonts dans les formulaires.
public function enumFonts() { public function enumFonts()
{
/** /**
* Récupère la liste des fontes installées et construit deux tableaux * Récupère la liste des fontes installées et construit deux tableaux
* id - nom * id - nom
* id - font-family - resource * id - font-family - resource
*/ */
$f ['files'] = $this->getData(['fonts', 'files']); $f['files'] = $this->getData(['fonts', 'files']);
$f ['imported'] = $this->getData(['fonts', 'imported']); $f['imported'] = $this->getData(['fonts', 'imported']);
$f ['websafe'] = self::$fontsWebSafe; $f['websafe'] = self::$fontsWebSafe;
// Construit un tableau avec leur ID et leur famille // Construit un tableau avec leur ID et leur famille
foreach(['websafe', 'imported', 'files'] as $type) { foreach (['websafe', 'imported', 'files'] as $type) {
if (is_array($f[$type])) { if (is_array($f[$type])) {
foreach ($f[$type] as $fontId => $fontValue ) { foreach ($f[$type] as $fontId => $fontValue) {
self::$fonts['name'][$fontId] = $fontValue['name']; self::$fonts['name'][$fontId] = $fontValue['name'];
self::$fonts['family'][$fontId] = $fontValue['font-family']; self::$fonts['family'][$fontId] = $fontValue['font-family'];
} }
@ -1178,44 +1219,46 @@ class theme extends common {
* Création d'un fichier de liens d'appel des fontes * Création d'un fichier de liens d'appel des fontes
* @param string $scope vaut all pour toutes les fontes ; 'user' pour les fontes utilisateurs * @param string $scope vaut all pour toutes les fontes ; 'user' pour les fontes utilisateurs
*/ */
private function setFonts($scope = 'all') { private function setFonts($scope = 'all')
{
// Filtrage par fontes installées // Filtrage par fontes installées
$fontsInstalled = [ $this->getData(['theme', 'text', 'font']), $fontsInstalled = [
$this->getData(['theme', 'title', 'font']), $this->getData(['theme', 'text', 'font']),
$this->getData(['theme', 'header', 'font']), $this->getData(['theme', 'title', 'font']),
$this->getData(['theme', 'menu', 'font']), $this->getData(['theme', 'header', 'font']),
$this->getData(['theme', 'footer', 'font']), $this->getData(['theme', 'menu', 'font']),
$this->getData(['admin', 'fontText']), $this->getData(['theme', 'footer', 'font']),
$this->getData(['admin', 'fontTitle']), $this->getData(['admin', 'fontText']),
]; $this->getData(['admin', 'fontTitle']),
];
// Compression // Compression
$fontsInstalled = array_unique($fontsInstalled); $fontsInstalled = array_unique($fontsInstalled);
/** /**
* Chargement des polices en ligne dans un fichier fonts.html inclus dans main.php * Chargement des polices en ligne dans un fichier fonts.html inclus dans main.php
*/ */
$gf = false; $gf = false;
$fileContent = '<!-- Fontes personnalisées -->'; $fileContent = '<!-- Fontes personnalisées -->';
if ( !empty($this->getData(['fonts', 'imported'])) ) { if (!empty($this->getData(['fonts', 'imported']))) {
foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) { foreach ($this->getData(['fonts', 'imported']) as $fontId => $fontValue) {
if ( if (
( $scope === 'user' && in_array($fontId, $fontsInstalled) ) ($scope === 'user' && in_array($fontId, $fontsInstalled))
|| $scope === 'all' || $scope === 'all'
) { ) {
//Pré chargement à revoir //Pré chargement à revoir
//$fileContent .= '<link rel="preload" href="' . $fontValue['resource'] . '" crossorigin="anonymous" as="style">'; //$fileContent .= '<link rel="preload" href="' . $fontValue['resource'] . '" crossorigin="anonymous" as="style">';
$fileContent .= '<link href="' . $fontValue['resource'] .'" rel="stylesheet">'; $fileContent .= '<link href="' . $fontValue['resource'] . '" rel="stylesheet">';
// Pré connect pour api.google // Pré connect pour api.google
$gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true; $gf = strpos($fontValue['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true;
} }
} }
} }
// Ajoute le préconnect des fontes Googles. // Ajoute le préconnect des fontes Googles.
$fileContent = $gf ? '<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' . $fileContent $fileContent = $gf ? '<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' . $fileContent
: $fileContent; : $fileContent;
@ -1223,32 +1266,30 @@ class theme extends common {
* Fontes installées localement * Fontes installées localement
*/ */
$fileContentCss = ''; $fileContentCss = '';
if ( !empty($this->getData(['fonts', 'files'])) ) { if (!empty($this->getData(['fonts', 'files']))) {
foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) { foreach ($this->getData(['fonts', 'files']) as $fontId => $fontValue) {
if ( if (
( $scope === 'user' && in_array($fontId, $fontsInstalled) ) ($scope === 'user' && in_array($fontId, $fontsInstalled))
|| $scope === 'all' || $scope === 'all'
) { ) {
if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource']) ) { if (file_exists(self::DATA_DIR . 'fonts/' . $fontValue['resource'])) {
// Extension // Extension
$path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']); $path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'fonts/' . $fontValue['resource']);
// Chargement de la police // Chargement de la police
$fileContentCss .= '@font-face {' ; $fileContentCss .= '@font-face {';
$fileContentCss .= 'font-family:"' . $fontValue['name'] . '";'; $fileContentCss .= 'font-family:"' . $fontValue['name'] . '";';
$fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");'; $fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");';
$fileContentCss .= '}' ; $fileContentCss .= '}';
// Préchargement // Préchargement
//$fileContent = '<link rel="preload" href="' . self::DATA_DIR . 'fonts/' . $fontValue['resource'] . '" type="font/woff" crossorigin="anonymous" as="font">' . $fileContent; //$fileContent = '<link rel="preload" href="' . self::DATA_DIR . 'fonts/' . $fontValue['resource'] . '" type="font/woff" crossorigin="anonymous" as="font">' . $fileContent;
}
} }
} }
}
} }
// Enregistre la personnalisation // Enregistre la personnalisation
file_put_contents(self::DATA_DIR.'fonts/fonts.html', $fileContent); file_put_contents(self::DATA_DIR . 'fonts/fonts.html', $fileContent);
// Enregistre la personnalisation // Enregistre la personnalisation
file_put_contents(self::DATA_DIR.'fonts/fonts.css', $fileContentCss); file_put_contents(self::DATA_DIR . 'fonts/fonts.css', $fileContentCss);
} }
} }

View File

@ -10,19 +10,19 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
/** /**
* Aperçu en direct * Aperçu en direct
*/ */
$("input, select").on("change", function() { $("input, select").on("change", function () {
var titleFont = $("#adminFontTitle").val(); var titleFont = $("#adminFontTitle").val();
var textFont = $("#adminFontText").val(); var textFont = $("#adminFontText").val();
var css = "@import url('https://fonts.cdnfonts.com/css/" + titleFont + "');"; var css = "@import url('https://fonts.cdnfonts.com/css/" + titleFont + "');";
var css = "@import url('https://fonts.cdnfonts.com/css/" + textFont + "');"; var css = "@import url('https://fonts.cdnfonts.com/css/" + textFont + "');";
var colors = core.colorVariants($("#adminBackgroundColor").val()); var colors = core.colorVariants($("#adminBackgroundColor").val());
var css = "#site{background-color:" + colors.normal + ";}"; var css = "#site{background-color:" + colors.normal + ";}";
css += "body, .row > div {font:" + $("#adminFontTextSize").val() + " '" + textFont + "', sans-serif;}"; css += "body, .row > div {font:" + $("#adminFontTextSize").val() + " '" + textFont + "', sans-serif;}";
css += "body h1, h2, h3, h4, h5, h6 {font-family:'" + titleFont + "', sans-serif; color:" + $("#adminColorTitle").val() + ";}"; css += "body h1, h2, h3, h4, h5, h6 {font-family:'" + titleFont + "', sans-serif; color:" + $("#adminColorTitle").val() + ";}";
css += "body:not(.editorWysiwyg),span .zwiico-help {color:" + $("#adminColorText").val() + ";}"; css += "body:not(.editorWysiwyg),span .zwiico-help {color:" + $("#adminColorText").val() + ";}";
var colors = core.colorVariants($("#adminColorButton").val()); var colors = core.colorVariants($("#adminColorButton").val());
css += "input[type='checkbox']:checked + label::before,.speechBubble{ background-color:" + colors.normal + "; color:" + $("#adminColorButtonText").val() + ";}"; css += "input[type='checkbox']:checked + label::before,.speechBubble{ background-color:" + colors.normal + "; color:" + $("#adminColorButtonText").val() + ";}";
@ -33,27 +33,27 @@ $("input, select").on("change", function() {
var colors = core.colorVariants($("#adminColorRed").val()); var colors = core.colorVariants($("#adminColorRed").val());
css += ".button.buttonRed {background-color: " + colors.normal + ";color:" + colors.text + ";}.button.buttonRed:hover {background-color:" + colors.darken + ";color:" + colors.text + "}.button.buttonRed:active {background-color:" + colors.veryDarken + ";color:" + colors.text + "}"; css += ".button.buttonRed {background-color: " + colors.normal + ";color:" + colors.text + ";}.button.buttonRed:hover {background-color:" + colors.darken + ";color:" + colors.text + "}.button.buttonRed:active {background-color:" + colors.veryDarken + ";color:" + colors.text + "}";
var colors = core.colorVariants($("#adminColorGreen").val()); var colors = core.colorVariants($("#adminColorGreen").val());
css += ".button.buttonGreen, button[type=submit] {background-color: " + colors.normal + ";color: " + ";color:" + colors.text + "}.button.buttonGreen:hover, button[type=submit]:hover {background-color: " + colors.darken + ";color:" + colors.text + ";}.button.buttonGreen:active, button[type=submit]:active {background-color:" + colors.veryDarken + ";color:" + colors.text + "}"; css += ".button.buttonGreen, button[type=submit] {background-color: " + colors.normal + ";color: " + ";color:" + colors.text + "}.button.buttonGreen:hover, button[type=submit]:hover {background-color: " + colors.darken + ";color:" + colors.text + ";}.button.buttonGreen:active, button[type=submit]:active {background-color:" + colors.veryDarken + ";color:" + colors.text + "}";
var colors = core.colorVariants($("#adminBackGroundBlockColor").val()); var colors = core.colorVariants($("#adminBackGroundBlockColor").val());
css += ".block {border: 1px solid " + $("#adminBorderBlockColor").val() + ";}.block h4 {background-color: " + colors.normal + ";color:" + colors.text + ";}"; css += ".block {border: 1px solid " + $("#adminBorderBlockColor").val() + ";}.block h4 {background-color: " + colors.normal + ";color:" + colors.text + ";}";
css += "input[type=email],input[type=text],input[type=password],select:not(#barSelectPage),textarea:not(.editorWysiwyg),.inputFile{background-color: " + colors.normal + ";color:" + colors.text + ";border: 1px solid " + $("#adminBorderBlockColor").val() + ";}"; css += "input[type=email],input[type=text],input[type=password],select:not(#barSelectPage),textarea:not(.editorWysiwyg),.inputFile{background-color: " + colors.normal + ";color:" + colors.text + ";border: 1px solid " + $("#adminBorderBlockColor").val() + ";}";
// Ajout du css au DOM // Ajout du css au DOM
$("#themePreview").remove(); $("#themePreview").remove();
$("<style>") $("<style>")
.attr("type", "text/css") .attr("type", "text/css")
.attr("id", "themePreview") .attr("id", "themePreview")
.text(css) .text(css)
.appendTo("head"); .appendTo("head");
}); });
/** /**
* Confirmation de réinitialisation * Confirmation de réinitialisation
*/ */
$("#configAdminReset").on("click", function() { $("#configAdminReset").on("click", function () {
var _this = $(this); var _this = $(this);
return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine le thème de l\'administration ?", function() { return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine le thème de l\'administration ?", function () {
$(location).attr("href", _this.attr("href")); $(location).attr("href", _this.attr("href"));
}); });
}); });

View File

@ -1,159 +1,159 @@
<?php echo template::formOpen('configAdminForm'); ?> <?php echo template::formOpen('configAdminForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('configAdminBack', [ <?php echo template::button('configAdminBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme', 'href' => helper::baseUrl() . 'theme',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<!-- <!--
<div class="col2 offset5"> <div class="col2 offset5">
<?php echo template::button('configAdminTest', [ <?php echo template::button('configAdminTest', [
'value' => 'Bouton Standard' 'value' => 'Bouton Standard'
]); ?> ]); ?>
</div> </div>
--> -->
<div class="col1 offset8"> <div class="col1 offset8">
<?php echo template::button('configAdminReset', [ <?php echo template::button('configAdminReset', [
'class' => 'buttonRed', 'class' => 'buttonRed',
'href' => helper::baseUrl() . 'theme/reset/admin' . '&csrf=' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'theme/reset/admin' . '&csrf=' . $_SESSION['csrf'],
'value' => template::ico('cancel'), 'value' => template::ico('cancel'),
'help' => 'Réinitialiser avec le thème par défaut' 'help' => 'Réinitialiser avec le thème par défaut'
]); ?> ]); ?>
</div>
<div class="col2">
<?php echo template::submit('configAdminSubmit',[
'value' => 'Valider',
'ico' => 'check'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col2">
<div class="col12"> <?php echo template::submit('configAdminSubmit', [
<div class="block"> 'value' => 'Valider',
<h4> 'ico' => 'check'
<?php echo template::topic('Couleurs'); ?> ]); ?>
</h4> </div>
<div class="row"> </div>
<div class="col4"> <div class="row">
<?php echo template::text('adminBackgroundColor', [ <div class="col12">
'class' => 'colorPicker', <div class="block">
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', <h4>
'label' => 'Arrière-plan', <?php echo template::topic('Couleurs'); ?>
'value' => $this->getData(['admin', 'backgroundColor']) </h4>
]); ?> <div class="row">
</div> <div class="col4">
<div class="col4"> <?php echo template::text('adminBackgroundColor', [
<?php echo template::text('adminColorTitle', [ 'class' => 'colorPicker',
'class' => 'colorPicker', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', 'label' => 'Arrière-plan',
'label' => 'Titres', 'value' => $this->getData(['admin', 'backgroundColor'])
'value' => $this->getData(['admin', 'colorTitle']) ]); ?>
]); ?>
</div>
<div class="col4">
<?php echo template::text('adminColorText', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Texte',
'value' => $this->getData(['admin', 'colorText'])
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col4">
<div class="col4"> <?php echo template::text('adminColorTitle', [
<?php echo template::text('adminBackGroundBlockColor', [ 'class' => 'colorPicker',
'class' => 'colorPicker', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence. La couleur du texte est automatique.', 'label' => 'Titres',
'label' => 'Arrière-plan des champs', 'value' => $this->getData(['admin', 'colorTitle'])
'value' => $this->getData(['admin', 'backgroundBlockColor']) ]); ?>
]); ?>
</div>
<div class="col4">
<?php echo template::text('adminBorderBlockColor', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bordure des champs',
'value' => $this->getData(['admin', 'borderBlockColor'])
]); ?>
</div>
<div class="col3 offset1">
<?php echo template::text('adminColorHelp', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bouton Aide',
'value' => $this->getData(['admin', 'backgroundColorButtonHelp'])
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col4">
<div class="col3"> <?php echo template::text('adminColorText', [
<?php echo template::text('adminColorGrey', [ 'class' => 'colorPicker',
'class' => 'colorPicker', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', 'label' => 'Texte',
'label' => 'Bouton retour', 'value' => $this->getData(['admin', 'colorText'])
'value' => $this->getData(['admin', 'backgroundColorButtonGrey']) ]); ?>
]); ?> </div>
</div> </div>
<div class="col3"> <div class="row">
<?php echo template::text('adminColorButton', [ <div class="col4">
'class' => 'colorPicker', <?php echo template::text('adminBackGroundBlockColor', [
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', 'class' => 'colorPicker',
'label' => 'Bouton standard', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence. La couleur du texte est automatique.',
'value' => $this->getData(['admin', 'backgroundColorButton']) 'label' => 'Arrière-plan des champs',
]); ?> 'value' => $this->getData(['admin', 'backgroundBlockColor'])
</div> ]); ?>
<div class="col3"> </div>
<?php echo template::text('adminColorRed', [ <div class="col4">
'class' => 'colorPicker', <?php echo template::text('adminBorderBlockColor', [
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', 'class' => 'colorPicker',
'label' => 'Bouton effacement', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'value' => $this->getData(['admin', 'backgroundColorButtonRed']) 'label' => 'Bordure des champs',
]); ?> 'value' => $this->getData(['admin', 'borderBlockColor'])
</div> ]); ?>
<div class="col3"> </div>
<?php echo template::text('adminColorGreen', [ <div class="col3 offset1">
'class' => 'colorPicker', <?php echo template::text('adminColorHelp', [
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.', 'class' => 'colorPicker',
'label' => 'Bouton validation', 'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'value' => $this->getData(['admin', 'backgroundColorButtonGreen']) 'label' => 'Bouton Aide',
]); ?> 'value' => $this->getData(['admin', 'backgroundColorButtonHelp'])
</div> ]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::text('adminColorGrey', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bouton retour',
'value' => $this->getData(['admin', 'backgroundColorButtonGrey'])
]); ?>
</div>
<div class="col3">
<?php echo template::text('adminColorButton', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bouton standard',
'value' => $this->getData(['admin', 'backgroundColorButton'])
]); ?>
</div>
<div class="col3">
<?php echo template::text('adminColorRed', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bouton effacement',
'value' => $this->getData(['admin', 'backgroundColorButtonRed'])
]); ?>
</div>
<div class="col3">
<?php echo template::text('adminColorGreen', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bouton validation',
'value' => $this->getData(['admin', 'backgroundColorButtonGreen'])
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<div class="block"> <div class="col12">
<h4> <div class="block">
<?php echo template::topic('Mise en forme du texte'); ?> <h4>
</h4> <?php echo template::topic('Mise en forme du texte'); ?>
<div class="row"> </h4>
<div class="col4"> <div class="row">
<?php echo template::select('adminFontText', $module::$fonts['name'], [ <div class="col4">
'label' => 'Police du texte', <?php echo template::select('adminFontText', $module::$fonts['name'], [
'selected' => $this->getData(['admin', 'fontText']), 'label' => 'Police du texte',
'fonts' => $module::$fonts['family'] 'selected' => $this->getData(['admin', 'fontText']),
]); ?> 'fonts' => $module::$fonts['family']
</div> ]); ?>
<div class="col4"> </div>
<?php echo template::select('adminFontTextSize', $module::$siteFontSizes, [ <div class="col4">
'label' => 'Taille', <?php echo template::select('adminFontTextSize', $module::$siteFontSizes, [
'selected' => $this->getData(['admin', 'fontSize']) 'label' => 'Taille',
]); ?> 'selected' => $this->getData(['admin', 'fontSize'])
</div> ]); ?>
<div class="col4"> </div>
<?php echo template::select('adminFontTitle', $module::$fonts['name'], [ <div class="col4">
'label' => 'Police des titres', <?php echo template::select('adminFontTitle', $module::$fonts['name'], [
'selected' => $this->getData(['admin', 'fontTitle']), 'label' => 'Police des titres',
'fonts' => $module::$fonts['family'] 'selected' => $this->getData(['admin', 'fontTitle']),
]); ?> 'fonts' => $module::$fonts['family']
</div> ]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> </div>
</div>
<?php echo template::formClose(); ?>

View File

@ -14,7 +14,7 @@
/** /**
* Aperçu en direct * Aperçu en direct
*/ */
$("#themeAdvancedCss").on("change keydown keyup", function() { $("#themeAdvancedCss").on("change keydown keyup", function () {
// Ajout du css au DOM // Ajout du css au DOM
$("#themePreview").remove(); $("#themePreview").remove();
$("<style>") $("<style>")
@ -27,9 +27,9 @@ $("#themeAdvancedCss").on("change keydown keyup", function() {
/** /**
* Confirmation de réinitialisation * Confirmation de réinitialisation
*/ */
$("#themeAdvancedReset").on("click", function() { $("#themeAdvancedReset").on("click", function () {
var _this = $(this); var _this = $(this);
return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine la personnalisation avancée ?", function() { return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine la personnalisation avancée ?", function () {
$(location).attr("href", _this.attr("href")); $(location).attr("href", _this.attr("href"));
}); });
}); });

View File

@ -1,31 +1,31 @@
<?php echo template::formOpen('themeAdvancedForm'); ?> <?php echo template::formOpen('themeAdvancedForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('themeAdvancedBack', [ <?php echo template::button('themeAdvancedBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme', 'href' => helper::baseUrl() . 'theme',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col1 offset8"> <div class="col1 offset8">
<?php echo template::button('themeAdvancedReset', [ <?php echo template::button('themeAdvancedReset', [
'href' => helper::baseUrl() . 'theme/reset/custom' . '&csrf=' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'theme/reset/custom' . '&csrf=' . $_SESSION['csrf'],
'class' => 'buttonRed', 'class' => 'buttonRed',
'value' => template::ico('cancel'), 'value' => template::ico('cancel'),
'help' => 'Réinitialiser la feuille de style' 'help' => 'Réinitialiser la feuille de style'
]); ?> ]); ?>
</div>
<div class="col2">
<?php echo template::submit('themeAdvancedSubmit'); ?>
</div>
</div> </div>
<div class="row"> <div class="col2">
<div class="col12"> <?php echo template::submit('themeAdvancedSubmit'); ?>
<?php echo template::textarea('themeAdvancedCss', [
'value' => file_get_contents(self::DATA_DIR.'custom.css'),
'class' => 'editor'
]); ?>
</div>
</div> </div>
</div>
<div class="row">
<div class="col12">
<?php echo template::textarea('themeAdvancedCss', [
'value' => file_get_contents(self::DATA_DIR . 'custom.css'),
'class' => 'editor'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -14,20 +14,20 @@
/** /**
* Affichage de l'icone de remontée et permettre l'aperçu. * Affichage de l'icone de remontée et permettre l'aperçu.
*/ */
$(document).ready(function(){ $(document).ready(function () {
$("#backToTop").css("display","show"); $("#backToTop").css("display", "show");
}); });
/** /**
* Aperçu en direct * Aperçu en direct
*/ */
$("input, select").on("change", function() { $("input, select").on("change", function () {
// Option fixe pour contain et cover // Option fixe pour contain et cover
var themeBodyImageSize = $("#themeBodyImageSize").val(); var themeBodyImageSize = $("#themeBodyImageSize").val();
if(themeBodyImageSize === "cover" || if (themeBodyImageSize === "cover" ||
themeBodyImageSize === "contain" ) { themeBodyImageSize === "contain") {
$("#themeBodyImageAttachment").val("fixed"); $("#themeBodyImageAttachment").val("fixed");
} }
@ -35,14 +35,14 @@ $("input, select").on("change", function() {
var css = "html{background-color:" + $("#themeBodyBackgroundColor").val() + "}"; var css = "html{background-color:" + $("#themeBodyBackgroundColor").val() + "}";
// Image du fond // Image du fond
var themeBodyImage = $("#themeBodyImage").val(); var themeBodyImage = $("#themeBodyImage").val();
if(themeBodyImage) { if (themeBodyImage) {
css += "html{background-image:url('<?php echo helper::baseUrl(false); ?>site/file/source/" + themeBodyImage + "');background-repeat:" + $("#themeBodyImageRepeat").val() + ";background-position:" + $("#themeBodyImagePosition").val() + ";background-attachment:" + $("#themeBodyImageAttachment").val() + ";background-size:" + $("#themeBodyImageSize").val() + "}"; css += "html{background-image:url('<?php echo helper::baseUrl(false); ?>site/file/source/" + themeBodyImage + "');background-repeat:" + $("#themeBodyImageRepeat").val() + ";background-position:" + $("#themeBodyImagePosition").val() + ";background-attachment:" + $("#themeBodyImageAttachment").val() + ";background-size:" + $("#themeBodyImageSize").val() + "}";
css += "html{background-color:rgba(0,0,0,0);}"; css += "html{background-color:rgba(0,0,0,0);}";
} }
else { else {
css += "html{background-image:none}"; css += "html{background-image:none}";
} }
css += '#backToTop {background-color:' + $("#themeBodyToTopBackground").val() + ';color:' + $("#themeBodyToTopColor").val() + ';}'; css += '#backToTop {background-color:' + $("#themeBodyToTopBackground").val() + ';color:' + $("#themeBodyToTopColor").val() + ';}';
// Ajout du css au DOM // Ajout du css au DOM
$("#themePreview").remove(); $("#themePreview").remove();
@ -53,8 +53,8 @@ $("input, select").on("change", function() {
.appendTo("head"); .appendTo("head");
}); });
// Affiche / Cache les options de l'image du fond // Affiche / Cache les options de l'image du fond
$("#themeBodyImage").on("change", function() { $("#themeBodyImage").on("change", function () {
if($(this).val()) { if ($(this).val()) {
$("#themeBodyImageOptions").slideDown(); $("#themeBodyImageOptions").slideDown();
} }
else { else {

View File

@ -63,7 +63,7 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php <?php
$imageFile = file_exists(self::FILE_DIR.'source/'.$this->getData(['theme', 'body', 'image'])) ? $this->getData(['theme', 'body', 'image']) : ""; $imageFile = file_exists(self::FILE_DIR . 'source/' . $this->getData(['theme', 'body', 'image'])) ? $this->getData(['theme', 'body', 'image']) : "";
echo template::file('themeBodyImage', [ echo template::file('themeBodyImage', [
'help' => 'Sélectionner une image', 'help' => 'Sélectionner une image',
'label' => 'Arrière-plan', 'label' => 'Arrière-plan',
@ -105,4 +105,4 @@
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,85 +1,85 @@
<?php echo template::formOpen('fontAddForm'); ?> <?php echo template::formOpen('fontAddForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('fontAddBack', [ <?php echo template::button('fontAddBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme/fonts', 'href' => helper::baseUrl() . 'theme/fonts',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col1">
<?php echo template::button('fontAddHelp', [
'href' => 'https://doc.zwiicms.fr/fontes#add',
'target' => '_blank',
'value' => template::ico('help'),
'class' => 'buttonHelp'
]); ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('fontAddPublish', [
'value' => 'Valider',
'uniqueSubmission' => true
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col1">
<div class="col12"> <?php echo template::button('fontAddHelp', [
<div class="block"> 'href' => 'https://doc.zwiicms.fr/fontes#add',
<h4> 'target' => '_blank',
<?php echo template::topic('Identité de la fonte'); ?> 'value' => template::ico('help'),
</h4> 'class' => 'buttonHelp'
<div class="row"> ]); ?>
<div class="col6"> </div>
<?php echo template::checkbox('fontAddFontImported', true, 'Fonte en ligne', [ <div class="col2 offset8">
'checked' => true <?php echo template::submit('fontAddPublish', [
]); ?> 'value' => 'Valider',
</div> 'uniqueSubmission' => true
<div class="col6"> ]); ?>
<?php echo template::checkbox('fontAddFontFile', true,'Fonte installée', []); ?> </div>
</div> </div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo template::topic('Identité de la fonte'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('fontAddFontImported', true, 'Fonte en ligne', [
'checked' => true
]); ?>
</div> </div>
<div class="row"> <div class="col6">
<div class="col6"> <?php echo template::checkbox('fontAddFontFile', true, 'Fonte installée', []); ?>
<?php echo template::text('fontAddFontId', [ </div>
'autocomplete' => 'off', </div>
'label' => 'Identifiant (sans espace ni majuscule)', <div class="row">
'placeholder' => 'big-marker-extrude' <div class="col6">
<?php echo template::text('fontAddFontId', [
'autocomplete' => 'off',
'label' => 'Identifiant (sans espace ni majuscule)',
'placeholder' => 'big-marker-extrude'
]); ?> ]); ?>
</div>
<div class="col6">
<?php echo template::text('fontAddFontName', [
'autocomplete' => 'off',
'label' => 'Nom',
'placeholder' => 'Big Marker Extrude'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col6">
<div class="col12"> <?php echo template::text('fontAddFontName', [
'autocomplete' => 'off',
'label' => 'Nom',
'placeholder' => 'Big Marker Extrude'
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::text('fontAddFontFamilyName', [ <?php echo template::text('fontAddFontFamilyName', [
'autocomplete' => 'off', 'autocomplete' => 'off',
'label' => 'Famille', 'label' => 'Famille',
'placeholder' => "'Big Marker Extrude', sans-serif" 'placeholder' => "'Big Marker Extrude', sans-serif"
]); ?> ]); ?>
</div>
</div> </div>
<div class="row" id="containerFontAddFile"> </div>
<div class="col12"> <div class="row" id="containerFontAddFile">
<?php echo template::file('fontAddFile', [ <div class="col12">
'label' => 'Fichier de fonte (Format WOFF)' <?php echo template::file('fontAddFile', [
]); ?> 'label' => 'Fichier de fonte (Format WOFF)'
</div> ]); ?>
</div> </div>
<div class="row" id="containerFontAddUrl"> </div>
<div class="col12"> <div class="row" id="containerFontAddUrl">
<?php echo template::text('fontAddUrl', [ <div class="col12">
'label' => 'Url du fichier de fonte', <?php echo template::text('fontAddUrl', [
'placeholder' => 'https://fonts.cdnfonts.com/css/big-marker-extrude' 'label' => 'Url du fichier de fonte',
]); ?> 'placeholder' => 'https://fonts.cdnfonts.com/css/big-marker-extrude'
</div> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -13,8 +13,8 @@
/** /**
* Option par défaut du sélecteur de mode * Option par défaut du sélecteur de mode
*/ */
$(document).ready(function(){ $(document).ready(function () {
if( $('input[name=fontEditFontImported]').is(':checked') ){ if ($('input[name=fontEditFontImported]').is(':checked')) {
$('#containerfontEditFile').hide(); $('#containerfontEditFile').hide();
$('#containerfontEditUrl').show(); $('#containerfontEditUrl').show();
$('#fontEditFontFileWrapper').hide(); $('#fontEditFontFileWrapper').hide();
@ -23,7 +23,7 @@
} }
if( $('input[name=fontEditFontFile]').is(':checked') ){ if ($('input[name=fontEditFontFile]').is(':checked')) {
$('#containerfontEditFile').show(); $('#containerfontEditFile').show();
$('#containerfontEditUrl').hide(); $('#containerfontEditUrl').hide();
$('#fontEditFontImportedWrapper').hide(); $('#fontEditFontImportedWrapper').hide();

View File

@ -1,88 +1,88 @@
<?php echo template::formOpen('fontEditForm'); ?> <?php echo template::formOpen('fontEditForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('fontEditBack', [ <?php echo template::button('fontEditBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme/fonts', 'href' => helper::baseUrl() . 'theme/fonts',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col1">
<?php echo template::button('fontEditHelp', [
'href' => 'https://doc.zwiicms.fr/fontes#add',
'target' => '_blank',
'value' => template::ico('help'),
'class' => 'buttonHelp'
]); ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('fontEditPublish', [
'value' => 'Valider',
'uniqueSubmission' => true
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col1">
<div class="col12"> <?php echo template::button('fontEditHelp', [
<div class="block"> 'href' => 'https://doc.zwiicms.fr/fontes#add',
<h4> 'target' => '_blank',
<?php echo template::topic('Identité de la fonte'); ?> 'value' => template::ico('help'),
'class' => 'buttonHelp'
</h4> ]); ?>
<div class="row"> </div>
<div class="col6"> <div class="col2 offset8">
<?php echo template::checkbox('fontEditFontImported', true, 'Fonte en ligne', [ <?php echo template::submit('fontEditPublish', [
'checked' => $this->getUrl(2) === 'imported' ? true : false 'value' => 'Valider',
]); ?> 'uniqueSubmission' => true
</div> ]); ?>
<div class="col6"> </div>
<?php echo template::checkbox('fontEditFontFile', true,'Fonte installée', [ </div>
'checked' => $this->getUrl(2) === 'files' ? true : false <div class="row">
]); ?> <div class="col12">
</div> <div class="block">
<h4>
<?php echo template::topic('Identité de la fonte'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::checkbox('fontEditFontImported', true, 'Fonte en ligne', [
'checked' => $this->getUrl(2) === 'imported' ? true : false
]); ?>
</div> </div>
<div class="row"> <div class="col6">
<div class="col6"> <?php echo template::checkbox('fontEditFontFile', true, 'Fonte installée', [
<?php echo template::text('fontEditFontId', [ 'checked' => $this->getUrl(2) === 'files' ? true : false
'autocomplete' => 'off', ]); ?>
'label' => 'Identifiant (sans espace ni majuscule)',
'value' => $this->getUrl(3)
]); ?>
</div>
<div class="col6">
<?php echo template::text('fontEditFontName', [
'autocomplete' => 'off',
'label' => 'Nom',
'value' => $this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'name'])
]); ?>
</div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<div class="col6">
<?php echo template::text('fontEditFontId', [
'autocomplete' => 'off',
'label' => 'Identifiant (sans espace ni majuscule)',
'value' => $this->getUrl(3)
]); ?>
</div>
<div class="col6">
<?php echo template::text('fontEditFontName', [
'autocomplete' => 'off',
'label' => 'Nom',
'value' => $this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'name'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<?php echo template::text('fontEditFontFamilyName', [ <?php echo template::text('fontEditFontFamilyName', [
'autocomplete' => 'off', 'autocomplete' => 'off',
'label' => 'Famille', 'label' => 'Famille',
'value' => stripslashes($this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'font-family'])) 'value' => stripslashes($this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'font-family']))
]); ?> ]); ?>
</div>
</div> </div>
<div class="row" id="containerfontEditFile"> </div>
<div class="col12"> <div class="row" id="containerfontEditFile">
<?php echo template::file('fontEditFile', [ <div class="col12">
'label' => 'Fichier de fonte (Format WOFF)', <?php echo template::file('fontEditFile', [
'value' => $this->getUrl(2) === 'files' ? $this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'resource']) : '' 'label' => 'Fichier de fonte (Format WOFF)',
]); ?> 'value' => $this->getUrl(2) === 'files' ? $this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'resource']) : ''
</div> ]); ?>
</div> </div>
<div class="row" id="containerfontEditUrl"> </div>
<div class="col12"> <div class="row" id="containerfontEditUrl">
<?php echo template::text('fontEditUrl', [ <div class="col12">
'label' => 'Url du fichier de fonte', <?php echo template::text('fontEditUrl', [
'value' => $this->getUrl(2) === 'imported' ? $this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'resource']) : '' 'label' => 'Url du fichier de fonte',
]); ?> 'value' => $this->getUrl(2) === 'imported' ? $this->getData(['fonts', $this->getUrl(2), $this->getUrl(3), 'resource']) : ''
</div> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -13,9 +13,9 @@
/** /**
* Confirmation de suppression * Confirmation de suppression
*/ */
$(".themeFontDelete").on("click", function() { $(".themeFontDelete").on("click", function () {
var _this = $(this); var _this = $(this);
return core.confirm("Êtes-vous sûr de vouloir supprimer cette fonte ?", function() { return core.confirm("Êtes-vous sûr de vouloir supprimer cette fonte ?", function () {
$(location).attr("href", _this.attr("href")); $(location).attr("href", _this.attr("href"));
}); });
}); });

View File

@ -23,8 +23,8 @@
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php if($module::$fontsDetail): ?> <?php if ($module::$fontsDetail) : ?>
<?php echo template::table([2, 2, 3, 2, 1, 1, 1], $module::$fontsDetail, ['FontId', 'Nom', 'Famille', 'Affectation', 'Origine', '', '']); ?> <?php echo template::table([2, 2, 3, 2, 1, 1, 1], $module::$fontsDetail, ['FontId', 'Nom', 'Famille', 'Affectation', 'Origine', '', '']); ?>
<?php else: ?> <?php else : ?>
<?php echo template::speech('Aucune fonte !'); ?> <?php echo template::speech('Aucune fonte !'); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -15,7 +15,7 @@
/** /**
* Aperçu en direct * Aperçu en direct
*/ */
$("input, select").on("change", function() { $("input, select").on("change", function () {
// Import des polices de caractères // Import des polices de caractères
var footerFont = $("#themeFooterFont :selected").val(); var footerFont = $("#themeFooterFont :selected").val();
var footerFontText = $("#themeFooterFont :selected").text(); var footerFontText = $("#themeFooterFont :selected").text();
@ -38,7 +38,7 @@ $("input, select").on("change", function() {
// Taille, couleur, épaisseur et capitalisation du titre de la bannière // Taille, couleur, épaisseur et capitalisation du titre de la bannière
css += "footer span, #footerText > p {color:" + $("#themeFooterTextColor").val() + ";font-family:'" + footerFontText + "',sans-serif;font-weight:" + $("#themeFooterFontWeight").val() + ";font-size:" + $("#themeFooterFontSize").val() + ";text-transform:" + $("#themeFooterTextTransform").val() + "}"; css += "footer span, #footerText > p {color:" + $("#themeFooterTextColor").val() + ";font-family:'" + footerFontText + "',sans-serif;font-weight:" + $("#themeFooterFontWeight").val() + ";font-size:" + $("#themeFooterFontSize").val() + ";text-transform:" + $("#themeFooterTextTransform").val() + "}";
// Marge // Marge
if($("#themeFooterMargin").is(":checked")) { if ($("#themeFooterMargin").is(":checked")) {
css += 'footer{padding: 0 20px;}'; css += 'footer{padding: 0 20px;}';
} }
else { else {
@ -52,65 +52,65 @@ $("input, select").on("change", function() {
.text(css) .text(css)
.appendTo("footer"); .appendTo("footer");
// Position du pied de page // Position du pied de page
switch($("#themeFooterPosition").val()) { switch ($("#themeFooterPosition").val()) {
case 'hide': case 'hide':
$("footer").hide(); $("footer").hide();
break; break;
case 'site': case 'site':
$("footer").show().appendTo("#site"); $("footer").show().appendTo("#site");
$("footer > div:first-child").removeAttr("class"); $("footer > div:first-child").removeAttr("class");
$("footer > div:first-child").addClass("container"); $("footer > div:first-child").addClass("container");
break; break;
case 'body': case 'body':
$("footer").show().appendTo("body"); $("footer").show().appendTo("body");
$("footer > div:first-child").removeAttr("class"); $("footer > div:first-child").removeAttr("class");
$("footer > div:first-child").addClass("container-large"); $("footer > div:first-child").addClass("container-large");
break; break;
} }
// Réduire la marge du paragraphe de la zone de texte enrichie // Réduire la marge du paragraphe de la zone de texte enrichie
$("#footerText > p").css("margin-top","0"); $("#footerText > p").css("margin-top", "0");
$("#footerText > p").css("margin-bottom","0"); $("#footerText > p").css("margin-bottom", "0");
}); });
// Position dans les blocs // Position dans les blocs
// Bloc texte personnalisé // Bloc texte personnalisé
$(".themeFooterContent").on("change",function() { $(".themeFooterContent").on("change", function () {
// Position site ou body // Position site ou body
var footerPosition = $("#themeFooterPosition").val(); var footerPosition = $("#themeFooterPosition").val();
switch($("#themeFooterTextPosition").val()) { switch ($("#themeFooterTextPosition").val()) {
case "hide": case "hide":
$("#footerText").hide(); $("#footerText").hide();
break; break;
default: default:
// Choix de la position du bloc // Choix de la position du bloc
textPosition = $("#themeFooterTextPosition").val(); textPosition = $("#themeFooterTextPosition").val();
textPosition = textPosition.substr(0,1).toUpperCase()+textPosition.substr(1); textPosition = textPosition.substr(0, 1).toUpperCase() + textPosition.substr(1);
$("#footerText").show().appendTo("#footer" + footerPosition + textPosition); $("#footerText").show().appendTo("#footer" + footerPosition + textPosition);
break; break;
} }
switch($("#themeFooterSocialsPosition").val()) { switch ($("#themeFooterSocialsPosition").val()) {
case 'hide': case 'hide':
$("#footerSocials").hide(); $("#footerSocials").hide();
break; break;
default: default:
// Choix de la position du bloc // Choix de la position du bloc
socialsPosition = $("#themeFooterSocialsPosition").val(); socialsPosition = $("#themeFooterSocialsPosition").val();
socialsPosition = socialsPosition.substr(0,1).toUpperCase()+socialsPosition.substr(1); socialsPosition = socialsPosition.substr(0, 1).toUpperCase() + socialsPosition.substr(1);
$("#footerSocials").show().appendTo("#footer" + footerPosition + socialsPosition); $("#footerSocials").show().appendTo("#footer" + footerPosition + socialsPosition);
break; break;
} }
switch($("#themeFooterCopyrightPosition").val()) { switch ($("#themeFooterCopyrightPosition").val()) {
case 'hide': case 'hide':
$("#footerCopyright").hide(); $("#footerCopyright").hide();
break; break;
default: default:
// Choix de la position du bloc // Choix de la position du bloc
copyrightPosition = $("#themeFooterCopyrightPosition").val(); copyrightPosition = $("#themeFooterCopyrightPosition").val();
copyrightPosition = copyrightPosition.substr(0,1).toUpperCase()+copyrightPosition.substr(1); copyrightPosition = copyrightPosition.substr(0, 1).toUpperCase() + copyrightPosition.substr(1);
$("#footerCopyright").show().appendTo("#footer" + footerPosition + copyrightPosition); $("#footerCopyright").show().appendTo("#footer" + footerPosition + copyrightPosition);
break; break;
} }
@ -119,47 +119,47 @@ $(".themeFooterContent").on("change",function() {
// Fin Position dans les blocs // Fin Position dans les blocs
// Modification dynamique de la mise en page // Modification dynamique de la mise en page
$("#themeFooterTemplate").on("change",function() { $("#themeFooterTemplate").on("change", function () {
// Nettoyage des sélecteurs des contenus // Nettoyage des sélecteurs des contenus
var newOptions = { var newOptions = {
4: {'hide' : 'Masqué', 'left' : 'En haut', 'center' : 'Au milieu', 'right' : 'En bas'} , 4: { 'hide': 'Masqué', 'left': 'En haut', 'center': 'Au milieu', 'right': 'En bas' },
3: {'hide': 'Masqué', 'left': 'A gauche', 'center': 'Au centre', 'right': 'A droite'} , 3: { 'hide': 'Masqué', 'left': 'A gauche', 'center': 'Au centre', 'right': 'A droite' },
2: {'hide': 'Masqué', 'left': 'A gauche', 'right': 'A droite'} , 2: { 'hide': 'Masqué', 'left': 'A gauche', 'right': 'A droite' },
1: {'hide': 'Masqué', 'center': 'Affiché'} 1: { 'hide': 'Masqué', 'center': 'Affiché' }
}; };
var $el = $(".themeFooterContent"); var $el = $(".themeFooterContent");
$el.empty(); $el.empty();
// Eléments des position de contenus // Eléments des position de contenus
$.each(newOptions[$("#themeFooterTemplate").val()], function(key,value) { $.each(newOptions[$("#themeFooterTemplate").val()], function (key, value) {
$el.append($("<option></option>") $el.append($("<option></option>")
.attr("value", key).text(value)); .attr("value", key).text(value));
}); });
var position = $("#themeFooterPosition").val(); var position = $("#themeFooterPosition").val();
// Masquer les contenus // Masquer les contenus
$("#footerCopyright").hide(); $("#footerCopyright").hide();
$("#footerText").hide(); $("#footerText").hide();
$("#footerSocials").hide(); $("#footerSocials").hide();
// Dimension des blocs // Dimension des blocs
switch($("#themeFooterTemplate").val()) { switch ($("#themeFooterTemplate").val()) {
case "1": case "1":
$("#footer" + position + "Left").css("display","none"); $("#footer" + position + "Left").css("display", "none");
$("#footer" + position + "Center").removeAttr('class').addClass("col12").css("display",""); $("#footer" + position + "Center").removeAttr('class').addClass("col12").css("display", "");
$("#footer" + position + "Right").css("display","none"); $("#footer" + position + "Right").css("display", "none");
break; break;
case "2": case "2":
$("#footer" + position + "Left").removeAttr('class').addClass('col6').css("display",""); $("#footer" + position + "Left").removeAttr('class').addClass('col6').css("display", "");
$("#footer" + position + "Center").css("display","none").removeAttr('class'); $("#footer" + position + "Center").css("display", "none").removeAttr('class');
$("#footer" + position + "Right").removeAttr('class').addClass('col6').css("display",""); $("#footer" + position + "Right").removeAttr('class').addClass('col6').css("display", "");
break; break;
case "3": case "3":
$("#footer" + position + "Left").removeAttr('class').addClass('col4').css("display",""); $("#footer" + position + "Left").removeAttr('class').addClass('col4').css("display", "");
$("#footer" + position + "Center").removeAttr('class').addClass('col4').css("display",""); $("#footer" + position + "Center").removeAttr('class').addClass('col4').css("display", "");
$("#footer" + position + "Right").removeAttr('class').addClass('col4').css("display",""); $("#footer" + position + "Right").removeAttr('class').addClass('col4').css("display", "");
break; break;
case "4": case "4":
$("#footer" + position + "Left").removeAttr('class').addClass('col12').css("display",""); $("#footer" + position + "Left").removeAttr('class').addClass('col12').css("display", "");
$("#footer" + position + "Center").removeAttr('class').addClass('col12').css("display",""); $("#footer" + position + "Center").removeAttr('class').addClass('col12').css("display", "");
$("#footer" + position + "Right").removeAttr('class').addClass('col12').css("display",""); $("#footer" + position + "Right").removeAttr('class').addClass('col12').css("display", "");
break; break;
} }
@ -167,58 +167,58 @@ $("#themeFooterTemplate").on("change",function() {
// Désactivation des sélections multiples // Désactivation des sélections multiples
$("#themeFooterSocialsPosition").on("change", function() { $("#themeFooterSocialsPosition").on("change", function () {
if ($(this).prop('selectedIndex') >= 1 ) { if ($(this).prop('selectedIndex') >= 1) {
if ( $("#themeFooterTextPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) { if ($("#themeFooterTextPosition").prop('selectedIndex') === $(this).prop('selectedIndex')) {
$("#themeFooterTextPosition").prop('selectedIndex',0); $("#themeFooterTextPosition").prop('selectedIndex', 0);
$("#footerText").hide(); $("#footerText").hide();
} }
if ( $("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) { if ($("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex')) {
$("#themeFooterCopyrightPosition").prop('selectedIndex',0); $("#themeFooterCopyrightPosition").prop('selectedIndex', 0);
$("#footerCopyright").hide(); $("#footerCopyright").hide();
} }
} }
}).trigger("change"); }).trigger("change");
$("#themeFooterTextPosition").on("change", function() { $("#themeFooterTextPosition").on("change", function () {
if ($(this).prop('selectedIndex') >= 1 ) { if ($(this).prop('selectedIndex') >= 1) {
if ( $("#themeFooterSocialsPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) { if ($("#themeFooterSocialsPosition").prop('selectedIndex') === $(this).prop('selectedIndex')) {
$("#themeFooterSocialsPosition").prop('selectedIndex',0); $("#themeFooterSocialsPosition").prop('selectedIndex', 0);
$("#footerSocials").hide(); $("#footerSocials").hide();
} }
if ( $("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) { if ($("#themeFooterCopyrightPosition").prop('selectedIndex') === $(this).prop('selectedIndex')) {
$("#themeFooterCopyrightPosition").prop('selectedIndex',0); $("#themeFooterCopyrightPosition").prop('selectedIndex', 0);
$("#footerCopyright").hide(); $("#footerCopyright").hide();
} }
} }
}).trigger("change"); }).trigger("change");
$("#themeFooterCopyrightPosition").on("change", function() { $("#themeFooterCopyrightPosition").on("change", function () {
if ($(this).prop('selectedIndex') >= 1 ) { if ($(this).prop('selectedIndex') >= 1) {
if ( $("#themeFooterTextPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) { if ($("#themeFooterTextPosition").prop('selectedIndex') === $(this).prop('selectedIndex')) {
$("#themeFooterTextPosition").prop('selectedIndex',0); $("#themeFooterTextPosition").prop('selectedIndex', 0);
$("#footerText").hide(); $("#footerText").hide();
}
if ( $("#themeFooterSocialsPosition").prop('selectedIndex') === $(this).prop('selectedIndex') ) {
$("#themeFooterSocialsPosition").prop('selectedIndex',0);
$("#footerSocials").hide();
}
} }
if ($("#themeFooterSocialsPosition").prop('selectedIndex') === $(this).prop('selectedIndex')) {
$("#themeFooterSocialsPosition").prop('selectedIndex', 0);
$("#footerSocials").hide();
}
}
}).trigger("change"); }).trigger("change");
// Affiche / Cache les options du footer fixe // Affiche / Cache les options du footer fixe
$("#themeFooterPosition").on("change", function() { $("#themeFooterPosition").on("change", function () {
if($(this).val() === 'body') { if ($(this).val() === 'body') {
$("#themeFooterPositionFixed").slideDown(); $("#themeFooterPositionFixed").slideDown();
} }
else { else {
$("#themeFooterPositionFixed").slideUp(function() { $("#themeFooterPositionFixed").slideUp(function () {
$("#themeFooterFixed").prop("checked", false).trigger("change"); $("#themeFooterFixed").prop("checked", false).trigger("change");
}); });
} }
}).trigger("change"); }).trigger("change");
// Lien de connexion // Lien de connexion
$("#themeFooterLoginLink").on("change", function() { $("#themeFooterLoginLink").on("change", function () {
if($(this).is(":checked")) { if ($(this).is(":checked")) {
$("#footerLoginLink").show(); $("#footerLoginLink").show();
} }
else { else {
@ -227,8 +227,8 @@ $("#themeFooterLoginLink").on("change", function() {
}).trigger("change"); }).trigger("change");
// Numéro de version // Numéro de version
$("#themefooterDisplayVersion").on("change", function() { $("#themefooterDisplayVersion").on("change", function () {
if($(this).is(":checked")) { if ($(this).is(":checked")) {
$("#footerDisplayVersion").show(); $("#footerDisplayVersion").show();
} }
else { else {
@ -237,8 +237,8 @@ $("#themefooterDisplayVersion").on("change", function() {
}).trigger("change"); }).trigger("change");
// Numéro de version // Numéro de version
$("#themefooterDisplayCopyright").on("change", function() { $("#themefooterDisplayCopyright").on("change", function () {
if($(this).is(":checked")) { if ($(this).is(":checked")) {
$("#footerDisplayCopyright").show(); $("#footerDisplayCopyright").show();
} }
else { else {
@ -247,8 +247,8 @@ $("#themefooterDisplayCopyright").on("change", function() {
}).trigger("change"); }).trigger("change");
// Site Map // Site Map
$("#themefooterDisplaySiteMap").on("change", function() { $("#themefooterDisplaySiteMap").on("change", function () {
if($(this).is(":checked")) { if ($(this).is(":checked")) {
$("#footerDisplaySiteMap").show(); $("#footerDisplaySiteMap").show();
} }
else { else {
@ -257,8 +257,8 @@ $("#themefooterDisplaySiteMap").on("change", function() {
}).trigger("change"); }).trigger("change");
// Rechercher // Rechercher
$("#themeFooterDisplaySearch").on("change", function() { $("#themeFooterDisplaySearch").on("change", function () {
if($(this).is(":checked")) { if ($(this).is(":checked")) {
$("#footerDisplaySearch").show(); $("#footerDisplaySearch").show();
} }
else { else {
@ -267,8 +267,8 @@ $("#themeFooterDisplaySearch").on("change", function() {
}).trigger("change"); }).trigger("change");
// Mentions légales // Mentions légales
$("#themeFooterDisplayLegal").on("change", function() { $("#themeFooterDisplayLegal").on("change", function () {
if($(this).is(":checked")) { if ($(this).is(":checked")) {
$("#footerDisplayLegal").show(); $("#footerDisplayLegal").show();
} }
else { else {
@ -278,22 +278,22 @@ $("#themeFooterDisplayLegal").on("change", function() {
// Pages spéciales : activation si une page est sélectionnée // Pages spéciales : activation si une page est sélectionnée
$("#configLegalPageId").on("change", function() { $("#configLegalPageId").on("change", function () {
if ( $("#configLegalPageId option:selected").text() === 'Aucune') { if ($("#configLegalPageId option:selected").text() === 'Aucune') {
$("#themeFooterDisplayLegal").prop('checked', false); $("#themeFooterDisplayLegal").prop('checked', false);
$("#themeFooterDisplayLegal").prop( "disabled", true ); $("#themeFooterDisplayLegal").prop("disabled", true);
$("#footerDisplayLegal").hide(); $("#footerDisplayLegal").hide();
} else { } else {
$("#themeFooterDisplayLegal").prop( "disabled", false ); $("#themeFooterDisplayLegal").prop("disabled", false);
} }
}).trigger("change"); }).trigger("change");
$("#configSearchPageId").on("change", function() { $("#configSearchPageId").on("change", function () {
if ( $("#configSearchPageId option:selected").text() === 'Aucune') { if ($("#configSearchPageId option:selected").text() === 'Aucune') {
$("#themeFooterDisplaySearch").prop('checked', false); $("#themeFooterDisplaySearch").prop('checked', false);
$("#themeFooterDisplaySearch").prop( "disabled", true ); $("#themeFooterDisplaySearch").prop("disabled", true);
$("#footerDisplaySearch").hide(); $("#footerDisplaySearch").hide();
} else { } else {
$("#themeFooterDisplaySearch").prop( "disabled", false ); $("#themeFooterDisplaySearch").prop("disabled", false);
} }
}).trigger("change"); }).trigger("change");

View File

@ -2,18 +2,18 @@
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('themeFooterBack', [ <?php echo template::button('themeFooterBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme', 'href' => helper::baseUrl() . 'theme',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col1"> <div class="col1">
<?php echo template::button('themeFooterHelp', [ <?php echo template::button('themeFooterHelp', [
'href' => 'https://doc.zwiicms.fr/pied-de-page', 'href' => 'https://doc.zwiicms.fr/pied-de-page',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'class' => 'buttonHelp' 'class' => 'buttonHelp'
]); ?> ]); ?>
</div> </div>
<div class="col2 offset8"> <div class="col2 offset8">
<?php echo template::submit('themeFooterSubmit'); ?> <?php echo template::submit('themeFooterSubmit'); ?>
@ -26,30 +26,30 @@
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::select('themeFooterPosition', $module::$footerPositions, [ <?php echo template::select('themeFooterPosition', $module::$footerPositions, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'footer', 'position']) 'selected' => $this->getData(['theme', 'footer', 'position'])
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('themeFooterHeight', $module::$footerHeights, [ <?php echo template::select('themeFooterHeight', $module::$footerHeights, [
'label' => 'Marges verticales', 'label' => 'Marges verticales',
'selected' => $this->getData(['theme', 'footer', 'height']) 'selected' => $this->getData(['theme', 'footer', 'height'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<div id="themeFooterPositionOptions"> <div id="themeFooterPositionOptions">
<?php echo template::checkbox('themeFooterMargin', true, 'Alignement avec le contenu', [ <?php echo template::checkbox('themeFooterMargin', true, 'Alignement avec le contenu', [
'checked' => $this->getData(['theme', 'footer', 'margin']) 'checked' => $this->getData(['theme', 'footer', 'margin'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="col6"> <div class="col6">
<div id="themeFooterPositionFixed" class="displayNone"> <div id="themeFooterPositionFixed" class="displayNone">
<?php echo template::checkbox('themeFooterFixed', true, 'Pied de page fixe', [ <?php echo template::checkbox('themeFooterFixed', true, 'Pied de page fixe', [
'checked' => $this->getData(['theme', 'footer', 'fixed']) 'checked' => $this->getData(['theme', 'footer', 'fixed'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -87,35 +87,35 @@
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themefooterDisplayCopyright', true, 'Motorisé par', [ <?php echo template::checkbox('themefooterDisplayCopyright', true, 'Motorisé par', [
'checked' => $this->getData(['theme', 'footer','displayCopyright']), 'checked' => $this->getData(['theme', 'footer', 'displayCopyright']),
'help' => 'Affiche cette mention devant ZwiiCMS' 'help' => 'Affiche cette mention devant ZwiiCMS'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themefooterDisplayVersion', true, 'Version', [ <?php echo template::checkbox('themefooterDisplayVersion', true, 'Version', [
'checked' => $this->getData(['theme', 'footer','displayVersion']), 'checked' => $this->getData(['theme', 'footer', 'displayVersion']),
'help' => 'Affiche le numéro de version après ZwiiCMS' 'help' => 'Affiche le numéro de version après ZwiiCMS'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themefooterDisplaySiteMap', true, 'Plan du site', [ <?php echo template::checkbox('themefooterDisplaySiteMap', true, 'Plan du site', [
'checked' => $this->getData(['theme', 'footer', 'displaySiteMap']) 'checked' => $this->getData(['theme', 'footer', 'displaySiteMap'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themefooterDisplayCookie', true, 'Cookies', [ <?php echo template::checkbox('themefooterDisplayCookie', true, 'Cookies', [
'checked' => $this->getData(['config', 'cookieConsent']) === true ? $this->getData(['theme', 'footer', 'displayCookie']) : false, 'checked' => $this->getData(['config', 'cookieConsent']) === true ? $this->getData(['theme', 'footer', 'displayCookie']) : false,
'help' => 'Message d\'information relatif aux cookies, disponible si l\'acceptation des cookies est activé.', 'help' => 'Message d\'information relatif aux cookies, disponible si l\'acceptation des cookies est activé.',
'disabled' => !$this->getData(['config', 'cookieConsent']) 'disabled' => !$this->getData(['config', 'cookieConsent'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themeFooterLoginLink', true, 'Lien de connexion', [ <?php echo template::checkbox('themeFooterLoginLink', true, 'Lien de connexion', [
'checked' => $this->getData(['theme', 'footer', 'loginLink']), 'checked' => $this->getData(['theme', 'footer', 'loginLink']),
'help' => 'Pour limiter les tentatives de piratage, enregistrez la page de connexion en favori et désactivez cette option.' 'help' => 'Pour limiter les tentatives de piratage, enregistrez la page de connexion en favori et désactivez cette option.'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themeFooterMemberBar', true, 'Barre du membre', [ <?php echo template::checkbox('themeFooterMemberBar', true, 'Barre du membre', [
@ -127,13 +127,13 @@
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themeFooterDisplayLegal', true, 'Mentions légales', [ <?php echo template::checkbox('themeFooterDisplayLegal', true, 'Mentions légales', [
'checked' => $this->getData(['locale', 'legalPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displayLegal']), 'checked' => $this->getData(['locale', 'legalPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displayLegal']),
'disabled' => $this->getData(['locale', 'legalPageId']) === 'none' ? true : false, 'disabled' => $this->getData(['locale', 'legalPageId']) === 'none' ? true : false,
'help' => 'Option active si une page a été sélectionnée.' 'help' => 'Option active si une page a été sélectionnée.'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('configLegalPageId', array_merge(['none' => 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ <?php echo template::select('configLegalPageId', array_merge(['none' => 'Aucune'], helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC')), [
'label' => 'Page "Mentions légales" ' . template::flag('selected', '20px'), 'label' => 'Page "Mentions légales" ' . template::flag('selected', '20px'),
'selected' => $this->getData(['locale', 'legalPageId']) 'selected' => $this->getData(['locale', 'legalPageId'])
]); ?> ]); ?>
@ -141,13 +141,13 @@
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themeFooterDisplaySearch', true, 'Rechercher', [ <?php echo template::checkbox('themeFooterDisplaySearch', true, 'Rechercher', [
'checked' => $this->getData(['locale', 'searchPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displaySearch']), 'checked' => $this->getData(['locale', 'searchPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displaySearch']),
'disabled' => $this->getData(['locale', 'searchPageId']) === 'none' ? true : false, 'disabled' => $this->getData(['locale', 'searchPageId']) === 'none' ? true : false,
'help' => 'Option active si une page a été sélectionnée.' 'help' => 'Option active si une page a été sélectionnée.'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('configSearchPageId', array_merge(['none' => 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ <?php echo template::select('configSearchPageId', array_merge(['none' => 'Aucune'], helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC')), [
'label' => 'Page "Rechercher" ' . template::flag('selected', '20px'), 'label' => 'Page "Rechercher" ' . template::flag('selected', '20px'),
'selected' => $this->getData(['locale', 'searchPageId']) 'selected' => $this->getData(['locale', 'searchPageId'])
]); ?> ]); ?>
@ -159,10 +159,10 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::textarea('themeFooterText', [ <?php echo template::textarea('themeFooterText', [
'label' => '<div class="titleWysiwygContent">' . template::topic('Contenu personnalisé') .'</div>', 'label' => '<div class="titleWysiwygContent">' . template::topic('Contenu personnalisé') . '</div>',
'value' => $this->getData(['theme', 'footer', 'text']), 'value' => $this->getData(['theme', 'footer', 'text']),
'class' => 'editorWysiwyg' 'class' => 'editorWysiwyg'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -174,29 +174,29 @@
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::select('themeFooterFont', $module::$fonts['name'], [ <?php echo template::select('themeFooterFont', $module::$fonts['name'], [
'label' => 'Fonte', 'label' => 'Fonte',
'selected' => $this->getData(['theme', 'footer', 'font']), 'selected' => $this->getData(['theme', 'footer', 'font']),
'fonts' => $module::$fonts['family'] 'fonts' => $module::$fonts['family']
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('themeFooterFontSize', $module::$footerFontSizes, [ <?php echo template::select('themeFooterFontSize', $module::$footerFontSizes, [
'label' => 'Taille', 'label' => 'Taille',
'help' => 'Proportionnelle à celle définie dans le site.', 'help' => 'Proportionnelle à celle définie dans le site.',
'selected' => $this->getData(['theme', 'footer', 'fontSize']) 'selected' => $this->getData(['theme', 'footer', 'fontSize'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('themeFooterFontWeight', $module::$fontWeights, [ <?php echo template::select('themeFooterFontWeight', $module::$fontWeights, [
'label' => 'Style', 'label' => 'Style',
'selected' => $this->getData(['theme', 'footer', 'fontWeight']) 'selected' => $this->getData(['theme', 'footer', 'fontWeight'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('themeFooterTextTransform', $module::$textTransforms, [ <?php echo template::select('themeFooterTextTransform', $module::$textTransforms, [
'label' => 'Casse', 'label' => 'Casse',
'selected' => $this->getData(['theme', 'footer', 'textTransform']) 'selected' => $this->getData(['theme', 'footer', 'textTransform'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -210,11 +210,11 @@
</h4> </h4>
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php $footerBlockPosition = is_null($this->getData(['theme', 'footer', 'template'])) ? $module::$footerblocks[3] : $module::$footerblocks [$this->getData(['theme', 'footer', 'template'])] ;?> <?php $footerBlockPosition = is_null($this->getData(['theme', 'footer', 'template'])) ? $module::$footerblocks[3] : $module::$footerblocks[$this->getData(['theme', 'footer', 'template'])]; ?>
<?php echo template::select('themeFooterTemplate', $module::$footerTemplate, [ <?php echo template::select('themeFooterTemplate', $module::$footerTemplate, [
'label' => 'Répartition', 'label' => 'Répartition',
'selected' => is_null($this->getData(['theme', 'footer', 'template'])) ? 4 : $this->getData(['theme', 'footer', 'template']) 'selected' => is_null($this->getData(['theme', 'footer', 'template'])) ? 4 : $this->getData(['theme', 'footer', 'template'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -227,42 +227,42 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::select('themeFooterTextPosition', $footerBlockPosition, [ <?php echo template::select('themeFooterTextPosition', $footerBlockPosition, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'footer', 'textPosition']), 'selected' => $this->getData(['theme', 'footer', 'textPosition']),
'class' => 'themeFooterContent' 'class' => 'themeFooterContent'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::select('themeFooterTextAlign', $module::$aligns, [ <?php echo template::select('themeFooterTextAlign', $module::$aligns, [
'label' => 'Alignement', 'label' => 'Alignement',
'selected' => $this->getData(['theme', 'footer', 'textAlign']) 'selected' => $this->getData(['theme', 'footer', 'textAlign'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
<div class="col4"> <div class="col4">
<p> <p>
<strong> <strong>
<?php echo template::topic('Réseaux sociaux'); ?> <?php echo template::topic('Réseaux sociaux'); ?>
</strong> </strong>
</p> </p>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::select('themeFooterSocialsPosition', $footerBlockPosition, [ <?php echo template::select('themeFooterSocialsPosition', $footerBlockPosition, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'footer', 'socialsPosition']), 'selected' => $this->getData(['theme', 'footer', 'socialsPosition']),
'class' => 'themeFooterContent' 'class' => 'themeFooterContent'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::select('themeFooterSocialsAlign', $module::$aligns, [ <?php echo template::select('themeFooterSocialsAlign', $module::$aligns, [
'label' => 'Alignement', 'label' => 'Alignement',
'selected' => $this->getData(['theme', 'footer', 'socialsAlign']) 'selected' => $this->getData(['theme', 'footer', 'socialsAlign'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -275,18 +275,18 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::select('themeFooterCopyrightPosition', $footerBlockPosition, [ <?php echo template::select('themeFooterCopyrightPosition', $footerBlockPosition, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'footer', 'copyrightPosition']), 'selected' => $this->getData(['theme', 'footer', 'copyrightPosition']),
'class' => 'themeFooterContent' 'class' => 'themeFooterContent'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::select('themeFooterCopyrightAlign', $module::$aligns, [ <?php echo template::select('themeFooterCopyrightAlign', $module::$aligns, [
'label' => 'Alignement', 'label' => 'Alignement',
'selected' => $this->getData(['theme', 'footer', 'copyrightAlign']) 'selected' => $this->getData(['theme', 'footer', 'copyrightAlign'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -294,4 +294,4 @@
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -2,18 +2,18 @@
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('themeHeaderBack', [ <?php echo template::button('themeHeaderBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme', 'href' => helper::baseUrl() . 'theme',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col1"> <div class="col1">
<?php echo template::button('themeHeaderHelp', [ <?php echo template::button('themeHeaderHelp', [
'href' => 'https://doc.zwiicms.fr/banniere', 'href' => 'https://doc.zwiicms.fr/banniere',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'class' => 'buttonHelp' 'class' => 'buttonHelp'
]); ?> ]); ?>
</div> </div>
<div class="col2 offset8"> <div class="col2 offset8">
<?php echo template::submit('themeHeaderSubmit'); ?> <?php echo template::submit('themeHeaderSubmit'); ?>
@ -28,44 +28,44 @@
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderPosition', $module::$headerPositions, [ <?php echo template::select('themeHeaderPosition', $module::$headerPositions, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'header', 'position']) 'selected' => $this->getData(['theme', 'header', 'position'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderFeature', $module::$headerFeatures, [ <?php echo template::select('themeHeaderFeature', $module::$headerFeatures, [
'label' => 'Nature de contenu', 'label' => 'Nature de contenu',
'selected' => $this->getData(['theme', 'header', 'feature']) 'selected' => $this->getData(['theme', 'header', 'feature'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderHeight', $module::$headerHeights, [ <?php echo template::select('themeHeaderHeight', $module::$headerHeights, [
'label' => 'Hauteur maximale', 'label' => 'Hauteur maximale',
'selected' => $this->getData(['theme', 'header', 'height']), 'selected' => $this->getData(['theme', 'header', 'height']),
'help' => 'La hauteur maximale est de 600 pixels, même si les dimensions de l\'image sélectionnée sont supérieures. <br />Lorsque l\'adaptation est positionnée sur Responsive, la hauteur diminue proportionnellement à la largeur.' 'help' => 'La hauteur maximale est de 600 pixels, même si les dimensions de l\'image sélectionnée sont supérieures. <br />Lorsque l\'adaptation est positionnée sur Responsive, la hauteur diminue proportionnellement à la largeur.'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderWide', $module::$containerWides, [ <?php echo template::select('themeHeaderWide', $module::$containerWides, [
'label' => 'Largeur', 'label' => 'Largeur',
'selected' => $this->getData(['theme', 'header', 'wide']) 'selected' => $this->getData(['theme', 'header', 'wide'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<div id="themeHeaderSmallDisplay" class="displayNone"> <div id="themeHeaderSmallDisplay" class="displayNone">
<?php echo template::checkbox('themeHeaderTinyHidden', true, 'Masquer la bannière en écran réduit', [ <?php echo template::checkbox('themeHeaderTinyHidden', true, 'Masquer la bannière en écran réduit', [
'checked' => $this->getData(['theme', 'header', 'tinyHidden']) 'checked' => $this->getData(['theme', 'header', 'tinyHidden'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="col4"> <div class="col4">
<div id="themeHeaderPositionOptions" class="displayNone"> <div id="themeHeaderPositionOptions" class="displayNone">
<?php echo template::checkbox('themeHeaderMargin', true, 'Aligner la bannière avec le contenu', [ <?php echo template::checkbox('themeHeaderMargin', true, 'Aligner la bannière avec le contenu', [
'checked' => $this->getData(['theme', 'header', 'margin']) 'checked' => $this->getData(['theme', 'header', 'margin'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -81,19 +81,19 @@
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::text('themeHeaderBackgroundColor', [ <?php echo template::text('themeHeaderBackgroundColor', [
'class' => 'colorPicker', 'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Arrière-plan', 'label' => 'Arrière-plan',
'value' => $this->getData(['theme', 'header', 'backgroundColor']) 'value' => $this->getData(['theme', 'header', 'backgroundColor'])
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::text('themeHeaderTextColor', [ <?php echo template::text('themeHeaderTextColor', [
'class' => 'colorPicker', 'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Texte', 'label' => 'Texte',
'value' => $this->getData(['theme', 'header', 'textColor']) 'value' => $this->getData(['theme', 'header', 'textColor'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -108,42 +108,42 @@
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::checkbox('themeHeaderTextHide', true, 'Masquer le titre du site', [ <?php echo template::checkbox('themeHeaderTextHide', true, 'Masquer le titre du site', [
'checked' => $this->getData(['theme', 'header', 'textHide']) 'checked' => $this->getData(['theme', 'header', 'textHide'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderFont', $module::$fonts['name'], [ <?php echo template::select('themeHeaderFont', $module::$fonts['name'], [
'label' => 'Fonte', 'label' => 'Fonte',
'selected' => $this->getData(['theme', 'header', 'font']), 'selected' => $this->getData(['theme', 'header', 'font']),
'fonts' => $module::$fonts['family'] 'fonts' => $module::$fonts['family']
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderFontSize', $module::$headerFontSizes, [ <?php echo template::select('themeHeaderFontSize', $module::$headerFontSizes, [
'label' => 'Taille', 'label' => 'Taille',
'help' => 'Proportionnelle à celle définie dans le site.', 'help' => 'Proportionnelle à celle définie dans le site.',
'selected' => $this->getData(['theme', 'header', 'fontSize']) 'selected' => $this->getData(['theme', 'header', 'fontSize'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderFontWeight', $module::$fontWeights, [ <?php echo template::select('themeHeaderFontWeight', $module::$fontWeights, [
'label' => 'Style', 'label' => 'Style',
'selected' => $this->getData(['theme', 'header', 'fontWeight']) 'selected' => $this->getData(['theme', 'header', 'fontWeight'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderTextTransform', $module::$textTransforms, [ <?php echo template::select('themeHeaderTextTransform', $module::$textTransforms, [
'label' => 'Casse', 'label' => 'Casse',
'selected' => $this->getData(['theme', 'header', 'textTransform']) 'selected' => $this->getData(['theme', 'header', 'textTransform'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeHeaderTextAlign', $module::$aligns, [ <?php echo template::select('themeHeaderTextAlign', $module::$aligns, [
'label' => 'Alignement du contenu', 'label' => 'Alignement du contenu',
'selected' => $this->getData(['theme', 'header', 'textAlign']) 'selected' => $this->getData(['theme', 'header', 'textAlign'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -159,14 +159,14 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php <?php
$imageFile = file_exists(self::FILE_DIR.'source/'.$this->getData(['theme', 'header', 'image'])) ? $imageFile = file_exists(self::FILE_DIR . 'source/' . $this->getData(['theme', 'header', 'image'])) ?
$this->getData(['theme', 'header', 'image']) : ""; $this->getData(['theme', 'header', 'image']) : "";
echo template::file('themeHeaderImage', [ echo template::file('themeHeaderImage', [
'label' => 'Image', 'label' => 'Image',
'type' => 1, 'type' => 1,
'value' => $imageFile 'value' => $imageFile
]); ?> ]); ?>
<span class="themeHeaderImageOptions displayNone" id="themeHeaderImageInfo"> <span class="themeHeaderImageOptions displayNone" id="themeHeaderImageInfo">
<?php echo template::topic('Largeur de l\'image :'); ?> <span id="themeHeaderImageWidth"></span> ( <?php echo template::topic('largeur de site :'); ?> <?php echo $this->getData(['theme', 'site', 'width']); ?>) <?php echo template::topic('Largeur de l\'image :'); ?> <span id="themeHeaderImageWidth"></span> ( <?php echo template::topic('largeur de site :'); ?> <?php echo $this->getData(['theme', 'site', 'width']); ?>)
- -
<?php echo template::topic('Hargeur de l\'image :'); ?> <span id="themeHeaderImageHeight"></span> <?php echo template::topic('Hargeur de l\'image :'); ?> <span id="themeHeaderImageHeight"></span>
@ -179,29 +179,29 @@
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::select('themeHeaderImageRepeat', $module::$repeats, [ <?php echo template::select('themeHeaderImageRepeat', $module::$repeats, [
'label' => 'Répétition', 'label' => 'Répétition',
'selected' => $this->getData(['theme', 'header', 'imageRepeat']) 'selected' => $this->getData(['theme', 'header', 'imageRepeat'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('themeHeaderImageContainer', $module::$headerWide, [ <?php echo template::select('themeHeaderImageContainer', $module::$headerWide, [
'label' => 'Adaptation', 'label' => 'Adaptation',
'selected' => $this->getData(['theme', 'header', 'imageContainer']), 'selected' => $this->getData(['theme', 'header', 'imageContainer']),
'help' => 'Les modes responsives permettent de conserver des dimensions proportionnelles.<br /> 'help' => 'Les modes responsives permettent de conserver des dimensions proportionnelles.<br />
Cover pour une image plus grande que la bannière, Contain pour une image plus petite. Cover pour une image plus grande que la bannière, Contain pour une image plus petite.
Les modes Auto et Etiré ne provoquent pas de modification de la hauteur de la bannière.' Les modes Auto et Etiré ne provoquent pas de modification de la hauteur de la bannière.'
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::select('themeHeaderImagePosition', $module::$imagePositions, [ <?php echo template::select('themeHeaderImagePosition', $module::$imagePositions, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'header', 'imagePosition']) 'selected' => $this->getData(['theme', 'header', 'imagePosition'])
]); ?> ]); ?>
</div> </div>
<div id="themeHeaderShow" class="col3"> <div id="themeHeaderShow" class="col3">
<?php echo template::checkbox('themeHeaderlinkHomePage', true, 'Bannière cliquable', [ <?php echo template::checkbox('themeHeaderlinkHomePage', true, 'Bannière cliquable', [
'checked' => $this->getData(['theme', 'header', 'linkHomePage']) 'checked' => $this->getData(['theme', 'header', 'linkHomePage'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -213,7 +213,7 @@
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::textarea('themeHeaderText', [ <?php echo template::textarea('themeHeaderText', [
'label' => '<div class="titleWysiwygContent">' . template::topic('Contenu personnalisé') .'</div>', 'label' => '<div class="titleWysiwygContent">' . template::topic('Contenu personnalisé') . '</div>',
'class' => 'editorWysiwyg', 'class' => 'editorWysiwyg',
'value' => $this->getData(['theme', 'header', 'featureContent']) 'value' => $this->getData(['theme', 'header', 'featureContent'])
]); ?> ]); ?>
@ -222,6 +222,6 @@
</div> </div>
</div> </div>
<div id="featureContent" class="displayNone"> <div id="featureContent" class="displayNone">
<?php echo $this->getData(['theme','header','featureContent']);?> <?php echo $this->getData(['theme', 'header', 'featureContent']); ?>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -60,7 +60,7 @@ $("<a>")
/** /**
* Affiche les zones cachées * Affiche les zones cachées
*/ */
$("#themeShowAll").on("click", function() { $("#themeShowAll").on("click", function () {
$("header.displayNone, nav.displayNone, footer.displayNone").slideToggle(); $("header.displayNone, nav.displayNone, footer.displayNone").slideToggle();
}); });
@ -68,9 +68,9 @@ $("#themeShowAll").on("click", function() {
* Simule un survole du site lors du survole de la section * Simule un survole du site lors du survole de la section
*/ */
$("section") $("section")
.on("mouseover", function() { .on("mouseover", function () {
$("#themeOverlaySite:not(.themeOverlayTriggerHover)").addClass("themeOverlayTriggerHover"); $("#themeOverlaySite:not(.themeOverlayTriggerHover)").addClass("themeOverlayTriggerHover");
}) })
.on("mouseleave", function() { .on("mouseleave", function () {
$("#themeOverlaySite.themeOverlayTriggerHover").removeClass("themeOverlayTriggerHover"); $("#themeOverlaySite.themeOverlayTriggerHover").removeClass("themeOverlayTriggerHover");
}); });

View File

@ -1,8 +1,8 @@
<?php if( <?php if (
$this->getData(['theme', 'header', 'position']) === 'hide' $this->getData(['theme', 'header', 'position']) === 'hide'
OR $this->getData(['theme', 'menu', 'position']) === 'hide' or $this->getData(['theme', 'menu', 'position']) === 'hide'
OR $this->getData(['theme', 'footer', 'position']) === 'hide' or $this->getData(['theme', 'footer', 'position']) === 'hide'
): ?> ) : ?>
<?php echo template::speech('Cliquez sur une zone afin d\'accéder à ses options de personnalisation. Vous pouvez également afficher les zones cachées à l\'aide du bouton ci-dessous.'); ?> <?php echo template::speech('Cliquez sur une zone afin d\'accéder à ses options de personnalisation. Vous pouvez également afficher les zones cachées à l\'aide du bouton ci-dessous.'); ?>
<div class="row"> <div class="row">
<div class="col2 offset3"> <div class="col2 offset3">
@ -45,7 +45,7 @@
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::button('themeAdmin', [ <?php echo template::button('themeAdmin', [
'ico' => 'brush', 'ico' => 'brush',
'href' => helper::baseUrl() . $this->getUrl(0) . '/admin', 'href' => helper::baseUrl() . $this->getUrl(0) . '/admin',
'value' => 'Administration' 'value' => 'Administration'
@ -60,7 +60,7 @@
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php else: ?> <?php else : ?>
<?php echo template::speech('Cliquez sur une zone afin d\'accéder à ses options de personnalisation.'); ?> <?php echo template::speech('Cliquez sur une zone afin d\'accéder à ses options de personnalisation.'); ?>
<div class="row"> <div class="row">
<div class="col2 offset4"> <div class="col2 offset4">
@ -97,7 +97,7 @@
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::button('themeAdmin', [ <?php echo template::button('themeAdmin', [
'ico' => 'brush', 'ico' => 'brush',
'href' => helper::baseUrl() . $this->getUrl(0) . '/admin', 'href' => helper::baseUrl() . $this->getUrl(0) . '/admin',
'value' => 'Administration' 'value' => 'Administration'
@ -111,4 +111,4 @@
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>

View File

@ -14,9 +14,9 @@
/** /**
* Confirmation de réinitialisation * Confirmation de réinitialisation
*/ */
$("#configManageReset").on("click", function() { $("#configManageReset").on("click", function () {
var _this = $(this); var _this = $(this);
return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine le thème du site ?", function() { return core.confirm("Êtes-vous sûr de vouloir réinitialiser à son état d'origine le thème du site ?", function () {
$(location).attr("href", _this.attr("href")); $(location).attr("href", _this.attr("href"));
}); });
}); });

View File

@ -1,93 +1,93 @@
<?php echo template::formOpen('themeManageForm'); ?> <?php echo template::formOpen('themeManageForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('themeManageBack', [ <?php echo template::button('themeManageBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme', 'href' => helper::baseUrl() . 'theme',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col1 offset8">
<?php echo template::button('configManageReset', [
'class' => 'buttonRed',
'href' => helper::baseUrl() . 'theme/reset/manage' . '&csrf=' . $_SESSION['csrf'],
'value' => template::ico('cancel'),
'help' => 'Réinitialiser avec le thème par défaut'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('themeImportSubmit', [
'value' => 'Appliquer'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col1 offset8">
<div class="col12"> <?php echo template::button('configManageReset', [
<div class="block"> 'class' => 'buttonRed',
<h4> 'href' => helper::baseUrl() . 'theme/reset/manage' . '&csrf=' . $_SESSION['csrf'],
<?php echo template::topic('Installer un thème archivé (site ou administration)'); ?> 'value' => template::ico('cancel'),
</h4> 'help' => 'Réinitialiser avec le thème par défaut'
<div class="row"> ]); ?>
<div class="col6 offset3"> </div>
<?php echo template::file('themeManageImport', [ <div class="col2">
'label' => 'Archive ZIP :', <?php echo template::submit('themeImportSubmit', [
'type' => 2 'value' => 'Appliquer'
]); ?> ]); ?>
</div> </div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo template::topic('Installer un thème archivé (site ou administration)'); ?>
</h4>
<div class="row">
<div class="col6 offset3">
<?php echo template::file('themeManageImport', [
'label' => 'Archive ZIP :',
'type' => 2
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col6"> <div class="row">
<div class="block"> <div class="col6">
<h4> <div class="block">
<?php echo template::topic('Sauvegarde du thème dans le'); ?> <h4>
<a href="<?php echo helper::baseUrl(false); ?>core/vendor/filemanager/dialog.php?fldr=theme&type=0&akey=<?php echo md5_file(self::DATA_DIR.'core.json'); ?>" data-lity> <?php echo template::topic('Sauvegarde du thème dans le'); ?>
<a href="<?php echo helper::baseUrl(false); ?>core/vendor/filemanager/dialog.php?fldr=theme&type=0&akey=<?php echo md5_file(self::DATA_DIR . 'core.json'); ?>" data-lity>
<?php echo template::topic('gestionnaire de fichiers'); ?> <?php echo template::topic('gestionnaire de fichiers'); ?>
</a> </a>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::button('themeSave', [ <?php echo template::button('themeSave', [
'href' => helper::baseUrl() . 'theme/save/theme', 'href' => helper::baseUrl() . 'theme/save/theme',
'ico' => 'download-cloud', 'ico' => 'download-cloud',
'value' => 'Thème du site' 'value' => 'Thème du site'
]); ?> ]); ?>
</div>
<div class="col6">
<?php echo template::button('themeSaveAdmin', [
'href' => helper::baseUrl() . 'theme/save/admin',
'ico' => 'download-cloud',
'value' => 'Thème de l\'administration'
]); ?>
</div>
</div> </div>
</div> <div class="col6">
</div> <?php echo template::button('themeSaveAdmin', [
'href' => helper::baseUrl() . 'theme/save/admin',
<div class="col6"> 'ico' => 'download-cloud',
<div class="block"> 'value' => 'Thème de l\'administration'
<h4> ]); ?>
<?php echo template::topic('Télécharger le thème'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::button('themeExport', [
'href' => helper::baseUrl() . 'theme/export/theme',
'ico' => 'download',
'value' => 'Thème du site'
]); ?>
</div>
<div class="col6">
<?php echo template::button('themeExport', [
'href' => helper::baseUrl() . 'theme/export/admin',
'ico' => 'download',
'value' => 'Thème de l\'administration'
]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?>
<div class="col6">
<div class="block">
<h4>
<?php echo template::topic('Télécharger le thème'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::button('themeExport', [
'href' => helper::baseUrl() . 'theme/export/theme',
'ico' => 'download',
'value' => 'Thème du site'
]); ?>
</div>
<div class="col6">
<?php echo template::button('themeExport', [
'href' => helper::baseUrl() . 'theme/export/admin',
'ico' => 'download',
'value' => 'Thème de l\'administration'
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -2,18 +2,18 @@
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('themeMenuBack', [ <?php echo template::button('themeMenuBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme', 'href' => helper::baseUrl() . 'theme',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col1"> <div class="col1">
<?php echo template::button('themeMenuHelp', [ <?php echo template::button('themeMenuHelp', [
'href' => 'https://doc.zwiicms.fr/menu', 'href' => 'https://doc.zwiicms.fr/menu',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'class' => 'buttonHelp' 'class' => 'buttonHelp'
]); ?> ]); ?>
</div> </div>
<div class="col2 offset8"> <div class="col2 offset8">
<?php echo template::submit('themeMenuSubmit'); ?> <?php echo template::submit('themeMenuSubmit'); ?>
@ -23,60 +23,61 @@
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic(' Paramètres'); ?> <?php echo template::topic(' Paramètres'); ?>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php <?php
if ( $this->getData(['theme', 'header', 'position']) == "site") if ($this->getData(['theme', 'header', 'position']) == "site") {
{ echo template::select('themeMenuPosition', $module::$menuPositionsSite, [ echo template::select('themeMenuPosition', $module::$menuPositionsSite, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'menu', 'position']) 'selected' => $this->getData(['theme', 'menu', 'position'])
]); ]);
}else{ } else {
echo template::select('themeMenuPosition', $module::$menuPositionsBody, [ echo template::select('themeMenuPosition', $module::$menuPositionsBody, [
'label' => 'Position', 'label' => 'Position',
'selected' => $this->getData(['theme', 'menu', 'position']) 'selected' => $this->getData(['theme', 'menu', 'position'])
]); } ]);
}
?> ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('themeMenuWide', $module::$containerWides, [ <?php echo template::select('themeMenuWide', $module::$containerWides, [
'label' => 'Largeur', 'label' => 'Largeur',
'selected' => $this->getData(['theme', 'menu', 'wide']) 'selected' => $this->getData(['theme', 'menu', 'wide'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::select('themeMenuRadius', $module::$menuRadius, [ <?php echo template::select('themeMenuRadius', $module::$menuRadius, [
'label' => 'Bords arrondis', 'label' => 'Bords arrondis',
'selected' => $this->getData(['theme', 'menu', 'radius']), 'selected' => $this->getData(['theme', 'menu', 'radius']),
'help' => 'Autour de la page sélectionnée' 'help' => 'Autour de la page sélectionnée'
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeMenuHeight', $module::$menuHeights, [ <?php echo template::select('themeMenuHeight', $module::$menuHeights, [
'label' => 'Hauteur', 'label' => 'Hauteur',
'selected' => $this->getData(['theme', 'menu', 'height']) 'selected' => $this->getData(['theme', 'menu', 'height'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::select('themeMenuTextAlign', $module::$aligns, [ <?php echo template::select('themeMenuTextAlign', $module::$aligns, [
'label' => 'Alignement du contenu', 'label' => 'Alignement du contenu',
'selected' => $this->getData(['theme', 'menu', 'textAlign']) 'selected' => $this->getData(['theme', 'menu', 'textAlign'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div id="themeMenuPositionOptions" class="displayNone"> <div id="themeMenuPositionOptions" class="displayNone">
<?php echo template::checkbox('themeMenuMargin', true, 'Aligner le menu avec le contenu', [ <?php echo template::checkbox('themeMenuMargin', true, 'Aligner le menu avec le contenu', [
'checked' => $this->getData(['theme', 'menu', 'margin']) 'checked' => $this->getData(['theme', 'menu', 'margin'])
]); ?> ]); ?>
</div> </div>
<div id="themeMenuPositionFixed" class="displayNone"> <div id="themeMenuPositionFixed" class="displayNone">
<?php echo template::checkbox('themeMenuFixed', true, 'Menu fixe', [ <?php echo template::checkbox('themeMenuFixed', true, 'Menu fixe', [
'checked' => $this->getData(['theme', 'menu', 'fixed']) 'checked' => $this->getData(['theme', 'menu', 'fixed'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -89,36 +90,36 @@
</h4> </h4>
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themeMenuLoginLink', true, 'Lien de connexion', [ <?php echo template::checkbox('themeMenuLoginLink', true, 'Lien de connexion', [
'checked' => $this->getData(['theme', 'menu', 'loginLink']) 'checked' => $this->getData(['theme', 'menu', 'loginLink'])
]); ?> ]); ?>
</div> </div>
<div class="col3"> <div class="col3">
<?php echo template::checkbox('themeMenuMemberBar', true, 'Barre de membre', [ <?php echo template::checkbox('themeMenuMemberBar', true, 'Barre de membre', [
'checked' => $this->getData(['theme', 'menu', 'memberBar']), 'checked' => $this->getData(['theme', 'menu', 'memberBar']),
'help' => 'Icônes de gestion de compte et de déconnexion. Uniquement pour les membres connectés' 'help' => 'Icônes de gestion de compte et de déconnexion. Uniquement pour les membres connectés'
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('themeMenuBurgerContent', $module::$burgerContent, [ <?php echo template::select('themeMenuBurgerContent', $module::$burgerContent, [
'label' => 'Affichage dans le menu burger', 'label' => 'Affichage dans le menu burger',
'selected' => $this->getData(['theme', 'menu', 'burgerContent']), 'selected' => $this->getData(['theme', 'menu', 'burgerContent']),
'help' => 'Le menu burger remplace le menu complet lorsque la largeur de l\'écran n\'est pas suffisante.' 'help' => 'Le menu burger remplace le menu complet lorsque la largeur de l\'écran n\'est pas suffisante.'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div id="themeMenuBurgerLogoId" class="col6 offset6 <?php if( $this->getData(['theme', 'menu', 'burgerContent']) !== 'logo') echo 'displayNone';?>"> <div id="themeMenuBurgerLogoId" class="col6 offset6 <?php if ($this->getData(['theme', 'menu', 'burgerContent']) !== 'logo') echo 'displayNone'; ?>">
<?php <?php
$imageFile = file_exists(self::FILE_DIR.'source/'.$this->getData(['theme', 'menu', 'burgerLogo'])) ? $imageFile = file_exists(self::FILE_DIR . 'source/' . $this->getData(['theme', 'menu', 'burgerLogo'])) ?
$this->getData(['theme', 'menu', 'burgerLogo']) : ""; $this->getData(['theme', 'menu', 'burgerLogo']) : "";
echo template::file('themeMenuBurgerLogo', [ echo template::file('themeMenuBurgerLogo', [
'help' => 'Sélectionner une image de dimensions adaptées', 'help' => 'Sélectionner une image de dimensions adaptées',
'label' => 'Logo du menu burger', 'label' => 'Logo du menu burger',
'type' => 1, 'type' => 1,
'value' => $imageFile 'value' => $imageFile
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@ -132,52 +133,52 @@
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::text('themeMenuTextColor', [ <?php echo template::text('themeMenuTextColor', [
'class' => 'colorPicker', 'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Texte', 'label' => 'Texte',
'value' => $this->getData(['theme', 'menu', 'textColor']) 'value' => $this->getData(['theme', 'menu', 'textColor'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::text('themeMenuBackgroundColor', [ <?php echo template::text('themeMenuBackgroundColor', [
'class' => 'colorPicker', 'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Arrière-plan', 'label' => 'Arrière-plan',
'value' => $this->getData(['theme', 'menu', 'backgroundColor']) 'value' => $this->getData(['theme', 'menu', 'backgroundColor'])
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::text('themeMenuBackgroundColorSub', [ <?php echo template::text('themeMenuBackgroundColorSub', [
'class' => 'colorPicker', 'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Fond du sous-menu', 'label' => 'Fond du sous-menu',
'value' => $this->getData(['theme', 'menu', 'backgroundColorSub']) 'value' => $this->getData(['theme', 'menu', 'backgroundColorSub'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::text('themeMenuActiveTextColor', [ <?php echo template::text('themeMenuActiveTextColor', [
'class' => 'colorPicker', 'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Texte page active', 'label' => 'Texte page active',
'value' => $this->getData(['theme', 'menu', 'activeTextColor']) 'value' => $this->getData(['theme', 'menu', 'activeTextColor'])
]); ?> ]); ?>
</div> </div>
<div class="col4 verticalAlignBottom"> <div class="col4 verticalAlignBottom">
<?php <?php
echo template::checkbox('themeMenuActiveColorAuto', true, 'Couleur de fond automatique', [ echo template::checkbox('themeMenuActiveColorAuto', true, 'Couleur de fond automatique', [
'checked' => $this->getData(['theme', 'menu', 'activeColorAuto']), 'checked' => $this->getData(['theme', 'menu', 'activeColorAuto']),
'help' => 'La couleur de fond de la page active peut être définie automatique ou selon une couleur définie, comme par exemple celle de fond des pages.' 'help' => 'La couleur de fond de la page active peut être définie automatique ou selon une couleur définie, comme par exemple celle de fond des pages.'
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<?php echo template::text('themeMenuActiveColor', [ <?php echo template::text('themeMenuActiveColor', [
'class' => 'colorPicker', 'class' => 'colorPicker',
'help' => 'Couleur de fond de la page sélectionnée dans le menu.<br>Le curseur horizontal règle le niveau de transparence.', 'help' => 'Couleur de fond de la page sélectionnée dans le menu.<br>Le curseur horizontal règle le niveau de transparence.',
'label' => 'Fond page active', 'label' => 'Fond page active',
'value' => $this->getData(['theme', 'menu', 'activeColor']) 'value' => $this->getData(['theme', 'menu', 'activeColor'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
@ -192,34 +193,34 @@
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::select('themeMenuFont', $module::$fonts['name'], [ <?php echo template::select('themeMenuFont', $module::$fonts['name'], [
'label' => 'Fonte', 'label' => 'Fonte',
'selected' => $this->getData(['theme', 'menu', 'font']), 'selected' => $this->getData(['theme', 'menu', 'font']),
'fonts' => $module::$fonts['family'] 'fonts' => $module::$fonts['family']
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('themeMenuFontSize', $module::$menuFontSizes, [ <?php echo template::select('themeMenuFontSize', $module::$menuFontSizes, [
'label' => 'Taille', 'label' => 'Taille',
'help' => 'Proportionnelle à celle définie dans le site', 'help' => 'Proportionnelle à celle définie dans le site',
'selected' => $this->getData(['theme', 'menu', 'fontSize']) 'selected' => $this->getData(['theme', 'menu', 'fontSize'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::select('themeMenuFontWeight', $module::$fontWeights, [ <?php echo template::select('themeMenuFontWeight', $module::$fontWeights, [
'label' => 'Style', 'label' => 'Style',
'selected' => $this->getData(['theme', 'menu', 'fontWeight']) 'selected' => $this->getData(['theme', 'menu', 'fontWeight'])
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('themeMenuTextTransform', $module::$textTransforms, [ <?php echo template::select('themeMenuTextTransform', $module::$textTransforms, [
'label' => 'Casse', 'label' => 'Casse',
'selected' => $this->getData(['theme', 'menu', 'textTransform']) 'selected' => $this->getData(['theme', 'menu', 'textTransform'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,154 +1,153 @@
<?php echo template::formOpen('themeSiteForm'); ?> <?php echo template::formOpen('themeSiteForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('themeSiteBack', [ <?php echo template::button('themeSiteBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'theme', 'href' => helper::baseUrl() . 'theme',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col1">
<?php echo template::button('themeSiteHelp', [
'href' => 'https://doc.zwiicms.fr/site61863d315ffe0',
'target' => '_blank',
'value' => template::ico('help'),
'class' => 'buttonHelp'
]); ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('themeSiteSubmit'); ?>
</div>
</div> </div>
<div class="row"> <div class="col1">
<div class="col12"> <?php echo template::button('themeSiteHelp', [
<div class="block"> 'href' => 'https://doc.zwiicms.fr/site61863d315ffe0',
<h4> 'target' => '_blank',
<?php echo template::topic('Paramètres'); ?> 'value' => template::ico('help'),
</h4> 'class' => 'buttonHelp'
<div class="row"> ]); ?>
<div class="col4"> </div>
<?php echo template::select('themeSiteWidth', $module::$siteWidths, [ <div class="col2 offset8">
'label' => 'Largeur du site', <?php echo template::submit('themeSiteSubmit'); ?>
'selected' => $this->getData(['theme', 'site', 'width']) </div>
]); ?> </div>
</div> <div class="row">
<div class="col4"> <div class="col12">
<?php echo template::select('themeSiteRadius', $module::$radius, [ <div class="block">
'label' => 'Arrondi des angles', <h4>
'selected' => $this->getData(['theme', 'site', 'radius']) <?php echo template::topic('Paramètres'); ?>
]); ?> </h4>
</div> <div class="row">
<div class="col4"> <div class="col4">
<?php echo template::select('themeSiteShadow', $module::$shadows, [ <?php echo template::select('themeSiteWidth', $module::$siteWidths, [
'label' => 'Ombre sur les bords du site', 'label' => 'Largeur du site',
'selected' => $this->getData(['theme', 'site', 'shadow']) 'selected' => $this->getData(['theme', 'site', 'width'])
]); ?> ]); ?>
</div>
</div> </div>
<div class="row"> <div class="col4">
<div class="col6"> <?php echo template::select('themeSiteRadius', $module::$radius, [
<?php echo template::checkbox('themeSiteMargin',true, 'Pas de marge au-dessus et en-dessous du site', [ 'label' => 'Arrondi des angles',
'checked' => $this->getData(['theme', 'site', 'margin']) 'selected' => $this->getData(['theme', 'site', 'radius'])
]); ?> ]); ?>
</div> </div>
<div class="col4">
<?php echo template::select('themeSiteShadow', $module::$shadows, [
'label' => 'Ombre sur les bords du site',
'selected' => $this->getData(['theme', 'site', 'shadow'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::checkbox('themeSiteMargin', true, 'Pas de marge au-dessus et en-dessous du site', [
'checked' => $this->getData(['theme', 'site', 'margin'])
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<div class="block"> <div class="col12">
<h4> <div class="block">
<?php echo template::topic('Couleurs'); ?> <h4>
</h4> <?php echo template::topic('Couleurs'); ?>
<div class="row"> </h4>
<div class="col8"> <div class="row">
<div class="row"> <div class="col8">
<div class="col6"> <div class="row">
<?php echo template::text('themeSiteBackgroundColor', [ <div class="col6">
'class' => 'colorPicker', <?php echo template::text('themeSiteBackgroundColor', [
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'class' => 'colorPicker',
'label' => 'Arrière-plan', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'value' => $this->getData(['theme', 'site', 'backgroundColor']) 'label' => 'Arrière-plan',
]); ?> 'value' => $this->getData(['theme', 'site', 'backgroundColor'])
</div> ]); ?>
<div class="col6">
<?php echo template::text('themeTextTextColor', [
'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Texte',
'value' => $this->getData(['theme', 'text', 'textColor'])
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col6">
<div class="col6"> <?php echo template::text('themeTextTextColor', [
<?php echo template::text('themeTitleTextColor', [ 'class' => 'colorPicker',
'class' => 'colorPicker', 'help' => 'Le curseur horizontal règle le niveau de transparence.',
'help' => 'Le curseur horizontal règle le niveau de transparence.', 'label' => 'Texte',
'label' => 'Titres', 'value' => $this->getData(['theme', 'text', 'textColor'])
'value' => $this->getData(['theme', 'title', 'textColor']) ]); ?>
]); ?>
</div>
<div class="col6">
<?php echo template::text('themeTextLinkColor', [
'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Liens',
'value' => $this->getData(['theme', 'text', 'linkColor'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::text('themeBlockBackgroundColor', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Arrière-plan des blocs',
'value' => $this->getData(['theme', 'block', 'backgroundColor'])
]); ?>
</div>
<div class="col6">
<?php echo template::text('themeBlockBorderColor', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bordure des blocs',
'value' => $this->getData(['theme', 'block', 'borderColor'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6 offset3">
<?php echo template::text('themeButtonBackgroundColor', [
'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Boutons',
'value' => $this->getData(['theme', 'button', 'backgroundColor'])
]); ?>
</div>
</div> </div>
</div> </div>
<div class="col4 bodybackground"> <div class="row">
<div class="bgPreview"> <div class="col6">
<div class="row"> <?php echo template::text('themeTitleTextColor', [
<div class="col6"> 'class' => 'colorPicker',
<h1 class="headerPreview">Titre</h1> 'help' => 'Le curseur horizontal règle le niveau de transparence.',
<h2 class="headerPreview">Sous-titre </h2> 'label' => 'Titres',
</div> 'value' => $this->getData(['theme', 'title', 'textColor'])
<div class="col6"> ]); ?>
<?php echo template::button('themeSiteSubmitButtonPreview', [ </div>
'class' => 'buttonSubmitPreview', <div class="col6">
'value' => 'Bouton' <?php echo template::text('themeTextLinkColor', [
]); ?> 'class' => 'colorPicker',
</div> 'help' => 'Le curseur horizontal règle le niveau de transparence.',
</div> 'label' => 'Liens',
<div class="row"> 'value' => $this->getData(['theme', 'text', 'linkColor'])
<div class="col12"> ]); ?>
<div class="block preview"> </div>
<h4 class="preview">Bloc</h4> </div>
<p class="textPreview">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <div class="row">
<p><a href="#" class="urlPreview">Lorem ipsum dolor sit amet.</a></p> <div class="col6">
</div> <?php echo template::text('themeBlockBackgroundColor', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Arrière-plan des blocs',
'value' => $this->getData(['theme', 'block', 'backgroundColor'])
]); ?>
</div>
<div class="col6">
<?php echo template::text('themeBlockBorderColor', [
'class' => 'colorPicker',
'help' => 'Couleur visible en l\'absence d\'une image.<br />Le curseur horizontal règle le niveau de transparence.',
'label' => 'Bordure des blocs',
'value' => $this->getData(['theme', 'block', 'borderColor'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6 offset3">
<?php echo template::text('themeButtonBackgroundColor', [
'class' => 'colorPicker',
'help' => 'Le curseur horizontal règle le niveau de transparence.',
'label' => 'Boutons',
'value' => $this->getData(['theme', 'button', 'backgroundColor'])
]); ?>
</div>
</div>
</div>
<div class="col4 bodybackground">
<div class="bgPreview">
<div class="row">
<div class="col6">
<h1 class="headerPreview">Titre</h1>
<h2 class="headerPreview">Sous-titre </h2>
</div>
<div class="col6">
<?php echo template::button('themeSiteSubmitButtonPreview', [
'class' => 'buttonSubmitPreview',
'value' => 'Bouton'
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block preview">
<h4 class="preview">Bloc</h4>
<p class="textPreview">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p><a href="#" class="urlPreview">Lorem ipsum dolor sit amet.</a></p>
</div> </div>
</div> </div>
</div> </div>
@ -157,58 +156,59 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col6"> <div class="row">
<div class="block"> <div class="col6">
<h4> <div class="block">
<?php echo template::topic('Mise en forme du texte'); ?> <h4>
</h4> <?php echo template::topic('Mise en forme du texte'); ?>
<div class="row"> </h4>
<div class="col6"> <div class="row">
<?php <div class="col6">
echo template::select('themeTextFont', $module::$fonts['name'], [ <?php
'label' => 'Fonte', echo template::select('themeTextFont', $module::$fonts['name'], [
'selected' => $this->getData(['theme', 'text', 'font']), 'label' => 'Fonte',
'fonts' => $module::$fonts['family'] 'selected' => $this->getData(['theme', 'text', 'font']),
]); ?> 'fonts' => $module::$fonts['family']
</div> ]); ?>
<div class="col6">
<?php echo template::select('themeTextFontSize', $module::$siteFontSizes, [
'label' => 'Taille',
'help' => 'Taille de référence pour le site. Les tailles des polices de la bannière, de menu et de pied de page sont proportionnelles à cette taille.',
'selected' => $this->getData(['theme', 'text', 'fontSize'])
]); ?>
</div>
</div> </div>
</div> <div class="col6">
</div> <?php echo template::select('themeTextFontSize', $module::$siteFontSizes, [
<div class="col6"> 'label' => 'Taille',
<div class="block"> 'help' => 'Taille de référence pour le site. Les tailles des polices de la bannière, de menu et de pied de page sont proportionnelles à cette taille.',
<h4> 'selected' => $this->getData(['theme', 'text', 'fontSize'])
<?php echo template::topic('Mise en forme des titres'); ?> ]); ?>
</h4>
<div class="row">
<div class="col4">
<?php echo template::select('themeTitleFont', $module::$fonts['name'] , [
'label' => 'Fonte',
'selected' => $this->getData(['theme', 'title', 'font']),
'fonts' => $module::$fonts['family']
]); ?>
</div>
<div class="col4">
<?php echo template::select('themeTitleFontWeight', $module::$fontWeights, [
'label' => 'Style',
'selected' => $this->getData(['theme', 'title', 'fontWeight'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('themeTitleTextTransform', $module::$textTransforms, [
'label' => 'Casse',
'selected' => $this->getData(['theme', 'title', 'textTransform'])
]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <div class="col6">
<div class="block">
<h4>
<?php echo template::topic('Mise en forme des titres'); ?>
</h4>
<div class="row">
<div class="col4">
<?php echo template::select('themeTitleFont', $module::$fonts['name'], [
'label' => 'Fonte',
'selected' => $this->getData(['theme', 'title', 'font']),
'fonts' => $module::$fonts['family']
]); ?>
</div>
<div class="col4">
<?php echo template::select('themeTitleFontWeight', $module::$fontWeights, [
'label' => 'Style',
'selected' => $this->getData(['theme', 'title', 'fontWeight'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('themeTitleTextTransform', $module::$textTransforms, [
'label' => 'Casse',
'selected' => $this->getData(['theme', 'title', 'textTransform'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -13,7 +13,8 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
class translate extends common { class translate extends common
{
public static $actions = [ public static $actions = [
'index' => self::GROUP_ADMIN, 'index' => self::GROUP_ADMIN,
@ -45,7 +46,8 @@ class translate extends common {
/** /**
* Configuration avancée des langues * Configuration avancée des langues
*/ */
public function copy() { public function copy()
{
// Soumission du formulaire // Soumission du formulaire
if ($this->isPost()) { if ($this->isPost()) {
@ -55,20 +57,20 @@ class translate extends common {
$toCreate = $this->getInput('translateFormCopyTarget'); $toCreate = $this->getInput('translateFormCopyTarget');
if ($copyFrom !== $toCreate) { if ($copyFrom !== $toCreate) {
// Création du dossier // Création du dossier
if (is_dir(self::DATA_DIR . $toCreate) === false ) { // Si le dossier est déjà créé if (is_dir(self::DATA_DIR . $toCreate) === false) { // Si le dossier est déjà créé
$success = mkdir (self::DATA_DIR . $toCreate, 0755); $success = mkdir(self::DATA_DIR . $toCreate, 0755);
$success = mkdir (self::DATA_DIR . $toCreate.'/content', 0755); $success = mkdir(self::DATA_DIR . $toCreate . '/content', 0755);
} else { } else {
$success = true; $success = true;
} }
// Copier les données par défaut avec gestion des erreurs // Copier les données par défaut avec gestion des erreurs
$success = (copy (self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false; $success = (copy(self::DATA_DIR . $copyFrom . '/locale.json', self::DATA_DIR . $toCreate . '/locale.json') === true && $success === true) ? true : false;
$success = (copy (self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false; $success = (copy(self::DATA_DIR . $copyFrom . '/module.json', self::DATA_DIR . $toCreate . '/module.json') === true && $success === true) ? true : false;
$success = (copy (self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false; $success = (copy(self::DATA_DIR . $copyFrom . '/page.json', self::DATA_DIR . $toCreate . '/page.json') === true && $success === true) ? true : false;
$success = ($this->copyDir (self::DATA_DIR . $copyFrom . '/content', self::DATA_DIR . $toCreate . '/content') === true && $success === true) ? true : false; $success = ($this->copyDir(self::DATA_DIR . $copyFrom . '/content', self::DATA_DIR . $toCreate . '/content') === true && $success === true) ? true : false;
// Enregistrer la langue // Enregistrer la langue
if ($success) { if ($success) {
$this->setData(['config', 'i18n', $toCreate, 'site' ]); $this->setData(['config', 'i18n', $toCreate, 'site']);
$notification = 'Données ' . self::$languages[$copyFrom] . ' copiées vers ' . self::$languages[$toCreate]; $notification = 'Données ' . self::$languages[$copyFrom] . ' copiées vers ' . self::$languages[$toCreate];
} else { } else {
$notification = "Quelque chose n\'a pas fonctionné, vérifiez les permissions."; $notification = "Quelque chose n\'a pas fonctionné, vérifiez les permissions.";
@ -87,7 +89,7 @@ class translate extends common {
} }
// Tableau des langues installées // Tableau des langues installées
foreach (self::$languages as $key => $value) { foreach (self::$languages as $key => $value) {
if ($this->getData(['config','i18n', $key]) === 'site') { if ($this->getData(['config', 'i18n', $key]) === 'site') {
self::$languagesTarget[$key] = $value; self::$languagesTarget[$key] = $value;
} }
} }
@ -104,13 +106,14 @@ class translate extends common {
/** /**
* Configuration * Configuration
*/ */
public function index() { public function index()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Sauvegarder les langues de contenu // Sauvegarder les langues de contenu
$this->setData(['config', 'i18n','interface', $this->getInput('translateUI')]); $this->setData(['config', 'i18n', 'interface', $this->getInput('translateUI')]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -126,26 +129,25 @@ class translate extends common {
// Onglet des langues de contenu // Onglet des langues de contenu
foreach (self::$languages as $keyi18n => $value) { foreach (self::$languages as $keyi18n => $value) {
// tableau des langues installées // tableau des langues installées
if (is_dir(self::DATA_DIR . $keyi18n) ) { if (is_dir(self::DATA_DIR . $keyi18n)) {
self::$languagesInstalled [] = [ self::$languagesInstalled[] = [
template::flag($keyi18n, '50%') , template::flag($keyi18n, '50%'),
$value . ' (' . $keyi18n . ')' , $value . ' (' . $keyi18n . ')',
self::$i18nUI === $keyi18n ? '(langue de l\'interface)' : '', self::$i18nUI === $keyi18n ? '(langue de l\'interface)' : '',
'', '',
template::button('translateContentLanguageEdit' . $keyi18n, [ template::button('translateContentLanguageEdit' . $keyi18n, [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $keyi18n. '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $keyi18n . '/' . $_SESSION['csrf'],
'value' => template::ico('flag'), 'value' => template::ico('flag'),
'help' => 'Editer les locales' 'help' => 'Editer les locales'
]), ]),
template::button('translateContentLanguageDelete' .$keyi18n, [ template::button('translateContentLanguageDelete' . $keyi18n, [
'class' => 'translateDelete buttonRed' . (self::$i18nUI === $keyi18n ? ' disabled' : '') , 'class' => 'translateDelete buttonRed' . (self::$i18nUI === $keyi18n ? ' disabled' : ''),
'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $keyi18n . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $keyi18n . '/' . $_SESSION['csrf'],
'value' => template::ico('trash'), 'value' => template::ico('trash'),
'help' => 'Supprimer cette langue' 'help' => 'Supprimer cette langue'
]) ])
]; ];
} }
} }
// Activation du bouton de copie // Activation du bouton de copie
self::$siteCopy = count(self::$languagesInstalled) > 1 ? false : true; self::$siteCopy = count(self::$languagesInstalled) > 1 ? false : true;
@ -156,10 +158,10 @@ class translate extends common {
chdir(self::I18N_DIR); chdir(self::I18N_DIR);
$files = glob('*.json'); $files = glob('*.json');
// Ajouter une clé au tableau avec le code de langue // Ajouter une clé au tableau avec le code de langue
foreach( $files as $file) { foreach ($files as $file) {
// La langue est-elle référencée ? // La langue est-elle référencée ?
if (array_key_exists(basename($file, '.json'), self::$languages)) { if (array_key_exists(basename($file, '.json'), self::$languages)) {
self::$i18nFiles[basename($file, '.json')] = self::$languages[basename($file, '.json')]; self::$i18nFiles[basename($file, '.json')] = self::$languages[basename($file, '.json')];
} }
} }
chdir($dir); chdir($dir);
@ -177,10 +179,11 @@ class translate extends common {
* Ajouter une langue de contenu * Ajouter une langue de contenu
*/ */
public function add() { public function add()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Création du contenu // Création du contenu
$lang = $this->getInput('translateAddContent'); $lang = $this->getInput('translateAddContent');
@ -193,7 +196,7 @@ class translate extends common {
// Sus-dossier localisé // Sus-dossier localisé
if (!file_exists(self::DATA_DIR . $lang)) { if (!file_exists(self::DATA_DIR . $lang)) {
mkdir (self::DATA_DIR . $lang, 0755); mkdir(self::DATA_DIR . $lang, 0755);
} }
// Initialiser la classe // Initialiser la classe
@ -204,9 +207,8 @@ class translate extends common {
]);; ]);;
// Capturer et sauver // Capturer et sauver
$db->set($key,init::$defaultData[$key]); $db->set($key, init::$defaultData[$key]);
$db->save; $db->save;
} }
@ -224,8 +226,8 @@ class translate extends common {
// Tableau des langues non installées // Tableau des langues non installées
foreach (self::$languages as $key => $value) { foreach (self::$languages as $key => $value) {
if (!is_dir( self::DATA_DIR . $key)) if (!is_dir(self::DATA_DIR . $key))
self::$i18nFiles [$key] = $value; self::$i18nFiles[$key] = $value;
} }
// Valeurs en sortie // Valeurs en sortie
@ -233,13 +235,14 @@ class translate extends common {
'title' => 'Ajouter', 'title' => 'Ajouter',
'view' => 'add' 'view' => 'add'
]); ]);
} }
public function edit() { public function edit()
{
// Jeton incorrect ou URl avec le code langue incorrecte // Jeton incorrect ou URl avec le code langue incorrecte
if ( $this->getUrl(3) !== $_SESSION['csrf'] if (
$this->getUrl(3) !== $_SESSION['csrf']
|| !array_key_exists($this->getUrl(2), self::$languages) || !array_key_exists($this->getUrl(2), self::$languages)
) { ) {
// Valeurs en sortie // Valeurs en sortie
@ -251,39 +254,40 @@ class translate extends common {
} }
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Sauvegarder les locales // Sauvegarder les locales
$data = ['locale' => [ $data = [
'homePageId' => $this->getInput('localeHomePageId', helper::FILTER_ID, true), 'locale' => [
'page404' => $this->getInput('localePage404'), 'homePageId' => $this->getInput('localeHomePageId', helper::FILTER_ID, true),
'page403' => $this->getInput('localePage403'), 'page404' => $this->getInput('localePage404'),
'page302' => $this->getInput('localePage302'), 'page403' => $this->getInput('localePage403'),
'legalPageId' => $this->getInput('localeLegalPageId'), 'page302' => $this->getInput('localePage302'),
'searchPageId' => $this->getInput('localeSearchPageId'), 'legalPageId' => $this->getInput('localeLegalPageId'),
'searchPageLabel' => empty($this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT), 'searchPageId' => $this->getInput('localeSearchPageId'),
'legalPageLabel' => empty($this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT), 'searchPageLabel' => empty($this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT)) ? 'Rechercher' : $this->getInput('localeSearchPageLabel', helper::FILTER_STRING_SHORT),
'sitemapPageLabel' => empty($this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT), 'legalPageLabel' => empty($this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT)) ? 'Mentions légales' : $this->getInput('localeLegalPageLabel', helper::FILTER_STRING_SHORT),
'metaDescription' => $this->getInput('localeMetaDescription', helper::FILTER_STRING_LONG, true), 'sitemapPageLabel' => empty($this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT)) ? 'Plan du site' : $this->getInput('localeSitemapPageLabel', helper::FILTER_STRING_SHORT),
'title' => $this->getInput('localeTitle', helper::FILTER_STRING_SHORT, true), 'metaDescription' => $this->getInput('localeMetaDescription', helper::FILTER_STRING_LONG, true),
'cookies' => [ 'title' => $this->getInput('localeTitle', helper::FILTER_STRING_SHORT, true),
// Les champs sont obligatoires si l'option consentement des cookies est active 'cookies' => [
'mainLabel' => $this->getInput('localeCookiesZwiiText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), // Les champs sont obligatoires si l'option consentement des cookies est active
'titleLabel' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), 'mainLabel' => $this->getInput('localeCookiesZwiiText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
'linkLegalLabel' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), 'titleLabel' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)), 'linkLegalLabel' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
'buttonValidLabel' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)) 'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
] 'buttonValidLabel' => $this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN))
]
] ]
]; ];
// Sauvegarde hors méthodes si la langue n'est pas celle de l'UI // Sauvegarde hors méthodes si la langue n'est pas celle de l'UI
if ( $this->getUrl(2) === self::$i18nUI ) { if ($this->getUrl(2) === self::$i18nUI) {
// Enregistrer les données par lecture directe du formulaire // Enregistrer les données par lecture directe du formulaire
$this->setData(['locale', $data['locale'] ]); $this->setData(['locale', $data['locale']]);
} else { } else {
// Sauver sur le disque // Sauver sur le disque
file_put_contents (self::DATA_DIR . $this->getUrl(2) . '/locale.json', json_encode($data, JSON_UNESCAPED_UNICODE), LOCK_EX); file_put_contents(self::DATA_DIR . $this->getUrl(2) . '/locale.json', json_encode($data, JSON_UNESCAPED_UNICODE), LOCK_EX);
} }
// Valeurs en sortie // Valeurs en sortie
@ -300,7 +304,7 @@ class translate extends common {
// Récupération des locales de la langue sélectionnée // Récupération des locales de la langue sélectionnée
// Vérifier la conformité de l'URL // Vérifier la conformité de l'URL
if ( !array_key_exists($this->getUrl(2), self::$languages)) { if (!array_key_exists($this->getUrl(2), self::$languages)) {
// Bidouillage de l'URL, on sort // Bidouillage de l'URL, on sort
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -311,27 +315,31 @@ class translate extends common {
} }
//Lecture des données pour transmission au formulaire //Lecture des données pour transmission au formulaire
// La locale est-elle celle de la langue de l'UI ? // La locale est-elle celle de la langue de l'UI ?
if ( $this->getUrl(2) === self::$i18nUI) { if ($this->getUrl(2) === self::$i18nUI) {
self::$locales [$this->getUrl(2)]['locale'] = $this->getData(['locale']); self::$locales[$this->getUrl(2)]['locale'] = $this->getData(['locale']);
} else { } else {
// Lire les locales sans passer par les méthodes // Lire les locales sans passer par les méthodes
self::$locales [$this->getUrl(2)] = json_decode(file_get_contents(self::DATA_DIR . $this->getUrl(2) . '/locale.json'), true); self::$locales[$this->getUrl(2)] = json_decode(file_get_contents(self::DATA_DIR . $this->getUrl(2) . '/locale.json'), true);
} }
// Générer la liste des pages disponibles // Générer la liste des pages disponibles
self::$pagesList = $this->getData(['page']); self::$pagesList = $this->getData(['page']);
foreach(self::$pagesList as $page => $pageId) { foreach (self::$pagesList as $page => $pageId) {
if ($this->getData(['page',$page,'block']) === 'bar' || if (
$this->getData(['page',$page,'disable']) === true) { $this->getData(['page', $page, 'block']) === 'bar' ||
$this->getData(['page', $page, 'disable']) === true
) {
unset(self::$pagesList[$page]); unset(self::$pagesList[$page]);
} }
} }
self::$orphansList = $this->getData(['page']); self::$orphansList = $this->getData(['page']);
foreach(self::$orphansList as $page => $pageId) { foreach (self::$orphansList as $page => $pageId) {
if ($this->getData(['page',$page,'block']) === 'bar' || if (
$this->getData(['page',$page,'disable']) === true || $this->getData(['page', $page, 'block']) === 'bar' ||
$this->getdata(['page',$page, 'position']) !== 0) { $this->getData(['page', $page, 'disable']) === true ||
$this->getdata(['page', $page, 'position']) !== 0
) {
unset(self::$orphansList[$page]); unset(self::$orphansList[$page]);
} }
} }
@ -346,21 +354,24 @@ class translate extends common {
/*** /***
* Effacer une langue de contenu * Effacer une langue de contenu
*/ */
public function delete() { public function delete()
{
// Jeton incorrect ou URl avec le code langue incorrecte // Jeton incorrect ou URl avec le code langue incorrecte
if ( $this->getUrl(3) !== $_SESSION['csrf'] if (
|| !array_key_exists($this->getUrl(2), self::$languages) ) { $this->getUrl(3) !== $_SESSION['csrf']
// Valeurs en sortie || !array_key_exists($this->getUrl(2), self::$languages)
$this->addOutput([ ) {
'redirect' => helper::baseUrl() . 'translate', // Valeurs en sortie
'state' => false, $this->addOutput([
'notification' => 'Action non autorisée' 'redirect' => helper::baseUrl() . 'translate',
]); 'state' => false,
'notification' => 'Action non autorisée'
]);
} }
// Effacement d'une langue installée // Effacement d'une langue installée
if ( is_dir( self::DATA_DIR . $this->getUrl(2) ) === true ) { if (is_dir(self::DATA_DIR . $this->getUrl(2)) === true) {
$success = $this->removeDir( self::DATA_DIR . $this->getUrl(2)); $success = $this->removeDir(self::DATA_DIR . $this->getUrl(2));
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -374,21 +385,22 @@ class translate extends common {
* Traitement du changement de langue * Traitement du changement de langue
* Fonction utilisée par le noyau * Fonction utilisée par le noyau
*/ */
public function i18n() { public function i18n()
{
// Activation du drapeau // Activation du drapeau
if ( $this->getInput('ZWII_I18N_' . strtoupper($this->getUrl(3))) !== $this->getUrl(2) ) { if ($this->getInput('ZWII_I18N_' . strtoupper($this->getUrl(3))) !== $this->getUrl(2)) {
// Nettoyer et stocker le choix de l'utilisateur // Nettoyer et stocker le choix de l'utilisateur
helper::deleteCookie('ZWII_I18N_SITE'); helper::deleteCookie('ZWII_I18N_SITE');
// Sélectionner // Sélectionner
setcookie('ZWII_I18N_' . strtoupper($this->getUrl(3)) , $this->getUrl(2), time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true); setcookie('ZWII_I18N_' . strtoupper($this->getUrl(3)), $this->getUrl(2), time() + 3600, helper::baseUrl(false, false), '', helper::isHttps(), true);
// Désactivation du drapeau, langue FR par défaut // Désactivation du drapeau, langue FR par défaut
} else { } else {
setcookie('ZWII_I18N_SITE' , 'fr', time() + 3600, helper::baseUrl(false, false) , '', helper::isHttps(), true); setcookie('ZWII_I18N_SITE', 'fr', time() + 3600, helper::baseUrl(false, false), '', helper::isHttps(), true);
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getData(['locale', $this->getUrl(2), 'homePageId' ]) 'redirect' => helper::baseUrl() . $this->getData(['locale', $this->getUrl(2), 'homePageId'])
]); ]);
} }
} }

View File

@ -1,31 +1,30 @@
<?php echo template::formOpen('translateAddForm'); ?> <?php echo template::formOpen('translateAddForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('translateFormBack', [ <?php echo template::button('translateFormBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'translate', 'href' => helper::baseUrl() . 'translate',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('translateFormSubmit'); ?>
</div>
</div> </div>
<div class="row"> <div class="col2 offset9">
<div class="col12"> <?php echo template::submit('translateFormSubmit'); ?>
<div class="block"> </div>
<h4> </div>
<?php echo template::topic('Ajout d\'une longue de contenu'); ?> <div class="row">
</h4> <div class="col12">
<div class="row"> <div class="block">
<div class="col4 offset4"> <h4>
<?php echo template::select('translateAddContent', $module::$i18nFiles, [ <?php echo template::topic('Ajout d\'une longue de contenu'); ?>
'label' => 'Langues disponibles' </h4>
]); ?> <div class="row">
</div> <div class="col4 offset4">
<?php echo template::select('translateAddContent', $module::$i18nFiles, [
'label' => 'Langues disponibles'
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -14,7 +14,7 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Copie des traductions rédigées'); ?> <?php echo template::topic('Copie des traductions rédigées'); ?>
@ -23,12 +23,12 @@
<div class="col6"> <div class="col6">
<?php echo template::select('translateFormCopySource', $module::$languagesInstalled, [ <?php echo template::select('translateFormCopySource', $module::$languagesInstalled, [
'label' => 'Pages et les modules de' 'label' => 'Pages et les modules de'
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('translateFormCopyTarget', $module::$languagesTarget, [ <?php echo template::select('translateFormCopyTarget', $module::$languagesTarget, [
'label' => 'Vers' 'label' => 'Vers'
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,201 +1,200 @@
<?php echo template::formOpen('translateLocaleForm'); ?> <?php echo template::formOpen('translateLocaleForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('translateFormBack', [ <?php echo template::button('translateFormBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'translate', 'href' => helper::baseUrl() . 'translate',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col2 offset9"> <div class="col2 offset9">
<?php echo template::submit('translateFormSubmit'); ?> <?php echo template::submit('translateFormSubmit'); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4>Identité du site <h4>Identité du site
<span id="localeHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne"> <span id="localeHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne">
<a href="https://doc.zwiicms.fr/localisation-et-identite" target="_blank"> <a href="https://doc.zwiicms.fr/localisation-et-identite" target="_blank">
<?php echo template::ico('help', ['margin' => 'left']);?> <?php echo template::ico('help', ['margin' => 'left']); ?>
</a> </a>
</span> </span>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::text('localeTitle', [ <?php echo template::text('localeTitle', [
'label' => 'Titre du site' , 'label' => 'Titre du site',
'value' => $module::$locales[$this->getUrl(2)]['locale']['title'], 'value' => $module::$locales[$this->getUrl(2)]['locale']['title'],
'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.' 'help' => 'Il apparaît dans la barre de titre et les partages sur les réseaux sociaux.'
]); ?> ]); ?>
</div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<?php echo template::textarea('localeMetaDescription', [ <div class="col12">
'label' => 'Description du site', <?php echo template::textarea('localeMetaDescription', [
'value' => $module::$locales[$this->getUrl(2)]['locale']['metaDescription'], 'label' => 'Description du site',
'help' => 'La description d\'une page participe à son référencement, chaque page doit disposer d\'une description différente.' 'value' => $module::$locales[$this->getUrl(2)]['locale']['metaDescription'],
]); ?> 'help' => 'La description d\'une page participe à son référencement, chaque page doit disposer d\'une description différente.'
</div> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<div class="block"> <div class="col12">
<h4>Assignation des pages spéciales <div class="block">
<span id="localeHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne"> <h4>Assignation des pages spéciales
<a href="https://doc.zwiicms.fr/localisation-et-identite" target="_blank"> <span id="localeHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <a href="https://doc.zwiicms.fr/localisation-et-identite" target="_blank">
</a> <?php echo template::ico('help', ['margin' => 'left']); ?>
</span> </a>
</h4> </span>
<div class="row"> </h4>
<div class="col4"> <div class="row">
<?php echo template::select('localeHomePageId', helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC'), [ <div class="col4">
'label' => 'Accueil du site', <?php echo template::select('localeHomePageId', helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC'), [
'selected' =>$module::$locales[$this->getUrl(2)]['locale'][ 'homePageId'], 'label' => 'Accueil du site',
'help' => 'La première page que vos visiteurs verront.' 'selected' => $module::$locales[$this->getUrl(2)]['locale']['homePageId'],
]); ?> 'help' => 'La première page que vos visiteurs verront.'
</div> ]); ?>
<div class="col4">
<?php echo template::select('localePage403', array_merge(['none' => 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [
'label' => 'Accès interdit, erreur 403',
'selected' =>$module::$locales[$this->getUrl(2)]['locale']['page403'],
'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.'
]); ?>
</div>
<div class="col4">
<?php echo template::select('localePage404', array_merge(['none' => 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [
'label' => 'Page inexistante, erreur 404',
'selected' =>$module::$locales[$this->getUrl(2)]['locale']['page404'],
'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col4">
<div class="col4"> <?php echo template::select('localePage403', array_merge(['none' => 'Page par défaut'], helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [
<?php echo template::select('localeLegalPageId', array_merge(['none' => 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ 'label' => 'Accès interdit, erreur 403',
'label' => 'Mentions légales', 'selected' => $module::$locales[$this->getUrl(2)]['locale']['page403'],
'selected' => $module::$locales[$this->getUrl(2)]['locale']['legalPageId'], 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.'
'help' => 'Les mentions légales sont obligatoires en France. Une option du pied de page ajoute un lien discret vers cette page.' ]); ?>
]); ?> </div>
</div> <div class="col4">
<div class="col4"> <?php echo template::select('localePage404', array_merge(['none' => 'Page par défaut'], helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [
<?php echo template::select('localeSearchPageId', array_merge(['none' => 'Aucune'] , helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC') ) , [ 'label' => 'Page inexistante, erreur 404',
'label' => 'Recherche dans le site', 'selected' => $module::$locales[$this->getUrl(2)]['locale']['page404'],
'selected' => $module::$locales[$this->getUrl(2)]['locale']['searchPageId'], 'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.'
'help' => 'Sélectionnez une page contenant le module \'Recherche\'. Une option du pied de page ajoute un lien discret vers cette page.' ]); ?>
]); ?> </div>
</div> </div>
<div class="col4"> <div class="row">
<?php <div class="col4">
echo template::select('localePage302', array_merge(['none' => 'Page par défaut'],helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [ <?php echo template::select('localeLegalPageId', array_merge(['none' => 'Aucune'], helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC')), [
'label' => 'Site en maintenance', 'label' => 'Mentions légales',
'selected' =>$module::$locales[$this->getUrl(2)]['locale']['page302'], 'selected' => $module::$locales[$this->getUrl(2)]['locale']['legalPageId'],
'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.' 'help' => 'Les mentions légales sont obligatoires en France. Une option du pied de page ajoute un lien discret vers cette page.'
]); ?> ]); ?>
</div> </div>
<div class="col4">
<?php echo template::select('localeSearchPageId', array_merge(['none' => 'Aucune'], helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC')), [
'label' => 'Recherche dans le site',
'selected' => $module::$locales[$this->getUrl(2)]['locale']['searchPageId'],
'help' => 'Sélectionnez une page contenant le module \'Recherche\'. Une option du pied de page ajoute un lien discret vers cette page.'
]); ?>
</div>
<div class="col4">
<?php
echo template::select('localePage302', array_merge(['none' => 'Page par défaut'], helper::arrayColumn($module::$orphansList, 'title', 'SORT_ASC')), [
'label' => 'Site en maintenance',
'selected' => $module::$locales[$this->getUrl(2)]['locale']['page302'],
'help' => 'Cette page ne doit pas apparaître dans l\'arborescence du menu. Créez une page orpheline.'
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<div class="block"> <div class="col12">
<h4>Etiquettes des pages spéciales <div class="block">
<span id="labelHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne"> <h4>Etiquettes des pages spéciales
<a href="https://doc.zwiicms.fr/etiquettes-des-pages-speciales" target="_blank"> <span id="labelHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <a href="https://doc.zwiicms.fr/etiquettes-des-pages-speciales" target="_blank">
</a> <?php echo template::ico('help', ['margin' => 'left']); ?>
</span> </a>
</h4> </span>
<div class="row"> </h4>
<div class="col6"> <div class="row">
<?php echo template::text('localeLegalPageLabel', [ <div class="col6">
'label' => 'Mentions légales', <?php echo template::text('localeLegalPageLabel', [
'placeholder' => 'Mentions légales', 'label' => 'Mentions légales',
'value' => $module::$locales[$this->getUrl(2)]['locale']['legalPageLabel'] 'placeholder' => 'Mentions légales',
]); ?> 'value' => $module::$locales[$this->getUrl(2)]['locale']['legalPageLabel']
</div> ]); ?>
<div class="col6">
<?php echo template::text('localeSearchPageLabel', [
'label' => 'Rechercher',
'placeholder' => 'Rechercher',
'value' => $module::$locales[$this->getUrl(2)]['locale']['searchPageLabel']
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col6">
<div class="col6"> <?php echo template::text('localeSearchPageLabel', [
<?php echo template::text('localeSitemapPageLabel', [ 'label' => 'Rechercher',
'label' => 'Plan du site', 'placeholder' => 'Rechercher',
'placeholder' => 'Plan du site', 'value' => $module::$locales[$this->getUrl(2)]['locale']['searchPageLabel']
'value' => $module::$locales[$this->getUrl(2)]['locale']['sitemapPageLabel'], ]); ?>
]); ?> </div>
</div> </div>
<div class="col6"> <div class="row">
<?php echo template::text('localeCookiesFooterText', [ <div class="col6">
'label' => 'Cookies', <?php echo template::text('localeSitemapPageLabel', [
'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['cookiesFooterText'], 'label' => 'Plan du site',
'placeHolder' => 'Cookies' 'placeholder' => 'Plan du site',
]); ?> 'value' => $module::$locales[$this->getUrl(2)]['locale']['sitemapPageLabel'],
</div> ]); ?>
</div>
<div class="col6">
<?php echo template::text('localeCookiesFooterText', [
'label' => 'Cookies',
'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['cookiesFooterText'],
'placeHolder' => 'Cookies'
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col12"> <div class="row">
<div class="block"> <div class="col12">
<h4>Message d'acceptation des Cookies <div class="block">
<span id="specialeHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne"> <h4>Message d'acceptation des Cookies
<a href="https://doc.zwiicms.fr/cookies" target="_blank"> <span id="specialeHelpButton" class="helpDisplayButton" title="Cliquer pour consulter l'aide en ligne">
<?php echo template::ico('help', ['margin' => 'left']);?> <a href="https://doc.zwiicms.fr/cookies" target="_blank">
</a> <?php echo template::ico('help', ['margin' => 'left']); ?>
</span> </a>
</h4> </span>
<div class="row"> </h4>
<div class="col6"> <div class="row">
<?php echo template::text('localeCookiesTitleText', [ <div class="col6">
'help' => 'Saisissez le titre de la fenêtre de gestion des cookies.', <?php echo template::text('localeCookiesTitleText', [
'label' => 'Titre de la fenêtre', 'help' => 'Saisissez le titre de la fenêtre de gestion des cookies.',
'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['titleLabel'], 'label' => 'Titre de la fenêtre',
'placeHolder' => 'Gérer les cookies' 'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['titleLabel'],
]); ?> 'placeHolder' => 'Gérer les cookies'
</div> ]); ?>
<div class="col6"> </div>
<?php echo template::text('localeCookiesButtonText', [ <div class="col6">
'label' => 'Bouton de validation', <?php echo template::text('localeCookiesButtonText', [
'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['buttonValidLabel'], 'label' => 'Bouton de validation',
'placeHolder' => 'J\'ai compris' 'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['buttonValidLabel'],
]); ?> 'placeHolder' => 'J\'ai compris'
</div> ]); ?>
</div>
</div>
<div class="row">
<div class="col8">
<?php echo template::textarea('localeCookiesZwiiText', [
'help' => 'Saisissez le message pour les cookies déposés par ZwiiCMS, nécessaires au fonctionnement et qui ne nécessitent pas de consentement.',
'label' => 'Cookies Zwii',
'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['mainLabel'],
'placeHolder' => 'Ce site utilise des cookies nécessaires à son fonctionnement, ils permettent de fluidifier son fonctionnement par exemple en mémorisant les données de connexion, la langue que vous avez choisie ou la validation de ce message.'
]); ?>
</div> </div>
<div class="row">
<div class="col8">
<?php echo template::textarea('localeCookiesZwiiText', [
'help' => 'Saisissez le message pour les cookies déposés par ZwiiCMS, nécessaires au fonctionnement et qui ne nécessitent pas de consentement.',
'label' => 'Cookies Zwii',
'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['mainLabel'],
'placeHolder' => 'Ce site utilise des cookies nécessaires à son fonctionnement, ils permettent de fluidifier son fonctionnement par exemple en mémorisant les données de connexion, la langue que vous avez choisie ou la validation de ce message.'
]); ?>
</div>
<div class="col4"> <div class="col4">
<?php echo template::text('localeCookiesLinkMlText', [ <?php echo template::text('localeCookiesLinkMlText', [
'help' => 'Saisissez le texte du lien vers les mentions légales,la page doit être définie dans la configuration du site.', 'help' => 'Saisissez le texte du lien vers les mentions légales,la page doit être définie dans la configuration du site.',
'label' => 'Lien page des mentions légales.', 'label' => 'Lien page des mentions légales.',
'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['linkLegalLabel'], 'value' => $module::$locales[$this->getUrl(2)]['locale']['cookies']['linkLegalLabel'],
'placeHolder' => 'Consulter les mentions légales' 'placeHolder' => 'Consulter les mentions légales'
]); ?> ]); ?>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,81 +1,81 @@
<?php echo template::formOpen('translateForm'); ?> <?php echo template::formOpen('translateForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('translateFormBack', [ <?php echo template::button('translateFormBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl(), 'href' => helper::baseUrl(),
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col1"> <div class="col1">
<?php /**echo template::button('translateHelp', [ <?php /**echo template::button('translateHelp', [
'href' => 'https://doc.zwiicms.fr/prise-en-charge-des-langues-etrangeres', 'href' => 'https://doc.zwiicms.fr/prise-en-charge-des-langues-etrangeres',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'class' => 'buttonHelp', 'class' => 'buttonHelp',
'help' => 'Consulter l\'aide en ligne' 'help' => 'Consulter l\'aide en ligne'
]);*/ ?> ]);*/ ?>
</div>
<div class="col1 offset6">
<?php echo template::button('translateButton', [
'href' => helper::baseUrl() . 'translate/copy',
'value' => template::ico('docs'),
'disabled' => $module::$siteCopy,
'help' => 'Copie de sites inter-langues'
]); ?>
</div>
<div class="col1">
<?php echo template::button('translateButton', [
'href' => helper::baseUrl() . 'translate/add',
'value' => template::ico('plus'),
'class' => 'buttonGreen',
'help' => 'Ajouter une langue de contenu'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('translateFormSubmit'); ?>
</div>
</div> </div>
<div class="col1 offset6">
<div class="tab"> <?php echo template::button('translateButton', [
<?php echo template::button('translateUiButton', [ 'href' => helper::baseUrl() . 'translate/copy',
'value' => 'Langue de l\'interface', 'value' => template::ico('docs'),
'class' => 'buttonTab' 'disabled' => $module::$siteCopy,
'help' => 'Copie de sites inter-langues'
]); ?> ]); ?>
<?php echo template::button('translateContentButton', [
'value' => 'Langues du contenu',
'class' => 'buttonTab'
]); ?>
</div> </div>
<div class="col1">
<?php echo template::button('translateButton', [
'href' => helper::baseUrl() . 'translate/add',
'value' => template::ico('plus'),
'class' => 'buttonGreen',
'help' => 'Ajouter une langue de contenu'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('translateFormSubmit'); ?>
</div>
</div>
<div id="uiContainer" class="tabContent"> <div class="tab">
<div class="row"> <?php echo template::button('translateUiButton', [
<div class="col12"> 'value' => 'Langue de l\'interface',
<div class="block"> 'class' => 'buttonTab'
<h4> ]); ?>
<?php echo template::topic('Langue de l\'administration'); ?> <?php echo template::button('translateContentButton', [
</h4> 'value' => 'Langues du contenu',
<div class="row"> 'class' => 'buttonTab'
<div class="col4 offset4"> ]); ?>
<?php echo template::select('translateUI', $module::$i18nFiles, [
'label' => 'Traductions installées', </div>
'selected' => $this->getData(['config', 'i18n' , 'interface']),
]); ?> <div id="uiContainer" class="tabContent">
</div> <div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo template::topic('Langue de l\'administration'); ?>
</h4>
<div class="row">
<div class="col4 offset4">
<?php echo template::select('translateUI', $module::$i18nFiles, [
'label' => 'Traductions installées',
'selected' => $this->getData(['config', 'i18n', 'interface']),
]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="contentContainer" class="tabContent"> </div>
<div class="row"> <div id="contentContainer" class="tabContent">
<div class="col12"> <div class="row">
<?php if($module::$languagesInstalled): ?> <div class="col12">
<?php echo template::table([1, 3, 2, 4, 1, 1], $module::$languagesInstalled, ['Langue', '', '', '', '', '']); ?> <?php if ($module::$languagesInstalled) : ?>
<?php endif; ?> <?php echo template::table([1, 3, 2, 4, 1, 1], $module::$languagesInstalled, ['Langue', '', '', '', '', '']); ?>
</div> <?php endif; ?>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -13,7 +13,8 @@
* @link http://zwiicms.fr/ * @link http://zwiicms.fr/
*/ */
class user extends common { class user extends common
{
public static $actions = [ public static $actions = [
'add' => self::GROUP_ADMIN, 'add' => self::GROUP_ADMIN,
@ -50,18 +51,19 @@ class user extends common {
/** /**
* Ajout * Ajout
*/ */
public function add() { public function add()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
$check=true; $check = true;
// L'identifiant d'utilisateur est indisponible // L'identifiant d'utilisateur est indisponible
$userId = $this->getInput('userAddId', helper::FILTER_ID, true); $userId = $this->getInput('userAddId', helper::FILTER_ID, true);
if($this->getData(['user', $userId])) { if ($this->getData(['user', $userId])) {
self::$inputNotices['userAddId'] = 'Identifiant déjà utilisé'; self::$inputNotices['userAddId'] = 'Identifiant déjà utilisé';
$check=false; $check = false;
} }
// Double vérification pour le mot de passe // Double vérification pour le mot de passe
if($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) { if ($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
self::$inputNotices['userAddConfirmPassword'] = 'Incorrect'; self::$inputNotices['userAddConfirmPassword'] = 'Incorrect';
$check = false; $check = false;
} }
@ -94,14 +96,14 @@ class user extends common {
// Envoie le mail // Envoie le mail
$sent = true; $sent = true;
if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $check === true) { if ($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $check === true) {
$sent = $this->sendMail( $sent = $this->sendMail(
$userMail, $userMail,
'Compte créé sur ' . $this->getData(['locale', 'title']), 'Compte créé sur ' . $this->getData(['locale', 'title']),
'Bonjour <strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' . 'Bonjour <strong>' . $userFirstname . ' ' . $userLastname . '</strong>,<br><br>' .
'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.<br><br>' . 'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.<br><br>' .
'<strong>Identifiant du compte :</strong> ' . $this->getInput('userAddId') . '<br>' . '<strong>Identifiant du compte :</strong> ' . $this->getInput('userAddId') . '<br>' .
'<small>Nous ne conservons pas les mots de passe, en conséquence nous vous conseillons de conserver ce message tant que vous ne vous êtes pas connecté. Vous pourrez modifier votre mot de passe après votre première connexion.</small>', '<small>Nous ne conservons pas les mots de passe, en conséquence nous vous conseillons de conserver ce message tant que vous ne vous êtes pas connecté. Vous pourrez modifier votre mot de passe après votre première connexion.</small>',
null null
); );
} }
@ -122,13 +124,14 @@ class user extends common {
/** /**
* Suppression * Suppression
*/ */
public function delete() { public function delete()
{
// Accès refusé // Accès refusé
if( if (
// L'utilisateur n'existe pas // L'utilisateur n'existe pas
$this->getData(['user', $this->getUrl(2)]) === null $this->getData(['user', $this->getUrl(2)]) === null
// Groupe insuffisant // Groupe insuffisant
AND ($this->getUrl('group') < self::GROUP_MODERATOR) and ($this->getUrl('group') < self::GROUP_MODERATOR)
) { ) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -144,7 +147,7 @@ class user extends common {
]); ]);
} }
// Bloque la suppression de son propre compte // Bloque la suppression de son propre compte
elseif($this->getUser('id') === $this->getUrl(2)) { elseif ($this->getUser('id') === $this->getUrl(2)) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'user', 'redirect' => helper::baseUrl() . 'user',
@ -166,9 +169,12 @@ class user extends common {
/** /**
* Édition * Édition
*/ */
public function edit() { public function edit()
if ($this->getUrl(3) !== $_SESSION['csrf'] && {
$this->getUrl(4) !== $_SESSION['csrf']) { if (
$this->getUrl(3) !== $_SESSION['csrf'] &&
$this->getUrl(4) !== $_SESSION['csrf']
) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . 'user', 'redirect' => helper::baseUrl() . 'user',
@ -176,18 +182,17 @@ class user extends common {
]); ]);
} }
// Accès refusé // Accès refusé
if( if (
// L'utilisateur n'existe pas // L'utilisateur n'existe pas
$this->getData(['user', $this->getUrl(2)]) === null $this->getData(['user', $this->getUrl(2)]) === null
// Droit d'édition // Droit d'édition
AND ( and (
// Impossible de s'auto-éditer // Impossible de s'auto-éditer
( ($this->getUser('id') === $this->getUrl(2)
$this->getUser('id') === $this->getUrl(2) and $this->getUrl('group') <= self::GROUP_VISITOR
AND $this->getUrl('group') <= self::GROUP_VISITOR
) )
// Impossible d'éditer un autre utilisateur // Impossible d'éditer un autre utilisateur
OR ($this->getUrl('group') < self::GROUP_MODERATOR) or ($this->getUrl('group') < self::GROUP_MODERATOR)
) )
) { ) {
// Valeurs en sortie // Valeurs en sortie
@ -198,45 +203,41 @@ class user extends common {
// Accès autorisé // Accès autorisé
else { else {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Double vérification pour le mot de passe // Double vérification pour le mot de passe
$newPassword = $this->getData(['user', $this->getUrl(2), 'password']); $newPassword = $this->getData(['user', $this->getUrl(2), 'password']);
if($this->getInput('userEditNewPassword')) { if ($this->getInput('userEditNewPassword')) {
// L'ancien mot de passe est correct // L'ancien mot de passe est correct
if(password_verify($this->getInput('userEditOldPassword'), $this->getData(['user', $this->getUrl(2), 'password']))) { if (password_verify($this->getInput('userEditOldPassword'), $this->getData(['user', $this->getUrl(2), 'password']))) {
// La confirmation correspond au mot de passe // La confirmation correspond au mot de passe
if($this->getInput('userEditNewPassword') === $this->getInput('userEditConfirmPassword')) { if ($this->getInput('userEditNewPassword') === $this->getInput('userEditConfirmPassword')) {
$newPassword = $this->getInput('userEditNewPassword', helper::FILTER_PASSWORD, true); $newPassword = $this->getInput('userEditNewPassword', helper::FILTER_PASSWORD, true);
// Déconnexion de l'utilisateur si il change le mot de passe de son propre compte // Déconnexion de l'utilisateur si il change le mot de passe de son propre compte
if($this->getUser('id') === $this->getUrl(2)) { if ($this->getUser('id') === $this->getUrl(2)) {
helper::deleteCookie('ZWII_USER_ID'); helper::deleteCookie('ZWII_USER_ID');
helper::deleteCookie('ZWII_USER_PASSWORD'); helper::deleteCookie('ZWII_USER_PASSWORD');
} }
} } else {
else {
self::$inputNotices['userEditConfirmPassword'] = 'Incorrect'; self::$inputNotices['userEditConfirmPassword'] = 'Incorrect';
} }
} } else {
else {
self::$inputNotices['userEditOldPassword'] = 'Incorrect'; self::$inputNotices['userEditOldPassword'] = 'Incorrect';
} }
} }
// Modification du groupe // Modification du groupe
if( if (
$this->getUser('group') === self::GROUP_ADMIN $this->getUser('group') === self::GROUP_ADMIN
AND $this->getUrl(2) !== $this->getUser('id') and $this->getUrl(2) !== $this->getUser('id')
) { ) {
$newGroup = $this->getInput('userEditGroup', helper::FILTER_INT, true); $newGroup = $this->getInput('userEditGroup', helper::FILTER_INT, true);
} } else {
else {
$newGroup = $this->getData(['user', $this->getUrl(2), 'group']); $newGroup = $this->getData(['user', $this->getUrl(2), 'group']);
} }
// Modification de nom Prénom // Modification de nom Prénom
if($this->getUser('group') === self::GROUP_ADMIN){ if ($this->getUser('group') === self::GROUP_ADMIN) {
$newfirstname = $this->getInput('userEditFirstname', helper::FILTER_STRING_SHORT, true); $newfirstname = $this->getInput('userEditFirstname', helper::FILTER_STRING_SHORT, true);
$newlastname = $this->getInput('userEditLastname', helper::FILTER_STRING_SHORT, true); $newlastname = $this->getInput('userEditLastname', helper::FILTER_STRING_SHORT, true);
} } else {
else{
$newfirstname = $this->getData(['user', $this->getUrl(2), 'firstname']); $newfirstname = $this->getData(['user', $this->getUrl(2), 'firstname']);
$newlastname = $this->getData(['user', $this->getUrl(2), 'lastname']); $newlastname = $this->getData(['user', $this->getUrl(2), 'lastname']);
} }
@ -253,20 +254,20 @@ class user extends common {
'signature' => $this->getInput('userEditSignature', helper::FILTER_INT, true), 'signature' => $this->getInput('userEditSignature', helper::FILTER_INT, true),
'mail' => $this->getInput('userEditMail', helper::FILTER_MAIL, true), 'mail' => $this->getInput('userEditMail', helper::FILTER_MAIL, true),
'password' => $newPassword, 'password' => $newPassword,
'connectFail' => $this->getData(['user',$this->getUrl(2),'connectFail']), 'connectFail' => $this->getData(['user', $this->getUrl(2), 'connectFail']),
'connectTimeout' => $this->getData(['user',$this->getUrl(2),'connectTimeout']), 'connectTimeout' => $this->getData(['user', $this->getUrl(2), 'connectTimeout']),
'accessUrl' => $this->getData(['user',$this->getUrl(2),'accessUrl']), 'accessUrl' => $this->getData(['user', $this->getUrl(2), 'accessUrl']),
'accessTimer' => $this->getData(['user',$this->getUrl(2),'accessTimer']), 'accessTimer' => $this->getData(['user', $this->getUrl(2), 'accessTimer']),
'accessCsrf' => $this->getData(['user',$this->getUrl(2),'accessCsrf']), 'accessCsrf' => $this->getData(['user', $this->getUrl(2), 'accessCsrf']),
'files' => $this->getInput('userEditFiles', helper::FILTER_BOOLEAN) 'files' => $this->getInput('userEditFiles', helper::FILTER_BOOLEAN)
] ]
]); ]);
// Redirection spécifique si l'utilisateur change son mot de passe // Redirection spécifique si l'utilisateur change son mot de passe
if($this->getUser('id') === $this->getUrl(2) AND $this->getInput('userEditNewPassword')) { if ($this->getUser('id') === $this->getUrl(2) and $this->getInput('userEditNewPassword')) {
$redirect = helper::baseUrl() . 'user/login/' . str_replace('/', '_', $this->getUrl()); $redirect = helper::baseUrl() . 'user/login/' . str_replace('/', '_', $this->getUrl());
} }
// Redirection si retour en arrière possible // Redirection si retour en arrière possible
elseif($this->getUser('group') === 3) { elseif ($this->getUser('group') === 3) {
$redirect = helper::baseUrl() . 'user'; $redirect = helper::baseUrl() . 'user';
} }
// Redirection normale // Redirection normale
@ -291,11 +292,12 @@ class user extends common {
/** /**
* Mot de passe perdu * Mot de passe perdu
*/ */
public function forgot() { public function forgot()
{
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
$userId = $this->getInput('userForgotId', helper::FILTER_ID, true); $userId = $this->getInput('userForgotId', helper::FILTER_ID, true);
if($this->getData(['user', $userId])) { if ($this->getData(['user', $userId])) {
// Enregistre la date de la demande dans le compte utilisateur // Enregistre la date de la demande dans le compte utilisateur
$this->setData(['user', $userId, 'forgot', time()]); $this->setData(['user', $userId, 'forgot', time()]);
// Crée un id unique pour la réinitialisation // Crée un id unique pour la réinitialisation
@ -305,9 +307,9 @@ class user extends common {
$this->getData(['user', $userId, 'mail']), $this->getData(['user', $userId, 'mail']),
'Réinitialisation de votre mot de passe', 'Réinitialisation de votre mot de passe',
'Bonjour <strong>' . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']) . '</strong>,<br><br>' . 'Bonjour <strong>' . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']) . '</strong>,<br><br>' .
'Vous avez demandé à changer le mot de passe lié à votre compte. Vous trouverez ci-dessous un lien vous permettant de modifier celui-ci.<br><br>' . 'Vous avez demandé à changer le mot de passe lié à votre compte. Vous trouverez ci-dessous un lien vous permettant de modifier celui-ci.<br><br>' .
'<a href="' . helper::baseUrl() . 'user/reset/' . $userId . '/' . $uniqId . '" target="_blank">' . helper::baseUrl() . 'user/reset/' . $userId . '/' . $uniqId . '</a><br><br>' . '<a href="' . helper::baseUrl() . 'user/reset/' . $userId . '/' . $uniqId . '" target="_blank">' . helper::baseUrl() . 'user/reset/' . $userId . '/' . $uniqId . '</a><br><br>' .
'<small>Si nous n\'avez pas demandé à réinitialiser votre mot de passe, veuillez ignorer ce mail.</small>', '<small>Si nous n\'avez pas demandé à réinitialiser votre mot de passe, veuillez ignorer ce mail.</small>',
null null
); );
// Valeurs en sortie // Valeurs en sortie
@ -335,23 +337,24 @@ class user extends common {
/** /**
* Liste des utilisateurs * Liste des utilisateurs
*/ */
public function index() { public function index()
{
$userIdsFirstnames = helper::arrayColumn($this->getData(['user']), 'firstname'); $userIdsFirstnames = helper::arrayColumn($this->getData(['user']), 'firstname');
ksort($userIdsFirstnames); ksort($userIdsFirstnames);
foreach($userIdsFirstnames as $userId => $userFirstname) { foreach ($userIdsFirstnames as $userId => $userFirstname) {
if ($this->getData(['user', $userId, 'group'])) { if ($this->getData(['user', $userId, 'group'])) {
self::$users[] = [ self::$users[] = [
$userId, $userId,
$userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']), $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']),
self::$groups[$this->getData(['user', $userId, 'group'])], self::$groups[$this->getData(['user', $userId, 'group'])],
template::button('userEdit' . $userId, [ template::button('userEdit' . $userId, [
'href' => helper::baseUrl() . 'user/edit/' . $userId . '/back/'. $_SESSION['csrf'], 'href' => helper::baseUrl() . 'user/edit/' . $userId . '/back/' . $_SESSION['csrf'],
'value' => template::ico('pencil'), 'value' => template::ico('pencil'),
'help' => 'Editer' 'help' => 'Editer'
]), ]),
template::button('userDelete' . $userId, [ template::button('userDelete' . $userId, [
'class' => 'userDelete buttonRed', 'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'user/delete/' . $userId. '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'user/delete/' . $userId . '/' . $_SESSION['csrf'],
'value' => template::ico('trash'), 'value' => template::ico('trash'),
'help' => 'Supprimer' 'help' => 'Supprimer'
]) ])
@ -368,17 +371,18 @@ class user extends common {
/** /**
* Connexion * Connexion
*/ */
public function login() { public function login()
{
// Soumission du formulaire // Soumission du formulaire
$logStatus = ''; $logStatus = '';
if($this->isPost()) { if ($this->isPost()) {
// Lire Id du compte // Lire Id du compte
$userId = $this->getInput('userLoginId', helper::FILTER_ID, true); $userId = $this->getInput('userLoginId', helper::FILTER_ID, true);
// Check le captcha // Check le captcha
if( if (
$this->getData(['config','connect','captcha']) $this->getData(['config', 'connect', 'captcha'])
AND password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult') ) === false ) and password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult')) === false
{ ) {
$captcha = false; $captcha = false;
} else { } else {
$captcha = true; $captcha = true;
@ -386,22 +390,24 @@ class user extends common {
/** /**
* Aucun compte existant * Aucun compte existant
*/ */
if ( !$this->getData(['user', $userId])) { if (!$this->getData(['user', $userId])) {
$logStatus = 'Compte inconnu'; $logStatus = 'Compte inconnu';
//Stockage de l'IP //Stockage de l'IP
$this->setData([ $this->setData([
'blacklist', 'blacklist',
$userId, $userId,
[ [
'connectFail' => $this->getData(['blacklist',$userId,'connectFail']) + 1, 'connectFail' => $this->getData(['blacklist', $userId, 'connectFail']) + 1,
'lastFail' => time(), 'lastFail' => time(),
'ip' => helper::getIp() 'ip' => helper::getIp()
] ]
]); ]);
// Verrouillage des IP // Verrouillage des IP
$ipBlackList = helper::arrayColumn($this->getData(['blacklist']), 'ip'); $ipBlackList = helper::arrayColumn($this->getData(['blacklist']), 'ip');
if ( $this->getData(['blacklist',$userId,'connectFail']) >= $this->getData(['config', 'connect', 'attempt']) if (
AND in_array($this->getData(['blacklist',$userId,'ip']),$ipBlackList) ) { $this->getData(['blacklist', $userId, 'connectFail']) >= $this->getData(['config', 'connect', 'attempt'])
and in_array($this->getData(['blacklist', $userId, 'ip']), $ipBlackList)
) {
$logStatus = 'Compte inconnu verrouillé'; $logStatus = 'Compte inconnu verrouillé';
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -415,38 +421,40 @@ class user extends common {
'notification' => 'Captcha, identifiant ou mot de passe incorrects' 'notification' => 'Captcha, identifiant ou mot de passe incorrects'
]); ]);
} }
/** /**
* Le compte existe * Le compte existe
*/ */
} else { } else {
// Cas 4 : le délai de blocage est dépassé et le compte est au max - Réinitialiser // Cas 4 : le délai de blocage est dépassé et le compte est au max - Réinitialiser
if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time() if (
AND $this->getData(['user',$userId,'connectFail']) === $this->getData(['config', 'connect', 'attempt']) ) { $this->getData(['user', $userId, 'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time()
$this->setData(['user',$userId,'connectFail',0 ]); and $this->getData(['user', $userId, 'connectFail']) === $this->getData(['config', 'connect', 'attempt'])
$this->setData(['user',$userId,'connectTimeout',0 ]); ) {
$this->setData(['user', $userId, 'connectFail', 0]);
$this->setData(['user', $userId, 'connectTimeout', 0]);
} }
// Check la présence des variables et contrôle du blocage du compte si valeurs dépassées // Check la présence des variables et contrôle du blocage du compte si valeurs dépassées
// Vérification du mot de passe et du groupe // Vérification du mot de passe et du groupe
if ( if (
( $this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) ) < time() ($this->getData(['user', $userId, 'connectTimeout']) + $this->getData(['config', 'connect', 'timeout'])) < time()
AND $this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt']) and $this->getData(['user', $userId, 'connectFail']) < $this->getData(['config', 'connect', 'attempt'])
AND password_verify($this->getInput('userLoginPassword', helper::FILTER_STRING_SHORT, true), $this->getData(['user', $userId, 'password'])) and password_verify($this->getInput('userLoginPassword', helper::FILTER_STRING_SHORT, true), $this->getData(['user', $userId, 'password']))
AND $this->getData(['user', $userId, 'group']) >= self::GROUP_MEMBER and $this->getData(['user', $userId, 'group']) >= self::GROUP_MEMBER
AND $captcha === true and $captcha === true
) { ) {
// RAZ // RAZ
$this->setData(['user',$userId,'connectFail',0 ]); $this->setData(['user', $userId, 'connectFail', 0]);
$this->setData(['user',$userId,'connectTimeout',0 ]); $this->setData(['user', $userId, 'connectTimeout', 0]);
// Expiration // Expiration
$expire = $this->getInput('userLoginLongTime', helper::FILTER_BOOLEAN ) === true ? strtotime("+1 year") : 0 ; $expire = $this->getInput('userLoginLongTime', helper::FILTER_BOOLEAN) === true ? strtotime("+1 year") : 0;
setcookie('ZWII_USER_ID', $userId, $expire, helper::baseUrl(false, false) , '', helper::isHttps(), true); setcookie('ZWII_USER_ID', $userId, $expire, helper::baseUrl(false, false), '', helper::isHttps(), true);
setcookie('ZWII_USER_PASSWORD', $this->getData(['user', $userId, 'password']), $expire, helper::baseUrl(false, false), '', helper::isHttps(), true); setcookie('ZWII_USER_PASSWORD', $this->getData(['user', $userId, 'password']), $expire, helper::baseUrl(false, false), '', helper::isHttps(), true);
// Accès multiples avec le même compte // Accès multiples avec le même compte
$this->setData(['user',$userId,'accessCsrf',$_SESSION['csrf']]); $this->setData(['user', $userId, 'accessCsrf', $_SESSION['csrf']]);
// Valeurs en sortie lorsque le site est en maintenance et que l'utilisateur n'est pas administrateur // Valeurs en sortie lorsque le site est en maintenance et que l'utilisateur n'est pas administrateur
if( if (
$this->getData(['config', 'maintenance']) $this->getData(['config', 'maintenance'])
AND $this->getData(['user', $userId, 'group']) < self::GROUP_ADMIN and $this->getData(['user', $userId, 'group']) < self::GROUP_ADMIN
) { ) {
$this->addOutput([ $this->addOutput([
'notification' => 'Seul un administrateur peut se connecter lors d\'une maintenance', 'notification' => 'Seul un administrateur peut se connecter lors d\'une maintenance',
@ -457,25 +465,25 @@ class user extends common {
$logStatus = 'Connexion réussie'; $logStatus = 'Connexion réussie';
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Bienvenue ' . $this->getData(['user',$userId,'firstname']) . ' ' . $this->getData(['user',$userId,'lastname']) , 'notification' => 'Bienvenue ' . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']),
'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), 'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))),
'state' => true 'state' => true
]); ]);
} }
// Sinon notification d'échec // Sinon notification d'échec
} else { } else {
$notification = 'Captcha, identifiant ou mot de passe incorrects'; $notification = 'Captcha, identifiant ou mot de passe incorrects';
$logStatus = $captcha === true ? 'Erreur de mot de passe' : 'Erreur de captcha'; $logStatus = $captcha === true ? 'Erreur de mot de passe' : 'Erreur de captcha';
// Cas 1 le nombre de connexions est inférieur aux tentatives autorisées : incrément compteur d'échec // Cas 1 le nombre de connexions est inférieur aux tentatives autorisées : incrément compteur d'échec
if ($this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt'])) { if ($this->getData(['user', $userId, 'connectFail']) < $this->getData(['config', 'connect', 'attempt'])) {
$this->setData(['user',$userId,'connectFail',$this->getdata(['user',$userId,'connectFail']) + 1 ]); $this->setData(['user', $userId, 'connectFail', $this->getdata(['user', $userId, 'connectFail']) + 1]);
} }
// Cas 2 la limite du nombre de connexion est atteinte : placer le timer // Cas 2 la limite du nombre de connexion est atteinte : placer le timer
if ( $this->getdata(['user',$userId,'connectFail']) == $this->getData(['config', 'connect', 'attempt']) ) { if ($this->getdata(['user', $userId, 'connectFail']) == $this->getData(['config', 'connect', 'attempt'])) {
$this->setData(['user',$userId,'connectTimeout', time()]); $this->setData(['user', $userId, 'connectTimeout', time()]);
} }
// Cas 3 le délai de bloquage court // Cas 3 le délai de bloquage court
if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time() ) { if ($this->getData(['user', $userId, 'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time()) {
$notification = 'Accès bloqué ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; $notification = 'Accès bloqué ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.';
} }
@ -487,15 +495,15 @@ class user extends common {
} }
} }
// Journalisation // Journalisation
$dataLog = mb_detect_encoding(strftime('%d/%m/%y',time()), 'UTF-8', true) $dataLog = mb_detect_encoding(strftime('%d/%m/%y', time()), 'UTF-8', true)
? strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ? strftime('%d/%m/%y', time()) . ';' . strftime('%R', time()) . ';'
: utf8_encode(strftime('%d/%m/%y',time())) . ';' . utf8_encode(strftime('%R',time())) . ';' ; : utf8_encode(strftime('%d/%m/%y', time())) . ';' . utf8_encode(strftime('%R', time())) . ';';
$dataLog .= helper::getIp($this->getData(['config','connect','anonymousIp'])) . ';'; $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';';
$dataLog .= $this->getInput('userLoginId', helper::FILTER_ID) . ';' ; $dataLog .= $this->getInput('userLoginId', helper::FILTER_ID) . ';';
$dataLog .= $this->getUrl() .';' ; $dataLog .= $this->getUrl() . ';';
$dataLog .= $logStatus ; $dataLog .= $logStatus;
$dataLog .= PHP_EOL; $dataLog .= PHP_EOL;
if ($this->getData(['config','connect','log'])) { if ($this->getData(['config', 'connect', 'log'])) {
file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND); file_put_contents(self::DATA_DIR . 'journal.log', $dataLog, FILE_APPEND);
} }
// Stockage des cookies // Stockage des cookies
@ -513,7 +521,8 @@ class user extends common {
/** /**
* Déconnexion * Déconnexion
*/ */
public function logout() { public function logout()
{
helper::deleteCookie('ZWII_USER_ID'); helper::deleteCookie('ZWII_USER_ID');
helper::deleteCookie('ZWII_USER_PASSWORD'); helper::deleteCookie('ZWII_USER_PASSWORD');
session_destroy(); session_destroy();
@ -528,15 +537,16 @@ class user extends common {
/** /**
* Réinitialisation du mot de passe * Réinitialisation du mot de passe
*/ */
public function reset() { public function reset()
{
// Accès refusé // Accès refusé
if( if (
// L'utilisateur n'existe pas // L'utilisateur n'existe pas
$this->getData(['user', $this->getUrl(2)]) === null $this->getData(['user', $this->getUrl(2)]) === null
// Lien de réinitialisation trop vieux // Lien de réinitialisation trop vieux
OR $this->getData(['user', $this->getUrl(2), 'forgot']) + 86400 < time() or $this->getData(['user', $this->getUrl(2), 'forgot']) + 86400 < time()
// Id unique incorrecte // Id unique incorrecte
OR $this->getUrl(3) !== md5(json_encode($this->getData(['user', $this->getUrl(2)]))) or $this->getUrl(3) !== md5(json_encode($this->getData(['user', $this->getUrl(2)])))
) { ) {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -546,15 +556,14 @@ class user extends common {
// Accès autorisé // Accès autorisé
else { else {
// Soumission du formulaire // Soumission du formulaire
if($this->isPost()) { if ($this->isPost()) {
// Double vérification pour le mot de passe // Double vérification pour le mot de passe
if($this->getInput('userResetNewPassword')) { if ($this->getInput('userResetNewPassword')) {
// La confirmation ne correspond pas au mot de passe // La confirmation ne correspond pas au mot de passe
if($this->getInput('userResetNewPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userResetConfirmPassword', helper::FILTER_STRING_SHORT, true)) { if ($this->getInput('userResetNewPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userResetConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
$newPassword = $this->getData(['user', $this->getUrl(2), 'password']); $newPassword = $this->getData(['user', $this->getUrl(2), 'password']);
self::$inputNotices['userResetConfirmPassword'] = 'Incorrect'; self::$inputNotices['userResetConfirmPassword'] = 'Incorrect';
} } else {
else {
$newPassword = $this->getInput('userResetNewPassword', helper::FILTER_PASSWORD, true); $newPassword = $this->getInput('userResetNewPassword', helper::FILTER_PASSWORD, true);
} }
// Modifie le mot de passe // Modifie le mot de passe
@ -562,8 +571,8 @@ class user extends common {
// Réinitialise la date de la demande // Réinitialise la date de la demande
$this->setData(['user', $this->getUrl(2), 'forgot', 0]); $this->setData(['user', $this->getUrl(2), 'forgot', 0]);
// Réinitialise le blocage // Réinitialise le blocage
$this->setData(['user', $this->getUrl(2),'connectFail',0 ]); $this->setData(['user', $this->getUrl(2), 'connectFail', 0]);
$this->setData(['user', $this->getUrl(2),'connectTimeout',0 ]); $this->setData(['user', $this->getUrl(2), 'connectTimeout', 0]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'notification' => 'Nouveau mot de passe enregistré', 'notification' => 'Nouveau mot de passe enregistré',
@ -585,66 +594,69 @@ class user extends common {
/** /**
* Importation CSV d'utilisateurs * Importation CSV d'utilisateurs
*/ */
public function import() { public function import()
{
// Soumission du formulaire // Soumission du formulaire
$notification = ''; $notification = '';
$success = true; $success = true;
if($this->isPost()) { if ($this->isPost()) {
// Lecture du CSV et construction du tableau // Lecture du CSV et construction du tableau
$file = $this->getInput('userImportCSVFile',helper::FILTER_STRING_SHORT, true); $file = $this->getInput('userImportCSVFile', helper::FILTER_STRING_SHORT, true);
$filePath = self::FILE_DIR . 'source/' . $file; $filePath = self::FILE_DIR . 'source/' . $file;
if ($file AND file_exists($filePath)) { if ($file and file_exists($filePath)) {
// Analyse et extraction du CSV // Analyse et extraction du CSV
$rows = array_map(function($row) { return str_getcsv($row, $this->getInput('userImportSeparator') ); }, file($filePath)); $rows = array_map(function ($row) {
return str_getcsv($row, $this->getInput('userImportSeparator'));
}, file($filePath));
$header = array_shift($rows); $header = array_shift($rows);
$csv = array(); $csv = array();
foreach($rows as $row) { foreach ($rows as $row) {
$csv[] = array_combine($header, $row); $csv[] = array_combine($header, $row);
} }
// Traitement des données // Traitement des données
foreach($csv as $item ) { foreach ($csv as $item) {
// Données valides // Données valides
if( array_key_exists('id', $item) if (
AND array_key_exists('prenom',$item) array_key_exists('id', $item)
AND array_key_exists('nom',$item) and array_key_exists('prenom', $item)
AND array_key_exists('groupe',$item) and array_key_exists('nom', $item)
AND array_key_exists('email',$item) and array_key_exists('groupe', $item)
AND $item['nom'] and array_key_exists('email', $item)
AND $item['prenom'] and $item['nom']
AND $item['id'] and $item['prenom']
AND $item['email'] and $item['id']
AND $item['groupe'] and $item['email']
and $item['groupe']
) { ) {
// Validation du groupe // Validation du groupe
$item['groupe'] = (int) $item['groupe']; $item['groupe'] = (int) $item['groupe'];
$item['groupe'] = ( $item['groupe'] >= self::GROUP_BANNED AND $item['groupe'] <= self::GROUP_ADMIN ) $item['groupe'] = ($item['groupe'] >= self::GROUP_BANNED and $item['groupe'] <= self::GROUP_ADMIN)
? $item['groupe'] : 1; ? $item['groupe'] : 1;
// L'utilisateur existe // L'utilisateur existe
if ( $this->getData(['user',helper::filter($item['id'] , helper::FILTER_ID)])) if ($this->getData(['user', helper::filter($item['id'], helper::FILTER_ID)])) {
{
// Notification du doublon // Notification du doublon
$item['notification'] = template::ico('cancel'); $item['notification'] = template::ico('cancel');
// Création du tableau de confirmation // Création du tableau de confirmation
self::$users[] = [ self::$users[] = [
helper::filter($item['id'] , helper::FILTER_ID), helper::filter($item['id'], helper::FILTER_ID),
$item['nom'], $item['nom'],
$item['prenom'], $item['prenom'],
self::$groups[$item['groupe']], self::$groups[$item['groupe']],
$item['prenom'], $item['prenom'],
helper::filter($item['email'] , helper::FILTER_MAIL), helper::filter($item['email'], helper::FILTER_MAIL),
$item['notification'] $item['notification']
]; ];
// L'utilisateur n'existe pas // L'utilisateur n'existe pas
} else { } else {
// Nettoyage de l'identifiant // Nettoyage de l'identifiant
$userId = helper::filter($item['id'] , helper::FILTER_ID); $userId = helper::filter($item['id'], helper::FILTER_ID);
// Enregistre le user // Enregistre le user
$create = $this->setData([ $create = $this->setData([
'user', 'user',
$userId, [ $userId, [
'firstname' => $item['prenom'], 'firstname' => $item['prenom'],
'forgot' => 0, 'forgot' => 0,
'group' => $item['groupe'] , 'group' => $item['groupe'],
'lastname' => $item['nom'], 'lastname' => $item['nom'],
'mail' => $item['email'], 'mail' => $item['email'],
'pseudo' => $item['prenom'], 'pseudo' => $item['prenom'],
@ -655,23 +667,26 @@ class user extends common {
"accessUrl" => null, "accessUrl" => null,
"accessTimer" => null, "accessTimer" => null,
"accessCsrf" => null "accessCsrf" => null
]]); ]
]);
// Icône de notification // Icône de notification
$item['notification'] = $create ? template::ico('check') : template::ico('cancel'); $item['notification'] = $create ? template::ico('check') : template::ico('cancel');
// Envoi du mail // Envoi du mail
if ($create if (
AND $this->getInput('userImportNotification',helper::FILTER_BOOLEAN) === true) { $create
and $this->getInput('userImportNotification', helper::FILTER_BOOLEAN) === true
) {
$sent = $this->sendMail( $sent = $this->sendMail(
$item['email'], $item['email'],
'Compte créé sur ' . $this->getData(['locale', 'title']), 'Compte créé sur ' . $this->getData(['locale', 'title']),
'Bonjour <strong>' . $item['prenom'] . ' ' . $item['nom'] . '</strong>,<br><br>' . 'Bonjour <strong>' . $item['prenom'] . ' ' . $item['nom'] . '</strong>,<br><br>' .
'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.<br><br>' . 'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.<br><br>' .
'<strong>Identifiant du compte :</strong> ' . $userId . '<br>' . '<strong>Identifiant du compte :</strong> ' . $userId . '<br>' .
'<small>Un mot de passe provisoire vous été attribué, à la première connexion cliquez sur Mot de passe Oublié.</small>' '<small>Un mot de passe provisoire vous été attribué, à la première connexion cliquez sur Mot de passe Oublié.</small>'
); );
if ($sent === true) { if ($sent === true) {
// Mail envoyé changement de l'icône // Mail envoyé changement de l'icône
$item['notification'] = template::ico('mail') ; $item['notification'] = template::ico('mail');
} }
} }
// Création du tableau de confirmation // Création du tableau de confirmation
@ -688,10 +703,10 @@ class user extends common {
} }
} }
if (empty(self::$users)) { if (empty(self::$users)) {
$notification = 'Rien à importer, erreur de format ou fichier incorrect' ; $notification = 'Rien à importer, erreur de format ou fichier incorrect';
$success = false; $success = false;
} else { } else {
$notification = 'Importation effectuée' ; $notification = 'Importation effectuée';
$success = true; $success = true;
} }
} else { } else {
@ -707,5 +722,4 @@ class user extends common {
'state' => $success 'state' => $success
]); ]);
} }
} }

View File

@ -1,95 +1,98 @@
<?php echo template::formOpen('userAddForm'); ?> <?php echo template::formOpen('userAddForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php echo template::button('userAddBack', [ <?php echo template::button('userAddBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'user', 'href' => helper::baseUrl() . 'user',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('userAddSubmit'); ?>
</div>
</div> </div>
<div class="row"> <div class="col2 offset9">
<div class="col6"> <?php echo template::submit('userAddSubmit'); ?>
<div class="block"> </div>
<h4> </div>
<?php echo template::topic('Identité'); ?> <div class="row">
</h4> <div class="col6">
<div class="row"> <div class="block">
<div class="col6"> <h4>
<?php echo template::text('userAddFirstname', [ <?php echo template::topic('Identité'); ?>
'autocomplete' => 'off', </h4>
'label' => 'Prénom' <div class="row">
]); ?> <div class="col6">
</div> <?php echo template::text('userAddFirstname', [
<div class="col6"> 'autocomplete' => 'off',
<?php echo template::text('userAddLastname', [ 'label' => 'Prénom'
'autocomplete' => 'off',
'label' => 'Nom'
]); ?>
</div>
</div>
<?php echo template::text('userAddPseudo', [
'autocomplete' => 'off',
'label' => 'Pseudo'
]); ?>
<?php echo template::select('userAddSignature', $module::$signature, [
'label' => 'Signature',
'selected' => 1
]); ?>
<?php echo template::mail('userAddMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail'
]); ?>
<?php echo template::select('userAddGroup', self::$groupNews, [
'label' => 'Groupe',
'selected' => self::GROUP_MEMBER
]); ?>
<div id="userAddMemberFiles" class="displayNone">
<?php echo template::checkbox('userAddFiles', true, 'Partage de fichiers autorisé', [
'checked' => false,
'help' => 'Ce membre pourra téléverser ou télécharger des fichiers dans le dossier \'partage\' et ses sous-dossiers'
]); ?> ]); ?>
</div> </div>
<div id="userAddLabelAuth"> <div class="col6">
<?php echo template::topic('Permissions :'); ?> <?php echo template::text('userAddLastname', [
'autocomplete' => 'off',
'label' => 'Nom'
]); ?>
</div> </div>
<ul id="userAddGroupDescription<?php echo self::GROUP_MEMBER; ?>" class="userAddGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
</ul>
<ul id="userAddGroupDescription<?php echo self::GROUP_MODERATOR; ?>" class="userAddGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de pages'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de fichiers'); ?></li>
</ul>
<ul id="userAddGroupDescription<?php echo self::GROUP_ADMIN; ?>" class="userAddGroupDescription displayNone">
<li><?php echo template::topic('Administration complète du site'); ?></li>
</ul>
</div> </div>
</div> <?php echo template::text('userAddPseudo', [
<div class="col6"> 'autocomplete' => 'off',
<div class="block"> 'label' => 'Pseudo'
<h4> ]); ?>
<?php echo template::topic('Authentification'); ?> <?php echo template::select('userAddSignature', $module::$signature, [
</h4> 'label' => 'Signature',
<?php echo template::text('userAddId', [ 'selected' => 1
'autocomplete' => 'off', ]); ?>
'label' => 'Identifiant' <?php echo template::mail('userAddMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail'
]); ?>
<?php echo template::select('userAddGroup', self::$groupNews, [
'label' => 'Groupe',
'selected' => self::GROUP_MEMBER
]); ?>
<div id="userAddMemberFiles" class="displayNone">
<?php echo template::checkbox('userAddFiles', true, 'Partage de fichiers autorisé', [
'checked' => false,
'help' => 'Ce membre pourra téléverser ou télécharger des fichiers dans le dossier \'partage\' et ses sous-dossiers'
]); ?> ]); ?>
<?php echo template::password('userAddPassword', [
'autocomplete' => 'off',
'label' => 'Mot de passe'
]); ?>
<?php echo template::password('userAddConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation'
]); ?>
<?php echo template::checkbox('userAddSendMail', true,
'Prévenir l\'utilisateur par mail');
?>
</div> </div>
<div id="userAddLabelAuth">
<?php echo template::topic('Permissions :'); ?>
</div>
<ul id="userAddGroupDescription<?php echo self::GROUP_MEMBER; ?>" class="userAddGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
</ul>
<ul id="userAddGroupDescription<?php echo self::GROUP_MODERATOR; ?>" class="userAddGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de pages'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de fichiers'); ?></li>
</ul>
<ul id="userAddGroupDescription<?php echo self::GROUP_ADMIN; ?>" class="userAddGroupDescription displayNone">
<li><?php echo template::topic('Administration complète du site'); ?></li>
</ul>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <div class="col6">
<div class="block">
<h4>
<?php echo template::topic('Authentification'); ?>
</h4>
<?php echo template::text('userAddId', [
'autocomplete' => 'off',
'label' => 'Identifiant'
]); ?>
<?php echo template::password('userAddPassword', [
'autocomplete' => 'off',
'label' => 'Mot de passe'
]); ?>
<?php echo template::password('userAddConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation'
]); ?>
<?php echo template::checkbox(
'userAddSendMail',
true,
'Prévenir l\'utilisateur par mail'
);
?>
</div>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -1,117 +1,117 @@
<?php echo template::formOpen('userEditForm'); ?> <?php echo template::formOpen('userEditForm'); ?>
<div class="row"> <div class="row">
<div class="col1"> <div class="col1">
<?php if($this->getUser('group') === self::GROUP_ADMIN): ?> <?php if ($this->getUser('group') === self::GROUP_ADMIN) : ?>
<?php echo template::button('userEditBack', [ <?php echo template::button('userEditBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'user', 'href' => helper::baseUrl() . 'user',
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
<?php else: ?> <?php else : ?>
<?php echo template::button('userEditBack', [ <?php echo template::button('userEditBack', [
'class' => 'buttonGrey', 'class' => 'buttonGrey',
'href' => helper::baseUrl(false), 'href' => helper::baseUrl(false),
'value' => template::ico('home') 'value' => template::ico('home')
]); ?>
<?php endif; ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('userEditSubmit'); ?>
</div>
</div>
<div class="row">
<div class="col6">
<div class="block">
<h4>
<?php echo template::topic('Identité'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::text('userEditFirstname', [
'autocomplete' => 'off',
'disabled' => $this->getUser('group') > 2 ? false : true,
'label' => 'Prénom',
'value' => $this->getData(['user', $this->getUrl(2), 'firstname'])
]); ?>
</div>
<div class="col6">
<?php echo template::text('userEditLastname', [
'autocomplete' => 'off',
'disabled' => $this->getUser('group') > 2 ? false : true,
'label' => 'Nom',
'value' => $this->getData(['user', $this->getUrl(2), 'lastname'])
]); ?>
</div>
</div>
<?php echo template::text('userEditPseudo', [
'autocomplete' => 'off',
'label' => 'Pseudo',
'value' => $this->getData(['user', $this->getUrl(2), 'pseudo'])
]); ?>
<?php echo template::select('userEditSignature', $module::$signature, [
'label' => 'Signature',
'selected' => $this->getData(['user', $this->getUrl(2), 'signature'])
]); ?>
<?php echo template::mail('userEditMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail',
'value' => $this->getData(['user', $this->getUrl(2), 'mail'])
]); ?>
<?php if ($this->getUser('group') === self::GROUP_ADMIN) : ?>
<?php echo template::select('userEditGroup', self::$groupEdits, [
'disabled' => ($this->getUrl(2) === $this->getUser('id')),
'help' => ($this->getUrl(2) === $this->getUser('id') ? 'Impossible de modifier votre propre groupe.' : ''),
'label' => 'Groupe',
'selected' => $this->getData(['user', $this->getUrl(2), 'group'])
]); ?> ]); ?>
<div id="userEditMemberFiles" class="displayNone">
<?php echo template::checkbox('userEditFiles', true, 'Partage de fichiers autorisé', [
'checked' => $this->getData(['user', $this->getUrl(2), 'files']),
'help' => 'Ce membre pourra téléverser ou télécharger des fichiers dans le dossier \'partage\' et ses sous-dossiers'
]); ?>
</div>
<div id="userEditLabelAuth">
<?php echo template::topic('Permissions :'); ?>
</div>
<ul id="userEditGroupDescription<?php echo self::GROUP_MEMBER; ?>" class="userEditGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
</ul>
<ul id="userEditGroupDescription<?php echo self::GROUP_MODERATOR; ?>" class="userEditGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de pages'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de fichiers'); ?></li>
</ul>
<ul id="userEditGroupDescription<?php echo self::GROUP_ADMIN; ?>" class="userEditGroupDescription displayNone">
<li><?php echo template::topic('Administration complète du site'); ?></li>
</ul>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="col2 offset9"> </div>
<?php echo template::submit('userEditSubmit'); ?> <div class="col6">
<div class="block">
<h4>
<?php echo template::topic('Authentification'); ?>
</h4>
<?php echo template::text('userEditId', [
'autocomplete' => 'off',
'help' => 'L\'identifiant est défini lors de la création du compte, il ne peut pas être modifié.',
'label' => 'Identifiant',
'readonly' => true,
'value' => $this->getUrl(2)
]); ?>
<?php echo template::password('userEditOldPassword', [
'autocomplete' => 'new-password', // remplace 'off' pour éviter le pré remplissage auto
'label' => 'Ancien mot de passe'
]); ?>
<?php echo template::password('userEditNewPassword', [
'autocomplete' => 'off',
'label' => 'Nouveau mot de passe'
]); ?>
<?php echo template::password('userEditConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation'
]); ?>
</div> </div>
</div> </div>
<div class="row"> </div>
<div class="col6"> <?php echo template::formClose(); ?>
<div class="block">
<h4>
<?php echo template::topic('Identité'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::text('userEditFirstname', [
'autocomplete' => 'off',
'disabled' => $this->getUser('group') > 2 ? false : true,
'label' => 'Prénom',
'value' => $this->getData(['user', $this->getUrl(2), 'firstname'])
]); ?>
</div>
<div class="col6">
<?php echo template::text('userEditLastname', [
'autocomplete' => 'off',
'disabled' => $this->getUser('group') > 2 ? false : true,
'label' => 'Nom',
'value' => $this->getData(['user', $this->getUrl(2), 'lastname'])
]); ?>
</div>
</div>
<?php echo template::text('userEditPseudo', [
'autocomplete' => 'off',
'label' => 'Pseudo',
'value' => $this->getData(['user', $this->getUrl(2), 'pseudo'])
]); ?>
<?php echo template::select('userEditSignature', $module::$signature, [
'label' => 'Signature',
'selected' => $this->getData(['user', $this->getUrl(2), 'signature'])
]); ?>
<?php echo template::mail('userEditMail', [
'autocomplete' => 'off',
'label' => 'Adresse mail',
'value' => $this->getData(['user', $this->getUrl(2), 'mail'])
]); ?>
<?php if($this->getUser('group') === self::GROUP_ADMIN): ?>
<?php echo template::select('userEditGroup', self::$groupEdits, [
'disabled' => ($this->getUrl(2) === $this->getUser('id')),
'help' => ($this->getUrl(2) === $this->getUser('id') ? 'Impossible de modifier votre propre groupe.' : ''),
'label' => 'Groupe',
'selected' => $this->getData(['user', $this->getUrl(2), 'group'])
]); ?>
<div id="userEditMemberFiles" class="displayNone">
<?php echo template::checkbox('userEditFiles', true, 'Partage de fichiers autorisé', [
'checked' => $this->getData(['user', $this->getUrl(2), 'files']),
'help' => 'Ce membre pourra téléverser ou télécharger des fichiers dans le dossier \'partage\' et ses sous-dossiers'
]); ?>
</div>
<div id="userEditLabelAuth">
<?php echo template::topic('Permissions :'); ?>
</div>
<ul id="userEditGroupDescription<?php echo self::GROUP_MEMBER; ?>" class="userEditGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
</ul>
<ul id="userEditGroupDescription<?php echo self::GROUP_MODERATOR; ?>" class="userEditGroupDescription displayNone">
<li><?php echo template::topic('Accès aux pages privées'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de pages'); ?></li>
<li><?php echo template::topic('Ajout / Édition / Suppression de fichiers'); ?></li>
</ul>
<ul id="userEditGroupDescription<?php echo self::GROUP_ADMIN; ?>" class="userEditGroupDescription displayNone">
<li><?php echo template::topic('Administration complète du site'); ?></li>
</ul>
<?php endif; ?>
</div>
</div>
<div class="col6">
<div class="block">
<h4>
<?php echo template::topic('Authentification'); ?>
</h4>
<?php echo template::text('userEditId', [
'autocomplete' => 'off',
'help' => 'L\'identifiant est défini lors de la création du compte, il ne peut pas être modifié.',
'label' => 'Identifiant',
'readonly' => true,
'value' => $this->getUrl(2)
]); ?>
<?php echo template::password('userEditOldPassword', [
'autocomplete' => 'new-password', // remplace 'off' pour éviter le pré remplissage auto
'label' => 'Ancien mot de passe'
]); ?>
<?php echo template::password('userEditNewPassword', [
'autocomplete' => 'off',
'label' => 'Nouveau mot de passe'
]); ?>
<?php echo template::password('userEditConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation'
]); ?>
</div>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -1,18 +1,18 @@
<?php echo template::formOpen('userForgotForm'); ?> <?php echo template::formOpen('userForgotForm'); ?>
<?php echo template::text('userForgotId', [ <?php echo template::text('userForgotId', [
'label' => 'Identifiant' 'label' => 'Identifiant'
]); ?> ]); ?>
<div class="row"> <div class="row">
<div class="col1 offset9"> <div class="col1 offset9">
<?php echo template::button('userForgotBack', [ <?php echo template::button('userForgotBack', [
'href' => helper::baseUrl() . 'user/login/' . $this->getUrl(2), 'href' => helper::baseUrl() . 'user/login/' . $this->getUrl(2),
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div>
<div class="col3">
<?php echo template::submit('userForgotSubmit', [
'value' => 'Valider'
]); ?>
</div>
</div> </div>
<div class="col3">
<?php echo template::submit('userForgotSubmit', [
'value' => 'Valider'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -7,55 +7,55 @@
'value' => template::ico('left') 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
<div class="col1"> <div class="col1">
<?php /**echo template::button('userHelp', [ <?php /**echo template::button('userHelp', [
'href' => 'https://doc.zwiicms.fr/importation-d-une-liste-d-utilisateurs', 'href' => 'https://doc.zwiicms.fr/importation-d-une-liste-d-utilisateurs',
'target' => '_blank', 'target' => '_blank',
'value' => template::ico('help'), 'value' => template::ico('help'),
'class' => 'buttonHelp', 'class' => 'buttonHelp',
'help' => 'Consulter l\'aide en ligne' 'help' => 'Consulter l\'aide en ligne'
]);*/ ?> ]);*/ ?>
</div> </div>
<div class="col2 offset8"> <div class="col2 offset8">
<?php echo template::submit('userImportSubmit', [ <?php echo template::submit('userImportSubmit', [
'value' => 'Importer' 'value' => 'Importer'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo template::topic('Importation de fichier plat CSV'); ?> <?php echo template::topic('Importation de fichier plat CSV'); ?>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col10"> <div class="col10">
<?php echo template::file('userImportCSVFile', [ <?php echo template::file('userImportCSVFile', [
'label' => 'Liste d\'utilisateurs :' 'label' => 'Liste d\'utilisateurs :'
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::select('userImportSeparator', $module::$separators, [ <?php echo template::select('userImportSeparator', $module::$separators, [
'label' => 'Séparateur' 'label' => 'Séparateur'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::checkbox('userImportNotification', true, 'Envoyer un message de confirmation', [ <?php echo template::checkbox('userImportNotification', true, 'Envoyer un message de confirmation', [
'checked' => false 'checked' => false
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>
<?php if ($module::$users): ?> <?php if ($module::$users) : ?>
<div class="row"> <div class="row">
<div class="col12 textAlignCenter"> <div class="col12 textAlignCenter">
<?php echo template::table([1, 3, 3, 1, 1, 2, 1], $module::$users, ['Id', 'Nom', 'Prénom','Groupe', 'Pseudo', 'eMail', '']); ?> <?php echo template::table([1, 3, 3, 1, 1, 2, 1], $module::$users, ['Id', 'Nom', 'Prénom', 'Groupe', 'Pseudo', 'eMail', '']); ?>
<?php echo template::ico('check');?> Compte créé | <?php echo template::ico('mail');?> Compte créé et notifié | <?php echo template::ico('cancel');?> Erreur dans le fichier, compte non créé. <?php echo template::ico('check'); ?> Compte créé | <?php echo template::ico('mail'); ?> Compte créé et notifié | <?php echo template::ico('cancel'); ?> Erreur dans le fichier, compte non créé.
</div> </div>
</div> </div>
<?php endif;?> <?php endif; ?>

View File

@ -18,7 +18,7 @@
<div class="col1 offset8"> <div class="col1 offset8">
<?php echo template::button('userImport', [ <?php echo template::button('userImport', [
'href' => helper::baseUrl() . 'user/import', 'href' => helper::baseUrl() . 'user/import',
'value' => template::ico('upload') , 'value' => template::ico('upload'),
'help' => 'Importer des utilisateurs en masse' 'help' => 'Importer des utilisateurs en masse'
]); ?> ]); ?>
</div> </div>

View File

@ -1,54 +1,54 @@
<?php echo template::formOpen('userLoginForm'); ?> <?php echo template::formOpen('userLoginForm'); ?>
<div class="row">
<div class="col6">
<?php echo template::text('userLoginId', [
'label' => 'Identifiant',
'value' => $module::$userId
]); ?>
</div>
<div class="col6">
<?php if ($this->getData(['config', 'connect', 'showPassword']) === true) {
$passwordLabel = '<span id="passwordLabel">Mot de passe</span><span id="passwordIcon">' . template::ico('eye') . '</span>';
} else {
$passwordLabel = 'Mot de passe';
}
?>
<?php echo template::password('userLoginPassword', [
'label' => $passwordLabel
]); ?>
</div>
</div>
<?php if ($this->getData(['config', 'connect', 'captcha'])) : ?>
<div class="row"> <div class="row">
<div class="col6"> <div class="col12 textAlignCenter">
<?php echo template::text('userLoginId', [ <?php echo template::captcha('userLoginCaptcha', [
'label' => 'Identifiant', 'limit' => $this->getData(['config', 'connect', 'captchaStrong']),
'value' => $module::$userId 'type' => $this->getData(['config', 'connect', 'captchaType'])
]); ?>
</div>
<div class="col6">
<?php if ($this->getData(['config', 'connect', 'showPassword']) === true) {
$passwordLabel = '<span id="passwordLabel">Mot de passe</span><span id="passwordIcon">'. template::ico('eye') . '</span>';
} else {
$passwordLabel = 'Mot de passe';
}
?>
<?php echo template::password('userLoginPassword', [
'label' => $passwordLabel
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php if ($this->getData(['config', 'connect','captcha'])): ?> <?php endif; ?>
<div class="row"> <div class="row">
<div class="col12 textAlignCenter"> <div class="col6">
<?php echo template::captcha('userLoginCaptcha', [ <?php echo template::checkbox('userLoginLongTime', true, 'Rester connecté sur ce navigateur', [
'limit' => $this->getData(['config','connect', 'captchaStrong']), 'checked' => $module::$userLongtime
'type' => $this->getData(['config','connect', 'captchaType']) ]); ?>
]); ?>
</div>
</div>
<?php endif;?>
<div class="row">
<div class="col6">
<?php echo template::checkbox('userLoginLongTime', true, 'Rester connecté sur ce navigateur', [
'checked' => $module::$userLongtime
]); ?>
</div>
<div class="col6 textAlignRight">
<a href="<?php echo helper::baseUrl(); ?>user/forgot/<?php echo $this->getUrl(2); ?>">Mot de passe perdu ?</a>
</div>
</div> </div>
<div class="row"> <div class="col6 textAlignRight">
<div class="col2"> <a href="<?php echo helper::baseUrl(); ?>user/forgot/<?php echo $this->getUrl(2); ?>">Mot de passe perdu ?</a>
<?php echo template::button('userLoginBack', [
'href' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))),
'value' => template::ico('left')
]); ?>
</div>
<div class="col3 offset7">
<?php echo template::submit('userLoginSubmit', [
'value' => 'Connexion'
]); ?>
</div>
</div> </div>
</div>
<div class="row">
<div class="col2">
<?php echo template::button('userLoginBack', [
'href' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))),
'value' => template::ico('left')
]); ?>
</div>
<div class="col3 offset7">
<?php echo template::submit('userLoginSubmit', [
'value' => 'Connexion'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,21 +1,21 @@
<?php echo template::formOpen('userResetForm'); ?> <?php echo template::formOpen('userResetForm'); ?>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::password('userResetNewPassword', [ <?php echo template::password('userResetNewPassword', [
'label' => 'Nouveau mot de passe' 'label' => 'Nouveau mot de passe'
]); ?> ]); ?>
</div>
<div class="col6">
<?php echo template::password('userResetConfirmPassword', [
'label' => 'Confirmation'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col6">
<div class="col2 offset10"> <?php echo template::password('userResetConfirmPassword', [
<?php echo template::submit('userResetSubmit', [ 'label' => 'Confirmation'
'value' => 'Valider' ]); ?>
]); ?>
</div>
</div> </div>
</div>
<div class="row">
<div class="col2 offset10">
<?php echo template::submit('userResetSubmit', [
'value' => 'Valider'
]); ?>
</div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>