Commit fa4b835f authored by Виталий Мурашко's avatar Виталий Мурашко

Merge branch 'master' of http://git.task-on.com/ktask/task-on.com

Conflicts:
	frontend/views/layouts/footer-index.php
parents 341ee21a 9d800725
......@@ -19,6 +19,7 @@ return [
'bids' => ['class' => 'common\modules\bids\Module'],
'faq' => ['class' => 'common\modules\faq\Module'],
'blog' => ['class' => 'common\modules\blog\Module'],
'sessions' => ['class' => 'common\modules\sessions\Module'],
'reviews' => ['class' => 'common\modules\reviews\Module'],
'users' => ['class' => 'common\modules\users\users'],
'testings' => ['class' => 'common\modules\testings\Module'],
......
......@@ -38,10 +38,10 @@ abstract class BaseController extends Controller
}
private function _initSession()
{
if(!Yii::$app->session->has('SessionData'))
{
$request = Yii::$app->request;
if($request->isGet && !$request->isAjax)
{
Yii::$app->session->set('SessionData', [$request->url, $request->referrer]);
}
}
......
......@@ -42,7 +42,9 @@ class Module extends \common\components\WebModule
public static function adminMenu()
{
return array(
'Новая запись' => '/blog/post-admin/create',
'Записи' => '/blog/post-admin/manage',
'Теги' => '/blog/tag-admin/manage',
);
}
}
......@@ -43,9 +43,11 @@ class TagBehavior extends Behavior
$tg = PostTag::find()->where(['name' => $tag])->one();
if(!$tg)
{
$tg = new PostTag;
$tg->name = $tag;
$tg->save();
// Убрана возможность создавать новые теги
return false;
// $tg = new PostTag;
// $tg->name = $tag;
// $tg->save();
}
$tgs = new PostTagAssign;
......
......@@ -5,9 +5,13 @@ namespace common\modules\blog\controllers;
use Yii;
use common\components\BaseController;
use yii\web\NotFoundHttpException;
use yii\web\Response;
use yii\widgets\ActiveForm;
use common\models\Settings;
use common\modules\blog\models\Post;
use common\modules\blog\models\PostTag;
use common\modules\blog\models\PostTagAssign;
/**
* PostController implements the CRUD actions for Post model.
......@@ -18,8 +22,10 @@ class PostController extends BaseController
{
return [
'Index' => 'Блог',
'Load' => 'Подгрузка записей',
'Tag' => 'Просмотр тега',
'View' => 'Просмотр записи',
'Send-article' => 'Послать статью',
];
}
......@@ -31,10 +37,11 @@ class PostController extends BaseController
{
$this->meta_title = Yii::t('menu', 'Blog') . ' - ' . \Yii::$app->params['name'];
$models = Post::find()->where(['active' => 1])->all();
$query = Post::find()->where(['active' => 1])->limit(Post::PAGE_SIZE)->orderBy('created_at DESC');
return $this->render('index', [
'models' => $models,
'models' => $query->all(),
'count' => $query->count(),
]);
}
......@@ -56,6 +63,7 @@ class PostController extends BaseController
return $this->render('tag', [
'model' => $model,
'count' => $model->getAllPosts()->count()
]);
}
......@@ -77,6 +85,115 @@ class PostController extends BaseController
]);
}
/**
* @return mixed
*/
public function actionLoad()
{
if(Yii::$app->request->isAjax)
{
$offset = Yii::$app->request->post('offset');
$tag = Yii::$app->request->post('tag');
Yii::$app->response->format = Response::FORMAT_JSON;
$query = Post::find()->where(['active' => 1])->orderBy(Post::tableName().'.created_at DESC');
if($tag)
{
$query = $query->joinWith('postTagAssigns')->andWhere([PostTagAssign::tableName().'.tag_id' => $tag]);
}
$models = $query->limit(Post::PAGE_SIZE)->offset($offset)->all();
$count = $query->count();
return [
'posts' => $this->renderPartial('_load', [
'models' => $models,
]),
'count' => (int)$count,
'offset' => $offset + Post::PAGE_SIZE
];
}
else
{
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* @return mixed
*/
public function actionSendArticle()
{
if(Yii::$app->request->isAjax)
{
Yii::$app->response->format = Response::FORMAT_JSON;
$model = $this->getModel();
$model->load(Yii::$app->request->post());
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);
}
catch (Exception $e)
{
}
return ['success' => true];
}
else
{
return ActiveForm::validate($model);
}
}
else
{
throw new NotFoundHttpException('The requested page does not exist.');
}
}
// Temp metod
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;
}
/**
* Finds the Post model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
......
<?php
namespace common\modules\blog\controllers;
use Yii;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\sessions\models\Session;
use common\modules\blog\models\SearchSession;
use common\modules\blog\models\Post;
/**
* StatisticsAdminController implements the CRUD actions for Session model.
*/
class StatisticsAdminController extends AdminController
{
public static function actionsTitles()
{
return [
'Manage' => 'Управление статистикой',
'View' => 'Просмотр тега',
];
}
/**
* Lists all Session models.
* @return mixed
*/
public function actionManage($id)
{
if (($model = Post::findOne($id)) === null)
{
throw new NotFoundHttpException('The requested page does not exist.');
}
$searchModel = new SearchSession();
$searchModel->blogUrl = '/blog/'.$model->url;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Session model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Finds the Session model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Session the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Session::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
<?php
namespace common\modules\blog\controllers;
use Yii;
use common\modules\blog\models\PostTag;
use common\modules\blog\models\SearchPostTag;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TagAdminController implements the CRUD actions for PostTag model.
*/
class TagAdminController extends AdminController
{
public static function actionsTitles(){
return [
'Manage' => 'Управление тегами',
'Create' => 'Добавление тега',
'Update' => 'Редактирование тега',
'Delete' => 'Удаление тега',
'View' => 'Просмотр тега',
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all PostTag models.
* @return mixed
*/
public function actionManage()
{
$searchModel = new SearchPostTag();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single PostTag model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new PostTag model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new PostTag();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing PostTag model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing PostTag model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['manage']);
}
/**
* Finds the PostTag model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return PostTag the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = PostTag::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
......@@ -9,6 +9,7 @@ use common\modules\blog\models\PostLang;
use common\modules\blog\models\PostTag;
use common\modules\users\models\User;
use common\models\MetaTags;
use common\modules\sessions\models\SessionUrl;
/**
* This is the model class for table "posts".
......@@ -28,6 +29,8 @@ class Post extends \common\components\ActiveRecordModel
const ACTIVE_FALSE = 0;
const ACTIVE_TRUE = 1;
const PAGE_SIZE = 2;
public static $active_title = [
self::ACTIVE_FALSE => 'Скрыта',
self::ACTIVE_TRUE => 'Доступна',
......@@ -183,6 +186,14 @@ class Post extends \common\components\ActiveRecordModel
return $this->hasOne(User::className(), ['id' => 'author_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getViews()
{
return SessionUrl::find()->where(['url' => '/blog/'.$this->url]);
}
public function getThumbnailUrl()
{
$path = pathinfo($this->preview);
......
......@@ -65,7 +65,22 @@ class PostTag extends \common\components\ActiveRecordModel
*/
public function getPosts()
{
return $this->hasMany(Post::className(), ['id' => 'post_id'])->viaTable('posts_tags_assign', ['tag_id' => 'id'])->where(['active' => 1]);
return $this->hasMany(Post::className(), ['id' => 'post_id'])
->viaTable('posts_tags_assign', ['tag_id' => 'id'])
->where(['active' => 1])
->orderBy(Post::tableName().'.created_at DESC')
->limit(Post::PAGE_SIZE);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getAllPosts()
{
return $this->hasMany(Post::className(), ['id' => 'post_id'])
->viaTable('posts_tags_assign', ['tag_id' => 'id'])
->where(['active' => 1])
->orderBy(Post::tableName().'.created_at DESC');
}
/**
......@@ -76,6 +91,26 @@ class PostTag extends \common\components\ActiveRecordModel
return $this->hasMany(PostTagAssign::className(), ['tag_id' => 'id']);
}
public function beforeDelete()
{
if (parent::beforeDelete())
{
if($this->assigns)
{
foreach ($this->assigns as $assign)
{
$assign->delete();
}
}
return true;
}
else
{
return false;
}
}
public function getUrl()
{
return Url::to(['/blog/tag/' . $this->name]);
......
<?php
namespace common\modules\blog\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\blog\models\PostTag;
/**
* SearchPostTag represents the model behind the search form about `common\modules\blog\models\PostTag`.
*/
class SearchPostTag extends PostTag
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'created_at', 'updated_at'], 'integer'],
[['name'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = PostTag::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}
<?php
namespace common\modules\blog\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\sessions\models\Session;
use common\modules\sessions\models\SessionUrl;
/**
* SearchSession represents the model behind the search form about `common\modules\sessions\models\Session`.
*/
class SearchSession extends Session
{
public $blogUrl;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'user_id', 'created_at'], 'integer'],
[['PHPSESSID', 'ip'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Session::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->joinWith('urls');
$query->select(['*', new \yii\db\Expression("SUM(".SessionUrl::tableName().".updated_at - ".SessionUrl::tableName().".created_at) as time")]);
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'user_id' => $this->user_id,
'created_at' => $this->created_at,
SessionUrl::tableName() . '.url' => $this->blogUrl
]);
$query->andFilterWhere(['like', 'PHPSESSID', $this->PHPSESSID])
->andFilterWhere(['like', 'ip', $this->ip]);
return $dataProvider;
}
}
......@@ -50,7 +50,7 @@ use common\modules\content\widgets\MetaTagsWidget;
],
'triggerKeys' => ['enter', 'space', 'tab'],
]
]); ?>
])->hint('Пожалуйста используйте только следующие тэги: “Реклама”, “Аналитика”, “Секреты бизнеса”,”Для души”, “Гаджеты”, “Разработка”, "АртПроект"'); ?>
<ul class="nav nav-pills">
<?php $c = 0; foreach ($model->getLangsHelper() as $i => $content) : $c++; ?>
......
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\SearchPost */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="post-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id') ?>
<?= $form->field($model, 'url') ?>
<?= $form->field($model, 'active') ?>
<?= $form->field($model, 'created_at') ?>
<?= $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use yii\grid\GridView;
......@@ -76,7 +77,16 @@ $this->params['breadcrumbs'][] = $this->title;
[
'class' => 'common\components\ColorActionColumn',
'template' => '{update} {delete}',
'template' => '{statistics} {update} {delete}',
'buttons' => [
'statistics' => function ($url, $model, $key) {
return '<a href="'.Url::toRoute(['/blog/statistics-admin/manage', 'id' => $model->id]).'">'.Html::beginTag('i', [
'title' => "Статистика",
'data-toggle' => 'tooltip',
'class' => 'fa fa-area-chart fa-lg'
]) . Html::endTag('i') . '</a>';
},
],
],
],
]); ?>
......
<?php
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
?>
<?php foreach ($models as $model) : ?>
<article class="article_short">
<a href="<?=Url::to(['/blog/'.$model->url])?>" class="article_short_title"><?=$model->lang->title?></a>
<div class="article_short_head">
<span class="article_short_date"><?=date('d.m.Y', $model->created_at)?></span>
<span class="article_short_view">
<?=$model->getViews()->count()?>
<div class="blog_toltip_left">Количество просмотров</div>
</span>
<!-- <ul class="article_short_social">
<li>
<a href="#"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_fb.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_tw.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_gp.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_t.png" height="30" width="30" alt=""></a>
</li>
</ul> -->
</div>
<div class="article_short_tags">
<?php foreach ($model->postTags as $tag) : ?>
<a href="<?=$tag->url;?>"># <?=$tag->name?></a>
<?php endforeach; ?>
</div>
<div class="article_short_txt">
<?php if($model->preview) :
echo Html::img($model->preview);
endif; ?>
<?=$model->lang->text?>
</div>
</article>
<?php endforeach; ?>
\ No newline at end of file
Имя Фамилия: <?=$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;
</div>
</div>
<!-- <div class="sidebar_module">
<div class="sidebar_module">
<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>
</a>
<a href="#" class="sidebar_btn">Послать статью</a>
<a href="#blog_form" class="sidebar_btn popup-form">Послать статью</a>
</div>
</div>
</div> -->
<?php $posts = Post::find();
if($model)
......
......@@ -15,7 +15,7 @@ use common\modules\bids\models\Bid;
$model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([
'action' => '/',
'action' => '/bids/bid/add',
'enableClientValidation' => false,
'options' => [
'class' => 'subsc_blog_form bids-form',
......
......@@ -3,6 +3,8 @@
use yii\helpers\Html;
use yii\helpers\Url;
use common\modules\blog\models\Post;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
......@@ -16,46 +18,21 @@ use yii\helpers\Url;
<h1><?=Yii::t('menu', 'Blog')?></h1>
<?php foreach ($models as $model) : ?>
<article class="article_short">
<a href="<?=Url::to(['/blog/'.$model->url])?>" class="article_short_title"><?=$model->lang->title?></a>
<div class="article_short_head">
<span class="article_short_date"><?=date('d.m.Y', $model->created_at)?></span>
<!-- <span class="article_short_view">
180
<div class="blog_toltip_left">Количество просмотров</div>
</span> -->
<!-- <ul class="article_short_social">
<li>
<a href="#"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_fb.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_tw.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_gp.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_t.png" height="30" width="30" alt=""></a>
</li>
</ul> -->
</div>
<div class="article_short_tags">
<?php foreach ($model->postTags as $tag) : ?>
<?=$this->render('_load', ['models' => $models])?>
<a href="<?=$tag->url;?>"># <?=$tag->name?></a>
<?php if($count > count($models)) : ?>
<?php endforeach; ?>
<div class="loaded">
</div>
<div class="article_short_txt">
<?php if($model->preview) :
echo Html::img($model->preview);
endif; ?>
<?=$model->lang->text?>
<div class="load-box">
<a href="#" class="sidebar_btn" id="load-post" data-offset="<?=Post::PAGE_SIZE?>" style="display:block; margin: 0 auto;">Загрузить еще</a>
<div class="loading-post"></div>
</div>
</article>
<?php endforeach; ?>
<br><br><br>
<?php endif; ?>
<?=$this->render('_subscribe', ['title' => 'Страница Блог'])?>
......@@ -68,6 +45,6 @@ use yii\helpers\Url;
</div>
</div>
<!-- <div class="end_keys_neft"></div> -->
<?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
......@@ -3,6 +3,8 @@
use yii\helpers\Html;
use yii\helpers\Url;
use common\modules\blog\models\Post;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
......@@ -16,46 +18,21 @@ use yii\helpers\Url;
<h1><?=Yii::t('app', 'Tag')?>: <?=$model->name;?></h1>
<?php foreach ($model->posts as $post) : ?>
<article class="article_short">
<a href="<?=Url::to(['/blog/'.$post->url])?>" class="article_short_title"><?=$post->lang->title?></a>
<div class="article_short_head">
<span class="article_short_date"><?=date('d.m.Y', $post->created_at)?></span>
<!-- <span class="article_short_view">
180
<div class="blog_toltip_left">Количество просмотров</div>
</span> -->
<!-- <ul class="article_short_social">
<li>
<a href="#"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_fb.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_tw.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_gp.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_t.png" height="30" width="30" alt=""></a>
</li>
</ul> -->
</div>
<div class="article_short_tags">
<?php foreach ($post->postTags as $tag) : ?>
<?=$this->render('_load', ['models' => $model->posts])?>
<a href="<?=$tag->url;?>"># <?=$tag->name?></a>
<?php if($count > count($model->posts)) : ?>
<?php endforeach; ?>
<div class="loaded">
</div>
<div class="article_short_txt">
<?php if($post->preview) :
echo Html::img($post->preview);
endif; ?>
<?=$post->lang->text?>
<div class="load-box">
<a href="#" class="sidebar_btn" id="load-post" data-offset="<?=Post::PAGE_SIZE?>" data-tag="<?=$model->id?>" style="display:block; margin: 0 auto;">Загрузить еще</a>
<div class="loading-post"></div>
</div>
</article>
<?php endforeach; ?>
<br><br><br>
<?php endif; ?>
<?=$this->render('_subscribe', ['title' => 'Тег: ' . $model->name])?>
......@@ -68,6 +45,6 @@ use yii\helpers\Url;
</div>
</div>
<!-- <div class="end_keys_neft"></div> -->
<?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?>
\ No newline at end of file
......@@ -17,10 +17,10 @@ use yii\helpers\Html;
<article class="article_short">
<div class="article_short_head">
<span class="article_short_date"><?=date('d.m.Y', $model->created_at)?></span>
<!-- <span class="article_short_view">
180
<span class="article_short_view">
<?=$model->getViews()->count()?>
<div class="blog_toltip_left">Количество просмотров</div>
</span> -->
</span>
<!-- <ul class="article_short_social">
<li>
<a href="#"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
......@@ -61,6 +61,6 @@ use yii\helpers\Html;
</div>
</div>
<!-- <div class="end_keys_neft"></div> -->
<?=$this->render('_modals')?>
<?=$this->render('@app/views/layouts/footer');?>
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\sessions\models\SearchSession */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Sessions';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="session-index">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
'PHPSESSID',
[
'attribute' => 'user_id',
'value' => function($model)
{
if($model->user_id)
{
return $model->user->surname.' '.$model->user->name;
}
return null;
}
],
'ip',
[
'header' => 'Общее время просмотра',
'value' => function($model)
{
return date('H:i:s', mktime(0, 0, $model->time));
}
],
// ['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\modules\sessions\models\Session */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Sessions', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="session-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'PHPSESSID',
'user_id',
'ip',
'created_at',
],
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="post-tag-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
$this->title = 'Create Post Tag';
$this->params['breadcrumbs'][] = ['label' => 'Post Tags', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-tag-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\blog\models\SearchPostTag */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Post Tags';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-tag-index">
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
'name',
[
'class' => 'common\components\ColorActionColumn',
'template' => '{update} {delete}',
],
],
]); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
$this->title = 'Update Post Tag: ' . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Post Tags', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="post-tag-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\PostTag */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Post Tags', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-tag-view">
<p>
<?= Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'name',
],
]) ?>
</div>
......@@ -12,7 +12,7 @@ class Module extends \common\components\WebModule
*/
public $controllerNamespace = 'common\modules\sessions\controllers';
public $menu_icons = 'fa fa-eye';
public $menu_icons = 'fa fa-area-chart';
/**
* @inheritdoc
......@@ -36,13 +36,13 @@ class Module extends \common\components\WebModule
public static function name()
{
return 'Управление сессиями';
return 'Статистика';
}
public static function adminMenu()
{
return array(
// 'Сессии' => '/sessions/post-admin/manage',
'Сессии' => '/sessions/statistics-admin/manage',
);
}
}
......@@ -7,6 +7,7 @@ use yii\web\Response;
use common\components\BaseController;
use common\modules\sessions\models\Session;
use common\modules\sessions\models\SessionUrl;
/**
* Default controller for the `sessions` module
......@@ -17,35 +18,100 @@ class DefaultController extends BaseController
{
return [
'Add' => 'Фиксация сессии',
'Update' => 'Фиксация пребывания на странице',
];
}
/**
* Renders the index view for the module
* @return string
* @return mixed
*/
public function actionAdd()
{
Yii::$app->response->format = Response::FORMAT_JSON;
if(!Yii::$app->session->has('Session'))
if(!Yii::$app->session->has('SessionId'))
{
list($url, $referrer) = Yii::$app->session->get('SessionData');
$session = $this->createSession();
}
else
{
$session = Session::findOne(Yii::$app->session->get('SessionId'));
if(!$session)
{
$session = $this->createSession();
}
}
if(!$session->user_id && !Yii::$app->user->isGuest)
{
$session->user_id = Yii::$app->user->id;
$session->save(false, ['user_id']);
}
list($url, $referer) = Yii::$app->session->get('SessionData');
$sUrl = new SessionUrl;
$sUrl->session_id = $session->id;
$sUrl->url = $url;
$sUrl->referer = $referer;
$sUrl->save();
return ['success' => true];
}
/**
* @return mixed
*/
public function actionUpdate()
{
Yii::$app->response->format = Response::FORMAT_JSON;
try
{
list($url, $referer) = Yii::$app->session->get('SessionData');
$url = SessionUrl::find()->where([
'url' => $url,
'referer' => $referer,
'session_id' => Yii::$app->session->get('SessionId')
])->orderBy('created_at DESC')->one();
if($url)
{
$url->save(false, ['updated_at']);
return ['success' => true];
}
return ['success' => false];
}
catch (Exception $e)
{
return ['error' => true];
}
}
/**
* @return Session
*/
private function createSession()
{
$request = Yii::$app->request;
$session = new Session;
$session->PHPSESSID = Yii::$app->session->id;
$session->ip = $request->userIP;
$session->url = $url;
$session->referer = $referrer;
if(!Yii::$app->user->isGuest)
{
$session->user_id = Yii::$app->user->id;
}
$session->save();
Yii::$app->session->set('Session', $session->id);
}
Yii::$app->session->set('SessionId', $session->id);
return ['success' => true];
return $session;
}
}
<?php
namespace common\modules\sessions\controllers;
use Yii;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\sessions\models\Session;
use common\modules\sessions\models\SearchSession;
use common\modules\sessions\models\SearchSessionUrl;
/**
* StatisticsAdminController implements the CRUD actions for Session model.
*/
class StatisticsAdminController extends AdminController
{
public static function actionsTitles()
{
return [
'Manage' => 'Управление статистикой',
'Details' => 'Подробная статистика',
'View' => 'Просмотр тега',
];
}
/**
* Lists all Session models.
* @return mixed
*/
public function actionManage()
{
$searchModel = new SearchSession();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Lists all Session models.
* @return mixed
*/
public function actionDetails($id)
{
$searchModel = new SearchSessionUrl();
$searchModel->session = $id;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('details', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Session model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Finds the Session model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Session the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Session::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
<?php
namespace common\modules\sessions\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\sessions\models\Session;
use common\modules\sessions\models\SessionUrl;
/**
* SearchSession represents the model behind the search form about `common\modules\sessions\models\Session`.
*/
class SearchSession extends Session
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'user_id', 'created_at'], 'integer'],
[['PHPSESSID', 'ip'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Session::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->select(['*', 'urls.time']);
$queryUrl = SessionUrl::find()
->select('session_id, SUM('.SessionUrl::tableName().'.updated_at - '.SessionUrl::tableName().'.created_at) as time')
->groupBy('session_id');
$query->leftJoin(['urls' => $queryUrl], 'urls.session_id = id');
// grid filtering conditions
$query->andFilterWhere([
't.id' => $this->id,
't.user_id' => $this->user_id,
't.created_at' => $this->created_at
]);
$query->andFilterWhere(['like', 't.PHPSESSID', $this->PHPSESSID])
->andFilterWhere(['like', 't.ip', $this->ip]);
return $dataProvider;
}
}
<?php
namespace common\modules\sessions\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\sessions\models\Session;
use common\modules\sessions\models\SessionUrl;
/**
* SearchSession represents the model behind the search form about `common\modules\sessions\models\Session`.
*/
class SearchSessionUrl extends SessionUrl
{
public $session;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'session_id', 'created_at', 'updated_at'], 'integer'],
[['referer', 'url'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = SessionUrl::find();
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'session_id' => $this->session,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
]);
$query->andFilterWhere(['like', 'url', $this->url])
->andFilterWhere(['like', 'referer', $this->referer]);
return $dataProvider;
}
}
......@@ -5,6 +5,8 @@ namespace common\modules\sessions\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use common\modules\users\models\User;
/**
* This is the model class for table "sessions".
*
......@@ -17,6 +19,8 @@ use yii\behaviors\TimestampBehavior;
*/
class Session extends \common\components\ActiveRecordModel
{
public $time;
/**
* @inheritdoc
*/
......@@ -53,7 +57,6 @@ class Session extends \common\components\ActiveRecordModel
return [
// [['PHPSESSID', 'ip', 'url'], 'required'],
[['user_id', 'created_at'], 'integer'],
[['url', 'referer'], 'string'],
[['PHPSESSID'], 'string', 'max' => 32],
[['ip'], 'string', 'max' => 15],
];
......@@ -69,8 +72,24 @@ class Session extends \common\components\ActiveRecordModel
'PHPSESSID' => 'Сессия',
'user_id' => 'Пользователь',
'ip' => 'IP',
'url' => 'Ссылка',
'created_at' => 'Дата добавления',
'time' => 'Общее время просмотра'
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUrls()
{
return $this->hasMany(SessionUrl::className(), ['session_id' => 'id']);
}
}
<?php
namespace common\modules\sessions\models;
use Yii;
use common\modules\sessions\models\Session;
/**
* This is the model class for table "sessions_url".
*
* @property integer $id
* @property integer $session_id
* @property string $url
* @property string $referer
* @property integer $created_at
* @property integer $updated_at
*
* @property Sessions $session
*/
class SessionUrl extends \common\components\ActiveRecordModel
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'sessions_url';
}
public function name()
{
return 'Посещения страниц';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['session_id'], 'required'],
[['session_id', 'created_at', 'updated_at'], 'integer'],
[['url', 'referer'], 'string'],
[['session_id'], 'exist', 'skipOnError' => true, 'targetClass' => Session::className(), 'targetAttribute' => ['session_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'session_id' => 'Сессия',
'url' => 'Адрес страницы',
'referer' => 'Реферер',
'created_at' => 'Дата посещения',
'updated_at' => 'Дата обновления',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getSession()
{
return $this->hasOne(Session::className(), ['id' => 'session_id']);
}
// Время пребывания на странице в секундах
public function getTime()
{
return $this->updated_at - $this->created_at;
}
}
<?php
use yii\helpers\Url;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\sessions\models\SearchSession */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="session-index">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'session_id',
'value' => function($model)
{
$session = '';
if($model->session->user_id)
{
$session .= $model->session->user->surname.' '.$model->session->user->name . ' / ';
}
$session .= $model->session->PHPSESSID;
return $session;
}
],
'url',
'referer',
[
'header' => 'Время просмотра',
'value' => function($model)
{
return date('H:i:s', mktime(0, 0, $model->time));
}
],
],
]); ?>
</div>
<?php
use yii\helpers\Url;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\sessions\models\SearchSession */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Sessions';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="session-index">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
'PHPSESSID',
[
'attribute' => 'user_id',
'value' => function($model)
{
if($model->user_id)
{
return $model->user->surname.' '.$model->user->name;
}
return null;
}
],
'ip',
[
'header' => 'Уник URL',
'value' => function($model)
{
return count($model->urls);
}
],
[
'attribute' => 'time',
'value' => function($model)
{
return date('H:i:s', mktime(0, 0, $model->time));
}
],
[
'class' => 'common\components\ColorActionColumn',
'template' => '{statistics}',
'buttons' => [
'statistics' => function ($url, $model, $key) {
return '<a href="'.Url::toRoute(['/sessions/statistics-admin/details', 'id' => $model->id]).'">'.Html::beginTag('i', [
'title' => "Подробная статистика",
'data-toggle' => 'tooltip',
'class' => 'fa fa-area-chart fa-lg'
]) . Html::endTag('i') . '</a>';
},
],
],
],
]); ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\modules\sessions\models\Session */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Sessions', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="session-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'PHPSESSID',
'user_id',
'ip',
'created_at',
],
]) ?>
</div>
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160220_060520_update_sessions extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->dropColumn('sessions', 'url');
$this->dropColumn('sessions', 'referer');
$this->createTable('sessions_url', [
'id' => Schema::TYPE_PK,
'session_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'url' => 'text DEFAULT NULL',
'referer' => 'text DEFAULT NULL',
'created_at' => Schema::TYPE_INTEGER . '(11) DEFAULT NULL',
'updated_at' => Schema::TYPE_INTEGER . '(11) DEFAULT NULL',
]);
$this->truncateTable('sessions');
$this->addForeignKey(
'fk_sessions_url_session_id_sessions_id',
'sessions_url', 'session_id',
'sessions', 'id'
);
}
public function safeDown()
{
$this->addColumn('sessions', 'url', 'text DEFAULT NULL AFTER `ip`');
$this->addColumn('sessions', 'referer', 'text DEFAULT NULL AFTER `url`');
$this->dropForeignKey('fk_sessions_url_session_id_sessions_id', 'sessions_url');
$this->dropTable('sessions_url');
}
}
......@@ -17,7 +17,7 @@ use common\modules\bids\models\Bid;
$model->form = Bid::FORM_CALLBACK;
$form = ActiveForm::begin([
'action' => '/',
'action' => '/bids/bid/add',
'enableClientValidation' => false,
'options' => [
'class' => 'valid_form bids-form',
......
......@@ -48,7 +48,7 @@ $more = CoContent::find()
$model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([
'action' => '/',
'action' => '/bids/bid/add',
'enableClientValidation' => false,
'options' => [
'class' => 'subsc_form bids-form',
......
......@@ -15,7 +15,7 @@ use common\modules\bids\models\Bid;
$model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([
'action' => '/',
'action' => '/bids/bid/add',
'enableClientValidation' => false,
'options' => [
'class' => 'keys_mail_form bids-form',
......
......@@ -24,5 +24,5 @@
<?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/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 ]);?>
\ No newline at end of file
......@@ -26,7 +26,7 @@ FileUploadBundle::register($this);
$form = ActiveForm::begin([
'id' => 'form_foot',
'action' => '/',
'action' => '/bids/bid/add',
'enableClientValidation' => false,
'options' => [
......
......@@ -90,7 +90,7 @@ FileUploadBundle::register($this);
$form = ActiveForm::begin([
'id' => 'form_foot',
'action' => '/',
'action' => '/bids/bid/add',
'enableClientValidation' => false,
'options' => [
'class' => 'sect_cont_form bids-form',
......
......@@ -174,6 +174,200 @@ a.toggle_bottom:hover .icon-arrowDown2:after, a.toggle_bottom:active .icon-arrow
.bx-wrapper .bx-pager.bx-default-pager a.active {
background: url(../images/elips_active.png) no-repeat center center;
}
.loading-post {
background: url(../images/post-loader.gif) no-repeat;
width: 32px;
height: 32px;
margin: 0 auto;
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) {
.article_short_txt img {
......
......@@ -15,7 +15,7 @@ $('form.bids-form').on('beforeSubmit', function(e) {
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.send(data);
......
......@@ -6,8 +6,51 @@ $(document).ready(function() {
return false;
});
$('a#load-post').click(function() {
var button = $(this), loading = $('.loading-post'), offset = button.data('offset'), tag = button.data('tag');
button.hide();
loading.show();
$.ajax({
method: 'POST',
url: "/blog/post/load",
data: {
offset: offset,
tag: tag
},
success: function(response)
{
$('.loaded').append(response.posts);
button.data('offset', response.offset);
if(response.count <= response.offset)
{
button.hide();
}
else
{
button.show();
}
loading.hide();
}
});
return false;
});
$.ajax({
url: "/sessions/default/add"
});
setInterval(function(){
$.ajax({
url: "/sessions/default/update"
});
}, 1000 * 60 * 5);
});
\ No newline at end of file
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