|
|
@ -9,76 +9,80 @@ use Yii; |
|
|
|
class MenuItemForm extends LanguageDynamicModel |
|
|
|
class MenuItemForm extends LanguageDynamicModel |
|
|
|
{ |
|
|
|
{ |
|
|
|
public $menu_id; |
|
|
|
public $menu_id; |
|
|
|
public $parent_id; |
|
|
|
public $parent_id; |
|
|
|
public $name; |
|
|
|
public $name; |
|
|
|
public $title_attr; |
|
|
|
public $title_attr; |
|
|
|
public $target; |
|
|
|
public $target; |
|
|
|
public $css; |
|
|
|
public $css; |
|
|
|
public $style; |
|
|
|
public $style; |
|
|
|
public $module; |
|
|
|
public $module; |
|
|
|
public $url; |
|
|
|
public $url; |
|
|
|
public $url_params; |
|
|
|
public $url_params; |
|
|
|
|
|
|
|
|
|
|
|
private $_menu; |
|
|
|
private $_menu; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct(MenuItem $menu = null, array $attributes = [], $config = []) |
|
|
|
public function __construct(MenuItem $menu = null, array $attributes = [], $config = []) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($menu) { |
|
|
|
if ($menu) { |
|
|
|
$this->menu_id = $menu->menu_id; |
|
|
|
$this->menu_id = $menu->menu_id; |
|
|
|
$this->parent_id = $menu->parent_id; |
|
|
|
$this->parent_id = $menu->parent_id; |
|
|
|
$this->target = $menu->target; |
|
|
|
$this->target = $menu->target; |
|
|
|
$this->css = $menu->css; |
|
|
|
$this->css = $menu->css; |
|
|
|
$this->style = $menu->style; |
|
|
|
$this->style = $menu->style; |
|
|
|
$this->module = $menu->module; |
|
|
|
$this->module = $menu->module; |
|
|
|
$this->url = $menu->url; |
|
|
|
$this->url = $menu->url; |
|
|
|
$this->url_params = $menu->url_params; |
|
|
|
$this->url_params = $menu->url_params; |
|
|
|
|
|
|
|
|
|
|
|
$this->_menu = $menu; |
|
|
|
$this->_menu = $menu; |
|
|
|
} |
|
|
|
} |
|
|
|
parent::__construct($menu, $attributes, $config); |
|
|
|
parent::__construct($menu, $attributes, $config); |
|
|
|
if ($menu) { |
|
|
|
if ($menu) { |
|
|
|
foreach ( $menu->translations as $translate ) { |
|
|
|
foreach ($menu->translations as $translate) { |
|
|
|
if ($translate->language == Yii::$app->params['backendDefaultLanguage']) { |
|
|
|
if (!in_array($translate->language, $menu->translatedLanguages)) { |
|
|
|
$this->name = $translate->name; |
|
|
|
continue; |
|
|
|
$this->title_attr = $translate->title_attr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
if ($translate->language == Yii::$app->params['backendDefaultLanguage']) { |
|
|
|
$this->{'name' . '_' . $translate->language} = $translate->name; |
|
|
|
$this->name = $translate->name; |
|
|
|
$this->{'title_attr' . '_' . $translate->language} = $translate->title_attr; |
|
|
|
$this->title_attr = $translate->title_attr; |
|
|
|
} |
|
|
|
} else { |
|
|
|
}; |
|
|
|
$this->{'name' . '_' . $translate->language} = $translate->name; |
|
|
|
} |
|
|
|
$this->{'title_attr' . '_' . $translate->language} = $translate->title_attr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function rules(): array |
|
|
|
public function rules(): array |
|
|
|
{ |
|
|
|
{ |
|
|
|
return array_merge( |
|
|
|
return array_merge( |
|
|
|
parent::rules(), |
|
|
|
parent::rules(), |
|
|
|
[ |
|
|
|
[ |
|
|
|
[['name', 'menu_id'], 'required'], |
|
|
|
[['name', 'menu_id'], 'required'], |
|
|
|
[['name', 'title_attr', 'css', 'style', 'module', 'url'], 'string', 'max' => 255], |
|
|
|
[['name', 'title_attr', 'css', 'style', 'module', 'url'], 'string', 'max' => 255], |
|
|
|
[['target'], 'string', 'max' => 20], |
|
|
|
[['target'], 'string', 'max' => 20], |
|
|
|
['url_params', 'string'], |
|
|
|
['url_params', 'string'], |
|
|
|
[['parent_id', 'menu_id'], 'integer'], |
|
|
|
[['parent_id', 'menu_id'], 'integer'], |
|
|
|
] |
|
|
|
] |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function attributeLabels() { |
|
|
|
public function attributeLabels() |
|
|
|
return array_merge( |
|
|
|
{ |
|
|
|
parent::attributeLabels(), |
|
|
|
return array_merge( |
|
|
|
[ |
|
|
|
parent::attributeLabels(), |
|
|
|
'menu_id' => Yii::t('menu', 'Menu'), |
|
|
|
[ |
|
|
|
'parent id' => Yii::t('menu', 'Parent menu item'), |
|
|
|
'menu_id' => Yii::t('menu', 'Menu'), |
|
|
|
'name' => Yii::t('menu', 'Name'), |
|
|
|
'parent id' => Yii::t('menu', 'Parent menu item'), |
|
|
|
'title_attr' => Yii::t('menu', 'Title attribute'), |
|
|
|
'name' => Yii::t('menu', 'Name'), |
|
|
|
'target' => Yii::t('menu', 'Target'), |
|
|
|
'title_attr' => Yii::t('menu', 'Title attribute'), |
|
|
|
'css' => Yii::t('menu', 'CSS Classes'), |
|
|
|
'target' => Yii::t('menu', 'Target'), |
|
|
|
'style' => Yii::t('menu', 'CSS Style'), |
|
|
|
'css' => Yii::t('menu', 'CSS Classes'), |
|
|
|
'module' => Yii::t('menu', 'Module'), |
|
|
|
'style' => Yii::t('menu', 'CSS Style'), |
|
|
|
'url' => Yii::t('menu', 'Url'), |
|
|
|
'module' => Yii::t('menu', 'Module'), |
|
|
|
'url_params' => Yii::t('menu', 'Url Params'), |
|
|
|
'url' => Yii::t('menu', 'Url'), |
|
|
|
] |
|
|
|
'url_params' => Yii::t('menu', 'Url Params'), |
|
|
|
); |
|
|
|
] |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|