Пример #1
0
 /**
  * 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 : Configuration de la redirection
  */
 public function index()
 {
     if ($this->getPost('submit')) {
         $this->setData($this->getUrl(1), 'url', $this->getPost('url', helpers::URL));
         $this->saveData();
         $this->setNotification('Configuration du module enregistrée avec succès !');
         helpers::redirect($this->getUrl());
     }
     self::$content = template::openForm() . template::openRow() . template::text('url', ['label' => 'URL de redirection', 'value' => $this->getData($this->getUrl(1), 'url')]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => '?edit/' . $this->getUrl(1), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow() . template::closeForm();
 }
Пример #3
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();
 }
Пример #4
0
 /** MODULE : Configuration de la redirection*/
 public function index()
 {
     // Traitement du formulaire
     if ($this->getPost('submit')) {
         // Modifie l'URL de redirection
         $this->setData([$this->getUrl(0), 'url', $this->getPost('url', helper::URL)]);
         // Enregistre les données
         $this->saveData();
         // Notification de succès
         $this->setNotification('URL de redirection enregistrée avec succès !');
         // Redirige vers l'URL courante
         helper::redirect($this->getUrl());
     }
     // Contenu de la page
     self::$content = template::openForm() . template::openRow() . template::text('url', ['label' => 'URL de redirection', 'value' => $this->getData([$this->getUrl(0), 'url'])]) . template::newRow() . template::button('back', ['value' => 'Retour', 'href' => helper::baseUrl() . 'edit/' . $this->getUrl(0), 'col' => 2]) . template::submit('submit', ['col' => 2, 'offset' => 8]) . template::closeRow() . template::closeForm();
 }
Пример #5
0
 /**
  * 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();
 }
Пример #6
0
 /** MODULE : Formulaire */
 public function index()
 {
     // Traitement du formulaire
     if ($this->getPost('submit')) {
         // Préparation des données (index + 1 comme l'item 0 = champ de copie qui est supprimé à l'enregistrement)
         $data = [];
         $mail = '';
         foreach ($this->getPost('input') as $key => $value) {
             // Préparation des données pour la création dans la base
             $data[$this->getData([$this->getUrl(0), 'inputs', $key + 1, 'name'])] = $value;
             // Préparation des données pour le mail
             $mail .= '<li>' . $this->getData([$this->getUrl(0), 'inputs', $key + 1, 'name']) . ' : ' . $value . '</li>';
         }
         // Crée les données
         $this->setData([$this->getUrl(0), 'data', helper::increment(1, $this->getData([$this->getUrl(0), 'data'])), $data]);
         // Enregistre les données
         $this->saveData();
         // Envoi du mail
         if ($this->getData([$this->getUrl(0), 'config', 'mail'])) {
             helper::mail(false, $this->getData([$this->getUrl(0), 'config', 'mail']), helper::translate('Mail de votre site ZwiiCMS'), '<h1>' . helper::translate('Mail en provenance de votre site ZwiiCMS') . '</h1>' . $mail . '</ul>');
         }
         // Notification de soumission
         $this->setNotification('Formulaire soumis avec succès !');
         // Redirige vers la page courante
         helper::redirect($this->getUrl());
     }
     // Génère les inputs
     if ($this->getData([$this->getUrl(0), 'inputs'])) {
         foreach ($this->getData([$this->getUrl(0), 'inputs']) as $input) {
             self::$content .= $this->generateInput($input);
         }
         // Texte du bouton de validation
         $submitText = $this->getData([$this->getUrl(0), 'config', 'button']);
         // Ajout du bouton de validation
         self::$content .= template::openRow() . template::submit('submit', ['value' => $submitText ? $submitText : 'Enregistrer', 'col' => 2]) . template::closeRow();
     }
     // Contenu de la page
     self::$content = template::openForm() . self::$content . template::closeForm();
 }
Пример #7
0
 /**
  * MODULE : Connexion
  */
 public function login()
 {
     if ($this->getPost('submit')) {
         if ($this->getPost('password', helpers::PASSWORD) === $this->getData('config', 'password')) {
             $time = $this->getPost('time') ? 0 : time() + 10 * 365 * 24 * 60 * 60;
             $this->setCookie($this->getPost('password'), $time);
             helpers::redirect($this->getUrl());
         } else {
             $this->setNotification('Mot de passe incorrect !');
             helpers::redirect($this->getUrl());
         }
     }
     self::$title = 'Connexion';
     self::$content = template::openForm() . template::openRow() . template::password('password', ['col' => 4]) . template::newRow() . template::checkbox('time', true, 'Me connecter automatiquement lors de mes prochaines visites.') . template::newRow() . template::submit('submit', ['value' => 'Me connecter', 'col' => 2]) . template::closeRow() . template::closeForm();
 }
Пример #8
0
 /** MODULE : Connexion */
 public function login()
 {
     // Traitement du formulaire
     if ($this->getPost('submit')) {
         // Crée un cookie (de durée infinie si la case est cochée) si le mot de passe est correct
         if ($this->getPost('password', helper::PASSWORD) === $this->getData(['config', 'password'])) {
             $time = $this->getPost('time') ? 0 : time() + 10 * 365 * 24 * 60 * 60;
             $this->setCookie($this->getPost('password'), $time);
         } else {
             $this->setNotification('Mot de passe incorrect !', true);
         }
         // Redirection vers l'URL courante
         helper::redirect($this->getUrl());
     }
     // Contenu de la page
     self::$title = helper::translate('Connexion');
     self::$content = template::openForm() . template::openRow() . template::password('password', ['required' => 'required', 'col' => 4]) . template::newRow() . template::checkbox('time', true, 'Me connecter automatiquement à chaque visite') . template::newRow() . template::submit('submit', ['value' => 'Me connecter', 'col' => 2]) . template::closeRow() . template::closeForm();
 }