From 045f243f20909a43d7d4586ab73e12d1ff899324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 24 Sep 2024 23:20:00 +0900 Subject: [PATCH] cfmgrv4 init...1 --- app/Config/Constants.php | 1 - .../Cloudflare/AccountController.php | 8 +-- app/Controllers/MVController.php | 50 +++++++++++++------ app/Language/en/Cloudflare/Account.php | 1 + app/Models/Cloudflare/AccountModel.php | 5 +- app/Views/cloudflare/account/index.php | 11 ++-- app/Views/templates/admin/index_head.php | 2 +- 7 files changed, 48 insertions(+), 30 deletions(-) diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 99adc53..802a43d 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -98,7 +98,6 @@ define('DEFAULTS', [ 'ROLE' => "guest", 'STATUS' => "use", 'EMPTY' => "", - 'PERPAGE' => 20, 'DELIMITER_FILE' => "||", 'DELIMITER_ROLE' => ",", ]); diff --git a/app/Controllers/Cloudflare/AccountController.php b/app/Controllers/Cloudflare/AccountController.php index 1c4d7d4..a21a660 100644 --- a/app/Controllers/Cloudflare/AccountController.php +++ b/app/Controllers/Cloudflare/AccountController.php @@ -35,19 +35,19 @@ class AccountController extends CloudflareController case 'type': $inputs[$field] = form_dropdown( $field, - $this->getFormFieldInputOption($field), + $this->getFormFieldInputOption($field, $inputs), $value ); break; default: - $inputs[$field] = parent::getFormFieldInput($field, $value, $inputs); + $inputs = parent::getFormFieldInput($field, $value, $inputs); break; } return $inputs; } protected function create_init(): void { - $this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'authkey', 'status']; + $this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'authkey', 'type', 'status']; $this->filter_fields = ['type', 'status']; $this->action = DB_ACTION['CREATE']; $this->getMyLibrary()->getMyStorage()->setAction($this->action); @@ -73,7 +73,7 @@ class AccountController extends CloudflareController protected function index_init(): void { - $this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'authkey', 'oldkey', 'title', 'type', 'status', 'updated_at', 'created_at']; + $this->fields = [$this->getMyLibrary()->getMyStorage()::TITLE, 'oldkey', 'type', 'status', 'updated_at', 'created_at']; $this->filter_fields = ['type', 'status']; $this->action = DB_ACTION['CREATE']; $this->getMyLibrary()->getMyStorage()->setAction($this->action); diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index ca79565..e7a3e33 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -18,26 +18,27 @@ abstract class MVController extends CommonController abstract protected function create_process_submit(): void; abstract protected function modify_process_submit(): void; //Field별 Form Input Option용 - protected function getFormFieldInputOption(string $field, array $options = []): array + protected function getFormFieldInputOption(string $field, array $options): array { switch ($field) { default: $options = [ "" => lang($this->class_name . '.label.' . $field) . ' 선택', - lang($this->class_name . '.' . strtoupper($field)), + ...lang($this->class_name . '.' . strtoupper($field)), ]; break; } + // dd($options); return $options; } //Field별 Form Input용 - protected function getFormFieldInput(string $field, string $value, array $inputs = []): array + protected function getFormFieldInput(string $field, string $value, array $inputs): array { switch ($field) { case 'status': $inputs[$field] = form_dropdown( $field, - $this->getFormFieldInputOption($field), + $this->getFormFieldInputOption($field, $inputs), $value ); break; @@ -234,24 +235,22 @@ abstract class MVController extends CommonController protected function list_total(): int { $this->list_condition(true); - return $this->getMyLibrary()->getMyStorage()->countAllResults(); + $total_count = $this->getMyLibrary()->getMyStorage()->countAllResults(); + // dd($this->getMyLibrary()->getMyStorage()->getLastQuery()); + return $total_count; } //PageNation 처리 protected function list_pagination($pager_group = 'default', int $segment = 0, $template = 'default_full'): string { //Page, Per_page필요부분 $this->page = (int)$this->request->getVar('page') ?: 1; - $this->per_page = (int)$this->request->getVar('per_page') ?: 20; + $this->per_page = (int)$this->request->getVar('per_page') ?: intval(getenv("default.list.per_page")); //줄수 처리용 $page_options = array("" => "줄수선택"); - for ($i = 10; $i <= $this->total_count + $this->per_page; $i += 10) { + for ($i = $this->per_page; $i <= $this->total_count; $i += $this->per_page) { $page_options[$i] = $i; } - $this->page_options = form_dropdown( - 'per_page', - $page_options, - $this->per_page - ); + $this->page_options = $page_options; // 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성 // 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full', // 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가 @@ -278,22 +277,41 @@ abstract class MVController extends CommonController $this->page * $this->per_page - $this->per_page ); } - return $this->getMyLibrary()->getMyStorage()->findAll(); + $entitys = $this->getMyLibrary()->getMyStorage()->findAll(); + // dd($this->getMyLibrary()->getMyStorage()->getLastQuery()); + return $entitys; + } + protected function list_field_columns(): array + { + $columns = []; + foreach ($this->fields as $field) { + $label = lang("{$this->class_name}.label.{$field}"); + if ($field == $this->order_field) { + $label .= $this->order_value == 'ASC' ? ICONS["UP"] : ICONS["DOWN"]; + $this->order_value = $this->order_value == 'DESC' ? "ASC" : "DESC"; + } else { + $this->order_value = "ASC"; + } + $columns[] = anchor(current_url() . "?order_field={$field}&order_value={$this->order_value}", $label); + } + return $columns; } public function list_process(): string { try { - //입력폼처리 - $this->forminputs = $this->getFormFieldInputs(); //URL처리 $this->uri = $this->request->getUri(); + //입력폼처리 + $this->list_forminputs = $this->getFormFieldInputs(); + //List Field Column처리 + $this->list_field_columns = $this->list_field_columns(); + //total 처리 $this->total_count = $this->list_total(); //pagenation 처리 $this->pagination = $this->list_pagination(); //모델 처리 $this->entitys = $this->list_entitys(); - // dd($this->getMyLibrary()->getMyStorage()->getLastQuery()); //setting return_url to session flashdata $this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: ""); return view( diff --git a/app/Language/en/Cloudflare/Account.php b/app/Language/en/Cloudflare/Account.php index 176d379..3252150 100644 --- a/app/Language/en/Cloudflare/Account.php +++ b/app/Language/en/Cloudflare/Account.php @@ -6,6 +6,7 @@ return [ 'id' => "인증ID", 'authkey' => "인증Key", 'oldkey' => "이전인증Key", + 'title' => "인증명", 'type' => "가입방식", 'status' => "상태", 'updated_at' => "수정일", diff --git a/app/Models/Cloudflare/AccountModel.php b/app/Models/Cloudflare/AccountModel.php index 4bd37e2..c9693a3 100644 --- a/app/Models/Cloudflare/AccountModel.php +++ b/app/Models/Cloudflare/AccountModel.php @@ -7,7 +7,7 @@ use App\Models\CommonModel; class AccountModel extends CommonModel { - const TABLE = "cloudflarerecord"; + const TABLE = "cloudflareaccount"; const PK = "uid"; const TITLE = "title"; protected $table = self::TABLE; @@ -34,8 +34,7 @@ class AccountModel extends CommonModel $rules[$field] = "required|valid_emailvalid_email|is_unique[cloudflareauth.id]"; break; case "authkey": - $rules[$field] = $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; - ; + $rules[$field] = $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";; break; case "oldkey": $rules[$field] = $rules[$field] = "if_exist|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; diff --git a/app/Views/cloudflare/account/index.php b/app/Views/cloudflare/account/index.php index 435033d..527a589 100644 --- a/app/Views/cloudflare/account/index.php +++ b/app/Views/cloudflare/account/index.php @@ -4,8 +4,7 @@
"get")) ?> include('templates/admin/index_head') ?> @@ -15,11 +14,13 @@ # - - - @ + + + + @ + diff --git a/app/Views/templates/admin/index_head.php b/app/Views/templates/admin/index_head.php index 813b68d..372b710 100644 --- a/app/Views/templates/admin/index_head.php +++ b/app/Views/templates/admin/index_head.php @@ -7,6 +7,6 @@ \ No newline at end of file