Merge branch 'task-on.com/faq' into 'master'

перенос модуля faq с task-on.ru

перенос модуля faq с task-on.ru

See merge request !1
parents 88136053 44f6c310
......@@ -2,46 +2,49 @@
namespace common\modules\faq;
/**
* blog module definition class
*/
class Module extends \common\components\WebModule
{
/**
* @inheritdoc
*/
public $controllerNamespace = 'common\modules\faq\controllers';
public $menu_icons = 'fa fa-question';
public static $active = true;
public static $base_module = true;
public $menu_icons = 'fa-info';
public static function name()
/**
* @inheritdoc
*/
public function init()
{
return 'Вопрос-ответ';
}
parent::init();
// custom initialization code goes here
}
public static function description()
{
return 'Вопрос-ответ';
return 'Справка';
}
public static function version()
{
return '1.0';
}
public function init()
{
parent::init();
// custom initialization code goes here
public static function name()
{
return 'Справка';
}
public static function adminMenu()
public static function adminMenu()
{
return array(
'Список вопросов и ответов' => '/faq/faq-admin/manage',
'Список страниц' => '/faq/faq-admin/manage',
'Рубрики' => '/faq/rubric-admin/manage',
'Голосования' => '/faq/vote-admin/manage',
);
}
}
<?php
namespace common\modules\faq\assets;
use yii\web\AssetBundle;
class AdminGeneratorAsset extends AssetBundle
{
public $sourcePath = '@common/modules/faq/assets/src';
public $css = [
];
public $js = [
'js/admin-generator.js',
];
public $depends = [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
// 'backend\assets\AppAsset'
];
}
<?php
namespace common\modules\faq\assets;
use yii\web\AssetBundle;
class GeneratorAsset extends AssetBundle
{
public $sourcePath = '@common/modules/faq/assets/src';
public $css = [
// 'css/reset.css',
'css/generator.css',
'css/style.css',
];
public $js = [
'js/generator.js',
];
public $depends = [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
// 'backend\assets\AppAsset'
];
}
._sidebar_form_response_hidden{
display: none !important;
}
#_sidebar_form_response{
min-height: 100px;
background: #ffffff ;
margin-bottom: 25px;
border-radius: 3px;
padding-top: 35px;
}
#_sidebar_form_response span{
display: block;
color: #a94442;
text-align: center;
padding: 0 20px;
}
.form_wr.radio_like_result.hidden{
display: none;
}
.keys_list_bl {
background: #fff;
/*padding-top: 56px;*/
}
.faq_sec {
width: 100%;
background: #fff;
}
a,abbr,acronym,address,applet,article,aside,audio,b,blockquote,big,body,center,canvas,caption,cite,code,command,datalist,dd,del,details,dfn,dl,div,dt,em,embed,fieldset,figcaption,figure,font,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,keygen,label,legend,li,meter,nav,object,ol,output,p,pre,progress,q,s,samp,section,small,span,source,strike,strong,sub,sup,table,tbody,tfoot,thead,th,tr,tdvideo,tt,u,ul,var{background:transparent;border:0 none;font-size:100%;margin:0;padding:0;border:0;outline:0;vertical-align:top;}ol, ul {list-style:none;}blockquote, q {quotes:none;}table, table td {padding:0;border:none;border-collapse:collapse;}img {vertical-align:top;}embed {vertical-align:top;}input[type=text], textarea{ outline:none;border-radius:0;}
article,aside,audio,canvas,command,datalist,details,embed,figcaption,figure,footer,header,hgroup,keygen,meter,nav,output,progress,section,source,video{display:block}mark,rp,rt,ruby,summary,time{display:inline}
\ No newline at end of file
This diff is collapsed.
$(document).ready(function() {
/**
* изменяем сдержимое селекта "Рубрика" в views/faq-admin/_form.php
*/
$('#faqrubric-section').on('change', function () {
var $this = $(this);
var action = $this.attr('ajax-action');
var form = $this.closest('form');
$.ajax({
type: "get",
url: action,
data:{'section': $this.val()},
success: function(msg){
var select = form.find('#faq-rubric_id');
select.find("option[value!='']").detach();
if(msg.length === 0){
if(!select.attr("disabled"))
select.closest('.form-group').removeClass('has-success').addClass('has-error');
select.val('');
}
else{
$.each(msg, function(key, value) {
select.append('<option value="' + key + '">' + value + '</option>');
});
}
}
});
})
});
\ No newline at end of file
$(document).ready(function() {
/**
* Created by andre on 18.05.2016.
*/
$('#radio-1,#radio-2').on('click', function()
{
var $this = $(this);
var id = $this.attr("id");
var action = $this.closest("form").attr("action");
var vote = 0;
if(id == "radio-1"){
vote = 1;
}
$.ajax({
type: "get",
url: action,
data: {"yes": vote},
success: function(msg){
$this.closest("form").detach();
$("h4.radio_like_result.hidden").removeClass("hidden");
}
});
})
$('form#contact-form').on('beforeSubmit', function(e) {
var form = $(this), xhr = new XMLHttpRequest, data = new FormData();
form.find('input, textarea').each(function(){
data.append($(this).attr('name'), $(this).val());
});
xhr.open("POST", form.attr('action'), true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(data);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4){
try
{
var response = JSON.parse(xhr.responseText);
}
catch(e)
{
var response = xhr.responseText;
}
form.find('.has-error').removeClass('has-error');
if(response.success)
{ console.log("ccc");return false;
var $response = $(response.text);
form.before($response);
form.addClass("_sidebar_form_response_hidden");
$response.animate({
"opacity": 0
}, 3000, function () {
$response.detach();
form.removeClass("_sidebar_form_response_hidden");
});
form.find('input:not(.not_clear), textarea').val('');
// console.log(response.text);
}
else
{
errors = [];
$.each(response, function(key, value) {
form.find('.field-'+key).addClass('has-error');
errors = errors.concat(value);
});
}
}
}
}).on('submit', function(e){
return false;
});
});
// $('form#contact-form').on('success', function(e){
// console.log("xxx");
// });
\ No newline at end of file
<?php
namespace common\modules\blog\components;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
use common\modules\blog\models\PostTag;
use common\modules\blog\models\PostTagAssign;
class TagBehavior extends Behavior
{
public $tags;
public function events()
{
return [
ActiveRecord::EVENT_AFTER_FIND => 'eventFind',
ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
];
}
private function clearPostTags()
{
if($this->owner->postTagAssigns)
{
foreach ($this->owner->postTagAssigns as $tag)
{
$tag->delete();
}
}
}
private function insertPostTags()
{
if($this->tags)
{
foreach ($this->tags as $tag)
{
$tg = PostTag::find()->where(['name' => $tag])->one();
if(!$tg)
{
// Убрана возможность создавать новые теги
return false;
// $tg = new PostTag;
// $tg->name = $tag;
// $tg->save();
}
$tgs = new PostTagAssign;
$tgs->post_id = $this->owner->id;
$tgs->tag_id = $tg->id;
$tgs->save();
}
}
}
public function eventFind($event)
{
$this->tags = array_keys(ArrayHelper::map($this->owner->postTags, 'name', 'id'));
}
public function Save($event)
{
$this->clearPostTags();
$this->insertPostTags();
return true;
}
public function Insert($event)
{
$this->insertPostTags();
return true;
}
public function Delete($event)
{
$this->clearPostTags();
return true;
}
}
......@@ -2,62 +2,69 @@
namespace common\modules\faq\controllers;
use Yii;
use common\modules\faq\models\Faq;
use common\modules\faq\models\SearchFaq;
use common\modules\faq\models\SearchFaqContent;
use Yii;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\Response;
use yii\helpers\ArrayHelper;
use common\modules\languages\models\Languages;
use common\modules\blog\models\Post;
use common\modules\blog\models\PostLang;
use common\modules\blog\models\PostTag;
use common\modules\blog\models\SearchPost;
/**
* FaqAdminController implements the CRUD actions for Faq model.
* PostAdminController implements the CRUD actions for Post model.
*/
class FaqAdminController extends AdminController
{
public static function actionsTitles(){
return [
'Manage' => 'Список вопросов и ответов',
'Create' => 'Задать вопрос',
'Update' => 'Дать ответ',
'View' => 'Просмотр вопроса/ответа',
'Delete' => 'Просмотр вопроса/ответа',
'Manage' => 'Управление записями',
'Create' => 'Добавление записи',
'Update' => 'Редактирование записи',
'Delete' => 'Удаление записи',
'View' => 'Просмотр записи',
'Autocomplete' => 'Автокомплит для поля тегов'
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
'delete' => ['POST'],
],
],
];
}
/**
* Lists all Faq models.
* Lists all Post models.
* @return mixed
*/
public function actionManage()
{
$searchModel = new SearchFaq();
$searchModel = new SearchFaqContent();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
\yii::$app->controller->page_title = 'Список вопросов и ответов';
\yii::$app->controller->breadcrumbs = [
'Список вопросов и ответов',
];
return $this->render('index', [
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Faq model.
* Displays a single Post model.
* @param integer $id
* @return mixed
*/
......@@ -69,7 +76,7 @@ class FaqAdminController extends AdminController
}
/**
* Creates a new Faq model.
* Creates a new Post model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
......@@ -77,52 +84,72 @@ class FaqAdminController extends AdminController
{
$model = new Faq();
\yii::$app->controller->page_title = 'Добавить вопрос';
\yii::$app->controller->breadcrumbs = [
['Список вопросов' => '/faq/faq-admin/manage'],
'Добавить вопрос'
];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/faq/forms/FaqForm', $model);
return $this->render('create', [
'model' => $model,
'form' => $form->out
]);
}
if (Yii::$app->request->isPost)
{
$model->attributes = Yii::$app->request->post('Faq');
$transaction = Yii::$app->db->beginTransaction();
try
{
if($model->save())
{
$transaction->commit();
}
return $this->redirect(['manage']);
}
catch (\Exception $e)
{
$transaction->rollBack();
throw $e;
}
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Faq model.
* Updates an existing Post model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id = null)
public function actionUpdate($id)
{
\yii::$app->controller->page_title = 'Ответить';
\yii::$app->controller->breadcrumbs = [
['Список вопросов' => '/faq/faq-admin/manage'],
'Ответить'
];
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['manage']);
} else {
$form = new \common\components\BaseForm('/common/modules/faq/forms/FaqForm', $model);
return $this->render('update', [
'model' => $model,
'form' => $form->out
]);
if (Yii::$app->request->isPost)
{
$model->attributes = Yii::$app->request->post('Faq');
$transaction = Yii::$app->db->beginTransaction();
try
{
if($model->save())
{
$transaction->commit();
}
return $this->redirect(['manage']);
}
catch (\Exception $e)
{
$transaction->rollBack();
throw $e;
}
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Faq model.
* Deletes an existing Post model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
......@@ -131,14 +158,15 @@ class FaqAdminController extends AdminController
{
$this->findModel($id)->delete();
return $this->redirect(['manage']);
return $this->redirect(['index']);
}
/**
* Finds the Faq model based on its primary key value.
* Finds the Post model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Faq the loaded model
* @return Post the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
......
<?php
namespace common\modules\faq\controllers;
use Yii;
use common\modules\faq\models\FaqRubric;
use common\modules\faq\models\SearchFaqRubric;
use common\modules\faq\models\Faq;
use common\modules\faq\models\SearchFaqContent;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\Response;
/**
* CategoryAdminController implements the CRUD actions for CoCategory model.
*/
class RubricAdminController extends AdminController
{
public static function actionsTitles(){
return [
'Manage' => 'Управление модулями',
'Create' => 'Создание модуля',
'Update' => 'Редактирование модуля',
'View' => 'Просмотр модуля',
'Delete' => '',
'Createcontroller' => 'Создание контроллера',
'Deletecontroller' => '',
'Updatecontroller' => '',
'Rubrics-by-section' => 'Получение рубрик по имени раздела',
];
}
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all CoCategory models.
* @return mixed
*/
public function actionManage()
{
$searchModel = new SearchFaqRubric();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
\yii::$app->controller->page_title = 'Управление рубриками';
\yii::$app->controller->breadcrumbs = [
'Управление рубриками',
];
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single CoCategory model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
$model = $this->findModel($id);
$searchModel = new SearchFaqContent();
$dataProvider = $searchModel->search(['rubric_id' => $id]);
\yii::$app->controller->page_title = 'Просмотр рубрики';
\yii::$app->controller->breadcrumbs = [
['Управление рубриками' => \yii\helpers\Url::toRoute('manage')],
$model->name,
];
return $this->render('view', [
'model' => $this->findModel($id),
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Creates a new CoCategory model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
return $this->actionUpdate();
}
/**
* Updates an existing CoCategory model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id = null)
{
if(empty($id)) {
$model = new FaqRubric();
\yii::$app->controller->page_title = 'Создать рубрику';
\yii::$app->controller->breadcrumbs = [
['Управление рубриками' => \yii\helpers\Url::toRoute('manage')],
'Создать рубрику',
];
}
else {
$model = $this->findModel($id);
\yii::$app->controller->page_title = 'Редактировать рубрику';
\yii::$app->controller->breadcrumbs = [
['Управление рубриками' => \yii\helpers\Url::toRoute('manage')],
$model->name,
];
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(\yii\helpers\Url::toRoute(['manage']));
} else {
$form = new \common\components\BaseForm('/common/modules/faq/forms/RubricForm', $model);
return $this->render('update', [
'model' => $model,
//'form' => $form->out,
]);
}
}
/**
* Deletes an existing CoCategory model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$items = \common\modules\faq\models\Faq::find()->where(['rubric_id' => $id])->all();
foreach($items as $item) {
$item->rubric_id = null;
$item->save();
}
$this->findModel($id)->delete();
return $this->redirect(['manage']);
}
/**
* Finds the CoCategory model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return CoCategory the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = FaqRubric::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* Получаем рубрики соответствующие разделу (FaqRubric->section)
*/
public function actionRubricsBySection()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$array = [];
$section = Yii::$app->request->get('section');
$rows = FaqRubric::find()->where(['=', 'section', $section])->all();
foreach ($rows as $row)
{
$array[$row["id"]] = $row["name"];
}
return $array;
}
}
<?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\faq\controllers;
namespace common\modules\blog\controllers;
use Yii;
use common\modules\faq\models\FaqCategory;
use common\modules\faq\models\SearchFaqCategory;
use common\modules\blog\models\PostTag;
use common\modules\blog\models\SearchPostTag;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* FaqCategoryAdminController implements the CRUD actions for FaqCategory model.
* TagAdminController implements the CRUD actions for PostTag model.
*/
class FaqCategoryAdminController extends AdminController
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'],
'delete' => ['POST'],
],
],
];
}
/**
* Lists all FaqCategory models.
* Lists all PostTag models.
* @return mixed
*/
public function actionIndex()
public function actionManage()
{
$searchModel = new SearchFaqCategory();
$searchModel = new SearchPostTag();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single FaqCategory model.
* Displays a single PostTag model.
* @param integer $id
* @param string $name
* @return mixed
*/
public function actionView($id, $name)
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id, $name),
'model' => $this->findModel($id),
]);
}
/**
* Creates a new FaqCategory model.
* 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 FaqCategory();
$model = new PostTag();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id, 'name' => $model->name]);
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
......@@ -73,18 +85,17 @@ class FaqCategoryAdminController extends AdminController
}
/**
* Updates an existing FaqCategory model.
* Updates an existing PostTag model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @param string $name
* @return mixed
*/
public function actionUpdate($id, $name)
public function actionUpdate($id)
{
$model = $this->findModel($id, $name);
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id, 'name' => $model->name]);
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
......@@ -93,30 +104,28 @@ class FaqCategoryAdminController extends AdminController
}
/**
* Deletes an existing FaqCategory model.
* Deletes an existing PostTag model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @param string $name
* @return mixed
*/
public function actionDelete($id, $name)
public function actionDelete($id)
{
$this->findModel($id, $name)->delete();
$this->findModel($id)->delete();
return $this->redirect(['index']);
return $this->redirect(['manage']);
}
/**
* Finds the FaqCategory model based on its primary key value.
* 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
* @param string $name
* @return FaqCategory the loaded model
* @return PostTag the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id, $name)
protected function findModel($id)
{
if (($model = FaqCategory::findOne(['id' => $id, 'name' => $name])) !== null) {
if (($model = PostTag::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
......
<?php
/**
* Created by PhpStorm.
* User: Андрей
* Date: 06.03.2015
* Time: 20:11
*/
use yii\helpers\ArrayHelper;
return [
'activeForm'=>[
'id' => 'faq-form',
],
'elements' => [
'lang' => [
'type' => 'dropdownlist',
'class' => 'form-control',
'items' => \yii\helpers\ArrayHelper::map(\common\modules\languages\models\Languages::find()->all(), 'code', 'name'),
'empty' => 'Select Language',
],
'name' => [
'type' => 'text',
'class' => 'form-control',
'placeholder' => \yii::t('faq','First Name'),
'title' => \yii::t('faq','First Name')
],
'phone' => [
'type' => 'text',
'class' => 'form-control',
'placeholder' => \yii::t('faq','Phone'),
'title' => \yii::t('faq','Phone')
],
'email' => [
'type' => 'email',
'class' => 'form-control',
'placeholder' => \yii::t('faq','Email'),
'title' => \yii::t('faq','Email')
],
'cat_id' => [
'type' => 'dropdownlist',
'class' => 'form-control',
'items' => \yii\helpers\ArrayHelper::map(\common\modules\faq\models\FaqCategory::find()->all(), 'id', 'name'),
'empty' => 'Select Category',
],
'question' => [
'type' => 'textarea',
'class' => 'form-control',
'placeholder' => \yii::t('faq','Question'),
'title' => \yii::t('faq','Question')
],
'answer' => [
'type' => 'textarea',
'class' => 'form-control',
'placeholder' => \yii::t('faq','Answer'),
'title' => \yii::t('faq','Answer')
],
'is_published' => ['type' => 'checkbox', 'readonly' => 'readonly'],
/*'notification_date' => [
'type' => 'date',
'class' => 'form-control',
'placeholder' => \yii::t('faq','Notify Date'),
'title' => \yii::t('faq','Notify Date'),
'readonly' => 'readonly',
],
'notification_send' => ['type' => 'checkbox'],*/
'url' => [
'type' => 'text',
'class' => 'form-control',
'placeholder' => \yii::t('faq','Url'),
'title' => \yii::t('faq','Url')
],
/*'name' => ['type' => 'text', 'class' => 'form-control'],
'activity_from' => ['type' => 'date', 'class' => 'form-control'],
'<div style="clear: both;">',
'activity_before' => ['type' => 'date', 'class' => 'form-control'],
'enabled' => ['type' => 'checkbox'],
'default' => ['type' => 'checkbox'],*/
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
]
];
\ No newline at end of file
<?php
use yii\helpers\ArrayHelper;
return [
'activeForm'=>[
'id' => 'module-form',
],
'elements' => [
'name' => ['type' => 'text', 'class' => 'form-control'],
'url' => ['type' => 'text', 'class' => 'form-control'],
],
'buttons' => [
'submit' => ['type' => 'submit', 'value' => 'Cохранить']
]
];
<?php
use yii\helpers\Html;
/* @var $this \yii\web\View view component instance */
/* @var $message \yii\mail\MessageInterface the message being composed */
/* @var $content string main view render result */
?>
<?php $this->beginPage() ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
<?php
use yii\helpers\Html;
/* @var $this \yii\web\View view component instance */
/* @var $message \yii\mail\MessageInterface the message being composed */
/* @var $content string main view render result */
?>
<?php $this->beginPage() ?>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
<?php $this->endPage() ?>
This diff is collapsed.
<?php
/* @var $this yii\web\View */
/* @var $user common\models\User */
use common\models\Settings;
?>
Добрый день!
Уведомляем Вас о том, что с сайта <?=Settings::getValue('setting-project-name')?> поступил вопрос из раздела "Справка"
Имя: <?= $model->fio; ?>
E-mail: <?= $model->email; ?>
Телефон: <?= $model->phone; ?>
Текст вопроса:
<?= $model->message; ?>
С уважением, команда <?=Settings::getValue('setting-project-name')?>.
Если у Вас есть вопросы обратитесь к администратору сервиса на адрес <?=Settings::getValue('content-support-email')?>
\ No newline at end of file
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160517_071645_add_table_faq extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->createTable('faq_content', [
'id' => Schema::TYPE_PK,
'url' => Schema::TYPE_STRING.'(255) NOT NULL',
'rubric_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'active' => Schema::TYPE_INTEGER.'(1) NOT NULL',
'created_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
'updated_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
]);
$this->createIndex('faq_url_unique', 'faq_content', 'url', true);
$this->createTable('faq_content_lang', [
'id' => Schema::TYPE_PK,
'faq_id' => Schema::TYPE_INTEGER.'(11) NOT NULL',
'lang_id' => Schema::TYPE_INTEGER.'(11) NOT NULL',
'title' => Schema::TYPE_STRING.'(255) DEFAULT NULL',
'text' => 'longtext DEFAULT NULL',
'created_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
'updated_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
]);
$this->createTable('faq_rubric', [
'id' => Schema::TYPE_PK,
'name' => Schema::TYPE_STRING . '(255) NOT NULL',
'url' => Schema::TYPE_STRING . '(255) NOT NULL',
'created_at' => Schema::TYPE_INTEGER . '(11) DEFAULT NULL',
'updated_at' => Schema::TYPE_INTEGER . '(11) DEFAULT NULL',
]);
$this->addForeignKey(
'fk_faq_content_rubric_id_faq_rubric_id',
'faq_content', 'rubric_id',
'faq_rubric', 'id'
);
}
public function safeDown()
{
echo "m160517_071645_add_table_faq cannot be rereverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160517_141200_add_column extends Migration
{
public function safeUp()
{
$this->addColumn('faq_rubric', 'img', Schema::TYPE_STRING.'(60) DEFAULT NULL');
$this->addColumn('faq_rubric', 'sort', Schema::TYPE_INTEGER . '(11) NOT NULL');
}
public function safeDown()
{
$this->dropColumn('faq_rubric', 'img');
$this->dropColumn('faq_rubric', 'sort');
}
}
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160527_080112_faq_mail_form extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$q = '
CREATE TABLE `faq_mail_form` (
`id` int(11) NOT NULL,
`content_id` int(11) NOT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`fio` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`message` text COLLATE utf8_unicode_ci NOT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE `faq_mail_form`
ADD PRIMARY KEY (`id`),
ADD KEY `content_id` (`content_id`);
ALTER TABLE `faq_mail_form`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=1;
ALTER TABLE `faq_mail_form`
ADD CONSTRAINT `faq_mail_form_ibfk_1` FOREIGN KEY (`content_id`) REFERENCES `faq_content` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
';
$this->execute($q);
}
public function safeDown()
{
$this->dropTable('faq_mail_form');
}
}
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160527_112741_faq_vote extends Migration
{
public function safeUp()
{
$this->createTable('faq_vote', [
'id' => Schema::TYPE_PK,
'content_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'yes' => Schema::TYPE_BOOLEAN,
'created_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
'updated_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
]);
$this->createIndex('faq_vote_yes', 'faq_vote', 'yes');
$this->addForeignKey(
'faq_vote_ibfk_1', 'faq_vote', 'content_id', 'faq_content', 'id', 'CASCADE', 'CASCADE'
);
}
public function safeDown()
{
$this->dropTable('faq_vote');
}
}
<?php
use yii\db\Migration;
use yii\db\Schema;
/**
* Handles adding session_id to table `faq_vote`.
*/
class m160530_113552_add_session_id_to_faq_vote extends Migration
{
/**
* @inheritdoc
*/
public function safeUp()
{
$this->addColumn('faq_vote', 'session_id', Schema::TYPE_STRING.'(32) DEFAULT NULL');
$this->createIndex('session_id_uniue', 'faq_vote', 'session_id', true);
}
/**
* @inheritdoc
*/
public function safeDown()
{
$this->dropColumn('faq_vote', 'session_id');
}
}
<?php
use yii\db\Migration;
use yii\db\Schema;
use common\modules\faq\models\Faq;
class m160607_121443_add_section extends Migration
{
public function safeUp()
{
$this->addColumn('faq_rubric', 'section', Schema::TYPE_STRING.'(32) DEFAULT \''.Faq::SECTION_FAQ.'\'');
}
public function safeDown()
{
$this->dropColumn('faq_rubric', 'section');
}
}
<?php
use yii\db\Migration;
class m160608_094035_remove_unique_session extends Migration
{
public function safeUp()
{
$this->dropIndex("session_id_uniue", 'faq_vote');
}
public function safeDown()
{
$this->createIndex('session_id_uniue', 'faq_vote', 'session_id', true);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<h1><?php echo $model->shortQuestion?></h1>
<div style="text-align: justify;"><?php echo $model->shortAnswer?></div>
<small><?php echo \yii\helpers\Html::a('Читать подробнее', \yii\helpers\Url::toRoute(['view', 'url' => $model->url]))?></small>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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