#1003 - Создать раздел и модуль Блог

parent 157355f3
...@@ -18,12 +18,19 @@ class AppAsset extends AssetBundle ...@@ -18,12 +18,19 @@ class AppAsset extends AssetBundle
public $basePath = '@webroot'; public $basePath = '@webroot';
public $baseUrl = '@web'; public $baseUrl = '@web';
public $css = [ public $css = [
'plugins/bootstrap-datepicker/css/datepicker3.css',
'plugins/bootstrap-datetimepicker/css/datetimepicker.css',
'plugins/switchery/switchery.min.css',
'plugins/powerange/powerange.min.css',
'css/site.css', 'css/site.css',
]; ];
public $js = [ public $js = [
'plugins/jquery-ui/ui/minified/jquery-ui.min.js',
'plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js',
'plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ru.js',
'plugins/tinymce/js/tinymce/tinymce.min.js',
]; ];
public $depends = [ public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
]; ];
} }
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace backend\assets;
use yii\web\AssetBundle;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class HeadAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
];
public $js = [
'plugins/switchery/switchery.min.js',
'plugins/powerange/powerange.min.js',
'js/form-slider-switcher.demo.min.js',
'js/apps.min.js',
'js/packages/adminBaseClasses/buttonSet.js',
'js/packages/adminBaseClasses/gridBase.js',
];
public $jsOptions = [
'position' => \yii\web\View::POS_HEAD
];
public $depends = [
];
}
...@@ -18,6 +18,7 @@ return [ ...@@ -18,6 +18,7 @@ return [
'content' => ['class' => 'common\modules\content\Module'], 'content' => ['class' => 'common\modules\content\Module'],
'bids' => ['class' => 'common\modules\bids\Module'], 'bids' => ['class' => 'common\modules\bids\Module'],
'faq' => ['class' => 'common\modules\faq\Module'], 'faq' => ['class' => 'common\modules\faq\Module'],
'blog' => ['class' => 'common\modules\blog\Module'],
'reviews' => ['class' => 'common\modules\reviews\Module'], 'reviews' => ['class' => 'common\modules\reviews\Module'],
'users' => ['class' => 'common\modules\users\users'], 'users' => ['class' => 'common\modules\users\users'],
'testings' => ['class' => 'common\modules\testings\Module'], 'testings' => ['class' => 'common\modules\testings\Module'],
...@@ -65,8 +66,6 @@ return [ ...@@ -65,8 +66,6 @@ return [
'assetManager'=>[ 'assetManager'=>[
'linkAssets' => true, 'linkAssets' => true,
'bundles' => [ 'bundles' => [
'yii\web\YiiAsset' => [
],
'yii\bootstrap\BootstrapPluginAsset' => [ 'yii\bootstrap\BootstrapPluginAsset' => [
'js' => [ 'js' => [
], ],
...@@ -77,7 +76,7 @@ return [ ...@@ -77,7 +76,7 @@ return [
'plugins/jquery/jquery-1.9.1.min.js', 'plugins/jquery/jquery-1.9.1.min.js',
], ],
'jsOptions' => [ 'jsOptions' => [
'position' => \yii\web\View::POS_BEGIN, 'position' => \yii\web\View::POS_HEAD,
], ],
], ],
'yii\jui\JuiAsset' => [ 'yii\jui\JuiAsset' => [
...@@ -87,7 +86,7 @@ return [ ...@@ -87,7 +86,7 @@ return [
'plugins/jquery-ui/ui/minified/jquery.ui.widget.min.js', 'plugins/jquery-ui/ui/minified/jquery.ui.widget.min.js',
], ],
'jsOptions' => [ 'jsOptions' => [
'position' => \yii\web\View::POS_BEGIN, 'position' => \yii\web\View::POS_HEAD,
], ],
'css' => [], 'css' => [],
], ],
......
<!-- ================== BEGIN BASE CSS STYLE ================== --> <?php $this->registerCssFile('http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/css/fonts.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/css/fonts.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/plugins/jquery-ui/themes/base/minified/jquery-ui.min.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/jquery-ui/themes/base/minified/jquery-ui.min.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/plugins/bootstrap/css/bootstrap.min.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/bootstrap/css/bootstrap.min.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/plugins/font-awesome/css/font-awesome.min.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/font-awesome/css/font-awesome.min.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/css/animate.min.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/css/animate.min.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/css/style.min.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/css/style.min.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/css/style-responsive.min.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/css/style-responsive.min.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/css/theme/default.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/css/theme/default.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/plugins/simple-line-icons/simple-line-icons.css', ['position' => \yii\web\View::POS_HEAD]);?>
<?php $this->registerCssFile('/plugins/simple-line-icons/simple-line-icons.css', ['position' => \yii\web\View::POS_HEAD]);?> <?php $this->registerCssFile('/css/custom.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/css/custom.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<!-- ================== END BASE CSS STYLE ================== --> <?php $this->registerCssFile('/plugins/jquery-jvectormap/jquery-jvectormap-1.2.2.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/bootstrap-datepicker/css/datepicker.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<!-- ================== BEGIN PAGE LEVEL STYLE ================== --> <?php $this->registerCssFile('/plugins/bootstrap-datepicker/css/datepicker3.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/jquery-jvectormap/jquery-jvectormap-1.2.2.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/plugins/gritter/css/jquery.gritter.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/bootstrap-datepicker/css/datepicker.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/bootstrap-datepicker/css/datepicker3.css', ['position' => \yii\web\View::POS_HEAD ]);?> <?php $this->registerCssFile('/plugins/DataTables/css/data-table.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<?php $this->registerCssFile('/plugins/gritter/css/jquery.gritter.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<!-- ================== END PAGE LEVEL STYLE ================== --> <?php $this->registerJsFile('/plugins/pace/pace.min.js', ['position' => \yii\web\View::POS_HEAD ]);?>
<!-- ================== BEGIN PAGE LEVEL STYLE ================== --> <?php $this->registerJsFile('/js/form-load.js', ['position' => \yii\web\View::POS_END ]);?>
<?php $this->registerCssFile('/plugins/DataTables/css/data-table.css', ['position' => \yii\web\View::POS_HEAD ]);?>
<!-- ================== END PAGE LEVEL STYLE ================== -->
<!-- ================== BEGIN BASE JS ================== -->
<?php $this->registerJsFile('/plugins/pace/pace.min.js', ['position' => \yii\web\View::POS_HEAD ]);?>
<!-- ================== END BASE JS ================== -->
<!-- ================== PagerSelector ================ -->
<?php
// moved in AdminGrid::run()
/*$publish = Yii::$app->assetManager->publish(
Yii::getAlias('@app/../common/js/plugins')
);
$this->registerJsFile($publish[1].'/gridview/gridBase.js', ['position'=>$this::POS_END]);
$this->registerJsFile($publish[1].'/gridview/grid.js', ['position'=>$this::POS_END]);
$this->registerJsFile($publish[1].'/gridview/pocket.js', ['position'=>$this::POS_END]);*/
?>
<!-- ================== PagerSelector ================ -->
\ No newline at end of file
<?php <?php
use backend\assets\AppAsset; use backend\assets;
use yii\helpers\Html; use yii\helpers\Html;
use yii\bootstrap\Nav; use yii\bootstrap\Nav;
use yii\bootstrap\NavBar; use yii\bootstrap\NavBar;
...@@ -8,7 +8,8 @@ use yii\widgets\Breadcrumbs; ...@@ -8,7 +8,8 @@ use yii\widgets\Breadcrumbs;
/* @var $this \yii\web\View */ /* @var $this \yii\web\View */
/* @var $content string */ /* @var $content string */
//die('-!-!-'); //die('-!-!-');
AppAsset::register($this); assets\AppAsset::register($this);
assets\HeadAsset::register($this);
?> ?>
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<!DOCTYPE html> <!DOCTYPE html>
......
...@@ -119,4 +119,5 @@ a.desc:after { ...@@ -119,4 +119,5 @@ a.desc:after {
} }
.file-widget{ .file-widget{
margin-bottom: 20px; margin-bottom: 20px;
} }
\ No newline at end of file .control-label {min-width: 100px;}
\ No newline at end of file
$(function() {
$('.datepicker-autoClose').datepicker({
dateFormat: 'dd.mm.yy',
todayHighlight: true,
regional: 'ru',
autoclose: true,
todayBtn: true
});
$('.datetimepicker-autoClose').datetimepicker({
todayHighlight: true,
language: 'ru',
autoclose: true,
todayBtn: true,
format: 'dd.mm.yyyy hh:ii'
});
FormSliderSwitcher.init();
tinymce.init({
selector: "textarea",theme: "modern",
language: "ru_RU",
custom_elements: "emstart,emend,header,main,span",
extended_valid_elements: "span[id|name|class|style],i[id|name|class|style],ul[id|name|class|style],li[id|name|class|style]",
height: '350px',
menubar: "edit insert view format table tools",
plugins: [
"advlist autolink link image code lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code ",
image_advtab: true ,
forced_root_block : false,
external_filemanager_path:"/filemanager/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : "/filemanager/plugin.min.js"}
});
});
...@@ -21,7 +21,6 @@ abstract class AdminController extends \common\components\BaseController ...@@ -21,7 +21,6 @@ abstract class AdminController extends \common\components\BaseController
{ {
parent::init(); parent::init();
if(Yii::$app->user->isGuest) if(Yii::$app->user->isGuest)
{ {
return $this->redirect('/site/login'); return $this->redirect('/site/login');
...@@ -31,9 +30,5 @@ abstract class AdminController extends \common\components\BaseController ...@@ -31,9 +30,5 @@ abstract class AdminController extends \common\components\BaseController
{ {
throw new NotSupportedException('The requested page does not exist.'); throw new NotSupportedException('The requested page does not exist.');
} }
$this->view->registerJsFile('/js/packages/adminBaseClasses/buttonSet.js');
$this->view->registerJsFile('/js/packages/adminBaseClasses/gridBase.js');
} }
} }
...@@ -94,7 +94,6 @@ abstract class BaseController extends Controller ...@@ -94,7 +94,6 @@ abstract class BaseController extends Controller
private function _setMetaTags($action) private function _setMetaTags($action)
{ {
if ($action->id != 'view' || $this instanceof AdminController) if ($action->id != 'view' || $this instanceof AdminController)
{ {
return false; return false;
...@@ -126,7 +125,13 @@ abstract class BaseController extends Controller ...@@ -126,7 +125,13 @@ abstract class BaseController extends Controller
{ {
$class = $this->getModelClass(); $class = $this->getModelClass();
if($class == 'Faq') if($class == 'Faq')
{
$class = '\common\modules\faq\models\Faq'; $class = '\common\modules\faq\models\Faq';
}
elseif($class == 'Post')
{
$class = '\common\modules\blog\models\Post';
}
$page_model = new $class; $page_model = new $class;
$page_model = $page_model::findOne(['url' => $url]); $page_model = $page_model::findOne(['url' => $url]);
......
...@@ -16,97 +16,6 @@ class BaseForm extends \yii\widgets\ActiveForm ...@@ -16,97 +16,6 @@ class BaseForm extends \yii\widgets\ActiveForm
public $cancel_button_show = true; public $cancel_button_show = true;
public function run() {
//parent::run();
//$out = ob_get_contents();
//ob_get_clean();
$view = $this->getView();
//ActiveFormAsset::register($view);
/*$view->registerCssFile('/plugins/bootstrap-datepicker/css/datepicker.css', ['position' => \yii\web\View::POS_HEAD ]);*/
$view->registerCssFile('/plugins/bootstrap-datepicker/css/datepicker3.css', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerCssFile('/plugins/bootstrap-datetimepicker/css/datetimepicker.css', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerCssFile('/plugins/switchery/switchery.min.css', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerCssFile('/plugins/powerange/powerange.min.css', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerJsFile('/js/form-plugins.demo.js', ['position' => \yii\web\View::POS_END ]);
// $view->registerJsFile('/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js', ['position' => \yii\web\View::POS_END ]);
// $view->registerJsFile('/plugins/bootstrap-datepicker/js/locales/bootstrap-datepicker.ru.js', ['position' => \yii\web\View::POS_END ]);
$view->registerJsFile('/plugins/jquery-ui/ui/minified/jquery-ui.min.js', ['position' => \yii\web\View::POS_END ]);
$view->registerJsFile('/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js', ['position' => \yii\web\View::POS_END ]);
$view->registerJsFile('/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ru.js', ['position' => \yii\web\View::POS_END ]);
$view->registerJsFile('/plugins/switchery/switchery.min.js', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerJsFile('/plugins/powerange/powerange.min.js', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerJsFile('/js/form-slider-switcher.demo.min.js', ['position' => \yii\web\View::POS_HEAD ]);
/*$view->registerJsFile('/plugins/ckeditor/ckeditor.js', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerJsFile('/plugins/ckeditor/config.js', ['position' => \yii\web\View::POS_HEAD ]);*/
//$view->registerJsFile('//tinymce.cachefly.net/4.1/tinymce.min.js', ['position' => \yii\web\View::POS_HEAD ]);
$view->registerJsFile('/plugins/tinymce/js/tinymce/tinymce.min.js', ['position' => \yii\web\View::POS_END ]);
$view->registerJsFile('/js/apps.min.js', ['position' => \yii\web\View::POS_HEAD ]);
$js = <<<JS
/*"use strict";
$.fn.datepicker.defaults.format = "dd.mm.yyyy";
$.fn.datepicker.defaults.language= 'ru';*/
JS;
$view->registerJs($js, \yii\web\View::POS_END, 'formLoad1');
$js = <<<JS
//$('.datepicker-autoClose').datetimepicker({
"use strict";
$('.datepicker-autoClose').datepicker({
dateFormat: 'dd.mm.yy',
todayHighlight: true,
regional: 'ru',
autoclose: true,
todayBtn: true
});
$('.datetimepicker-autoClose').datetimepicker({
todayHighlight: true,
language: 'ru',
autoclose: true,
todayBtn: true,
format: 'dd.mm.yyyy hh:ii'
});
FormSliderSwitcher.init();
tinymce.init({
selector: "textarea",theme: "modern",
language: "ru_RU",
custom_elements: "emstart,emend,header,main,span",
extended_valid_elements: "span[id|name|class|style],i[id|name|class|style],ul[id|name|class|style],li[id|name|class|style]",
height: '350px',
menubar: "edit insert view format table tools",
plugins: [
"advlist autolink link image code lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code ",
image_advtab: true ,
forced_root_block : false,
external_filemanager_path:"/filemanager/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : "/filemanager/plugin.min.js"}
});
JS;
$view->registerJs($js, \yii\web\View::POS_READY, 'formLoad');
$view->registerCss(".control-label {min-width: 100px;}");
//return $out;
}
public function __construct($config, $model = null, $parent = null) public function __construct($config, $model = null, $parent = null)
{ {
$this->model = $model; $this->model = $model;
......
<?php
namespace common\modules\blog;
/**
* blog module definition class
*/
class Module extends \common\components\WebModule
{
/**
* @inheritdoc
*/
public $controllerNamespace = 'common\modules\blog\controllers';
public $menu_icons = 'fa fa-file-o';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
public static function description()
{
return 'Блог';
}
public static function version()
{
return '1.0';
}
public static function name()
{
return 'Управление блогом';
}
public static function adminMenu()
{
return array(
'Записи' => '/blog/post-admin/manage',
);
}
}
<?php
namespace common\modules\blog\components;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use common\modules\blog\models\PostLang;
class PostLangBehavior extends Behavior
{
public function events()
{
return [
ActiveRecord::EVENT_AFTER_UPDATE => 'Save',
ActiveRecord::EVENT_AFTER_INSERT => 'Insert',
ActiveRecord::EVENT_BEFORE_DELETE => 'Delete',
];
}
public function Save($event)
{
$langs = Yii::$app->request->post('PostLang');
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = PostLang::find()->where([
'post_id' => $this->owner->id,
'lang_id' => $lang_id,
])->one();
if (!$lang)
{
$lang = new PostLang;
}
$attributes['post_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$lang->setAttributes( $attributes );
if(!$lang->save()) die(print_r($lang->errors));
}
}
return true;
}
public function Insert($event)
{
$langs = Yii::$app->request->post('PostLang');
if ($langs)
{
foreach ($langs as $lang_id => $attributes)
{
$lang = new PostLang;
$attributes['post_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id;
$lang->setAttributes($attributes);
$lang->save(false);
}
}
return true;
}
public function Delete($event)
{
if($this->owner->langs)
{
foreach ($this->owner->langs as $lang)
{
$lang->delete();
}
}
return true;
}
}
<?php
namespace common\modules\blog\controllers;
use Yii;
use common\components\AdminController;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\modules\languages\models\Languages;
use common\modules\blog\models\Post;
use common\modules\blog\models\PostLang;
use common\modules\blog\models\SearchPost;
/**
* PostAdminController implements the CRUD actions for Post model.
*/
class PostAdminController 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 Post models.
* @return mixed
*/
public function actionManage()
{
$searchModel = new SearchPost();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('manage', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Post model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Post model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Post();
$langs = [];
foreach (Languages::find()->all() as $lang)
{
$lng = new PostLang;
$lng->lang_id = $lang->id;
$langs[$lang->id] = $lng;
}
if (Yii::$app->request->isPost)
{
$model->attributes = Yii::$app->request->post('Post');
$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,
'langs' => $langs,
]);
}
/**
* 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)
{
$model = $this->findModel($id);
$langs = [];
foreach (Languages::find()->all() as $lang)
{
$lng = $model->getLang($lang->id)->one();
if(!$lng)
{
$lng = new PostLang;
$lng->lang_id = $lang->id;
}
$langs[$lang->id] = $lng;
}
if (Yii::$app->request->isPost)
{
$model->attributes = Yii::$app->request->post('Post');
$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,
'langs' => $langs,
]);
}
/**
* Deletes an existing Post 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(['index']);
}
/**
* 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 Post the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Post::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\components\BaseController;
use yii\web\NotFoundHttpException;
use common\modules\blog\models\Post;
/**
* PostController implements the CRUD actions for Post model.
*/
class PostController extends BaseController
{
public static function actionsTitles(){
return [
'View' => 'Просмотр записи',
];
}
/**
* Displays a single Post model.
* @param string $url
* @return mixed
*/
public function actionView($url)
{
return $this->render('view', [
'model' => $this->findModelByUrl($url),
]);
}
/**
* Finds the Post model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param string $url
* @return Post the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModelByUrl($url)
{
if (($model = Post::find()->where(['url' => $url])->one()) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}
<?php
namespace common\modules\blog\models;
use Yii;
use common\modules\languages\models\Languages;
use common\modules\blog\models\PostLang;
use common\modules\blog\models\PostTags;
/**
* This is the model class for table "posts".
*
* @property integer $id
* @property string $url
* @property integer $active
* @property integer $created_at
* @property integer $updated_at
*
* @property PostsLang[] $postsLangs
* @property PostsTagsAssign[] $postsTagsAssigns
* @property PostsTags[] $tags
*/
class Post extends \common\components\ActiveRecordModel
{
const ACTIVE_FALSE = 0;
const ACTIVE_TRUE = 1;
public static $active_title = [
self::ACTIVE_FALSE => 'Скрыта',
self::ACTIVE_TRUE => 'Доступна',
];
/**
* @inheritdoc
*/
public static function tableName()
{
return 'posts';
}
public function name()
{
return 'Посты';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['url', 'active'], 'required'],
[['active', 'created_at', 'updated_at'], 'integer'],
[['url'], 'string', 'max' => 255],
[['url'], 'unique'],
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'langs' => [
'class' => 'common\modules\blog\components\PostLangBehavior',
],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'url' => 'Ссылка',
'active' => 'Видимость',
'created_at' => 'Дата добавления',
'updated_at' => 'Дата обновления',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getLang($lang_id = null)
{
$lang_id = ($lang_id === null)? Languages::getCurrent()->id: $lang_id;
return $this->hasOne(PostLang::className(), ['post_id' => 'id'])->where('lang_id = :lang_id', [':lang_id' => $lang_id]);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getLangs()
{
return $this->hasMany(PostLang::className(), ['post_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTags()
{
return $this->hasMany(PostTags::className(), ['id' => 'tag_id'])->viaTable('posts_tags_assign', ['post_id' => 'id']);
}
}
<?php
namespace common\modules\blog\models;
use Yii;
use common\modules\languages\models\Languages;
use common\modules\blog\models\Post;
/**
* This is the model class for table "posts_lang".
*
* @property integer $id
* @property integer $post_id
* @property integer $lang_id
* @property string $title
* @property string $text
* @property integer $created_at
* @property integer $updated_at
*
* @property Posts $post
* @property Languages $lang
*/
class PostLang extends \common\components\ActiveRecordModel
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'posts_lang';
}
public function name()
{
return 'Языковые посты';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['post_id', 'lang_id'], 'required'],
[['post_id', 'lang_id', 'created_at', 'updated_at'], 'integer'],
[['text'], 'string'],
[['title'], 'string', 'max' => 255],
[['post_id'], 'exist', 'skipOnError' => true, 'targetClass' => Post::className(), 'targetAttribute' => ['post_id' => 'id']],
[['lang_id'], 'exist', 'skipOnError' => true, 'targetClass' => Languages::className(), 'targetAttribute' => ['lang_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'post_id' => 'Запись',
'lang_id' => 'Язык',
'title' => 'Заголовок',
'text' => 'Контент',
'created_at' => 'Дата добавления',
'updated_at' => 'Дата обновления',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getPost()
{
return $this->hasOne(Post::className(), ['id' => 'post_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getLang()
{
return $this->hasOne(Languages::className(), ['id' => 'lang_id']);
}
}
<?php
namespace common\modules\blog\models;
use Yii;
use common\modules\blog\models\Post;
/**
* This is the model class for table "posts_tags".
*
* @property integer $id
* @property string $name
* @property integer $created_at
* @property integer $updated_at
*
* @property PostsTagsAssign[] $postsTagsAssigns
* @property Posts[] $posts
*/
class PostTag extends \common\components\ActiveRecordModel
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'posts_tags';
}
public function name()
{
return 'Теги';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['created_at', 'updated_at'], 'integer'],
[['name'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Имя тега',
'created_at' => 'Дата добавления',
'updated_at' => 'Дата обновления',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getPosts()
{
return $this->hasMany(Post::className(), ['id' => 'post_id'])->viaTable('posts_tags_assign', ['tag_id' => 'id']);
}
}
<?php
namespace common\modules\blog\models;
use Yii;
use common\modules\blog\models\Post;
use common\modules\blog\models\PostTags;
/**
* This is the model class for table "posts_tags_assign".
*
* @property integer $id
* @property integer $tag_id
* @property integer $post_id
* @property integer $created_at
* @property integer $updated_at
*
* @property Posts $post
* @property PostsTags $tag
*/
class PostTagAssign extends \common\components\ActiveRecordModel
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'posts_tags_assign';
}
public function name()
{
return 'Связь тегов и постов';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['tag_id', 'post_id'], 'required'],
[['tag_id', 'post_id', 'created_at', 'updated_at'], 'integer'],
[['tag_id', 'post_id'], 'unique', 'targetAttribute' => ['tag_id', 'post_id'], 'message' => 'The combination of Tag ID and Post ID has already been taken.'],
[['post_id'], 'exist', 'skipOnError' => true, 'targetClass' => Post::className(), 'targetAttribute' => ['post_id' => 'id']],
[['tag_id'], 'exist', 'skipOnError' => true, 'targetClass' => PostTags::className(), 'targetAttribute' => ['tag_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'tag_id' => 'Тег',
'post_id' => 'Запись',
'created_at' => 'Дата добавления',
'updated_at' => 'Дата обновления',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getPost()
{
return $this->hasOne(Post::className(), ['id' => 'post_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getTag()
{
return $this->hasOne(PostTags::className(), ['id' => 'tag_id']);
}
}
<?php
namespace common\modules\blog\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\modules\blog\models\Post;
/**
* SearchPost represents the model behind the search form about `common\modules\blog\models\Post`.
*/
class SearchPost extends Post
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'active', 'created_at', 'updated_at'], 'integer'],
[['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 = Post::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,
'active' => $this->active,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'url', $this->url]);
return $dataProvider;
}
}
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="post-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'url')->textInput(['maxlength' => 250])->hint('Для создания ЧПУ («Человеку Понятный Урл») укажите латинскими буквами путь, например, razdel/podrazdel/nazvanie_stranici.html') ?>
<?= $form->field($model, 'active', [
'template' => '{input}<a href="#" class="btn btn-xs btn-success m-l-5 disabled">Страница скрыта от пользователя / Страница видна пользователю</a>'
])->checkbox([
'data-theme' => 'self',
'data-render' => 'switchery',
'data-classname' => 'switchery',
'label' => ' '
], false); ?>
<ul class="nav nav-pills">
<?php $c = 0; foreach ($langs as $i => $content) : $c++; ?>
<li class="<?=($c==1?'active':'')?>"><a href="#lang-<?=$content->lang->url?>" data-toggle="tab"><?=$content->lang->name?></a></li>
<?php endforeach; ?>
</ul>
<div class="tab-content">
<?php $c = 0; foreach ($langs as $content) : $c++;
$lang_id = $content->lang->id; ?>
<div class="tab-pane fade <?=($c==1?'active in':'')?>" id="lang-<?=$content->lang->url;?>">
<?= $form->field($content, '['.$lang_id.']title')->textInput(['maxlength' => 250])->hint('Заголовок страницы виден пользователю сайта и как правило оформляется в тег &lt;h1&gt;. Если дизайном страницы не предусмотрен вывод заголовка, то он не будет выводиться даже если был введен в данное поле.') ?>
<?= $form->field($content, '['.$lang_id.']text')->textArea() ?>
</div>
<?php endforeach; ?>
</div>
<div class="form-group">
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
<?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;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
$this->title = 'Create Post';
$this->params['breadcrumbs'][] = ['label' => 'Posts', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-create">
<?= $this->render('_form', [
'model' => $model,
'langs' => $langs,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\grid\GridView;
use common\modules\blog\models\Post;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\blog\models\SearchPost */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Posts';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-index">
<p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
// ['class' => 'yii\grid\SerialColumn'],
'url:url',
[
'attribute' => 'active',
'filter' => Post::$active_title,
'value' => function($model)
{
return Post::$active_title[$model->active];
}
],
[
'class' => 'common\components\ColorActionColumn',
'template' => '{update} {delete}',
],
],
]); ?>
</div>
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
$this->title = 'Update Post: ' . ' ' . $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Posts', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="post-update">
<?= $this->render('_form', [
'model' => $model,
'langs' => $langs,
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Posts', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-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',
'url:url',
'active',
'created_at',
'updated_at',
],
]) ?>
</div>
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Posts', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-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',
'url:url',
'active',
'created_at',
'updated_at',
],
]) ?>
</div>
...@@ -52,13 +52,13 @@ class CoBlocksLangBehavior extends Behavior ...@@ -52,13 +52,13 @@ class CoBlocksLangBehavior extends Behavior
{ {
foreach ($langs as $lang_id => $attributes) foreach ($langs as $lang_id => $attributes)
{ {
$meta_tag = new CoBlocksLang; $lang = new CoBlocksLang;
$attributes['block_id'] = $this->owner->id; $attributes['block_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id; $attributes['lang_id'] = $lang_id;
$meta_tag->setAttributes($attributes); $lang->setAttributes($attributes);
$meta_tag->save(false); $lang->save(false);
} }
} }
......
...@@ -52,13 +52,13 @@ class CoContentLangBehavior extends Behavior ...@@ -52,13 +52,13 @@ class CoContentLangBehavior extends Behavior
{ {
foreach ($langs as $lang_id => $attributes) foreach ($langs as $lang_id => $attributes)
{ {
$meta_tag = new CoContentLang; $lang = new CoContentLang;
$attributes['content_id'] = $this->owner->id; $attributes['content_id'] = $this->owner->id;
$attributes['lang_id'] = $lang_id; $attributes['lang_id'] = $lang_id;
$meta_tag->setAttributes($attributes); $lang->setAttributes($attributes);
$meta_tag->save(false); $lang->save(false);
} }
} }
......
...@@ -10,33 +10,6 @@ use common\modules\content\models\CoBlocks; ...@@ -10,33 +10,6 @@ use common\modules\content\models\CoBlocks;
/* @var $model common\modules\content\models\CoBlocks */ /* @var $model common\modules\content\models\CoBlocks */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$this->registerJsFile('/plugins/tinymce/js/tinymce/tinymce.min.js', ['position' => \yii\web\View::POS_END ]);
$js = <<<JS
tinymce.init({
selector: "textarea",theme: "modern",
language: "ru_RU",
custom_elements: "emstart,emend,header,main,span",
extended_valid_elements: "span[id|name|class|style],i[id|name|class|style],ul[id|name|class|style],li[id|name|class|style]",
height: '350px',
menubar: "edit insert view format table tools",
plugins: [
"advlist autolink link image code lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code ",
image_advtab: true ,
forced_root_block : false,
external_filemanager_path:"/filemanager/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : "/filemanager/plugin.min.js"}
});
JS;
$this->registerJs($js, \yii\web\View::POS_READY, 'tinymceLoad');
?> ?>
<div class="co-content-form"> <div class="co-content-form">
......
...@@ -11,37 +11,6 @@ use common\modules\content\widgets\MetaTagsWidget; ...@@ -11,37 +11,6 @@ use common\modules\content\widgets\MetaTagsWidget;
/* @var $model common\modules\content\models\CoContent */ /* @var $model common\modules\content\models\CoContent */
/* @var $form yii\widgets\ActiveForm */ /* @var $form yii\widgets\ActiveForm */
$this->registerJsFile('/plugins/switchery/switchery.min.js', ['position' => \yii\web\View::POS_HEAD ]);
$this->registerCssFile('/plugins/switchery/switchery.min.css', ['position' => \yii\web\View::POS_HEAD ]);
$this->registerJsFile('/js/form-slider-switcher.demo.min.js', ['position' => \yii\web\View::POS_HEAD ]);
$this->registerJsFile('/plugins/tinymce/js/tinymce/tinymce.min.js', ['position' => \yii\web\View::POS_END ]);
$js = <<<JS
FormSliderSwitcher.init();
tinymce.init({
selector: "textarea",theme: "modern",
language: "ru_RU",
custom_elements: "emstart,emend,header,main,span",
extended_valid_elements: "span[id|name|class|style],i[id|name|class|style],ul[id|name|class|style],li[id|name|class|style]",
height: '350px',
menubar: "edit insert view format table tools",
plugins: [
"advlist autolink link image code lists charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
"table contextmenu directionality emoticons paste textcolor responsivefilemanager"
],
toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code ",
image_advtab: true ,
forced_root_block : false,
external_filemanager_path:"/filemanager/",
filemanager_title:"Responsive Filemanager" ,
external_plugins: { "filemanager" : "/filemanager/plugin.min.js"}
});
JS;
$this->registerJs($js, \yii\web\View::POS_READY, 'switcheryLoad');
$blocks = \common\modules\content\models\CoBlocks::find()->all(); $blocks = \common\modules\content\models\CoBlocks::find()->all();
?> ?>
......
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160209_151440_add_table_blog extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->createTable('posts', [
'id' => Schema::TYPE_PK,
'url' => Schema::TYPE_STRING.'(255) 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',
], $tableOptions);
$this->createIndex('posts_url_unique', 'posts', 'url', true);
$this->createTable('posts_lang', [
'id' => Schema::TYPE_PK,
'post_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('posts_tags', [
'id' => Schema::TYPE_PK,
'name' => Schema::TYPE_STRING.'(255) NOT NULL',
'created_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
'updated_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
]);
$this->createIndex('posts_tags_index', 'posts_tags', 'name');
$this->createTable('posts_tags_assign', [
'id' => Schema::TYPE_PK,
'tag_id' => Schema::TYPE_INTEGER.'(11) NOT NULL',
'post_id' => Schema::TYPE_INTEGER.'(11) NOT NULL',
'created_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
'updated_at' => Schema::TYPE_INTEGER.'(11) DEFAULT NULL',
]);
$this->createIndex('posts_tags_assign_tag_id_post_id_unique', 'posts_tags_assign', ['tag_id', 'post_id'], true);
$this->addForeignKey(
'fk_posts_lang_lang_id_languages_id',
'posts_lang', 'lang_id',
'languages', 'id'
);
$this->addForeignKey(
'fk_posts_lang_posts_id_post_id',
'posts_lang', 'post_id',
'posts', 'id'
);
$this->addForeignKey(
'fk_posts_tags_assign_tag_id_posts_tags_id',
'posts_tags_assign', 'tag_id',
'posts_tags', 'id'
);
$this->addForeignKey(
'fk_posts_tags_assign_post_id_posts_id',
'posts_tags_assign', 'post_id',
'posts', 'id'
);
}
public function safeDown()
{
$this->dropForeignKey('fk_posts_lang_lang_id_languages_id', 'posts_lang');
$this->dropForeignKey('fk_posts_lang_posts_id_post_id', 'posts_lang');
$this->dropForeignKey('fk_posts_tags_assign_tag_id_posts_tags_id', 'posts_tags_assign');
$this->dropForeignKey('fk_posts_tags_assign_post_id_posts_id', 'posts_tags_assign');
$this->dropIndex('posts_tags_index', 'posts_tags');
$this->dropIndex('posts_url_unique', 'posts');
$this->dropIndex('posts_tags_assign_tag_id_post_id_unique', 'posts_tags_assign');
$this->dropTable('posts');
$this->dropTable('posts_lang');
$this->dropTable('posts_tags');
$this->dropTable('posts_tags_assign');
}
}
...@@ -23,6 +23,7 @@ return [ ...@@ -23,6 +23,7 @@ return [
'bids' => ['class' => 'common\modules\bids\Module'], 'bids' => ['class' => 'common\modules\bids\Module'],
'testings' => ['class' => 'common\modules\testings\Module',], 'testings' => ['class' => 'common\modules\testings\Module',],
'users' => ['class' => 'common\modules\users\users',], 'users' => ['class' => 'common\modules\users\users',],
'blog' => ['class' => 'common\modules\blog\Module'],
'sitemap' => [ 'sitemap' => [
'class' => 'himiklab\sitemap\Sitemap', 'class' => 'himiklab\sitemap\Sitemap',
'models' => [ 'models' => [
...@@ -152,6 +153,7 @@ return [ ...@@ -152,6 +153,7 @@ return [
'faq/view/all' => 'faq/faq/all', 'faq/view/all' => 'faq/faq/all',
'faq/<url>' => 'faq/faq/view', 'faq/<url>' => 'faq/faq/view',
'faq' => 'faq/faq/index', 'faq' => 'faq/faq/index',
'blog/<url>' => 'blog/post/view',
'school' => 'school/course/index', 'school' => 'school/course/index',
'school/course/<id>' => 'school/course/view', 'school/course/<id>' => 'school/course/view',
'school/lesson/<id>' => 'school/lesson/view', 'school/lesson/<id>' => 'school/lesson/view',
......
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