From 1dc61c44089f518053ee5b70b1097bb1aa6bdb2b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 4 Jan 2019 01:01:45 +0100 Subject: [PATCH] removed unfinished plugin --- plugins/contactform/contactform.php | 173 --------------------------- plugins/contactform/contactform.yaml | 94 --------------- 2 files changed, 267 deletions(-) delete mode 100644 plugins/contactform/contactform.php delete mode 100644 plugins/contactform/contactform.yaml diff --git a/plugins/contactform/contactform.php b/plugins/contactform/contactform.php deleted file mode 100644 index d60617a..0000000 --- a/plugins/contactform/contactform.php +++ /dev/null @@ -1,173 +0,0 @@ - 'onSessionSegmentsLoaded', - 'onHtmlLoaded' => 'onHtmlLoaded', - ); - } - - # add the path stored in user-settings to initiate session and csrf-protection - public function onSessionSegmentsLoaded($segments) - { - $this->pluginSettings = $this->getPluginSettings('contactform'); - - if($this->getPath() == $this->pluginSettings['page_value']) - { - $data = $segments->getData(); - $data[] = $this->pluginSettings['page_value']; - - $segments->setData($data); - } - } - - # create the output - public function onHtmlLoaded($html) - { - if($this->getPath() == $this->pluginSettings['page_value']) - { - $content = $html->getData(); - - # add css - $this->addCSS('/contactform/css/contactform.css'); - - # check if form data have been stored - $formdata = $this->getFormdata('contactform'); - - if($formdata) - { - # process the form-data - $sendmail = $this->sendMail($formdata); - if($sendmail) - { - $mailresult = '
' . $this->markdownToHtml($this->pluginSettings['message_success']) . '
'; - } - else - { - $mailresult = '
' . $this->markdownToHtml($this->pluginSettings['message_error']) . '
'; - } - - # add thank you to the content - $content = $content . $mailresult; - } - else - { - # get the public forms for the plugin - $contactform = $this->generateForm('contactform'); - - # add forms to the content - $content = $content . $contactform; - } - $html->setData($content); - } - } - - private function sendMail($formdata) - { - $mailto = $this->pluginSettings['mailto']; - $subject = $formdata['subject']; - $message = wordwrap($formdata['message'],70); - $header = 'From: ' . $formdata['email'] . "\r\n" . - 'Reply-To: ' . $formdata['email'] . "\r\n" . - 'X-Mailer: PHP/' . phpversion(); - - return @mail($mailto, $subject, $message, $header); - } - - # check if the mail-plugin is active - /* - public function onTwigLoaded() - { - $this->settings = $this->getSettings(); - - if(isset($this->settings['plugins']['mail']) OR !$this->settings['plugins']['mail']['active']) - { - $this->container->flash->addMessage('error', 'You have to activate the mail-plugin to use the contactform.'); - } - } - */ - - # get the original html without manipulations from other plugins - /* - public function onOriginalLoaded($original) - { - if(substr($this->getPath(), 0, strlen($this->pluginSettings['area_value'])) === $this->pluginSettings['area_value']) - { - $this->originalHtml = $original->getHTML($urlrel = false); - } - } - */ - - # create the output - /* - public function onHtmlLoaded($html) - { - if(substr($this->getPath(), 0, strlen($this->pluginSettings['area_value'])) === $this->pluginSettings['area_value']) - { - $content = $this->originalHtml; - - if($this->getPath() == $this->pluginSettings['page_value']) - { - # add css - $this->addCSS('/contactform/css/contactform.css'); - - # check if form data have been stored - $formdata = $this->getFormdata('contactform'); - - if($formdata) - { - # process the form-data - $sendmail = $this->sendMail($formdata); - if($sendmail) - { - $mailresult = '

Thank you!

Your Message has been send.

'; - } - else - { - $mailresult = '

Error

We could not send your message. Please send the mail manually.

'; - } - /* - print_r($formdata); - die(); - $mail = $this->container->mail->send('mail/welcome.twig', ['user' => $user, 'url' => $host], function($message) use ($user){ - $message->to($user['email']); - $message->subject('Dein Account bei der Regierungsmannschaft'); - }); - - if(!$mail) - { - $this->container->flash->addMessage('error', 'Die Bestätigungsmail konnte nicht verschickt werden.'); - } - - # create thank you page - - # add thank you to the content - $content = $this->originalHtml . $mailresult; - } - else - { - # get the public forms for the plugin - $contactform = $this->generateForm('contactform'); - - # add forms to the content - $content = $this->originalHtml . $contactform; - } - } - - $html->setData($content); - $html->stopPropagation(); - } - } - */ -} \ No newline at end of file diff --git a/plugins/contactform/contactform.yaml b/plugins/contactform/contactform.yaml deleted file mode 100644 index 419fae0..0000000 --- a/plugins/contactform/contactform.yaml +++ /dev/null @@ -1,94 +0,0 @@ -name: ContactForm -version: 1.0.0 -description: Integrate a google like text-add into each content page (file). -author: Sebastian Schürmanns -homepage: https://typemill.net -licence: MIT - -settings: - message_success: "## Thank you!\r\n\r\nWe got your message and will answer as soon as possible." - message_error: "## Error\r\n\r\nWe could not send your message. Please send your e-mail manually." - -forms: - fields: - - mailto: - type: email - label: Your e-mail-address - required: true - - page_value: - type: text - label: Path to page where to include the form - placeholder: 'path/to/page' - required: true - - name_label: - type: text - label: Label for Name Input Field - required: true - - email_label: - type: text - label: Label for E-Mail-Field - required: true - - subject_label: - type: text - label: Label for Subject-Field - required: true - - message_label: - type: text - label: Label for Message - required: true - - button_label: - type: text - label: Label for Button - placeholder: 'Send Message' - required: true - - legalnotice: - type: textarea - rows: 5; - label: Text below button (use markdown) - placeholder: 'Add your legal text or other hints here' - - message_success: - type: textarea - rows: 5; - label: Message if mail is send (use markdown) - placeholder: 'Add your legal text or other hints here' - - message_error: - type: textarea - rows: 5; - label: Message if mail failed (use markdown) - placeholder: 'Add your legal text or other hints here' - -public: - fields: - - name: - type: text - label: name_label - required: true - - email: - type: email - label: email_label - required: true - - subject: - type: text - label: subject_label - required: true - - message: - type: textarea - label: message_label - required: true - - legalnotice: - type: paragraph \ No newline at end of file