cfmgrv4 init...1

This commit is contained in:
최준흠 2024-10-06 13:18:14 +09:00
parent 36806b0c12
commit 2bbea6a4b0
22 changed files with 128 additions and 323 deletions

View File

@ -4,3 +4,7 @@
<IfModule !authz_core_module> <IfModule !authz_core_module>
Deny from all Deny from all
</IfModule> </IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

View File

@ -22,15 +22,15 @@ $routes->group('cli', ['namespace' => 'App\CLI'], function ($routes) {
$routes->cli('reload', 'Cloudflare::reload'); $routes->cli('reload', 'Cloudflare::reload');
}); });
}); });
$routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($routes) { $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) {
$routes->get('/', 'Home::index'); $routes->get('/', 'Home::index');
$routes->group('user', function ($routes) { $routes->group('user', function ($routes) {
$routes->get('/', 'UserController::index'); $routes->get('/', 'UserController::index');
$routes->get('create', 'UserController::create_form'); $routes->get('create', 'UserController::create_form', ['filter' => 'authFilter:master']);
$routes->post('create', 'UserController::create'); $routes->post('create', 'UserController::create', ['filter' => 'authFilter:master']);
$routes->get('modify/(:num)', 'UserController::modify_form/$1'); $routes->get('modify/(:num)', 'UserController::modify_form/$1');
$routes->post('modify/(:num)', 'UserController::modify/$1'); $routes->post('modify/(:num)', 'UserController::modify/$1');
$routes->get('delete/(:num)', 'UserController::delete/$1'); $routes->get('delete/(:num)', 'UserController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:num)/(:any)', 'UserController::toggle/$1/$2'); $routes->get('toggle/(:num)/(:any)', 'UserController::toggle/$1/$2');
$routes->post('batchjob', 'UserController::batcjob'); $routes->post('batchjob', 'UserController::batcjob');
$routes->get('download/(:alpha)', 'UserController::download/$1'); $routes->get('download/(:alpha)', 'UserController::download/$1');
@ -52,7 +52,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($rou
$routes->get('create', 'AuthController::create_form'); $routes->get('create', 'AuthController::create_form');
$routes->post('create', 'AuthController::create'); $routes->post('create', 'AuthController::create');
$routes->get('modify/(:num)', 'AuthController::modify_form/$1'); $routes->get('modify/(:num)', 'AuthController::modify_form/$1');
$routes->get('delete/(:num)', 'AuthController::delete/$1'); $routes->get('delete/(:num)', 'AuthController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:num)/(:any)', 'AuthController::toggle/$1/$2'); $routes->get('toggle/(:num)/(:any)', 'AuthController::toggle/$1/$2');
$routes->post('batchjob', 'AuthController::batcjob'); $routes->post('batchjob', 'AuthController::batcjob');
$routes->get('download/(:alpha)', 'AccountController::download/$1'); $routes->get('download/(:alpha)', 'AccountController::download/$1');

View File

@ -14,6 +14,6 @@ abstract class AdminController extends MVController
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
$this->layout = "admin"; $this->layout = "admin";
$this->view_root .= "admin/"; $this->view_root .= "admin/";
$this->action_form = FORMS['MODAL']; $this->action_form = FORMS['IFRAME'];
} }
} }

View File

@ -61,7 +61,7 @@ class AccountController extends CloudflareController
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'status']; $this->filter_fields = [$this->getModel()::PARENT, 'type', 'status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields); $this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->batchjob_fields = ['typep', 'status']; $this->batchjob_fields = ['type', 'status'];
return $this->list_procedure(); return $this->list_procedure();
} }
// Download // Download
@ -72,7 +72,7 @@ class AccountController extends CloudflareController
$this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields); $this->field_rules = $this->getModel()->getFieldRules($this->action, $this->fields);
$this->filter_fields = [$this->getModel()::PARENT, 'type', 'status']; $this->filter_fields = [$this->getModel()::PARENT, 'type', 'status'];
$this->field_options = $this->getFormFieldOptions($this->filter_fields); $this->field_options = $this->getFormFieldOptions($this->filter_fields);
$this->batchjob_fields = ['typep', 'status']; $this->batchjob_fields = ['type', 'status'];
return $this->download_procedure($output_type, $uid); return $this->download_procedure($output_type, $uid);
} }
//reload Account By Auth //reload Account By Auth

View File

@ -45,7 +45,7 @@ class AuthController extends CloudflareController
public function create(): RedirectResponse|string public function create(): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->create_procedure($this->action_form); return $this->create_procedure();
} }
//수정 //수정
public function modify_form(string $uid): RedirectResponse|string public function modify_form(string $uid): RedirectResponse|string
@ -56,7 +56,7 @@ class AuthController extends CloudflareController
public function modify(string $uid): RedirectResponse|string public function modify(string $uid): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->modify_procedure($uid, $this->action_form); return $this->modify_procedure($uid);
} }
//일괄처리작업 //일괄처리작업
public function batcjob(): RedirectResponse public function batcjob(): RedirectResponse

View File

@ -59,10 +59,9 @@ abstract class CloudflareController extends AdminController
$this->getModel()->transStart(); $this->getModel()->transStart();
try { try {
$this->sync_process($uid); $this->sync_process($uid);
$message = "Sync 작업을 완료하였습니다.";
log_message("notice", $message);
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $message);
$this->getModel()->transCommit(); $this->getModel()->transCommit();
log_message("notice", $this->message);
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message);
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
@ -80,10 +79,9 @@ abstract class CloudflareController extends AdminController
$this->getModel()->transStart(); $this->getModel()->transStart();
try { try {
$this->reload_process($uid); $this->reload_process($uid);
$message = "Reload 작업을 완료하였습니다.";
log_message("notice", $message);
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $message);
$this->getModel()->transCommit(); $this->getModel()->transCommit();
log_message("notice", $this->message);
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message);
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback

View File

@ -110,11 +110,12 @@ class RecordController extends CloudflareController
$entity = $this->getMyLibrary()->create($host, $this->formDatas['type'], $this->formDatas['content'], $this->formDatas['proxied']); $entity = $this->getMyLibrary()->create($host, $this->formDatas['type'], $this->formDatas['content'], $this->formDatas['proxied']);
log_message("debug", "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다."); log_message("debug", "Record:{$entity->getTitle()} 생성 작업을 완료하였습니다.");
} }
$this->message = "Record {$this->action} 작업을 완료하였습니다.";
} }
public function create(mixed $zone_uid = false): RedirectResponse|string public function create(mixed $zone_uid = false): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->create_procedure($this->action_form); return $this->create_procedure();
} }
//수정 (modify,toggle,batchjob사용) //수정 (modify,toggle,batchjob사용)
protected function modify_process(string $uid): void protected function modify_process(string $uid): void
@ -136,15 +137,7 @@ class RecordController extends CloudflareController
//Socket처리 //Socket처리
$entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas); $entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
} }
log_message("debug", "Record:{$entity->getTitle()} 수정 작업을 완료하였습니다."); $this->message = "Record:{$entity->getTitle()} {$this->action} 작업을 완료하였습니다.";
}
//단일필드작업
public function toggle(string $uid, string $field): RedirectResponse
{
$this->action = __FUNCTION__;
$this->fields = [$field];
$this->modify_process($uid);
return $this->modify_procedure($uid);
} }
//일괄처리작업 //일괄처리작업
public function batcjob(): RedirectResponse public function batcjob(): RedirectResponse
@ -166,6 +159,7 @@ class RecordController extends CloudflareController
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent()); $this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->entity->getParent());
//Socket처리 //Socket처리
$this->getMyLibrary()->sync($this->entity); $this->getMyLibrary()->sync($this->entity);
$this->message = "Record:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다.";
} }
public function sync(string $uid): RedirectResponse public function sync(string $uid): RedirectResponse
{ {
@ -184,6 +178,7 @@ class RecordController extends CloudflareController
$this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]); $this->_zone_entity = $this->getZoneModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
//Cloudflare 삭제 //Cloudflare 삭제
$this->getMyLibrary()->delete($this->entity); $this->getMyLibrary()->delete($this->entity);
$this->message = "Record:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다.";
} }
// 리스트 // 리스트
public function index(): string public function index(): string

View File

@ -153,11 +153,12 @@ class ZoneController extends CloudflareController
log_message("debug", "Record:{$entity->getTitle()} 작업을 완료하였습니다."); log_message("debug", "Record:{$entity->getTitle()} 작업을 완료하였습니다.");
} }
} }
$this->message = "Zone {$this->action} 작업을 완료하였습니다.";
} }
public function create(): RedirectResponse|string public function create(): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->create_procedure($this->action_form); return $this->create_procedure();
} }
//수정 (modify,toggle,batchjob사용) //수정 (modify,toggle,batchjob사용)
protected function modify_process(string $uid): void protected function modify_process(string $uid): void
@ -174,7 +175,7 @@ class ZoneController extends CloudflareController
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent()); $this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
//Socket처리 //Socket처리
$entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas); $entity = $this->getMyLibrary()->modify($this->entity, $this->formDatas);
log_message("debug", "Zone:{$entity->getTitle()} 수정 작업을 완료하였습니다."); $this->message = "Zone:{$entity->getTitle()} {$this->action} 작업을 완료하였습니다.";
} }
//일괄처리작업 //일괄처리작업
public function batcjob(): RedirectResponse public function batcjob(): RedirectResponse
@ -196,6 +197,7 @@ class ZoneController extends CloudflareController
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent()); $this->_account_entity = $this->getAccountModel()->getEntityByPK($this->entity->getParent());
//Socket처리 //Socket처리
$this->getMyLibrary()->sync($this->entity); $this->getMyLibrary()->sync($this->entity);
$this->message = "Zone:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다.";
} }
public function sync(string $uid): RedirectResponse public function sync(string $uid): RedirectResponse
{ {
@ -214,6 +216,7 @@ class ZoneController extends CloudflareController
$this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]); $this->_account_entity = $this->getAccountModel()->getEntityByPK($this->formDatas[$this->getModel()::PARENT]);
//Cloudflare 삭제 //Cloudflare 삭제
$this->getMyLibrary()->delete($this->entity); $this->getMyLibrary()->delete($this->entity);
$this->message = "Zone:{$this->entity->getTitle()} {$this->action} 작업을 완료하였습니다.";
} }
// 리스트 // 리스트
public function index(): string public function index(): string

View File

@ -86,7 +86,7 @@ class MapurlController extends AdminController
public function create(): RedirectResponse|string public function create(): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->create_procedure($this->action_form); return $this->create_procedure();
} }
//수정 //수정
public function modify_form(string $uid): RedirectResponse|string public function modify_form(string $uid): RedirectResponse|string
@ -103,7 +103,7 @@ class MapurlController extends AdminController
public function modify(string $uid): RedirectResponse|string public function modify(string $uid): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->modify_procedure($uid, $this->action_form); return $this->modify_procedure($uid);
} }
//일괄처리작업 //일괄처리작업
public function batcjob(): RedirectResponse public function batcjob(): RedirectResponse

View File

@ -85,7 +85,7 @@ class UserController extends AdminController
public function create(): RedirectResponse|string public function create(): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->create_procedure($this->action_form); return $this->create_procedure();
} }
//수정 //수정
public function modify_form(string $uid): RedirectResponse|string public function modify_form(string $uid): RedirectResponse|string
@ -96,7 +96,7 @@ class UserController extends AdminController
public function modify(string $uid): RedirectResponse|string public function modify(string $uid): RedirectResponse|string
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
return $this->modify_procedure($uid, $this->action_form); return $this->modify_procedure($uid);
} }
//일괄작업 //일괄작업
public function batcjob(): RedirectResponse public function batcjob(): RedirectResponse

View File

@ -111,9 +111,9 @@ abstract class MVController extends CommonController
$this->create_validate($this->action, $this->fields); $this->create_validate($this->action, $this->fields);
$this->formDatas = $this->getFormDatas(); $this->formDatas = $this->getFormDatas();
$this->entity = $this->getModel()->create(formDatas: $this->formDatas); $this->entity = $this->getModel()->create(formDatas: $this->formDatas);
$this->message = "입력작업이 완료되었습니다."; $this->message = "{$this->action} 작업이 완료되었습니다.";
} }
final protected function create_procedure(string $action_form = "default"): RedirectResponse|string final protected function create_procedure(): RedirectResponse|string
{ {
//Transaction Start //Transaction Start
$this->getModel()->transStart(); $this->getModel()->transStart();
@ -121,12 +121,12 @@ abstract class MVController extends CommonController
$this->create_process(); $this->create_process();
$this->getModel()->transCommit(); $this->getModel()->transCommit();
log_message("notice", __FUNCTION__ . $this->message); log_message("notice", __FUNCTION__ . $this->message);
switch ($action_form) { switch ($this->action_form) {
case FORMS['MODAL']: case FORMS['MODAL']:
$result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]);
break; break;
case FORMS['IFRAME']: case FORMS['IFRAME']:
$result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]);
break; break;
default: default:
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message);
@ -188,9 +188,9 @@ abstract class MVController extends CommonController
throw new \Exception(__FUNCTION__, " => {$uid} 정보를 찾을수 없습니다."); throw new \Exception(__FUNCTION__, " => {$uid} 정보를 찾을수 없습니다.");
} }
$this->entity = $this->getModel()->modify($this->entity, $this->formDatas); $this->entity = $this->getModel()->modify($this->entity, $this->formDatas);
$this->message = "수정작업이 완료되었습니다."; $this->message = "{$this->action} 작업이 완료되었습니다.";
} }
final protected function modify_procedure(string $uid, string $action_form = "default"): RedirectResponse|string final protected function modify_procedure(string $uid): RedirectResponse|string
{ {
//Transaction Start //Transaction Start
$this->getModel()->transStart(); $this->getModel()->transStart();
@ -198,12 +198,12 @@ abstract class MVController extends CommonController
$this->modify_process($uid); $this->modify_process($uid);
$this->getModel()->transCommit(); $this->getModel()->transCommit();
log_message("notice", __FUNCTION__ . $this->message); log_message("notice", __FUNCTION__ . $this->message);
switch ($action_form) { switch ($this->action_form) {
case FORMS['MODAL']: case FORMS['MODAL']:
$result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]);
break; break;
case FORMS['IFRAMEE']: case FORMS['IFRAME']:
$result = view("templates/{$this->layout}/{$action_form}_close", data: ['viewDatas' => $this->getViewDatas()]); $result = view("templates/{$this->layout}/{$this->action_form}_close", data: ['viewDatas' => $this->getViewDatas()]);
break; break;
default: default:
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message);
@ -220,13 +220,6 @@ abstract class MVController extends CommonController
return redirect()->back()->withInput(); return redirect()->back()->withInput();
} }
} }
//단일필드작업
public function toggle(string $uid, string $field): RedirectResponse
{
$this->action = __FUNCTION__;
$this->fields = [$field];
return $this->modify_procedure($uid);
}
//일괄처리작업 //일괄처리작업
final protected function batcjob_procedure(): RedirectResponse final protected function batcjob_procedure(): RedirectResponse
{ {
@ -242,9 +235,30 @@ abstract class MVController extends CommonController
$this->modify_process($uid); $this->modify_process($uid);
} }
$this->getModel()->transCommit(); $this->getModel()->transCommit();
$message = "일괄처리 작업을 완료하였습니다."; log_message("notice", $this->message);
log_message("notice", $message); $this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message);
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $message); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) {
//Transaction Rollback
$this->getModel()->transRollback();
log_message("error", $e->getMessage());
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage());
$this->session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return redirect()->back()->withInput();
}
}
//단일필드작업
final public function toggle(string $uid, string $field): RedirectResponse
{
$this->action = __FUNCTION__;
$this->fields = [$field];
//Transaction Start
$this->getModel()->transStart();
try {
$this->modify_process($uid);
$this->getModel()->transCommit();
log_message("notice", $this->message);
$this->session->setFlashdata(SESSION_NAMES['RETURN_MSG'], $this->message);
return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); return redirect()->to($this->session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
@ -376,7 +390,7 @@ abstract class MVController extends CommonController
//모델 처리 //모델 처리
$this->entitys = $this->list_entitys_process(); $this->entitys = $this->list_entitys_process();
//setting return_url to session flashdata //setting return_url to session flashdata
$this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->uri->getQuery() ?: ""); $this->session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . $this->uri->getQuery() ? "?" . $this->uri->getQuery() : "");
return view( return view(
$this->view_path . "/index", $this->view_path . "/index",
['viewDatas' => $this->getViewDatas()] ['viewDatas' => $this->getViewDatas()]

View File

@ -41,7 +41,6 @@ class AuthFilter implements FilterInterface
); );
} }
} else { } else {
dd(session()->get(SESSION_NAMES['AUTH']));
session()->setFlashdata(SESSION_NAMES['RETURN_URL'], $request->getUri()->getPath() . '?' . $request->getUri()->getQuery()); session()->setFlashdata(SESSION_NAMES['RETURN_URL'], $request->getUri()->getPath() . '?' . $request->getUri()->getQuery());
return redirect()->to(URLS['LOGIN'])->with('return_message', '로그인을하셔야합니다.'); return redirect()->to(URLS['LOGIN'])->with('return_message', '로그인을하셔야합니다.');
} }

View File

@ -144,44 +144,13 @@ function getListLabel_AccountHelper(string $field, array $viewDatas, array $extr
} }
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label); return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
} }
function getListButtonLabel_AccountHelper(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$label = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
if ($action == 'create') {
$label = form_label($label, "", [
"onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')",
...$extras,
]);
} else {
$label = "";
}
break;
default:
$label = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
return $label;
}
function getListButton_AccountHelper(string $action, array $viewDatas, array $extras = []): string function getListButton_AccountHelper(string $action, array $viewDatas, array $extras = []): string
{ {
switch ($action) { switch ($action) {
case 'create': case 'create':
$viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => AccountModel::PARENT]); $viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => AccountModel::PARENT]);
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = getListButtonLabel_AccountHelper($action, '입력', $viewDatas, $extras); $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras);
break; break;
case 'sync': case 'sync':
$action = $viewDatas['cnt']; $action = $viewDatas['cnt'];

View File

@ -111,44 +111,13 @@ function getListLabel_AuthHelper(string $field, array $viewDatas, array $extras
} }
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label); return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
} }
function getListButtonLabel_AuthHelper(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$label = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
if ($action == 'create') {
$label = form_label($label, "", [
"onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')",
...$extras,
]);
} else {
$label = "";
}
break;
default:
$label = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
return $label;
}
function getListButton_AuthHelper(string $action, array $viewDatas, array $extras = []): string function getListButton_AuthHelper(string $action, array $viewDatas, array $extras = []): string
{ {
switch ($action) { switch ($action) {
case 'create': case 'create':
$viewDatas['list_action_url'] = current_url() . '/' . $action; $viewDatas['list_action_url'] = current_url() . '/' . $action;
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = getListButtonLabel_AuthHelper($action, '입력', $viewDatas, $extras); $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras);
break; break;
case 'modify': case 'modify':
$pk = $viewDatas['entity']->getPK(); $pk = $viewDatas['entity']->getPK();
@ -160,7 +129,7 @@ function getListButton_AuthHelper(string $action, array $viewDatas, array $extra
"checked" => in_array($pk, old("batchjob_uids", [])) "checked" => in_array($pk, old("batchjob_uids", []))
]); ]);
$viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK();
$action = $checkbox . getListButtonLabel_AuthHelper($action, $viewDatas['cnt'], $viewDatas, $extras); $action = $checkbox . getListButtonLabel_CommonHelper($action, $viewDatas['cnt'], $viewDatas, $extras);
break; break;
case 'delete': case 'delete':
$viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK();

View File

@ -160,68 +160,13 @@ function getListLabel_RecordHelper(string $field, array $viewDatas, array $extra
} }
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label); return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
} }
function getListButtonLabel_RecordHelper(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'create':
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$value = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
$value = "";
break;
default:
$value = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
break;
case 'modify':
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$value = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
$value = form_label($label, "", [
"onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')",
...$extras
]);
break;
default:
$value = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
break;
default:
break;
}
return $value;
}
function getListButton_RecordHelper(string $action, array $viewDatas, array $extras = []): string function getListButton_RecordHelper(string $action, array $viewDatas, array $extras = []): string
{ {
switch ($action) { switch ($action) {
case 'create': case 'create':
$viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => RecordModel::PARENT]); $viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => RecordModel::PARENT]);
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = getListButtonLabel_RecordHelper($action, '입력', $viewDatas, $extras); $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras);
break; break;
case 'sync': case 'sync':
$checkbox = ""; $checkbox = "";

View File

@ -192,68 +192,13 @@ function getListLabel_ZoneHelper(string $field, array $viewDatas, array $extras
} }
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label); return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
} }
function getListButtonLabel_ZoneHelper(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'create':
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$value = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
$value = "";
break;
default:
$value = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
break;
case 'modify':
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$value = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
$value = form_label($label, "", [
"onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')",
...$extras
]);
break;
default:
$value = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
break;
default:
break;
}
return $value;
}
function getListButton_ZoneHelper(string $action, array $viewDatas, array $extras = []): string function getListButton_ZoneHelper(string $action, array $viewDatas, array $extras = []): string
{ {
switch ($action) { switch ($action) {
case 'create': case 'create':
$viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => ZoneModel::PARENT]); $viewDatas['list_action_url'] = current_url() . '/' . $action . '?' . $viewDatas['uri']->getQuery(['only' => ZoneModel::PARENT]);
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = getListButtonLabel_ZoneHelper($action, '입력', $viewDatas, $extras); $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras);
break; break;
case 'sync': case 'sync':
$pk = $viewDatas['entity']->getPK(); $pk = $viewDatas['entity']->getPK();

View File

@ -222,3 +222,31 @@ function form_dropdown_test($data = '', $options = [], $selected = [], $extra =
return $form . "</select>\n"; return $form . "</select>\n";
} }
function getListButtonLabel_CommonHelper(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$label = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
$label = form_label($label, "", [
"onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')",
...$extras,
]);
break;
default:
$label = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
return $label;
}

View File

@ -116,44 +116,13 @@ function getListLabel_MapurlHelper(string $field, array $viewDatas, array $extra
} }
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label); return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
} }
function getListButtonLabel_MapurlHelper(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$label = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
if ($action == 'create') {
$label = form_label($label, "", [
"onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')",
...$extras,
]);
} else {
$label = "";
}
break;
default:
$label = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
return $label;
}
function getListButton_MapurlHelper(string $action, array $viewDatas, array $extras = []): string function getListButton_MapurlHelper(string $action, array $viewDatas, array $extras = []): string
{ {
switch ($action) { switch ($action) {
case 'create': case 'create':
$viewDatas['list_action_url'] = current_url() . '/' . $action; $viewDatas['list_action_url'] = current_url() . '/' . $action;
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = getListButtonLabel_MapurlHelper($action, '입력', $viewDatas, $extras); $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras);
break; break;
case 'modify': case 'modify':
$pk = $viewDatas['entity']->getPK(); $pk = $viewDatas['entity']->getPK();
@ -165,7 +134,7 @@ function getListButton_MapurlHelper(string $action, array $viewDatas, array $ext
"checked" => in_array($pk, old("batchjob_uids", [])) "checked" => in_array($pk, old("batchjob_uids", []))
]); ]);
$viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK();
$action = $checkbox . getListButtonLabel_MapurlHelper($action, $viewDatas['cnt'], $viewDatas, $extras); $action = $checkbox . getListButtonLabel_CommonHelper($action, $viewDatas['cnt'], $viewDatas, $extras);
break; break;
case 'delete': case 'delete':
$viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK();

View File

@ -142,44 +142,13 @@ function getListLabel_UserHelper(string $field, array $viewDatas, array $extras
} }
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label); return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
} }
function getListButtonLabel_UserHelper(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($viewDatas['action_form']) {
case FORMS['MODAL']:
$label = form_label(
$label,
"",
[
"data-src" => $viewDatas['list_action_url'],
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case FORMS['IFRAME']:
if ($action == 'create') {
$label = form_label($label, "", [
"onClick" => "changeIframe_src('{$viewDatas['list_action_url']}')",
...$extras,
]);
} else {
$label = "";
}
break;
default:
$label = anchor($viewDatas['list_action_url'], $label, $extras);
break;
}
return $label;
}
function getListButton_UserHelper(string $action, array $viewDatas, array $extras = []): string function getListButton_UserHelper(string $action, array $viewDatas, array $extras = []): string
{ {
switch ($action) { switch ($action) {
case 'create': case 'create':
$viewDatas['list_action_url'] = current_url() . '/' . $action; $viewDatas['list_action_url'] = current_url() . '/' . $action;
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras]; $extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = getListButtonLabel_UserHelper($action, '입력', $viewDatas, $extras); $action = getListButtonLabel_CommonHelper($action, '입력', $viewDatas, $extras);
break; break;
case 'modify': case 'modify':
$pk = $viewDatas['entity']->getPK(); $pk = $viewDatas['entity']->getPK();
@ -190,9 +159,8 @@ function getListButton_UserHelper(string $action, array $viewDatas, array $extra
"class" => "batchjobuids_checkboxs", "class" => "batchjobuids_checkboxs",
"checked" => in_array($pk, old("batchjob_uids", [])) "checked" => in_array($pk, old("batchjob_uids", []))
]); ]);
$viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK();
$action = $checkbox . getListButtonLabel_UserHelper($action, $viewDatas['cnt'], $viewDatas, $extras); $action = $checkbox . getListButtonLabel_CommonHelper($action, $viewDatas['cnt'], $viewDatas, $extras);
break; break;
case 'delete': case 'delete':
$viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(); $viewDatas['list_action_url'] = current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK();

View File

@ -16,14 +16,11 @@ class CloudflareSocket extends MySocket
parent::__construct([ parent::__construct([
'base_uri' => 'https://api.cloudflare.com/client/v4/', 'base_uri' => 'https://api.cloudflare.com/client/v4/',
'headers' => [ 'headers' => [
'X-Auth-Email' => $auth_entity->getID(), // 인증 토큰 사용 'X-Auth-Email' => $auth_entity->getID(),
'X-Auth-Key' => $auth_entity->getAuthKey(), // 인증 토큰 사용 'X-Auth-Key' => $auth_entity->getAuthKey(),
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
] ]
]); ]);
self::$_request_max = getenv("cfmgr.request.max") ?: 1000;
self::$_request_perpage_max = getenv("cfmgr.request.perpage.max") ?: 700;
self::$_request_timewait = getenv("cfmgr.request.timewait") ?: 60;
} }
final public function request(string $method, $uri = '', array $options = []): ResponseInterface final public function request(string $method, $uri = '', array $options = []): ResponseInterface

View File

@ -22,19 +22,20 @@
<ul class="nav justify-content-end"> <ul class="nav justify-content-end">
<li class="nav-item"> <li class="nav-item">
<?php if ($viewDatas['session']->get(SESSION_NAMES['ISLOGIN'])): ?> <?php if ($viewDatas['session']->get(SESSION_NAMES['ISLOGIN'])): ?>
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> <div class="btn-group">
<?= ICONS['LOGIN'] . $viewDatas['session']->get(SESSION_NAMES['AUTH'])['name'] ?> <button type="button" class="btn btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<b><?= ICONS['LOGIN'] . $viewDatas['session']->get(SESSION_NAMES['AUTH'])['name'] ?></b>
</button>
<ul class="dropdown-menu dropdown-menu-end"> <ul class="dropdown-menu dropdown-menu-end">
<li><a class="dropdown-item" <?php $viewDatas['list_action_url'] = "/admin/user/modify/" . $viewDatas['session']->get(SESSION_NAMES['AUTH'])['uid'] ?>
href="/user/modify/<?= $viewDatas['session']->get(SESSION_NAMES['AUTH'])['uid'] ?>"><?= ICONS['SETUP'] ?>수정</a> <li><?= getListButtonLabel_CommonHelper("modify", ICONS['SETUP'] . "정보수정", $viewDatas, ["class" => "dropdown-item"]) ?></li>
</li>
<li> <li>
<hr class="dropdown-divider"> <hr class="dropdown-divider">
</li> </li>
<li><a class="dropdown-item" href="<?= URLS['LOGOUT'] ?>"><?= ICONS['LOGOUT'] ?>Logout</a></li> <li><a class="dropdown-item" href="<?= URLS['LOGOUT'] ?>"><?= ICONS['LOGOUT'] ?>Logout</a></li>
</ul> </ul>
<?php else: ?><a class="nav-link dropdown-toggle" href="<?= URLS['LOGIN'] ?>" </div>
role="button"><?= ICONS['LOGIN'] ?>Login</a><?php endif ?> <?php else: ?><a class="nav-link dropdown-toggle" href="<?= URLS['LOGIN'] ?>" role="button"><?= ICONS['LOGIN'] ?>Login</a><?php endif ?>
</li> </li>
</ul> </ul>
</div> </div>

View File

@ -22,18 +22,19 @@
<ul class="nav justify-content-end"> <ul class="nav justify-content-end">
<li class="nav-item"> <li class="nav-item">
<?php if ($viewDatas['session']->get(SESSION_NAMES['ISLOGIN'])): ?> <?php if ($viewDatas['session']->get(SESSION_NAMES['ISLOGIN'])): ?>
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false"> <div class="btn-group">
<?= ICONS['LOGIN'] . $viewDatas['session']->get(SESSION_NAMES['AUTH'])['name'] ?> <button type="button" class="btn btn-outline-primary dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
</a> <b><?= ICONS['LOGIN'] . $viewDatas['session']->get(SESSION_NAMES['AUTH'])['name'] ?></b>
<ul class="dropdown-menu dropdown-menu-end"> </button>
<li><a class="dropdown-item" <ul class="dropdown-menu dropdown-menu-end">
href="/user/modify/<?= $viewDatas['session']->get(SESSION_NAMES['AUTH'])['uid'] ?>"><?= ICONS['SETUP'] ?>수정</a> <?php $viewDatas['list_action_url'] = "/admin/user/modify/" . $viewDatas['session']->get(SESSION_NAMES['AUTH'])['uid'] ?>
</li> <li><?= getListButtonLabel_CommonHelper("modify", ICONS['SETUP'] . "정보수정", $viewDatas, ["class" => "dropdown-item"]) ?></li>
<li> <li>
<hr class="dropdown-divider"> <hr class="dropdown-divider">
</li> </li>
<li><a class="dropdown-item" href="<?= URLS['LOGOUT'] ?>"><?= ICONS['LOGOUT'] ?>Logout</a></li> <li><a class="dropdown-item" href="<?= URLS['LOGOUT'] ?>"><?= ICONS['LOGOUT'] ?>Logout</a></li>
</ul> </ul>
</div>
<?php else: ?><a class="nav-link dropdown-toggle" href="<?= URLS['LOGIN'] ?>" <?php else: ?><a class="nav-link dropdown-toggle" href="<?= URLS['LOGIN'] ?>"
role="button"><?= ICONS['LOGIN'] ?>Login</a><?php endif ?> role="button"><?= ICONS['LOGIN'] ?>Login</a><?php endif ?>
</li> </li>