30], [['flagtext','description'], 'string', 'max' => 500], [['settings'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'menu_id' => Yii::t('attr','linkmenu.menu_id'), 'key_id' => Yii::t('attr','linkmenu.key_id'), 'map_id' => Yii::t('attr','linkmenu.map_id'), 'name' => Yii::t('attr','linkmenu.name'), 'parent_id' => Yii::t('attr','linkmenu.parent_id'), 'has_child' => Yii::t('attr','linkmenu.has_child'), 'arr_child_ids' => Yii::t('attr','linkmenu.arr_child_ids'), 'level' => Yii::t('attr','linkmenu.level'), 'list_order' => Yii::t('attr','linkmenu.list_order'), 'flagtext' => Yii::t('attr','linkmenu.flagtext'), 'description' => Yii::t('attr','linkmenu.description'), 'settings' => Yii::t('attr','linkmenu.settings'), 'disabled' => Yii::t('attr','linkmenu.disabled'), ]; } //递归获取父级名称和Id public static function getParentMenuRs($menu_id,$info = array()) { $model = self::findOne($menu_id); $info[] = array('map_id'=>$model->map_id,'menu_id'=>$model->menu_id,'name'=>$model->name); if(!empty($model)&&$model->parent_id==0) { $info = array_reverse($info); return $info; } else { return self::getParentMenuRs($model->parent_id,$info); } } //返回格式化后的区域ID public static function getParentMenuIdRs($menu_id) { $parentMenus = self::getParentMenuRs($menu_id); $menuIds = array(); if(is_array($parentMenus))foreach($parentMenus as $menu) { $menuIds[] = $menu['menu_id']; } return $menuIds; } //返回格式化后的区域名称 public static function getMenuNameRs($menu_id) { $parentMenus = self::getParentMenuRs($menu_id); $nameList = array(); if(is_array($parentMenus))foreach($parentMenus as $menu) { $nameList[] = $menu['name']; } return $nameList; } //返回格式化后的区域 public static function getMenuNameStr($menu_id,$start=0,$glue='') { $parentMenus = self::getParentMenuRs($menu_id); $nameList = array(); if(is_array($parentMenus))foreach($parentMenus as $menu) { $nameList[] = $menu['name']; } return join($glue,array_slice($nameList,$start)); } }