From 81c4a5cfb384c168ebb3c0916527b6093ef85e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Tue, 4 Oct 2022 14:06:52 +0200 Subject: [PATCH] =?UTF-8?q?phpmailer=20num=C3=A9ro=20de=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 2034 +++++++++++++++++++++++++------------------------ 1 file changed, 1057 insertions(+), 977 deletions(-) diff --git a/core/core.php b/core/core.php index 47be7251..89dff6fb 100644 --- a/core/core.php +++ b/core/core.php @@ -13,7 +13,8 @@ * @link http://zwiicms.fr/ */ -class common { +class common +{ const DISPLAY_RAW = 0; const DISPLAY_JSON = 1; @@ -45,7 +46,7 @@ class common { // Numéro de version const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; - const ZWII_VERSION = '11.5.07'; + const ZWII_VERSION = '11.5.08'; const ZWII_UPDATE_CHANNEL = "v11"; public static $actions = []; @@ -189,7 +190,7 @@ class common { 'font-family' => 'Arial, Helvetica, sans-serif', 'resource' => 'websafe' ], - 'arvo'=> [ + 'arvo' => [ 'name' => 'Arvo', 'font-family' => 'Arvo, sans-serif', 'resource' => 'websafe' @@ -214,7 +215,7 @@ class common { 'font-family' => 'Impact, Charcoal, sans-serif', 'resource' => 'websafe' ], - 'lora'=> [ + 'lora' => [ 'name' => 'Lora', 'font-family' => 'Lora, serif', 'resource' => 'websafe' @@ -224,7 +225,7 @@ class common { 'font-family' => '\'Lucida Sans Unicode\', \'Lucida Grande\', sans-serif', 'resource' => 'websafe' ], - 'roboto'=> [ + 'roboto' => [ 'name' => 'Roboto', 'font-family' => 'Roboto, sans-serif', 'resource' => 'websafe' @@ -260,23 +261,22 @@ class common { /** * Constructeur commun */ - public function __construct() { + public function __construct() + { // Extraction des données http - if(isset($_POST)) { + if (isset($_POST)) { $this->input['_POST'] = $_POST; } - if(isset($_COOKIE)) { + if (isset($_COOKIE)) { $this->input['_COOKIE'] = $_COOKIE; } // Déterminer la langue sélectionnée pour le chargement des fichiers de données - if (isset($this->input['_COOKIE']['ZWII_I18N_SITE']) - ) { + if (isset($this->input['_COOKIE']['ZWII_I18N_SITE'])) { self::$i18n = $this->input['_COOKIE']['ZWII_I18N_SITE']; - setlocale (LC_TIME, self::$i18n . '_' . strtoupper (self::$i18n) ); - - } else { + setlocale(LC_TIME, self::$i18n . '_' . strtoupper(self::$i18n)); + } else { self::$i18n = 'fr'; } @@ -286,37 +286,40 @@ class common { // Constructeur JsonDB $this->dataFiles[$keys] = new \Prowebcraft\JsonDb([ 'name' => $keys . '.json', - 'dir' => $this->dataPath ($keys, self::$i18n), + 'dir' => $this->dataPath($keys, self::$i18n), 'backup' => file_exists('site/data/.backup') ]);; } // Import version 9 - if (file_exists(self::DATA_DIR . 'core.json') === true && - $this->getData(['core','dataVersion']) < 10000) { + if ( + file_exists(self::DATA_DIR . 'core.json') === true && + $this->getData(['core', 'dataVersion']) < 10000 + ) { $keepUsers = isset($_SESSION['KEEP_USERS']) ? $_SESSION['KEEP_USERS'] : false; $this->importData($keepUsers); - unset ($_SESSION['KEEP_USERS']); + unset($_SESSION['KEEP_USERS']); // Réinstaller htaccess copy('core/module/install/ressource/.htaccess', self::DATA_DIR . '.htaccess'); - common::$importNotices [] = "Importation réalisée avec succès" ; + common::$importNotices[] = "Importation réalisée avec succès"; //echo ''; } // Installation fraîche, initialisation des modules manquants // La langue d'installation par défaut est fr foreach ($this->dataFiles as $stageId => $item) { - $folder = $this->dataPath ($stageId, self::$i18n); - if ( file_exists($folder . $stageId .'.json') === false || - $this->getData([$stageId]) === NULL - ) { + $folder = $this->dataPath($stageId, self::$i18n); + if ( + file_exists($folder . $stageId . '.json') === false || + $this->getData([$stageId]) === NULL + ) { $this->initData($stageId, self::$i18n); - common::$coreNotices [] = $stageId ; + common::$coreNotices[] = $stageId; } } // Utilisateur connecté - if($this->user === []) { + if ($this->user === []) { $this->user = $this->getData(['user', $this->getInput('ZWII_USER_ID')]); } @@ -329,75 +332,72 @@ class common { * - L'auto-détection est active */ - if ( $this->getData(['config', 'i18n', 'enable']) === true - AND $this->getData(['config', 'i18n','scriptGoogle']) === true - AND $this->getData(['config', 'i18n','autoDetect']) === true - AND $this->getInput('ZWII_I18N_SITE') !== '' - AND !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) - { + if ( + $this->getData(['config', 'i18n', 'enable']) === true + and $this->getData(['config', 'i18n', 'scriptGoogle']) === true + and $this->getData(['config', 'i18n', 'autoDetect']) === true + and $this->getInput('ZWII_I18N_SITE') !== '' + and !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) + ) { /** * Le cookie est prioritaire sur le navigateur * la traduction est celle de la langue du drapeau * */ - if ( $this->getInput('ZWII_I18N_SCRIPT') !== substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2 ) ) { - setrawcookie('googtrans', '/fr/'.substr( $_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2 ), time() + 3600, helper::baseUrl(false, false)); + if ($this->getInput('ZWII_I18N_SCRIPT') !== substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2)) { + setrawcookie('googtrans', '/fr/' . substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2), time() + 3600, helper::baseUrl(false, false)); } else { // Langue du drapeau si elle est définie - if ( $this->getInput('ZWII_I18N_SCRIPT') !== '' ) { + if ($this->getInput('ZWII_I18N_SCRIPT') !== '') { // Paramètre du script - setrawcookie("googtrans", '/fr/'. $this->getInput('ZWII_I18N_SCRIPT') , time() + 3600, helper::baseUrl(false,false)); + setrawcookie("googtrans", '/fr/' . $this->getInput('ZWII_I18N_SCRIPT'), time() + 3600, helper::baseUrl(false, false)); } } } // Construit la liste des pages parents/enfants - if($this->hierarchy['all'] === []) { + if ($this->hierarchy['all'] === []) { $pages = helper::arrayCollumn($this->getData(['page']), 'position', 'SORT_ASC'); // Parents - foreach($pages as $pageId => $pagePosition) { - if( + foreach ($pages as $pageId => $pagePosition) { + if ( // Page parent $this->getData(['page', $pageId, 'parentPageId']) === "" // Ignore les pages dont l'utilisateur n'a pas accès - AND ( - $this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR - OR ( - $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') - AND $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) + and ($this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR + or ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') + and $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) ) ) ) { - if($pagePosition !== 0) { + if ($pagePosition !== 0) { $this->hierarchy['visible'][$pageId] = []; } - if($this->getData(['page', $pageId, 'block']) === 'bar') { + if ($this->getData(['page', $pageId, 'block']) === 'bar') { $this->hierarchy['bar'][$pageId] = []; } $this->hierarchy['all'][$pageId] = []; } } // Enfants - foreach($pages as $pageId => $pagePosition) { - if( + foreach ($pages as $pageId => $pagePosition) { + if ( // Page parent $parentId = $this->getData(['page', $pageId, 'parentPageId']) // Ignore les pages dont l'utilisateur n'a pas accès - AND ( - ( - $this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR - AND $this->getData(['page', $parentId, 'group']) === self::GROUP_VISITOR + and ( + ($this->getData(['page', $pageId, 'group']) === self::GROUP_VISITOR + and $this->getData(['page', $parentId, 'group']) === self::GROUP_VISITOR ) - OR ( - $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') - AND $this->getUser('group') >= $this->getData(['page', $parentId, 'group']) - AND $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) + or ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') + and $this->getUser('group') >= $this->getData(['page', $parentId, 'group']) + and $this->getUser('group') >= $this->getData(['page', $pageId, 'group']) ) ) ) { - if($pagePosition !== 0) { + if ($pagePosition !== 0) { $this->hierarchy['visible'][$parentId][] = $pageId; } - if($this->getData(['page', $pageId, 'block']) === 'bar') { + if ($this->getData(['page', $pageId, 'block']) === 'bar') { $this->hierarchy['bar'][$pageId] = []; } $this->hierarchy['all'][$parentId][] = $pageId; @@ -405,22 +405,23 @@ class common { } } // Construit l'url - if($this->url === '') { - if($url = $_SERVER['QUERY_STRING']) { + if ($this->url === '') { + if ($url = $_SERVER['QUERY_STRING']) { $this->url = $url; - } - else { + } else { $this->url = $this->getData(['locale', 'homePageId']); } } // Mise à jour des données core - if( $this->getData(['core', 'dataVersion']) !== intval(str_replace('.','',self::ZWII_VERSION))) include( 'core/include/update.inc.php'); + if ($this->getData(['core', 'dataVersion']) !== intval(str_replace('.', '', self::ZWII_VERSION))) include('core/include/update.inc.php'); // Données de proxy - $proxy = $this->getData(['config','proxyType']) . $this->getData(['config','proxyUrl']) . ':' . $this->getData(['config','proxyPort']); - if (!empty($this->getData(['config','proxyUrl'])) && - !empty($this->getData(['config','proxyPort'])) ) { + $proxy = $this->getData(['config', 'proxyType']) . $this->getData(['config', 'proxyUrl']) . ':' . $this->getData(['config', 'proxyPort']); + if ( + !empty($this->getData(['config', 'proxyUrl'])) && + !empty($this->getData(['config', 'proxyPort'])) + ) { $context = array( 'http' => array( 'proxy' => $proxy, @@ -428,21 +429,21 @@ class common { 'verify_peer' => false, 'verify_peer_name' => false, ), - "ssl"=>array( - "verify_peer"=>false, - "verify_peer_name"=>false + "ssl" => array( + "verify_peer" => false, + "verify_peer_name" => false ) ); stream_context_set_default($context); } - } /** * Ajoute les valeurs en sortie * @param array $output Valeurs en sortie */ - public function addOutput($output) { + public function addOutput($output) + { $this->output = array_merge($this->output, $output); } @@ -450,17 +451,18 @@ class common { * Ajoute une notice de champ obligatoire * @param string $key Clef du champ */ - public function addRequiredInputNotices($key) { + public function addRequiredInputNotices($key) + { // La clef est un tableau - if(preg_match('#\[(.*)\]#', $key, $secondKey)) { + if (preg_match('#\[(.*)\]#', $key, $secondKey)) { $firstKey = explode('[', $key)[0]; $secondKey = $secondKey[1]; - if(empty($this->input['_POST'][$firstKey][$secondKey])) { + if (empty($this->input['_POST'][$firstKey][$secondKey])) { common::$inputNotices[$firstKey . '_' . $secondKey] = 'Obligatoire'; } } // La clef est une chaine - elseif(empty($this->input['_POST'][$key])) { + elseif (empty($this->input['_POST'][$key])) { common::$inputNotices[$key] = 'Obligatoire'; } } @@ -468,39 +470,41 @@ class common { /** * Check du token CSRF (true = bo */ - public function checkCSRF() { - return ((empty($_POST['csrf']) OR hash_equals($_SESSION['csrf'], $_POST['csrf']) === false) === false); + public function checkCSRF() + { + return ((empty($_POST['csrf']) or hash_equals($_SESSION['csrf'], $_POST['csrf']) === false) === false); } /** * Supprime des données * @param array $keys Clé(s) des données */ - public function deleteData($keys) { + public function deleteData($keys) + { // Descripteur $db = $this->dataFiles[$keys[0]]; // Aiguillage - switch(count($keys)) { + switch (count($keys)) { case 1: $db->delete($keys[0], true); break; case 2: - $db->delete($keys[0].'.'.$keys[1],true); + $db->delete($keys[0] . '.' . $keys[1], true); break; case 3: - $db->delete($keys[0].'.'.$keys[1].'.'.$keys[2], true); + $db->delete($keys[0] . '.' . $keys[1] . '.' . $keys[2], true); break; case 4: - $db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3], true); + $db->delete($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3], true); break; case 5: - $db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4], true); + $db->delete($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4], true); break; case 6: - $db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5], true); + $db->delete($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4] . '.' . $keys[5], true); break; case 7: - $db->delete($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5].'.'.$keys[6], true); + $db->delete($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4] . '.' . $keys[5] . '.' . $keys[6], true); break; } } @@ -510,37 +514,38 @@ class common { * @param array $keys Clé(s) des données * @return mixed */ - public function getData($keys = []) { + public function getData($keys = []) + { if (count($keys) >= 1) { /** * Lecture directe - */ + */ $db = $this->dataFiles[$keys[0]]; - switch(count($keys)) { + switch (count($keys)) { case 1: $tempData = $db->get($keys[0]); break; case 2: - $tempData = $db->get($keys[0].'.'.$keys[1]); + $tempData = $db->get($keys[0] . '.' . $keys[1]); break; case 3: - $tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2]); + $tempData = $db->get($keys[0] . '.' . $keys[1] . '.' . $keys[2]); break; case 4: - $tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3]); + $tempData = $db->get($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3]); break; case 5: - $tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4]); + $tempData = $db->get($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4]); break; case 6: - $tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5]); + $tempData = $db->get($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4] . '.' . $keys[5]); break; case 7: - $tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5].'.'.$keys[6]); + $tempData = $db->get($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4] . '.' . $keys[5] . '.' . $keys[6]); break; case 8: - $tempData = $db->get($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5].'.'.$keys[6].'.'.$keys[7]); + $tempData = $db->get($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4] . '.' . $keys[5] . '.' . $keys[6] . '.' . $keys[7]); break; } return $tempData; @@ -553,18 +558,18 @@ class common { * @param string langue * @param return contenu de la page */ - public function getPage($page, $lang) { + public function getPage($page, $lang) + { // Le nom de la ressource et le fichier de contenu sont définis : if ( - $this->getData(['page', $page, 'content']) !== '' - && file_exists(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])) - ) { - return file_get_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])); - } else { - return 'Aucun contenu trouvé.'; + $this->getData(['page', $page, 'content']) !== '' + && file_exists(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])) + ) { + return file_get_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])); + } else { + return 'Aucun contenu trouvé.'; } - } /** @@ -573,10 +578,10 @@ class common { * @param string contenu de la page * @param return nombre d'octets écrits ou erreur */ - public function setPage($page, $value, $lang) { + public function setPage($page, $value, $lang) + { return file_put_contents(self::DATA_DIR . $lang . '/content/' . $page . '.html', $value); - } /** @@ -584,52 +589,55 @@ class common { * @param string pageId * @param return statut de l'effacement */ - public function deletePage($page, $lang) { + public function deletePage($page, $lang) + { - return unlink(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])); - - } + return unlink(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content'])); + } /** * Sauvegarde des données * @param array $keys Clé(s) des données */ - public function setData($keys = []) { + public function setData($keys = []) + { // Pas d'enregistrement lorsqu'une notice est présente ou tableau transmis vide - if (!empty(self::$inputNotices) - OR empty($keys)) { + if ( + !empty(self::$inputNotices) + or empty($keys) + ) { return false; } // Empêcher la sauvegarde d'une donnée nulle. - if (gettype($keys[count($keys) -1]) === NULL) { + if (gettype($keys[count($keys) - 1]) === NULL) { return false; } // Descripteur $db = $this->dataFiles[$keys[0]]; // Aiguillage - switch(count($keys)) { + switch (count($keys)) { case 2: - $db->set($keys[0],$keys[1], true); + $db->set($keys[0], $keys[1], true); break; case 3: - $db->set($keys[0].'.'.$keys[1],$keys[2], true); + $db->set($keys[0] . '.' . $keys[1], $keys[2], true); break; case 4: - $db->set($keys[0].'.'.$keys[1].'.'.$keys[2],$keys[3], true); + $db->set($keys[0] . '.' . $keys[1] . '.' . $keys[2], $keys[3], true); break; case 5: - $db->set($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3],$keys[4], true); + $db->set($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3], $keys[4], true); break; case 6: - $db->set($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4],$keys[5], true); + $db->set($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4], $keys[5], true); break; case 7: - $db->set($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5],$keys[6], true); + $db->set($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4] . '.' . $keys[5], $keys[6], true); break; case 8: - $db->set($keys[0].'.'.$keys[1].'.'.$keys[2].'.'.$keys[3].'.'.$keys[4].'.'.$keys[5].'.'.$keys[6],$keys[7], true ); + $db->set($keys[0] . '.' . $keys[1] . '.' . $keys[2] . '.' . $keys[3] . '.' . $keys[4] . '.' . $keys[5] . '.' . $keys[6], $keys[7], true); break; } return true; @@ -640,20 +648,21 @@ class common { * @param array $module : nom du module à générer * choix valides : core config user theme page module */ - public function initData($module, $lang = 'fr', $sampleSite = false) { + public function initData($module, $lang = 'fr', $sampleSite = false) + { // Tableau avec les données vierges require_once('core/module/install/ressource/defaultdata.php'); // Stockage dans un sous-dossier localisé if (!file_exists(self::DATA_DIR . $lang)) { - mkdir (self::DATA_DIR .$lang, 0755); + mkdir(self::DATA_DIR . $lang, 0755); } $db = $this->dataFiles[$module]; if ($sampleSite === true) { - $db->set($module,init::$siteData[$module]); + $db->set($module, init::$siteData[$module]); } else { - $db->set($module,init::$defaultData[$module]); + $db->set($module, init::$defaultData[$module]); } $db->save; @@ -662,12 +671,12 @@ class common { mkdir(self::DATA_DIR . $lang . '/content', 0755); } // Créer le jeu de pages du site de test - if ($module === 'page' ) { + if ($module === 'page') { // Site de test ou page simple if ($sampleSite === true) { - foreach(init::$siteContent as $key => $value) { + foreach (init::$siteContent as $key => $value) { // Creation du contenu de la page - if (!empty($this->getData(['page', $key, 'content'])) ) { + if (!empty($this->getData(['page', $key, 'content']))) { file_put_contents(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $key, 'content']), $value); } } @@ -682,7 +691,8 @@ class common { * Dummy function * Compatibilité des modules avec v8 et v9 */ - public function saveData() { + public function saveData() + { return; } @@ -693,15 +703,15 @@ class common { * @param bool $onlyBlock Affiche seulement les pages de type barre * @return array */ - public function getHierarchy($parentId = null, $onlyVisible = true, $onlyBlock = false) { + public function getHierarchy($parentId = null, $onlyVisible = true, $onlyBlock = false) + { $hierarchy = $onlyVisible ? $this->hierarchy['visible'] : $this->hierarchy['all']; $hierarchy = $onlyBlock ? $this->hierarchy['bar'] : $hierarchy; // Enfants d'un parent - if($parentId) { - if(array_key_exists($parentId, $hierarchy)) { + if ($parentId) { + if (array_key_exists($parentId, $hierarchy)) { return $hierarchy[$parentId]; - } - else { + } else { return []; } } @@ -718,24 +728,25 @@ class common { * @param bool $required Champ requis * @return mixed */ - public function getInput($key, $filter = helper::FILTER_STRING_SHORT, $required = false) { + public function getInput($key, $filter = helper::FILTER_STRING_SHORT, $required = false) + { // La clef est un tableau - if(preg_match('#\[(.*)\]#', $key, $secondKey)) { + if (preg_match('#\[(.*)\]#', $key, $secondKey)) { $firstKey = explode('[', $key)[0]; $secondKey = $secondKey[1]; - foreach($this->input as $type => $values) { + foreach ($this->input as $type => $values) { // Champ obligatoire - if($required) { + if ($required) { $this->addRequiredInputNotices($key); } // Check de l'existence // Également utile pour les checkbox qui ne retournent rien lorsqu'elles ne sont pas cochées - if( + if ( array_key_exists($firstKey, $values) - AND array_key_exists($secondKey, $values[$firstKey]) + and array_key_exists($secondKey, $values[$firstKey]) ) { // Retourne la valeur filtrée - if($filter) { + if ($filter) { return helper::filter($this->input[$type][$firstKey][$secondKey], $filter); } // Retourne la valeur @@ -747,16 +758,16 @@ class common { } // La clef est une chaîne else { - foreach($this->input as $type => $values) { + foreach ($this->input as $type => $values) { // Champ obligatoire - if($required) { + if ($required) { $this->addRequiredInputNotices($key); } // Check de l'existence // Également utile pour les checkbox qui ne retournent rien lorsqu'elles ne sont pas cochées - if(array_key_exists($key, $values)) { + if (array_key_exists($key, $values)) { // Retourne la valeur filtrée - if($filter) { + if ($filter) { return helper::filter($this->input[$type][$key], $filter); } // Retourne la valeur @@ -775,9 +786,10 @@ class common { * @param int $key Clé de l'url * @return string|null */ - public function getUrl($key = null) { + public function getUrl($key = null) + { // Url complète - if($key === null) { + if ($key === null) { return $this->url; } // Une partie de l'url @@ -792,17 +804,15 @@ class common { * @param int $key Clé de la valeur * @return string|null */ - public function getUser($key) { - if(is_array($this->user) === false) { + public function getUser($key) + { + if (is_array($this->user) === false) { return false; - } - elseif($key === 'id') { + } elseif ($key === 'id') { return $this->getInput('ZWII_USER_ID'); - } - elseif(array_key_exists($key, $this->user)) { + } elseif (array_key_exists($key, $this->user)) { return $this->user[$key]; - } - else { + } else { return false; } } @@ -811,27 +821,28 @@ class common { * Check qu'une valeur est transmise par la méthode _POST * @return bool */ - public function isPost() { - return ($this->checkCSRF() AND $this->input['_POST'] !== []); + public function isPost() + { + return ($this->checkCSRF() and $this->input['_POST'] !== []); } /** * Import des données de la version 9 * Convertit un fichier de données data.json puis le renomme */ - public function importData($keepUsers = false) { + public function importData($keepUsers = false) + { // Trois tentatives de lecture - for($i = 0; $i < 3; $i++) { - $tempData=json_decode(file_get_contents(self::DATA_DIR.'core.json'), true); - $tempTheme=json_decode(file_get_contents(self::DATA_DIR.'theme.json'), true); - if($tempData && $tempTheme) { + for ($i = 0; $i < 3; $i++) { + $tempData = json_decode(file_get_contents(self::DATA_DIR . 'core.json'), true); + $tempTheme = json_decode(file_get_contents(self::DATA_DIR . 'theme.json'), true); + if ($tempData && $tempTheme) { // Backup - rename (self::DATA_DIR.'core.json',self::DATA_DIR.'imported_core.json'); - rename (self::DATA_DIR.'theme.json',self::DATA_DIR.'imported_theme.json'); + rename(self::DATA_DIR . 'core.json', self::DATA_DIR . 'imported_core.json'); + rename(self::DATA_DIR . 'theme.json', self::DATA_DIR . 'imported_theme.json'); break; - } - elseif($i === 2) { - throw new \ErrorException('Import des données impossible.'); + } elseif ($i === 2) { + throw new \ErrorException('Import des données impossible.'); } // Pause de 10 millisecondes usleep(10000); @@ -839,85 +850,95 @@ class common { // Dossier de langues if (!file_exists(self::DATA_DIR . '/fr')) { - mkdir (self::DATA_DIR . '/fr', 0755); + mkdir(self::DATA_DIR . '/fr', 0755); } // Un seul fichier pour éviter les erreurs de sauvegarde des v9 - $tempData = array_merge($tempData,$tempTheme); + $tempData = array_merge($tempData, $tempTheme); // Ecriture des données - $this->setData(['config',$tempData['config']]); - $this->setData(['core',$tempData['core']]); - $this->setData(['page',$tempData['page']]); - $this->setData(['module',$tempData['module']]); - $this->setData(['theme',$tempData['theme']]); + $this->setData(['config', $tempData['config']]); + $this->setData(['core', $tempData['core']]); + $this->setData(['page', $tempData['page']]); + $this->setData(['module', $tempData['module']]); + $this->setData(['theme', $tempData['theme']]); // Import des users sauvegardés si option active - if ($keepUsers === false - AND $tempData['user'] !== NULL) { - $this->setData(['user',$tempData['user']]); + if ( + $keepUsers === false + and $tempData['user'] !== NULL + ) { + $this->setData(['user', $tempData['user']]); } // Nettoyage du fichier de thème pour forcer une régénération if (file_exists(self::DATA_DIR . '/theme.css')) { // On ne sait jamais - unlink (self::DATA_DIR . '/theme.css'); + unlink(self::DATA_DIR . '/theme.css'); } } /** * Génère la liste des pages pour le plugin Link de TinyMCE - */ - public function listPages() { - // Sauve la liste des pages pour TinyMCE + */ + public function listPages() + { + // Sauve la liste des pages pour TinyMCE $parents = []; - $rewrite = (helper::checkRewrite()) ? '' : '?'; - // Boucle de recherche des pages actives - foreach($this->getHierarchy(null,false,false) as $parentId => $childIds) { + $rewrite = (helper::checkRewrite()) ? '' : '?'; + // Boucle de recherche des pages actives + foreach ($this->getHierarchy(null, false, false) as $parentId => $childIds) { $children = []; // Exclure les barres - if ($this->getData(['page', $parentId, 'block']) !== 'bar' ) { + if ($this->getData(['page', $parentId, 'block']) !== 'bar') { // Boucler sur les enfants et récupérer le tableau children avec la liste des enfants - foreach($childIds as $childId) { - $children [] = [ 'title' => ' » '. html_entity_decode($this->getData(['page', $childId, 'shortTitle']), ENT_QUOTES) , - 'value'=> $rewrite.$childId + foreach ($childIds as $childId) { + $children[] = [ + 'title' => ' » ' . html_entity_decode($this->getData(['page', $childId, 'shortTitle']), ENT_QUOTES), + 'value' => $rewrite . $childId ]; } // Traitement if (empty($childIds)) { // Pas d'enfant, uniquement l'entrée du parent - $parents [] = ['title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES) , - 'value'=> $rewrite.$parentId + $parents[] = [ + 'title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES), + 'value' => $rewrite . $parentId ]; } else { // Des enfants, on ajoute la page parent en premier - array_unshift ($children , ['title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES) , - 'value'=> $rewrite.$parentId + array_unshift($children, [ + 'title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES), + 'value' => $rewrite . $parentId ]); // puis on ajoute les enfants au parent - $parents [] = ['title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES) , - 'value'=> $rewrite.$parentId , - 'menu' => $children + $parents[] = [ + 'title' => html_entity_decode($this->getData(['page', $parentId, 'shortTitle']), ENT_QUOTES), + 'value' => $rewrite . $parentId, + 'menu' => $children ]; } } } - // Sitemap et Search - $children = []; - $children [] = ['title'=>'Rechercher dans le site', - 'value'=>$rewrite.'search' - ]; - $children [] = ['title'=>'Plan du site', - 'value'=>$rewrite.'sitemap' - ]; - $parents [] = ['title' => 'Pages spéciales', - 'value' => '#', - 'menu' => $children - ]; + // Sitemap et Search + $children = []; + $children[] = [ + 'title' => 'Rechercher dans le site', + 'value' => $rewrite . 'search' + ]; + $children[] = [ + 'title' => 'Plan du site', + 'value' => $rewrite . 'sitemap' + ]; + $parents[] = [ + 'title' => 'Pages spéciales', + 'value' => '#', + 'menu' => $children + ]; // Enregistrement : 3 tentatives - for($i = 0; $i < 3; $i++) { - if (file_put_contents ('core/vendor/tinymce/link_list.json', json_encode($parents), LOCK_EX) !== false) { + for ($i = 0; $i < 3; $i++) { + if (file_put_contents('core/vendor/tinymce/link_list.json', json_encode($parents), LOCK_EX) !== false) { break; } // Pause de 10 millisecondes @@ -931,12 +952,15 @@ class common { * @param $lang langue des pages * @return string du dossier à créer */ - public function dataPath($id, $lang) { + public function dataPath($id, $lang) + { // Sauf pour les pages et les modules - if ($id === 'page' || + if ( + $id === 'page' || $id === 'module' || - $id === 'locale' ) { - $folder = self::DATA_DIR . $lang . '/' ; + $id === 'locale' + ) { + $folder = self::DATA_DIR . $lang . '/'; } else { $folder = self::DATA_DIR; } @@ -950,13 +974,14 @@ class common { * $command valeurs possible * all : génère un site map complet * Sinon contient id de la page à créer - */ + */ - public function createSitemap($command = "all") { + public function createSitemap($command = "all") + { - $timezone = $this->getData(['config','timezone']); + $timezone = $this->getData(['config', 'timezone']); $outputDir = getcwd(); - $sitemap = new \Icamys\SitemapGenerator\SitemapGenerator(helper::baseurl(false),$outputDir); + $sitemap = new \Icamys\SitemapGenerator\SitemapGenerator(helper::baseurl(false), $outputDir); // will create also compressed (gzipped) sitemap : option buguée // $sitemap->enableCompression(); @@ -966,58 +991,63 @@ class common { $sitemap->setMaxUrlsPerSitemap(50000); // sitemap file name - $sitemap->setSitemapFileName( 'sitemap.xml') ; + $sitemap->setSitemapFileName('sitemap.xml'); // Set the sitemap index file name - $sitemap->setSitemapIndexFileName( 'sitemap-index.xml'); + $sitemap->setSitemapIndexFileName('sitemap-index.xml'); $datetime = new DateTime(date('c')); $datetime->format(DateTime::ATOM); // Updated ISO8601 - foreach($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { + foreach ($this->getHierarchy(null, null, null) as $parentPageId => $childrenPageIds) { // Exclure les barres et les pages non publiques et les pages masquées - if ($this->getData(['page',$parentPageId,'group']) !== 0 || - $this->getData(['page', $parentPageId, 'block']) === 'bar' ) { + if ( + $this->getData(['page', $parentPageId, 'group']) !== 0 || + $this->getData(['page', $parentPageId, 'block']) === 'bar' + ) { continue; } // Page désactivée, traiter les sous-pages sans prendre en compte la page parente. - if ($this->getData(['page', $parentPageId, 'disable']) !== true ) { + if ($this->getData(['page', $parentPageId, 'disable']) !== true) { // Cas de la page d'accueil ne pas dupliquer l'URL $pageId = ($parentPageId !== $this->getData(['locale', 'homePageId'])) ? $parentPageId : ''; - $sitemap->addUrl ('/' . $pageId, $datetime); + $sitemap->addUrl('/' . $pageId, $datetime); } // Articles du blog - if ($this->getData(['page', $parentPageId, 'moduleId']) === 'blog' && - !empty($this->getData(['module',$parentPageId])) ) { - foreach($this->getData(['module',$parentPageId,'posts']) as $articleId => $article) { - if($this->getData(['module',$parentPageId,'posts',$articleId,'state']) === true) { - $date = $this->getData(['module',$parentPageId,'posts',$articleId,'publishedOn']); - $sitemap->addUrl('/' . $parentPageId . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone))); + if ( + $this->getData(['page', $parentPageId, 'moduleId']) === 'blog' && + !empty($this->getData(['module', $parentPageId])) + ) { + foreach ($this->getData(['module', $parentPageId, 'posts']) as $articleId => $article) { + if ($this->getData(['module', $parentPageId, 'posts', $articleId, 'state']) === true) { + $date = $this->getData(['module', $parentPageId, 'posts', $articleId, 'publishedOn']); + $sitemap->addUrl('/' . $parentPageId . '/' . $articleId, new DateTime("@{$date}", new DateTimeZone($timezone))); } } } // Sous-pages - foreach($childrenPageIds as $childKey) { - if ($this->getData(['page',$childKey,'group']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) { + foreach ($childrenPageIds as $childKey) { + if ($this->getData(['page', $childKey, 'group']) !== 0 || $this->getData(['page', $childKey, 'disable']) === true) { continue; } // Cas de la page d'accueil ne pas dupliquer l'URL $pageId = ($childKey !== $this->getData(['locale', 'homePageId'])) ? $childKey : ''; - $sitemap->addUrl('/' . $childKey,$datetime); + $sitemap->addUrl('/' . $childKey, $datetime); // La sous-page est un blog - if ($this->getData(['page', $childKey, 'moduleId']) === 'blog' && - !empty($this->getData(['module',$childKey])) ) { - foreach($this->getData(['module',$childKey,'posts']) as $articleId => $article) { - if($this->getData(['module',$childKey,'posts',$articleId,'state']) === true) { - $date = $this->getData(['module',$childKey,'posts',$articleId,'publishedOn']); - $sitemap->addUrl( '/' . $childKey . '/' . $articleId , new DateTime("@{$date}",new DateTimeZone($timezone))); + if ( + $this->getData(['page', $childKey, 'moduleId']) === 'blog' && + !empty($this->getData(['module', $childKey])) + ) { + foreach ($this->getData(['module', $childKey, 'posts']) as $articleId => $article) { + if ($this->getData(['module', $childKey, 'posts', $articleId, 'state']) === true) { + $date = $this->getData(['module', $childKey, 'posts', $articleId, 'publishedOn']); + $sitemap->addUrl('/' . $childKey . '/' . $articleId, new DateTime("@{$date}", new DateTimeZone($timezone))); } } } } - } // Flush all stored urls from memory to the disk and close all necessary tags. @@ -1028,20 +1058,19 @@ class common { // Update robots.txt file in output directory - if ($this->getData(['config','seo', 'robots']) === true) { + if ($this->getData(['config', 'seo', 'robots']) === true) { unlink('robots.txt'); $sitemap->updateRobots(); } else { - file_put_contents('robots.txt','User-agent: *' . PHP_EOL . 'Disallow: /'); + file_put_contents('robots.txt', 'User-agent: *' . PHP_EOL . 'Disallow: /'); } // Submit your sitemaps to Google, Yahoo, Bing and Ask.com - if (empty ($this->getData(['config','proxyType']) . $this->getData(['config','proxyUrl']) . ':' . $this->getData(['config','proxyPort'])) ) { + if (empty($this->getData(['config', 'proxyType']) . $this->getData(['config', 'proxyUrl']) . ':' . $this->getData(['config', 'proxyPort']))) { $sitemap->submitSitemap(); } - return(file_exists('sitemap.xml') && file_exists('robots.txt')); - + return (file_exists('sitemap.xml') && file_exists('robots.txt')); } /* @@ -1051,7 +1080,8 @@ class common { * @param string $dets image destination * @param integer $desired_width largeur demandée */ - function makeThumb($src, $dest, $desired_width) { + function makeThumb($src, $dest, $desired_width) + { // Vérifier l'existence du dossier de destination. $fileInfo = pathinfo($dest); if (!is_dir($fileInfo['dirname'])) { @@ -1059,7 +1089,7 @@ class common { } $source_image = ''; // Type d'image - switch( $fileInfo['extension']) { + switch ($fileInfo['extension']) { case 'jpeg': case 'jpg': $source_image = imagecreatefromjpeg($src); @@ -1083,7 +1113,7 @@ class common { $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); - switch(mime_content_type($src) ) { + switch (mime_content_type($src)) { case 'image/jpeg': case 'image/jpg': return (imagejpeg($virtual_image, $dest)); @@ -1111,7 +1141,8 @@ class common { * @param string $content Contenu * @return bool */ - public function sendMail($to, $subject, $content, $replyTo = null) { + public function sendMail($to, $subject, $content, $replyTo = null) + { // Layout ob_start(); include 'core/layout/mail.php'; @@ -1120,27 +1151,27 @@ class common { $mail->CharSet = 'UTF-8'; $mail->setLanguage('fr', 'core/class/phpmailer/phpmailer.lang-fr.php'); // Mail - try{ + try { // Paramètres SMTP - if ($this->getdata(['config','smtp','enable'])) { + if ($this->getdata(['config', 'smtp', 'enable'])) { //$mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->SMTPAutoTLS = false; - $mail->Host = $this->getdata(['config','smtp','host']); - $mail->Port = (int) $this->getdata(['config','smtp','port']); - if ($this->getData(['config','smtp','auth'])) { - $mail->Username = $this->getData(['config','smtp','username']); - $mail->Password = helper::decrypt($this->getData(['config','smtp','username']),$this->getData(['config','smtp','password'])); - $mail->SMTPAuth = $this->getData(['config','smtp','auth']); - $mail->SMTPSecure = $this->getData(['config','smtp','secure']); - $mail->setFrom($this->getData(['config','smtp','username'])); + $mail->Host = $this->getdata(['config', 'smtp', 'host']); + $mail->Port = (int) $this->getdata(['config', 'smtp', 'port']); + if ($this->getData(['config', 'smtp', 'auth'])) { + $mail->Username = $this->getData(['config', 'smtp', 'username']); + $mail->Password = helper::decrypt($this->getData(['config', 'smtp', 'username']), $this->getData(['config', 'smtp', 'password'])); + $mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']); + $mail->SMTPSecure = $this->getData(['config', 'smtp', 'secure']); + $mail->setFrom($this->getData(['config', 'smtp', 'username'])); if (is_null($replyTo)) { - $mail->addReplyTo($this->getData(['config','smtp','username'])); + $mail->addReplyTo($this->getData(['config', 'smtp', 'username'])); } else { $mail->addReplyTo($replyTo); } } - // Fin SMTP + // Fin SMTP } else { $host = str_replace('www.', '', $_SERVER['HTTP_HOST']); $mail->setFrom('no-reply@' . $host, $this->getData(['locale', 'title'])); @@ -1150,26 +1181,22 @@ class common { $mail->addReplyTo($replyTo); } } - if(is_array($to)) { - foreach($to as $userMail) { - $mail->addAddress($userMail); - } - } - else { - $mail->addAddress($to); + if (is_array($to)) { + foreach ($to as $userMail) { + $mail->addAddress($userMail); + } + } else { + $mail->addAddress($to); } $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $layout; $mail->AltBody = strip_tags($content); - if($mail->send()) { - return true; + if ($mail->send()) { + return true; + } else { + return $mail->ErrorInfo; } - else { - return $mail->ErrorInfo; - } - } catch (Exception $e) { - echo $e->errorMessage(); } catch (\Exception $e) { echo $e->getMessage(); } @@ -1178,15 +1205,16 @@ class common { /** - * Effacer un dossier non vide. - * @param string URL du dossier à supprimer - */ - public function removeDir ( $path ) { - foreach ( new DirectoryIterator($path) as $item ) { - if ( $item->isFile() ) @unlink($item->getRealPath()); - if ( !$item->isDot() && $item->isDir() ) $this->removeDir($item->getRealPath()); + * Effacer un dossier non vide. + * @param string URL du dossier à supprimer + */ + public function removeDir($path) + { + foreach (new DirectoryIterator($path) as $item) { + if ($item->isFile()) @unlink($item->getRealPath()); + if (!$item->isDot() && $item->isDir()) $this->removeDir($item->getRealPath()); } - return ( rmdir($path) ); + return (rmdir($path)); } @@ -1196,7 +1224,8 @@ class common { * @param string $dst dossier destination * @return bool */ - public function copyDir($src, $dst) { + public function copyDir($src, $dst) + { // Ouvrir le dossier source $dir = opendir($src); // Créer le dossier de destination @@ -1206,16 +1235,17 @@ class common { $success = true; // Boucler dans le dossier source en l'absence d'échec de lecture écriture - while( $success - AND $file = readdir($dir) ) { + while ( + $success + and $file = readdir($dir) + ) { - if (( $file != '.' ) && ( $file != '..' )) { - if ( is_dir($src . '/' . $file) ){ + if (($file != '.') && ($file != '..')) { + if (is_dir($src . '/' . $file)) { // Appel récursif des sous-dossiers $s = $this->copyDir($src . '/' . $file, $dst . '/' . $file); $success = $s || $success; - } - else { + } else { $s = copy($src . '/' . $file, $dst . '/' . $file); $success = $s || $success; } @@ -1231,23 +1261,24 @@ class common { * @param string folder path à zipper * @param array filter dossiers à exclure */ - public function makeZip ($fileName, $folder, $filter ) { + public function makeZip($fileName, $folder, $filter) + { $zip = new ZipArchive(); $zip->open($fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE); //$directory = 'site/'; $files = new RecursiveIteratorIterator( new RecursiveCallbackFilterIterator( - new RecursiveDirectoryIterator( - $folder, - RecursiveDirectoryIterator::SKIP_DOTS - ), - function ($fileInfo, $key, $iterator) use ($filter) { - return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); - } + new RecursiveDirectoryIterator( + $folder, + RecursiveDirectoryIterator::SKIP_DOTS + ), + function ($fileInfo, $key, $iterator) use ($filter) { + return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter); + } ) ); - foreach ($files as $name => $file) { - if (!$file->isDir()) { + foreach ($files as $name => $file) { + if (!$file->isDir()) { $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen(realpath($folder)) + 1); $zip->addFile($filePath, $relativePath); @@ -1261,28 +1292,31 @@ class common { /** * Affiche le script Google Analytics */ - public function showAnalytics() { - if( !empty($code = $this->getData(['config', 'seo', 'analyticsId'])) && - $this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true' ) { - echo ' - + public function showAnalytics() + { + if ( + !empty($code = $this->getData(['config', 'seo', 'analyticsId'])) && + $this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true' + ) { + echo ' + '; - } - } + } + } /** * Affiche le consentement aux cookies */ - public function showCookies() { + public function showCookies() + { // Gestion des cookies intégrée - if ($this->getData(['config', 'cookieConsent']) === true ) - { + if ($this->getData(['config', 'cookieConsent']) === true) { // Détermine si le bloc doit être affiché selon la validité du cookie // L'URL du serveur faut TRUE $item = '
getData(['locale', 'cookies', 'titleLabel']) . ''; + $item .= '

' . $this->getData(['locale', 'cookies', 'titleLabel']) . '

'; $item .= '

' . $this->getData(['locale', 'cookies', 'mainLabel']) . '

'; // Formulaire de réponse $item .= '
'; $analytics = $this->getData(['config', 'seo', 'analyticsId']); $stateCookieGA = $this->getInput('ZWII_COOKIE_GA_CONSENT') === 'true' ? 'checked="checked"' : ''; - if( $analytics !== null AND $analytics !== '' ) { + if ($analytics !== null and $analytics !== '') { $item .= '

' . $this->getData(['locale', 'cookies', 'gaLabel']) . '

'; $item .= ''; $item .= ''; @@ -1308,105 +1342,104 @@ class common { $item .= '
'; // mentions légales si la page est définie $legalPage = $this->getData(['locale', 'legalPageId']); - if ($legalPage !== 'none') { + if ($legalPage !== 'none') { $item .= '

' . $this->getData(['locale', 'cookies', 'linkLegalLabel']) . '

'; } $item .= '
'; echo $item; } - } /** * Formate le contenu de la page selon les gabarits * @param Page par defaut */ - public function showSection() { + public function showSection() + { echo '
'; // Récupérer la config de la page courante - $blocks = is_null($this->getData(['page',$this->getUrl(0),'block'])) ? '12' : $this->getData(['page',$this->getUrl(0),'block']); + $blocks = is_null($this->getData(['page', $this->getUrl(0), 'block'])) ? '12' : $this->getData(['page', $this->getUrl(0), 'block']); $blocks = explode('-', $blocks); // Initialiser - $blockleft=$blockright=""; + $blockleft = $blockright = ""; switch (sizeof($blocks)) { - case 1 : // une colonne - $content = 'col'. $blocks[0] ; + case 1: // une colonne + $content = 'col' . $blocks[0]; break; - case 2 : // 2 blocs + case 2: // 2 blocs if ($blocks[0] < $blocks[1]) { // détermine la position de la colonne - $blockleft = 'col'. $blocks[0]; - $content = 'col'. $blocks[1] ; + $blockleft = 'col' . $blocks[0]; + $content = 'col' . $blocks[1]; } else { $content = 'col' . $blocks[0]; $blockright = 'col' . $blocks[1]; } - break; - case 3 : // 3 blocs - $blockleft = 'col' . $blocks[0]; - $content = 'col' . $blocks[1]; - $blockright = 'col' . $blocks[2]; + break; + case 3: // 3 blocs + $blockleft = 'col' . $blocks[0]; + $content = 'col' . $blocks[1]; + $blockright = 'col' . $blocks[2]; } // Page pleine pour la configuration des modules et l'édition des pages sauf l'affichage d'un article de blog - $pattern = ['config','edit','add','comment','data']; + $pattern = ['config', 'edit', 'add', 'comment', 'data']; if ((sizeof($blocks) === 1 || - in_array($this->getUrl(1),$pattern) ) - ) { // Pleine page en mode configuration - $this->showContent(); - if (file_exists(self::DATA_DIR . 'body.inc.html')) { - include( self::DATA_DIR . 'body.inc.html'); - } + in_array($this->getUrl(1), $pattern))) { // Pleine page en mode configuration + $this->showContent(); + if (file_exists(self::DATA_DIR . 'body.inc.html')) { + include(self::DATA_DIR . 'body.inc.html'); + } } else { echo '
'; - /** - * Barre gauche - */ - if ($blockleft !== "") { - echo '
"; + /** + * Barre gauche + */ + if ($blockleft !== "") { + echo '
"; + } + /** + * Contenu de page + */ + echo '
'; + $this->showContent(); + echo '
'; + /** + * Barre droite + */ + if ($blockright !== "") { + echo '
'; + } echo '
'; } echo '
'; @@ -1416,13 +1449,13 @@ class common { * Affiche le contenu * @param Page par défaut */ - public function showContent() { - if( + public function showContent() + { + 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' + 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'] . '

'; @@ -1435,66 +1468,66 @@ class common { * La traduction est active et le site n'est pas en français. * La fonction est activée. */ - if ( $this->getData(['config', 'i18n', 'enable']) === 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 ''; + if ( + $this->getData(['config', 'i18n', 'enable']) === 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 pied de page */ - public function showFooter () { + public function showFooter() + { // Déterminer la position $positionFixed = ''; if ( $this->getData(['theme', 'footer', 'position']) === 'site' // Affiche toujours le pied de page pour l'édition du thème - OR ( - $this->getData(['theme', 'footer', 'position']) === 'hide' - AND $this->getUrl(0) === 'theme' + or ($this->getData(['theme', 'footer', 'position']) === 'hide' + and $this->getUrl(0) === 'theme' ) - ) { - $position = 'site'; - } else { - $position = 'body'; - if ( $this->getData(['theme', 'footer', 'fixed']) === true) { - $positionFixed = ' footerbodyFixed'; - } - // Sortir de la division précédente - echo ''; + ) { + $position = 'site'; + } else { + $position = 'body'; + if ($this->getData(['theme', 'footer', 'fixed']) === true) { + $positionFixed = ' footerbodyFixed'; + } + // Sortir de la division précédente + echo ''; } echo $this->getData(['theme', 'footer', 'position']) === 'hide' ? '