Активировать формы в блоге

parent a7ec3a99
...@@ -6,7 +6,9 @@ use Yii; ...@@ -6,7 +6,9 @@ use Yii;
use common\components\BaseController; use common\components\BaseController;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\web\Response; use yii\web\Response;
use yii\widgets\ActiveForm;
use common\models\Settings;
use common\modules\blog\models\Post; use common\modules\blog\models\Post;
use common\modules\blog\models\PostTag; use common\modules\blog\models\PostTag;
use common\modules\blog\models\PostTagAssign; use common\modules\blog\models\PostTagAssign;
...@@ -23,6 +25,7 @@ class PostController extends BaseController ...@@ -23,6 +25,7 @@ class PostController extends BaseController
'Load' => 'Подгрузка записей', 'Load' => 'Подгрузка записей',
'Tag' => 'Просмотр тега', 'Tag' => 'Просмотр тега',
'View' => 'Просмотр записи', 'View' => 'Просмотр записи',
'Send-article' => 'Послать статью',
]; ];
} }
...@@ -43,7 +46,46 @@ class PostController extends BaseController ...@@ -43,7 +46,46 @@ class PostController extends BaseController
} }
/** /**
* Displays all Post models. * Displays a single Post model.
* @param string $url
* @return mixed
*/
public function actionTag($tag)
{
$model = PostTag::find()->where(['name' => $tag])->one();
if(!$model || !$model->posts)
{
throw new NotFoundHttpException('The requested page does not exist.');
}
$this->meta_title = Yii::t('app', 'Tag') . ': ' . $model->name . ' - ' . \Yii::$app->params['name'];
return $this->render('tag', [
'model' => $model,
'count' => $model->getAllPosts()->count()
]);
}
/**
* Displays a single Post model.
* @param string $url
* @return mixed
*/
public function actionView($url)
{
$model = $this->findModelByUrl($url);
$this->meta_title = $model->metaTag->title . ' - ' . \Yii::$app->params['name'];
$this->meta_description = $model->metaTag->description;
$this->meta_keywords = $model->metaTag->keywords;
return $this->render('view', [
'model' => $model,
]);
}
/**
* @return mixed * @return mixed
*/ */
public function actionLoad() public function actionLoad()
...@@ -80,43 +122,76 @@ class PostController extends BaseController ...@@ -80,43 +122,76 @@ class PostController extends BaseController
} }
/** /**
* Displays a single Post model.
* @param string $url
* @return mixed * @return mixed
*/ */
public function actionTag($tag) public function actionSendArticle()
{ {
$model = PostTag::find()->where(['name' => $tag])->one(); if(Yii::$app->request->isAjax)
if(!$model || !$model->posts)
{ {
throw new NotFoundHttpException('The requested page does not exist.'); Yii::$app->response->format = Response::FORMAT_JSON;
}
$this->meta_title = Yii::t('app', 'Tag') . ': ' . $model->name . ' - ' . \Yii::$app->params['name']; $model = $this->getModel();
return $this->render('tag', [ $model->load(Yii::$app->request->post());
'model' => $model,
'count' => $model->getAllPosts()->count() if($model->validate())
{
try
{
$email = 'Levshin@kupitsite.ru';
$message = $this->renderPartial('_mail', [
'model' => $model
]); ]);
$headers = "MIME-Version: 1.0\r\n".
"Content-Transfer-Encoding: 8bit\r\n".
"Content-Type: text/html; charset=\"UTF-8\"\r\n".
"X-Mailer: PHP v.".phpversion()."\r\n".
"From: Блог на task-on.com <".Settings::getValue('bids-support-email-from').">\r\n";
switch ($model->form)
{
case 'theme':
$subject = "Блог. Предложить тему";
break;
case 'article':
$subject = "Блог. Статья";
break;
} }
/** @mail($email, $subject, $message, $headers);
* Displays a single Post model. }
* @param string $url catch (Exception $e)
* @return mixed
*/
public function actionView($url)
{ {
$model = $this->findModelByUrl($url); }
$this->meta_title = $model->metaTag->title . ' - ' . \Yii::$app->params['name']; return ['success' => true];
$this->meta_description = $model->metaTag->description; }
$this->meta_keywords = $model->metaTag->keywords; else
{
return ActiveForm::validate($model);
}
}
else
{
throw new NotFoundHttpException('The requested page does not exist.');
}
}
return $this->render('view', [ // Temp metod
'model' => $model, public function getModel()
{
$model = new \yii\base\DynamicModel([
'name', 'email', 'message', 'form'
]); ]);
$model->addRule(['name', 'email', 'message'], 'required')
->addRule(['email'], 'email')
->addRule(['message', 'name', 'form'], 'string');
return $model;
} }
/** /**
......
Имя Фамилия: <?=$model->name?><br>
Email: <?=$model->email?><br>
<hr>
<?=$model->message?>
\ No newline at end of file
<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\modules\bids\models\Bid;
?>
<div class="hidden">
<div id="blog_form" class="popup popup_2 blog_form">
<span class="popup__title">Предложить тему для блога</span>
<?php
$model = \Yii::$app->controller->getModel();
$model->form = 'article';
$form = ActiveForm::begin([
'action' => '/blog/post/send-article',
'enableClientValidation' => false,
'options' => [
'class' => 'valid_form bids-form blog-form',
'data-title' => 'Предложить тему для блога',
'data-form' => 'Предложить тему для блога',
'data-tag' => Bid::TAG_TREATMENT
],
]); ?>
<?php echo $form->field($model, 'form', ['template' => '{input}'])->hiddenInput(['class' => 'not_clear']); ?>
<div class="blog_form_left form_resp">
<div>
<?php echo $form->field($model, 'name')->textInput([
'placeholder' => 'Имя Фамилия',
'class' => 'input_st'
])->label(false); ?>
<?php echo $form->field($model, 'email')->textInput([
'placeholder' => 'E-mail',
'class' => 'input_st'
])->label(false); ?>
</div>
</div>
<div class="blog_form_right form_resp">
<p><strong>Вы можете предложить статью для публикации или написать нам о том, что бы было интересно почитать.</strong></p>
<p><strong>Мы с радостью поделимся своим опытом и напишем интересную статью.</strong></p>
</div>
<div class="blog_lmg">
<img src="/images/blog_form_img.png" height="123" width="118" alt="">
</div>
<div class="clear"></div>
<br>
<?php echo $form->field($model, 'message')->textArea([
'placeholder' => 'Что хочу почитать?
Например: Хочу почитать про то, как настраивается контекстная реклама.
Про то как выставляются ставки.',
'class' => 'sect_cont_form__textarea'
])->label(false); ?>
<div class="clear"></div>
<?php echo Html::submitButton('Предложить тему', ['class' => 'save-button btn-default button-lg']); ?>
<?php ActiveForm::end(); ?>
</div>
<div id="blog_form_2" class="popup popup_2 blog_form_2">
<!-- <div class="txtbtnclose">Закрыть</div> -->
<span class="popup__title">Предложить тему для блога</span>
<p><strong>Мы готовы бесплатно поделиться накопленным опытом, если вы сообщите тему которая вас интересует</strong></p>
<br>
<?php
$model = \Yii::$app->controller->getModel();
$model->form = 'theme';
$form = ActiveForm::begin([
'action' => '/blog/post/send-article',
'enableClientValidation' => false,
'options' => [
'class' => 'valid_form bids-form blog-form',
'data-title' => 'Предложить тему для блога',
'data-form' => 'Предложить тему для блога',
'data-tag' => Bid::TAG_TREATMENT
],
]); ?>
<?php echo $form->field($model, 'form', ['template' => '{input}'])->hiddenInput(['class' => 'not_clear']); ?>
<div class="blog_form_left50 form_resp">
<div>
<?php echo $form->field($model, 'name')->textInput([
'placeholder' => 'Имя Фамилия',
'class' => 'input_st'
])->label(false); ?>
</div>
</div>
<div class="blog_form_right50 form_resp">
<?php echo $form->field($model, 'email')->textInput([
'placeholder' => 'E-mail',
'class' => 'input_st'
])->label(false); ?>
</div>
<div class="clear"></div>
<?php echo $form->field($model, 'message')->textArea([
'placeholder' => 'Что хочу почитать?
Например: Хочу почитать про то, как настраивается контекстная реклама.
Про то как выставляются ставки.',
'class' => 'sect_cont_form__textarea'
])->label(false); ?>
<div class="clear"></div>
<?php echo Html::submitButton('Предложить тему', ['class' => 'save-button btn-default button-lg']); ?>
<?php ActiveForm::end(); ?>
</div>
</div>
<style>
.blog-form input,
.blog-form textarea {
margin-bottom: 10px !important;
}
</style>
\ No newline at end of file
...@@ -29,15 +29,15 @@ use common\models\Settings; ...@@ -29,15 +29,15 @@ use common\models\Settings;
</div> </div>
</div> </div>
<!-- <div class="sidebar_module"> <div class="sidebar_module">
<div class="sidebar_module_body"> <div class="sidebar_module_body">
<a href="#" class="sidebar_btn"> <a href="#blog_form_2" class="sidebar_btn popup-form">
Предложить тему Предложить тему
<div class="blog_toltip_right">Предложите свою тему и мы напишем</div> <div class="blog_toltip_right">Предложите свою тему и мы напишем</div>
</a> </a>
<a href="#" class="sidebar_btn">Послать статью</a> <a href="#blog_form" class="sidebar_btn popup-form">Послать статью</a>
</div>
</div> </div>
</div> -->
<?php $posts = Post::find(); <?php $posts = Post::find();
if($model) if($model)
......
...@@ -15,7 +15,7 @@ use common\modules\bids\models\Bid; ...@@ -15,7 +15,7 @@ use common\modules\bids\models\Bid;
$model->form = Bid::FORM_SUBSCRIBE; $model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'action' => '/', 'action' => '/bids/bid/add',
'enableClientValidation' => false, 'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'subsc_blog_form bids-form', 'class' => 'subsc_blog_form bids-form',
......
...@@ -45,6 +45,6 @@ use common\modules\blog\models\Post; ...@@ -45,6 +45,6 @@ use common\modules\blog\models\Post;
</div> </div>
</div> </div>
<!-- <div class="end_keys_neft"></div> --> <?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?> <?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
...@@ -45,6 +45,6 @@ use common\modules\blog\models\Post; ...@@ -45,6 +45,6 @@ use common\modules\blog\models\Post;
</div> </div>
</div> </div>
<!-- <div class="end_keys_neft"></div> --> <?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?> <?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
...@@ -61,6 +61,6 @@ use yii\helpers\Html; ...@@ -61,6 +61,6 @@ use yii\helpers\Html;
</div> </div>
</div> </div>
<!-- <div class="end_keys_neft"></div> --> <?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?> <?=$this->render('@app/views/layouts/footer');?>
...@@ -17,7 +17,7 @@ use common\modules\bids\models\Bid; ...@@ -17,7 +17,7 @@ use common\modules\bids\models\Bid;
$model->form = Bid::FORM_CALLBACK; $model->form = Bid::FORM_CALLBACK;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'action' => '/', 'action' => '/bids/bid/add',
'enableClientValidation' => false, 'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'valid_form bids-form', 'class' => 'valid_form bids-form',
......
...@@ -48,7 +48,7 @@ $more = CoContent::find() ...@@ -48,7 +48,7 @@ $more = CoContent::find()
$model->form = Bid::FORM_SUBSCRIBE; $model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'action' => '/', 'action' => '/bids/bid/add',
'enableClientValidation' => false, 'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'subsc_form bids-form', 'class' => 'subsc_form bids-form',
......
...@@ -15,7 +15,7 @@ use common\modules\bids\models\Bid; ...@@ -15,7 +15,7 @@ use common\modules\bids\models\Bid;
$model->form = Bid::FORM_SUBSCRIBE; $model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'action' => '/', 'action' => '/bids/bid/add',
'enableClientValidation' => false, 'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'keys_mail_form bids-form', 'class' => 'keys_mail_form bids-form',
......
...@@ -24,5 +24,5 @@ ...@@ -24,5 +24,5 @@
<?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/jquery.form.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/jquery.form.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/bids-form.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/connect-form.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/custom.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/custom.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file
...@@ -22,7 +22,7 @@ use common\modules\bids\models\Bid; ...@@ -22,7 +22,7 @@ use common\modules\bids\models\Bid;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'id' => 'form_foot', 'id' => 'form_foot',
'action' => '/', 'action' => '/bids/bid/add',
'enableClientValidation' => false, 'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'footer_form bids-form', 'class' => 'footer_form bids-form',
......
...@@ -86,7 +86,7 @@ use \common\modules\bids\models\Bid; ...@@ -86,7 +86,7 @@ use \common\modules\bids\models\Bid;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'id' => 'form_foot', 'id' => 'form_foot',
'action' => '/', 'action' => '/bids/bid/add',
'enableClientValidation' => false, 'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'sect_cont_form bids-form', 'class' => 'sect_cont_form bids-form',
......
...@@ -182,6 +182,193 @@ a.toggle_bottom:hover .icon-arrowDown2:after, a.toggle_bottom:active .icon-arrow ...@@ -182,6 +182,193 @@ a.toggle_bottom:hover .icon-arrowDown2:after, a.toggle_bottom:active .icon-arrow
display: none; display: none;
} }
/* ------------ BLOG MODAL ------------------ */
.clear {
clear: both;
}
.support_form {
width: 760px;
padding: 30px;
padding-bottom: 40px;
color: #525252;
}
.popup_2 .popup__title {
font-size: 38px;
font-weight: bold;
color: #344555;
text-align: left;
}
.support_form_left {
width: 45%;
float: left;
padding-right: 15px;
}
.support_form_right {
width: 55%;
float: right;
padding-left: 15px;
}
.popup_2 p {
font-size: 17px;
color: #525252;
line-height: 22px;
font-weight: 400;
}
.support_form .support_block__link_pv {
margin-top: 10px;
}
.popup_2 input:not([type="radio"]):not([type="checkbox"]){
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
width: 100%;
}
.popup_2 input {
margin-bottom: 10px;
}
.popup_2 input:not(:last-child) {
margin-bottom: 30px;
}
.popup_2 .checkbox:not(checked) + label {
position: relative;
padding: 6px 0px 0px 28px;
margin-bottom: 30px;
}
.popup_2 label {
margin-bottom: 10px;
}
.support_form_left2 {
float: left;
width: 50%;
padding-right: 15px;
}
.support_form_right2 {
float: right;
width: 50%;
padding-left: 15px;
margin-bottom: 30px;
}
.popup_2 .sect_cont_form__textarea {
background-color: #f1f1f1;
height: 170px;
width: 100%;
line-height: 24px;
resize: none;
}
.file-upload_block_cs2 {
height: 170px;
background-color: #f8f8f8;
padding-top: 30px;
border: 2px solid #f1f1f1;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
}
.file-upload_block_cs2 .filename_cs {
background-color: #f8f8f8;
margin-bottom: 0px !important;
}
.button-lg {
padding-left: 30px;
padding-right: 30px;
width: auto;
}
.blog_form {
width: 820px;
padding: 30px;
padding-bottom: 40px;
color: #525252;
}
.blog_form_left {
width: 280px;
float: left;
padding-right: 18px;
}
.blog_form_right {
width: 340px;
float: left;
font-size: 15px;
}
.blog_form_right p {
font-size: 15px;
}
.blog_lmg {
float: right;
}
.blog_form_2 {
width: 670px;
padding: 30px;
padding-bottom: 40px;
color: #525252;
}
.blog_form_left50 {
float: left;
width: 50%;
padding-right: 15px;
}
.blog_form_right50 {
float: right;
width: 50%;
padding-left: 15px;
}
@media only screen and (max-width: 992px) {
.blog_form_2, .blog_form, .support_form {
width: 100%;
height: auto;
}
.popup_2 .popup__title {
font-size: 32px;
}
}
@media only screen and (max-width: 820px) {
.blog_lmg {
display: none;
}
}
@media only screen and (max-width: 767px) {
.form_resp {
float: none;
width: 100%;
padding-left: 0;
padding-right: 0;
}
.support_form_right {
margin-bottom: 20px;
}
}
@media only screen and (max-width: 479px) {
.popup_2 .popup__title {
font-size: 22px;
}
.blog_form_right {
width: 100%;
}
}
/* ------------ BLOG MODAL ------------------ */
@media (min-width: 970px) { @media (min-width: 970px) {
.article_short_txt img { .article_short_txt img {
width: auto !important; width: auto !important;
......
...@@ -15,7 +15,7 @@ $('form.bids-form').on('beforeSubmit', function(e) { ...@@ -15,7 +15,7 @@ $('form.bids-form').on('beforeSubmit', function(e) {
data.append("Bid[file]", file); data.append("Bid[file]", file);
} }
xhr.open("POST", '/bids/bid/add', true); xhr.open("POST", form.attr('action'), true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(data); xhr.send(data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment