cfmgrv4 init...1
This commit is contained in:
parent
2990b6812f
commit
95b8a0a4e6
@ -41,7 +41,7 @@ class AccountController extends CloudflareController
|
||||
$this->action = 'create';
|
||||
$this->fields = ['id', 'authkey'];
|
||||
$this->filter_fields = [];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->fields);
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
@ -50,6 +50,8 @@ class AccountController extends CloudflareController
|
||||
parent::create_process();
|
||||
$this->getMyLibrary()->create($this->formDatas);
|
||||
}
|
||||
//수정
|
||||
protected function modify_init(): void {}
|
||||
// 리스트
|
||||
public function list_init(): void
|
||||
{
|
||||
@ -57,7 +59,7 @@ class AccountController extends CloudflareController
|
||||
$this->fields = [$this->getModel()::TITLE, 'oldkey', 'type', 'status', 'updated_at', 'created_at'];
|
||||
$this->filter_fields = ['type', 'status'];
|
||||
$this->batchjob_fields = ['status'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->fields);
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ class RecordController extends CloudflareController
|
||||
$this->class_name = "Record";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
helper($this->class_name);
|
||||
helper($this->class_path);
|
||||
}
|
||||
final protected function getModel(): RecordModel
|
||||
{
|
||||
@ -73,7 +73,7 @@ class RecordController extends CloudflareController
|
||||
$this->action = 'create';
|
||||
$this->fields = [$this->getModel()::PARENT, 'type', 'content', 'proxied', 'hosts'];
|
||||
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->fields);
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
@ -82,7 +82,7 @@ class RecordController extends CloudflareController
|
||||
//hosts를 제외한 fields Valid처리
|
||||
$this->validateFormDatas(array_diff($this->fields, ['hosts']));
|
||||
}
|
||||
protected function create_process_submit(): void
|
||||
protected function create_process(): void
|
||||
{
|
||||
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
|
||||
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->_zone_entity->getParent());
|
||||
@ -94,14 +94,16 @@ class RecordController extends CloudflareController
|
||||
$this->getMyLibrary()->create($host, $this->formDatas);
|
||||
}
|
||||
}
|
||||
//수정
|
||||
protected function modify_init(): void {}
|
||||
// 리스트
|
||||
public function list_init(): void
|
||||
{
|
||||
$this->action = 'index';
|
||||
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'type', 'content', 'ttl', 'proxied', 'locked', 'updated_at', 'created_at'];
|
||||
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied', 'status'];
|
||||
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'proxied'];
|
||||
$this->batchjob_fields = ['proxied'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->fields);
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ class ZoneController extends CloudflareController
|
||||
$this->class_name = "Zone";
|
||||
$this->class_path .= $this->class_name;
|
||||
$this->title = lang("{$this->class_path}.title");
|
||||
helper($this->class_name);
|
||||
helper($this->class_path);
|
||||
}
|
||||
final protected function getModel(): ZoneModel
|
||||
{
|
||||
@ -79,7 +79,7 @@ class ZoneController extends CloudflareController
|
||||
$this->action = 'create';
|
||||
$this->fields = [$this->$this->getModel()::PARENT, 'domains', 'hosts', 'type', 'content', 'proxied'];
|
||||
$this->filter_fields = [$this->$this->getModel()::PARENT, 'type', 'proxied'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->fields);
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
@ -96,7 +96,7 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
foreach ($this->formDatas['domains'] as $domain) {
|
||||
//Zone생성
|
||||
$zone_entity = $this->getMyLibrary()->create($domain);
|
||||
$zone_entity = $this->getMyLibrary()->create($domain, $this->formDatas);
|
||||
//Record생성
|
||||
$record = new Record($this->_account_entity, $zone_entity);
|
||||
foreach ($this->formDatas['hosts'] as $host) {
|
||||
@ -108,6 +108,8 @@ class ZoneController extends CloudflareController
|
||||
}
|
||||
}
|
||||
}
|
||||
//수정
|
||||
protected function modify_init(): void {}
|
||||
// 리스트
|
||||
public function list_init(): void
|
||||
{
|
||||
@ -115,7 +117,7 @@ class ZoneController extends CloudflareController
|
||||
$this->fields = [$this->getModel()::PARENT, $this->getModel()::TITLE, 'name_servers', 'original_name_servers', 'plan', 'development_mode', 'ipv6', 'security_level', 'status', 'updated_at', 'created_at'];
|
||||
$this->filter_fields = [$this->getModel()::PARENT, 'development_mode', 'ipv6', 'security_level', 'status'];
|
||||
$this->batchjob_fields = ['development_mode', 'ipv6', 'security_level'];
|
||||
$this->field_rules = $this->getFormFieldRules();
|
||||
$this->field_rules = $this->getModel()->getFieldRules($this->fields);
|
||||
$this->field_options = $this->getFormFieldOptions();
|
||||
$this->getModel()->setAction($this->action);
|
||||
}
|
||||
|
||||
@ -16,18 +16,21 @@ abstract class MVController extends CommonController
|
||||
}
|
||||
abstract protected function getModel(): mixed;
|
||||
abstract protected function getMyLibrary(): mixed;
|
||||
abstract protected function create_init(): void;
|
||||
abstract protected function modify_init(): void;
|
||||
abstract protected function list_init(): void;
|
||||
//Field별 Form Option용
|
||||
protected function getFormFieldOption(string $field, array $options): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
// log_message("debug", __FUNCTION__ . "에서 호출:" . $field);
|
||||
$options[$field] = [
|
||||
"" => lang($this->class_path . '.label.' . $field) . ' 선택',
|
||||
...lang($this->class_path . '.' . strtoupper($field)),
|
||||
];
|
||||
break;
|
||||
}
|
||||
// dd($options);
|
||||
return $options;
|
||||
}
|
||||
final protected function getFormFieldOptions(array $options = []): array
|
||||
@ -40,18 +43,6 @@ abstract class MVController extends CommonController
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
final protected function getFormFieldRules(array $rules = []): array
|
||||
{
|
||||
foreach ($this->fields as $field) {
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
$rules = $this->getModel()->getFieldRule($field, $rules);
|
||||
}
|
||||
// var_dump($rules);
|
||||
// exit;
|
||||
return $rules;
|
||||
}
|
||||
//전송된 데이터
|
||||
protected function getFormData(string $field, array $formDatas): array
|
||||
{
|
||||
@ -98,13 +89,11 @@ abstract class MVController extends CommonController
|
||||
}
|
||||
}
|
||||
// 생성
|
||||
protected function create_form_process(): void
|
||||
{
|
||||
}
|
||||
protected function create_form_process(): void {}
|
||||
public function create_form(): RedirectResponse|string
|
||||
{
|
||||
helper(['form']);
|
||||
try {
|
||||
helper(['form']);
|
||||
$this->create_init();
|
||||
$this->create_form_process();
|
||||
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
@ -122,9 +111,7 @@ abstract class MVController extends CommonController
|
||||
{
|
||||
$this->validateFormDatas($this->fields);
|
||||
}
|
||||
protected function create_process(): void
|
||||
{
|
||||
}
|
||||
protected function create_process(): void {}
|
||||
public function create(): RedirectResponse
|
||||
{
|
||||
try {
|
||||
@ -150,13 +137,11 @@ abstract class MVController extends CommonController
|
||||
{
|
||||
$this->validateFormDatas($this->fields);
|
||||
}
|
||||
protected function modify_form_process(): void
|
||||
{
|
||||
}
|
||||
protected function modify_form_process(): void {}
|
||||
public function modify_form(): RedirectResponse|string
|
||||
{
|
||||
helper(['form']);
|
||||
try {
|
||||
helper(['form']);
|
||||
$this->modify_init();
|
||||
$this->formDatas = $this->getFormDatas();
|
||||
//기존 데이터 가져오기
|
||||
@ -176,9 +161,7 @@ abstract class MVController extends CommonController
|
||||
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with(SESSION_NAMES['RETURN_MSG'], $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function modify_process(): void
|
||||
{
|
||||
}
|
||||
protected function modify_process(): void {}
|
||||
public function modify(): mixed
|
||||
{
|
||||
try {
|
||||
@ -282,7 +265,7 @@ abstract class MVController extends CommonController
|
||||
// echo $this->getModel()->getLastQuery();
|
||||
return $entitys;
|
||||
}
|
||||
public function list(): string
|
||||
public function index(): string
|
||||
{
|
||||
try {
|
||||
helper(['form']);
|
||||
|
||||
138
app/Helpers/Admin/Cloudflare/Record_helper.php
Normal file
138
app/Helpers/Admin/Cloudflare/Record_helper.php
Normal file
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
function getFieldLabel_RecordHelper(string $field, array $viewDatas, array $attributes = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
$label = sprintf(
|
||||
"<span %s>%s</span>",
|
||||
implode(" ", $attributes),
|
||||
lang("{$viewDatas['class_path']}.label.{$field}")
|
||||
);
|
||||
break;
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas, array $attributes = []): string
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
$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]);
|
||||
// foreach ($viewDatas['field_options'][$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
break;
|
||||
case 'content':
|
||||
case 'head':
|
||||
case 'tail':
|
||||
$form = form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
break;
|
||||
case "type":
|
||||
case "status":
|
||||
$form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'id':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)sample@test.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'name':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
} //
|
||||
|
||||
function getFieldView_RecordHelper(string $field, mixed $entity, array $viewDatas, array $attributes = [])
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'category_uid':
|
||||
foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) {
|
||||
foreach ($category_2depths as $key => $depth) {
|
||||
if ($key == $depth) {
|
||||
$value = $depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'cost':
|
||||
case 'price':
|
||||
case 'sale':
|
||||
$value = number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'stock':
|
||||
case 'view_cnt':
|
||||
$value = number_format(!$value ? 0 : $value);
|
||||
break;
|
||||
case 'content':
|
||||
$value = html_entity_decode($value);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
$value = $value ? date("Y-m-d", strtotime($value)) : "";
|
||||
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("<th %s>%s</th>", implode(" ", $attributes), $header);
|
||||
}
|
||||
function getListColumns_RecordHelper(string $field, mixed $entity, array $viewDatas, array $attributes = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
$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(
|
||||
'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 = getFieldView_RecordHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
@ -1,67 +1,138 @@
|
||||
<?php
|
||||
function getFieldLabel_ZoneHelper($field, array $viewDatas, array $attributes = []): string
|
||||
function getFieldLabel_ZoneHelper(string $field, array $viewDatas, array $attributes = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
$label = sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
|
||||
$label = sprintf(
|
||||
"<span %s>%s</span>",
|
||||
implode(" ", $attributes),
|
||||
lang("{$viewDatas['class_path']}.label.{$field}")
|
||||
);
|
||||
break;
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_ZoneHelper($field, $value, array $viewDatas, array $attributes = [])
|
||||
function getFieldForm_ZoneHelper(string $field, mixed $value, array $viewDatas, array $attributes = []): string
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'category_uid':
|
||||
case 'user_uid':
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
|
||||
// // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
|
||||
// foreach ($viewDatas['fieldFormOptions'][$field] as $key => $label) {
|
||||
$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]);
|
||||
// foreach ($viewDatas['field_options'][$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
break;
|
||||
case 'title':
|
||||
case 'name':
|
||||
return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
|
||||
break;
|
||||
case 'content':
|
||||
case 'head':
|
||||
case 'tail':
|
||||
return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
$form = form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
break;
|
||||
case "type":
|
||||
case "status":
|
||||
case "category":
|
||||
$viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
|
||||
return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
|
||||
$form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $attributes);
|
||||
break;
|
||||
case 'id':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)sample@test.com", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'name':
|
||||
$form = form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{color:silver; opacity: 1;}"]);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return form_input($field, $value, ['class' => 'calender']);
|
||||
$form = form_input($field, $value, ['class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value);
|
||||
$form = form_input($field, $value, ["style" => "width:60%;"]);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
} //
|
||||
|
||||
protected function list_field_columns(): array
|
||||
function getFieldView_ZoneHelper(string $field, mixed $entity, array $viewDatas, array $attributes = [])
|
||||
{
|
||||
$columns = [];
|
||||
foreach ($this->fields as $field) {
|
||||
$label = lang("{$this->class_path}.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);
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'category_uid':
|
||||
foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) {
|
||||
foreach ($category_2depths as $key => $depth) {
|
||||
if ($key == $depth) {
|
||||
$value = $depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'cost':
|
||||
case 'price':
|
||||
case 'sale':
|
||||
$value = number_format(!$value ? 0 : $value) . "원";
|
||||
break;
|
||||
case 'stock':
|
||||
case 'view_cnt':
|
||||
$value = number_format(!$value ? 0 : $value);
|
||||
break;
|
||||
case 'content':
|
||||
$value = html_entity_decode($value);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
$value = $value ? date("Y-m-d", strtotime($value)) : "";
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['filter_fields']) && $value) {
|
||||
$value = $viewDatas['field_options'][$field][$value];
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $columns;
|
||||
return $value;
|
||||
} //
|
||||
|
||||
function getListHeaders_ZoneHelper(string $field, array $viewDatas, array $attributes = []): string
|
||||
{
|
||||
$label = getFieldLabel_ZoneHelper($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("<th %s>%s</th>", implode(" ", $attributes), $header);
|
||||
}
|
||||
function getListColumns_ZoneHelper(string $field, mixed $entity, array $viewDatas, array $attributes = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
$value = anchor(
|
||||
current_url() . '/view/' . $entity->getPK(),
|
||||
getFieldView_ZoneHelper($field, $entity, $viewDatas),
|
||||
["target" => "_self"]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['filter_fields'])) {
|
||||
$attributes["onChange"] = sprintf(
|
||||
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
|
||||
current_url(),
|
||||
$entity->getPK(),
|
||||
$field,
|
||||
$field
|
||||
);
|
||||
$value = getFieldForm_ZoneHelper($field, $entity, $viewDatas, $attributes);
|
||||
}
|
||||
$value = getFieldView_ZoneHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
@ -68,9 +68,8 @@ class Account extends MyCloudflare
|
||||
// log_message("notice", "Account::" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
||||
// return $entity;
|
||||
// }
|
||||
public function create($formDatas): array
|
||||
public function create(array $formDatas): array
|
||||
{
|
||||
$this->_authkey = $formDatas['authkey'];
|
||||
//Account의 경우 인증키를 가지고있고 생성할수 없으므로 get으로 읽은후 첫번째것을 사용하기로 함
|
||||
$entitys = [];
|
||||
foreach ($this->reload_cfs($this->getRequest(), 'accounts') as $cf) {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
namespace App\Libraries\MyCloudflare;
|
||||
|
||||
use Cloudflare\API\Adapter\Guzzle;
|
||||
use App\Models\Cloudflare\API\RecordModel;
|
||||
use App\Models\Cloudflare\RecordModel;
|
||||
use App\Libraries\MyCloudflare\MyCloudflare;
|
||||
use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Entities\Cloudflare\RecordEntity;
|
||||
|
||||
@ -91,14 +91,14 @@ class Zone extends MyCloudflare
|
||||
$entity->$field = $cf->result->value;
|
||||
return $entity;
|
||||
}
|
||||
public function create(string $domain, $jump_start = false): ZoneEntity
|
||||
public function create(string $domain, array $formDatas): ZoneEntity
|
||||
{
|
||||
//Socket용
|
||||
//도메인생성을 위해 Cloudflare에 전송
|
||||
$cf = $this->getRequest()->post('zones/', [
|
||||
'accountId' => $this->_account_entity->getPK(),
|
||||
'name' => $domain,
|
||||
'jump_start' => $jump_start,
|
||||
'jump_start' => array_key_exists('jump_start', $formDatas) ? $formDatas['jumb_start'] : false,
|
||||
]);
|
||||
$cf = json_decode($cf->getBody());
|
||||
if (!$cf->success) {
|
||||
|
||||
@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Models\Cloudflare;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Entities\Cloudflare\ZoneEntity;
|
||||
use App\Entities\Cloudflare\RecordEntity;
|
||||
use App\Models\CommonModel;
|
||||
|
||||
class RecordModel extends Model
|
||||
class RecordModel extends CommonModel
|
||||
{
|
||||
const TABLE = "cloudflarerecord";
|
||||
const PK = "uid";
|
||||
|
||||
@ -63,10 +63,10 @@ abstract class CommonModel extends Model
|
||||
{
|
||||
return $this->_action = $action;
|
||||
}
|
||||
final public function getFields(array $except_fields = []): array
|
||||
{
|
||||
return array_diff($this->allowedFields, $except_fields); //제외한 fields
|
||||
}
|
||||
// final public function getFields(array $except_fields = []): array
|
||||
// {
|
||||
// return array_diff($this->allowedFields, $except_fields); //제외한 fields
|
||||
// }
|
||||
public function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
if (is_array($field)) {
|
||||
@ -80,8 +80,7 @@ abstract class CommonModel extends Model
|
||||
$rules[$field] .= $this->getAction() == "create" ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
} else {
|
||||
$rules[$field] = "required|numeric";
|
||||
}
|
||||
;
|
||||
};
|
||||
break;
|
||||
case $this->getTitleField():
|
||||
$rules[$field] = "required|string";
|
||||
|
||||
@ -73,9 +73,9 @@
|
||||
<div id="index_create_form"></div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadContentForm(
|
||||
"<?= base_url('admin/cloudflare/account/create') ?>",
|
||||
"<?= base_url(strtolower($viewDatas["class_path"]) . "/create") ?>",
|
||||
document.getElementById('index_create_form')
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<div id="content">
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-striped">
|
||||
<tbody>
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_UserHelper($field, $viewDatas) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_UserHelper($field, $viewDatas['entity']->$field ?: DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td valign="bottom" colspan="2"><?= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<?= form_close(); ?>
|
||||
</table>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,19 +0,0 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/admin/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<div id="content">
|
||||
<table class="form table table-bordered table-striped">
|
||||
<tbody>
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_UserHelper($field, $viewDatas) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldView_UserHelper($field, $viewDatas['entity'], $viewDatas) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
19
app/Views/admin/cloudflare/record/create.php
Normal file
19
app/Views/admin/cloudflare/record/create.php
Normal file
@ -0,0 +1,19 @@
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_RecordHelper($field, $viewDatas) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_RecordHelper($field, old($field), $viewDatas) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td valign="bottom" colspan="2">
|
||||
<?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?= form_close(); ?>
|
||||
</table>
|
||||
83
app/Views/admin/cloudflare/record/index.php
Normal file
83
app/Views/admin/cloudflare/record/index.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?= $this->extend("layouts/{$viewDatas['layout']}") ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= form_open(current_url(), array("method" => "get")) ?>
|
||||
<nav class="index_top navbar navbar-expand-lg">
|
||||
<div class="container-fluid">
|
||||
<nav class="condition nav">
|
||||
조건검색:
|
||||
<?php foreach ($viewDatas['filter_fields'] as $field): ?>
|
||||
<?= getFieldForm_RecordHelper($field, $viewDatas[$field], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
</nav>
|
||||
<nav class="search nav justify-content-center">
|
||||
검색어:<?= form_input('word', $viewDatas['word']) ?>
|
||||
검색일:<?= form_input('start', $viewDatas['start'], ["class" => "calender"]) ?><?= form_input('end', $viewDatas['end'], ["class" => "calender"]) ?>
|
||||
<?= form_submit('', '검색하기') ?>
|
||||
<?= anchor(current_url() . '/excel?' . $viewDatas['uri']->getQuery(), ICONS['EXCEL'], ["target" => "_self", "class" => "excel"]) ?>
|
||||
</nav>
|
||||
<nav class="pageinfo nav justify-content-end">
|
||||
페이지정보 : <?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?>
|
||||
<?= form_dropdown('per_page', $viewDatas['page_options'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?>
|
||||
/ 총:<?= $viewDatas['total_count'] ?>
|
||||
</nav>
|
||||
</div>
|
||||
</nav>
|
||||
<?= form_close() ?>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<?= getListHeaders_RecordHelper($field, $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<th>작업</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $cnt = 0 ?>
|
||||
<?php foreach ($viewDatas['entitys'] as $entity): ?>
|
||||
<tr id="<?= $entity->getPK() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
|
||||
<td class="text-center text-wrap">
|
||||
<?= form_checkbox(["id" => "checkbox_uid_{$entity->getPK()}", "name" => "batchjob_uids[]", "value" => $entity->getPK(), "class" => "batchjobuids_checkboxs"]); ?>
|
||||
<?= anchor(current_url() . '/modify/' . $entity->getPK(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
|
||||
</td>
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<td><?= getListColumns_RecordHelper($field, $entity, $viewDatas) ?></td>
|
||||
<?php endforeach ?>
|
||||
<td>
|
||||
<?= anchor(current_url() . '/delete/' . $entity->getPK(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $cnt++ ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_RecordHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item">
|
||||
<?= anchor(current_url() . '/create', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= form_close() ?>
|
||||
<div class="index_form">
|
||||
<div id="index_create_form"></div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadContentForm(
|
||||
"<?= base_url(strtolower($viewDatas["class_path"]) . "/create") ?>",
|
||||
document.getElementById('index_create_form')
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
19
app/Views/admin/cloudflare/zone/create.php
Normal file
19
app/Views/admin/cloudflare/zone/create.php
Normal file
@ -0,0 +1,19 @@
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_ZoneHelper($field, $viewDatas) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_ZoneHelper($field, old($field), $viewDatas) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td valign="bottom" colspan="2">
|
||||
<?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?= form_close(); ?>
|
||||
</table>
|
||||
83
app/Views/admin/cloudflare/zone/index.php
Normal file
83
app/Views/admin/cloudflare/zone/index.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?= $this->extend("layouts/{$viewDatas['layout']}") ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/<?= $viewDatas['layout'] ?>/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/content.js"></script>
|
||||
<?= form_open(current_url(), array("method" => "get")) ?>
|
||||
<nav class="index_top navbar navbar-expand-lg">
|
||||
<div class="container-fluid">
|
||||
<nav class="condition nav">
|
||||
조건검색:
|
||||
<?php foreach ($viewDatas['filter_fields'] as $field): ?>
|
||||
<?= getFieldForm_ZoneHelper($field, $viewDatas[$field], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
</nav>
|
||||
<nav class="search nav justify-content-center">
|
||||
검색어:<?= form_input('word', $viewDatas['word']) ?>
|
||||
검색일:<?= form_input('start', $viewDatas['start'], ["class" => "calender"]) ?><?= form_input('end', $viewDatas['end'], ["class" => "calender"]) ?>
|
||||
<?= form_submit('', '검색하기') ?>
|
||||
<?= anchor(current_url() . '/excel?' . $viewDatas['uri']->getQuery(), ICONS['EXCEL'], ["target" => "_self", "class" => "excel"]) ?>
|
||||
</nav>
|
||||
<nav class="pageinfo nav justify-content-end">
|
||||
페이지정보 : <?= $viewDatas['page'] ?>/<?= $viewDatas['total_page'] ?>
|
||||
<?= form_dropdown('per_page', $viewDatas['page_options'], $viewDatas['per_page'], array('onChange' => 'this.form.submit()')) ?>
|
||||
/ 총:<?= $viewDatas['total_count'] ?>
|
||||
</nav>
|
||||
</div>
|
||||
</nav>
|
||||
<?= form_close() ?>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="index_table table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<?= getListHeaders_ZoneHelper($field, $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<th>작업</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $cnt = 0 ?>
|
||||
<?php foreach ($viewDatas['entitys'] as $entity): ?>
|
||||
<tr id="<?= $entity->getPK() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
|
||||
<td class="text-center text-wrap">
|
||||
<?= form_checkbox(["id" => "checkbox_uid_{$entity->getPK()}", "name" => "batchjob_uids[]", "value" => $entity->getPK(), "class" => "batchjobuids_checkboxs"]); ?>
|
||||
<?= anchor(current_url() . '/modify/' . $entity->getPK(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
|
||||
</td>
|
||||
<?php foreach ($viewDatas['fields'] as $field): ?>
|
||||
<td><?= getListColumns_ZoneHelper($field, $entity, $viewDatas) ?></td>
|
||||
<?php endforeach ?>
|
||||
<td>
|
||||
<?= anchor(current_url() . '/delete/' . $entity->getPK(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $cnt++ ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="index_bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
|
||||
<?= getFieldForm_ZoneHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?>
|
||||
<?php endforeach ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")) ?></li>
|
||||
<li class="nav-item">
|
||||
<?= anchor(current_url() . '/create', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||
<?= form_close() ?>
|
||||
<div class="index_form">
|
||||
<div id="index_create_form"></div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadContentForm(
|
||||
"<?= base_url(strtolower($viewDatas["class_path"]) . "/create") ?>",
|
||||
document.getElementById('index_create_form')
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
@ -100,6 +100,7 @@ div.index_pagination nav ul.pagination li a:hover {
|
||||
border: 1px solid black;
|
||||
}
|
||||
div.index_form {
|
||||
margin-top:30px;
|
||||
text-align: center;
|
||||
/* border: 1px solid red; */
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user