cfmgrv4 init...2

This commit is contained in:
최준흠 2024-10-14 23:13:19 +09:00
parent f896a478bd
commit c70ab29ef7
8 changed files with 140 additions and 56 deletions

View File

@ -107,17 +107,29 @@ class RecordController extends CloudflareController
$cnt++;
}
//Socket처리
$entitys = [];
foreach ($this->formDatas['hosts'] as $host) {
$this->entity = $this->getMyLibrary()->create(
$entity = $this->getMyLibrary()->create(
$host,
$this->formDatas['type'],
$this->formDatas['content'],
$this->formDatas['proxied']
);
log_message("debug", message: "Record:{$this->entity->getTitle()} 생성 작업을 완료하였습니다.");
log_message("debug", message: "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
$entitys[] = $entity;
}
$this->entitys = $entitys;
}
public function create(mixed $zone_uid = false): RedirectResponse|string
protected function create_result(): string
{
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'host'];
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
return view(
$this->view_path . strtolower($this->class_path) . "/view",
data: ['viewDatas' => $this->getViewDatas()]
);
}
public function create(): RedirectResponse|string
{
$this->init(__FUNCTION__);
return $this->create_procedure();
@ -146,6 +158,13 @@ class RecordController extends CloudflareController
$this->entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
}
}
protected function modify_result(): string
{
return view(
$this->view_path . strtolower($this->class_path) . "/view",
data: ['viewDatas' => $this->getViewDatas()]
);
}
//일괄처리작업
public function batcjob(): RedirectResponse
{

View File

@ -138,17 +138,18 @@ class ZoneController extends CloudflareController
//Socket처리
//Zone생성
$cnt = 1;
$this->zone_entitys = [];
$zone_entitys = [];
foreach ($this->formDatas['domains'] as $domain) {
$entity = $this->getMyLibrary()->create($domain);
log_message("debug", "Zone:{$entity->getTitle()} 작업을 완료하였습니다.");
$this->zone_entitys[] = $entity;
$zone_entitys[] = $entity;
$cnt++;
}
//Record생성
$this->record_entitys = [];
foreach ($this->zone_entitys as $zone_entity) {
$this->entitys = [];
foreach ($zone_entitys as $zone_entity) {
$record = new Record($zone_entity);
$record_entitys = [];
foreach ($this->formDatas['hosts'] as $host) {
$entity = $record->create(
$host,
@ -157,10 +158,19 @@ class ZoneController extends CloudflareController
$this->formDatas['proxied']
);
log_message("debug", "Record:{$entity->getTitle()} 작업을 완료하였습니다.");
$this->record_entitys[] = $entity;
$record_entitys[] = $entity;
}
$zone_entity->records = $record_entitys;
$this->entitys[] = $zone_entity;
}
}
protected function create_result(): string
{
return view(
$this->view_path . strtolower($this->class_path) . DIRECTORY_SEPARATOR . "view",
data: ['viewDatas' => $this->getViewDatas()]
);
}
public function create(): RedirectResponse|string
{
$this->init(__FUNCTION__);
@ -182,6 +192,13 @@ class ZoneController extends CloudflareController
//Socket처리
$this->entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
}
protected function modify_result(): string
{
return view(
$this->view_path . strtolower($this->class_path) . DIRECTORY_SEPARATOR . "view",
data: ['viewDatas' => $this->getViewDatas()]
);
}
//일괄처리작업
public function batcjob(): RedirectResponse
{

View File

@ -77,18 +77,9 @@ abstract class MVController extends CommonController
return $formDatas;
}
// 생성
protected function create_validate(string $action, array $fields): void
protected function create_form_process(): void
{
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요
$this->validation = $this->setFormFieldRules($fields, service('validation'), $action);
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
"\n",
$this->validation->getErrors()
));
}
}
protected function create_form_process(): void {}
final protected function create_form_procedure(): RedirectResponse|string
{
try {
@ -104,6 +95,17 @@ abstract class MVController extends CommonController
return redirect()->back()->with('error', $e->getMessage());
}
}
protected function create_validate(string $action, array $fields): void
{
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요
$this->validation = $this->setFormFieldRules($fields, service('validation'), $action);
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
"\n",
$this->validation->getErrors()
));
}
}
protected function create_process(): void
{
$this->create_validate($this->action, $this->fields);
@ -135,17 +137,6 @@ abstract class MVController extends CommonController
}
}
// 수정
protected function modify_validate(string $action, array $fields): void
{
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
$this->validation = $this->setFormFieldRules($fields, service('validation'), $action);
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
"\n",
$this->validation->getErrors()
));
}
}
protected function modify_form_process(string $uid): void
{
$this->entity = $this->getModel()->getEntityByPK(intval($uid));
@ -168,6 +159,17 @@ abstract class MVController extends CommonController
return redirect()->back()->with('error', $e->getMessage());
}
}
protected function modify_validate(string $action, array $fields): void
{
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getVar()보다 먼처 체크필요
$this->validation = $this->setFormFieldRules($fields, service('validation'), $action);
if (!$this->validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->class_name} 작업 데이터 검증 오류발생\n" . implode(
"\n",
$this->validation->getErrors()
));
}
}
protected function modify_process(string $uid): void
{
$this->modify_validate($this->action, $this->fields);

View File

@ -74,7 +74,7 @@ class RecordHelper extends CommonHelper
case RecordModel::TITLE:
$url = sprintf("%s/toggle/%s/fixed?fixed=%s", current_url(), $viewDatas['entity']->getPK(), $viewDatas['entity']->fixed == 'on' ? "off" : "on");
$fixed = $viewDatas['entity']->fixed == 'on' ? "<span class=\"text-danger\">" . ICONS['LOCK'] . "</span>" : "";
$value = sprintf("%s<span class=\"label_hosts\">%s</span>", $fixed, $value);
$value = sprintf("%s<span class=\"label_hosts\">%s</span>", $fixed, $value);
$value = anchor($url, $value, ["target" => "_self"]);
break;
case 'content':

View File

@ -0,0 +1,32 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form">
<table class="table table-bordered">
<tr>
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th nowrap class="text-center"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<?php endforeach ?>
</tr>
<?php $cnt = 1 ?>
<?php foreach ($viewDatas['entitys'] as $entity): ?>
<?php $viewDatas['entity'] = $entity ?>
<tr>
<td><?= $cnt ?></td>
<?php foreach ($viewDatas['fields'] as $field): ?>
<td nowrap class="text-center"><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
<tr>
<td colspan="<?= count($viewDatas['fields']) + 1 ?>" class="text-center">
<div><?= $viewDatas['message'] ?></div>
</td>
</tr>
</table>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,39 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form">
<table class="table table-bordered">
<?php foreach ($viewDatas['entitys'] as $entity): ?>
<?php $viewDatas['entity'] = $entity ?>
<?php $cnt = 1 ?>
<tr>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th>번호</th>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<?php endforeach ?>
</tr>
<tr>
<?php foreach ($viewDatas['fields'] as $field): ?>
<th><?= $cnt ?></th>
<td nowrap class="text-start"><?= $viewDatas['helper']->getFieldView($field, $viewDatas, $viewDatas) ?></td>
<?php endforeach ?>
</tr>
<tr>
<td colspan="<?= count($viewDatas['fields']) + 1 ?>">
<?php foreach ($entity->records as $record): ?>
<?= $record->getTitle() ?>
<?php endforeach ?>
</td>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
<tr>
<td colspan="<?= $cnt * 2 ?>" class="text-center">
<div><?= $viewDatas['message'] ?></div>
</td>
</tr>
</table>
</div>
</div>
<?= $this->endSection() ?>

View File

@ -16,7 +16,7 @@
$extras = ["required" => "", ...$extras];
}
?>
<?= $viewDatas['helper']->getFieldForm($field, old($field), $viewDatas, $extras) ?>
<?= $viewDatas['helper']->getFieldForm($field, old($field), $viewDatas, $extras) ?>
<div><?= validation_show_error($field); ?></div>
</td>
<?php $cnt++ ?>

View File

@ -1,25 +0,0 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<div class="action_form">
<table class="table table-bordered">
<?php $cnt = 1 ?>
<?php foreach ($viewDatas['fields'] as $field): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldView($field, $viewDatas, $viewDatas) ?>
</td>
<?php $cnt++ ?>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="<?= $cnt * 2 ?>" class="text-center">
<div><?= $viewDatas['message'] ?></div>
</td>
</tr>
</table>
</div>
</div>
<?= $this->endSection() ?>