diff --git a/core/class/router.class.php b/core/class/router.class.php index 83175dd..659fd50 100644 --- a/core/class/router.class.php +++ b/core/class/router.class.php @@ -105,53 +105,14 @@ class core extends common // Suppression des polices identiques $fonts = array_unique($fonts); - /** - * Charge les fontes websafe - */ - $fontFile = ''; - foreach ($fonts as $fontId) { - if (isset($fontsAvailable['websafe'][$fontId])) { - $fonts[$fontId] = $fontsAvailable['websafe'][$fontId]['font-family']; - } - } /** - * Chargement des polices en ligne dans un fichier font.html inclus dans main.php - */ - $fontFile = ''; - $gf = false; - foreach ($fonts as $fontId) { - if (isset($fontsAvailable['imported'][$fontId])) { - $fontFile .= ''; - // Tableau pour la construction de la feuille de style - $fonts[$fontId] = $fontsAvailable['imported'][$fontId]['font-family']; - $gf = strpos($fontsAvailable['imported'][$fontId]['resource'], 'fonts.googleapis.com') === false ? $gf || false : $gf || true; - } - } - // Ajoute le préconnect des fontes Googles. - $fontFile = $gf ? '' . $fontFile - : $fontFile; - // Enregistre la personnalisation - if (!is_dir(self::DATA_DIR . 'font')) { - mkdir(self::DATA_DIR . 'font'); - } - file_put_contents(self::DATA_DIR . 'font/font.html', $fontFile); - - /** - * Fontes installées localement + * Charge les fontes */ foreach ($fonts as $fontId) { - // Validité du tableau : - if (isset($fontsAvailable['files'][$fontId])) { - if (file_exists(self::DATA_DIR . 'font/' . $fontId)) { - // Chargement de la police - $css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";'; - $css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'font/' . $fontsAvailable['files'][$fontId]['resource'] . '");}'; - // Tableau pour la construction de la feuille de style - $fonts[$fontId] = $fontsAvailable['files'][$fontId]['font-family']; - } else { - // Le fichier de font n'est pas disponible, fonte par défaut - $fonts[$fontId] = 'verdana'; + foreach (['websafe', 'imported', 'files'] as $typeFont) { + if (isset($fontsAvailable[$typeFont][$fontId])) { + $fonts[$fontId] = $fontsAvailable[$typeFont][$fontId]['font-family']; } } } @@ -223,7 +184,7 @@ class core extends common // Bannière - // Éléments communs + // Eléments communs if ($this->getData(['theme', 'header', 'margin'])) { if ($this->getData(['theme', 'menu', 'position']) === 'site-first') { $css .= 'header{margin:0 20px}'; @@ -311,12 +272,6 @@ class core extends common $css .= '#footerText > p {text-align:' . $this->getData(['theme', 'footer', 'textAlign']) . '}'; $css .= '#footerCopyright{text-align:' . $this->getData(['theme', 'footer', 'copyrightAlign']) . '}'; - // Enregistre les fontes - if (!is_dir(self::DATA_DIR . 'font')) { - mkdir(self::DATA_DIR . 'font'); - } - file_put_contents(self::DATA_DIR . 'font/font.html', $fontFile); - // Enregistre la personnalisation file_put_contents(self::DATA_DIR . self::$siteContent . '/theme.css', $css); @@ -352,44 +307,12 @@ class core extends common $fonts = array_unique($fonts); /** - * Charge les fontes websafe - */ - $fontFile = ''; - foreach ($fonts as $fontId) { - if (isset($fontsAvailable['websafe'][$fontId])) { - $fonts[$fontId] = $fontsAvailable['websafe'][$fontId]['font-family']; - } - } - - /** - * Chargement des polices en ligne dans un fichier font.html inclus dans main.php - */ - $fontFile = ''; - foreach ($fonts as $fontId) { - if (isset($fontsAvailable['imported'][$fontId])) { - $fontFile .= ''; - // Tableau pour la construction de la feuille de style - $fonts[$fontId] = $fontsAvailable['imported'][$fontId]['font-family']; - } - } - // Enregistre la personnalisation - file_put_contents(self::DATA_DIR . 'font/font.html', $fontFile); - - /** - * Fontes installées localement + * Charge les fontes */ foreach ($fonts as $fontId) { - // Validité du tableau : - if (isset($fontsAvailable['files'][$fontId])) { - if (file_exists(self::DATA_DIR . 'font/' . $fontId)) { - // Chargement de la police - $css .= '@font-face {font-family:"' . $fontsAvailable['files'][$fontId]['font-family'] . '";'; - $css .= 'src: url("' . helper::baseUrl(false) . self::DATA_DIR . 'font/' . $fontsAvailable['files'][$fontId]['resource'] . '");}'; - // Tableau pour la construction de la feuille de style - $fonts[$fontId] = $fontsAvailable['files'][$fontId]['font-family']; - } else { - // Le fichier de font n'est pas disponible, fonte par défaut - $fonts[$fontId] = 'verdana'; + foreach (['websafe', 'imported', 'files'] as $typeFont) { + if (isset($fontsAvailable[$typeFont][$fontId])) { + $fonts[$fontId] = $fontsAvailable[$typeFont][$fontId]['font-family']; } } } diff --git a/core/core.php b/core/core.php index 9230734..0610673 100644 --- a/core/core.php +++ b/core/core.php @@ -50,7 +50,7 @@ class common const ACCESS_TIMER = 1800; // Numéro de version - const ZWII_VERSION = '1.4.01'; + const ZWII_VERSION = '1.4.02'; // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/campus-update/raw/branch/master/'; diff --git a/core/layout/blank.php b/core/layout/blank.php index faff2b1..0713285 100644 --- a/core/layout/blank.php +++ b/core/layout/blank.php @@ -16,6 +16,9 @@ + + + showContent(); ?> diff --git a/core/layout/light.php b/core/layout/light.php index 66d29cf..b639f42 100644 --- a/core/layout/light.php +++ b/core/layout/light.php @@ -16,6 +16,9 @@ + + + showNotification(); ?> diff --git a/core/layout/main.php b/core/layout/main.php index e2fc4e2..796c04a 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -16,6 +16,9 @@ + + + getData(['page', $this->getUrl(0), 'moduleId']) === 'blog' or $this->getData(['page', $this->getUrl(0), 'moduleId']) === 'news') diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index 52556d0..a5564b2 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -666,7 +666,7 @@ class theme extends common 'class' => 'themeFontEdit', 'href' => helper::baseUrl() . $this->getUrl(0) . '/fontEdit/' . $type . '/' . $fontId, 'value' => template::ico('pencil'), - 'disabled' => !empty($fontUsed[$fontId]) + //'disabled' => !empty($fontUsed[$fontId]) ]) : '', $type !== 'websafe' ? template::button('themeFontDelete' . $fontId, [ @@ -701,8 +701,8 @@ class theme extends common // Type d'import en ligne ou local $type = $this->getInput('fontAddUrl', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; $type === 'files' ? 'imported' : 'files'; - $ressource = $type === 'imported' ? $this->getInput('fontAddUrl', null) : $this->getInput('fontAddFile', null); - if (!empty($ressource)) { + $resource = $type === 'imported' ? $this->getInput('fontAddUrl', null) : $this->getInput('fontAddFile', null); + if (!empty($resource)) { $fontId = $this->getInput('fontAddFontId', null, true); $fontName = $this->getInput('fontAddFontName', null, true); $fontFamilyName = $this->getInput('fontAddFontFamilyName', null, true); @@ -714,6 +714,19 @@ class theme extends common if (is_array($this->getData(['font', $type, $fontId]))) { $this->deleteData(['font', $type, $fontId]); } + + // Copier la fonte si le nom du fichier est fourni + $success = false; + if (!is_dir(self::DATA_DIR . 'font/')) { + mkdir(self::DATA_DIR . 'font/'); + } + if ( + $type === 'files' && + file_exists(self::FILE_DIR . 'source/' . $resource) + ) { + $success = copy(self::FILE_DIR . 'source/' . $resource, self::DATA_DIR . 'font/' . basename($resource)); + } + // Stocker la fonte $this->setData([ 'font', @@ -722,24 +735,15 @@ class theme extends common [ 'name' => $fontName, 'font-family' => $fontFamilyName, - 'resource' => $ressource + 'resource' => $resource ] ]); - - // Copier la fonte si le nom du fichier est fourni - if ( - $type === 'files' && - file_exists(self::FILE_DIR . 'source/' . $ressource) - ) { - copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'font/' . $ressource); - } - // Valeurs en sortie $this->addOutput([ - 'notification' => helper::translate('Fonte créée'), - 'redirect' => helper::baseUrl() . 'theme/fonts', - 'state' => true + 'notification' => $success ? helper::translate('Fonte actualisée') : helper::translate('Erreur de copie'), + 'redirect' => helper::baseUrl() . 'theme/font', + 'state' => $success ]); } else { // Valeurs en sortie @@ -770,8 +774,8 @@ class theme extends common ) { // Type d'import en ligne ou local $type = $this->getInput('fontEditUrl', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; - $ressource = $type === 'imported' ? $this->getInput('fontEditUrl', null) : $this->getInput('fontEditFile', null); $fontId = $this->getInput('fontEditFontId', null, true); + $resource = $this->getData(['font', $type, $fontId, 'resource']); $fontName = $this->getInput('fontEditFontName', null, true); $fontFamilyName = $this->getInput('fontEditFontFamilyName', null, true); @@ -783,6 +787,7 @@ class theme extends common $this->deleteData(['font', $type, $fontId]); } + // Stocker les fontes $this->setData([ 'font', @@ -791,21 +796,14 @@ class theme extends common [ 'name' => $fontName, 'font-family' => $fontFamilyName, - 'resource' => $ressource + 'resource' => $resource ] ]); - // Copier la fonte si le nom du fichier est fourni - if ( - $type === 'files' && - file_exists(self::FILE_DIR . 'source/' . $ressource) - ) { - copy(self::FILE_DIR . 'source/' . $ressource, self::DATA_DIR . 'font/' . $ressource); - } // Valeurs en sortie $this->addOutput([ 'notification' => helper::translate('Fonte actualisée'), - 'redirect' => helper::baseUrl() . 'theme/fonts', + 'redirect' => helper::baseUrl() . 'theme/font', 'state' => true ]); } @@ -847,7 +845,7 @@ class theme extends common // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . 'theme/fonts', + 'redirect' => helper::baseUrl() . 'theme/font', 'notification' => helper::translate('Fonte supprimée'), 'state' => true ]); @@ -1045,8 +1043,8 @@ class theme extends common // Archive de thème ? if ( file_exists(self::TEMP_DIR . $tempFolder . '/site/data/custom.css') - and file_exists(self::TEMP_DIR . $tempFolder . '/site/data//theme.css') - and file_exists(self::TEMP_DIR . $tempFolder . '/site/data//theme.json') + and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.css') + and file_exists(self::TEMP_DIR . $tempFolder . '/site/data/theme.json') ) { $modele = 'theme'; } @@ -1381,13 +1379,13 @@ class theme extends common ($scope === 'user' && in_array($fontId, $fontsInstalled)) || $scope === 'all' ) { - if (file_exists(self::DATA_DIR . 'font/' . $fontValue['resource'])) { + if (file_exists($fontValue['resource'])) { // Extension $path_parts = pathinfo(helper::baseUrl(false) . self::DATA_DIR . 'font/' . $fontValue['resource']); // Chargement de la police $fileContentCss .= '@font-face {'; $fileContentCss .= 'font-family:"' . $fontValue['name'] . '";'; - $fileContentCss .= 'src: url("' . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");'; + $fileContentCss .= 'src: url("' . helper::baseUrl(false) . $fontValue['resource'] . '") format("' . $path_parts['extension'] . '");'; $fileContentCss .= '}'; // Préchargement //$fileContent = '' . $fileContent; diff --git a/core/module/theme/view/fontAdd/fontAdd.php b/core/module/theme/view/fontAdd/fontAdd.php index 157586b..d036a77 100644 --- a/core/module/theme/view/fontAdd/fontAdd.php +++ b/core/module/theme/view/fontAdd/fontAdd.php @@ -3,7 +3,7 @@
'buttonGrey', - 'href' => helper::baseUrl() . 'theme/fonts', + 'href' => helper::baseUrl() . 'theme/font', 'value' => template::ico('left') ]); ?>
diff --git a/core/module/theme/view/fontEdit/fontEdit.php b/core/module/theme/view/fontEdit/fontEdit.php index f42c0d5..3767aa9 100644 --- a/core/module/theme/view/fontEdit/fontEdit.php +++ b/core/module/theme/view/fontEdit/fontEdit.php @@ -3,7 +3,7 @@
'buttonGrey', - 'href' => helper::baseUrl() . 'theme/fonts', + 'href' => helper::baseUrl() . 'theme/font', 'value' => template::ico('left') ]); ?>
@@ -66,10 +66,10 @@
- 'Fichier de fonte (Format WOFF)', - 'language' => $this->getData(['user', $this->getUser('id'), 'language']), - 'value' => $this->getUrl(2) === 'files' ? $this->getData(['font', $this->getUrl(2), $this->getUrl(3), 'resource']) : '' + 'value' => $this->getUrl(2) === 'files' ? $this->getData(['font', $this->getUrl(2), $this->getUrl(3), 'resource']) : '', + 'disabled' => true ]); ?>
diff --git a/core/module/theme/view/footer/footer.php b/core/module/theme/view/footer/footer.php index 370818f..cd41c6a 100644 --- a/core/module/theme/view/footer/footer.php +++ b/core/module/theme/view/footer/footer.php @@ -131,29 +131,29 @@
$this->getData(['config', 'legalPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displayLegal']), - 'disabled' => $this->getData(['config', 'legalPageId']) === 'none' ? true : false, + 'checked' => $this->getData(['locale', 'legalPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displayLegal']), + 'disabled' => $this->getData(['locale', 'legalPageId']) === 'none' ? true : false, 'help' => 'Sélectionnez une page pour activer' ]); ?>
'Aucune'], helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC')), [ 'label' => helper::translate('Mentions légales') . ' ' . template::flag('selected', '20px'), - 'selected' => $this->getData(['config', 'legalPageId']) + 'selected' => $this->getData(['locale', 'legalPageId']) ]); ?>
$this->getData(['config', 'searchPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displaySearch']), - 'disabled' => $this->getData(['config', 'searchPageId']) === 'none' ? true : false, + 'checked' => $this->getData(['locale', 'searchPageId']) === 'none' ? false : $this->getData(['theme', 'footer', 'displaySearch']), + 'disabled' => $this->getData(['locale', 'searchPageId']) === 'none' ? true : false, 'help' => 'Sélectionnez une page pour activer' ]); ?>
'Aucune'], helper::arrayColumn($module::$pagesList, 'title', 'SORT_ASC')), [ 'label' => helper::translate('Rechercher dans le site') . ' ' . template::flag('selected', '20px'), - 'selected' => $this->getData(['config', 'searchPageId']) + 'selected' => $this->getData(['locale', 'searchPageId']) ]); ?>