-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,16 @@ | ||
monstra-cms-contact | ||
Contact | ||
=================== | ||
|
||
Simple contact plugin for Monstra CMS | ||
|
||
Usage: | ||
|
||
Shordcode for content | ||
``` | ||
{contact recipient="[email protected]"} | ||
``` | ||
|
||
Code for templates | ||
``` | ||
<?php Contact::display('[email protected]'); ?> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Contact 1.1.1, 2013-12-22 | ||
------------------------ | ||
- PHPMailer used | ||
- PSR coding fixes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
/** | ||
* Contact plugin | ||
* | ||
* @package Monstra | ||
* @subpackage Plugins | ||
* @author Romanenko Sergey / Awilum | ||
* @copyright 2012 - 2014 Romanenko Sergey / Awilum | ||
* @version 1.1.1 | ||
* | ||
*/ | ||
|
||
// Register plugin | ||
Plugin::register( __FILE__, | ||
__('Contact', 'contact'), | ||
__('Contact plugin for Monstra', 'contact'), | ||
'1.1.1', | ||
'Awilum', | ||
'http://monstra.org/'); | ||
|
||
/** | ||
* Shorcode: {contact recipient="[email protected]"} | ||
*/ | ||
Shortcode::add('contact', 'Contact::_shorcode'); | ||
|
||
/** | ||
* Usage: <?php Contact::display('[email protected]'); ?> | ||
*/ | ||
class Contact | ||
{ | ||
public static function _shorcode($attributes) | ||
{ | ||
return Contact::form($attributes['recipient']); | ||
} | ||
|
||
public static function form($recipient) | ||
{ | ||
$name = Request::post('contact_name'); | ||
$email = Request::post('contact_email'); | ||
$body = Request::post('contact_body'); | ||
|
||
$errors = array(); | ||
|
||
if (Request::post('contact_submit')) { | ||
|
||
if (Security::check(Request::post('csrf'))) { | ||
|
||
if (Request::post('contact_name') == '' || Request::post('contact_email') == '' || Request::post('contact_body') == '') { | ||
$errors['contact_empty_fields'] = __('Empty required fields!', 'contact'); | ||
} | ||
|
||
if ( ! Valid::email(Request::post('contact_email'))) { | ||
$errors['contact_email_not_valid'] = __('Email address is not valid!', 'contact'); | ||
} | ||
|
||
if (Option::get('captcha_installed') == 'true' && ! CryptCaptcha::check(Request::post('answer'))) { | ||
$errors['users_captcha_wrong'] = __('Captcha code is wrong', 'users'); | ||
} | ||
|
||
if (count($errors) == 0) { | ||
|
||
$mail = new PHPMailer(); | ||
$mail->SetFrom($email); | ||
$mail->AddReplyTo($email); | ||
$mail->AddAddress($recipient); | ||
$mail->Subject = $name; | ||
$mail->Body = $body; | ||
|
||
if ($mail->Send()) { | ||
Notification::set('success', __('A letter has been sent!', 'contact')); | ||
Request::redirect(Page::url()); | ||
} else { | ||
Notification::set('error', __('A Letter was not sent!', 'contact')); | ||
} | ||
|
||
} | ||
|
||
} else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } | ||
|
||
} | ||
|
||
return View::factory('contact/views/frontend/form') | ||
->assign('name', $name) | ||
->assign('email', $email) | ||
->assign('body', $body) | ||
->assign('errors', $errors) | ||
->render(); | ||
} | ||
|
||
public static function display($recipient) | ||
{ | ||
echo Contact::form($recipient); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<root> | ||
<plugin_location>plugins/contact/contact.plugin.php</plugin_location> | ||
<plugin_status>active</plugin_status> | ||
<plugin_priority>15</plugin_priority> | ||
<plugin_name>Contact</plugin_name> | ||
<plugin_description>Contact plugin for Monstra</plugin_description> | ||
<plugin_version>1.1.0</plugin_version> | ||
<plugin_author>Awilum</plugin_author> | ||
<plugin_author_uri>http://monstra.org/</plugin_author_uri> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
return array( | ||
'contact' => array( | ||
'Contact' => 'Contact', | ||
'Contact plugin for Monstra' => 'Contact plugin for Monstra', | ||
'Name' => 'Name', | ||
'Email' => 'Email', | ||
'Message' => 'Message', | ||
'Send' => 'Send', | ||
'Empty required fields!' => 'Empty required fields!', | ||
'Email address is not valid!' => 'Email address is not valid!', | ||
'A letter has been sent!' => 'A letter has been sent!', | ||
'A Letter was not sent!' => 'A Letter was not sent!', | ||
'Wrong captcha!' => 'Wrong captcha!', | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
return array( | ||
'contact' => array( | ||
'Contact' => 'Контакт', | ||
'Contact plugin for Monstra' => 'Плагин контакт для Монстра!', | ||
'Name' => 'Имя', | ||
'Email' => 'Емейл', | ||
'Message' => 'Сообщение', | ||
'Send' => 'Отправить', | ||
'Empty required fields!' => 'Пустые поля обязательные для заполнения!', | ||
'Email address is not valid!' => 'Адрес электронной почты не действителен!', | ||
'A letter has been sent!' => 'Письмо было отправлено!', | ||
'A Letter was not sent!' => 'Письмо не было отправлено!', | ||
'Wrong captcha!' => 'Неправильная капча!', | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?> | ||
<?php if (Notification::get('error')) Alert::error(Notification::get('error')); ?> | ||
<br /> | ||
<form method="post"> | ||
<?php echo (Form::hidden('csrf', Security::token())); ?> | ||
<label><?php echo __('Name', 'contact'); ?></label> | ||
<input type="text" name="contact_name" class="input-xlarge" value="<?php echo $name; ?>" /><br /> | ||
<label><?php echo __('Email', 'contact'); ?></label> | ||
<input type="text" name="contact_email" class="input-xlarge" value="<?php echo $email; ?>" /><br /> | ||
<label><?php echo __('Message', 'contact'); ?></label> | ||
<textarea class="input-xxlarge" rows="10" name="contact_body"><?php echo $body; ?></textarea><br /><br /> | ||
|
||
<?php if (Option::get('captcha_installed') == 'true') { ?> | ||
<label><?php echo __('Captcha', 'users'); ?><label> | ||
<input type="text" name="answer"><?php if (isset($errors['captcha_wrong'])) echo Html::nbsp(3).'<span class="error">'.$errors['captcha_wrong'].'</span>'; ?> | ||
<?php CryptCaptcha::draw(); ?> | ||
<?php } ?> | ||
|
||
<br /> | ||
<?php if (count($errors) > 0) { ?> | ||
<ul> | ||
<?php foreach ($errors as $error) { ?> | ||
<li><?php echo $error; ?></li> | ||
<?php } ?> | ||
</ul> | ||
<?php } ?> | ||
<input type="submit" class="btn" value="<?php echo __('Send', 'contact'); ?>" name="contact_submit"/> | ||
</form> |