Stockage des blocs avec les pages

This commit is contained in:
fredtempez 2019-01-04 18:53:24 +01:00
parent 5cdb96d25f
commit 01b4acddf6
7 changed files with 220 additions and 48 deletions

View File

@ -362,10 +362,6 @@ class common {
'fontWeight' => 'normal',
'textColor' => 'rgba(74, 105, 189, 1)',
'textTransform' => 'none'
],
'block' => [
'contentLeft' => '',
'contentRight' => ''
]
]
];
@ -1000,8 +996,8 @@ class common {
// Version 9.0.0
if($this->getData(['core', 'dataVersion']) < 900) {
$this->setData(['theme', 'site', 'blocks','100']);
$this->setData(['theme', 'block', 'contentLeft','']);
$this->setData(['theme', 'block', 'contentRight','']);
$this->setData(['page', 'blockLeft', 'content','']);
$this->setData(['page', 'blockRight', 'content','']);
$this->setData(['core', 'dataVersion', 900]);
$this->SaveData();
}
@ -2138,13 +2134,17 @@ class layout extends common {
if($this->getUser('group') >= self::GROUP_MODERATOR) {
$leftItems .= '<li><select id="barSelectPage">';
$leftItems .= '<option value="">Choisissez une page</option>';
$currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2);
$currentPageId = $this->getData(['page', $this->getUrl(0)]) ? $this->getUrl(0) : $this->getUrl(2);
foreach($this->getHierarchy(null, false) as $parentPageId => $childrenPageIds) {
if ($this->getData(['page', $parentPageId, 'title']) === 'blockLeft'
OR $this->getData(['page', $parentPageId, 'title']) === 'blockRight') { continue; }
$leftItems .= '<option value="' . helper::baseUrl() . $parentPageId . '"' . ($parentPageId === $currentPageId ? ' selected' : false) . '>' . $this->getData(['page', $parentPageId, 'title']) . '</option>';
foreach($childrenPageIds as $childKey) {
$leftItems .= '<option value="' . helper::baseUrl() . $childKey . '"' . ($childKey === $currentPageId ? ' selected' : false) . '>&nbsp;&nbsp;&nbsp;&nbsp;' . $this->getData(['page', $childKey, 'title']) . '</option>';
}
}
$leftItems .= '<option value="">-------------------</option>';
$leftItems .= '<option value="' . helper::baseUrl() . 'page/block">Edition des blocs</option>';
$leftItems .= '</select></li>';
$leftItems .= '<li><a href="' . helper::baseUrl() . 'page/add" title="Créer une page">' . template::ico('plus') . '</a></li>';
if(

View File

@ -120,6 +120,7 @@
$this->getUrl(0) === 'config' OR
$this->getUrl(0) === 'install' OR
$this->getUrl(0) === 'maintenance' OR
$this->getUrl(0) === 'page' OR
$this->getUrl(0) === 'user' ) { ?> <!-- Pas de multi colonne-->
<section><?php $layout->showContent(); ?></section>
<?php } else {
@ -146,9 +147,9 @@
?>
<section>
<div class="row">
<?php if ($blockleft !== "") :?> <div class="<?php echo $blockleft; ?>" id="contentleft"><?php echo $this->getData(['theme','block','contentLeft']);?></div> <?php endif; ?>
<?php if ($blockleft !== "") :?> <div class="<?php echo $blockleft; ?>" id="contentleft"><?php echo $this->getData(['page','blockLeft','content']);?></div> <?php endif; ?>
<div class="<?php echo $content; ?>" id="contentsite"><?php $layout->showContent(); ?></div>
<?php if ($blockright !== "") :?> <div class="<?php echo $blockright; ?>" id="contentright"><?php echo $this->getData(['theme','block','contentRight']);?></div> <?php endif; ?>
<?php if ($blockright !== "") :?> <div class="<?php echo $blockright; ?>" id="contentright"><?php echo $this->getData(['page','blockRight','content']);?></div> <?php endif; ?>
</div>
</section>
<?php } ?>

View File

@ -17,7 +17,8 @@ class page extends common {
public static $actions = [
'add' => self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR
'edit' => self::GROUP_MODERATOR,
'block' => self::GROUP_ADMIN
];
public static $pagesNoParentId = [
'' => 'Aucune'
@ -31,9 +32,9 @@ class page extends common {
];
// Position du module
public static $modulePosition = [
'bottom' => 'En bas',
'top' => 'En haut',
'free' => 'Libre'
'bottom' => 'En bas',
'top' => 'En haut',
'free' => 'Libre'
];
/**
@ -117,6 +118,66 @@ class page extends common {
}
}
/**
* Édition des blocs
*/
public function block () {
if($this->isPost()) {
$this->setData([
'page',
'blockLeft', [
'typeMenu' => 'text',
'iconUrl' => '',
'disable' => true,
'hideTitle' => false,
'metaDescription' => '',
'metaTitle' => '',
'moduleId' => '',
'parentPageId' => '',
'modulePosition' => 'bottom',
'position' => 0,
'group' => self::GROUP_VISITOR,
'targetBlank' => false,
'title' => 'blockLeft',
'content' => (empty($this->getInput('pageBlockLeftContent', null)) ? "<p></p>" : $this->getInput('pageBlockLeftContent', null))]
]);
$this->setData([
'page',
'blockRight', [
'typeMenu' => 'text',
'iconUrl' => '',
'disable' => true,
'hideTitle' => false,
'metaDescription' => '',
'metaTitle' => '',
'moduleId' => '',
'parentPageId' => '',
'modulePosition' => 'bottom',
'position' => 0,
'group' => self::GROUP_VISITOR,
'targetBlank' => false,
'title' => 'blockRight',
'content' => (empty($this->getInput('pageBlockRightContent', null)) ? "<p></p>" : $this->getInput('pageBlockRightContent', null))]
]);
$this->addOutput([
'redirect' => helper::baseUrl(),
'notification' => 'Modifications enregistrées',
'state' => true
]);
}
// Valeurs en sortie
$this->addOutput([
'title' => 'Édition des blocs',
'vendor' => [
'tinymce'
],
'view' => 'block'
]);
}
/**
* Édition
*/

View File

@ -0,0 +1,102 @@
/**
* This file is part of Zwii.
*
* For full copyright and license information, please see the LICENSE
* file that was distributed with this source code.
*
* @author Rémi Jean <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @license GNU General Public License, version 3
* @link http://zwiicms.com/
*/
/**
* Confirmation de suppression
*/
$("#pageEditDelete").on("click", function() {
var _this = $(this);
return core.confirm("Êtes-vous sûr de vouloir supprimer cette page ?", function() {
$(location).attr("href", _this.attr("href"));
});
});
/**
* Bloque/Débloque le bouton de configuration au changement de module
*/
var pageEditModuleIdDOM = $("#pageEditModuleId");
pageEditModuleIdDOM.on("change", function() {
if($(this).val() === "") {
$("#pageEditModuleConfig").addClass("disabled");
$("#pageEditContentContainer").slideDown();
}
else {
$("#pageEditModuleConfig").removeClass("disabled");
$("#pageEditContentContainer").slideUp();
}
});
/**
* Soumission du formulaire pour éditer le module
*/
$("#pageEditModuleConfig").on("click", function() {
$("#pageEditModuleRedirect").val(1);
$("#pageEditForm").trigger("submit");
});
/**
* Affiche les pages en fonction de la page parent dans le choix de la position
*/
var hierarchy = <?php echo json_encode($this->getHierarchy()); ?>;
var pages = <?php echo json_encode($this->getData(['page'])); ?>;
$("#pageEditParentPageId").on("change", function() {
var positionDOM = $("#pageEditPosition");
positionDOM.empty().append(
$("<option>").val(0).text("Ne pas afficher"),
$("<option>").val(1).text("Au début")
);
var parentSelected = $(this).val();
var positionSelected = 0;
var positionPrevious = 1;
// Aucune page parent selectionnée
if(parentSelected === "") {
// Liste des pages sans parents
for(var key in hierarchy) {
if(hierarchy.hasOwnProperty(key)) {
// Sélectionne la page avant si il s'agit de la page courante
if(key === "<?php echo $this->getUrl(2); ?>") {
positionSelected = positionPrevious;
}
// Sinon ajoute la page à la liste
else {
// Enregistre la position de cette page afin de la sélectionner si la prochaine page de la liste est la page courante
positionPrevious++;
// Ajout à la liste
positionDOM.append(
$("<option>").val(positionPrevious).text("Après \"" + pages[key].title + "\"")
);
}
}
}
}
// Un page parent est selectionnée
else {
// Liste des pages enfants de la page parent
for(var i = 0; i < hierarchy[parentSelected].length; i++) {
// Pour page courante sélectionne la page précédente (pas de - 1 à positionSelected à cause des options par défaut)
if(hierarchy[parentSelected][i] === "<?php echo $this->getUrl(2); ?>") {
positionSelected = positionPrevious;
}
// Sinon ajoute la page à la liste
else {
// Enregistre la position de cette page afin de la sélectionner si la prochaine page de la liste est la page courante
positionPrevious++;
// Ajout à la liste
positionDOM.append(
$("<option>").val(positionPrevious).text("Après \"" + pages[hierarchy[parentSelected][i]].title + "\"")
);
}
}
}
// Sélectionne la bonne position
positionDOM.val(positionSelected);
}).trigger("change");

View File

@ -0,0 +1,33 @@
<?php echo template::formOpen('pageblockEditForm'); ?>
<div class="row">
<div class="col2">
<?php $href = helper::baseUrl() . $this->getUrl(2); ?>
<?php if ($this->getData(['page', $this->getUrl(2), 'moduleId']) === 'redirection')$href = helper::baseUrl(); ?>
<?php echo template::button('pageblockEditBack', [
'class' => 'buttonGrey',
'href' => $href,
'ico' => 'left',
'value' => 'Retour'
]); ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('pageblockEditSubmit'); ?>
</div>
</div>
<div class='row'>
<div class="col6">
<?php echo template::textarea('pageBlockLeftContent', [
'label' => 'Contenu du bloc à gauche :',
'class' => 'editorWysiwyg',
'value' => $this->getData(['page','blockLeft', 'content'])
]); ?>
</div>
<div class="col6">
<?php echo template::textarea('pageBlockRightContent', [
'label' => 'Contenu du bloc à droite :',
'class' => 'editorWysiwyg',
'value' => $this->getData(['page','blockRight', 'content'])
]); ?>
</div>
</div>
<?php echo template::formClose(); ?>

View File

@ -436,10 +436,6 @@ class theme extends common {
'width' => $this->getInput('themeSiteWidth'),
'blocks' => $this->getInput('themeSiteBlocks')
]]);
$this->setData(['theme','block', [
'contentLeft' => (empty($this->getInput('themeBlockContentLeft', null)) ? "<p></p>" : $this->getInput('themeBlockContentLeft', null)),
'contentRight' => (empty($this->getInput('themeBlockContentRight', null)) ? "<p></p>" : $this->getInput('themeBlockContentRight', null))
]]);
// Valeurs en sortie
$this->addOutput([
'notification' => 'Modifications enregistrées',

View File

@ -40,7 +40,7 @@
</div>
</div>
<div class="row">
<div class="col4">
<div class="col4 offset2">
<?php echo template::text('themeButtonBackgroundColor', [
'class' => 'colorPicker',
'label' => 'Boutons',
@ -82,6 +82,15 @@
]); ?>
</div>
</div>
<div class='row'>
<div class="col4 offset4">
<?php echo template::select('themeSiteBlocks', $module::$siteBlocks, [
'label' => 'Répartition des blocs :',
'help' => 'Pour éditer le contenu des blocs, sélectionnez \'Édition des blocs\' dans la liste des pages.',
'selected' => $this->getData(['theme', 'site', 'blocks'])
]); ?>
</div>
</div>
</div>
</div>
</div>
@ -131,34 +140,4 @@
</div>
</div>
</div>
<div class="row">
<div class="block">
<h4>Mise en page </h4>
<div class='row'>
<div class="col3">
<?php echo template::select('themeSiteBlocks', $module::$siteBlocks, [
'label' => 'Répartition des blocs :',
'help' => 'Le bloc la plus large abrite le contenu du site',
'selected' => $this->getData(['theme', 'site', 'blocks'])
]); ?>
</div>
</div>
<div class='row'>
<div class="col6">
<?php echo template::textarea('themeBlockContentLeft', [
'label' => 'Contenu du bloc à gauche :',
'class' => 'editorWysiwyg',
'value' => $this->getData(['theme','block', 'contentLeft'])
]); ?>
</div>
<div class="col6">
<?php echo template::textarea('themeBlockContentRight', [
'label' => 'Contenu du bloc à droite :',
'class' => 'editorWysiwyg',
'value' => $this->getData(['theme','block', 'contentRight'])
]); ?>
</div>
</div>
</div>
</div>
<?php echo template::formClose(); ?>