diff --git a/app/Config/Constants.php b/app/Config/Constants.php
index aab90f0..9c6cacb 100644
--- a/app/Config/Constants.php
+++ b/app/Config/Constants.php
@@ -161,9 +161,9 @@ define('ICONS', [
'LOGOUT' => '',
'HOME' => '',
'MENU' => '',
- 'LOCK' => '',
'NEW' => '',
'REPLY' => '',
+ 'DATABASE' => '',
'DELETE' => '',
'REBOOT' => '',
'RELOAD' => '',
@@ -184,7 +184,10 @@ define('ICONS', [
'GOOGLE' => '',
'CLOUD' => '',
'SIGNPOST' => '',
- 'SIGNPOST2' => '',
+ 'LOCK' => '',
+ 'UNLOCK' => '',
+ 'BOX' => '',
+ 'BOXS' => '',
]);
//배너관련
define('TOP_BANNER', [
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 1f0c68c..81b67e0 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -34,10 +34,12 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($rou
});
$routes->group('zone', function ($routes) {
$routes->get('/', 'ZoneController::index');
+ $routes->get('create', 'ZoneController::create_form');
$routes->post('create/(:uuid)', 'ZoneController::create/$1');
});
$routes->group('record', function ($routes) {
$routes->get('/', 'RecordController::index');
+ $routes->get('create', 'RecordController::create_form');
$routes->post('create/(:uuid)', 'RecordController::create/$1');
});
});
diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php
index 5961cea..d760af9 100644
--- a/app/Controllers/Admin/AdminController.php
+++ b/app/Controllers/Admin/AdminController.php
@@ -8,13 +8,14 @@ use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Traits\AuthTrait;
+
abstract class AdminController extends MVController
{
use AuthTrait;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
- $this->class_path = "Admin/";
+ $this->root = "Admin/";
$this->layout = "admin";
$this->session = $this->session_AuthTrait();
}
diff --git a/app/Controllers/Admin/Cloudflare/AccountController.php b/app/Controllers/Admin/Cloudflare/AccountController.php
index 003f3b8..d5d13b0 100644
--- a/app/Controllers/Admin/Cloudflare/AccountController.php
+++ b/app/Controllers/Admin/Cloudflare/AccountController.php
@@ -19,7 +19,7 @@ class AccountController extends CloudflareController
{
parent::initController($request, $response, $logger);
$this->class_name = "Account";
- $this->class_path .= $this->class_name;
+ $this->class_path = $this->root . $this->class_name;
$this->title = lang("{$this->class_path}.title");
helper($this->class_path);
}
@@ -37,13 +37,32 @@ class AccountController extends CloudflareController
}
return $this->_mySocket;
}
+ protected function getFormFieldOption(string $field, array $options = []): array
+ {
+ switch ($field) {
+ case $this->getModel()::PARENT:
+ $this->getAuthModel()->where('status', DEFAULTS['STATUS']);
+ $options[$field] = [
+ DEFAULTS['EMPTY'] => lang($this->class_path . '.label.' . $field) . ' 선택',
+ ...$this->getAuthModel()->getFormFieldOption($field, $options),
+ ];
+ // echo $this->getAuthModel()->getLastQuery();
+ // dd($options);
+ break;
+ default:
+ $options = parent::getFormFieldOption($field, $options);
+ break;
+ }
+ return $options;
+ }
// 리스트
public function index(): string
{
- $this->fields = [$this->getModel()::TITLE, 'oldkey', 'type', 'status', 'updated_at', 'created_at'];
- $this->field_rules = $this->getModel()->getFieldRules(__FUNCTION__, $this->fields);
- $this->filter_fields = ['type', 'status'];
- $this->batchjob_fields = ['status'];
+ $this->action = __FUNCTION__;
+ $this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'status', 'updated_at', 'created_at'];
+ $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
+ $this->filter_fields = [$this->getModel()::PARENT, 'type', 'status'];
+ $this->batchjob_fields = ['typep', 'status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
return $this->list_procedure();
}
diff --git a/app/Controllers/Admin/Cloudflare/AuthController.php b/app/Controllers/Admin/Cloudflare/AuthController.php
index c014b38..efb82d8 100644
--- a/app/Controllers/Admin/Cloudflare/AuthController.php
+++ b/app/Controllers/Admin/Cloudflare/AuthController.php
@@ -16,7 +16,7 @@ class AuthController extends CloudflareController
{
parent::initController($request, $response, $logger);
$this->class_name = "Auth";
- $this->class_path .= $this->class_name;
+ $this->class_path = $this->root . $this->class_name;
$this->title = lang("{$this->class_path}.title");
helper($this->class_path);
}
@@ -29,8 +29,9 @@ class AuthController extends CloudflareController
}
private function init(string $action): void
{
- $this->fields = [$this->getModel()::TITLE, 'authkey', 'status'];
- $this->field_rules = $this->getModel()->getFieldRules($action, $this->fields);
+ $this->action = $action;
+ $this->fields = [$this->getModel()::TITLE, 'authkey'];
+ $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = ['status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
}
@@ -42,43 +43,52 @@ class AuthController extends CloudflareController
}
protected function create_process(): void
{
+ $this->create_validate($this->action, $this->fields);
+ $this->formDatas = $this->getFormDatas();
parent::create_process();
- $entity = $this->getModel()->create($this->formDatas);
+ $this->entity = $this->getModel()->create($this->formDatas);
}
public function create(): RedirectResponse
{
$this->init(__FUNCTION__);
- $this->create_validate($this->_fields);
- $this->formDatas = $this->getFormDatas();
return $this->create_procedure();
}
//수정
- public function modify_form(): RedirectResponse|string
+ protected function modify_form_process(string $uid): void
+ {
+ $this->entity = $this->getModel()->getEntityByPK(intval($uid));
+ if ($this->entity === null) {
+ throw new \Exception("해당 정보를 찾을수 없습니다.");
+ }
+ parent::modify_form_process($uid);
+ }
+ public function modify_form(string $uid): RedirectResponse|string
{
$this->init('modify');
- return $this->create_form_procedure();
+ return $this->modify_form_procedure($uid);
}
- protected function modify_process(): void
+ protected function modify_process(string $uid): void
{
- parent::modify_process();
+ $this->entity = $this->getModel()->getEntityByPK(intval($uid));
+ if ($this->entity === null) {
+ throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
+ }
+ $this->modify_validate($this->action, $this->fields);
+ $this->formDatas = $this->getFormDatas();
+ parent::modify_process($uid);
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
}
public function modify(string $uid): RedirectResponse
{
- $this->entity = $this->getModel()->getEntityByPK($uid);
- if ($this->entity === null) {
- throw new \Exception("해당 정보를 찾을수 없습니다.");
- }
- $this->init(__FUNCTION__);;
- $this->modify_validate($this->_fields);
- $this->formDatas = $this->getFormDatas();
- return $this->create_procedure();
+ $this->init(__FUNCTION__);
+ return $this->modify_procedure($uid);
}
// 리스트
public function index(): string
{
+ $this->action = __FUNCTION__;
$this->fields = [$this->getModel()::TITLE, 'oldkey', 'status', 'updated_at', 'created_at'];
- $this->field_rules = $this->getModel()->getFieldRules(__FUNCTION__, $this->fields);
+ $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = ['status'];
$this->batchjob_fields = ['status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
diff --git a/app/Controllers/Admin/Cloudflare/CloudflareController.php b/app/Controllers/Admin/Cloudflare/CloudflareController.php
index 843b2eb..52a959a 100644
--- a/app/Controllers/Admin/Cloudflare/CloudflareController.php
+++ b/app/Controllers/Admin/Cloudflare/CloudflareController.php
@@ -21,7 +21,7 @@ abstract class CloudflareController extends AdminController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
- $this->class_path .= "Cloudflare/";
+ $this->root .= "Cloudflare/";
}
final protected function getAuthModel(): AuthModel
{
diff --git a/app/Controllers/Admin/Cloudflare/RecordController.php b/app/Controllers/Admin/Cloudflare/RecordController.php
index 7d52871..9ff00e9 100644
--- a/app/Controllers/Admin/Cloudflare/RecordController.php
+++ b/app/Controllers/Admin/Cloudflare/RecordController.php
@@ -16,7 +16,7 @@ class RecordController extends CloudflareController
{
parent::initController($request, $response, $logger);
$this->class_name = "Record";
- $this->class_path .= $this->class_name;
+ $this->class_path = $this->root . $this->class_name;
$this->title = lang("{$this->class_path}.title");
helper($this->class_path);
}
@@ -70,16 +70,22 @@ class RecordController extends CloudflareController
}
private function init(string $action): void
{
+ $this->action = $action;
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'hosts'];
- $this->field_rules = $this->getModel()->getFieldRules($action, $this->fields);
+ $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
}
//생성
- protected function create_validate(array $fields): void
+ public function create_form(): RedirectResponse|string
+ {
+ $this->init('create');
+ return $this->create_form_procedure();
+ }
+ protected function create_validate(string $action, array $fields): void
{
//hosts를 제외한 fields Valid처리
- parent::create_validate(array_diff($fields, ['hosts']));
+ parent::create_validate($action, array_diff($fields, ['hosts']));
}
protected function create_process(): void
{
@@ -95,7 +101,7 @@ class RecordController extends CloudflareController
public function create(): RedirectResponse
{
$this->init(__FUNCTION__);
- $this->create_validate($this->fields);
+ $this->create_validate($this->action, $this->fields);
$this->formDatas = $this->getFormDatas();
//부모데이터 정의
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
@@ -113,9 +119,10 @@ class RecordController extends CloudflareController
// 리스트
public function index(): string
{
+ $this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
- $this->field_rules = $this->getModel()->getFieldRules(__FUNCTION__, $this->fields);
+ $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->batchjob_fields = ['proxied'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
return $this->list_procedure();
diff --git a/app/Controllers/Admin/Cloudflare/ZoneController.php b/app/Controllers/Admin/Cloudflare/ZoneController.php
index 3783407..cb31eb6 100644
--- a/app/Controllers/Admin/Cloudflare/ZoneController.php
+++ b/app/Controllers/Admin/Cloudflare/ZoneController.php
@@ -19,7 +19,7 @@ class ZoneController extends CloudflareController
{
parent::initController($request, $response, $logger);
$this->class_name = "Zone";
- $this->class_path .= $this->class_name;
+ $this->class_path = $this->root . $this->class_name;
$this->title = lang("{$this->class_path}.title");
helper($this->class_path);
}
@@ -50,6 +50,13 @@ class ZoneController extends CloudflareController
// echo $this->getAccountModel()->getLastQuery();
// dd($options);
break;
+ case 'type':
+ case 'proxied':
+ $options[$field] = [
+ "" => lang($this->root . 'Record.label.' . $field) . ' 선택',
+ ...lang($this->root . 'Record.' . strtoupper($field)),
+ ];
+ break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
@@ -79,16 +86,22 @@ class ZoneController extends CloudflareController
}
private function init(string $action): void
{
+ $this->action = $action;
$this->fields = [$this->getModel()::PARENT, 'domains', 'hosts', 'type', 'content', 'proxied'];
- $this->field_rules = $this->getModel()->getFieldRules($action, $this->fields);
- $this->filter_fields = [$this->getModel()::PARENT, 'development_mode', 'ipv6', 'security_level', 'status'];
+ $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
+ $this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
}
//생성
- protected function create_validate(array $fields): void
+ public function create_form(): RedirectResponse|string
+ {
+ $this->init('create');
+ return $this->create_form_procedure();
+ }
+ protected function create_validate(string $action, array $fields): void
{
//domains,hosts를 제외한 fields Valid처리
- parent::create_validate(array_diff($fields, ['domains', 'hosts']));
+ parent::create_validate($action, array_diff($fields, ['domains', 'hosts']));
}
protected function create_process(): void
{
@@ -114,7 +127,7 @@ class ZoneController extends CloudflareController
public function create(): RedirectResponse
{
$this->init(__FUNCTION__);
- $this->create_validate($this->_fields);
+ $this->create_validate($this->action, $this->fields);
$this->formDatas = $this->getFormDatas();
//부모데이터 정의
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
@@ -149,8 +162,9 @@ class ZoneController extends CloudflareController
// 리스트
public function index(): string
{
+ $this->action = __FUNCTION__;
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'created_at'];
- $this->field_rules = $this->getModel()->getFieldRules(__FUNCTION__, $this->fields);
+ $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'development_mode', 'ipv6', 'security_level'];
$this->batchjob_fields = ['development_mode', 'ipv6', 'security_level'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields);
diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php
index 5bfa30d..874fc7c 100644
--- a/app/Controllers/Admin/UserController.php
+++ b/app/Controllers/Admin/UserController.php
@@ -6,20 +6,20 @@ use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
-use App\Controllers\CommonController;
use App\Models\UserModel;
use App\Traits\AuthTrait;
-class UserController extends CommonController
+class UserController extends AdminController
{
- use AuthTrait;
private $_model = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
- $this->session = $this->session_AuthTrait();
+ $this->root = "Admin/";
+ $this->layout = "admin";
+ $this->session = $this->session_AuthTrait();
}
- private function getModel(): UserModel
+ protected function getModel(): UserModel
{
if ($this->_model === null) {
$this->_model = new UserModel();
diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php
index 31f1eb7..3fa2b53 100644
--- a/app/Controllers/MVController.php
+++ b/app/Controllers/MVController.php
@@ -57,11 +57,11 @@ abstract class MVController extends CommonController
return $formDatas;
}
// 생성
- protected function create_validate(array $fields): void
+ protected function create_validate(string $action, array $fields): void
{
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
$this->validation = service('validation');
- $this->validation->setRules($this->getModel()->getFieldRules($fields));
+ $this->validation->setRules($this->getModel()->getFieldRules($action, $fields));
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
"\n",
@@ -78,7 +78,7 @@ abstract class MVController extends CommonController
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view(
- strtolower($this->class_path) . "/create",
+ strtolower(string: $this->class_path) . "/create",
data: ['viewDatas' => $this->getViewDatas()]
);
} catch (\Exception $e) {
@@ -105,11 +105,11 @@ abstract class MVController extends CommonController
}
}
// 수정
- protected function modify_validate(array $fields): void
+ protected function modify_validate(string $action, array $fields): void
{
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
$this->validation = service('validation');
- $this->validation->setRules($this->getModel()->getFieldRules($fields));
+ $this->validation->setRules($this->getModel()->getFieldRules($action, $fields));
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
"\n",
@@ -117,12 +117,12 @@ abstract class MVController extends CommonController
));
}
}
- protected function modify_form_process(): void {}
- final protected function modify_form_procedure(): RedirectResponse|string
+ protected function modify_form_process(string $uid): void {}
+ final protected function modify_form_procedure(string $uid): RedirectResponse|string
{
try {
helper(['form']);
- $this->modify_form_process();
+ $this->modify_form_process($uid);
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view(
@@ -134,13 +134,13 @@ abstract class MVController extends CommonController
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage());
}
}
- protected function modify_process(): void {}
- final protected function modify_procedure(): RedirectResponse
+ protected function modify_process(string $uid): void {}
+ final protected function modify_procedure(string $uid): RedirectResponse
{
try {
//Transaction Start
$this->getModel()->transStart();
- $this->modify_process();
+ $this->modify_process($uid);
log_message("notice", __FUNCTION__ . "=> 작업을 완료하였습니다.");
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) {
@@ -222,7 +222,7 @@ abstract class MVController extends CommonController
$this->page * $this->per_page - $this->per_page
);
}
- $entitys = $this->getModel()->findAll();
+ $entitys = $this->getModel()->select($this->getModel()->getTable() . '.*')->findAll();
echo $this->getModel()->getLastQuery();
return $entitys;
}
diff --git a/app/Database/update.txt b/app/Database/update.txt
index 4b43f91..c129b42 100644
--- a/app/Database/update.txt
+++ b/app/Database/update.txt
@@ -1,3 +1,4 @@
+###cloudflareaccount 조정###
1. 필드추가
alter table cloudflareaccount add column id varchar(30) not null after auth_uid;
alter table cloudflareaccount add column authkey varchar(255) not null after id;
diff --git a/app/Helpers/Admin/Cloudflare/Account_helper.php b/app/Helpers/Admin/Cloudflare/Account_helper.php
index c93f28f..af8a955 100644
--- a/app/Helpers/Admin/Cloudflare/Account_helper.php
+++ b/app/Helpers/Admin/Cloudflare/Account_helper.php
@@ -1,39 +1,41 @@
'text-danger'];
+ break;
default:
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
- $attributes = ['style="color:red";'];
+ $extras = [...$extras, "class" => 'text-danger'];
}
- $label = sprintf(
- "%s",
- implode(" ", $attributes),
- lang("{$viewDatas['class_path']}.label.{$field}")
- );
break;
}
- return $label;
+ return form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
}
//header.php에서 getFieldForm_Helper사용
-function getFieldForm_AccountHelper(string $field, mixed $value, array $viewDatas, array $attributes = []): string
+function getFieldForm_AccountHelper(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case AccountModel::PARENT:
- $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, [...$attributes, 'class' => "select-field"]);
- // // return form_multiselect($field, $field_options[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
+ $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, [...$extras, 'class' => "select-field"]);
+ // // return form_multiselect($field, $field_options[$field], is_array($value) ? [...$value] : [$value], [$extras]);
// foreach ($viewDatas['field_options'][$field] as $key => $label) {
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
// }
// return implode(" ", $checkboxs);
break;
- case "type":
- case "status":
- $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $attributes);
+ case AccountModel::TITLE:
+ $form = form_input($field, $value, ["placeholder" => "예)test@exmaple.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
+ break;
+ case 'type':
+ case 'status':
+ $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $extras);
break;
case 'updated_at':
case 'created_at':
@@ -45,11 +47,45 @@ function getFieldForm_AccountHelper(string $field, mixed $value, array $viewData
}
return $form;
} //
-
-function getFieldView_AccountHelper(string $field, mixed $entity, array $viewDatas, array $attributes = [])
+function getFieldView_AccountHelper(string $field, AccountEntity $entity, array $viewDatas, array $extras = [])
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
+ case AccountModel::PARENT:
+ if ($extras['old_auth'] === $entity->getParent()) {
+ $value = "";
+ } else {
+ // dd($viewDatas['field_options']);
+ $value = anchor(
+ base_url() . strtolower($viewDatas['root']) . "auth/reload/" . $entity->getParent(),
+ ICONS["RELOAD"],
+ [
+ "class" => "btn btn-sm btn-primary btn-circle",
+ "target" => "_self"
+ ]
+ ) . " " .
+ preg_replace("/(\w+)@(.+)/", "$1", $viewDatas['field_options'][$field][$value])
+ . "";
+ }
+ break;
+ case AccountModel::TITLE:
+ $value = anchor(
+ current_url() . '/reload/' . $entity->getPK(),
+ ICONS["RELOAD"],
+ [
+ "class" => "btn btn-sm btn-primary btn-circle",
+ "target" => "_self"
+ ]
+ ) . " " .
+ anchor(
+ base_url() . strtolower($viewDatas['root']) . "zone?account_uid=" . $entity->getPK(),
+ ICONS["FLAG"],
+ [
+ "class" => "btn btn-sm btn-primary btn-circle",
+ "target" => "_self"
+ ]
+ ) . " {$value}";
+ break;
case 'category_uid':
foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) {
foreach ($category_2depths as $key => $depth) {
@@ -59,64 +95,40 @@ function getFieldView_AccountHelper(string $field, mixed $entity, array $viewDat
}
}
break;
- case 'cost':
- case 'price':
- case 'sale':
- $value = number_format(!$value ? 0 : $value) . "원";
- break;
case 'updated_at':
case 'created_at':
$value = $value ? date("Y-m-d", strtotime($value)) : "";
break;
default:
if (in_array($field, $viewDatas['filter_fields']) && $value) {
- $value = $viewDatas['field_options'][$field][$value];
- }
- break;
- }
- return $value;
-} //
-
-function getListHeaders_AccountHelper(string $field, array $viewDatas, array $attributes = []): string
-{
- $label = getFieldLabel_AccountHelper($field, $viewDatas, $attributes);
- if ($field == $viewDatas['order_field']) {
- $label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
- }
- $order_value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
- $viewDatas['uri']->addQuery('order_field', $field);
- $viewDatas['uri']->addQuery('order_value', $order_value);
- $header = anchor((string)$viewDatas['uri'], $label);
- switch ($field) {
- case 'title':
- $attributes = [...$attributes, "class=\"col-2\""];
- break;
- }
- return sprintf("
%s | ", implode(" ", $attributes), $header);
-}
-function getListColumns_AccountHelper(string $field, mixed $entity, array $viewDatas, array $attributes = []): string
-{
- switch ($field) {
- case AccountModel::TITLE:
- $value = anchor(
- current_url() . '/view/' . $entity->getPK(),
- getFieldView_AccountHelper($field, $entity, $viewDatas),
- ["target" => "_self"]
- );
- break;
- default:
- if (in_array($field, $viewDatas['filter_fields'])) {
- $attributes["onChange"] = sprintf(
+ $extras["onChange"] = sprintf(
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
current_url(),
$entity->getPK(),
$field,
$field
);
- $value = getFieldForm_AccountHelper($field, $entity, $viewDatas, $attributes);
+ $value = getFieldForm_AccountHelper($field, $entity->$field, $viewDatas, $extras);
}
- $value = getFieldView_AccountHelper($field, $entity, $viewDatas);
break;
}
return $value;
+} //
+function getListColumns_AccountHelper(string $field, array $viewDatas, array $extras = []): string
+{
+ $label = getFieldLabel_AccountHelper($field, $viewDatas, $extras);
+ if ($field == $viewDatas['order_field']) {
+ $label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
+ }
+ $order_value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
+ $viewDatas['uri']->addQuery('order_field', $field);
+ $viewDatas['uri']->addQuery('order_value', $order_value);
+ $label = anchor((string)$viewDatas['uri'], $label);
+ switch ($field) {
+ case AccountModel::PARENT:
+ break;
+ case AccountModel::TITLE:
+ break;
+ }
+ return sprintf("%s | ", implode(" ", $extras), $label);
}
diff --git a/app/Helpers/Admin/Cloudflare/Auth_helper.php b/app/Helpers/Admin/Cloudflare/Auth_helper.php
index 768e2cf..60a0b25 100644
--- a/app/Helpers/Admin/Cloudflare/Auth_helper.php
+++ b/app/Helpers/Admin/Cloudflare/Auth_helper.php
@@ -1,37 +1,29 @@
'text-danger'];
}
- $label = sprintf(
- "%s",
- implode(" ", $attributes),
- lang("{$viewDatas['class_path']}.label.{$field}")
- );
break;
}
- return $label;
+ return form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
}
//header.php에서 getFieldForm_Helper사용
-function getFieldForm_AuthHelper(string $field, mixed $value, array $viewDatas, array $attributes = []): string
+function getFieldForm_AuthHelper(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case AuthModel::TITLE:
- $form = form_input($field, $value, ["placeholder" => "예)sample@test.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
+ $form = form_input($field, $value, ["placeholder" => "예)test@example.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
break;
- case 'head':
- case 'tail':
- $form = form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
- break;
- case "status":
- $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $attributes);
+ case 'status':
+ $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $extras);
break;
case 'updated_at':
case 'created_at':
@@ -43,11 +35,28 @@ function getFieldForm_AuthHelper(string $field, mixed $value, array $viewDatas,
}
return $form;
} //
-
-function getFieldView_AuthHelper(string $field, mixed $entity, array $viewDatas, array $attributes = [])
+function getFieldView_AuthHelper(string $field, AuthEntity $entity, array $viewDatas, array $extras = [])
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
+ case AuthModel::TITLE:
+ $value = anchor(
+ current_url() . '/reload/' . $entity->getPK(),
+ ICONS["RELOAD"],
+ [
+ "class" => "btn btn-sm btn-primary btn-circle",
+ "target" => "_self"
+ ]
+ ) . " " .
+ anchor(
+ base_url() . strtolower($viewDatas['root']) . "account?auth_uid=" . $entity->getPK(),
+ ICONS["FLAG"],
+ [
+ "class" => "btn btn-sm btn-primary btn-circle",
+ "target" => "_self"
+ ]
+ ) . " {$value}";
+ break;
case 'category_uid':
foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) {
foreach ($category_2depths as $key => $depth) {
@@ -57,67 +66,39 @@ function getFieldView_AuthHelper(string $field, mixed $entity, array $viewDatas,
}
}
break;
- case 'cost':
- case 'price':
- case 'sale':
- $value = number_format(!$value ? 0 : $value) . "원";
- break;
- case 'content':
- $value = html_entity_decode($value);
- break;
case 'updated_at':
case 'created_at':
$value = $value ? date("Y-m-d", strtotime($value)) : "";
break;
default:
if (in_array($field, $viewDatas['filter_fields']) && $value) {
- $value = $viewDatas['field_options'][$field][$value];
- }
- break;
- }
- return $value;
-} //
-
-function getListHeaders_AuthHelper(string $field, array $viewDatas, array $attributes = []): string
-{
- $label = getFieldLabel_AuthHelper($field, $viewDatas, $attributes);
- if ($field == $viewDatas['order_field']) {
- $label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
- }
- $order_value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
- $viewDatas['uri']->addQuery('order_field', $field);
- $viewDatas['uri']->addQuery('order_value', $order_value);
- $header = anchor((string)$viewDatas['uri'], $label);
- switch ($field) {
- case 'title':
- $attributes = [...$attributes, "class=\"col-2\""];
- break;
- }
- return sprintf("%s | ", implode(" ", $attributes), $header);
-}
-function getListColumns_AuthHelper(string $field, mixed $entity, array $viewDatas, array $attributes = []): string
-{
- switch ($field) {
- case AuthModel::TITLE:
- $value = anchor(
- current_url() . '/view/' . $entity->getPK(),
- getFieldView_AuthHelper($field, $entity, $viewDatas),
- ["target" => "_self"]
- );
- break;
- default:
- if (in_array($field, $viewDatas['filter_fields'])) {
- $attributes["onChange"] = sprintf(
+ $extras["onChange"] = sprintf(
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
current_url(),
$entity->getPK(),
$field,
$field
);
- $value = getFieldForm_AuthHelper($field, $entity, $viewDatas, $attributes);
+ $value = getFieldForm_AuthHelper($field, $entity->$field, $viewDatas, $extras);
}
- $value = getFieldView_AuthHelper($field, $entity, $viewDatas);
break;
}
return $value;
+} //
+function getListColumns_AuthHelper(string $field, array $viewDatas, array $extras = []): string
+{
+ $label = getFieldLabel_AuthHelper($field, $viewDatas, $extras);
+ if ($field == $viewDatas['order_field']) {
+ $label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
+ }
+ $order_value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
+ $viewDatas['uri']->addQuery('order_field', $field);
+ $viewDatas['uri']->addQuery('order_value', $order_value);
+ $label = anchor((string)$viewDatas['uri'], $label);
+ switch ($field) {
+ case AuthModel::TITLE:
+ $label .= "