Egorka
6 years ago
21 changed files with 894 additions and 9 deletions
@ -0,0 +1,56 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages; |
||||
|
||||
use core\components\modules\ModuleInterface; |
||||
use yii\helpers\ArrayHelper; |
||||
|
||||
|
||||
/** |
||||
* languages module definition class |
||||
*/ |
||||
class LanguagesModule extends \yii\base\Module implements ModuleInterface |
||||
{ |
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public $controllerNamespace = 'common\modules\languages\controllers'; |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
// custom initialization code goes here |
||||
} |
||||
|
||||
public function bootstrap($app) |
||||
{ |
||||
// add migration path |
||||
$app->controllerMap['migrate']['migrationPath'][] = '@common/modules/languages/migrations'; |
||||
|
||||
$app->getUrlManager()->addRules([ |
||||
'languages/manage/language/view/<id:\d+>' => 'languages/manage/language/view', |
||||
]); |
||||
|
||||
// add languages |
||||
$app->getI18n()->translations = ArrayHelper::merge($app->getI18n()->translations, [ |
||||
'languages' => [ |
||||
'class' => 'yii\i18n\PhpMessageSource', |
||||
'basePath' => '@common/modules/languages/messages', |
||||
], |
||||
]); |
||||
|
||||
// add menu items |
||||
if (basename($app->getBasePath()) === 'backend') { |
||||
$app->params['adminMenu'][] = [ |
||||
'label' => \Yii::t( 'languages', 'Site Languages' ), |
||||
'icon' => 'language', |
||||
'url' => [ '/languages/manage/language/index' ], |
||||
'visible' => \Yii::$app->user->can( 'admin' ) || \Yii::$app->user->can( 'LanguagesManagement' ) |
||||
]; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,166 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages\controllers\manage; |
||||
|
||||
use common\modules\languages\entities\Language; |
||||
use common\modules\languages\forms\LanguageForm; |
||||
use common\modules\languages\forms\search\LanguageSearch; |
||||
use common\modules\languages\services\LanguageManageService; |
||||
use yii\web\NotFoundHttpException; |
||||
use yii\filters\AccessControl; |
||||
use yii\filters\VerbFilter; |
||||
use yii\web\Controller; |
||||
use Yii; |
||||
|
||||
class LanguageController extends Controller |
||||
{ |
||||
private $service; |
||||
|
||||
public function __construct($id, $module, LanguageManageService $service, $config = []) |
||||
{ |
||||
parent::__construct($id, $module, $config); |
||||
$this->service = $service; |
||||
} |
||||
|
||||
public function behaviors(): array |
||||
{ |
||||
return [ |
||||
'access' => [ |
||||
'class' => AccessControl::class, |
||||
'rules' => [ |
||||
[ |
||||
'allow' => true, |
||||
'roles' => ['LanguagesManagement'], |
||||
], |
||||
[ // all the action are accessible to admin |
||||
'allow' => true, |
||||
'roles' => ['admin'], |
||||
], |
||||
], |
||||
], |
||||
'verbs' => [ |
||||
'class' => VerbFilter::class, |
||||
'actions' => [ |
||||
'delete' => ['POST'], |
||||
'set-default' => ['POST'], |
||||
], |
||||
], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @return mixed |
||||
*/ |
||||
public function actionIndex() |
||||
{ |
||||
$searchModel = new LanguageSearch(); |
||||
$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', [ |
||||
'language' => $this->findModel($id), |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* @return mixed |
||||
*/ |
||||
public function actionCreate() |
||||
{ |
||||
$form = new LanguageForm(); |
||||
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) { |
||||
try { |
||||
$form = $this->service->create($form); |
||||
return $this->redirect(['view', 'id' => $form->id]); |
||||
} catch (\DomainException $e) { |
||||
Yii::$app->errorHandler->logException($e); |
||||
Yii::$app->session->setFlash('error', $e->getMessage()); |
||||
} |
||||
} |
||||
else { |
||||
$form->status = $form->status ?: Language::STATUS_ACTIVE; |
||||
} |
||||
return $this->render('create', [ |
||||
'model' => $form, |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* @param $id |
||||
* |
||||
* @return string|\yii\web\Response |
||||
* @throws NotFoundHttpException |
||||
*/ |
||||
public function actionUpdate($id) |
||||
{ |
||||
$language = $this->findModel($id); |
||||
$form = new LanguageForm($language); |
||||
|
||||
if ($form->load(Yii::$app->request->post()) && $form->validate()) { |
||||
try { |
||||
$this->service->edit($language->id, $form); |
||||
return $this->redirect(['view', 'id' => $language->id]); |
||||
} catch (\DomainException $e) { |
||||
Yii::$app->errorHandler->logException($e); |
||||
Yii::$app->session->setFlash('error', $e->getMessage()); |
||||
} |
||||
} |
||||
|
||||
return $this->render('update', [ |
||||
'model' => $form, |
||||
'language' => $language, |
||||
]); |
||||
} |
||||
|
||||
/** |
||||
* @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']); |
||||
} |
||||
|
||||
public function actionSetDefault($id) |
||||
{ |
||||
$language = $this->findModel($id); |
||||
if ($language) { |
||||
$this->service->setDefault($language); |
||||
return $this->redirect(['index']); |
||||
} |
||||
throw new NotFoundHttpException('Language is not exists'); |
||||
} |
||||
|
||||
/** |
||||
* @param integer $id |
||||
* @return Language the loaded model |
||||
* @throws NotFoundHttpException if the model cannot be found |
||||
*/ |
||||
protected function findModel($id): Language |
||||
{ |
||||
if (($model = Language::findOne($id)) !== null) { |
||||
return $model; |
||||
} |
||||
throw new NotFoundHttpException('The requested language does not exist.'); |
||||
} |
||||
} |
@ -0,0 +1,96 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages\entities; |
||||
|
||||
use common\modules\languages\entities\queries\LanguageQuery; |
||||
use yii\db\ActiveRecord; |
||||
use Yii; |
||||
|
||||
|
||||
/** |
||||
* This is the model class for table "languages". |
||||
* |
||||
* @property int $id |
||||
* @property string $title |
||||
* @property string $name |
||||
* @property int $default |
||||
* @property int $status |
||||
* |
||||
*/ |
||||
class Language extends ActiveRecord |
||||
{ |
||||
const STATUS_DRAFT = 0; |
||||
const STATUS_ACTIVE = 1; |
||||
|
||||
const DEFAULT_TRUE = 1; |
||||
const DEFAULT_FALSE = 0; |
||||
|
||||
public static function create($name, $title, $status): self |
||||
{ |
||||
$language = new static(); |
||||
$language->name = $name; |
||||
$language->title = $title; |
||||
$language->status = $status; |
||||
return $language; |
||||
} |
||||
|
||||
public function edit($name, $title, $status): void |
||||
{ |
||||
$this->name = $name; |
||||
$this->title = $title; |
||||
$this->status = $status; |
||||
} |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public static function tableName() |
||||
{ |
||||
return 'languages'; |
||||
} |
||||
|
||||
/** |
||||
* @inheritdoc |
||||
*/ |
||||
public function attributeLabels() |
||||
{ |
||||
return [ |
||||
'id' => Yii::t('languages', 'ID'), |
||||
'name' => Yii::t('languages', 'Name'), |
||||
'title' => Yii::t('languages', 'Title'), |
||||
'status' => Yii::t('languages', 'Status'), |
||||
'default' => Yii::t('languages', 'Default'), |
||||
]; |
||||
} |
||||
|
||||
public function activate(): void |
||||
{ |
||||
if ($this->isActive()) { |
||||
throw new \DomainException('Language is already active.'); |
||||
} |
||||
$this->status = self::STATUS_ACTIVE; |
||||
} |
||||
|
||||
public function draft(): void |
||||
{ |
||||
if ($this->isDraft()) { |
||||
throw new \DomainException('Language is already draft.'); |
||||
} |
||||
$this->status = self::STATUS_DRAFT; |
||||
} |
||||
|
||||
public function isActive(): bool |
||||
{ |
||||
return $this->status == self::STATUS_ACTIVE; |
||||
} |
||||
|
||||
public function isDraft(): bool |
||||
{ |
||||
return $this->status == self::STATUS_DRAFT; |
||||
} |
||||
|
||||
public static function find(): LanguageQuery |
||||
{ |
||||
return new LanguageQuery(static::class); |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages\entities\queries; |
||||
|
||||
use common\modules\languages\entities\Language; |
||||
use yii\db\ActiveQuery; |
||||
|
||||
class LanguageQuery extends ActiveQuery |
||||
{ |
||||
/** |
||||
* @return LanguageQuery |
||||
*/ |
||||
public function active() |
||||
{ |
||||
return $this->andWhere(['status' => Language::STATUS_ACTIVE]); |
||||
} |
||||
|
||||
public function default() |
||||
{ |
||||
return $this->andWhere(['default' => Language::DEFAULT_TRUE]); |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages\forms; |
||||
|
||||
use common\modules\languages\entities\Language; |
||||
use yii\base\Model; |
||||
use Yii; |
||||
|
||||
class LanguageForm extends Model |
||||
{ |
||||
public $name; |
||||
public $title; |
||||
public $status; |
||||
|
||||
public $_language; |
||||
|
||||
public function __construct(Language $language = null, $config = []) |
||||
{ |
||||
if ($language) { |
||||
$this->name = $language->name; |
||||
$this->title = $language->title; |
||||
$this->status = $language->status; |
||||
} |
||||
parent::__construct($config); |
||||
} |
||||
|
||||
public function rules(): array |
||||
{ |
||||
return [ |
||||
[['title', 'name'], 'required'], |
||||
[['status'], 'integer'], |
||||
[['name'], 'string', 'max' => 2], |
||||
[['title'], 'string', 'max' => 64], |
||||
]; |
||||
} |
||||
|
||||
public function attributeLabels() { |
||||
return [ |
||||
'id' => Yii::t('languages', 'ID'), |
||||
'name' => Yii::t('languages', 'Name'), |
||||
'title' => Yii::t('languages', 'Title'), |
||||
'status' => Yii::t('languages', 'Status'), |
||||
'default' => Yii::t('languages', 'Default'), |
||||
]; |
||||
} |
||||
} |
@ -0,0 +1,56 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages\forms\search; |
||||
|
||||
use common\modules\languages\entities\Language; |
||||
use yii\base\Model; |
||||
use yii\data\ActiveDataProvider; |
||||
|
||||
class LanguageSearch extends Model |
||||
{ |
||||
public $id; |
||||
public $name; |
||||
public $title; |
||||
public $status; |
||||
|
||||
public function rules(): array |
||||
{ |
||||
return [ |
||||
[['id', 'status'], 'integer'], |
||||
[['title', 'name'], 'safe'], |
||||
]; |
||||
} |
||||
|
||||
/** |
||||
* @param array $params |
||||
* @return ActiveDataProvider |
||||
*/ |
||||
public function search(array $params): ActiveDataProvider |
||||
{ |
||||
$query = Language::find(); |
||||
|
||||
$dataProvider = new ActiveDataProvider([ |
||||
'query' => $query, |
||||
'sort' => [ |
||||
'defaultOrder' => ['id' => SORT_ASC] |
||||
] |
||||
]); |
||||
|
||||
$this->load($params); |
||||
|
||||
if (!$this->validate()) { |
||||
$query->where('0=1'); |
||||
return $dataProvider; |
||||
} |
||||
|
||||
$query->andFilterWhere([ |
||||
'id' => $this->id, |
||||
'status' => $this->status, |
||||
]); |
||||
|
||||
$query |
||||
->andFilterWhere(['like', 'title', $this->title]) |
||||
->andFilterWhere(['like', 'name', $this->name]); |
||||
return $dataProvider; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
<?php |
||||
/** |
||||
* Created by Error202 |
||||
* Date: 21.08.2018 |
||||
*/ |
||||
|
||||
namespace common\modules\languages\helpers; |
||||
|
||||
use common\modules\languages\entities\Language; |
||||
use yii\helpers\ArrayHelper; |
||||
use yii\helpers\Html; |
||||
use Yii; |
||||
|
||||
class LanguageHelper |
||||
{ |
||||
public static function defaultLabel($default): string |
||||
{ |
||||
switch ($default) { |
||||
case Language::DEFAULT_FALSE: |
||||
$class = 'text-gray'; |
||||
break; |
||||
case Language::DEFAULT_TRUE: |
||||
$class = 'text-yellow'; |
||||
break; |
||||
default: |
||||
$class = 'text-gray'; |
||||
} |
||||
|
||||
return '<i class="fa fa-star '.$class.'" aria-hidden="true"></i>'; |
||||
} |
||||
|
||||
public static function statusList(): array |
||||
{ |
||||
return [ |
||||
Language::STATUS_DRAFT => Yii::t('languages', 'Draft'), |
||||
Language::STATUS_ACTIVE => Yii::t('languages', 'Active'), |
||||
]; |
||||
} |
||||
|
||||
public static function statusName($status): string |
||||
{ |
||||
return ArrayHelper::getValue(self::statusList(), $status); |
||||
} |
||||
|
||||
public static function statusLabel($status): string |
||||
{ |
||||
switch ($status) { |
||||
case Language::STATUS_DRAFT: |
||||
$class = 'label label-default'; |
||||
break; |
||||
case Language::STATUS_ACTIVE: |
||||
$class = 'label label-success'; |
||||
break; |
||||
default: |
||||
$class = 'label label-default'; |
||||
} |
||||
|
||||
return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [ |
||||
'class' => $class, |
||||
]); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,8 @@
|
||||
<?php |
||||
|
||||
return [ |
||||
'version' => '1.0.1', |
||||
'name' => 'languages', |
||||
'description' => 'Web site languages management', |
||||
'module' => 'LanguagesModule', |
||||
]; |
@ -0,0 +1,17 @@
|
||||
<?php |
||||
|
||||
return [ |
||||
'languages' => 'Языки', |
||||
'Languages' => 'Языки', |
||||
'Site Languages' => 'Языки веб-сайта', |
||||
'Create Language' => 'Новый язык', |
||||
'Update Language: {name}' => 'Редактирование языка: {name}', |
||||
'Title' => 'Заголовок', |
||||
'Name' => 'Название', |
||||
'Status' => 'Статус', |
||||
'Default' => 'По умолчанию', |
||||
'Active' => 'Включен', |
||||
'Draft' => 'Отключен', |
||||
'Publish' => 'Публикация', |
||||
'Are you sure you want to set this language as default?' => 'Вы действительно хотите сделать этот язык основным?', |
||||
]; |
@ -0,0 +1,33 @@
|
||||
<?php |
||||
|
||||
use yii\db\Migration; |
||||
|
||||
/** |
||||
* Handles the creation of table `languages`. |
||||
*/ |
||||
class m180827_210614_create_languages_table extends Migration |
||||
{ |
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeUp() |
||||
{ |
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; |
||||
|
||||
$this->createTable('{{%languages}}', [ |
||||
'id' => $this->primaryKey(), |
||||
'name' => $this->string(2)->notNull(), |
||||
'title' => $this->string(64)->notNull(), |
||||
'status' => $this->integer(1)->defaultValue(1), |
||||
'default' => $this->integer(1)->defaultValue(0), |
||||
], $tableOptions); |
||||
} |
||||
|
||||
/** |
||||
* {@inheritdoc} |
||||
*/ |
||||
public function safeDown() |
||||
{ |
||||
$this->dropTable('{{%languages}}'); |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages\repositories; |
||||
|
||||
use common\modules\languages\entities\Language; |
||||
use core\repositories\NotFoundException; |
||||
|
||||
class LanguageRepository |
||||
{ |
||||
public function get($id): Language |
||||
{ |
||||
if (!$language = Language::findOne($id)) { |
||||
throw new NotFoundException('Language is not found.'); |
||||
} |
||||
return $language; |
||||
} |
||||
|
||||
public function save(Language $language): void |
||||
{ |
||||
if (!$language->save()) { |
||||
throw new \RuntimeException('Saving error.'); |
||||
} |
||||
} |
||||
|
||||
public function remove(Language $language): void |
||||
{ |
||||
if (!$language->delete()) { |
||||
throw new \RuntimeException('Removing error.'); |
||||
} |
||||
} |
||||
|
||||
public function clearDefaults() |
||||
{ |
||||
Language::updateAll(['default' => 0]); |
||||
} |
||||
} |
@ -0,0 +1,54 @@
|
||||
<?php |
||||
|
||||
namespace common\modules\languages\services; |
||||
|
||||
use common\modules\languages\entities\Language; |
||||
use common\modules\languages\forms\LanguageForm; |
||||
use common\modules\languages\helpers\LanguageHelper; |
||||
use common\modules\languages\repositories\LanguageRepository; |
||||
|
||||
class LanguageManageService |
||||
{ |
||||
private $repository; |
||||
|
||||
public function __construct(LanguageRepository $repository) |
||||
{ |
||||
$this->repository = $repository; |
||||
} |
||||
|
||||
public function create(LanguageForm $form): Language |
||||
{ |
||||
$language = Language::create( |
||||
$form->name, |
||||
$form->title, |
||||
$form->status |
||||
); |
||||
$this->repository->save($language); |
||||
return $language; |
||||
} |
||||
|
||||
public function edit($id, LanguageForm $form): void |
||||
{ |
||||
$language = $this->repository->get($id); |
||||
|
||||
$language->edit( |
||||
$form->name, |
||||
$form->title, |
||||
$form->status |
||||
); |
||||
$this->repository->save($language); |
||||
} |
||||
|
||||
public function remove($id): void |
||||
{ |
||||
$language = $this->repository->get($id); |
||||
$this->repository->remove($language); |
||||
} |
||||
|
||||
public function setDefault(Language $language) |
||||
{ |
||||
$this->repository->clearDefaults(); |
||||
$language->default = Language::DEFAULT_TRUE; |
||||
$this->repository->save($language); |
||||
} |
||||
} |
@ -0,0 +1,71 @@
|
||||
<?php |
||||
|
||||
use yii\helpers\Html; |
||||
use kartik\form\ActiveForm; |
||||
use common\modules\languages\helpers\LanguageHelper; |
||||
|
||||
/* @var $this yii\web\View */ |
||||
/* @var $model \common\modules\languages\forms\LanguageForm */ |
||||
/* @var $form yii\widgets\ActiveForm */ |
||||
|
||||
$js2 = ' |
||||
$(".hint-block").each(function () { |
||||
var $hint = $(this); |
||||
var label = $hint.parent().find("label"); |
||||
label.html(label.html() + \' <i style="color:#3c8dbc" class="fa fa-question-circle" aria-hidden="true"></i>\'); |
||||
label.addClass("help").popover({ |
||||
html: true, |
||||
trigger: "hover", |
||||
placement: "bottom", |
||||
content: $hint.html() |
||||
}); |
||||
$(this).hide(); |
||||
}); |
||||
'; |
||||
$this->registerJs($js2); |
||||
?> |
||||
|
||||
<div class="language-form"> |
||||
|
||||
<?php $form = ActiveForm::begin(); ?> |
||||
|
||||
<div class="row"> |
||||
<div class="col-md-10"> |
||||
|
||||
<div class="box box-default"> |
||||
<div class="box-body"> |
||||
|
||||
<div class="row"> |
||||
<div class="col-md-2"> |
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> |
||||
</div> |
||||
<div class="col-md-10"> |
||||
<?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
</div> |
||||
|
||||
<div class="form-group"> |
||||
<?= Html::submitButton(Yii::t('buttons', 'Save'), ['class' => 'btn btn-success']) ?> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
<div class="col-md-2"> |
||||
<div class="box box-default"> |
||||
<div class="box-header with-border"><?= Yii::t('languages', 'Publish') ?></div>
|
||||
<div class="box-body"> |
||||
|
||||
<?= $form->field($model, 'status')->radioList(LanguageHelper::statusList()) ?> |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
<?php ActiveForm::end(); ?> |
||||
|
||||
</div> |
@ -0,0 +1,16 @@
|
||||
<?php |
||||
|
||||
/* @var $this yii\web\View */ |
||||
/* @var $model \common\modules\languages\forms\LanguageForm */ |
||||
|
||||
$this->title = Yii::t('languages', 'Create Language'); |
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('languages', 'Languages'), 'url' => ['index']]; |
||||
$this->params['breadcrumbs'][] = $this->title; |
||||
?> |
||||
<div class="language-create"> |
||||
|
||||
<?= $this->render('_form', [ |
||||
'model' => $model, |
||||
]) ?> |
||||
|
||||
</div> |
@ -0,0 +1,69 @@
|
||||
<?php |
||||
|
||||
use yii\grid\ActionColumn; |
||||
use yii\helpers\Html; |
||||
use yii\grid\GridView; |
||||
use common\modules\languages\entities\Language; |
||||
use common\modules\languages\helpers\LanguageHelper; |
||||
|
||||
/* @var $this yii\web\View */ |
||||
/* @var $searchModel \common\modules\languages\forms\search\LanguageSearch */ |
||||
/* @var $dataProvider yii\data\ActiveDataProvider */ |
||||
|
||||
$this->title = Yii::t('languages', 'Languages'); |
||||
$this->params['breadcrumbs'][] = $this->title; |
||||
?> |
||||
<div class="language-index"> |
||||
|
||||
<p> |
||||
<?= Html::a(Yii::t('languages','Create Language'), ['create'], ['class' => 'btn btn-success']) ?> |
||||
</p> |
||||
|
||||
<div class="box"> |
||||
<div class="box-body"> |
||||
<?= GridView::widget([ |
||||
'dataProvider' => $dataProvider, |
||||
'filterModel' => $searchModel, |
||||
'columns' => [ |
||||
[ |
||||
'attribute' => 'default', |
||||
'format' => 'raw', |
||||
'value' => function(Language $language) { |
||||
return Html::a(LanguageHelper::defaultLabel($language->default), ['set-default', 'id' => $language->id], [ |
||||
'data' => [ |
||||
'confirm' => Yii::t('languages', 'Are you sure you want to set this language as default?'), |
||||
'method' => 'post', |
||||
], |
||||
]); |
||||
}, |
||||
'options' => ['style' => 'width: 150px;'], |
||||
'contentOptions' => ['class' => 'text-center'], |
||||
], |
||||
[ |
||||
'attribute' => 'title', |
||||
'value' => function (Language $model) { |
||||
return Html::a(Html::encode($model->title), ['view', 'id' => $model->id]); |
||||
}, |
||||
'format' => 'raw', |
||||
], |
||||
'name', |
||||
[ |
||||
'attribute' => 'status', |
||||
'filter' => LanguageHelper::statusList(), |
||||
'format' => 'raw', |
||||
'value' => function(Language $language) { |
||||
return LanguageHelper::statusLabel($language->status); |
||||
}, |
||||
'options' => ['style' => 'width: 150px;'], |
||||
'contentOptions' => ['class' => 'text-center'], |
||||
], |
||||
[ |
||||
'class' => ActionColumn::class, |
||||
'options' => ['style' => 'width: 100px;'], |
||||
'contentOptions' => ['class' => 'text-center'], |
||||
], |
||||
], |
||||
]); ?> |
||||
</div> |
||||
</div> |
||||
</div> |
@ -0,0 +1,18 @@
|
||||
<?php |
||||
|
||||
/* @var $this yii\web\View */ |
||||
/* @var $language \common\modules\languages\entities\Language */ |
||||
/* @var $model \common\modules\languages\forms\LanguageForm */ |
||||
|
||||
$this->title = Yii::t('languages', 'Update Language: {name}', ['name' => $language->title]); |
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('languages', 'Languages'), 'url' => ['index']]; |
||||
$this->params['breadcrumbs'][] = ['label' => $language->title, 'url' => ['view', 'id' => $language->id]]; |
||||
$this->params['breadcrumbs'][] = Yii::t('buttons', 'Editing'); |
||||
?> |
||||
<div class="language-update"> |
||||
|
||||
<?= $this->render('_form', [ |
||||
'model' => $model, |
||||
]) ?> |
||||
|
||||
</div> |
@ -0,0 +1,50 @@
|
||||
<?php |
||||
|
||||
use yii\helpers\Html; |
||||
use yii\widgets\DetailView; |
||||
use common\modules\languages\entities\Language; |
||||
|
||||
/* @var $this yii\web\View */ |
||||
/* @var $language Language */ |
||||
|
||||
$this->title = $language->title; |
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('languages', 'Languages'), 'url' => ['index']]; |
||||
$this->params['breadcrumbs'][] = $this->title; |
||||
?> |
||||
<div class="language-view"> |
||||
|
||||
<p> |
||||
<?= Html::a(Yii::t('languages','Languages'), ['index'], ['class' => 'btn btn-default']) ?> |
||||
<?= Html::a(Yii::t('buttons', 'Edit'), ['update', 'id' => $language->id], ['class' => 'btn btn-primary']) ?> |
||||
<?= Html::a(Yii::t('buttons', 'Delete'), ['delete', 'id' => $language->id], [ |
||||
'class' => 'btn btn-danger', |
||||
'data' => [ |
||||
'confirm' => Yii::t('buttons', 'Are you sure you want to delete this item?'), |
||||
'method' => 'post', |
||||
], |
||||
]) ?> |
||||
</p> |
||||
|
||||
<div class="row"> |
||||
<div class="col-md-12"> |
||||
|
||||
<div class="box"> |
||||
<div class="box-body"> |
||||
<?= DetailView::widget([ |
||||
'model' => $language, |
||||
'attributes' => [ |
||||
'id', |
||||
'title', |
||||
'name', |
||||
'status', |
||||
'default' |
||||
], |
||||
]) ?> |
||||
</div> |
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
</div> |
||||
|
||||
</div> |
Loading…
Reference in new issue