diff --git a/core/core.php b/core/core.php
index ca007a06..0b7097d8 100755
--- a/core/core.php
+++ b/core/core.php
@@ -186,6 +186,7 @@ class common {
* Constructeur commun
*/
public function __construct() {
+
// Extraction des données http
if(isset($_POST)) {
$this->input['_POST'] = $_POST;
@@ -352,6 +353,7 @@ class common {
);
stream_context_set_default($context);
}
+
}
/**
@@ -1111,6 +1113,796 @@ class common {
}
$zip->close();
}
+
+ // Layout remplace la classe précédente
+
+ /**
+ * Affiche le script Google Analytics
+ */
+ public function showAnalytics() {
+ if($code = $this->getData(['config', 'analyticsId'])
+ AND $this->getInput('ZWII_COOKIE_CONSENT') === 'true') {
+ echo '
+
+ ';
+ }
+ }
+
+ /**
+ * Affiche le contenu
+ * @param Page par défaut
+ */
+ public function showContent() {
+ if ($this->getData(['config', 'i18n', 'active']) === true) {
+ echo $this->showi18n('Site');
+ }
+ if(
+ $this->output['title']
+ AND (
+ $this->getData(['page', $this->getUrl(0)]) === null
+ OR $this->getData(['page', $this->getUrl(0), 'hideTitle']) === false
+ OR $this->getUrl(1) === 'config'
+ )
+ ) {
+ echo '
' . $this->output['title'] . '
';
+ }
+
+ echo $this->output['content'];
+
+ /**
+ * Affiche les crédits, conditions requis :
+ * La traduction est active et le site n'est pas en français.
+ * La fonction est activée.
+ */
+ if ( $this->getData(['config', 'i18n', 'active']) === true
+ AND $this->getData(['config', 'i18n','scriptGoogle']) === true
+ AND $this->getData(['config', 'i18n','showCredits']) === true
+ AND
+ // et la traduction n'est pas manuelle
+ ( $this->getInput('ZWII_I18N_SCRIPT')
+ AND $this->getData(['config', 'i18n', $this->getInput('ZWII_I18N_SCRIPT')]) === 'script'
+ )
+ )
+ {
+ echo '
';
+ }
+ }
+
+
+
+ /**
+ * Affiche le contenu de la barre gauche
+ *
+ */
+ public function showBarContentLeft() {
+ // Détermine si le menu est présent
+ if ($this->getData(['page',$this->getData(['page',$this->getUrl(0),'barLeft']),'displayMenu']) === 'none') {
+ // Pas de menu
+ echo $this->output['contentLeft'];
+ } else {
+ // $mark contient 0 le menu est positionné à la fin du contenu
+ $contentLeft = str_replace ('[]','[MENU]',$this->output['contentLeft']);
+ $contentLeft = str_replace ('[menu]','[MENU]',$contentLeft);
+ $mark = strrpos($contentLeft,'[MENU]') !== false ? strrpos($contentLeft,'[MENU]') : strlen($contentLeft);
+ echo substr($contentLeft,0,$mark);
+ echo '
';
+ echo substr($contentLeft,$mark+6,strlen($contentLeft));
+ }
+ }
+
+ /**
+ * Affiche le contenu de la barre droite
+ */
+ public function showBarContentRight() {
+ // Détermine si le menu est présent
+ if ($this->getData(['page',$this->getData(['page',$this->getUrl(0),'barRight']),'displayMenu']) === 'none') {
+ // Pas de menu
+ echo $this->output['contentRight'];
+ } else {
+ // $mark contient 0 le menu est positionné à la fin du contenu
+ $contentRight = str_replace ('[]','[MENU]',$this->output['contentRight']);
+ $contentRight = str_replace ('[menu]','[MENU]',$contentRight);
+ $mark = strrpos($contentRight,'[MENU]') !== false ? strrpos($contentRight,'[MENU]') : strlen($contentRight);
+ echo substr($contentRight,0,$mark);
+ echo '
';
+ if ($this->getData(['config', 'i18n', 'active']) === true) {
+ echo $this->showi18n('Nav');
+ }
+ }
+
+ /**
+ * Générer un menu pour la barre latérale
+ * Uniquement texte
+ * @param onlyChildren n'affiche les sous-pages de la page actuelle
+ */
+ public function showMenuSide($onlyChildren = null) {
+ // Met en forme les items du menu
+ $items = '';
+ // Nom de la page courante
+ $currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2);
+ // Nom de la page parente
+ $currentParentPageId = $this->getData(['page',$currentPageId,'parentPageId']);
+ // Détermine si on affiche uniquement le parent et les enfants
+ // Filtre contient le nom de la page parente
+
+ if ($onlyChildren === true) {
+ if (empty($currentParentPageId)) {
+ $filterCurrentPageId = $currentPageId;
+ } else {
+ $filterCurrentPageId = $currentParentPageId;
+ }
+ } else {
+ $items .= '
';
+ }
+
+ foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
+ // Ne pas afficher les entrées masquées
+ if ($this->getData(['page',$parentPageId,'hideMenuSide']) === true ) {
+ continue;
+ }
+ // Filtre actif et nom de la page parente courante différente, on sort de la boucle
+ if ($onlyChildren === true && $parentPageId !== $filterCurrentPageId) {
+ continue;
+ }
+ // Propriétés de l'item
+ $active = ($parentPageId === $currentPageId OR in_array($currentPageId, $childrenPageIds)) ? ' class="active"' : '';
+ $targetBlank = $this->getData(['page', $parentPageId, 'targetBlank']) ? ' target="_blank" ' : '';
+ // Mise en page de l'item;
+ // Ne pas afficher le parent d'une sous-page quand l'option est sélectionnée.
+ if ($onlyChildren === false) {
+ $items .= '
';
+ if(
+ // Sur un module de page qui autorise le bouton de modification de la page
+ $this->output['showBarEditButton']
+ // Sur une page sans module
+ OR $this->getData(['page', $this->getUrl(0), 'moduleId']) === ''
+ // Sur une page d'accueil
+ OR $this->getUrl(0) === ''
+ ) {
+ $leftItems .= '
';
+ // Mise à jour automatique
+ $today = mktime(0, 0, 0);
+ // Une mise à jour est disponible + recherche auto activée + 1 jour de délais
+ if ( $this->getData(['config','autoUpdate']) === true
+ AND $today > $this->getData(['core','lastAutoUpdate']) + 86400 ) {
+ if ( helper::checkNewVersion(common::ZWII_UPDATE_CHANNEL) ) {
+ $this->setData(['core','updateAvailable', true]);
+ $this->setData(['core','lastAutoUpdate',$today]);
+ }
+ }
+ // Afficher le bouton : Mise à jour détectée + activée
+ if ( $this->getData(['core','updateAvailable']) === true &&
+ $this->getData(['config','autoUpdate']) === true ) {
+ $rightItems .= '
';
+ }
}
class core extends common {
@@ -1124,6 +1916,7 @@ class core extends common {
if(empty($_SESSION['csrf'])) {
$_SESSION['csrf'] = bin2hex(openssl_random_pseudo_bytes(32));
}
+
// Fuseau horaire
self::$timezone = $this->getData(['config', 'timezone']); // Utile pour transmettre le timezone à la classe helper
date_default_timezone_set(self::$timezone);
@@ -1397,6 +2190,7 @@ class core extends common {
elseif(is_readable('core/vendor/' . $classPath)) {
require 'core/vendor/' . $classPath;
}
+
}
/**
@@ -1857,804 +2651,3 @@ class core extends common {
}
}
}
-
-class layout extends common {
-
- private $core;
-
- /**
- * Constructeur du layout
- */
- public function __construct(core $core) {
- parent::__construct();
- $this->core = $core;
- }
-
- /**
- * Affiche le script Google Analytics
- */
- public function showAnalytics() {
- if($code = $this->getData(['config', 'analyticsId'])
- AND $this->getInput('ZWII_COOKIE_CONSENT') === 'true') {
- echo '
-
- ';
- }
- }
-
- /**
- * Affiche le contenu
- * @param Page par défaut
- */
- public function showContent() {
- if ($this->getData(['config', 'i18n', 'active']) === true) {
- echo $this->showi18n('Site');
- }
- if(
- $this->core->output['title']
- AND (
- $this->getData(['page', $this->getUrl(0)]) === null
- OR $this->getData(['page', $this->getUrl(0), 'hideTitle']) === false
- OR $this->getUrl(1) === 'config'
- )
- ) {
- echo '
' . $this->core->output['title'] . '
';
- }
-
- echo $this->core->output['content'];
-
- /**
- * Affiche les crédits, conditions requis :
- * La traduction est active et le site n'est pas en français.
- * La fonction est activée.
- */
- if ( $this->getData(['config', 'i18n', 'active']) === true
- AND $this->getData(['config', 'i18n','scriptGoogle']) === true
- AND $this->getData(['config', 'i18n','showCredits']) === true
- AND
- // et la traduction n'est pas manuelle
- ( $this->getInput('ZWII_I18N_SCRIPT')
- AND $this->getData(['config', 'i18n', $this->getInput('ZWII_I18N_SCRIPT')]) === 'script'
- )
- )
- {
- echo '
';
- }
- }
-
-
-
- /**
- * Affiche le contenu de la barre gauche
- *
- */
- public function showBarContentLeft() {
- // Détermine si le menu est présent
- if ($this->getData(['page',$this->getData(['page',$this->getUrl(0),'barLeft']),'displayMenu']) === 'none') {
- // Pas de menu
- echo $this->core->output['contentLeft'];
- } else {
- // $mark contient 0 le menu est positionné à la fin du contenu
- $contentLeft = str_replace ('[]','[MENU]',$this->core->output['contentLeft']);
- $contentLeft = str_replace ('[menu]','[MENU]',$contentLeft);
- $mark = strrpos($contentLeft,'[MENU]') !== false ? strrpos($contentLeft,'[MENU]') : strlen($contentLeft);
- echo substr($contentLeft,0,$mark);
- echo '
';
- echo substr($contentLeft,$mark+6,strlen($contentLeft));
- }
- }
-
- /**
- * Affiche le contenu de la barre droite
- */
- public function showBarContentRight() {
- // Détermine si le menu est présent
- if ($this->getData(['page',$this->getData(['page',$this->getUrl(0),'barRight']),'displayMenu']) === 'none') {
- // Pas de menu
- echo $this->core->output['contentRight'];
- } else {
- // $mark contient 0 le menu est positionné à la fin du contenu
- $contentRight = str_replace ('[]','[MENU]',$this->core->output['contentRight']);
- $contentRight = str_replace ('[menu]','[MENU]',$contentRight);
- $mark = strrpos($contentRight,'[MENU]') !== false ? strrpos($contentRight,'[MENU]') : strlen($contentRight);
- echo substr($contentRight,0,$mark);
- echo '
';
- if ($this->getData(['config', 'i18n', 'active']) === true) {
- echo $this->showi18n('Nav');
- }
- }
-
- /**
- * Générer un menu pour la barre latérale
- * Uniquement texte
- * @param onlyChildren n'affiche les sous-pages de la page actuelle
- */
- public function showMenuSide($onlyChildren = null) {
- // Met en forme les items du menu
- $items = '';
- // Nom de la page courante
- $currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2);
- // Nom de la page parente
- $currentParentPageId = $this->getData(['page',$currentPageId,'parentPageId']);
- // Détermine si on affiche uniquement le parent et les enfants
- // Filtre contient le nom de la page parente
-
- if ($onlyChildren === true) {
- if (empty($currentParentPageId)) {
- $filterCurrentPageId = $currentPageId;
- } else {
- $filterCurrentPageId = $currentParentPageId;
- }
- } else {
- $items .= '
';
- }
-
- foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
- // Ne pas afficher les entrées masquées
- if ($this->getData(['page',$parentPageId,'hideMenuSide']) === true ) {
- continue;
- }
- // Filtre actif et nom de la page parente courante différente, on sort de la boucle
- if ($onlyChildren === true && $parentPageId !== $filterCurrentPageId) {
- continue;
- }
- // Propriétés de l'item
- $active = ($parentPageId === $currentPageId OR in_array($currentPageId, $childrenPageIds)) ? ' class="active"' : '';
- $targetBlank = $this->getData(['page', $parentPageId, 'targetBlank']) ? ' target="_blank" ' : '';
- // Mise en page de l'item;
- // Ne pas afficher le parent d'une sous-page quand l'option est sélectionnée.
- if ($onlyChildren === false) {
- $items .= '
';
- if(
- // Sur un module de page qui autorise le bouton de modification de la page
- $this->core->output['showBarEditButton']
- // Sur une page sans module
- OR $this->getData(['page', $this->getUrl(0), 'moduleId']) === ''
- // Sur une page d'accueil
- OR $this->getUrl(0) === ''
- ) {
- $leftItems .= '
';
- // Mise à jour automatique
- $today = mktime(0, 0, 0);
- // Une mise à jour est disponible + recherche auto activée + 1 jour de délais
- if ( $this->getData(['config','autoUpdate']) === true
- AND $today > $this->getData(['core','lastAutoUpdate']) + 86400 ) {
- if ( helper::checkNewVersion(common::ZWII_UPDATE_CHANNEL) ) {
- $this->setData(['core','updateAvailable', true]);
- $this->setData(['core','lastAutoUpdate',$today]);
- }
- }
- // Afficher le bouton : Mise à jour détectée + activée
- if ( $this->getData(['core','updateAvailable']) === true &&
- $this->getData(['config','autoUpdate']) === true ) {
- $rightItems .= '