-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c410c0
commit 0eb91ab
Showing
6 changed files
with
377 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* @link https://cms.skeeks.com/ | ||
* @copyright Copyright (c) 2010 SkeekS | ||
* @license https://cms.skeeks.com/license/ | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
*/ | ||
namespace skeeks\cms\actions\backend; | ||
|
||
use skeeks\cms\backend\actions\BackendModelMultiAction; | ||
use skeeks\cms\components\Cms; | ||
/** | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
*/ | ||
class BackendModelMultiActivateAction extends BackendModelMultiAction { | ||
|
||
public function init() | ||
{ | ||
if (!$this->icon) | ||
{ | ||
$this->icon = "fas fa-eye"; | ||
} | ||
|
||
if (!$this->name) | ||
{ | ||
$this->name = \Yii::t('skeeks/cms', "Activate"); | ||
} | ||
|
||
parent::init(); | ||
} | ||
|
||
/** | ||
* @param $model | ||
* @return bool | ||
*/ | ||
public function eachExecute($model) | ||
{ | ||
try { | ||
$model->active = Cms::BOOL_Y; | ||
return $model->save(false); | ||
} catch (\Exception $e) { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* @link https://cms.skeeks.com/ | ||
* @copyright Copyright (c) 2010 SkeekS | ||
* @license https://cms.skeeks.com/license/ | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
*/ | ||
namespace skeeks\cms\actions\backend; | ||
|
||
use skeeks\cms\backend\actions\BackendModelMultiAction; | ||
use skeeks\cms\components\Cms; | ||
/** | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
*/ | ||
class BackendModelMultiDeactivateAction extends BackendModelMultiAction { | ||
public function init() | ||
{ | ||
if (!$this->icon) | ||
{ | ||
$this->icon = "fas fa-eye-slash"; | ||
} | ||
|
||
if (!$this->name) | ||
{ | ||
$this->name = \Yii::t('skeeks/cms', "Deactivate"); | ||
} | ||
|
||
parent::init(); | ||
} | ||
|
||
/** | ||
* @param $model | ||
* @return bool | ||
*/ | ||
public function eachExecute($model) | ||
{ | ||
try { | ||
$model->active = Cms::BOOL_N; | ||
return $model->save(false); | ||
} catch (\Exception $e) { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 31.05.2015 | ||
*/ | ||
|
||
namespace skeeks\cms\controllers; | ||
|
||
use skeeks\cms\actions\backend\BackendModelMultiActivateAction; | ||
use skeeks\cms\actions\backend\BackendModelMultiDeactivateAction; | ||
use skeeks\cms\backend\actions\BackendModelAction; | ||
use skeeks\cms\backend\controllers\BackendModelStandartController; | ||
use skeeks\cms\grid\BooleanColumn; | ||
use skeeks\cms\grid\ImageColumn2; | ||
use skeeks\cms\models\CmsSite; | ||
use skeeks\cms\queryfilters\filters\modes\FilterModeEmpty; | ||
use skeeks\cms\queryfilters\filters\modes\FilterModeNotEmpty; | ||
use skeeks\yii2\form\fields\BoolField; | ||
use skeeks\yii2\form\fields\FieldSet; | ||
use skeeks\yii2\form\fields\HiddenField; | ||
use skeeks\yii2\form\fields\HtmlBlock; | ||
use skeeks\yii2\form\fields\SelectField; | ||
use skeeks\yii2\form\fields\TextareaField; | ||
use skeeks\yii2\form\fields\WidgetField; | ||
use yii\helpers\ArrayHelper; | ||
|
||
/** | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
*/ | ||
class AdminCmsSite2Controller extends BackendModelStandartController | ||
{ | ||
public function init() | ||
{ | ||
$this->name = \Yii::t('skeeks/cms', "Site management"); | ||
$this->modelShowAttribute = "name"; | ||
$this->modelClassName = CmsSite::class; | ||
|
||
parent::init(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function actions() | ||
{ | ||
$bool = [ | ||
'isAllowChangeMode' => false, | ||
'field' => [ | ||
'class' => SelectField::class, | ||
'items' => [ | ||
'Y' => \Yii::t('yii', 'Yes'), | ||
'N' => \Yii::t('yii', 'No'), | ||
], | ||
], | ||
]; | ||
|
||
|
||
return ArrayHelper::merge(parent::actions(), [ | ||
|
||
'index' => [ | ||
"filters" => [ | ||
'visibleFilters' => [ | ||
'id', | ||
'name', | ||
], | ||
|
||
'filtersModel' => [ | ||
'fields' => [ | ||
'name' => [ | ||
'isAllowChangeMode' => false, | ||
], | ||
'code' => [ | ||
'isAllowChangeMode' => false, | ||
], | ||
'active' => $bool, | ||
'def' => $bool, | ||
'image_id' => [ | ||
'isAllowChangeMode' => true, | ||
'modes' => [ | ||
FilterModeNotEmpty::class, | ||
FilterModeEmpty::class, | ||
], | ||
], | ||
], | ||
], | ||
], | ||
|
||
"grid" => [ | ||
'visibleColumns' => [ | ||
'checkbox', | ||
'actions', | ||
'id', | ||
'image_id', | ||
'server_name', | ||
'def', | ||
'active', | ||
'priority', | ||
'code', | ||
'name', | ||
], | ||
'columns' => [ | ||
'active' => [ | ||
'class' => BooleanColumn::class, | ||
], | ||
'def' => [ | ||
'class' => BooleanColumn::class, | ||
], | ||
'image_id' => [ | ||
'class' => ImageColumn2::class, | ||
], | ||
], | ||
], | ||
], | ||
|
||
"create" => [ | ||
'fields' => [$this, 'updateFields'], | ||
], | ||
|
||
"update" => [ | ||
'fields' => [$this, 'updateFields'], | ||
], | ||
|
||
"activate-multi" => [ | ||
'class' => BackendModelMultiActivateAction::class, | ||
], | ||
|
||
"deactivate-multi" => [ | ||
'class' => BackendModelMultiDeactivateAction::class, | ||
], | ||
]); | ||
} | ||
|
||
public function updateFields($action) | ||
{ | ||
$active = [ | ||
'class' => BoolField::class, | ||
'formElement' => BoolField::ELEMENT_RADIO_LIST, | ||
'allowNull' => false, | ||
'trueValue' => 'Y', | ||
'falseValue' => 'N', | ||
]; | ||
$def = [ | ||
'class' => BoolField::class, | ||
'formElement' => BoolField::ELEMENT_RADIO_LIST, | ||
'allowNull' => false, | ||
'trueValue' => 'Y', | ||
'falseValue' => 'N', | ||
]; | ||
|
||
if ($action->model->def == 'Y') { | ||
$active = [ | ||
'class' => HiddenField::class, | ||
'hint' => \Yii::t('skeeks/cms', 'Site selected by default always active') | ||
]; | ||
$def = [ | ||
'class' => HiddenField::class, | ||
'hint' => \Yii::t('skeeks/cms', 'This site is the site selected by default. If you want to change it, you need to choose a different site, the default site.') | ||
]; | ||
} | ||
|
||
$result = [ | ||
'main' => [ | ||
'class' => FieldSet::class, | ||
'name' => \Yii::t('skeeks/cms', 'Main'), | ||
'fields' => [ | ||
'image_id' => [ | ||
'class' => WidgetField::class, | ||
'widgetClass' => \skeeks\cms\widgets\AjaxFileUploadWidget::class, | ||
'widgetConfig' => [ | ||
'accept' => 'image/*', | ||
'multiple' => false, | ||
], | ||
], | ||
'name', | ||
'code', | ||
'active' => $active, | ||
'def' => $def, | ||
'description' => [ | ||
'class' => TextareaField::class, | ||
], | ||
'server_name', | ||
'priority', | ||
], | ||
], | ||
|
||
]; | ||
|
||
if (!$action->model->isNewRecord) { | ||
$result['domains'] = [ | ||
'class' => FieldSet::class, | ||
'name' => \Yii::t('skeeks/cms', "Domains"), | ||
'fields' => [ | ||
'domains' => [ | ||
'class' => HtmlBlock::class, | ||
'content' => \skeeks\cms\modules\admin\widgets\RelatedModelsGrid::widget([ | ||
'label' => "", | ||
'hint' => "", | ||
'parentModel' => $action->model, | ||
'relation' => [ | ||
'cms_site_id' => 'id' | ||
], | ||
|
||
'controllerRoute' => '/cms/admin-cms-site-domain', | ||
'gridViewOptions' => [ | ||
'columns' => [ | ||
//['class' => 'yii\grid\SerialColumn'], | ||
'domain', | ||
], | ||
], | ||
]) | ||
] | ||
], | ||
]; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 31.05.2015 | ||
*/ | ||
|
||
namespace skeeks\cms\controllers; | ||
|
||
use skeeks\cms\backend\controllers\BackendModelStandartController; | ||
use skeeks\cms\models\CmsSiteDomain; | ||
use yii\helpers\ArrayHelper; | ||
|
||
/** | ||
* @author Semenov Alexander <semenov@skeeks.com> | ||
*/ | ||
class AdminCmsSiteDomain2Controller extends BackendModelStandartController | ||
{ | ||
public function init() | ||
{ | ||
$this->name = \Yii::t('skeeks/cms', "Managing domains"); | ||
$this->modelShowAttribute = "domain"; | ||
$this->modelClassName = CmsSiteDomain::class; | ||
|
||
parent::init(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function actions() | ||
{ | ||
$updateFields = [ | ||
'domain', | ||
'cms_site_id', | ||
]; | ||
|
||
return ArrayHelper::merge(parent::actions(), [ | ||
'index' => [ | ||
"filters" => [ | ||
'visibleFilters' => [ | ||
'id', | ||
'domain', | ||
'cms_site_id', | ||
], | ||
], | ||
'grid' => [ | ||
'visibleColumns' => [ | ||
'checkbox', | ||
'actions', | ||
'id', | ||
'domain', | ||
'cms_site_id', | ||
], | ||
], | ||
], | ||
"create" => [ | ||
'fields' => $updateFields, | ||
], | ||
"update" => [ | ||
'fields' => $updateFields, | ||
], | ||
]); | ||
} | ||
} |
Oops, something went wrong.