cfmgrv4 init...1

This commit is contained in:
최준흠 2024-09-24 23:20:00 +09:00
parent 9c69e478fe
commit 045f243f20
7 changed files with 48 additions and 30 deletions

View File

@ -98,7 +98,6 @@ define('DEFAULTS', [
'ROLE' => "guest", 'ROLE' => "guest",
'STATUS' => "use", 'STATUS' => "use",
'EMPTY' => "", 'EMPTY' => "",
'PERPAGE' => 20,
'DELIMITER_FILE' => "||", 'DELIMITER_FILE' => "||",
'DELIMITER_ROLE' => ",", 'DELIMITER_ROLE' => ",",
]); ]);

View File

@ -35,19 +35,19 @@ class AccountController extends CloudflareController
case 'type': case 'type':
$inputs[$field] = form_dropdown( $inputs[$field] = form_dropdown(
$field, $field,
$this->getFormFieldInputOption($field), $this->getFormFieldInputOption($field, $inputs),
$value $value
); );
break; break;
default: default:
$inputs[$field] = parent::getFormFieldInput($field, $value, $inputs); $inputs = parent::getFormFieldInput($field, $value, $inputs);
break; break;
} }
return $inputs; return $inputs;
} }
protected function create_init(): void 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->filter_fields = ['type', 'status'];
$this->action = DB_ACTION['CREATE']; $this->action = DB_ACTION['CREATE'];
$this->getMyLibrary()->getMyStorage()->setAction($this->action); $this->getMyLibrary()->getMyStorage()->setAction($this->action);
@ -73,7 +73,7 @@ class AccountController extends CloudflareController
protected function index_init(): void 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->filter_fields = ['type', 'status'];
$this->action = DB_ACTION['CREATE']; $this->action = DB_ACTION['CREATE'];
$this->getMyLibrary()->getMyStorage()->setAction($this->action); $this->getMyLibrary()->getMyStorage()->setAction($this->action);

View File

@ -18,26 +18,27 @@ abstract class MVController extends CommonController
abstract protected function create_process_submit(): void; abstract protected function create_process_submit(): void;
abstract protected function modify_process_submit(): void; abstract protected function modify_process_submit(): void;
//Field별 Form Input Option용 //Field별 Form Input Option용
protected function getFormFieldInputOption(string $field, array $options = []): array protected function getFormFieldInputOption(string $field, array $options): array
{ {
switch ($field) { switch ($field) {
default: default:
$options = [ $options = [
"" => lang($this->class_name . '.label.' . $field) . ' 선택', "" => lang($this->class_name . '.label.' . $field) . ' 선택',
lang($this->class_name . '.' . strtoupper($field)), ...lang($this->class_name . '.' . strtoupper($field)),
]; ];
break; break;
} }
// dd($options);
return $options; return $options;
} }
//Field별 Form Input용 //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) { switch ($field) {
case 'status': case 'status':
$inputs[$field] = form_dropdown( $inputs[$field] = form_dropdown(
$field, $field,
$this->getFormFieldInputOption($field), $this->getFormFieldInputOption($field, $inputs),
$value $value
); );
break; break;
@ -234,24 +235,22 @@ abstract class MVController extends CommonController
protected function list_total(): int protected function list_total(): int
{ {
$this->list_condition(true); $this->list_condition(true);
return $this->getMyLibrary()->getMyStorage()->countAllResults(); $total_count = $this->getMyLibrary()->getMyStorage()->countAllResults();
// dd($this->getMyLibrary()->getMyStorage()->getLastQuery());
return $total_count;
} }
//PageNation 처리 //PageNation 처리
protected function list_pagination($pager_group = 'default', int $segment = 0, $template = 'default_full'): string protected function list_pagination($pager_group = 'default', int $segment = 0, $template = 'default_full'): string
{ {
//Page, Per_page필요부분 //Page, Per_page필요부분
$this->page = (int)$this->request->getVar('page') ?: 1; $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("" => "줄수선택"); $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; $page_options[$i] = $i;
} }
$this->page_options = form_dropdown( $this->page_options = $page_options;
'per_page',
$page_options,
$this->per_page
);
// 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성 // 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성
// 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full', // 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full',
// 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가 // 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가
@ -278,22 +277,41 @@ abstract class MVController extends CommonController
$this->page * $this->per_page - $this->per_page $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 public function list_process(): string
{ {
try { try {
//입력폼처리
$this->forminputs = $this->getFormFieldInputs();
//URL처리 //URL처리
$this->uri = $this->request->getUri(); $this->uri = $this->request->getUri();
//입력폼처리
$this->list_forminputs = $this->getFormFieldInputs();
//List Field Column처리
$this->list_field_columns = $this->list_field_columns();
//total 처리 //total 처리
$this->total_count = $this->list_total(); $this->total_count = $this->list_total();
//pagenation 처리 //pagenation 처리
$this->pagination = $this->list_pagination(); $this->pagination = $this->list_pagination();
//모델 처리 //모델 처리
$this->entitys = $this->list_entitys(); $this->entitys = $this->list_entitys();
// dd($this->getMyLibrary()->getMyStorage()->getLastQuery());
//setting return_url to session flashdata //setting return_url to session flashdata
$this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: ""); $this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: "");
return view( return view(

View File

@ -6,6 +6,7 @@ return [
'id' => "인증ID", 'id' => "인증ID",
'authkey' => "인증Key", 'authkey' => "인증Key",
'oldkey' => "이전인증Key", 'oldkey' => "이전인증Key",
'title' => "인증명",
'type' => "가입방식", 'type' => "가입방식",
'status' => "상태", 'status' => "상태",
'updated_at' => "수정일", 'updated_at' => "수정일",

View File

@ -7,7 +7,7 @@ use App\Models\CommonModel;
class AccountModel extends CommonModel class AccountModel extends CommonModel
{ {
const TABLE = "cloudflarerecord"; const TABLE = "cloudflareaccount";
const PK = "uid"; const PK = "uid";
const TITLE = "title"; const TITLE = "title";
protected $table = self::TABLE; protected $table = self::TABLE;
@ -34,8 +34,7 @@ class AccountModel extends CommonModel
$rules[$field] = "required|valid_emailvalid_email|is_unique[cloudflareauth.id]"; $rules[$field] = "required|valid_emailvalid_email|is_unique[cloudflareauth.id]";
break; break;
case "authkey": 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; break;
case "oldkey": 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}/]"; $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}/]";

View File

@ -4,8 +4,7 @@
<div class="top container-fluid"> <div class="top container-fluid">
<?= form_open(current_url(), array("method" => "get")) ?> <?= form_open(current_url(), array("method" => "get")) ?>
<nav class="nav"> <nav class="nav">
<?= dd($viewDatas['forminputs']) ?> 조건검색:<?php foreach ($viewDatas['filter_fields'] as $field): ?><?= $viewDatas['list_forminputs'][$field] ?><?php endforeach ?>
조건검색:<?php foreach ($viewDatas['filter_fields'] as $field): ?><?= $viewDatas['forminputs'][$field] ?><?php endforeach ?>
</nav> </nav>
<?= $this->include('templates/admin/index_head') ?> <?= $this->include('templates/admin/index_head') ?>
<?= form_close() ?> <?= form_close() ?>
@ -15,11 +14,13 @@
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
<?php foreach ($viewDatas['fields'] as $field): ?> <?php foreach ($viewDatas['list_field_columns'] as $column): ?>
<?= getFieldIndex_Column_UserHelper($field, $viewDatas) ?><?php endforeach ?> <th><?= $column ?></th>
<th>@</th> <?php endforeach ?>
<th>@</th>
</tr> </tr>
</thead> </thead>
<?= dd($viewDatas['list_field_columns']) ?>
<tbody> <tbody>
<?php $cnt = 0 ?> <?php $cnt = 0 ?>
<?php foreach ($viewDatas['entitys'] as $entity): ?> <?php foreach ($viewDatas['entitys'] as $entity): ?>

View File

@ -7,6 +7,6 @@
<nav class="nav justify-content-end"> <nav class="nav justify-content-end">
<span class="pageinfo"> <span class="pageinfo">
페이지정보 : <?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?> 페이지정보 : <?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?>
<?= form_dropdown('per_page', $viewDatas['pageOptions'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?> / 총:<?= $viewDatas['total_count'] ?> <?= form_dropdown('per_page', $viewDatas['page_options'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?> / 총:<?= $viewDatas['total_count'] ?>
</span> </span>
</nav> </nav>