예제 #1
0
파일: news.php 프로젝트: Okutsuko/ZwiiCMS
 /**
  * MODULE : Édition d'une news */
 public function edit()
 {
     // Erreur 404
     if (!$this->getData([$this->getUrl(0), $this->getUrl(2)])) {
         return false;
     } elseif ($this->getPost('submit')) {
         // Modifie la clef de la news si le titre a été modifié
         $key = $this->getPost('title') ? $this->getPost('title', helper::URL) : $this->getUrl(2);
         // Sauvegarde la date de création de la news
         $date = $this->getData([$this->getUrl(0), $this->getUrl(2), 'date']);
         // Si la clef à changée
         if ($key !== $this->getUrl(2)) {
             // Incrémente la nouvelle clef de la news pour éviter les doublons
             $key = helper::increment($key, $this->getData($this->getUrl(0)));
             // Supprime l'ancienne news
             $this->removeData([$this->getUrl(0), $this->getUrl(2)]);
         }
         // Modifie la news ou en crée une nouvelle si la clef a changée
         $this->setData([$this->getUrl(0), $key, ['title' => $this->getPost('title', helper::STRING), 'date' => $date, 'content' => $this->getPost('content')]]);
         // Enregistre les données
         $this->saveData();
         // Notification de modification
         $this->setNotification('News modifiée avec succès !');
         // Redirige vers l'édition de la nouvelle news si la clef à changée ou sinon vers l'ancienne
         helper::redirect('module/' . $this->getUrl(0) . '/edit/' . $key);
     }
     // Contenu de la page
     self::$content = template::openForm() . template::openRow() . template::text('title', ['label' => 'Titre de la news', 'value' => $this->getData([$this->getUrl(0), $this->getUrl(2), 'title']), 'required' => 'required']) . template::newRow() . template::textarea('content', ['class' => 'editor', 'value' => $this->getData([$this->getUrl(0), $this->getUrl(2), 'content'])]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => helper::baseUrl() . 'module/' . $this->getUrl(0), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow();
     template::closeForm();
 }
예제 #2
0
 /**
  * MODULE : Formulaire de contact
  */
 public function index()
 {
     // Envoi du mail
     if ($this->getPost('submit')) {
         $mail = helpers::mail($this->getPost('subject', helpers::STRING), $this->getData($this->getUrl(0), 'mail'), $this->getPost('subject', helpers::STRING), $this->getPost('message', helpers::STRING));
         if ($mail) {
             $this->setNotification('Mail envoyé avec succès !');
         } else {
             $this->setNotification('Impossible d\'envoyer le mail !');
         }
         helpers::redirect($this->getUrl());
     }
     // Interface d'écriture de mail
     self::$content = template::openForm() . template::openRow() . template::text('mail', ['label' => 'Adresse mail', 'required' => true, 'col' => 6]) . template::newRow() . template::text('subject', ['label' => 'Sujet', 'required' => true, 'col' => 6]) . template::newRow() . template::textarea('message', ['label' => 'Sujet', 'required' => true, 'col' => 7]) . template::newRow() . template::submit('submit', ['col' => 2]) . template::closeRow() . template::closeForm();
 }
예제 #3
0
파일: news.php 프로젝트: HasClass0/ZwiiCMS
 /**
  * MODULE : Édition d'une news
  */
 public function edit()
 {
     if (!$this->getData($this->getUrl(1), $this->getUrl(3))) {
         return false;
     } elseif ($this->getPost('submit')) {
         $key = $this->getPost('title') ? $this->getPost('title', helpers::URL) : $this->getUrl(3);
         $date = $this->getData($this->getUrl(1), $this->getUrl(3), 'date');
         if ($key !== $this->getUrl(3)) {
             $key = helpers::increment($key, $this->getData($this->getUrl(1)));
             $this->removeData($this->getUrl(1), $this->getUrl(3));
         }
         $this->setData($this->getUrl(1), $key, ['title' => $this->getPost('title', helpers::STRING), 'date' => $date, 'content' => $this->getPost('content')]);
         $this->saveData();
         $this->setNotification('News modifiée avec succès !');
         helpers::redirect('module/' . $this->getUrl(1) . '/' . $this->getUrl(2) . '/' . $key);
     }
     self::$content = template::openForm() . template::openRow() . template::text('title', ['label' => 'Titre de la news', 'value' => $this->getData($this->getUrl(1), $this->getUrl(3), 'title'), 'required' => true]) . template::newRow() . template::textarea('content', ['class' => 'editor', 'value' => $this->getData($this->getUrl(1), $this->getUrl(3), 'content')]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => '?module/' . $this->getUrl(1), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow();
     template::closeForm();
 }
예제 #4
0
파일: form.php 프로젝트: Okutsuko/ZwiiCMS
 /**
  * Génère un champ en fonction de son type
  * @param  $input array Input à générer
  * @return string
  */
 private function generateInput($input)
 {
     switch ($input['type']) {
         case 'text':
             // Génère le champ texte
             return template::openRow() . template::text('input[]', ['label' => $input['name'], 'col' => $input['width']]) . template::closeRow();
         case 'textarea':
             // Génère le grand champ texte
             return template::openRow() . template::textarea('input[]', ['label' => $input['name'], 'col' => $input['width']]) . template::closeRow();
         case 'select':
             // Génère un tableau sous forme value => value
             $values = array_flip(explode(',', $input['values']));
             foreach ($values as $value => $key) {
                 $values[$value] = $value;
             }
             // Génère le champ de sélection
             return template::openRow() . template::select('input[]', $values, ['label' => $input['name'], 'col' => $input['width']]) . template::closeRow();
     }
 }
예제 #5
0
파일: core.php 프로젝트: HasClass0/ZwiiCMS
 /**
  * MODULE : Configuration
  */
 public function config()
 {
     if ($this->getPost('submit')) {
         if ($this->getPost('password')) {
             if ($this->getPost('password') === $this->getPost('confirm')) {
                 $password = $this->getPost('password', helpers::PASSWORD);
             } else {
                 $password = $this->getData('config', 'password');
                 template::$notices['confirm'] = 'La confirmation ne correspond pas au nouveau mot de passe';
             }
         } else {
             $password = $this->getData('config', 'password');
         }
         $this->setData('config', ['title' => $this->getPost('title', helpers::STRING), 'description' => $this->getPost('description', helpers::STRING), 'password' => $password, 'index' => $this->getPost('index', helpers::STRING), 'theme' => $this->getPost('theme', helpers::STRING)]);
         $this->saveData(true);
         $this->setNotification('Configuration enregistrée avec succès !');
         helpers::redirect($this->getUrl());
     }
     self::$title = 'Configuration';
     self::$content = template::openForm() . template::openRow() . template::text('title', ['label' => 'Titre du site', 'required' => true, 'value' => $this->getData('config', 'title')]) . template::newRow() . template::textarea('description', ['label' => 'Description du site', 'required' => true, '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', helpers::arrayCollumn($this->getData('pages'), 'title', 'SORT_ASC', true), ['label' => 'Page d\'accueil', 'required' => true, 'selected' => $this->getData('config', 'index')]) . template::newRow() . template::select('theme', helpers::listThemes(), ['label' => 'Thème par défaut', 'required' => true, 'selected' => $this->getData('config', 'theme')]) . template::newRow() . template::text('version', ['label' => 'Version de ZwiiCMS', 'value' => self::VERSION, 'disabled' => true]) . template::newRow() . template::button('clean', ['value' => 'Vider le cache', 'href' => '?clean', 'col' => 3, 'offset' => 4]) . template::button('export', ['value' => 'Exporter les données', 'href' => '?export', 'col' => 3]) . template::submit('submit', ['col' => 2]) . template::closeRow() . template::closeForm();
 }
예제 #6
0
파일: core.php 프로젝트: Okutsuko/ZwiiCMS
 /** 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();
 }