Commit b4623caf authored by Олег Гиммельшпах's avatar Олег Гиммельшпах

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

parents f5dd6f30 fc960103
......@@ -46,6 +46,7 @@ class Module extends \common\components\WebModule
{
return [
'Управление курсами' => '/analyticsSchool/courses-admin/manage',
'Управление уроками' => '/analyticsSchool/lesson-admin/manage',
];
}
}
<?php
namespace common\modules\analyticsSchool\controllers;
use common\components\FrontendController;
use common\modules\analyticsSchool\models\CoursesSearch;
use yii\filters\AccessControl;
class CourseController extends FrontendController {
public static function actionsTitles() {
return [
'Index' => 'Школа аналитики'
];
}
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'user' => 'support',
'only' => ['view', 'index'],
'rules' => [
[
'allow' => true,
'actions' => ['view', 'index'],
'roles' => ['?'],
],
],
],
];
}
public function actionIndex(){
$searchModel = new CoursesSearch();
$search = \Yii::$app->request->queryParams;
$dataProvider = $searchModel->search($search);
return $this->render(
'index',
[
'dataProvider' => $dataProvider
]
);
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ class AnalyticsSchoolCourse extends \common\components\ActiveRecordModel
[['name','status'], 'required'],
[['status'], 'integer'],
[['description', 'image'], 'string'],
[['uploadedImage'], 'file', 'extensions' => ['jpg', 'jpeg', 'png']],
[['uploadedImage'], 'file', 'extensions' => ['jpg', 'jpeg', 'png'],'checkExtensionByMimeType'=>false],
[['name'], 'string', 'max' => 255],
];
}
......
<?php
/**
* Created by PhpStorm.
* User: PHOENIX
* Date: 18.04.16
* Time: 16:59
*/
namespace common\modules\analyticsSchool\models;
use yii\base\Model;
use yii\data\ActiveDataProvider;
class CoursesSearch extends AnalyticsSchoolCourse {
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id'], 'integer'],
[['description', 'name', 'image'], '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)
{
if (count($params)>0){
$params = array_filter($params);
$query = AnalyticsSchoolCourse::findByCondition($params);
}
else {
$query = AnalyticsSchoolCourse::find();
}
$this->load($params);
$query->andFilterWhere([
'id' => $this->id
]);
$query
->andFilterWhere(['like', 'description', $this->description])
->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'image', $this->image]);
$query->orderBy(['id' => SORT_DESC]);
return new ActiveDataProvider([
'query' => $query,
]);
}
}
\ No newline at end of file
<?php
use common\modules\school\assets\WidgetAssetBundle;
use yii\web\View;
WidgetAssetBundle::register($this);
?>
<section class="sh_kurs">
<div class="container">
<div class="row">
<div class="col-md-6 col-xs-6 col-sm-12">
<h1>Школа аналитики</h1>
</div>
<div class="col-md-3 col-md-offset-3 col-xs-6 col-sm-12">
<div class="sh_social">
<script type="text/javascript" src="//yastatic.net/es5-shims/0.0.2/es5-shims.min.js" charset="utf-8"></script>
<script type="text/javascript" src="//yastatic.net/share2/share.js" charset="utf-8"></script>
<div id="my-share"></div>
<?php $this->registerJs("Ya.share2('#my-share', {
hooks: {
onshare: function (name) {
$.ajax({
type: 'POST',
url: '/school/statistics/shares',
data: {'name': name},
success: function(data){}
});
}
},
theme: {
services: 'vkontakte,facebook,gplus,twitter,tumblr',
counter: true,
},
content: {
title: 'Школа аналитики',
}
});", View::POS_END, 'my-options');?>
</div>
</div>
</div>
<?php
if (Yii::$app->session->hasFlash('success_activate')) {
echo '<div class="alert alert-block alert-success">'.\Yii::$app->session->getFlash('success_activate').'</div>';
}
?>
<?php
if (Yii::$app->session->hasFlash('error_activate')) {
echo '<div class="alert alert-block alert-danger">'.\Yii::$app->session->getFlash('error_activate').'</div>';
}
?>
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<p>Рынок переполнен псевдотренерами, которые не имеют реального опыта в it отрасли. Они думают линейно и не создают последователей с аналитическим складом ума. Мы решили это изменить и создали данный раздел в который не только для своих сотрудников, но и для всего рынка выкладываем учебные материалы. Это не просто набор роликов. Это продуманные и обкатанные программы обучения с системой он-тестирования и сертификации. Выбери интересный для себя курс, зарегистрируйся, а все остальное сделаем мы!</p>
</div>
</div>
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<?php echo \yii\widgets\ListView::widget( [
'dataProvider' => $dataProvider,
'itemView' => 'item-view',
'itemOptions' => ['tag' => 'div'],
'options' => ['tag' => 'div'],
'emptyTextOptions' => [ 'tag' => 'div', 'class' => 'empty-text' ],
'layout' => '{items}<li><nav class="pages">{pager}</nav></li>',
'pager' => [
'class' => 'common\components\zii\FrontLinkPager',
'activePageCssClass' => 'is-active',
'prevPageLabel' => '<span class="glyphicon glyphicon-chevron-left"></span>Предыдущая',
'nextPageLabel' => 'Следующая<span class="glyphicon glyphicon-chevron-right"></span>',
'options' => [
'class' => 'pages-list',
],
],
] );
?>
<div class="kurs_item">
<div class="kurs_img">
<img src="/uploads/courses/kurs1.jpg" height="262" width="907" alt="" class="kurs_img_poz_2">
</div>
<div class="kurs_over lock">
<h1 class="kurs_title"><span>Как организовать процесс в веб-студии</span></h1><br/>
<span class="kurs_sub-title"><span>Живое наставничество как создать веб-студию с "нуля".</span></span>
<div class="kurs_lock"></div>
<div class="kurs_foot clearfix">
<!-- add 00.02.16 -->
<a href="#registration_form" class="kurs_bt popup-form kurs_bt_resp">Предварительная регистрация</a>
<!-- add 00.02.16 -->
</div>
<!-- <div class="for_dv"><div class="r_dv"></div>в разработке</div>-->
</div>
</div>
</div>
</div>
</div>
</section>
<?php echo $this->render('@app/views/layouts/footer'); ?>
<?php
use common\modules\school\assets\WidgetAssetBundle;
use yii\helpers\Html;
WidgetAssetBundle::register($this);
?>
<div class="kurs_item">
<div class="kurs_img">
<img src="<?php echo $model->image;?>" height="262" width="907" alt="">
</div>
<div class="kurs_over">
<h1 class="kurs_title"><span><?php echo $model->name;?></span></h1><br>
<span class="kurs_sub-title"><?php echo mb_substr($model->description, 0, 150, 'UTF-8');?></span>
<div class="kurs_foot clearfix">
<?php echo Html::a('Подробнее', ['/school/course/view', 'id' => $model->id], ['class' => 'kurs_bt']); ?>
</div>
</div>
</div>
<?php
namespace common\modules\users\controllers;
use common\components\AdminController;
use common\modules\users\models\UserStopWords;
use yii\data\ActiveDataProvider;
use yii\web\NotFoundHttpException;
class StopwordsAdminController extends AdminController {
/**
* @return array|void
*/
public static function actionsTitles(){
return [
'Manage' => 'Управление стоп словами',
'Create' => 'Добавление нового стоп-слова',
'View' => 'Просмотр стоп слова',
'Update' => 'Редактирование стоп-слова',
'Delete' => 'Удаление стоп слова',
];
}
/**
* @return string
*/
public function actionManage(){
$dataProvider = new ActiveDataProvider([
'query' => UserStopWords::find(),
]);
return $this->render(
'manage',
[
'dataProvider' => $dataProvider,
]
);
}
/**
* @return string|\yii\web\Response
*/
public function actionCreate(){
$model = new UserStopWords();
if ($model->load(\Yii::$app->request->post())) {
if ($model->validate() && $model->save())
return $this->redirect([
'manage'
]);
}
$form = new \common\components\BaseForm('/common/modules/users/forms/StopWordsForm', $model);
return $this->render(
'create',
[
'form' => $form
]
);
}
/**
* @param $id
* @return string
*/
public function actionView($id){
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* @param $id
* @return string|\yii\web\Response
*/
public function actionUpdate($id){
/** @var UserStopWords $model */
$model = $this->findModel($id);
if ($model->load(\Yii::$app->request->post())) {
if ($model->validate() && $model->save())
return $this->redirect([
'manage'
]);
}
$form = new \common\components\BaseForm('/common/modules/users/forms/StopWordsForm', $model);
return $this->render(
'update',
[
'form' => $form
]
);
}
/**
* @param $id
* @return UserStopWords|null
* @throws NotFoundHttpException
*/
public function findModel($id)
{
if (($model = UserStopWords::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* @param $id
* @return \yii\web\Response
*/
public function actionDelete($id){
$this->findModel($id)->delete();
return $this->redirect(['manage']);
}
}
\ No newline at end of file
<?php
use \yii\data\ActiveDataProvider;
return [
'activeForm' => [
'id' => 'trigger-form',
'options' => [
'enctype' => 'multipart/form-data'
]
],
'elements' => [
'active' => [
'type' => 'checkbox',
'class' => 'form-control'
],
'word' => [
'type' => 'text',
'class' => 'form-control'
],
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
]
];
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace common\modules\users\models;
use common\components\UnisenderAPI;
use common\modules\analyticsSchool\models\UserStopWords;
use common\modules\messageTemplate\controllers\TemplateAdminController;
use common\modules\messageTemplate\models\MessageTemplate;
use common\modules\triggers\components\conditions\Conditions;
......@@ -186,6 +187,9 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self::SCENARIO_CHANGE_PASSWORD,
self::SCENARIO_CREATE,
], 'message' => 'Пожалуйста, укажите пароль'],
[['name'], 'checkToStopWord', 'on' => [
self::SCENARIO_REGISTRATION
]],
[['password'], 'string', 'min' => 7, 'on' => [
self::SCENARIO_REGISTRATION,
self::SCENARIO_CHANGE_PASSWORD,
......@@ -239,6 +243,19 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
];
}
/**
* @param $attribute
* @param $params
* @return bool
*/
public function checkToStopWord($attribute, $params) {
if (UserStopWords::find()->where(['word' => $this->$attribute, 'active' => 1])->exists()==true) {
$this->addError($attribute, 'Имя не может принимать значение '.$this->$attribute);
return false;
}
return true;
}
public function getEavAttributes() {
return $this->hasMany(\lagman\eav\DynamicModel::className(), ['customer_id' => 'id']);
}
......
<?php
namespace common\modules\users\models;
use Yii;
/**
* This is the model class for table "user_stop_words".
*
* @property integer $id
* @property integer $active
* @property string $word
*/
class UserStopWords extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_stop_words';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['active'], 'integer'],
[['word'], 'required'],
[['word'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'active' => 'Активно',
'word' => 'Слово',
];
}
}
......@@ -42,6 +42,7 @@ class users extends \common\components\WebModule
public static function adminMenu()
{
return array(
'Управление стоп-словами' => '/users/stopwords-admin/manage'
// 'Добавить пользователя' => '/users/user-admin/create',
);
}
......
<?= $form->out;
\ No newline at end of file
<?php
use \yii\helpers\Html;
use yii\grid\GridView;
/**
* @var $this \common\modules\users\controllers\StopwordsAdminController
* @var $dataProvider yii\data\ActiveDataProvider
*/
?>
<div class="analytics-school-manage">
<h1><?= Html::encode($this->title); ?></h1>
<p>
<?= Html::a('Добавить стоп слово', ['create'], ['class' => 'btn btn-success']); ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
[
'attribute' => 'active',
'value' => function($model) {
return ($model->active==1) ? 'Активно' : 'Не активно';
}
],
'word',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
<?= $form->out;
\ No newline at end of file
<?php
use yii\widgets\DetailView;
use \common\modules\analyticsSchool\models\AnalyticsSchoolLesson;
use \yii\grid\GridView;
/** @var AnalyticsSchoolLesson $model */
/** @var \yii\data\ActiveDataProvider $files */
?>
<h1>Просмотр стоп слова #<?= $model->id; ?></h1>
<div class="analytics-school-view">
<?=
DetailView::widget([
'model' => $model,
'attributes' => [
'id',
[
'attribute' => 'active',
'value' => ($model->active==1) ? 'Активно' : 'Не активно'
],
'word'
],
]);
?>
</div>
<?php
use yii\db\Migration;
class m160418_124301_add_user_stop_words_table extends Migration
{
public function up()
{
$this->createTable(
'user_stop_words',
[
'id' => $this->primaryKey(),
'active' => $this->boolean()->defaultValue(true),
'word' => $this->string(255)->notNull()
]
);
}
public function down()
{
$this->dropTable('user_stop_words');
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}
......@@ -26,6 +26,7 @@ return [
'blog' => ['class' => 'common\modules\blog\Module'],
'support' => ['class' => 'common\modules\support\Module'],
'sessions' => ['class' => 'common\modules\sessions\Module'],
'analyticsSchool' => ['class' => 'common\modules\analyticsSchool\Module'],
'sitemap' => [
'class' => 'frontend\modules\sitemap\Sitemap',
'models' => [
......
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