From 5d620c8d888842f9a54550e69e769f8e54c8ac8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Sat, 28 Sep 2024 18:47:43 +0900 Subject: [PATCH] cfmgrv4 init...1 --- app/Config/Constants.php | 3 +- app/Controllers/MVController.php | 18 ++- .../Admin/Cloudflare/Record_helper.php | 107 +++++++++--------- app/Models/Cloudflare/RecordModel.php | 11 +- app/Models/Cloudflare/ZoneModel.php | 4 +- app/Models/CommonModel.php | 9 +- app/Views/admin/cloudflare/record/index.php | 8 +- public/css/admin.css | 2 +- public/css/admin/content.css | 4 +- public/css/admin/left_menu.css | 1 + public/css/common/left_menu.css | 6 +- public/css/common/login_v1.css | 2 +- public/css/common/top_menu.css | 6 +- public/css/common/top_navigator.css | 2 +- public/css/empty.css | 12 +- public/css/front.css | 13 +-- public/css/front/content.css | 4 +- public/css/front/order.css | 4 +- public/css/main.css | 10 +- public/css/main/content.css | 4 +- public/css/style.css | 4 - public/js/admin.js | 5 +- 22 files changed, 113 insertions(+), 126 deletions(-) diff --git a/app/Config/Constants.php b/app/Config/Constants.php index c429da7..aab90f0 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -165,7 +165,8 @@ define('ICONS', [ 'NEW' => '', 'REPLY' => '', 'DELETE' => '', - 'RELOAD' => '', + 'REBOOT' => '', + 'RELOAD' => '', 'SETUP' => '', 'FLAG' => '', 'SEARCH' => '', diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index 7f8961f..31f1eb7 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -153,7 +153,7 @@ abstract class MVController extends CommonController } } // 리스트 - private function list_condition_process($isTotalCount = false): void + private function list_condition_process(): void { //조건절 처리 foreach ($this->filter_fields as $field) { @@ -171,19 +171,11 @@ abstract class MVController extends CommonController $this->start = $this->request->getVar('start') ?: DEFAULTS['EMPTY']; $this->end = $this->request->getVar('end') ?: DEFAULTS['EMPTY']; $this->getModel()->setList_DateFilter($this->start, $this->end); - if (!$isTotalCount) { - //Sorting 처리 - $this->order_field = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY']; - $this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY']; - if ($this->order_field !== DEFAULTS['EMPTY'] && $this->order_value !== DEFAULTS['EMPTY']) { - $this->getModel()->setList_OrderBy("{$this->order_field} {$this->order_value}"); - } - } } //Totalcount 처리 private function list_total_process(): int { - $this->list_condition_process(true); + $this->list_condition_process(); $total_count = $this->getModel()->countAllResults(); // echo $this->getModel()->getLastQuery(); return $total_count; @@ -220,6 +212,10 @@ abstract class MVController extends CommonController private function list_entitys_process(): array { $this->list_condition_process(); + //Sorting 처리 + $this->order_field = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY']; + $this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY']; + $this->getModel()->setList_OrderBy($this->order_field !== DEFAULTS['EMPTY'] && $this->order_value !== DEFAULTS['EMPTY'] ? "{$this->order_field} {$this->order_value}" : ""); if ($this->page) { $this->getModel()->limit( $this->per_page, @@ -227,7 +223,7 @@ abstract class MVController extends CommonController ); } $entitys = $this->getModel()->findAll(); - // echo $this->getModel()->getLastQuery(); + echo $this->getModel()->getLastQuery(); return $entitys; } final protected function list_procedure(): string diff --git a/app/Helpers/Admin/Cloudflare/Record_helper.php b/app/Helpers/Admin/Cloudflare/Record_helper.php index 804f082..7e7e42a 100644 --- a/app/Helpers/Admin/Cloudflare/Record_helper.php +++ b/app/Helpers/Admin/Cloudflare/Record_helper.php @@ -2,30 +2,28 @@ use App\Models\Cloudflare\RecordModel; -function getFieldLabel_RecordHelper(string $field, array $viewDatas, array $attributes = []): string +function getFieldLabel_RecordHelper(string $field, array $viewDatas, array $extras = []): string { switch ($field) { + case RecordModel::PARENT: + $extras = [...$extras, "class" => '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_RecordHelper(string $field, mixed $value, array $viewDatas, array $attributes = []): string +function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas, array $extras = []): string { $value = $value ?: DEFAULTS['EMPTY']; switch ($field) { case RecordModel::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; // } @@ -41,7 +39,7 @@ function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas case "locked": case "proxied": case "proxiable": - $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $attributes); + $form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $extras); break; case 'updated_at': case 'created_at': @@ -53,11 +51,31 @@ function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas } return $form; } // - -function getFieldView_RecordHelper(string $field, mixed $entity, array $viewDatas, array $attributes = []) +function getFieldView_RecordHelper(string $field, mixed $entity, array $viewDatas, array $extras = []) { $value = $entity->$field ?: DEFAULTS['EMPTY']; switch ($field) { + case RecordModel::PARENT: + if ($extras['old_zone'] === $entity->getParent()) { + $value = ""; + } else { + $value = anchor( + current_url() . '/reload/' . $entity->getParent(), + ICONS["RELOAD"], + [ + "class" => "btn btn-sm btn-primary btn-circle fa fa-refresh", + "target" => "_self" + ] + ) . "{$viewDatas['field_options'][$field][$value]}"; + } + break; + case RecordModel::TITLE: + $value = anchor( + current_url() . '/immobilized/' . $entity->getPK(), + $value, + ["target" => "_self", "class" => "label_hosts"] + ); + break; case 'category_uid': foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) { foreach ($category_2depths as $key => $depth) { @@ -78,53 +96,36 @@ function getFieldView_RecordHelper(string $field, mixed $entity, array $viewData break; default: if (in_array($field, $viewDatas['filter_fields']) && $value) { - $value = $viewDatas['field_options'][$field][$value]; - } - break; - } - return $value; -} // - -function getListHeaders_RecordHelper(string $field, array $viewDatas, array $attributes = []): string -{ - $label = getFieldLabel_RecordHelper($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_RecordHelper(string $field, mixed $entity, array $viewDatas, array $attributes = []): string -{ - switch ($field) { - case RecordModel::TITLE: - $value = anchor( - current_url() . '/view/' . $entity->getPK(), - getFieldView_RecordHelper($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_RecordHelper($field, $entity, $viewDatas, $attributes); + $value = getFieldForm_RecordHelper($field, $entity->$field, $viewDatas, $extras); } - $value = getFieldView_RecordHelper($field, $entity, $viewDatas); break; } return $value; +} // +function getListColumns_RecordHelper(string $field, array $viewDatas, array $extras = []): string +{ + $label = getFieldLabel_RecordHelper($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 RecordModel::PARENT: + $label .= "