From 812220ed8ebec4a99d41ae92e2b6b4b770d0b133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Wed, 14 May 2014 14:14:45 +0200 Subject: [PATCH] Added Contactform on Aboutpage --- .idea/workspace.xml | 423 ++++++++++--------- www/protected/controllers/SiteController.php | 35 +- www/protected/models/SendMailForm.php | 59 +++ www/protected/views/site/about.php | 109 ++--- 4 files changed, 366 insertions(+), 260 deletions(-) create mode 100644 www/protected/models/SendMailForm.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index eb5501b..346d52c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,13 +2,13 @@ + - - + @@ -62,89 +62,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -160,11 +78,12 @@ @@ -246,6 +165,7 @@ + @@ -366,7 +286,7 @@ @@ -434,7 +354,6 @@ - @@ -453,7 +372,7 @@ - + @@ -483,17 +402,25 @@ - + - - - - + + + + + + + + + + + + @@ -530,7 +457,7 @@ - + @@ -538,11 +465,11 @@ - - + + - - + + @@ -572,17 +499,125 @@ - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -592,58 +627,36 @@ - - - + - - - + - - - + - - - - - - - - - - - - - + - - - + - - - + @@ -673,16 +686,7 @@ - - - - - - - - - - + @@ -692,144 +696,143 @@ - - - + - - - + - - - - - - - - - - + - - - + - - - + - - - + - - - + - - - + - - - + - - - + - + - + - + - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + - + - - - + + + - + - - - - - - - - + diff --git a/www/protected/controllers/SiteController.php b/www/protected/controllers/SiteController.php index b21f660..645505b 100644 --- a/www/protected/controllers/SiteController.php +++ b/www/protected/controllers/SiteController.php @@ -22,6 +22,39 @@ class SiteController extends Controller public function actionAbout() { - $this->render('about'); + $data = array(); + + if(isset($_POST['SendMailForm'])) + { + $model = new SendMailForm(); + + $model->attributes=$_POST['SendMailForm']; + + if($model->validate()) { + if ($model->send()) + { + $data['alerts_success'][] = "Successfully send mail from " . $model->name; + $data['model'] = new SendMailForm(); + } + else + { + $data['alerts_error'][] = "Internal error while sending mail"; + $data['model'] = $model; + } + + } + else + { + $data['model'] = $model; + } + } + else + { + $data['model'] = new SendMailForm(); + } + + + + $this->render('about', $data); } } \ No newline at end of file diff --git a/www/protected/models/SendMailForm.php b/www/protected/models/SendMailForm.php new file mode 100644 index 0000000..bf7661d --- /dev/null +++ b/www/protected/models/SendMailForm.php @@ -0,0 +1,59 @@ +3, 'max'=>128), + array('email', 'length', 'min'=>5, 'max'=>128), + array('header', 'length', 'min'=>0, 'max'=>200), + array('message', 'length', 'min'=>1, 'max'=>20000), + ); + } + + public function send() { + $Software = getenv("SERVER_SOFTWARE"); + $ip = getenv("REMOTE_ADDR"); + $date = date('Y-m-d G:i:s'); + $Browser = $_SERVER['HTTP_USER_AGENT']; + + $empfaenger = "kundenservice@mikescher.de"; + $betreff = "Neue Mail für Mikescher.de vom Typ Kontaktformular ($this->header)"; + $text = +" +Name: $this->name + +Typ : Kontaktformular + +IP: $ip + +Datum: $date + +E-Mail: $this->email + +Software: $Software + +Browser: $Browser + +Header: $this->header + +Text: $this->message +"; + + if (! (empty($name) && empty($textin) && empty($typ) && empty($link) && empty($email)) ) + { + return mail($empfaenger, $betreff, $text,"From: Mikescher "); + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/www/protected/views/site/about.php b/www/protected/views/site/about.php index f1b4bac..b1a0bf0 100644 --- a/www/protected/views/site/about.php +++ b/www/protected/views/site/about.php @@ -14,61 +14,72 @@ $this->selectedNav = 'about';
+ + + +
+

Welcome to my private homepage.

-

Welcome to my private homepage.

+

My name is Mike Schwörer, and this is my homepage - here i upload programs i write in my free time and sometimes i even write a blog entry ...');

-

My name is Mike Schwörer, and this is my homepage - here i upload programs i write in my free time and sometimes i even write a blog entry ...');

+

If you want you can look at the things I programmed

+
-

If you want you can look at the things I programmed

+
+ beginWidget('bootstrap.widgets.TbActiveForm', + [ + 'layout' => TbHtml::FORM_LAYOUT_HORIZONTAL + ]); + ?> + +
+ Contact + textFieldControlGroup($model, 'name', + [ + 'placeholder' => 'Name', + 'size' => TbHtml::INPUT_SIZE_XXLARGE, + 'prepend' => TbHtml::icon(TbHtml::ICON_USER), + 'span' => 2, + ]); + echo $form->textFieldControlGroup($model, 'email', + [ + 'placeholder' => 'Email address', + 'size' => TbHtml::INPUT_SIZE_XXLARGE, + 'prepend' => TbHtml::icon(TbHtml::ICON_ENVELOPE), + 'span' => 2, + ]); + echo $form->textFieldControlGroup($model, 'header', + [ + 'placeholder' => 'Header', + 'size' => TbHtml::INPUT_SIZE_XXLARGE, + 'prepend' => TbHtml::icon(TbHtml::ICON_TAG), + 'span' => 5, + ]); + echo $form->textAreaControlGroup( $model, 'message', + [ + 'placeholder' => 'Message', + 'size' => TbHtml::INPUT_SIZE_XXLARGE, + 'rows' => 10, + ]); + ?> +
+ + TbHtml::BUTTON_COLOR_PRIMARY)), + TbHtml::resetButton('Reset'), + ], + [ + 'class' => 'cstm-background-white', + ]); ?> + + endWidget(); ?> +
- beginWidget('bootstrap.widgets.TbActiveForm', array('layout' => TbHtml::FORM_LAYOUT_HORIZONTAL)); ?> - -
-
- Contact Me - - 'Name:', - 'placeholder' => 'Name' - ]); - - echo TbHtml::textFieldControlGroup('email', '', - [ - 'label' => 'Email address:', - 'placeholder' => 'Email' - ]); - - echo TbHtml::textFieldControlGroup('header', '', - [ - 'label' => 'Title:', - 'placeholder' => 'Header' - ]); - - echo TbHtml::textAreaControlGroup('text', '', - [ - 'label' => 'Message:', - 'rows' => 6 - ]); - ?> - -
- - TbHtml::BUTTON_COLOR_PRIMARY)), - TbHtml::resetButton('Reset'), - ], - [ - 'class' => 'cstm-background-white', - ]); - ?> - - endWidget(); ?> -
\ No newline at end of file