From 229e7e0fa95e5a0a12566d54a146a9930a05056c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 14 May 2024 09:48:09 +0900 Subject: [PATCH] vhost init...2 --- app/Controllers/Admin/CategoryController.php | 38 ++++++-------------- app/Language/ko/Category.php | 2 +- app/Models/BaseModel.php | 2 +- app/Models/CategoryModel.php | 18 +++++----- 4 files changed, 22 insertions(+), 38 deletions(-) diff --git a/app/Controllers/Admin/CategoryController.php b/app/Controllers/Admin/CategoryController.php index a794fad..b027646 100644 --- a/app/Controllers/Admin/CategoryController.php +++ b/app/Controllers/Admin/CategoryController.php @@ -13,43 +13,27 @@ class CategoryController extends AdminController { parent::initController($request, $response, $logger); $this->_model = new CategoryModel(); - $this->_viewDatas['className'] = 'Category'; - $this->_viewPath .= strtolower($this->_viewDatas['className']); - $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title'); - $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])]; - helper($this->_viewDatas['className']); + $this->_viewDatas["className"] = "Category"; + $this->_viewPath .= strtolower($this->_viewDatas["className"]); + $this->_viewDatas["title"] = lang($this->_viewDatas["className"] . ".title"); + $this->_viewDatas["class_icon"] = CLASS_ICONS[strtoupper($this->_viewDatas["className"])]; + helper($this->_viewDatas["className"]); } public function getFields(string $action = ""): array { $fields = [ - 'uid', - 'name', - "linkurl", - "isaccess", - "isread", - "iswrite", - "isreply", - "isupload", - "isdownload", - "status", - "head", - "tail", + "uid", "name", "linkurl", + "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + "status", "head", "tail", ]; switch ($action) { case "index": case "excel": return [ - 'name', - "linkurl", - "isaccess", - "isread", - "iswrite", - "isreply", - "isupload", - "isdownload", - "status", - "created_at", + "name", "linkurl", + "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + "status", "created_at", ]; break; case "view": diff --git a/app/Language/ko/Category.php b/app/Language/ko/Category.php index a0a5156..13794dd 100644 --- a/app/Language/ko/Category.php +++ b/app/Language/ko/Category.php @@ -8,9 +8,9 @@ return [ 'title' => "분류 정보", 'label' => [ 'uid' => "분류코드", + 'linkurl' => "연결URL", 'parent' => "상단코드", 'name' => "분류제목", - 'linkurl' => "LinkURL", 'photo' => "이미지", 'isaccess' => "접속권한", 'isread' => "읽기권한", diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index e06529d..a57b3be 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -180,7 +180,7 @@ abstract class BaseModel extends Model break; case 'category_uid': if (is_null($this->_category_options)) { - $this->_category_options = $this->getCategoryModel()->getOptions(['classname' => $this->_className]); + $this->_category_options = $this->getCategoryModel()->getOptions(); } $options = $this->_category_options; break; diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index bbaf2e4..c0e69fb 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -11,21 +11,21 @@ class CategoryModel extends BaseHierarchyModel protected $returnType = CategoryEntity::class; public function __construct() { - parent::__construct('Category'); + parent::__construct("Category"); $this->allowedFields = [ ...$this->allowedFields, - 'name', "linkurl", "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + "name", "linkurl", "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "head", "tail", "status" ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } public function getTitleField(): string { - return 'name'; + return "name"; } public function getContentField(): string { - return 'head'; + return "head"; } public function getFieldRule(string $field, array $rules, string $action = ""): array { @@ -37,7 +37,7 @@ class CategoryModel extends BaseHierarchyModel $rules[$field] = "required|trim|string"; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; break; - case 'photo': + case "photo": $rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; break; case "isaccess": @@ -80,9 +80,9 @@ class CategoryModel extends BaseHierarchyModel foreach ($this->getEntitys($conditions) as $entity) { if ($entity->getHierarchy_Depth() == 1) { $old = $entity->getPrimaryKey(); - $menus[$old] = ['entity' => $entity, 'childs' => []]; + $menus[$old] = ["entity" => $entity, "childs" => []]; } else { - $menus[$old]['childs'][] = $entity; + $menus[$old]["childs"][] = $entity; } } return $menus; @@ -99,7 +99,7 @@ class CategoryModel extends BaseHierarchyModel case "isupload": case "isdownload": if (array_key_exists($field, $formDatas) && $formDatas[$field]) { - $entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS['DELIMITER_ROLE'], $formDatas[$field]) : $formDatas[$field]; + $entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS["DELIMITER_ROLE"], $formDatas[$field]) : $formDatas[$field]; } break; case "head": @@ -117,7 +117,7 @@ class CategoryModel extends BaseHierarchyModel public function getEntity($conditions): CategoryEntity { - return parent::getEntity($conditions); + return new CategoryEntity(parent::getEntity($conditions)->toArray()); } public function getEntitys(array $conditions = array()): array {