Browse Source

init

master
Egorka 7 years ago
commit
111e94932b
  1. 3
      .bowerrc
  2. 51
      .editorconfig
  3. 37
      .gitignore
  4. 32
      LICENSE.md
  5. 60
      README.md
  6. 78
      Vagrantfile
  7. 17
      backend/assets/AdminLteSkinAsset.php
  8. 23
      backend/assets/AppAsset.php
  9. 18
      backend/bootstrap/SetUp.php
  10. 15
      backend/codeception.yml
  11. 3
      backend/config/.gitignore
  12. 1
      backend/config/bootstrap.php
  13. 124
      backend/config/main.php
  14. 4
      backend/config/params.php
  15. 12
      backend/config/test.php
  16. 20
      backend/config/urlManager.php
  17. 93
      backend/controllers/AuthController.php
  18. 171
      backend/controllers/PageController.php
  19. 137
      backend/controllers/PermissionController.php
  20. 163
      backend/controllers/RoleController.php
  21. 77
      backend/controllers/SiteController.php
  22. 160
      backend/controllers/SliderController.php
  23. 160
      backend/controllers/UserController.php
  24. 181
      backend/controllers/post/CategoryController.php
  25. 159
      backend/controllers/post/CommentController.php
  26. 232
      backend/controllers/post/PostController.php
  27. 179
      backend/controllers/post/TagController.php
  28. 156
      backend/controllers/post/TypeController.php
  29. 57
      backend/forms/PageSearch.php
  30. 71
      backend/forms/UserSearch.php
  31. 43
      backend/forms/rbac/RbacCreatePermissionForm.php
  32. 43
      backend/forms/rbac/RbacCreateRoleForm.php
  33. 53
      backend/forms/rbac/RbacEditPermissionForm.php
  34. 53
      backend/forms/rbac/RbacEditRoleForm.php
  35. 23
      backend/forms/rbac/RbacUpdateChildren.php
  36. 10
      backend/messages/ru/buttons.php
  37. 4
      backend/messages/ru/dashboard.php
  38. 11
      backend/messages/ru/main.php
  39. 13
      backend/messages/ru/page.php
  40. 61
      backend/messages/ru/post.php
  41. 15
      backend/messages/ru/slider.php
  42. 35
      backend/messages/ru/user.php
  43. 1
      backend/models/.gitkeep
  44. 2
      backend/runtime/.gitignore
  45. 9
      backend/tests/_bootstrap.php
  46. 0
      backend/tests/_data/.gitignore
  47. 13
      backend/tests/_data/login_data.php
  48. 2
      backend/tests/_output/.gitignore
  49. 1
      backend/tests/_support/.gitignore
  50. 25
      backend/tests/_support/FunctionalTester.php
  51. 25
      backend/tests/_support/UnitTester.php
  52. 4
      backend/tests/functional.suite.yml
  53. 45
      backend/tests/functional/LoginCest.php
  54. 16
      backend/tests/functional/_bootstrap.php
  55. 1
      backend/tests/unit.suite.yml
  56. 16
      backend/tests/unit/_bootstrap.php
  57. 60
      backend/views/auth/login.php
  58. 235
      backend/views/layouts/content.php
  59. 30
      backend/views/layouts/error.php
  60. 281
      backend/views/layouts/header.php
  61. 86
      backend/views/layouts/left.php
  62. 30
      backend/views/layouts/main-login.php
  63. 65
      backend/views/layouts/main.php
  64. 42
      backend/views/page/_form.php
  65. 16
      backend/views/page/create.php
  66. 55
      backend/views/page/index.php
  67. 18
      backend/views/page/update.php
  68. 76
      backend/views/page/view.php
  69. 33
      backend/views/permission/create.php
  70. 42
      backend/views/permission/index.php
  71. 33
      backend/views/permission/update.php
  72. 50
      backend/views/permission/view.php
  73. 139
      backend/views/post/articles/_form.php
  74. 18
      backend/views/post/articles/create.php
  75. 83
      backend/views/post/articles/index.php
  76. 20
      backend/views/post/articles/update.php
  77. 139
      backend/views/post/articles/view.php
  78. 139
      backend/views/post/blog/_form.php
  79. 18
      backend/views/post/blog/create.php
  80. 83
      backend/views/post/blog/index.php
  81. 20
      backend/views/post/blog/update.php
  82. 139
      backend/views/post/blog/view.php
  83. 54
      backend/views/post/category/_form.php
  84. 18
      backend/views/post/category/create.php
  85. 55
      backend/views/post/category/index.php
  86. 20
      backend/views/post/category/update.php
  87. 71
      backend/views/post/category/view.php
  88. 54
      backend/views/post/comment/index.php
  89. 34
      backend/views/post/comment/update.php
  90. 70
      backend/views/post/comment/view.php
  91. 139
      backend/views/post/gallery/_form.php
  92. 18
      backend/views/post/gallery/create.php
  93. 83
      backend/views/post/gallery/index.php
  94. 20
      backend/views/post/gallery/update.php
  95. 126
      backend/views/post/gallery/view.php
  96. 140
      backend/views/post/news/_form.php
  97. 18
      backend/views/post/news/create.php
  98. 83
      backend/views/post/news/index.php
  99. 20
      backend/views/post/news/update.php
  100. 139
      backend/views/post/news/view.php
  101. Some files were not shown because too many files have changed in this diff Show More

3
.bowerrc

@ -0,0 +1,3 @@
{
"directory" : "vendor/bower"
}

51
.editorconfig

@ -0,0 +1,51 @@
[*]
charset=utf-8
end_of_line=crlf
insert_final_newline=false
indent_style=space
indent_size=4
[{.babelrc,.stylelintrc,.eslintrc,jest.config,*.json,*.jsb3,*.jsb2,*.bowerrc}]
indent_style=space
indent_size=2
[*.feature]
indent_style=space
indent_size=2
[{jshint.json,*.jshintrc}]
indent_style=space
indent_size=2
[{*.jscs.json,*.jscsrc}]
indent_style=space
indent_size=2
[*.js.map]
indent_style=space
indent_size=2
[{*.ddl,*.sql}]
indent_style=space
indent_size=2
[*.coffee]
indent_style=space
indent_size=2
[{*.hphp,*.phtml,*.module,*.php,*.php5,*.php4,*.inc}]
indent_style=tab
tab_width=4
[*.less]
indent_style=space
indent_size=2
[*.scss]
indent_style=space
indent_size=2
[{*.yml,*.yaml}]
indent_style=space
indent_size=2

37
.gitignore vendored

@ -0,0 +1,37 @@
# yii console commands
/yii
/yii_test
/yii_test.bat
# phpstorm project files
.idea
# netbeans project files
nbproject
# zend studio for eclipse project files
.buildpath
.project
.settings
# windows thumbnail cache
Thumbs.db
# composer vendor dir
/vendor
# composer itself is not needed
composer.phar
# Mac DS_Store Files
.DS_Store
# phpunit itself is not needed
phpunit.phar
# local phpunit config
/phpunit.xml
# vagrant runtime
/.vagrant
composer.lock
todo.txt

32
LICENSE.md

@ -0,0 +1,32 @@
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Yii Software LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

60
README.md

@ -0,0 +1,60 @@
<p align="center">
<a href="https://github.com/yiisoft" target="_blank">
<img src="https://avatars0.githubusercontent.com/u/993323" height="100px">
</a>
<h1 align="center">Yii 2 Advanced Project Template</h1>
<br>
</p>
Yii 2 Advanced Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
developing complex Web applications with multiple tiers.
The template includes three tiers: front end, back end, and console, each of which
is a separate Yii application.
The template is designed to work in a team development environment. It supports
deploying the application in different environments.
Documentation is at [docs/guide/README.md](docs/guide/README.md).
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-app-advanced/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-app-advanced/downloads.png)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
[![Build Status](https://travis-ci.org/yiisoft/yii2-app-advanced.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-app-advanced)
DIRECTORY STRUCTURE
-------------------
```
common
config/ contains shared configurations
mail/ contains view files for e-mails
models/ contains model classes used in both backend and frontend
tests/ contains tests for common classes
console
config/ contains console configurations
controllers/ contains console controllers (commands)
migrations/ contains database migrations
models/ contains console-specific model classes
runtime/ contains files generated during runtime
backend
assets/ contains application assets such as JavaScript and CSS
config/ contains backend configurations
controllers/ contains Web controller classes
models/ contains backend-specific model classes
runtime/ contains files generated during runtime
tests/ contains tests for backend application
views/ contains view files for the Web application
web/ contains the entry script and Web resources
frontend
assets/ contains application assets such as JavaScript and CSS
config/ contains frontend configurations
controllers/ contains Web controller classes
models/ contains frontend-specific model classes
runtime/ contains files generated during runtime
tests/ contains tests for frontend application
views/ contains view files for the Web application
web/ contains the entry script and Web resources
widgets/ contains frontend widgets
vendor/ contains dependent 3rd-party packages
environments/ contains environment-based overrides
```

78
Vagrantfile vendored

@ -0,0 +1,78 @@
require 'yaml'
require 'fileutils'
required_plugins = %w( vagrant-hostmanager vagrant-vbguest )
required_plugins.each do |plugin|
exec "vagrant plugin install #{plugin}" unless Vagrant.has_plugin? plugin
end
domains = {
frontend: 'morework.local',
backend: 'admin.morework.local',
static: 'static.morework.local',
}
config = {
local: './vagrant/config/vagrant-local.yml',
example: './vagrant/config/vagrant-local.example.yml'
}
# copy config from example if local config not exists
FileUtils.cp config[:example], config[:local] unless File.exist?(config[:local])
# read config
options = YAML.load_file config[:local]
# check github token
if options['github_token'].nil? || options['github_token'].to_s.length != 40
puts "You must place REAL GitHub token into configuration:\n/yii2-app-advanced/vagrant/config/vagrant-local.yml"
exit
end
# vagrant configurate
Vagrant.configure(2) do |config|
# select the box
config.vm.box = 'bento/ubuntu-16.04'
# should we ask about box updates?
config.vm.box_check_update = options['box_check_update']
config.vm.provider 'virtualbox' do |vb|
# machine cpus count
vb.cpus = options['cpus']
# machine memory size
vb.memory = options['memory']
# machine name (for VirtualBox UI)
vb.name = options['machine_name']
end
# machine name (for vagrant console)
config.vm.define options['machine_name']
# machine name (for guest machine console)
config.vm.hostname = options['machine_name']
# network settings
config.vm.network 'private_network', ip: options['ip']
# sync: folder 'yii2-app-advanced' (host machine) -> folder '/app' (guest machine)
config.vm.synced_folder './', '/app', owner: 'vagrant', group: 'vagrant'
# disable folder '/vagrant' (guest machine)
config.vm.synced_folder '.', '/vagrant', disabled: true
# hosts settings (host machine)
config.vm.provision :hostmanager
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.aliases = domains.values
# provisioners
config.vm.provision 'shell', path: './vagrant/provision/once-as-root.sh', args: [options['timezone']]
config.vm.provision 'shell', path: './vagrant/provision/once-as-vagrant.sh', args: [options['github_token']], privileged: false
config.vm.provision 'shell', path: './vagrant/provision/always-as-root.sh', run: 'always'
# post-install message (vagrant console)
config.vm.post_up_message = "Frontend URL: http://#{domains[:frontend]}\nBackend URL: http://#{domains[:backend]}"
end

17
backend/assets/AdminLteSkinAsset.php

@ -0,0 +1,17 @@
<?php
/**
* Created by Error202
* Date: 26.10.2017
*/
namespace backend\assets;
use yii\web\AssetBundle;
class AdminLteSkinAsset extends AssetBundle
{
public $css = [
'css/skin.css',
];
}

23
backend/assets/AppAsset.php

@ -0,0 +1,23 @@
<?php
namespace backend\assets;
use yii\web\AssetBundle;
/**
* Main backend application asset bundle.
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapPluginAsset',
];
}

18
backend/bootstrap/SetUp.php

@ -0,0 +1,18 @@
<?php
namespace backend\bootstrap;
use mihaildev\ckeditor\CKEditor;
use mihaildev\elfinder\ElFinder;
use yii\base\BootstrapInterface;
class SetUp implements BootstrapInterface
{
public function bootstrap($app)
{
$container = \Yii::$container;
$container->set(CKEditor::class, [
'editorOptions' => ElFinder::ckeditorOptions('elfinder', []),
]);
}
}

15
backend/codeception.yml

@ -0,0 +1,15 @@
namespace: backend\tests
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
modules:
config:
Yii2:
configFile: 'config/test-local.php'

3
backend/config/.gitignore vendored

@ -0,0 +1,3 @@
main-local.php
params-local.php
test-local.php

1
backend/config/bootstrap.php

@ -0,0 +1 @@
<?php

124
backend/config/main.php

@ -0,0 +1,124 @@
<?php
$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
require __DIR__ . '/params.php',
require __DIR__ . '/params-local.php'
);
return [
'id' => 'app-backend',
'language' => 'ru',
'basePath' => dirname(__DIR__),
'aliases' => [
'@staticRoot' => $params['staticPath'],
'@static' => $params['staticHostInfo'],
],
'controllerNamespace' => 'backend\controllers',
'bootstrap' => [
'log',
'common\bootstrap\SetUp',
'backend\bootstrap\SetUp',
],
'modules' => [],
'controllerMap' => [
'elfinder' => [
'class' => 'mihaildev\elfinder\Controller',
'access' => ['@'],
'plugin' => [
[
'class'=>'\mihaildev\elfinder\plugin\Sluggable',
'lowercase' => true,
'replacement' => '-'
]
],
'roots' => [
[
'baseUrl'=>'@static',
'basePath'=>'@staticRoot',
'path' => 'files',
'name' => 'Global'
],
],
],
],
'components' => [
'request' => [
'csrfParam' => '_csrf-backend',
'cookieValidationKey' => $params['cookieValidationKey'],
],
'user' => [
'identityClass' => 'common\auth\Identity',
'enableAutoLogin' => true,
'identityCookie' => [
'name' => '_identity',
'httpOnly' => true,
'domain' => $params['cookieDomain'],
],
'loginUrl' => ['auth/login'],
],
'session' => [
'name' => '_session',
'class' => 'yii\web\DbSession',
'writeCallback' => function($session){
return [
'user_id' => Yii::$app->user->id
];
},
'cookieParams' => [
'domain' => $params['cookieDomain'],
'httpOnly' => true,
],
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'backendUrlManager' => require __DIR__ . '/urlManager.php',
'frontendUrlManager' => require __DIR__ . '/../../frontend/config/urlManager.php',
'urlManager' => function () {
return Yii::$app->get('backendUrlManager');
},
'i18n' => [
'translations' => [
'main' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@backend/messages',
],
'dashboard' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@backend/messages',
],
'page' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@backend/messages',
],
'user' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@backend/messages',
],
'post' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@backend/messages',
],
'buttons' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@backend/messages',
],
'slider' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@backend/messages',
],
],
],
],
'params' => $params,
];

4
backend/config/params.php

@ -0,0 +1,4 @@
<?php
return [
'adminEmail' => 'admin@example.com',
];

12
backend/config/test.php

@ -0,0 +1,12 @@
<?php
return [
'id' => 'app-backend-tests',
'components' => [
'assetManager' => [
'basePath' => __DIR__ . '/../web/assets',
],
'urlManager' => [
'showScriptName' => true,
],
],
];

20
backend/config/urlManager.php

@ -0,0 +1,20 @@
<?php
/** @var array $params */
return [
'class' => 'yii\web\UrlManager',
'hostInfo' => $params['backendHostInfo'],
'baseUrl' => '',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
'<_a:login|logout>' => 'auth/<_a>',
'<_c:[\w\-]+>' => '<_c>/index',
'<_c:[\w\-]+>/<id:\d+>' => '<_c>/view',
'<_c:[\w\-]+>/<_a:[\w-]+>' => '<_c>/<_a>',
'<_c:[\w\-]+>/<id:\d+>/<_a:[\w\-]+>' => '<_c>/<_a>',
],
];

93
backend/controllers/AuthController.php

@ -0,0 +1,93 @@
<?php
namespace backend\controllers;
use common\auth\Identity;
use core\services\auth\AuthService;
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use core\forms\auth\LoginForm;
use yii\filters\AccessControl;
class AuthController extends Controller
{
private $authService;
public function __construct($id, $module, AuthService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->authService = $service;
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* @return mixed
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$this->layout = 'main-login';
$form = new LoginForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$user = $this->authService->auth($form);
Yii::$app->user->login(new Identity($user), $form->rememberMe ? 3600 * 24 * 30 : 0);
return $this->goBack();
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('login', [
'model' => $form,
]);
}
/**
* @return mixed
*/
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
}

171
backend/controllers/PageController.php

@ -0,0 +1,171 @@
<?php
namespace backend\controllers;
use core\forms\PageForm;
use core\services\PageManageService;
use Yii;
use core\entities\Page;
use backend\forms\PageSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
class PageController extends Controller
{
private $service;
public function __construct($id, $module, PageManageService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
public function behaviors(): array
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['create', 'view', 'index', 'update', 'delete', 'move-up', 'move-down'],
'allow' => true,
'roles' => ['PagesManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* @return mixed
*/
public function actionIndex()
{
$searchModel = new PageSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
return $this->render('view', [
'page' => $this->findModel($id),
]);
}
/**
* @return mixed
*/
public function actionCreate()
{
$form = new PageForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$page = $this->service->create($form);
return $this->redirect(['view', 'id' => $page->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
}
/**
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$page = $this->findModel($id);
$form = new PageForm($page);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($page->id, $form);
return $this->redirect(['view', 'id' => $page->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'page' => $page,
]);
}
/**
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
try {
$this->service->remove($id);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index']);
}
/**
* @param integer $id
* @return mixed
*/
public function actionMoveUp($id)
{
$this->service->moveUp($id);
return $this->redirect(['index']);
}
/**
* @param integer $id
* @return mixed
*/
public function actionMoveDown($id)
{
$this->service->moveDown($id);
return $this->redirect(['index']);
}
/**
* @param integer $id
* @return Page the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id): Page
{
if (($model = Page::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

137
backend/controllers/PermissionController.php

@ -0,0 +1,137 @@
<?php
/**
* Created by Error202
* Date: 15.08.2017
*/
namespace backend\controllers;
use backend\forms\rbac\RbacCreatePermissionForm;
use backend\forms\rbac\RbacEditPermissionForm;
use core\services\PermissionManager;
use yii\behaviors\TimestampBehavior;
use yii\data\ArrayDataProvider;
use yii\rbac\Permission;
use yii\web\Controller;
use yii\filters\VerbFilter;
use Yii;
use yii\filters\AccessControl;
class PermissionController extends Controller
{
private $permission;
public function __construct($id, $module, PermissionManager $permission, $config = [])
{
parent::__construct($id, $module, $config);
$this->permission = $permission;
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['create','view','index', 'update', 'delete'],
'allow' => true,
'roles' => ['UserManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actionIndex()
{
$data = array_map(function (Permission $permission){
return [
'name' => $permission->name,
'description' => $permission->description,
];
}, $this->permission->getPermissions());
$dataProvider = new ArrayDataProvider([
'allModels' => $data,
'pagination' => [
'pageSize' => 20,
],
'sort' => [
'attributes' => ['name', 'description'],
],
]);
return $this->render('index', ['dataProvider' => $dataProvider]);
}
public function actionCreate()
{
$form = new RbacCreatePermissionForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->permission->create($form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
}
public function actionUpdate($id)
{
$permission = $this->findModel($id);
$form = new RbacEditPermissionForm($permission);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->permission->update($permission->name, $form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
]);
}
public function actionDelete($id)
{
$this->permission->delete($id);
return $this->redirect(['index']);
}
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
protected function findModel($id)
{
return $this->permission->getPermission($id);
}
}

163
backend/controllers/RoleController.php

@ -0,0 +1,163 @@
<?php
/**
* Created by Error202
* Date: 15.08.2017
*/
namespace backend\controllers;
use backend\forms\rbac\RbacEditRoleForm;
use backend\forms\rbac\RbacUpdateChildren;
use core\services\PermissionManager;
use yii\behaviors\TimestampBehavior;
use backend\forms\rbac\RbacCreateRoleForm;
use core\services\RoleManager;
use yii\data\ArrayDataProvider;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use Yii;
class RoleController extends Controller
{
private $role;
private $permission;
public function __construct($id, $module, RoleManager $role, PermissionManager $permission, $config = [])
{
parent::__construct($id, $module, $config);
$this->role = $role;
$this->permission = $permission;
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
],
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['create','view','index', 'update', 'delete'],
'allow' => true,
'roles' => ['UserManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actionIndex()
{
$data = $this->role->getRolesListArray();
$dataProvider = new ArrayDataProvider([
'allModels' => $data,
'pagination' => [
'pageSize' => 20,
],
'sort' => [
'attributes' => ['name', 'description'],
],
]);
return $this->render('index', ['dataProvider' => $dataProvider]);
}
public function actionCreate()
{
$form = new RbacCreateRoleForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->role->create($form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
}
public function actionUpdate($id)
{
$role = $this->findModel($id);
$form = new RbacEditRoleForm($role);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->role->update($role->name, $form->name, $form->description, $form->rule_name, $form->data);
return $this->redirect(['view', 'id' => $form->name]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
]);
}
public function actionDelete($id)
{
try {
$this->role->delete($id);
}
catch (\DomainException $e)
{
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index']);
}
public function actionView($id)
{
$currentRole = $this->role->getRole($id);
$rolesSelectArray = array_diff_assoc($this->role->getRolesSelectArray(), [$currentRole->name => $currentRole->description]);
$itemsForm = new RbacUpdateChildren();
if ($itemsForm->load(Yii::$app->request->post()) && $itemsForm->validate()) {
$this->role->saveChildren($id, $itemsForm->roles, $itemsForm->permissions);
Yii::$app->session->setFlash('success', Yii::t('user', 'Children roles and permissions for "{role}" is updated.', ['role' => $currentRole->description]));
}
$rolesSelected = $this->role->getRolesSelectArrayByRole($id);
$permissionsSelectArray = $this->permission->getPermissionsSelectArray();
$permissionsSelected = $this->permission->getPermissionsSelectArrayByRole($id);
$itemsForm->roles = $rolesSelected;
$itemsForm->permissions = $permissionsSelected;
return $this->render('view', [
'model' => $this->findModel($id),
'roles' => $rolesSelectArray,
'permissions' => $permissionsSelectArray,
'permissionsSelected' => $permissionsSelected,
'itemsForm' => $itemsForm,
]);
}
protected function findModel($id)
{
return $this->role->getRole($id);
}
}

77
backend/controllers/SiteController.php

@ -0,0 +1,77 @@
<?php
namespace backend\controllers;
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
/**
* Site controller
*/
class SiteController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['error'],
'allow' => true,
],
[
'actions' => ['index'],
'allow' => true,
'roles' => ['Dashboard'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
public function beforeAction($action)
{
if ($action->id === 'error') {
$this->layout = 'error';
}
return parent::beforeAction($action);
}
}

160
backend/controllers/SliderController.php

@ -0,0 +1,160 @@
<?php
namespace backend\controllers;
use core\entities\Slider;
use core\forms\SliderForm;
use core\services\SliderService;
use Yii;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
class SliderController extends Controller
{
private $service;
public function __construct($id, $module, SliderService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['create', 'view', 'index', 'update', 'delete'],
'allow' => true,
'roles' => ['SliderManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
public function actionIndex()
{
//$searchModel = new UserSearch();
//$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$query = Slider::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 20,
],
'sort' => [
'defaultOrder' => [
'id' => SORT_ASC,
]
],
]);
return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}
/**
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$form = new SliderForm();
$form->scenario = Slider::SCENARIO_CREATE;
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$slider = $this->service->create($form);
return $this->redirect(['view', 'id' => $slider->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
}
/**
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$slider = $this->findModel($id);
$form = new SliderForm($slider);
$form->scenario = Slider::SCENARIO_UPDATE;
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($slider->id, $form);
return $this->redirect(['view', 'id' => $slider->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'slider' => $slider,
]);
}
/**
* @param $id
*
* @return \yii\web\Response
*/
public function actionDelete($id)
{
$this->service->remove($id);
return $this->redirect(['index']);
}
protected function findModel($id): ?Slider
{
if (($model = Slider::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

160
backend/controllers/UserController.php

@ -0,0 +1,160 @@
<?php
namespace backend\controllers;
use core\forms\user\UserForm;
use core\services\user\UserManageService;
use Yii;
use core\entities\user\User;
use backend\forms\UserSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
/**
* UserController implements the CRUD actions for User model.
*/
class UserController extends Controller
{
private $service;
public function __construct($id, $module, UserManageService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['create','view','index', 'update', 'delete'],
'allow' => true,
'roles' => ['UserManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all User models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new UserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new User model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$form = new UserForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$user = $this->service->create($form);
return $this->redirect(['view', 'id' => $user->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
}
/**
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$user = $this->findModel($id);
$form = new UserForm($user);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($user->id, $form);
return $this->redirect(['view', 'id' => $user->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'user' => $user,
]);
}
/**
* Deletes an existing User model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->service->remove($id);
return $this->redirect(['index']);
}
/**
* Finds the User model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return User the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = User::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

181
backend/controllers/post/CategoryController.php

@ -0,0 +1,181 @@
<?php
namespace backend\controllers\post;
use core\entities\post\PostType;
use core\forms\post\PostCategoryForm;
use core\services\post\PostCategoryManageService;
use Yii;
use core\entities\post\PostCategory;
use core\forms\post\search\PostCategorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
class CategoryController extends Controller
{
private $service;
public function __construct($id, $module, PostCategoryManageService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
public function behaviors(): array
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['PostManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* @param $tid
*
* @return string
* @throws NotFoundHttpException
*/
public function actionIndex($tid)
{
$type = $this->findType($tid);
$searchModel = new PostCategorySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'type' => $type,
]);
}
/**
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
$category = $this->findModel($id);
$type = $this->findType($category->type_id);
return $this->render('view', [
'category' => $category,
'type' => $type,
]);
}
/**
* @param $tid
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionCreate($tid)
{
$type = $this->findType($tid);
$form = new PostCategoryForm();
$form->type_id = $type->id;
$form->updateSort();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$category = $this->service->create($form);
return $this->redirect(['view', 'id' => $category->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
'type' => $type,
]);
}
/**
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$category = $this->findModel($id);
$type = $this->findType($category->type_id);
$form = new PostCategoryForm($category);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($category->id, $form);
return $this->redirect(['view', 'id' => $category->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'category' => $category,
'type' => $type,
]);
}
/**
* @param $id
*
* @return \yii\web\Response
* @throws NotFoundHttpException
*/
public function actionDelete($id)
{
$category = $this->findModel($id);
$type = $this->findType($category->type_id);
try {
$this->service->remove($id);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index', 'tid' => $type->id]);
}
/**
* @param integer $id
* @return PostCategory the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id): PostCategory
{
if (($model = PostCategory::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
protected function findType($id): PostType
{
if (($type = PostType::findOne($id)) !== null) {
return $type;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

159
backend/controllers/post/CommentController.php

@ -0,0 +1,159 @@
<?php
namespace backend\controllers\post;
use core\forms\post\search\PostCommentSearch;
use core\forms\post\PostCommentEditForm;
use core\services\post\PostCommentManageService;
use Yii;
use core\entities\post\Post;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
class CommentController extends Controller
{
private $service;
public function __construct($id, $module, PostCommentManageService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
public function behaviors(): array
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['PostManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* @return mixed
*/
public function actionIndex()
{
$searchModel = new PostCommentSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* @param $post_id
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($post_id, $id)
{
$post = $this->findModel($post_id);
$comment = $post->getComment($id);
$form = new PostCommentEditForm($comment);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($post->id, $comment->id, $form);
return $this->redirect(['view', 'post_id' => $post->id, 'id' => $comment->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'post' => $post,
'model' => $form,
'comment' => $comment,
]);
}
/**
* @param $post_id
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($post_id, $id)
{
$post = $this->findModel($post_id);
$comment = $post->getComment($id);
return $this->render('view', [
'post' => $post,
'comment' => $comment,
]);
}
/**
* @param $post_id
* @param $id
*
* @return \yii\web\Response
* @throws NotFoundHttpException
*/
public function actionActivate($post_id, $id)
{
$post = $this->findModel($post_id);
try {
$this->service->activate($post->id, $id);
} catch (\DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['view', 'post_id' => $post_id, 'id' => $id]);
}
/**
* @param $post_id
* @param $id
*
* @return \yii\web\Response
* @throws NotFoundHttpException
*/
public function actionDelete($post_id, $id)
{
$post = $this->findModel($post_id);
try {
$this->service->remove($post->id, $id);
} catch (\DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index']);
}
/**
* @param integer $id
* @return Post the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id): Post
{
if (($model = Post::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

232
backend/controllers/post/PostController.php

@ -0,0 +1,232 @@
<?php
namespace backend\controllers\post;
use core\entities\post\PostTag;
use core\entities\post\PostType;
use core\forms\post\PostForm;
use core\services\post\PostManageService;
use Yii;
use core\entities\post\Post;
use core\forms\post\search\PostSearch;
use yii\helpers\ArrayHelper;
use yii\log\Logger;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use yii\web\Response;
class PostController extends Controller
{
private $service;
public function __construct($id, $module, PostManageService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
public function behaviors(): array
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['PostManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
'activate' => ['POST'],
'draft' => ['POST'],
'delete-photo' => ['POST'],
'move-photo-up' => ['POST'],
'move-photo-down' => ['POST'],
],
],
];
}
/**
* @param $tid
*
* @return string
* @throws NotFoundHttpException
*/
public function actionIndex($tid)
{
$type = $this->findType($tid);
$searchModel = new PostSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render( '/post/' . $type->name . '/index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'type' => $type,
]);
}
/**
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
$post = $this->findModel($id);
$type = $this->findType($post->type_id);
return $this->render('/post/' . $type->name . '/view', [
'post' => $post,
'type' => $type,
]);
}
/**
* @param $tid
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionCreate($tid)
{
$type = $this->findType($tid);
$form = new PostForm();
$form->type_id = $type->id;
$form->published_at = date('d.m.Y H:i:s');
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$post = $this->service->create($form);
return $this->redirect(['view', 'id' => $post->id, 'tid' => $post->type_id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('/post/' . $type->name . '/create', [
'model' => $form,
'type' => $type,
]);
}
/**
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$post = $this->findModel($id);
$type = $this->findType($post->type_id);
$form = new PostForm($post);
$form->published_at = date('d.m.Y H:i:s', $form->published_at);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($post->id, $form);
return $this->redirect(['view', 'id' => $post->id, 'tid' => $post->type_id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('/post/' . $type->name . '/update', [
'model' => $form,
'post' => $post,
'type' => $type,
]);
}
/**
* @param $id
*
* @return \yii\web\Response
* @throws NotFoundHttpException
*/
public function actionDelete($id)
{
$post = $this->findModel($id);
$type = $this->findType($post->type_id);
try {
$this->service->remove($id);
} catch (\DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index', 'tid' => $type->id]);
}
/**
* @param integer $id
* @return mixed
*/
public function actionActivate($id)
{
try {
$this->service->activate($id);
} catch (\DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['view', 'id' => $id]);
}
/**
* @param integer $id
* @return mixed
*/
public function actionDraft($id)
{
try {
$this->service->draft($id);
} catch (\DomainException $e) {
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['view', 'id' => $id]);
}
public function actionTagSearch($type_id, $q = null, $id = null)
{
\Yii::$app->response->format = Response::FORMAT_JSON;
$out = ['results' => ['id' => '', 'text' => '']];
if (!is_null($q)) {
$data = PostTag::find()->select('name as id, name as text')->andWhere(['type_id' => $type_id])->andWhere(['like', 'name', $q])->orderBy('name')->limit(20)->asArray()->all();
$out['results'] = array_values($data);
}
elseif ($id > 0) {
$tag_name = PostTag::findOne($id)->name;
$out['results'] = ['id' => $tag_name, 'text' => $tag_name];
}
return $out;
}
/**
* @param integer $id
* @return Post the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id): Post
{
if (($model = Post::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
protected function findType($id): PostType
{
if (($type = PostType::findOne($id)) !== null) {
return $type;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

179
backend/controllers/post/TagController.php

@ -0,0 +1,179 @@
<?php
namespace backend\controllers\post;
use core\entities\post\PostType;
use core\forms\post\PostTagSingleForm;
use core\services\post\PostTagManageService;
use Yii;
use core\entities\post\PostTag;
use core\forms\post\search\PostTagSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
class TagController extends Controller
{
private $service;
public function __construct($id, $module, PostTagManageService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
public function behaviors(): array
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['PostManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* @param $tid
*
* @return string
* @throws NotFoundHttpException
*/
public function actionIndex($tid)
{
$type = $this->findType($tid);
$searchModel = new PostTagSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'type' => $type,
]);
}
/**
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
$tag = $this->findModel($id);
$type = $this->findType($tag->type_id);
return $this->render('view', [
'tag' => $tag,
'type' => $type,
]);
}
/**
* @param $tid
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionCreate($tid)
{
$type = $this->findType($tid);
$form = new PostTagSingleForm();
$form->type_id = $type->id;
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$tag = $this->service->create($form);
return $this->redirect(['view', 'id' => $tag->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
'type' => $type,
]);
}
/**
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$tag = $this->findModel($id);
$type = $this->findType($tag->type_id);
$form = new PostTagSingleForm($tag);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($tag->id, $form);
return $this->redirect(['view', 'id' => $tag->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
'tag' => $tag,
'type' => $type,
]);
}
/**
* @param $id
*
* @return \yii\web\Response
* @throws NotFoundHttpException
*/
public function actionDelete($id)
{
$tag = $this->findModel($id);
$type = $this->findType($tag->type_id);
try {
$this->service->remove($id);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index', 'tid' => $type->id]);
}
/**
* @param integer $id
* @return PostTag the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id): PostTag
{
if (($model = PostTag::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
protected function findType($id): PostType
{
if (($type = PostType::findOne($id)) !== null) {
return $type;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

156
backend/controllers/post/TypeController.php

@ -0,0 +1,156 @@
<?php
namespace backend\controllers\post;
use core\entities\post\PostType;
use core\forms\post\PostTypeForm;
use core\forms\post\search\PostTypeSearch;
use core\services\post\PostTypeService;
use yii\web\NotFoundHttpException;
use yii\web\Controller;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use Yii;
class TypeController extends Controller
{
private $service;
public function __construct($id, $module, PostTypeService $service, $config = [])
{
parent::__construct($id, $module, $config);
$this->service = $service;
}
public function behaviors(): array
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['PostManagement'],
],
[ // all the action are accessible to admin
'allow' => true,
'roles' => ['admin'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* @return string
*/
public function actionIndex()
{
$searchModel = new PostTypeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* @param $id
*
* @return string
* @throws NotFoundHttpException
*/
public function actionView($id)
{
$type = $this->findModel($id);
return $this->render('view', [
'type' => $type,
]);
}
/**
* @return string|\yii\web\Response
*/
public function actionCreate()
{
$form = new PostTypeForm();
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$type = $this->service->create($form);
return $this->redirect(['view', 'id' => $type->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('create', [
'model' => $form,
]);
}
/**
* @param $id
*
* @return string|\yii\web\Response
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$type = $this->findModel($id);
$form = new PostTypeForm($type);
if ($form->load(Yii::$app->request->post()) && $form->validate()) {
try {
$this->service->edit($type->id, $form);
return $this->redirect(['view', 'id' => $type->id]);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
}
return $this->render('update', [
'model' => $form,
]);
}
/**
* @param $id
*
* @return \yii\web\Response
* @throws NotFoundHttpException
*/
public function actionDelete($id)
{
$type = $this->findModel($id);
try {
$this->service->remove($id);
} catch (\DomainException $e) {
Yii::$app->errorHandler->logException($e);
Yii::$app->session->setFlash('error', $e->getMessage());
}
return $this->redirect(['index']);
}
/**
* @param $id
*
* @return PostType
* @throws NotFoundHttpException
*/
protected function findModel($id): PostType
{
if (($type = PostType::findOne($id)) !== null) {
return $type;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

57
backend/forms/PageSearch.php

@ -0,0 +1,57 @@
<?php
namespace backend\forms;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use core\entities\Page;
class PageSearch extends Model
{
public $id;
public $name;
public $slug;
public $title;
public function rules(): array
{
return [
[['id'], 'integer'],
[['name', 'slug', 'title'], 'safe'],
];
}
/**
* @param array $params
* @return ActiveDataProvider
*/
public function search(array $params): ActiveDataProvider
{
$query = Page::find()->andWhere(['>', 'depth', 0]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => [
'defaultOrder' => ['lft' => SORT_ASC]
]
]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
]);
$query
->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'slug', $this->slug])
->andFilterWhere(['like', 'title', $this->title]);
return $dataProvider;
}
}

71
backend/forms/UserSearch.php

@ -0,0 +1,71 @@
<?php
namespace backend\forms;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use core\entities\user\User;
use yii\helpers\ArrayHelper;
class UserSearch extends Model
{
public $id;
public $date_from;
public $date_to;
public $username;
public $email;
public $status;
public $role;
public function rules()
{
return [
[['id', 'status'], 'integer'],
[['username', 'email', 'role'], 'safe'],
[['date_from', 'date_to'], 'date', 'format' => 'php:Y-m-d'],
];
}
/**
* @param array $params
* @return ActiveDataProvider
*/
public function search(array $params): ActiveDataProvider
{
$query = User::find()->alias('u');
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
$query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'u.id' => $this->id,
'u.status' => $this->status,
]);
if (!empty($this->role)) {
$query->innerJoin('{{%auth_assignments}} a', 'a.user_id = u.id');
$query->andWhere(['a.item_name' => $this->role]);
}
$query
->andFilterWhere(['like', 'u.username', $this->username])
->andFilterWhere(['like', 'u.email', $this->email])
->andFilterWhere(['>=', 'u.created_at', $this->date_from ? strtotime($this->date_from . ' 00:00:00') : null])
->andFilterWhere(['<=', 'u.created_at', $this->date_to ? strtotime($this->date_to . ' 23:59:59') : null]);
return $dataProvider;
}
public function rolesList(): array
{
return ArrayHelper::map(\Yii::$app->authManager->getRoles(), 'name', 'description');
}
}

43
backend/forms/rbac/RbacCreatePermissionForm.php

@ -0,0 +1,43 @@
<?php
/**
* Created by Error202
* Date: 15.08.2017
*/
namespace backend\forms\rbac;
use yii\base\Model;
use Yii;
class RbacCreatePermissionForm extends Model
{
public $name;
public $description;
public $rule_name;
public $data;
public $created_at;
public $updated_at;
public function rules()
{
return [
[['name'], 'required'],
[['name', 'description', 'rule_name'], 'trim'],
[['description', 'data'], 'string'],
[['rule_name'], 'string', 'max' => 64],
[['created_at', 'updated_at'], 'integer'],
];
}
public function attributeLabels()
{
return [
'name' => Yii::t('user', 'Permission Name'),
'description' => Yii::t('user', 'Permission Description'),
'rule_name' => Yii::t('user', 'Rule Name'),
'data' => Yii::t('user', 'Permission Data'),
];
}
}

43
backend/forms/rbac/RbacCreateRoleForm.php

@ -0,0 +1,43 @@
<?php
/**
* Created by Error202
* Date: 15.08.2017
*/
namespace backend\forms\rbac;
use yii\base\Model;
use Yii;
class RbacCreateRoleForm extends Model
{
public $name;
public $description;
public $rule_name;
public $data;
public $created_at;
public $updated_at;
public function rules()
{
return [
[['name'], 'required'],
[['name', 'description', 'rule_name'], 'trim'],
[['description', 'data'], 'string'],
[['rule_name'], 'string', 'max' => 64],
[['created_at', 'updated_at'], 'integer'],
];
}
public function attributeLabels()
{
return [
'name' => Yii::t('user', 'Role Name'),
'description' => Yii::t('user', 'Role Description'),
'rule_name' => Yii::t('user', 'Rule Name'),
'data' => Yii::t('user', 'Role Data'),
];
}
}

53
backend/forms/rbac/RbacEditPermissionForm.php

@ -0,0 +1,53 @@
<?php
/**
* Created by Error202
* Date: 15.08.2017
*/
namespace backend\forms\rbac;
use yii\rbac\Permission;
use yii\base\Model;
use Yii;
class RbacEditPermissionForm extends Model
{
public $name;
public $description;
public $rule_name;
public $data;
public $created_at;
public $updated_at;
public function __construct(Permission $permission, $config = [])
{
$this->name = $permission->name;
$this->description = $permission->description;
$this->rule_name = $permission->ruleName;
$this->data = $permission->data;
parent::__construct($config);
}
public function rules()
{
return [
[['name'], 'required'],
[['name', 'description', 'rule_name'], 'trim'],
[['description', 'data'], 'string'],
[['rule_name'], 'string', 'max' => 64],
[['created_at', 'updated_at'], 'integer'],
];
}
public function attributeLabels()
{
return [
'name' => Yii::t('user', 'Permission Name'),
'description' => Yii::t('user', 'Permission Description'),
'rule_name' => Yii::t('user', 'Rule Name'),
'data' => Yii::t('user', 'Permission Data'),
];
}
}

53
backend/forms/rbac/RbacEditRoleForm.php

@ -0,0 +1,53 @@
<?php
/**
* Created by Error202
* Date: 15.08.2017
*/
namespace backend\forms\rbac;
use yii\rbac\Role;
use yii\base\Model;
use Yii;
class RbacEditRoleForm extends Model
{
public $name;
public $description;
public $rule_name;
public $data;
public $created_at;
public $updated_at;
public function __construct(Role $role, $config = [])
{
$this->name = $role->name;
$this->description = $role->description;
$this->rule_name = $role->ruleName;
$this->data = $role->data;
parent::__construct($config);
}
public function rules()
{
return [
[['name'], 'required'],
[['name', 'description', 'rule_name'], 'trim'],
[['description', 'data'], 'string'],
[['rule_name'], 'string', 'max' => 64],
[['created_at', 'updated_at'], 'integer'],
];
}
public function attributeLabels()
{
return [
'name' => Yii::t('user', 'Role Name'),
'description' => Yii::t('user', 'Role Description'),
'rule_name' => Yii::t('user', 'Rule Name'),
'data' => Yii::t('user', 'Role Data'),
];
}
}

23
backend/forms/rbac/RbacUpdateChildren.php

@ -0,0 +1,23 @@
<?php
/**
* Created by Error202
* Date: 17.08.2017
*/
namespace backend\forms\rbac;
use yii\base\Model;
class RbacUpdateChildren extends Model
{
public $roles;
public $permissions;
public function rules()
{
return [
[['roles', 'permissions'], 'each', 'rule' => ['string']],
];
}
}

10
backend/messages/ru/buttons.php

@ -0,0 +1,10 @@
<?php
return [
'Are you sure you want to delete this item?' => 'Вы уверены, что хотите удалить эту запись',
'Update' => 'Обновить',
'Save' => 'Сохранить',
'Create' => 'Создать',
'Delete' => 'Удалить',
'Edit' => 'Изменить',
'Editing' => 'Редактирование',
];

4
backend/messages/ru/dashboard.php

@ -0,0 +1,4 @@
<?php
return [
'Dashboard' => 'Панель управления',
];

11
backend/messages/ru/main.php

@ -0,0 +1,11 @@
<?php
return [
'Menu' => 'Меню',
'Title' => 'Заголовок',
'Description' => 'Описание',
'Keywords' => 'Ключевые слова',
'Sign out' => 'Выход',
'Profile' => 'Профиль',
'Error' => 'Ошибка',
'Return to back or login page please.' => 'Вернитесь назад или авторизуйтесь снова.',
];

13
backend/messages/ru/page.php

@ -0,0 +1,13 @@
<?php
return [
'Create Page' => 'Новая страница',
'Pages' => 'Страницы',
'Common' => 'Основное',
'Content' => 'Содержание',
'SEO' => 'META теги',
'Title' => 'Заголовок',
'Slug' => 'ЧПУ ссылка',
'ID' => '№',
'Parent Page' => 'Родительская страница',
'Update Page: {name}' => 'Редактирование страницы: {name}',
];

61
backend/messages/ru/post.php

@ -0,0 +1,61 @@
<?php
return [
'All Posts' => 'Все записи',
'Posts' => 'Записи',
'Categories' => 'Категории',
'Tags' => 'Теги',
'News' => 'Новости',
'Comments' => 'Комментарии',
'Articles' => 'Статьи',
'Blog' => 'Блог',
'Blogs' => 'Блоги',
'Events' => 'События',
'Gallery' => 'Фотогалерея',
'Create Post' => 'Новая запись',
'Create Category' => 'Новая категория',
'Create Tag' => 'Новый тег',
'Common' => 'Основное',
'Title' => 'Заголовок',
'Description' => 'Описание',
'Content' => 'Содержание',
'Image' => 'Изображение',
'Existing' => 'Существующие',
'New tag' => 'Новый тег',
'Category' => 'Категория',
'Post is already active.' => 'Запись уже опубликована.',
'Published At' => 'Опубликовано',
'Created At' => 'Создано',
'Updated At' => 'Обновлено',
'Status' => 'Статус',
'ID' => '№',
'SEO' => 'МЕТА теги',
'Tag Name' => 'Тег',
'SEO link' => 'ЧПУ ссылка',
'Draft' => 'Черновик',
'Active' => 'Опубликовано',
'Activate' => 'Опубликовать',
'Meta Title' => 'Заголовок',
'Meta Description' => 'Описание',
'Meta Keywords' => 'Ключевые слова',
'Name' => 'Название',
'Sort' => 'Позиция',
'Update: {name}' => 'Редактирование: {name}',
'Types' => 'Типы',
'Create Type' => 'Новый тип',
'Singular' => 'Единственное число',
'Plural' => 'Множественное число',
'Slug' => 'ЧПУ ссылка',
'Update Post: {name}' => 'Редактирование: {name}',
'Update Post Comment: {name}' => 'Редактирование комментария: {name}',
'Update Tag: {name}' => 'Редактирование тега: {name}',
'Parent Comment ID' => 'Родительский комментарий',
'Comment' => 'Комментарий',
'Published' => 'Опубликовано',
'User' => 'Пользователь',
'Post' => 'Запись',
'YouTube URL' => 'Ссылка YouTube',
'Add Image' => 'Новое изображение',
'Video' => 'Видео',
'If a video link is specified, the image will be used as a preview image' => 'Если указана ссылка на видео, то изображение будет рассматриваться как картинка для предварительного просмотра',
'Reset Image' => 'Сбросить изображение',
];

15
backend/messages/ru/slider.php

@ -0,0 +1,15 @@
<?php
return [
'Title' => 'Заголовок',
'Tagline' => 'Слоган',
'Image' => 'Изображение',
'URL' => 'Ссылка',
'Sort' => 'Сортировка',
'Slider' => 'Карусель',
'Slide' => 'Слайд',
'Create Slide' => 'Новый слайд',
'Update Slide' => 'Редактирование слайда',
'ID' => '№',
'Background Image' => 'Фоновое изображение',
];

35
backend/messages/ru/user.php

@ -0,0 +1,35 @@
<?php
return [
'Users' => 'Пользователи',
'Create User' => 'Новый пользователь',
'Username' => 'Имя пользователя',
'Password' => 'Пароль',
'E-mail' => 'E-mail',
'Created At' => 'Создан',
'Status' => 'Статус',
'Role' => 'Роль',
'Updated At' => 'Изменен',
'ID' => '№',
'Update User: {user}' => 'Редактирование пользователя: {user}',
'Wait' => 'Не подтвержден',
'Active' => 'Активен',
'Access Rules' => 'Права доступа',
'Roles' => 'Роли',
'Permissions' => 'Разрешения',
'Create Role' => 'Новая роль',
'Create Permission' => 'Новое разрешение',
'Role Name' => 'Название роли',
'Rule Name' => 'Название правила',
'Role Description' => 'Описание роли',
'Role Data' => 'Данные роли',
'Permission Name' => 'Название разрешения',
'Permission Description' => 'Описание разрешения',
'Permission Data' => 'Данные разрешения',
'Update Role: {role}' => 'Редактирование роли: {role}',
'Select role...' => 'Укажите роль...',
'Select permission...' => 'Укажите разрешение...',
'Contains roles' => 'Содержит роли',
'Update Permission: {permission}' => 'Редактирование разрешения: {permission}',
'Administrator has full access rules' => 'Администратор обладает всеми правами доступа',
'Children roles and permissions for "{role}" is updated.' => 'Дочерние роли и разрешения для роли "{role}" обновлены.',
];

1
backend/models/.gitkeep

@ -0,0 +1 @@
*

2
backend/runtime/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

9
backend/tests/_bootstrap.php

@ -0,0 +1,9 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../');
require_once YII_APP_BASE_PATH . '/vendor/autoload.php';
require_once YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php';
require_once YII_APP_BASE_PATH . '/common/config/bootstrap.php';
require_once __DIR__ . '/../config/bootstrap.php';

0
backend/tests/_data/.gitignore vendored

13
backend/tests/_data/login_data.php

@ -0,0 +1,13 @@
<?php
return [
[
'username' => 'erau',
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
// password_0
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
'created_at' => '1392559490',
'updated_at' => '1392559490',
'email' => 'sfriesen@jenkins.info',
],
];

2
backend/tests/_output/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

1
backend/tests/_support/.gitignore vendored

@ -0,0 +1 @@
_generated

25
backend/tests/_support/FunctionalTester.php

@ -0,0 +1,25 @@
<?php
namespace backend\tests;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}

25
backend/tests/_support/UnitTester.php

@ -0,0 +1,25 @@
<?php
namespace backend\tests;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}

4
backend/tests/functional.suite.yml

@ -0,0 +1,4 @@
class_name: FunctionalTester
modules:
enabled:
- Yii2

45
backend/tests/functional/LoginCest.php

@ -0,0 +1,45 @@
<?php
namespace backend\tests\functional;
use backend\tests\FunctionalTester;
use common\fixtures\UserFixture;
/**
* Class LoginCest
*/
class LoginCest
{
/**
* Load fixtures before db transaction begin
* Called in _before()
* @see \Codeception\Module\Yii2::_before()
* @see \Codeception\Module\Yii2::loadFixtures()
* @return array
*/
public function _fixtures()
{
return [
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'login_data.php'
]
];
}
/**
* @param FunctionalTester $I
*/
public function loginUser(FunctionalTester $I)
{
$I->amOnPage('/site/login');
$I->fillField('Username', 'erau');
$I->fillField('Password', 'password_0');
$I->click('login-button');
$I->see('Logout (erau)', 'form button[type=submit]');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
}
}

16
backend/tests/functional/_bootstrap.php

@ -0,0 +1,16 @@
<?php
/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Cests.
*
* ```php
* // Here _bootstrap.php
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
* ```
*
* In Cests
*
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/

1
backend/tests/unit.suite.yml

@ -0,0 +1 @@
class_name: UnitTester

16
backend/tests/unit/_bootstrap.php

@ -0,0 +1,16 @@
<?php
/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Tests.
*
* ```php
* // Here _bootstrap.php
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
* ```
*
* In Tests
*
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/

60
backend/views/auth/login.php

@ -0,0 +1,60 @@
<?php
use common\widgets\Alert;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \core\forms\auth\LoginForm */
$this->title = 'Sign In';
$fieldOptions1 = [
'options' => ['class' => 'form-group has-feedback'],
'inputTemplate' => "{input}<span class='glyphicon glyphicon-envelope form-control-feedback'></span>"
];
$fieldOptions2 = [
'options' => ['class' => 'form-group has-feedback'],
'inputTemplate' => "{input}<span class='glyphicon glyphicon-lock form-control-feedback'></span>"
];
?>
<div class="login-box">
<div class="login-logo">
<a href="#"><b>Admin</b>LTE</a>
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>
<?= Alert::widget() ?>
<?php $form = ActiveForm::begin(['id' => 'login-form', 'enableClientValidation' => false]); ?>
<?= $form
->field($model, 'username', $fieldOptions1)
->label(false)
->textInput(['placeholder' => $model->getAttributeLabel('username')]) ?>
<?= $form
->field($model, 'password', $fieldOptions2)
->label(false)
->passwordInput(['placeholder' => $model->getAttributeLabel('password')]) ?>
<div class="row">
<div class="col-xs-8">
<?= $form->field($model, 'rememberMe')->checkbox() ?>
</div>
<!-- /.col -->
<div class="col-xs-4">
<?= Html::submitButton('Sign in', ['class' => 'btn btn-primary btn-block btn-flat', 'name' => 'login-button']) ?>
</div>
<!-- /.col -->
</div>
<?php ActiveForm::end(); ?>
</div>
<!-- /.login-box-body -->
</div><!-- /.login-box -->

235
backend/views/layouts/content.php

@ -0,0 +1,235 @@
<?php
use yii\widgets\Breadcrumbs;
use dmstr\widgets\Alert;
?>
<div class="content-wrapper">
<section class="content-header">
<?php if (isset($this->blocks['content-header'])) { ?>
<h1><?= $this->blocks['content-header'] ?></h1>
<?php } else { ?>
<h1>
<?php
if ($this->title !== null) {
echo \yii\helpers\Html::encode($this->title);
} else {
echo \yii\helpers\Inflector::camel2words(
\yii\helpers\Inflector::id2camel($this->context->module->id)
);
echo ($this->context->module->id !== \Yii::$app->id) ? '<small>Module</small>' : '';
} ?>
</h1>
<?php } ?>
<?=
Breadcrumbs::widget(
[
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]
) ?>
</section>
<section class="content">
<?= Alert::widget() ?>
<?= $content ?>
</section>
</div>
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 2.0
</div>
<strong>Copyright &copy; 2017 - <?= date('Y') ?> <a href="http://zertex.ru">Zertex</a>, Dashboard by <a href="http://almsaeedstudio.com">Almsaeed Studio</a>.</strong> All rights
reserved.
</footer>
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Create the tabs -->
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
<li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
<li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<!-- Home tab content -->
<div class="tab-pane" id="control-sidebar-home-tab">
<h3 class="control-sidebar-heading">Recent Activity</h3>
<ul class='control-sidebar-menu'>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-birthday-cake bg-red"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
<p>Will be 23 on April 24th</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-user bg-yellow"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>
<p>New phone +1(800)555-1234</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-envelope-o bg-light-blue"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>
<p>nora@example.com</p>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<i class="menu-icon fa fa-file-code-o bg-green"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>
<p>Execution time 5 seconds</p>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
<h3 class="control-sidebar-heading">Tasks Progress</h3>
<ul class='control-sidebar-menu'>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Custom Template Design
<span class="label label-danger pull-right">70%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Update Resume
<span class="label label-success pull-right">95%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-success" style="width: 95%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Laravel Integration
<span class="label label-waring pull-right">50%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-warning" style="width: 50%"></div>
</div>
</a>
</li>
<li>
<a href='javascript::;'>
<h4 class="control-sidebar-subheading">
Back End Framework
<span class="label label-primary pull-right">68%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-primary" style="width: 68%"></div>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
</div>
<!-- /.tab-pane -->
<!-- Settings tab content -->
<div class="tab-pane" id="control-sidebar-settings-tab">
<form method="post">
<h3 class="control-sidebar-heading">General Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Report panel usage
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Some information about this general settings option
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Allow mail redirect
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Other sets of options are available
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Expose author name in posts
<input type="checkbox" class="pull-right" checked/>
</label>
<p>
Allow the user to show his name in blog posts
</p>
</div>
<!-- /.form-group -->
<h3 class="control-sidebar-heading">Chat Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Show me as online
<input type="checkbox" class="pull-right" checked/>
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Turn off notifications
<input type="checkbox" class="pull-right"/>
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Delete chat history
<a href="javascript::;" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
</label>
</div>
<!-- /.form-group -->
</form>
</div>
<!-- /.tab-pane -->
</div>
</aside><!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class='control-sidebar-bg'></div>

30
backend/views/layouts/error.php

@ -0,0 +1,30 @@
<?php
use backend\assets\AppAsset;
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
dmstr\web\AdminLteAsset::register($this);
\backend\assets\AdminLteSkinAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

281
backend/views/layouts/header.php

@ -0,0 +1,281 @@
<?php
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
?>
<header class="main-header">
<?= Html::a('<span class="logo-mini">APP</span><span class="logo-lg">' . Yii::$app->name . '</span>', Yii::$app->homeUrl, ['class' => 'logo']) ?>
<nav class="navbar navbar-static-top" role="navigation">
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">Toggle navigation</span>
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<!-- Messages: style can be found in dropdown.less-->
<li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i>
<span class="label label-success">4</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 4 messages</li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<li><!-- start message -->
<a href="#">
<div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle"
alt="User Image"/>
</div>
<h4>
Support Team
<small><i class="fa fa-clock-o"></i> 5 mins</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<!-- end message -->
<li>
<a href="#">
<div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
AdminLTE Design Team
<small><i class="fa fa-clock-o"></i> 2 hours</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Developers
<small><i class="fa fa-clock-o"></i> Today</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Sales Department
<small><i class="fa fa-clock-o"></i> Yesterday</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
<li>
<a href="#">
<div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/>
</div>
<h4>
Reviewers
<small><i class="fa fa-clock-o"></i> 2 days</small>
</h4>
<p>Why not buy a new awesome theme?</p>
</a>
</li>
</ul>
</li>
<li class="footer"><a href="#">See All Messages</a></li>
</ul>
</li>
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<span class="label label-warning">10</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 10 notifications</li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<li>
<a href="#">
<i class="fa fa-users text-aqua"></i> 5 new members joined today
</a>
</li>
<li>
<a href="#">
<i class="fa fa-warning text-yellow"></i> Very long description here that may
not fit into the page and may cause design problems
</a>
</li>
<li>
<a href="#">
<i class="fa fa-users text-red"></i> 5 new members joined
</a>
</li>
<li>
<a href="#">
<i class="fa fa-shopping-cart text-green"></i> 25 sales made
</a>
</li>
<li>
<a href="#">
<i class="fa fa-user text-red"></i> You changed your username
</a>
</li>
</ul>
</li>
<li class="footer"><a href="#">View all</a></li>
</ul>
</li>
<!-- Tasks: style can be found in dropdown.less -->
<li class="dropdown tasks-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-flag-o"></i>
<span class="label label-danger">9</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 9 tasks</li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<li><!-- Task item -->
<a href="#">
<h3>
Design some buttons
<small class="pull-right">20%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-aqua" style="width: 20%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">20% Complete</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
<li><!-- Task item -->
<a href="#">
<h3>
Create a nice theme
<small class="pull-right">40%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 40%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">40% Complete</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
<li><!-- Task item -->
<a href="#">
<h3>
Some task I need to do
<small class="pull-right">60%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-red" style="width: 60%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">60% Complete</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
<li><!-- Task item -->
<a href="#">
<h3>
Make beautiful transitions
<small class="pull-right">80%</small>
</h3>
<div class="progress xs">
<div class="progress-bar progress-bar-yellow" style="width: 80%"
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">80% Complete</span>
</div>
</div>
</a>
</li>
<!-- end task item -->
</ul>
</li>
<li class="footer">
<a href="#">View all tasks</a>
</li>
</ul>
</li>
<!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="user-image" alt="User Image"/>
<span class="hidden-xs"><?= Yii::$app->user->identity->user->username ?></span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle"
alt="User Image"/>
<p>
<?= Yii::$app->user->identity->user->username ?> - Web Developer
<small>Member since Nov. 2012</small>
</p>
</li>
<!-- Menu Body -->
<li class="user-body">
<div class="col-xs-4 text-center">
<a href="#">Followers</a>
</div>
<div class="col-xs-4 text-center">
<a href="#">Sales</a>
</div>
<div class="col-xs-4 text-center">
<a href="#">Friends</a>
</div>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<a href="#" class="btn btn-default btn-flat"><?= Yii::t('main', 'Profile') ?></a>
</div>
<div class="pull-right">
<?= Html::a(
Yii::t('main', 'Sign out'),
['/auth/logout'],
['data-method' => 'post', 'class' => 'btn btn-default btn-flat']
) ?>
</div>
</li>
</ul>
</li>
<!-- User Account: style can be found in dropdown.less -->
<li>
<a href="#" data-toggle="control-sidebar"><i class="fa fa-gears"></i></a>
</li>
</ul>
</div>
</nav>
</header>

86
backend/views/layouts/left.php

@ -0,0 +1,86 @@
<aside class="main-sidebar">
<section class="sidebar">
<!-- Sidebar user panel -->
<div class="user-panel">
<div class="pull-left image">
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle" alt="User Image"/>
</div>
<div class="pull-left info">
<p><?= Yii::$app->user->identity->user->username ?></p>
<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
</div>
</div>
<!-- search form -->
<form action="#" method="get" class="sidebar-form">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Search..."/>
<span class="input-group-btn">
<button type='submit' name='search' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i>
</button>
</span>
</div>
</form>
<!-- /.search form -->
<?= dmstr\widgets\Menu::widget(
[
'options' => ['class' => 'sidebar-menu tree', 'data-widget'=> 'tree'],
'items' => [
['label' => Yii::t('main', 'Menu'), 'options' => ['class' => 'header']],
[
'label' => Yii::t('dashboard', 'Dashboard'),
'icon' => 'dashboard',
'url' => ['/site/index'],
'active' => $this->context->id == '/site/index'],
[
'label' => Yii::t('user', 'Users'),
'icon' => 'user',
'url' => ['/user/index'],
'active' => $this->context->id == 'user',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement'),
],
['label' => Yii::t('user', 'Access Rules'), 'icon' => 'lock', 'items' => [
['label' => Yii::t('user', 'Roles'), 'icon' => 'caret-right', 'url' => ['/role/index'], 'active' => \Yii::$app->controller->getUniqueId() == 'role'],
['label' => Yii::t('user', 'Permissions'), 'icon' => 'caret-right', 'url' => ['/permission/index'], 'active' => \Yii::$app->controller->getUniqueId() == 'permission'],
], 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('UserManagement')],
[
'label' => Yii::t('page', 'Pages'),
'icon' => 'file-o', 'url' => ['/page/index'],
'active' => $this->context->id == 'page',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PagesManagement'),
],
['label' => Yii::t('post', 'Posts'), 'icon' => 'newspaper-o', 'items' => array_merge(
array_map(function(\core\entities\post\PostType $type) {
return ['label' => $type->plural, 'icon' => 'caret-right', 'items' => [
['label' => Yii::t('post', 'Categories'), 'icon' => 'caret-right', 'url' => ['/post/category', 'tid' => $type->id], 'active' => \Yii::$app->controller->getUniqueId() == 'post/category' && \Yii::$app->request->get('tid') == $type->id],
['label' => $type->plural, 'icon' => 'caret-right', 'url' => ['/post/post', 'tid' => $type->id], 'active' => \Yii::$app->controller->getUniqueId() == 'post/post' && \Yii::$app->request->get('tid') == $type->id],
['label' => Yii::t('post', 'Tags'), 'icon' => 'caret-right', 'url' => ['/post/tag', 'tid' => $type->id], 'active' => \Yii::$app->controller->getUniqueId() == 'post/tag' && \Yii::$app->request->get('tid') == $type->id],
]];
}, \core\entities\post\PostType::find()->all()),
[['label' => Yii::t('post', 'Comments'), 'icon' => 'caret-right', 'url' => ['/post/comment'], 'active' => \Yii::$app->controller->getUniqueId() == 'post/comment']],
[['label' => Yii::t('post', 'Types'), 'icon' => 'caret-right', 'url' => ['/post/type'], 'active' => \Yii::$app->controller->getUniqueId() == 'post/type']]
), 'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('PostManagement')],
[
'label' => Yii::t('slider', 'Slider'),
'icon' => 'retweet', 'url' => ['/slider/index'],
'active' => $this->context->id == 'slider',
'visible' => \Yii::$app->user->can('admin') || \Yii::$app->user->can('SliderManagement'),
],
],
]
) ?>
</section>
</aside>

30
backend/views/layouts/main-login.php

@ -0,0 +1,30 @@
<?php
use backend\assets\AppAsset;
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
dmstr\web\AdminLteAsset::register($this);
\backend\assets\AdminLteSkinAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body class="login-page">
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

65
backend/views/layouts/main.php

@ -0,0 +1,65 @@
<?php
use yii\helpers\Html;
/* @var $this \yii\web\View */
/* @var $content string */
if (Yii::$app->controller->action->id === 'login') {
/**
* Do not use this code in your template. Remove it.
* Instead, use the code $this->layout = '//main-login'; in your controller.
*/
echo $this->render(
'main-login',
['content' => $content]
);
} else {
if (class_exists('backend\assets\AppAsset')) {
backend\assets\AppAsset::register($this);
} else {
app\assets\AppAsset::register($this);
}
dmstr\web\AdminLteAsset::register($this);
\backend\assets\AdminLteSkinAsset::register($this);
$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist');
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<?php $this->beginBody() ?>
<div class="wrapper">
<?= $this->render(
'header.php',
['directoryAsset' => $directoryAsset]
) ?>
<?= $this->render(
'left.php',
['directoryAsset' => $directoryAsset]
)
?>
<?= $this->render(
'content.php',
['content' => $content, 'directoryAsset' => $directoryAsset]
) ?>
</div>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
<?php } ?>

42
backend/views/page/_form.php

@ -0,0 +1,42 @@
<?php
use mihaildev\ckeditor\CKEditor;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model core\forms\PageForm */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="page-form">
<?php $form = ActiveForm::begin(); ?>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('page', 'Common') ?></div>
<div class="box-body">
<?= $form->field($model, 'parentId')->dropDownList($model->parentsList()) ?>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('page', 'SEO') ?></div>
<div class="box-body">
<?= $form->field($model->meta, 'title')->textInput() ?>
<?= $form->field($model->meta, 'description')->textarea(['rows' => 2]) ?>
<?= $form->field($model->meta, 'keywords')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('page', Yii::t('buttons', 'Save')), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

16
backend/views/page/create.php

@ -0,0 +1,16 @@
<?php
/* @var $this yii\web\View */
/* @var $model core\forms\PageForm */
$this->title = Yii::t('page', 'Create Page');
$this->params['breadcrumbs'][] = ['label' => Yii::t('page', 'Pages'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="page-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

55
backend/views/page/index.php

@ -0,0 +1,55 @@
<?php
use core\entities\Page;
use yii\grid\ActionColumn;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\forms\PageSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('page', 'Pages');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-index">
<p>
<?= Html::a(Yii::t('page','Create Page'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<div class="box">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'title',
'value' => function (Page $model) {
$indent = ($model->depth > 1 ? str_repeat('&nbsp;&nbsp;', $model->depth - 1) . ' ' : '');
return $indent . Html::a(Html::encode($model->title), ['view', 'id' => $model->id]);
},
'format' => 'raw',
],
[
'value' => function (Page $model) {
return
Html::a('<span class="glyphicon glyphicon-arrow-up"></span>', ['move-up', 'id' => $model->id]) .
Html::a('<span class="glyphicon glyphicon-arrow-down"></span>', ['move-down', 'id' => $model->id]);
},
'format' => 'raw',
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['style' => 'text-align: center'],
],
'slug',
[
'class' => ActionColumn::class,
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

18
backend/views/page/update.php

@ -0,0 +1,18 @@
<?php
/* @var $this yii\web\View */
/* @var $page core\entities\Page */
/* @var $model core\forms\PageForm */
$this->title = Yii::t('page', 'Update Page: {name}', ['name' => $page->title]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('page', 'Pages'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $page->title, 'url' => ['view', 'id' => $page->id]];
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing');
?>
<div class="page-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

76
backend/views/page/view.php

@ -0,0 +1,76 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $page core\entities\Page */
$this->title = $page->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('page', 'Pages'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-view">
<p>
<?= Html::a(Yii::t('page','Pages'), ['index'], ['class' => 'btn btn-default']) ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $page->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $page->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box">
<div class="box-header with-border"><?= Yii::t('page', 'Common') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $page,
'attributes' => [
'id',
'title',
'slug',
],
]) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('page', 'Content') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asHtml($page->content, [
'Attr.AllowedRel' => array('nofollow'),
'HTML.SafeObject' => true,
'Output.FlashCompat' => true,
'HTML.SafeIframe' => true,
'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%',
]) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('page', 'SEO') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $page,
'attributes' => [
[
'attribute' => 'meta.title',
'label' => Yii::t('main', 'Title'),
],
[
'attribute' => 'meta.description',
'label' => Yii::t('main', 'Description'),
],
[
'attribute' => 'meta.keywords',
'label' => Yii::t('main', 'Keywords'),
],
],
]) ?>
</div>
</div>
</div>

33
backend/views/permission/create.php

@ -0,0 +1,33 @@
<?php
/* @var $this yii\web\View */
/* @var $model \backend\forms\rbac\RbacCreatePermissionForm */
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
$this->title = Yii::t('user', 'Create Permission');
$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Permissions'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="users-rbac-permission-create">
<?php $form = ActiveForm::begin(); ?>
<div class="box box-default">
<div class="box-body">
<?= $form->field($model, 'name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'description')->textarea() ?>
<?= $form->field($model, 'rule_name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'data')->textarea() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

42
backend/views/permission/index.php

@ -0,0 +1,42 @@
<?php
use yii\grid\ActionColumn;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ArrayDataProvider */
$this->title = Yii::t('user', 'Permissions');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="users-rbac-permission-index">
<p>
<?= Html::a(Yii::t('user', 'Create Permission'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<div class="box box-default">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'name',
'label' => Yii::t('user', 'Permission Name'),
],
[
'attribute' => 'description',
'label' => Yii::t('user', 'Permission Description'),
],
[
'class' => ActionColumn::class,
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

33
backend/views/permission/update.php

@ -0,0 +1,33 @@
<?php
/* @var $this yii\web\View */
/* @var $model \backend\forms\rbac\RbacEditPermissionForm */
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
$this->title = Yii::t('user', 'Update Permission: {permission}', ['permission' => $model->name]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Permissions'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->name]];
$this->params['breadcrumbs'][] = Yii::t('user', 'Editing');
?>
<div class="users-rbac-permission-update">
<?php $form = ActiveForm::begin(); ?>
<div class="box box-default">
<div class="box-body">
<?= $form->field($model, 'name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'description')->textarea() ?>
<?= $form->field($model, 'rule_name')->textInput(['maxLength' => true]) ?>
<?= $form->field($model, 'data')->textarea() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

50
backend/views/permission/view.php

@ -0,0 +1,50 @@
<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model \yii\rbac\Role */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Permissions'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="users-rbac-permission-view">
<p>
<?= Html::a(Yii::t('user', 'Permissions'), ['index'], ['class' => 'btn btn-default']) ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $model->name], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $model->name], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box box-default">
<div class="box-body">
<?= DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' => 'name',
'label' => Yii::t('user', 'Role Name'),
],
[
'attribute' => 'description',
'label' => Yii::t('user', 'Role Description'),
],
[
'attribute' => 'ruleName',
'label' => Yii::t('user', 'Rule Name'),
],
],
]) ?>
</div>
</div>
</div>

139
backend/views/post/articles/_form.php

@ -0,0 +1,139 @@
<?php
use kartik\file\FileInput;
use mihaildev\ckeditor\CKEditor;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\web\JsExpression;
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] );
if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS
var arr = {$tagsJson};
$.each(JSON.parse(arr), function( key, value ) {
$("#posttagform-new_tags").append("<option value='"+value+"' selected>"+value+"</option>");
});
$('#posttagform-new_tags').trigger('change');
JS;
$this->registerJs( $js, $this::POS_READY );
}
?>
<div class="post-form">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']
]); ?>
<div class="row">
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [
'options' => [],
'pluginOptions' => [
'autoclose' => true,
'format' => 'dd.mm.yyyy hh:ii:ss',
]
]); ?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [
'options' => [
'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true,
],
'pluginOptions' => [
'tags' => true,
'tokenSeparators' => [',', ' '],
'maximumInputLength' => 12,
'ajax' => [
'url' => $fetchUrl,
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term, type_id:' . $model->type_id . '}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(tag) { return tag.text; }'),
'templateSelection' => new JsExpression('function (tag) { return tag.text; }'),
],
])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#field_image"><?= Yii::t('post', 'Image') ?></a></li>
<li><a data-toggle="tab" href="#field_video"><?= Yii::t('post', 'Video') ?></a></li>
</ul>
<div class="tab-content">
<div id="field_image" class="tab-pane fade in active" style="padding-top: 20px;">
<?= $form->field($model, 'image')->label(false)->widget(FileInput::class, [
'options' => [
'accept' => 'image/*',
],
'pluginOptions' => [
'showUpload' => false,
],
]) ?>
<?php if (isset($model->_post) && $model->_post->image): ?>
<?= Html::img($model->_post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
<?= $form->field($model, 'reset_image')->checkbox() ?>
<?php endif; ?>
</div>
<div id="field_video" class="tab-pane fade" style="padding-top: 20px;">
<?= $form->field($model, 'video')->textInput()->label(Yii::t('post', 'YouTube URL'))->hint(Yii::t('post', 'If a video link is specified, the image will be used as a preview image')) ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= $form->field($model->meta, 'title')->textInput() ?>
<?= $form->field($model->meta, 'description')->textarea(['rows' => 2]) ?>
<?= $form->field($model->meta, 'keywords')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

18
backend/views/post/articles/create.php

@ -0,0 +1,18 @@
<?php
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Create Post');
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $title;
?>
<div class="post-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

83
backend/views/post/articles/index.php

@ -0,0 +1,83 @@
<?php
use core\entities\post\Post;
use core\helpers\PostHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title;
$this->params['breadcrumbs'][] = $title;
?>
<div class="blog-post-index">
<p>
<?= Html::a(Yii::t('post', 'Create Post'), ['create', 'tid' => $type->id], ['class' => 'btn btn-success']) ?>
</p>
<div class="box">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
/*[
'value' => function (Post $model) {
return $model->image ? Html::img($model->getThumbFileUrl('image', 'admin')) : null;
},
'format' => 'raw',
'contentOptions' => ['style' => 'width: 100px'],
],*/
[
'attribute' => 'id',
'options' => ['style' => 'width: 40px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'title',
'value' => function (Post $model) {
return Html::a(Html::encode($model->title), ['view', 'id' => $model->id]);
},
'format' => 'raw',
],
[
'attribute' => 'category_id',
'filter' => $searchModel->categoriesList(),
'value' => 'category.name',
],
[
'attribute' => 'published_at',
'format' => ['datetime', 'php:d.m.Y H:i'],
'options' => ['style' => 'width: 60px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'status',
'filter' => $searchModel->statusList(),
'value' => function (Post $model) {
return PostHelper::statusLabel($model->status);
},
'format' => 'raw',
'options' => ['style' => 'width: 120px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'class' => \yii\grid\ActionColumn::class,
'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params);
},
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

20
backend/views/post/articles/update.php

@ -0,0 +1,20 @@
<?php
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]];
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing');
?>
<div class="post-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

139
backend/views/post/articles/view.php

@ -0,0 +1,139 @@
<?php
use core\helpers\PostHelper;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = $post->title;
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $type->singular;
?>
<div class="user-view">
<p>
<?= Html::a(Yii::t('post', 'All Posts'), ['index', 'tid' => $type->id], ['class' => 'btn btn-default']) ?>
<?php if ($post->isActive()): ?>
<?= Html::a(Yii::t('post', 'Draft'), ['draft', 'id' => $post->id], ['class' => 'btn btn-primary', 'data-method' => 'post']) ?>
<?php else: ?>
<?= Html::a(Yii::t('post', 'Activate'), ['activate', 'id' => $post->id], ['class' => 'btn btn-success', 'data-method' => 'post']) ?>
<?php endif; ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $post->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $post->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
'id',
[
'attribute' => 'status',
'value' => PostHelper::statusLabel($post->status),
'format' => 'raw',
],
'title',
[
'attribute' => 'category_id',
'value' => ArrayHelper::getValue($post, 'category.name'),
],
[
'label' => Yii::t('post', 'Tags'),
'value' => implode(', ', ArrayHelper::getColumn($post->tags, 'name')),
],
],
]) ?>
</div>
</div>
<?php if ($post->image): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img($post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
</div>
</div>
<?php endif; ?>
<?php if (!$post->image && $post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img('https://i.ytimg.com/vi/' . PostHelper::parseYoutubeUrl($post->video) . '/maxresdefault.jpg', [
'width' => 300,
'class' => 'thumbnail',
]) ?>
</div>
</div>
<?php endif; ?>
<?php if ($post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Video') ?></div>
<div class="box-body">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?= PostHelper::parseYoutubeUrl($post->video) ?>?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<?php endif; ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Description') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asNtext($post->description) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Content') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asHtml($post->content, [
'Attr.AllowedRel' => array('nofollow'),
'HTML.SafeObject' => true,
'Output.FlashCompat' => true,
'HTML.SafeIframe' => true,
'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%',
]) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
[
'attribute' => 'meta.title',
'value' => $post->meta->title,
],
[
'attribute' => 'meta.description',
'value' => $post->meta->description,
],
[
'attribute' => 'meta.keywords',
'value' => $post->meta->keywords,
],
],
]) ?>
</div>
</div>
</div>

139
backend/views/post/blog/_form.php

@ -0,0 +1,139 @@
<?php
use kartik\file\FileInput;
use mihaildev\ckeditor\CKEditor;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\web\JsExpression;
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] );
if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS
var arr = {$tagsJson};
$.each(JSON.parse(arr), function( key, value ) {
$("#posttagform-new_tags").append("<option value='"+value+"' selected>"+value+"</option>");
});
$('#posttagform-new_tags').trigger('change');
JS;
$this->registerJs( $js, $this::POS_READY );
}
?>
<div class="post-form">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']
]); ?>
<div class="row">
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [
'options' => [],
'pluginOptions' => [
'autoclose' => true,
'format' => 'dd.mm.yyyy hh:ii:ss',
]
]); ?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [
'options' => [
'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true,
],
'pluginOptions' => [
'tags' => true,
'tokenSeparators' => [',', ' '],
'maximumInputLength' => 12,
'ajax' => [
'url' => $fetchUrl,
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term, type_id:' . $model->type_id . '}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(tag) { return tag.text; }'),
'templateSelection' => new JsExpression('function (tag) { return tag.text; }'),
],
])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#field_image"><?= Yii::t('post', 'Image') ?></a></li>
<li><a data-toggle="tab" href="#field_video"><?= Yii::t('post', 'Video') ?></a></li>
</ul>
<div class="tab-content">
<div id="field_image" class="tab-pane fade in active" style="padding-top: 20px;">
<?= $form->field($model, 'image')->label(false)->widget(FileInput::class, [
'options' => [
'accept' => 'image/*',
],
'pluginOptions' => [
'showUpload' => false,
],
]) ?>
<?php if (isset($model->_post) && $model->_post->image): ?>
<?= Html::img($model->_post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
<?= $form->field($model, 'reset_image')->checkbox() ?>
<?php endif; ?>
</div>
<div id="field_video" class="tab-pane fade" style="padding-top: 20px;">
<?= $form->field($model, 'video')->textInput()->label(Yii::t('post', 'YouTube URL'))->hint(Yii::t('post', 'If a video link is specified, the image will be used as a preview image')) ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= $form->field($model->meta, 'title')->textInput() ?>
<?= $form->field($model->meta, 'description')->textarea(['rows' => 2]) ?>
<?= $form->field($model->meta, 'keywords')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

18
backend/views/post/blog/create.php

@ -0,0 +1,18 @@
<?php
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Create Post');
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $title;
?>
<div class="post-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

83
backend/views/post/blog/index.php

@ -0,0 +1,83 @@
<?php
use core\entities\post\Post;
use core\helpers\PostHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title;
$this->params['breadcrumbs'][] = $title;
?>
<div class="blog-post-index">
<p>
<?= Html::a(Yii::t('post', 'Create Post'), ['create', 'tid' => $type->id], ['class' => 'btn btn-success']) ?>
</p>
<div class="box">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
/*[
'value' => function (Post $model) {
return $model->image ? Html::img($model->getThumbFileUrl('image', 'admin')) : null;
},
'format' => 'raw',
'contentOptions' => ['style' => 'width: 100px'],
],*/
[
'attribute' => 'id',
'options' => ['style' => 'width: 40px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'title',
'value' => function (Post $model) {
return Html::a(Html::encode($model->title), ['view', 'id' => $model->id]);
},
'format' => 'raw',
],
[
'attribute' => 'category_id',
'filter' => $searchModel->categoriesList(),
'value' => 'category.name',
],
[
'attribute' => 'published_at',
'format' => ['datetime', 'php:d.m.Y H:i'],
'options' => ['style' => 'width: 60px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'status',
'filter' => $searchModel->statusList(),
'value' => function (Post $model) {
return PostHelper::statusLabel($model->status);
},
'format' => 'raw',
'options' => ['style' => 'width: 120px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'class' => \yii\grid\ActionColumn::class,
'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params);
},
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

20
backend/views/post/blog/update.php

@ -0,0 +1,20 @@
<?php
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]];
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing');
?>
<div class="post-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

139
backend/views/post/blog/view.php

@ -0,0 +1,139 @@
<?php
use core\helpers\PostHelper;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = $post->title;
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $type->singular;
?>
<div class="user-view">
<p>
<?= Html::a(Yii::t('post', 'All Posts'), ['index', 'tid' => $type->id], ['class' => 'btn btn-default']) ?>
<?php if ($post->isActive()): ?>
<?= Html::a(Yii::t('post', 'Draft'), ['draft', 'id' => $post->id], ['class' => 'btn btn-primary', 'data-method' => 'post']) ?>
<?php else: ?>
<?= Html::a(Yii::t('post', 'Activate'), ['activate', 'id' => $post->id], ['class' => 'btn btn-success', 'data-method' => 'post']) ?>
<?php endif; ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $post->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $post->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
'id',
[
'attribute' => 'status',
'value' => PostHelper::statusLabel($post->status),
'format' => 'raw',
],
'title',
[
'attribute' => 'category_id',
'value' => ArrayHelper::getValue($post, 'category.name'),
],
[
'label' => Yii::t('post', 'Tags'),
'value' => implode(', ', ArrayHelper::getColumn($post->tags, 'name')),
],
],
]) ?>
</div>
</div>
<?php if ($post->image): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img($post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
</div>
</div>
<?php endif; ?>
<?php if (!$post->image && $post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img('https://i.ytimg.com/vi/' . PostHelper::parseYoutubeUrl($post->video) . '/maxresdefault.jpg', [
'width' => 300,
'class' => 'thumbnail',
]) ?>
</div>
</div>
<?php endif; ?>
<?php if ($post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Video') ?></div>
<div class="box-body">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?= PostHelper::parseYoutubeUrl($post->video) ?>?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<?php endif; ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Description') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asNtext($post->description) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Content') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asHtml($post->content, [
'Attr.AllowedRel' => array('nofollow'),
'HTML.SafeObject' => true,
'Output.FlashCompat' => true,
'HTML.SafeIframe' => true,
'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%',
]) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
[
'attribute' => 'meta.title',
'value' => $post->meta->title,
],
[
'attribute' => 'meta.description',
'value' => $post->meta->description,
],
[
'attribute' => 'meta.keywords',
'value' => $post->meta->keywords,
],
],
]) ?>
</div>
</div>
</div>

54
backend/views/post/category/_form.php

@ -0,0 +1,54 @@
<?php
use mihaildev\ckeditor\CKEditor;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostCategoryForm */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="category-form">
<?php $form = ActiveForm::begin(); ?>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<div class="row">
<div class="col-md-2">
<?= $form->field($model, 'sort')->textInput(['maxlength' => true]) ?>
</div>
<div class="col-md-5">
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
<div class="col-md-5">
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
</div>
</div>
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->widget(CKEditor::className()) ?>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= $form->field($model->meta, 'title')->textInput() ?>
<?= $form->field($model->meta, 'description')->textarea(['rows' => 2]) ?>
<?= $form->field($model->meta, 'keywords')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons','Save'), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

18
backend/views/post/category/create.php

@ -0,0 +1,18 @@
<?php
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostCategoryForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Create Category');
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Categories'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $title;
?>
<div class="category-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

55
backend/views/post/category/index.php

@ -0,0 +1,55 @@
<?php
use core\entities\post\PostCategory;
use yii\grid\ActionColumn;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostCategorySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Categories');
$this->title = $type->plural .' > '. $title;
$this->params['breadcrumbs'][] = $title;
?>
<div class="user-index">
<p>
<?= Html::a(Yii::t('post', 'Create Category'), ['create', 'tid' => $type->id], ['class' => 'btn btn-success']) ?>
</p>
<div class="box">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'sort',
'options' => ['style' => 'width: 100px;'],
],
[
'attribute' => 'name',
'value' => function (PostCategory $model) {
return Html::a(Html::encode($model->name), ['view', 'id' => $model->id]);
},
'format' => 'raw',
],
[
'attribute' => 'slug',
],
[
'attribute' => 'title',
],
[
'class' => ActionColumn::class,
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

20
backend/views/post/category/update.php

@ -0,0 +1,20 @@
<?php
/* @var $this yii\web\View */
/* @var $category \core\entities\post\PostCategory */
/* @var $model \core\forms\post\PostCategoryForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Update: {name}', ['name' => $category->name]);
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Categories'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $category->name, 'url' => ['view', 'id' => $category->id]];
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing');
?>
<div class="category-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

71
backend/views/post/category/view.php

@ -0,0 +1,71 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $category \core\entities\post\PostCategory */
/* @var $type \core\entities\post\PostType */
$title = $category->name;
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Categories'), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $title;
?>
<div class="user-view">
<p>
<?= Html::a(Yii::t('post', 'Categories'), ['index', 'tid' => $type->id], ['class' => 'btn btn-default']) ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $category->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $category->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $category,
'attributes' => [
'id',
'name',
'slug',
'title',
'sort',
],
]) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Description') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asHtml($category->description, [
'Attr.AllowedRel' => array('nofollow'),
'HTML.SafeObject' => true,
'Output.FlashCompat' => true,
'HTML.SafeIframe' => true,
'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%',
]) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $category,
'attributes' => [
'meta.title',
'meta.description',
'meta.keywords',
],
]) ?>
</div>
</div>
</div>

54
backend/views/post/comment/index.php

@ -0,0 +1,54 @@
<?php
use core\entities\post\PostComment;
use yii\grid\ActionColumn;
use yii\grid\GridView;
use yii\helpers\StringHelper;
/* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostCommentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('post', 'Comments');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="blog-comments-index">
<div class="box">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'id',
'options' => ['style' => 'width: 40px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'text',
'value' => function (PostComment $model) {
return StringHelper::truncate(strip_tags($model->text), 100);
},
],
[
'attribute' => 'created_at',
'format' => ['datetime', 'php:d.m.Y H:i'],
'options' => ['style' => 'width: 60px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'active',
'filter' => $searchModel->activeList(),
'format' => 'boolean',
'contentOptions' => ['style' => 'width: 150px'],
],
[
'class' => ActionColumn::class,
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

34
backend/views/post/comment/update.php

@ -0,0 +1,34 @@
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $model \core\forms\post\PostCommentEditForm */
$this->title = Yii::t('post', 'Update Post Comment: {name}', ['name' => $post->title]);
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Comment'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $post->title, 'url' => ['view', 'id' => $post->id]];
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing');
?>
<div class="post-update">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']
]); ?>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= $form->field($model, 'parentId')->textInput() ?>
<?= $form->field($model, 'text')->textarea(['rows' => 20]) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

70
backend/views/post/comment/view.php

@ -0,0 +1,70 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use core\entities\user\User;
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $comment \core\entities\post\PostComment */
/* @var $modificationsProvider yii\data\ActiveDataProvider */
$this->title = $post->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Comments'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="user-view">
<p>
<?= Html::a(Yii::t('post', 'Comments'), ['index'], ['class' => 'btn btn-default']) ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'post_id' => $post->id, 'id' => $comment->id], ['class' => 'btn btn-primary']) ?>
<?php if ($comment->isActive()): ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'post_id' => $post->id, 'id' => $comment->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
<?php else: ?>
<?= Html::a(Yii::t('buttons', 'Restore'), ['activate', 'post_id' => $post->id, 'id' => $comment->id], [
'class' => 'btn btn-success',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to activate this item?'),
'method' => 'post',
],
]) ?>
<?php endif; ?>
</p>
<div class="box">
<div class="box-body">
<?= DetailView::widget([
'model' => $comment,
'attributes' => [
'id',
'created_at:boolean',
'active:boolean',
[
'attribute' => 'user_id',
'value' => function(\core\entities\post\PostComment $comment) {
return User::findOne($comment->user_id)->username;
},
],
'parent_id',
[
'attribute' => 'post_id',
'value' => $post->title,
],
],
]) ?>
</div>
</div>
<div class="box">
<div class="box-body">
<?= Yii::$app->formatter->asNtext($comment->text) ?>
</div>
</div>
</div>

139
backend/views/post/gallery/_form.php

@ -0,0 +1,139 @@
<?php
use kartik\file\FileInput;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\web\JsExpression;
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] );
if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS
var arr = {$tagsJson};
$.each(JSON.parse(arr), function( key, value ) {
$("#posttagform-new_tags").append("<option value='"+value+"' selected>"+value+"</option>");
});
$('#posttagform-new_tags').trigger('change');
JS;
$this->registerJs( $js, $this::POS_READY );
}
?>
<div class="post-form">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']
]); ?>
<div class="row">
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [
'options' => [],
'pluginOptions' => [
'autoclose' => true,
'format' => 'dd.mm.yyyy hh:ii:ss',
]
]); ?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [
'options' => [
'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true,
],
'pluginOptions' => [
'tags' => true,
'tokenSeparators' => [',', ' '],
'maximumInputLength' => 12,
'ajax' => [
'url' => $fetchUrl,
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term, type_id:' . $model->type_id . '}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(tag) { return tag.text; }'),
'templateSelection' => new JsExpression('function (tag) { return tag.text; }'),
],
])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#field_image"><?= Yii::t('post', 'Image') ?></a></li>
<li><a data-toggle="tab" href="#field_video"><?= Yii::t('post', 'Video') ?></a></li>
</ul>
<div class="tab-content">
<div id="field_image" class="tab-pane fade in active" style="padding-top: 20px;">
<?= $form->field($model, 'image')->label(false)->widget(FileInput::class, [
'options' => [
'accept' => 'image/*',
],
'pluginOptions' => [
'showUpload' => false,
],
]) ?>
<?php if (isset($model->_post) && $model->_post->image): ?>
<?= Html::img($model->_post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
<?= $form->field($model, 'reset_image')->checkbox() ?>
<?php endif; ?>
</div>
<div id="field_video" class="tab-pane fade" style="padding-top: 20px;">
<?= $form->field($model, 'video')->textInput()->label(Yii::t('post', 'YouTube URL'))->hint(Yii::t('post', 'If a video link is specified, the image will be used as a preview image')) ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= $form->field($model->meta, 'title')->textInput() ?>
<?= $form->field($model->meta, 'description')->textarea(['rows' => 2]) ?>
<?= $form->field($model->meta, 'keywords')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

18
backend/views/post/gallery/create.php

@ -0,0 +1,18 @@
<?php
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Add Image');
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Gallery'), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $title;
?>
<div class="post-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

83
backend/views/post/gallery/index.php

@ -0,0 +1,83 @@
<?php
use core\entities\post\Post;
use core\helpers\PostHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title;
$this->params['breadcrumbs'][] = $title;
?>
<div class="blog-post-index">
<p>
<?= Html::a(Yii::t('post', 'Create Post'), ['create', 'tid' => $type->id], ['class' => 'btn btn-success']) ?>
</p>
<div class="box">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
/*[
'value' => function (Post $model) {
return $model->image ? Html::img($model->getThumbFileUrl('image', 'admin')) : null;
},
'format' => 'raw',
'contentOptions' => ['style' => 'width: 100px'],
],*/
[
'attribute' => 'id',
'options' => ['style' => 'width: 40px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'title',
'value' => function (Post $model) {
return Html::a(Html::encode($model->title), ['view', 'id' => $model->id]);
},
'format' => 'raw',
],
[
'attribute' => 'category_id',
'filter' => $searchModel->categoriesList(),
'value' => 'category.name',
],
[
'attribute' => 'published_at',
'format' => ['datetime', 'php:d.m.Y H:i'],
'options' => ['style' => 'width: 60px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'status',
'filter' => $searchModel->statusList(),
'value' => function (Post $model) {
return PostHelper::statusLabel($model->status);
},
'format' => 'raw',
'options' => ['style' => 'width: 120px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'class' => \yii\grid\ActionColumn::class,
'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params);
},
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

20
backend/views/post/gallery/update.php

@ -0,0 +1,20 @@
<?php
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $post->title, 'url' => ['view', 'id' => $post->id]];
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing');
?>
<div class="post-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

126
backend/views/post/gallery/view.php

@ -0,0 +1,126 @@
<?php
use core\helpers\PostHelper;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = $post->title;
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', 'Gallery'), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $title;
?>
<div class="user-view">
<p>
<?= Html::a(Yii::t('post', 'All Posts'), ['index', 'tid' => $type->id], ['class' => 'btn btn-default']) ?>
<?php if ($post->isActive()): ?>
<?= Html::a(Yii::t('post', 'Draft'), ['draft', 'id' => $post->id], ['class' => 'btn btn-primary', 'data-method' => 'post']) ?>
<?php else: ?>
<?= Html::a(Yii::t('post', 'Activate'), ['activate', 'id' => $post->id], ['class' => 'btn btn-success', 'data-method' => 'post']) ?>
<?php endif; ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $post->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $post->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
'id',
[
'attribute' => 'status',
'value' => PostHelper::statusLabel($post->status),
'format' => 'raw',
],
'title',
[
'attribute' => 'category_id',
'value' => ArrayHelper::getValue($post, 'category.name'),
],
[
'label' => Yii::t('post', 'Tags'),
'value' => implode(', ', ArrayHelper::getColumn($post->tags, 'name')),
],
],
]) ?>
</div>
</div>
<?php if ($post->image): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img($post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
</div>
</div>
<?php endif; ?>
<?php if (!$post->image && $post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img('https://i.ytimg.com/vi/' . PostHelper::parseYoutubeUrl($post->video) . '/maxresdefault.jpg', [
'width' => 300,
'class' => 'thumbnail',
]) ?>
</div>
</div>
<?php endif; ?>
<?php if ($post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Video') ?></div>
<div class="box-body">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?= PostHelper::parseYoutubeUrl($post->video) ?>?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<?php endif; ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Description') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asNtext($post->description) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
[
'attribute' => 'meta.title',
'value' => $post->meta->title,
],
[
'attribute' => 'meta.description',
'value' => $post->meta->description,
],
[
'attribute' => 'meta.keywords',
'value' => $post->meta->keywords,
],
],
]) ?>
</div>
</div>
</div>

140
backend/views/post/news/_form.php

@ -0,0 +1,140 @@
<?php
use kartik\file\FileInput;
use mihaildev\ckeditor\CKEditor;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\web\JsExpression;
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $form yii\widgets\ActiveForm */
$fetchUrl = \yii\helpers\Url::to( [ 'tag-search' ] );
if (isset($model->_post)) {
$tagsJson = \yii\helpers\Json::encode( \yii\helpers\Json::encode( \yii\helpers\ArrayHelper::map( $model->_post->tags, 'id', 'name' ) ) );
$js = <<<JS
var arr = {$tagsJson};
$.each(JSON.parse(arr), function( key, value ) {
$("#posttagform-new_tags").append("<option value='"+value+"' selected>"+value+"</option>");
});
$('#posttagform-new_tags').trigger('change');
JS;
$this->registerJs( $js, $this::POS_READY );
}
?>
<div class="post-form">
<?php $form = ActiveForm::begin([
'options' => ['enctype'=>'multipart/form-data']
]); ?>
<div class="row">
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= $form->field($model, 'category_id')->dropDownList($model->categoriesList($model->type_id), ['prompt' => '']) ?>
<?= $form->field($model, 'published_at')->widget(\kartik\widgets\DateTimePicker::classname(), [
'options' => [],
'pluginOptions' => [
'autoclose' => true,
'format' => 'dd.mm.yyyy hh:ii:ss',
]
]); ?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'Tags') ?></div>
<div class="box-body">
<?= $form->field($model->tags, 'new_tags')->widget(\kartik\widgets\Select2::classname(), [
'options' => [
'placeholder' => Yii::t('post','Set tags...'),
'multiple' => true,
],
'pluginOptions' => [
'tags' => true,
'tokenSeparators' => [',', ' '],
'maximumInputLength' => 12,
'ajax' => [
'url' => $fetchUrl,
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term, type_id:' . $model->type_id . '}; }')
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(tag) { return tag.text; }'),
'templateSelection' => new JsExpression('function (tag) { return tag.text; }'),
],
])->label(false); ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'description')->textarea(['rows' => 5]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className()) ?>
</div>
</div>
<div class="box box-default">
<div class="box-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#field_image"><?= Yii::t('post', 'Image') ?></a></li>
<li><a data-toggle="tab" href="#field_video"><?= Yii::t('post', 'Video') ?></a></li>
</ul>
<div class="tab-content">
<div id="field_image" class="tab-pane fade in active" style="padding-top: 20px;">
<?= $form->field($model, 'image')->label(false)->widget(FileInput::class, [
'options' => [
'accept' => 'image/*',
],
'pluginOptions' => [
'showUpload' => false,
],
]) ?>
<?php if (isset($model->_post) && $model->_post->image): ?>
<?= Html::img($model->_post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
<?= $form->field($model, 'reset_image')->checkbox() ?>
<?php endif; ?>
</div>
<div id="field_video" class="tab-pane fade" style="padding-top: 20px;">
<?= $form->field($model, 'video')->textInput()->label(Yii::t('post', 'YouTube URL'))->hint(Yii::t('post', 'If a video link is specified, the image will be used as a preview image')) ?>
</div>
</div>
</div>
</div>
<div class="box box-default">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= $form->field($model->meta, 'title')->textInput() ?>
<?= $form->field($model->meta, 'description')->textarea(['rows' => 2]) ?>
<?= $form->field($model->meta, 'keywords')->textInput() ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

18
backend/views/post/news/create.php

@ -0,0 +1,18 @@
<?php
/* @var $this yii\web\View */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Create Post');
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $title;
?>
<div class="post-create">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

83
backend/views/post/news/index.php

@ -0,0 +1,83 @@
<?php
use core\entities\post\Post;
use core\helpers\PostHelper;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel \core\forms\post\search\PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'All Posts');
$this->title = $type->plural .' > '. $title;
$this->params['breadcrumbs'][] = $title;
?>
<div class="blog-post-index">
<p>
<?= Html::a(Yii::t('post', 'Create Post'), ['create', 'tid' => $type->id], ['class' => 'btn btn-success']) ?>
</p>
<div class="box">
<div class="box-body">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
/*[
'value' => function (Post $model) {
return $model->image ? Html::img($model->getThumbFileUrl('image', 'admin')) : null;
},
'format' => 'raw',
'contentOptions' => ['style' => 'width: 100px'],
],*/
[
'attribute' => 'id',
'options' => ['style' => 'width: 40px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'title',
'value' => function (Post $model) {
return Html::a(Html::encode($model->title), ['view', 'id' => $model->id]);
},
'format' => 'raw',
],
[
'attribute' => 'category_id',
'filter' => $searchModel->categoriesList(),
'value' => 'category.name',
],
[
'attribute' => 'published_at',
'format' => ['datetime', 'php:d.m.Y H:i'],
'options' => ['style' => 'width: 60px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'attribute' => 'status',
'filter' => $searchModel->statusList(),
'value' => function (Post $model) {
return PostHelper::statusLabel($model->status);
},
'format' => 'raw',
'options' => ['style' => 'width: 120px;'],
'contentOptions' => ['class' => 'text-center'],
],
[
'class' => \yii\grid\ActionColumn::class,
'urlCreator' => function($action, Post $model, $key, $index, $column) {
$params = is_array($key) ? $key : ['id' => (string) $key, 'tid' => $model->type_id];
$params[0] = $column->controller ? $column->controller . '/' . $action : $action;
return \yii\helpers\Url::toRoute($params);
},
'options' => ['style' => 'width: 100px;'],
'contentOptions' => ['class' => 'text-center'],
],
],
]); ?>
</div>
</div>
</div>

20
backend/views/post/news/update.php

@ -0,0 +1,20 @@
<?php
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $model \core\forms\post\PostForm */
/* @var $type \core\entities\post\PostType */
$title = Yii::t('post', 'Update Post: {name}', ['name' => \yii\helpers\StringHelper::truncateWords($post->title, 6, '...')]);
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = ['label' => $type->singular, 'url' => ['view', 'id' => $post->id]];
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing');
?>
<div class="post-update">
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

139
backend/views/post/news/view.php

@ -0,0 +1,139 @@
<?php
use core\helpers\PostHelper;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $post \core\entities\post\Post */
/* @var $modificationsProvider yii\data\ActiveDataProvider */
/* @var $type \core\entities\post\PostType */
$title = $post->title;
$this->title = $type->plural . ' > ' . $title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('post', $type->plural), 'url' => ['index', 'tid' => $type->id]];
$this->params['breadcrumbs'][] = $type->singular;
?>
<div class="user-view">
<p>
<?= Html::a(Yii::t('post', 'All Posts'), ['index', 'tid' => $type->id], ['class' => 'btn btn-default']) ?>
<?php if ($post->isActive()): ?>
<?= Html::a(Yii::t('post', 'Draft'), ['draft', 'id' => $post->id], ['class' => 'btn btn-primary', 'data-method' => 'post']) ?>
<?php else: ?>
<?= Html::a(Yii::t('post', 'Activate'), ['activate', 'id' => $post->id], ['class' => 'btn btn-success', 'data-method' => 'post']) ?>
<?php endif; ?>
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $post->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $post->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Common') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
'id',
[
'attribute' => 'status',
'value' => PostHelper::statusLabel($post->status),
'format' => 'raw',
],
'title',
[
'attribute' => 'category_id',
'value' => ArrayHelper::getValue($post, 'category.name'),
],
[
'label' => Yii::t('post', 'Tags'),
'value' => implode(', ', ArrayHelper::getColumn($post->tags, 'name')),
],
],
]) ?>
</div>
</div>
<?php if ($post->image): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img($post->getThumbFileUrl('image', 'thumb_gallery_view'), [
'class' => 'thumbnail',
'width' => 300,
]) ?>
</div>
</div>
<?php endif; ?>
<?php if (!$post->image && $post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Image') ?></div>
<div class="box-body">
<?= Html::img('https://i.ytimg.com/vi/' . PostHelper::parseYoutubeUrl($post->video) . '/maxresdefault.jpg', [
'width' => 300,
'class' => 'thumbnail',
]) ?>
</div>
</div>
<?php endif; ?>
<?php if ($post->video): ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Video') ?></div>
<div class="box-body">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/<?= PostHelper::parseYoutubeUrl($post->video) ?>?rel=0" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<?php endif; ?>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Description') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asNtext($post->description) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'Content') ?></div>
<div class="box-body">
<?= Yii::$app->formatter->asHtml($post->content, [
'Attr.AllowedRel' => array('nofollow'),
'HTML.SafeObject' => true,
'Output.FlashCompat' => true,
'HTML.SafeIframe' => true,
'URI.SafeIframeRegexp'=>'%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%',
]) ?>
</div>
</div>
<div class="box">
<div class="box-header with-border"><?= Yii::t('post', 'SEO') ?></div>
<div class="box-body">
<?= DetailView::widget([
'model' => $post,
'attributes' => [
[
'attribute' => 'meta.title',
'value' => $post->meta->title,
],
[
'attribute' => 'meta.description',
'value' => $post->meta->description,
],
[
'attribute' => 'meta.keywords',
'value' => $post->meta->keywords,
],
],
]) ?>
</div>
</div>
</div>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save