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",
'STATUS' => "use",
'EMPTY' => "",
'PERPAGE' => 20,
'DELIMITER_FILE' => "||",
'DELIMITER_ROLE' => ",",
]);

View File

@ -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);

View File

@ -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(

View File

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

View File

@ -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}/]";

View File

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

View File

@ -7,6 +7,6 @@
<nav class="nav justify-content-end">
<span class="pageinfo">
페이지정보 : <?= $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>
</nav>