diff --git a/app/Backend/BaseBackend.php b/app/Backend/BaseBackend.php new file mode 100644 index 0000000..498c041 --- /dev/null +++ b/app/Backend/BaseBackend.php @@ -0,0 +1,151 @@ +_className = $className; + $this->_session = \Config\Services::session(); + } + + final public function getClassName() + { + return $this->_className; + } + + //User모델 + final public function getUserModel(): UserModel + { + return is_null($this->_userModel) ? new UserModel() : $this->_userModel; + } + //Entity값 가져오기 + final public function getEntity($uid) + { + return $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]); + } + + //transaction관련 + final public function transStart($isTest = false) + { + $this->_model->transStart($isTest); + } + final public function transComplete() + { + $this->_model->transComplete(); + } + final public function transRollback() + { + $this->_model->transRollback(); + } + + //초기화 + final public function getFields(string $action) + { + return $this->_model->getFields($action); + } + //TitleField + final public function getTitleField() + { + return $this->_model->getTitleField(); + } + //Field별 Form Rule용 + final public function getFieldRules(array $fields, string $action) + { + return $this->_model->getFieldRules($fields, $action); + } + //Field별 Form Filter용 + final public function getFieldFilters() + { + return $this->_model->getFieldFilters(); + } + //Field별 Form BatchFilter용 + final public function getFieldBatchFilters() + { + return $this->_model->getFieldBatchFilters(); + } + //Field별 Form Option용 + public function getFieldFormOption(string $field): array + { + switch ($field) { + case 'user_uid': + $options = $this->_user_uids = $this->_user_uids ?: $this->getUserModel()->getFieldFormOptions(['status' => 'use']); + break; + default: + $options = lang($this->_className . '.' . strtoupper($field)); + break; + } + if (!is_array($options)) { + throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); + } + return $options; + } + //Field별 Form Option용 + final public function getFieldFormOptions(array $fields): array + { + $fieldFormOptions = array(); + foreach ($fields as $field) { + if (!is_string($field)) { + throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true)); + } + $fieldFormOptions[$field] = $this->getFieldFormOption($field); + } + return $fieldFormOptions; + } + + //Insert관련 + public function insert(array $fieldDatas): BaseEntity + { + return $this->_model->create($fieldDatas); + } + //Update관련 + public function update($entity, array $fieldDatas) + { + return $this->_model->modify($entity, $fieldDatas); + } + //Delete 관련 + public function delete($entity) + { + if (!$this->_model->delete($entity->getPrimaryKey())) { + log_message("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery()); + log_message("error", implode("\n", $this->_model->errors())); + throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true)); + } + } + //View 관련 + public function view($entity) + { + return $entity; + } + + public function setCondition(array $filterFields, $word, $start, $end, $order_field, $order_value) + { + foreach ($filterFields as $field => $value) { + $this->_model->where($field, $value); + } + if (!is_null($word)) { + $this->_model->setIndexWordFilter($word); + } + if (!is_null($start) && !is_null($end)) { + $this->_model->setIndexDateFilter($start, $end); + } + $this->_model->setIndexOrderBy($order_field, $order_value); + } + final public function getTotalCount() + { + return $this->_model->countAllResults(); + } + final public function getFindEntitys(int $page = 0, int $per_page = 0) + { + return $per_page ? $this->_model->findAll($per_page, $page * $per_page - $per_page) : $this->_model->findAll(); + } +} diff --git a/app/Backend/BaseHierarchyBackend.php b/app/Backend/BaseHierarchyBackend.php new file mode 100644 index 0000000..d10d640 --- /dev/null +++ b/app/Backend/BaseHierarchyBackend.php @@ -0,0 +1,21 @@ +_model->getContentField(); + } + //Reply관련 + public function reply($entity, array $fieldDatas) + { + return $this->_model->reply($entity, $fieldDatas); + } +} diff --git a/app/Backend/BoardBackend.php b/app/Backend/BoardBackend.php new file mode 100644 index 0000000..0cc30ba --- /dev/null +++ b/app/Backend/BoardBackend.php @@ -0,0 +1,47 @@ +_model = new BoardModel(); + } + //BoardConfig모델 + final public function getBoardConfigModel(): BoardConfigModel + { + return is_null($this->_boardConfigModel) ? new BoardConfigModel() : $this->_boardConfigModel; + } + + //Field별 Form Option용 + public function getFieldFormOption(string $field): array + { + switch ($field) { + case 'board_config_uid': + $options = $this->_board_config_uids = $this->_board_config_uids ?: $this->getBoardConfigModel()->getFieldFormOptions(['status' => 'use']); + break; + default: + return parent::getFieldFormOption($field); + break; + } + if (!is_array($options)) { + throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); + } + return $options; + } + + //View관련 + public function view($entity) + { + //view_cnt에 추가하기위함 + $this->_model->increaseViewCount($entity->getPrimaryKey()); + return parent::view($entity); + } +} diff --git a/app/Backend/BoardConfigBackend.php b/app/Backend/BoardConfigBackend.php new file mode 100644 index 0000000..70428b6 --- /dev/null +++ b/app/Backend/BoardConfigBackend.php @@ -0,0 +1,14 @@ +_model = new BoardConfigModel(); + } +} diff --git a/app/Backend/UserBackend.php b/app/Backend/UserBackend.php new file mode 100644 index 0000000..3618566 --- /dev/null +++ b/app/Backend/UserBackend.php @@ -0,0 +1,14 @@ +_model = new UserModel(); + } +} diff --git a/app/Backend/UserSNSBackend.php b/app/Backend/UserSNSBackend.php new file mode 100644 index 0000000..cb8da34 --- /dev/null +++ b/app/Backend/UserSNSBackend.php @@ -0,0 +1,14 @@ +_model = new UserSNSModel(); + } +} diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9a142d2..1f05cb0 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -39,9 +39,9 @@ $routes->get('/login', 'AuthController::login'); $routes->post('/signup', 'AuthController::signup/local'); $routes->get('/signup/(:alpha)', 'AuthController::signup/$1'); $routes->get('/logout', 'AuthController::logout'); -$routes->group('ecommerce', ['namespace' => 'App\Controllers'], static function ($routes) { - $routes->post('addCart', 'EcommerceController::addCart'); - $routes->get('cancelCart/(:uuid)', 'EcommerceController::cancelCart/$1'); +$routes->group('cart', ['namespace' => 'App\Controllers'], static function ($routes) { + $routes->post('addCart', 'CartController::addCart'); + $routes->get('cancelCart/(:uuid)', 'CartController::cancelCart/$1'); });; $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) { }); @@ -95,39 +95,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->post('batchjob', 'BoardController::batchjob'); $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); }); - $routes->group('category', static function ($routes) { - $routes->get('', 'CategoryController::index'); - $routes->get('excel', 'CategoryController::excel/$1'); - $routes->get('insert', 'CategoryController::insert_form'); - $routes->post('insert', 'CategoryController::insert'); - $routes->get('update/(:num)', 'CategoryController::update_form/$1'); - $routes->post('update/(:num)', 'CategoryController::update/$1'); - $routes->get('view/(:num)', 'CategoryController::view/$1'); - $routes->get('reply/(:num)', 'CategoryController::reply_form/$1'); - $routes->post('reply/(:num)', 'CategoryController::reply/$1'); - $routes->get('delete/(:num)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:num)/(:hash)', 'CategoryController::toggle/$1/$2'); - $routes->post('batchjob', 'CategoryController::batchjob'); - }); - $routes->group('product', static function ($routes) { - $routes->get('', 'ProductController::index'); - $routes->get('excel', 'ProductController::excel/$1'); - $routes->get('insert', 'ProductController::insert_form'); - $routes->post('insert', 'ProductController::insert'); - $routes->get('update/(:uuid)', 'ProductController::update_form/$1'); - $routes->post('update/(:uuid)', 'ProductController::update/$1'); - $routes->get('view/(:uuid)', 'ProductController::view/$1'); - $routes->get('delete/(:uuid)', 'ProductController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:uuid)/(:hash)', 'ProductController::toggle/$1/$2'); - $routes->post('batchjob', 'ProductController::batchjob'); - }); - $routes->group('order', static function ($routes) { - $routes->get('', 'OrderController::index'); - $routes->get('view/(:uuid)', 'OrderController::view/$1'); - $routes->get('delete/(:uuid)', 'OrderController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:uuid)/(:hash)', 'OrderController::toggle/$1/$2'); - $routes->post('batchjob', 'OrderController::batchjob`'); - }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { $routes->group('user', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:master,director,cloudflare,manager,gold,silver,brone,vip,user'], static function ($routes) { @@ -148,15 +115,6 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou $routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); }); - $routes->group('product', static function ($routes) { - $routes->get('', 'ProductController::index'); - $routes->get('excel', 'ProductController::excel/$1'); - $routes->get('view/(:uuid)', 'ProductController::view/$1'); - }); - $routes->group('order', static function ($routes) { - $routes->get('', 'OrderController::index'); - $routes->get('view/(:uuid)', 'OrderController::view/$1'); - });; }); /* * -------------------------------------------------------------------- diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 8b5a6fe..87f01db 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -22,6 +22,10 @@ class UserController extends AdminController protected function getFieldFormData(string $field, $entity = null): array { switch ($field) { + case 'role': + $roles = $this->request->getVar($field); + $this->_viewDatas['fieldDatas'][$field] = is_array($roles) ? implode(",", $roles) : $roles; + break; case 'passwd': $this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field); $this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword'); diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index df390e0..552d2c0 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -70,6 +70,23 @@ abstract class BaseController extends Controller { return $this->getFieldFilters(); } + protected function getFieldRule(string $field, array $rules, string $action = ""): array + { + switch ($field) { + default: + $rules = $this->_model->getFieldRule($field, $rules, $action); + break; + } + return $rules; + } + final public function getFieldRules(array $fields, string $action = ""): array + { + $rules = array(); + foreach ($fields as $field) { + $rules = $this->getFieldRule($field, $rules, $action); + } + return $rules; + } //Field별 Form Datas 처리용 protected function getFieldFormData(string $field, $entity = null): array { @@ -127,9 +144,9 @@ abstract class BaseController extends Controller break; } $this->_viewDatas['fields'] = $fields ?: $this->getFields($action); + $this->_viewDatas['fieldRules'] = $this->getFieldRules($this->_viewDatas['fields'], $action); $this->_viewDatas['fieldFilters'] = $this->getFieldFilters(); $this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters(); - $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action); $this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']); return $this->_viewDatas; } @@ -189,7 +206,7 @@ abstract class BaseController extends Controller $this->_viewDatas = $this->init(__FUNCTION__); $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []]; helper(['form']); - $$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']); + $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']); $this->_viewDatas['entity'] = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]); return view($this->_viewPath . '/update', $this->_viewDatas); } catch (\Exception $e) { diff --git a/app/Helpers/User_helper.php b/app/Helpers/User_helper.php index 17ff344..8206f7b 100644 --- a/app/Helpers/User_helper.php +++ b/app/Helpers/User_helper.php @@ -17,12 +17,12 @@ function getFieldForm_UserHelper($field, $value, array $fieldFormOptions, array $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { case 'role': - $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; - return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); - // foreach ($fieldFormOptions[$field] as $key => $label) { - // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : [$value]), $attributes) . $label; - // } - // return implode(" ", $checkboxs); + // $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; + // return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + foreach ($fieldFormOptions[$field] as $key => $label) { + $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : [$value]), $attributes) . $label; + } + return implode(" ", $checkboxs); // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); break; case "status": @@ -86,6 +86,15 @@ function getFieldFilter_UserHelper($field, $value, array $fieldFormOptions, arra { $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { + case 'role': + $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]]; + return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]); + // foreach ($fieldFormOptions[$field] as $key => $label) { + // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : [$value]), $attributes) . $label; + // } + // return implode(" ", $checkboxs); + // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]); + break; default: return getFieldForm_UserHelper($field, $value, $fieldFormOptions, $attributes); break; diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index f57d605..c2fe284 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -106,14 +106,6 @@ abstract class BaseModel extends Model } return $rules; } - final public function getFieldRules(array $fields, string $action = ""): array - { - $rules = array(); - foreach ($fields as $field) { - $rules = $this->getFieldRule($field, $rules, $action); - } - return $rules; - } //Field별 Form Option용 public function getOptions(array $conditions = array(), $options = array()): array { diff --git a/app/Views/admin/board/index.php b/app/Views/admin/board/index.php index 0e4ec9b..4737b03 100644 --- a/app/Views/admin/board/index.php +++ b/app/Views/admin/board/index.php @@ -9,7 +9,7 @@ - + @@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/boardconfig/index.php b/app/Views/admin/boardconfig/index.php index 3e28890..8168605 100644 --- a/app/Views/admin/boardconfig/index.php +++ b/app/Views/admin/boardconfig/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/user/index.php b/app/Views/admin/user/index.php index 57e6a6a..67f1860 100644 --- a/app/Views/admin/user/index.php +++ b/app/Views/admin/user/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/usersns/index.php b/app/Views/admin/usersns/index.php index b4a08b9..4294d44 100644 --- a/app/Views/admin/usersns/index.php +++ b/app/Views/admin/usersns/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/layouts/admin/left_menu.php b/app/Views/layouts/admin/left_menu.php index 7ebd6ca..03a3677 100644 --- a/app/Views/layouts/admin/left_menu.php +++ b/app/Views/layouts/admin/left_menu.php @@ -5,6 +5,5 @@
include($layout['path'] . '/left_menu/base'); ?> include($layout['path'] . '/left_menu/board'); ?> - include($layout['path'] . '/left_menu/shoppingmall'); ?>
\ No newline at end of file diff --git a/app/Views/layouts/front/header.php b/app/Views/layouts/front/header.php new file mode 100644 index 0000000..6bd4c0b --- /dev/null +++ b/app/Views/layouts/front/header.php @@ -0,0 +1,5 @@ +
+ HOME + title_japanese:$parentCategory->title ?> + title_japanese:$currentCategory->title ?> +
diff --git a/app/Views/layouts/front/siteboard_left_banner.php b/app/Views/layouts/front/siteboard_left_banner.php new file mode 100644 index 0000000..a7e11b4 --- /dev/null +++ b/app/Views/layouts/front/siteboard_left_banner.php @@ -0,0 +1,8 @@ + + + +
+
+
+
+ diff --git a/app/Views/layouts/front/sitecontent_left_banner.php b/app/Views/layouts/front/sitecontent_left_banner.php new file mode 100644 index 0000000..2cf1792 --- /dev/null +++ b/app/Views/layouts/front/sitecontent_left_banner.php @@ -0,0 +1,8 @@ + + + +
+
+
+
+ diff --git a/app/Views/layouts/front/top_logo.php b/app/Views/layouts/front/top_logo.php new file mode 100644 index 0000000..6e5a8d2 --- /dev/null +++ b/app/Views/layouts/front/top_logo.php @@ -0,0 +1,13 @@ + +
+ + +
+ + + + + +
+
+ \ No newline at end of file diff --git a/app/Views/layouts/front/welcome_left_banner.php b/app/Views/layouts/front/welcome_left_banner.php new file mode 100644 index 0000000..18c3514 --- /dev/null +++ b/app/Views/layouts/front/welcome_left_banner.php @@ -0,0 +1,5 @@ +
+ +
+
+
diff --git a/app/Views/layouts/front/welcome_partner_banner.php b/app/Views/layouts/front/welcome_partner_banner.php new file mode 100644 index 0000000..95013bf --- /dev/null +++ b/app/Views/layouts/front/welcome_partner_banner.php @@ -0,0 +1,16 @@ +
+     +   +   +   +   +   +   +   +   +   +   +   +   +   +
diff --git a/app/Views/layouts/front/welcome_right_banner.php b/app/Views/layouts/front/welcome_right_banner.php new file mode 100644 index 0000000..45c9c01 --- /dev/null +++ b/app/Views/layouts/front/welcome_right_banner.php @@ -0,0 +1,14 @@ +
+ +
+
+
+
+
+
+
+
+
+
+
+
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>