Example #1
0
 /** MODULE : Configuration du formulaire */
 public function index()
 {
     // Traitement du formulaire
     if ($this->getPost('submit')) {
         // Configuration du module
         $this->setData([$this->getUrl(0), 'config', ['mail' => $this->getPost('mail', helper::EMAIL), 'button' => $this->getPost('button', helper::STRING)]]);
         // Génération des champs
         $inputs = [];
         foreach ($this->getPost('position') as $key => $value) {
             $value = helper::filter($value, helper::INT);
             // Supprime le premier élément (= le champ caché pour la copie)
             if (!empty($value)) {
                 $inputs[] = ['position' => $value, 'name' => $this->getPost(['name', $key], helper::STRING), 'type' => $this->getPost(['type', $key], helper::STRING), 'values' => $this->getPost(['values', $key], helper::STRING), 'width' => $this->getPost(['width', $key], helper::INT)];
             }
         }
         // Crée les champs
         $this->setData([$this->getUrl(0), 'inputs', $inputs]);
         // Enregistre les données
         $this->saveData();
         // Notification de succès
         $this->setNotification('Formulaire enregistré avec succès !');
         // Redirige vers l'URL courante
         helper::redirect($this->getUrl());
     }
     // Liste des champs
     if ($this->getData([$this->getUrl(0), 'inputs'])) {
         // Liste les champs en les classant par position en ordre croissant
         $inputs = helper::arrayCollumn($this->getData([$this->getUrl(0), 'inputs']), 'position', 'SORT_ASC');
         // Crée l'affichage des champs en fonction
         for ($i = 0; $i < count($inputs); $i++) {
             self::$content .= template::openRow() . template::hidden('position[]', ['value' => $this->getData([$this->getUrl(0), 'inputs', $inputs[$i], 'position']), 'class' => 'position']) . template::button('move[]', ['value' => '&#8597;', 'class' => 'move', 'col' => 1]) . template::text('name[]', ['placeholder' => 'Nom', 'value' => $this->getData([$this->getUrl(0), 'inputs', $inputs[$i], 'name']), 'col' => 3]) . template::select('type[]', self::$types, ['selected' => $this->getData([$this->getUrl(0), 'inputs', $inputs[$i], 'type']), 'class' => 'type', 'col' => 2]) . template::text('values[]', ['placeholder' => 'Liste des valeurs (valeur1,valeur2,...)', 'value' => $this->getData([$this->getUrl(0), 'inputs', $inputs[$i], 'values']), 'class' => 'values', 'col' => 3]) . template::select('width[]', self::$widths, ['selected' => (int) $this->getData([$this->getUrl(0), 'inputs', $inputs[$i], 'width']), 'col' => 2]) . template::button('delete[]', ['value' => '-', 'class' => 'delete', 'col' => 1]) . template::closeRow();
         }
     }
     // Contenu de la page
     self::$content = template::openForm() . template::title('Configuration') . template::openRow() . template::text('mail', ['label' => 'Recevoir à chaque validation un mail contenant les données saisies', 'value' => $this->getData([$this->getUrl(0), 'config', 'mail'])]) . template::text('button', ['label' => 'Personnaliser le texte du bouton', 'value' => $this->getData([$this->getUrl(0), 'config', 'button'])]) . template::closeRow() . template::title('Liste des champs') . template::div(['id' => 'copy', 'class' => 'hide', 'text' => template::openRow() . template::hidden('position[]', ['class' => 'position']) . template::button('move[]', ['value' => '&#8597;', 'class' => 'move', 'col' => 1]) . template::text('name[]', ['placeholder' => 'Nom', 'col' => 3]) . template::select('type[]', self::$types, ['class' => 'type', 'col' => 2]) . template::text('values[]', ['placeholder' => 'Liste des valeurs (valeur1,valeur2,...)', 'class' => 'values', 'col' => 3]) . template::select('width[]', self::$widths, ['selected' => 12, 'col' => 2]) . template::button('delete[]', ['value' => '-', 'class' => 'delete', 'col' => 1]) . template::closeRow()]) . template::div(['id' => 'inputs', 'text' => self::$content]) . template::openRow() . template::button('add', ['value' => '+', 'col' => 1, 'offset' => 11]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => helper::baseUrl() . 'edit/' . $this->getUrl(0), 'col' => 2]) . template::button('data', ['value' => 'Données saisies', 'href' => helper::baseUrl() . $this->getUrl() . '/data', 'col' => 2, 'offset' => 6]) . template::submit('submit', ['col' => 2]) . template::closeRow() . template::closeForm();
 }
Example #2
0
 /** MODULE : Liste des news */
 public function index()
 {
     // Erreur 404
     if (!$this->getData($this->getUrl(0))) {
         return false;
     } else {
         // Crée une pagination (retourne la première news et dernière news de la page et la liste des pages
         $pagination = helper::pagination($this->getData($this->getUrl(0)), $this->getUrl());
         // Liste les news en classant les classant par date en ordre décroissant
         $news = helper::arrayCollumn($this->getData($this->getUrl(0)), 'date', 'SORT_DESC');
         // Crée l'affichage des news en fonction de la pagination
         for ($i = $pagination['first']; $i < $pagination['last']; $i++) {
             self::$content .= template::title($this->getData([$this->getUrl(0), $news[$i], 'title'])) . template::subTitle(date('d/m/Y - H:i', $this->getData([$this->getUrl(0), $news[$i], 'date']))) . $this->getData([$this->getUrl(0), $news[$i], 'content']);
         }
         // Ajoute la liste des pages en dessous des news
         self::$content .= $pagination['pages'];
     }
 }
Example #3
0
 /** MODULE : Configuration */
 public function config()
 {
     // Traitement du formulaire
     if ($this->getPost('submit')) {
         // Double vérification pour le mot de passe si il a changé
         if ($this->getPost('password')) {
             // Change le mot de passe si la confirmation correspond au mot de passe
             if ($this->getPost('password') === $this->getPost('confirm')) {
                 $password = $this->getPost('password', helper::PASSWORD);
             } else {
                 $password = $this->getData(['config', 'password']);
                 template::$notices['confirm'] = 'La confirmation du mot de passe ne correspond pas au mot de passe';
             }
         } else {
             $password = $this->getData(['config', 'password']);
         }
         // Modifie la configuration
         $this->setData(['config', ['title' => $this->getPost('title', helper::STRING), 'description' => $this->getPost('description', helper::STRING), 'password' => $password, 'index' => $this->getPost('index', helper::STRING), 'language' => $this->getPost('language', helper::STRING), 'themeHeader' => $this->getPost('themeHeader', helper::STRING), 'themeElement' => $this->getPost('themeElement', helper::STRING), 'themeMenu' => $this->getPost('themeMenu', helper::STRING), 'themeBackground' => $this->getPost('themeBackground', helper::STRING), 'themeImage' => $this->getPost('themeImage', helper::URL), 'themeMargin' => $this->getPost('themeMargin', helper::BOOLEAN), 'themeRadius' => $this->getPost('themeRadius', helper::BOOLEAN), 'themeShadow' => $this->getPost('themeShadow', helper::BOOLEAN)]]);
         // Active/désactive l'URL rewriting
         if (!template::$notices) {
             // Active l'URL rewriting
             if ($this->getPost('rewriting', helper::BOOLEAN) and file_exists('.rewriting')) {
                 // Check que l'URL rewriting fonctionne sur le serveur
                 if (get_headers(helper::baseUrl(false) . 'core/rewrite/test')[0] === 'HTTP/1.1 200 OK') {
                     rename('.htaccess', '.simple');
                     rename('.rewriting', '.htaccess');
                 }
             } elseif (!$this->getPost('rewriting', helper::BOOLEAN) and file_exists('.simple')) {
                 rename('.htaccess', '.rewriting');
                 rename('.simple', '.htaccess');
             }
         }
         // Enregistre les données et supprime le cache
         $this->saveData(true);
         // Notification de modification
         $this->setNotification('Configuration enregistrée avec succès !');
         // Redirige vers l'URL courante
         helper::redirect($this->getUrl());
     }
     // Contenu de la page
     self::$title = helper::translate('Configuration');
     self::$content = template::openForm() . template::title('Configuration générale') . template::openRow() . template::text('title', ['label' => 'Titre du site', 'required' => 'required', 'value' => $this->getData(['config', 'title'])]) . template::newRow() . template::textarea('description', ['label' => 'Description du site', 'required' => 'required', 'value' => $this->getData(['config', 'description'])]) . template::newRow() . template::password('password', ['label' => 'Nouveau mot de passe', 'col' => 6]) . template::password('confirm', ['label' => 'Confirmation du mot de passe', 'col' => 6]) . template::newRow() . template::select('index', helper::arrayCollumn($this->getData('pages'), 'title', 'SORT_ASC', true), ['label' => 'Page d\'accueil', 'required' => 'required', 'selected' => $this->getData(['config', 'index'])]) . template::newRow() . template::select('language', helper::listLanguages('Ne pas traduire'), ['label' => 'Traduire le site', 'selected' => $this->getData(['config', 'language'])]) . template::newRow() . template::checkbox('rewriting', true, 'Activer la réécriture d\'URL', ['checked' => file_exists('.simple'), 'help' => 'Supprime le point d\'interrogation de l\'URL (si vous n\'arrivez pas à cocher la case, vérifiez que le module d\'URL rewriting de votre serveur soit bien activé).', 'disabled' => get_headers(helper::baseUrl(false) . 'core/rewrite/test')[0] !== 'HTTP/1.1 200 OK' ? 'disabled' : '']) . template::newRow() . template::text('version', ['label' => 'Version de ZwiiCMS', 'value' => self::$version, 'disabled' => 'disabled']) . template::closeRow() . template::title('Configuration du thème') . template::div(['id' => 'theme', 'text' => template::openRow() . template::colorPicker('themeHeader', ['label' => 'Couleur de la bannière', 'ignore' => ['Clouds'], 'selected' => $this->getData(['config', 'themeHeader']) ? $this->getData(['config', 'themeHeader']) : 'themeHeaderWhite', 'col' => 6]) . template::colorPicker('themeMenu', ['label' => 'Couleur du menu', 'ignore' => ['Clouds', 'White'], 'selected' => $this->getData(['config', 'themeMenu']) ? $this->getData(['config', 'themeMenu']) : 'themeMenuPeterRiver', 'col' => 6]) . template::newRow() . template::colorPicker('themeElement', ['label' => 'Couleur des éléments du site', 'ignore' => ['Clouds', 'White'], 'selected' => $this->getData(['config', 'themeElement']) ? $this->getData(['config', 'themeElement']) : 'themeElementPeterRiver', 'col' => 6]) . template::colorPicker('themeBackground', ['label' => 'Couleur du fond', 'ignore' => ['White'], 'selected' => $this->getData(['config', 'themeBackground']) ? $this->getData(['config', 'themeBackground']) : 'themeBackgroundClouds', 'col' => 6]) . template::newRow() . template::select('themeImage', helper::listUploads('Aucune image', ['png', 'jpeg', 'jpg', 'gif']), ['label' => 'Afficher une image à la place du texte dans la bannière', 'help' => 'Vous pouvez afficher une image de votre gestionnaire de fichiers dans votre bannière (formats autorisés : png, gif, jpg, jpeg).', 'selected' => $this->getData(['config', 'themeImage'])]) . template::newRow() . template::checkbox('themeMargin', true, 'Ajouter une marge autour de la bannière et du menu', ['checked' => $this->getData(['config', 'themeMargin'])]) . template::newRow() . template::checkbox('themeRadius', true, 'Arrondir les coins du site', ['checked' => $this->getData(['config', 'themeRadius'])]) . template::checkbox('themeShadow', true, 'Ajouter une ombre autour du site', ['checked' => $this->getData(['config', 'themeShadow'])]) . template::closeRow()]) . template::openRow() . template::button('clean', ['value' => 'Vider le cache', 'href' => helper::baseUrl() . 'clean', 'col' => 3, 'offset' => 4]) . template::button('export', ['value' => 'Exporter les données', 'href' => helper::baseUrl() . 'export', 'col' => 3]) . template::submit('submit', ['col' => 2]) . template::closeRow() . template::closeForm();
 }