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 ''; + echo substr($contentRight,$mark+6,strlen($contentRight)); + } + } + + /** + * Affiche le texte du footer + */ + public function showFooterText() { + if($footerText = $this->getData(['theme', 'footer', 'text']) OR $this->getUrl(0) === 'theme') { + echo '
' . $footerText . '
'; + } + } + + /** + * Affiche le copyright + */ + public function showCopyright() { + // Ouverture Bloc copyright + $items = '
'; + $items .= ''; + // Affichage de motorisé par + $items .= 'getData(['theme','footer','displayCopyright']) === false ? 'class="displayNone"' : ''; + $items .= '>Motorisé par '; + // Toujours afficher le nom du CMS + $items .= ''; + $items .= 'ZwiiCMS'; + $items .= ''; + // Affichage du numéro de version + $items .= 'getData(['theme','footer','displayVersion']) === false ? ' class="displayNone"' : ''; + $items .= '> '. common::ZWII_VERSION ; + $items .= ''; + // Affichage du sitemap + $items .= 'getData(['theme','footer','displaySiteMap']) === false ? ' class="displayNone"' : ''; + $items .= '> | Plan du site'; + $items .= ''; + // Affichage du module de recherche + $items .= 'getData(['theme','footer','displaySearch']) === false ? ' class="displayNone" >' : '>'; + if ($this->getData(['locale','searchPageId']) !== 'none') { + $items .= ' | Recherche'; + } + $items .= ''; + // Affichage des mentions légales + $items .= 'getData(['theme','footer','displayLegal']) === false ? ' class="displayNone" >' : '>'; + if ($this->getData(['locale','legalPageId']) !== 'none') { + $items .= ' | Mentions légales'; + } + $items .= ''; + // Affichage du lien de connexion + if( + ( + $this->getData(['theme', 'footer', 'loginLink']) + AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') + ) + OR $this->getUrl(0) === 'theme' + ) { + $items .= 'getUrl(0) === 'theme' ? 'class="displayNone"' : '') . + '> | ' . template::ico('login') .''; + } + // Affichage de la barre de membre simple + if ( $this->getUser('group') === self::GROUP_MEMBER + && $this->getData(['theme','footer','displayMemberBar']) === true + ) { + $items .= 'getData(['theme','footer','displaymemberAccount']) === false ? ' class="displayNone"' : ''; + $items .= '> | ' . template::ico('user', 'all') . ''; + if( $this->getData(['user', $this->getUser('id') , 'files']) === true) $items .= '' . template::ico('folder') . ''; + $items .= '' . template::ico('logout','left') . ''; + $items .= ''; + } + // Fermeture du bloc copyright + $items .= '
'; + echo $items; + } + + + /** + * Affiche les réseaux sociaux + */ + public function showSocials() { + $socials = ''; + foreach($this->getData(['config', 'social']) as $socialName => $socialId) { + switch($socialName) { + case 'facebookId': + $socialUrl = 'https://www.facebook.com/'; + $title = 'Facebook'; + break; + case 'linkedinId': + $socialUrl = 'https://fr.linkedin.com/in/'; + $title = 'Linkedin'; + break; + case 'instagramId': + $socialUrl = 'https://www.instagram.com/'; + $title = 'Instagram'; + break; + case 'pinterestId': + $socialUrl = 'https://pinterest.com/'; + $title = 'Pinterest'; + break; + case 'twitterId': + $socialUrl = 'https://twitter.com/'; + $title = 'Twitter'; + break; + case 'youtubeId': + $socialUrl = 'https://www.youtube.com/channel/'; + $title = 'Chaîne YouTube'; + break; + case 'youtubeUserId': + $socialUrl = 'https://www.youtube.com/user/'; + $title = 'YouTube'; + break; + case 'githubId': + $socialUrl = 'https://www.github.com/'; + $title = 'Github'; + break; + default: + $socialUrl = ''; + } + if($socialId !== '') { + $socials .= '' . template::ico(substr(str_replace('User','',$socialName), 0, -2)) . ''; + } + } + if($socials !== '') { + echo '
' . $socials . '
'; + } + } + + + + /** + * Affiche le favicon + */ + public function showFavicon() { + // Light scheme + $favicon = $this->getData(['config', 'favicon']); + if($favicon && + file_exists(self::FILE_DIR.'source/' . $favicon) + ) { + echo ''; + } else { + echo ''; + } + // Dark scheme + $faviconDark = $this->getData(['config', 'faviconDark']); + if(!empty($faviconDark) && + file_exists(self::FILE_DIR.'source/' . $faviconDark) + ) { + echo ''; + //echo ''; + echo ''; + } + } + + + /** + * Affiche le menu + */ + public function showMenu() { + // Met en forme les items du menu + $itemsLeft = ''; + $currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2); + foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { + // Passer les entrées masquées + // Propriétés de l'item + $active = ($parentPageId === $currentPageId OR in_array($currentPageId, $childrenPageIds)) ? 'active ' : ''; + $targetBlank = $this->getData(['page', $parentPageId, 'targetBlank']) ? ' target="_blank"' : ''; + // Mise en page de l'item + $itemsLeft .= '
  • '; + + if ( ( $this->getData(['page',$parentPageId,'disable']) === true + AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') + ) OR ( + $this->getData(['page',$parentPageId,'disable']) === true + AND $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') + AND $this->getUser('group') < self::GROUP_MODERATOR + ) + ){ + $itemsLeft .= ''; + } else { + $itemsLeft .= ''; + } + + switch ($this->getData(['page', $parentPageId, 'typeMenu'])) { + case '' : + $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); + break; + case 'text' : + $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); + break; + case 'icon' : + if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") { + $itemsLeft .= ''.$this->getData(['page', $parentPageId, 'title']).''; + } else { + $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); + } + break; + case 'icontitle' : + if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") { + $itemsLeft .= ''.$this->getData(['page', $parentPageId, 'title']).''; + } else { + $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); + } + break; + } + // Cas où les pages enfants enfant sont toutes masquées dans le menu + // ne pas afficher de symbole lorsqu'il n'y a rien à afficher + $totalChild = 0; + $disableChild = 0; + foreach($childrenPageIds as $childKey) { + $totalChild += 1; + } + if($childrenPageIds && $disableChild !== $totalChild && + $this->getdata(['page',$parentPageId,'hideMenuChildren']) === false) { + $itemsLeft .= template::ico('down', 'left'); + } + // ------------------------------------------------ + $itemsLeft .= ''; + if ($this->getdata(['page',$parentPageId,'hideMenuChildren']) === true || + empty($childrenPageIds)) { + continue; + } + $itemsLeft .= ''; + } + // Lien de connexion + $itemsRight = ''; + if( + ( + $this->getData(['theme', 'menu', 'loginLink']) + AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') + ) + OR $this->getUrl(0) === 'theme' + ) { + $itemsRight .= '
  • '; + } + // Commandes pour les membres simples + if($this->getUser('group') == self::GROUP_MEMBER + && ( $this->getData(['theme','menu','memberBar']) === true + || $this->getData(['theme','footer','displayMemberBar']) === false + ) + ) { + if( $this->getData(['user', $this->getUser('id') , 'files']) === true) $itemsRight .= '
  • ' . template::ico('folder') . '
  • '; + $itemsRight .= '
  • ' . template::ico('user', 'right') . '
  • '; + $itemsRight .= '
  • ' . template::ico('logout') . '
  • '; + } + // Retourne les items du menu + 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 .= ''; + } + // Retourne les items du menu + echo $items; + } + + + + /** + * Affiche le meta titre + */ + public function showMetaTitle() { + echo '' . $this->output['metaTitle'] . ''; + echo ''; + echo ''; + } + + /** + * Affiche la meta description + */ + public function showMetaDescription() { + echo ''; + echo ''; + } + + /** + * Affiche le meta type + */ + public function showMetaType() { + echo ''; + } + + /** + * Affiche la meta image (site screenshot) + */ + public function showMetaImage() { + echo ''; + } + + + + /** + * Affiche la notification + */ + public function showNotification() { + if (common::$importNotices) { + $notification = common::$importNotices [0]; + $notificationClass = 'notificationSuccess'; + } + if(common::$inputNotices) { + $notification = 'Impossible de soumettre le formulaire, car il contient des erreurs'; + $notificationClass = 'notificationError'; + } + if (common::$coreNotices) { + $notification = 'Données absentes, restauration de

    | '; + foreach (common::$coreNotices as $item) $notification .= $item . ' | '; + $notificationClass = 'notificationError'; + } + elseif(empty($_SESSION['ZWII_NOTIFICATION_SUCCESS']) === false) { + $notification = $_SESSION['ZWII_NOTIFICATION_SUCCESS']; + $notificationClass = 'notificationSuccess'; + unset($_SESSION['ZWII_NOTIFICATION_SUCCESS']); + } + elseif(empty($_SESSION['ZWII_NOTIFICATION_ERROR']) === false) { + $notification = $_SESSION['ZWII_NOTIFICATION_ERROR']; + $notificationClass = 'notificationError'; + unset($_SESSION['ZWII_NOTIFICATION_ERROR']); + } + elseif(empty($_SESSION['ZWII_NOTIFICATION_OTHER']) === false) { + $notification = $_SESSION['ZWII_NOTIFICATION_OTHER']; + $notificationClass = 'notificationOther'; + unset($_SESSION['ZWII_NOTIFICATION_OTHER']); + } + if(isset($notification) AND isset($notificationClass)) { + echo '

    ' . $notification . '' . template::ico('cancel') . '
    '; + } + } + + /** + * Affiche la barre de membre + */ + public function showBar() { + if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')) { + // Items de gauche + $leftItems = ''; + if($this->getUser('group') >= self::GROUP_MODERATOR) { + $leftItems .= '
  • '; + $leftItems .= '
  • ' . template::ico('plus') . '
  • '; + 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 .= '
  • ' . template::ico('pencil') . '
  • '; + if ($this->getData(['page', $this->getUrl(0),'moduleId'])) { + $leftItems .= '
  • ' . template::ico('gear') . '
  • '; + } + $leftItems .= '
  • ' . template::ico('clone') . '
  • '; + $leftItems .= '
  • ' . template::ico('trash') . '
  • '; + } + } + // Items de droite + $rightItems = ''; + if($this->getUser('group') >= self::GROUP_MODERATOR) { + $rightItems .= '
  • ' . template::ico('folder') . '
  • '; + } + if($this->getUser('group') >= self::GROUP_ADMIN) { + if ($this->getData(['config', 'i18n', 'active']) === true) { + $rightItems .= '
  • ' . template::ico('flag') . '
  • '; + } + $rightItems .= '
  • ' . template::ico('puzzle') . '
  • '; + $rightItems .= '
  • ' . template::ico('brush') . '
  • '; + $rightItems .= '
  • ' . template::ico('cog-alt') . '
  • '; + // 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 .= '
  • ' . template::ico('update colorRed') . '
  • '; + } + $rightItems .= '
  • ' . template::ico('users') . '
  • '; + } + $rightItems .= '
  • ' . template::ico('user', 'right') . '' . $this->getUser('firstname') . ' ' . $this->getUser('lastname') . '
  • '; + $rightItems .= '
  • ' . template::ico('logout') . '
  • '; + // Barre de membre + echo '
    '; + } + } + + /** + * Affiche le script + */ + public function showScript() { + ob_start(); + require 'core/core.js.php'; + $coreScript = ob_get_clean(); + echo ''; + } + + /** + * Affiche le style + */ + public function showStyle() { + if($this->output['style']) { + echo ''; + if (strpos($this->output['style'], 'admin.css') >= 1 ) { + echo ''; + } + echo ''; + } + } + + /** + * Affiche l'import des librairies + */ + public function showVendor() { + // Variables partagées + $vars = 'var baseUrl = ' . json_encode(helper::baseUrl(false)) . ';'; + $vars .= 'var baseUrlQs = ' . json_encode(helper::baseUrl()) . ';'; + if( + $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') + AND $this->getUser('group') >= self::GROUP_MODERATOR + ) { + $vars .= 'var privateKey = ' . json_encode(md5_file(self::DATA_DIR.'core.json')) . ';'; + } + echo ''; + // Librairies + $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); + foreach($this->output['vendor'] as $vendorName) { + // Coeur + if(file_exists('core/vendor/' . $vendorName . '/inc.json')) { + $vendorPath = 'core/vendor/' . $vendorName . '/'; + } + // Module + elseif( + $moduleId + AND in_array($moduleId, self::$coreModuleIds) === false + AND file_exists('module/' . $moduleId . '/vendor/' . $vendorName . '/inc.json') + ) { + $vendorPath = 'module/' . $moduleId . '/vendor/' . $vendorName . '/'; + } + // Sinon continue + else { + continue; + } + // Détermine le type d'import en fonction de l'extension de la librairie + $vendorFiles = json_decode(file_get_contents($vendorPath . 'inc.json')); + foreach($vendorFiles as $vendorFile) { + switch(pathinfo($vendorFile, PATHINFO_EXTENSION)) { + case 'css': + // Force le rechargement lors d'une mise à jour du jeu d'icônes + $reload = $vendorPath === 'core/vendor/zwiico/' + ? '?' . md5_file('core/vendor/zwiico/css/zwiico-codes.css') + : ''; + echo ''; + break; + case 'js': + echo ''; + break; + } + } + } + } + /** + * Affiche le cadre avec les drapeaux sélectionnés + */ + public function showi18n($id) { + echo '
    '; + } } 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 ''; - echo substr($contentRight,$mark+6,strlen($contentRight)); - } - } - - /** - * Affiche le texte du footer - */ - public function showFooterText() { - if($footerText = $this->getData(['theme', 'footer', 'text']) OR $this->getUrl(0) === 'theme') { - echo '
    ' . $footerText . '
    '; - } - } - - /** - * Affiche le copyright - */ - public function showCopyright() { - // Ouverture Bloc copyright - $items = '
    '; - $items .= ''; - // Affichage de motorisé par - $items .= 'getData(['theme','footer','displayCopyright']) === false ? 'class="displayNone"' : ''; - $items .= '>Motorisé par '; - // Toujours afficher le nom du CMS - $items .= ''; - $items .= 'ZwiiCMS'; - $items .= ''; - // Affichage du numéro de version - $items .= 'getData(['theme','footer','displayVersion']) === false ? ' class="displayNone"' : ''; - $items .= '> '. common::ZWII_VERSION ; - $items .= ''; - // Affichage du sitemap - $items .= 'getData(['theme','footer','displaySiteMap']) === false ? ' class="displayNone"' : ''; - $items .= '> | Plan du site'; - $items .= ''; - // Affichage du module de recherche - $items .= 'getData(['theme','footer','displaySearch']) === false ? ' class="displayNone" >' : '>'; - if ($this->getData(['locale','searchPageId']) !== 'none') { - $items .= ' | Recherche'; - } - $items .= ''; - // Affichage des mentions légales - $items .= 'getData(['theme','footer','displayLegal']) === false ? ' class="displayNone" >' : '>'; - if ($this->getData(['locale','legalPageId']) !== 'none') { - $items .= ' | Mentions légales'; - } - $items .= ''; - // Affichage du lien de connexion - if( - ( - $this->getData(['theme', 'footer', 'loginLink']) - AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') - ) - OR $this->getUrl(0) === 'theme' - ) { - $items .= 'getUrl(0) === 'theme' ? 'class="displayNone"' : '') . - '> | ' . template::ico('login') .''; - } - // Affichage de la barre de membre simple - if ( $this->getUser('group') === self::GROUP_MEMBER - && $this->getData(['theme','footer','displayMemberBar']) === true - ) { - $items .= 'getData(['theme','footer','displaymemberAccount']) === false ? ' class="displayNone"' : ''; - $items .= '> | ' . template::ico('user', 'all') . ''; - if( $this->getData(['user', $this->getUser('id') , 'files']) === true) $items .= '' . template::ico('folder') . ''; - $items .= '' . template::ico('logout','left') . ''; - $items .= ''; - } - // Fermeture du bloc copyright - $items .= '
    '; - echo $items; - } - - - /** - * Affiche les réseaux sociaux - */ - public function showSocials() { - $socials = ''; - foreach($this->getData(['config', 'social']) as $socialName => $socialId) { - switch($socialName) { - case 'facebookId': - $socialUrl = 'https://www.facebook.com/'; - $title = 'Facebook'; - break; - case 'linkedinId': - $socialUrl = 'https://fr.linkedin.com/in/'; - $title = 'Linkedin'; - break; - case 'instagramId': - $socialUrl = 'https://www.instagram.com/'; - $title = 'Instagram'; - break; - case 'pinterestId': - $socialUrl = 'https://pinterest.com/'; - $title = 'Pinterest'; - break; - case 'twitterId': - $socialUrl = 'https://twitter.com/'; - $title = 'Twitter'; - break; - case 'youtubeId': - $socialUrl = 'https://www.youtube.com/channel/'; - $title = 'Chaîne YouTube'; - break; - case 'youtubeUserId': - $socialUrl = 'https://www.youtube.com/user/'; - $title = 'YouTube'; - break; - case 'githubId': - $socialUrl = 'https://www.github.com/'; - $title = 'Github'; - break; - default: - $socialUrl = ''; - } - if($socialId !== '') { - $socials .= '' . template::ico(substr(str_replace('User','',$socialName), 0, -2)) . ''; - } - } - if($socials !== '') { - echo '
    ' . $socials . '
    '; - } - } - - - - /** - * Affiche le favicon - */ - public function showFavicon() { - // Light scheme - $favicon = $this->getData(['config', 'favicon']); - if($favicon && - file_exists(self::FILE_DIR.'source/' . $favicon) - ) { - echo ''; - } else { - echo ''; - } - // Dark scheme - $faviconDark = $this->getData(['config', 'faviconDark']); - if(!empty($faviconDark) && - file_exists(self::FILE_DIR.'source/' . $faviconDark) - ) { - echo ''; - //echo ''; - echo ''; - } - } - - - /** - * Affiche le menu - */ - public function showMenu() { - // Met en forme les items du menu - $itemsLeft = ''; - $currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2); - foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) { - // Passer les entrées masquées - // Propriétés de l'item - $active = ($parentPageId === $currentPageId OR in_array($currentPageId, $childrenPageIds)) ? 'active ' : ''; - $targetBlank = $this->getData(['page', $parentPageId, 'targetBlank']) ? ' target="_blank"' : ''; - // Mise en page de l'item - $itemsLeft .= '
  • '; - - if ( ( $this->getData(['page',$parentPageId,'disable']) === true - AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') - ) OR ( - $this->getData(['page',$parentPageId,'disable']) === true - AND $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') - AND $this->getUser('group') < self::GROUP_MODERATOR - ) - ){ - $itemsLeft .= ''; - } else { - $itemsLeft .= ''; - } - - switch ($this->getData(['page', $parentPageId, 'typeMenu'])) { - case '' : - $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); - break; - case 'text' : - $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); - break; - case 'icon' : - if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") { - $itemsLeft .= ''.$this->getData(['page', $parentPageId, 'title']).''; - } else { - $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); - } - break; - case 'icontitle' : - if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") { - $itemsLeft .= ''.$this->getData(['page', $parentPageId, 'title']).''; - } else { - $itemsLeft .= $this->getData(['page', $parentPageId, 'title']); - } - break; - } - // Cas où les pages enfants enfant sont toutes masquées dans le menu - // ne pas afficher de symbole lorsqu'il n'y a rien à afficher - $totalChild = 0; - $disableChild = 0; - foreach($childrenPageIds as $childKey) { - $totalChild += 1; - } - if($childrenPageIds && $disableChild !== $totalChild && - $this->getdata(['page',$parentPageId,'hideMenuChildren']) === false) { - $itemsLeft .= template::ico('down', 'left'); - } - // ------------------------------------------------ - $itemsLeft .= ''; - if ($this->getdata(['page',$parentPageId,'hideMenuChildren']) === true || - empty($childrenPageIds)) { - continue; - } - $itemsLeft .= ''; - } - // Lien de connexion - $itemsRight = ''; - if( - ( - $this->getData(['theme', 'menu', 'loginLink']) - AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') - ) - OR $this->getUrl(0) === 'theme' - ) { - $itemsRight .= '
  • '; - } - // Commandes pour les membres simples - if($this->getUser('group') == self::GROUP_MEMBER - && ( $this->getData(['theme','menu','memberBar']) === true - || $this->getData(['theme','footer','displayMemberBar']) === false - ) - ) { - if( $this->getData(['user', $this->getUser('id') , 'files']) === true) $itemsRight .= '
  • ' . template::ico('folder') . '
  • '; - $itemsRight .= '
  • ' . template::ico('user', 'right') . '
  • '; - $itemsRight .= '
  • ' . template::ico('logout') . '
  • '; - } - // Retourne les items du menu - 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 .= ''; - } - // Retourne les items du menu - echo $items; - } - - - - /** - * Affiche le meta titre - */ - public function showMetaTitle() { - echo '' . $this->core->output['metaTitle'] . ''; - echo ''; - echo ''; - } - - /** - * Affiche la meta description - */ - public function showMetaDescription() { - echo ''; - echo ''; - } - - /** - * Affiche le meta type - */ - public function showMetaType() { - echo ''; - } - - /** - * Affiche la meta image (site screenshot) - */ - public function showMetaImage() { - echo ''; - } - - - - /** - * Affiche la notification - */ - public function showNotification() { - if (common::$importNotices) { - $notification = common::$importNotices [0]; - $notificationClass = 'notificationSuccess'; - } - if(common::$inputNotices) { - $notification = 'Impossible de soumettre le formulaire, car il contient des erreurs'; - $notificationClass = 'notificationError'; - } - if (common::$coreNotices) { - $notification = 'Données absentes, restauration de

    | '; - foreach (common::$coreNotices as $item) $notification .= $item . ' | '; - $notificationClass = 'notificationError'; - } - elseif(empty($_SESSION['ZWII_NOTIFICATION_SUCCESS']) === false) { - $notification = $_SESSION['ZWII_NOTIFICATION_SUCCESS']; - $notificationClass = 'notificationSuccess'; - unset($_SESSION['ZWII_NOTIFICATION_SUCCESS']); - } - elseif(empty($_SESSION['ZWII_NOTIFICATION_ERROR']) === false) { - $notification = $_SESSION['ZWII_NOTIFICATION_ERROR']; - $notificationClass = 'notificationError'; - unset($_SESSION['ZWII_NOTIFICATION_ERROR']); - } - elseif(empty($_SESSION['ZWII_NOTIFICATION_OTHER']) === false) { - $notification = $_SESSION['ZWII_NOTIFICATION_OTHER']; - $notificationClass = 'notificationOther'; - unset($_SESSION['ZWII_NOTIFICATION_OTHER']); - } - if(isset($notification) AND isset($notificationClass)) { - echo '

    ' . $notification . '' . template::ico('cancel') . '
    '; - } - } - - /** - * Affiche la barre de membre - */ - public function showBar() { - if($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')) { - // Items de gauche - $leftItems = ''; - if($this->getUser('group') >= self::GROUP_MODERATOR) { - $leftItems .= '
  • '; - $leftItems .= '
  • ' . template::ico('plus') . '
  • '; - 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 .= '
  • ' . template::ico('pencil') . '
  • '; - if ($this->getData(['page', $this->getUrl(0),'moduleId'])) { - $leftItems .= '
  • ' . template::ico('gear') . '
  • '; - } - $leftItems .= '
  • ' . template::ico('clone') . '
  • '; - $leftItems .= '
  • ' . template::ico('trash') . '
  • '; - } - } - // Items de droite - $rightItems = ''; - if($this->getUser('group') >= self::GROUP_MODERATOR) { - $rightItems .= '
  • ' . template::ico('folder') . '
  • '; - } - if($this->getUser('group') >= self::GROUP_ADMIN) { - if ($this->getData(['config', 'i18n', 'active']) === true) { - $rightItems .= '
  • ' . template::ico('flag') . '
  • '; - } - $rightItems .= '
  • ' . template::ico('puzzle') . '
  • '; - $rightItems .= '
  • ' . template::ico('brush') . '
  • '; - $rightItems .= '
  • ' . template::ico('cog-alt') . '
  • '; - // 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 .= '
  • ' . template::ico('update colorRed') . '
  • '; - } - $rightItems .= '
  • ' . template::ico('users') . '
  • '; - } - $rightItems .= '
  • ' . template::ico('user', 'right') . '' . $this->getUser('firstname') . ' ' . $this->getUser('lastname') . '
  • '; - $rightItems .= '
  • ' . template::ico('logout') . '
  • '; - // Barre de membre - echo '
    '; - } - } - - /** - * Affiche le script - */ - public function showScript() { - ob_start(); - require 'core/core.js.php'; - $coreScript = ob_get_clean(); - echo ''; - } - - /** - * Affiche le style - */ - public function showStyle() { - if($this->core->output['style']) { - echo ''; - if (strpos($this->core->output['style'], 'admin.css') >= 1 ) { - echo ''; - } - echo ''; - } - } - - /** - * Affiche l'import des librairies - */ - public function showVendor() { - // Variables partagées - $vars = 'var baseUrl = ' . json_encode(helper::baseUrl(false)) . ';'; - $vars .= 'var baseUrlQs = ' . json_encode(helper::baseUrl()) . ';'; - if( - $this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') - AND $this->getUser('group') >= self::GROUP_MODERATOR - ) { - $vars .= 'var privateKey = ' . json_encode(md5_file(self::DATA_DIR.'core.json')) . ';'; - } - echo ''; - // Librairies - $moduleId = $this->getData(['page', $this->getUrl(0), 'moduleId']); - foreach($this->core->output['vendor'] as $vendorName) { - // Coeur - if(file_exists('core/vendor/' . $vendorName . '/inc.json')) { - $vendorPath = 'core/vendor/' . $vendorName . '/'; - } - // Module - elseif( - $moduleId - AND in_array($moduleId, self::$coreModuleIds) === false - AND file_exists('module/' . $moduleId . '/vendor/' . $vendorName . '/inc.json') - ) { - $vendorPath = 'module/' . $moduleId . '/vendor/' . $vendorName . '/'; - } - // Sinon continue - else { - continue; - } - // Détermine le type d'import en fonction de l'extension de la librairie - $vendorFiles = json_decode(file_get_contents($vendorPath . 'inc.json')); - foreach($vendorFiles as $vendorFile) { - switch(pathinfo($vendorFile, PATHINFO_EXTENSION)) { - case 'css': - // Force le rechargement lors d'une mise à jour du jeu d'icônes - $reload = $vendorPath === 'core/vendor/zwiico/' - ? '?' . md5_file('core/vendor/zwiico/css/zwiico-codes.css') - : ''; - echo ''; - break; - case 'js': - echo ''; - break; - } - } - } - } - /** - * Affiche le cadre avec les drapeaux sélectionnés - */ - public function showi18n($id) { - echo '
    '; - } -} diff --git a/core/layout/blank.php b/core/layout/blank.php index ae92b811..ed8baa32 100644 --- a/core/layout/blank.php +++ b/core/layout/blank.php @@ -1,23 +1,22 @@ - + - showMetaTitle(); ?> - showMetaDescription(); ?> - showMetaType(); ?> - showMetaImage(); ?> - showFavicon(); ?> - showVendor(); ?> - showStyle(); ?> + showMetaTitle(); ?> + showMetaDescription(); ?> + showMetaType(); ?> + showMetaImage(); ?> + showFavicon(); ?> + showVendor(); ?> + showStyle(); ?> -showContent(); ?> -showScript(); ?> +showContent(); ?> +showScript(); ?> \ No newline at end of file diff --git a/core/layout/light.php b/core/layout/light.php index a781f64e..82ae54fd 100644 --- a/core/layout/light.php +++ b/core/layout/light.php @@ -1,27 +1,26 @@ - + - showMetaTitle(); ?> - showMetaDescription(); ?> - showMetaType(); ?> - showMetaImage(); ?> - showFavicon(); ?> - showVendor(); ?> - showStyle(); ?> + showMetaTitle(); ?> + showMetaDescription(); ?> + showMetaType(); ?> + showMetaImage(); ?> + showFavicon(); ?> + showVendor(); ?> + showStyle(); ?> -showNotification(); ?> +showNotification(); ?>
    -
    showContent(); ?>
    +
    showContent(); ?>
    -showScript(); ?> +showScript(); ?> \ No newline at end of file diff --git a/core/layout/main.php b/core/layout/main.php index 6e10f387..c046975c 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -1,16 +1,16 @@ - + - + - showMetaTitle(); ?> - showMetaDescription(); ?> - showMetaType(); ?> - showMetaImage(); ?> - showFavicon(); ?> - showVendor(); ?> - showAnalytics(); ?> + showMetaTitle(); ?> + showMetaDescription(); ?> + showMetaType(); ?> + showMetaImage(); ?> + showFavicon(); ?> + showVendor(); ?> + showAnalytics(); ?> @@ -20,16 +20,16 @@ AND $this->getData(['module', $this->getUrl(0), 'config', 'feeds']) === TRUE ): ?> - showStyle(); ?> + showStyle(); ?> getUser('group') > self::GROUP_MEMBER): ?> - showBar(); ?> + showBar(); ?> - showNotification(); ?> + showNotification(); ?> getData(['theme', 'menu', 'position']) === 'body-first' || $this->getData(['theme', 'menu', 'position']) === 'top' ): ?> @@ -52,14 +52,14 @@ getData(['theme', 'header', 'position']) === 'body'): ?>
    - showi18n();?> + showi18n();?> getData(['theme','header','linkHomePage'])){ echo "" ;} ?> @@ -88,7 +88,7 @@
    getData(['locale','title']);?>
    - + @@ -101,7 +101,7 @@
    getData(['locale','title']);?>
    - + getData(['locale','title']);?> - +
    - showi18n();?> + showi18n();?> getUrl(1),$pattern) ) ) { // Pleine page en mode configuration - $layout->showContent(); + $this->showContent(); if (file_exists(self::DATA_DIR . 'body.inc.html')) { include( self::DATA_DIR . 'body.inc.html'); } @@ -192,10 +192,10 @@
    -
    +
    - showContent(); + showContent(); if (file_exists(self::DATA_DIR . 'body.inc.html')) { include(self::DATA_DIR . 'body.inc.html'); } @@ -203,7 +203,7 @@
    -
    +
    - getData(['theme', 'footer', 'textPosition']) === 'left') { $layout->showFooterText(); } - if($this->getData(['theme', 'footer', 'socialsPosition']) === 'left') { $layout->showSocials(); } - if($this->getData(['theme', 'footer', 'copyrightPosition']) === 'left') {$layout->showCopyright(); } + getData(['theme', 'footer', 'textPosition']) === 'left') { $this->showFooterText(); } + if($this->getData(['theme', 'footer', 'socialsPosition']) === 'left') { $this->showSocials(); } + if($this->getData(['theme', 'footer', 'copyrightPosition']) === 'left') {$this->showCopyright(); } ?>
    - getData(['theme', 'footer', 'textPosition']) === 'center') { $layout->showFooterText(); } - if($this->getData(['theme', 'footer', 'socialsPosition']) === 'center') { $layout->showSocials(); } - if($this->getData(['theme', 'footer', 'copyrightPosition']) === 'center') { $layout->showCopyright(); } + getData(['theme', 'footer', 'textPosition']) === 'center') { $this->showFooterText(); } + if($this->getData(['theme', 'footer', 'socialsPosition']) === 'center') { $this->showSocials(); } + if($this->getData(['theme', 'footer', 'copyrightPosition']) === 'center') { $this->showCopyright(); } ?>
    - getData(['theme', 'footer', 'textPosition']) === 'right') { $layout->showFooterText(); } - if($this->getData(['theme', 'footer', 'socialsPosition']) === 'right') { $layout->showSocials(); } - if($this->getData(['theme', 'footer', 'copyrightPosition']) === 'right') { $layout->showCopyright(); } + getData(['theme', 'footer', 'textPosition']) === 'right') { $this->showFooterText(); } + if($this->getData(['theme', 'footer', 'socialsPosition']) === 'right') { $this->showSocials(); } + if($this->getData(['theme', 'footer', 'copyrightPosition']) === 'right') { $this->showCopyright(); } ?>
    @@ -287,6 +287,6 @@ } ?>
    - showScript();?> + showScript();?>