@ -45,8 +45,8 @@ class common {
// Numéro de version
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
const ZWII_VERSION = '11.3.01 ';
const ZWII_UPDATE_CHANNEL = "v11 ";
const ZWII_VERSION = '12.0.00 ';
const ZWII_UPDATE_CHANNEL = "test ";
public static $actions = [];
public static $coreModuleIds = [
@ -538,6 +538,8 @@ class common {
}
/**
* Effacer les données de la page
* @param string pageId
@ -547,7 +549,8 @@ class common {
return unlink(self::DATA_DIR . $lang . '/content/' . $this->getData(['page', $page, 'content']));
}
}
/**
* Sauvegarde des données
@ -1032,8 +1035,6 @@ class common {
case 'gif':
$source_image = imagecreatefromgif($src);
break;
case 'webp':
$source_image = imagecreatefromwebp($src);
}
// Image valide
if ($source_image) {
@ -1056,9 +1057,6 @@ class common {
case 'image/gif':
return (imagegif($virtual_image, $dest));
break;
case 'image/webp':
return (imagewebp($virtual_image, $dest));
break;
}
} else {
return (false);
@ -1184,13 +1182,34 @@ class common {
}
/**
* Fonction de parcours des données de module
* @param string $find donnée à rechercher
* @param string $replace donnée à remplacer
* @param array tableau à analyser
* @param int count nombres d'occurrences
* @return array avec les valeurs remplacées.
*/
public function recursive_array_replace ($find, $replace, $array, & $count) {
if (!is_array($array)) {
return str_replace($find, $replace, $array, $count);
}
$newArray = [];
foreach ($array as $key => $value) {
$newArray[$key] = $this->recursive_array_replace($find, $replace, $value,$c);
$count += $c;
}
return $newArray;
}
/**
* Génère une archive d'un dossier et des sous-dossiers
* @param string fileName path et nom de l'archive
* @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/';
@ -1656,65 +1675,15 @@ class common {
*/
public function showMenu() {
// Met en forme les items du menu
$itemsLeft = $this->formatMenu(false);
// Menu extra
$itemsRight = $this->formatMenu(true);
// Lien de connexion
if(
(
$this->getData(['theme', 'menu', 'loginLink'])
AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
)
OR $this->getUrl(0) === 'theme'
) {
$itemsRight .= '< li id = "menuLoginLink" ' .
($this->getUrl(0) === 'theme' ? 'class="displayNone"' : '') .
'>< a href = "' . helper::baseUrl ( ) . ' user / login / ' .
strip_tags(str_replace('/', '_', $this->getUrl())) .
'">' . template::ico('login') .'< / a > < / li > ';
}
// 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 .= '< li > < a href = "' . helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json') .'" data-tippy-content = "Gérer les fichiers" data-lity > ' . template::ico('folder') . '< / a > < / li > ';
$itemsRight .= '< li > < a href = "' . helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf'] . '" data-tippy-content = "Gérer mon compte" > ' . template::ico('user', 'right') . '< / a > < / li > ';
$itemsRight .= '< li > < a id = "barLogout" href = "' . helper::baseUrl() . 'user/logout" data-tippy-content = "Me déconnecter" > ' . template::ico('logout') . '< / a > < / li > ';
}
// Retourne les items du menu
echo '< ul class = "navMain" id = "menuLeft" > ' . $itemsLeft . '< / ul > < ul class = "navMain" id = "menuRight" > ' . $itemsRight;
if ($this->getData(['config', 'i18n', 'enable']) === true) {
echo $this->showi18n();
}
echo '< / ul > ';
}
/**
* Cette fonction est appelée par showMenu
* Elle permet de générer le menu selon qu'il s'agisse du menu principal ou du petit menu
* @param $menu bool false pour le menu principal, true pour le petit menu
*/
private function formatMenu($extra = false) {
$items = '';
$itemsLeft = '';
$currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2);
foreach($this->getHierarchy() as $parentPageId => $childrenPageIds) {
// Menu extra ou standard
if (
// Absence de la position extra, la page est toujours affichée à gauche.
($this->getData(['page',$parentPageId,'extraPosition']) !== NULL || $extra === true)
& &
$this->getData(['page',$parentPageId,'extraPosition']) !== $extra ) {
continue;
}
// 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
$items .= '< li id = "' . $parentPageId .'" > ';
$itemsLeft .= '< li id = "' . $parentPageId .'" > ';
if ( ( $this->getData(['page',$parentPageId,'disable']) === true
AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
@ -1725,32 +1694,32 @@ class common {
)
){
$pageUrl = ($this->getData(['locale', 'homePageId']) === $this->getUrl(0)) ? helper::baseUrl(false) : helper::baseUrl() . $this->getUrl(0);
$items .= '< a id = "' . $parentPageId . '" href = "' . $pageUrl . '" > ';
$itemsLeft .= '< a id = "' . $parentPageId . '" href = "' . $pageUrl . '" > ';
} else {
$pageUrl = ($this->getData(['locale', 'homePageId']) === $parentPageId) ? helper::baseUrl(false) : helper::baseUrl() . $parentPageId;
$items .= '< a class = "' . $active . '" id = "' . $parentPageId . '" href = "' . $pageUrl . '" ' . $ targetBlank . ' > ';
$itemsLeft .= '< a class = "' . $active . '" id = "' . $parentPageId . '" href = "' . $pageUrl . '" ' . $ targetBlank . ' > ';
}
switch ($this->getData(['page', $parentPageId, 'typeMenu'])) {
case '' :
$items .= $this->getData(['page', $parentPageId, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
break;
case 'text' :
$items .= $this->getData(['page', $parentPageId, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
break;
case 'icon' :
if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") {
$items .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $parentPageId, 'iconUrl']).'" / > ';
$itemsLeft .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $parentPageId, 'iconUrl']).'" / > ';
} else {
$items .= $this->getData(['page', $parentPageId, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
case 'icontitle' :
if ($this->getData(['page', $parentPageId, 'iconUrl']) != "") {
$items .= '< img alt = "'.$this->getData(['page', $parentPageId, 'titlshortTitlee']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $parentPageId, 'iconUrl']).'" data-tippy-content = "';
$items .= $this->getData(['page', $parentPageId, 'shortTitle']).'"/>';
$itemsLeft .= '< img alt = "'.$this->getData(['page', $parentPageId, 'titlshortTitlee']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $parentPageId, 'iconUrl']).'" data-tippy-content = "';
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']).'"/>';
} else {
$items .= $this->getData(['page', $parentPageId, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
}
@ -1763,21 +1732,21 @@ class common {
}
if($childrenPageIds & & $disableChild !== $totalChild & &
$this->getdata(['page',$parentPageId,'hideMenuChildren']) === false) {
$items .= template::ico('down', 'left');
$itemsLeft .= template::ico('down', 'left');
}
// ------------------------------------------------
$items .= '< / a > ';
$itemsLeft .= '< / a > ';
if ($this->getdata(['page',$parentPageId,'hideMenuChildren']) === true ||
empty($childrenPageIds)) {
continue;
}
$items .= '< ul class = "navSub" > ';
$itemsLeft .= '< ul class = "navSub" > ';
foreach($childrenPageIds as $childKey) {
// Propriétés de l'item
$active = ($childKey === $currentPageId) ? 'active ' : '';
$targetBlank = $this->getData(['page', $childKey, 'targetBlank']) ? ' target="_blank"' : '';
// Mise en page du sous-item
$items .= '< li id = ' . $childKey .' > ';
$itemsLeft .= '< li id = ' . $childKey .' > ';
if ( ( $this->getData(['page',$childKey,'disable']) === true
AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
) OR (
@ -1787,49 +1756,78 @@ class common {
)
){
$pageUrl = ($this->getData(['locale', 'homePageId']) === $this->getUrl(0)) ? helper::baseUrl(false) : helper::baseUrl() . $this->getUrl(0);
$items .= '< a id = "' . $parentPageId . '" href = "'. $pageUrl .'" > ';
$itemsLeft .= '< a id = "' . $parentPageId . '" href = "'. $pageUrl .'" > ';
} else {
$pageUrl = ($this->getData(['locale', 'homePageId']) === $childKey) ? helper::baseUrl(false) : helper::baseUrl() . $childKey;
$items .= '< a class = "' . $active . ' ' . $parentPageId . '" id = "' . $childKey . '" href = "' . $pageUrl . '" ' . $ targetBlank . ' > ';
$itemsLeft .= '< a class = "' . $active . ' ' . $parentPageId . '" id = "' . $childKey . '" href = "' . $pageUrl . '" ' . $ targetBlank . ' > ';
}
switch ($this->getData(['page', $childKey, 'typeMenu'])) {
case '' :
$items .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
break;
case 'text' :
$items .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
break;
case 'icon' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$items .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" / > ';
$itemsLeft .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" / > ';
} else {
$items .= $this->getData(['page', $parentPageId, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $parentPageId, 'shortTitle']);
}
break;
case 'icontitle' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$items .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" data-tippy-content = "';
$items .= $this->getData(['page', $childKey, 'shortTitle']).'"/>';
$itemsLeft .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" data-tippy-content = "';
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']).'"/>';
} else {
$items .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
}
break;
case 'icontext' :
if ($this->getData(['page', $childKey, 'iconUrl']) != "") {
$items .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" / > ';
$items .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= '< img alt = "'.$this->getData(['page', $parentPageId, 'shortTitle']).'" src = "'. helper::baseUrl(false) .self::FILE_DIR.'source/'.$this->getData(['page', $childKey, 'iconUrl']).'" / > ';
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
} else {
$items .= $this->getData(['page', $childKey, 'shortTitle']);
$itemsLeft .= $this->getData(['page', $childKey, 'shortTitle']);
}
break;
}
$items .= '< / a > < / li > ';
$itemsLeft .= '< / a > < / li > ';
}
$items .= '< / ul > ';
$itemsLeft .= '< / ul > ';
}
// 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 .= '< li id = "menuLoginLink" ' .
($this->getUrl(0) === 'theme' ? 'class="displayNone"' : '') .
'>< a href = "' . helper::baseUrl ( ) . ' user / login / ' .
strip_tags(str_replace('/', '_', $this->getUrl())) .
'">' . template::ico('login') .'< / a > < / li > ';
}
return($items);
// 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 .= '< li > < a href = "' . helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR.'core.json') .'" data-tippy-content = "Gérer les fichiers" data-lity > ' . template::ico('folder') . '< / a > < / li > ';
$itemsRight .= '< li > < a href = "' . helper::baseUrl() . 'user/edit/' . $this->getUser('id'). '/' . $_SESSION['csrf'] . '" data-tippy-content = "Gérer mon compte" > ' . template::ico('user', 'right') . '< / a > < / li > ';
$itemsRight .= '< li > < a id = "barLogout" href = "' . helper::baseUrl() . 'user/logout" data-tippy-content = "Me déconnecter" > ' . template::ico('logout') . '< / a > < / li > ';
}
// Retourne les items du menu
echo '< ul class = "navMain" id = "menuLeft" > ' . $itemsLeft . '< / ul > < ul class = "navMain" id = "menuRight" > ' . $itemsRight;
if ($this->getData(['config', 'i18n', 'enable']) === true) {
echo $this->showi18n();
}
echo '< / ul > ';
}
/**
@ -2324,7 +2322,7 @@ class core extends common {
*/
foreach ($fonts as $fontId) {
if (!array_key_exists($fontId, $localFonts) ) {
$css .= '@import url("https ://fonts.cdnfonts.com/css/' . $fontId . '");';
$css .= '@import url("http://fonts.cdnfonts.com/css/' . $fontId . '");';
// Supprimer l'élément des fontes chargées en ligne
unset($fonts[$fontId]);
}
@ -2550,7 +2548,7 @@ class core extends common {
*/
foreach ($fonts as $fontId) {
if (!array_key_exists($fontId, $localFonts) ) {
$css .= '@import url("https ://fonts.cdnfonts.com/css/' . $fontId . '");';
$css .= '@import url("http://fonts.cdnfonts.com/css/' . $fontId . '");';
// Supprimer l'élément des fontes chargées en ligne
unset($fonts[$fontId]);
}