servermgrv2 init...
This commit is contained in:
parent
eaa3a76677
commit
ec13903407
@ -168,14 +168,11 @@ define('FORM_OPTIONS', [
|
||||
|
||||
//Upload , Download 관련
|
||||
define('PATHS', [
|
||||
'EXCEL' => getenv('path.excel') ?: "../writable/Excel",
|
||||
'UPLOAD' => getenv('path.upload') ?: "../writable/uploads",
|
||||
'DOWNLOAD' => getenv('path.download') ?: "../writable/download",
|
||||
'API' => getenv('path.api') ?: "../writable/api",
|
||||
'EXCEL' => "excel/", 'UPLOAD' => "uploads/", 'DOWNLOAD' => "download/", 'API' => "api/",
|
||||
]);
|
||||
foreach (PATHS as $key => $path) {
|
||||
if (!is_dir(APPPATH . $path)) {
|
||||
mkdir(APPPATH . $path, 0640);
|
||||
if (!is_dir(WRITEPATH . $path)) {
|
||||
mkdir(WRITEPATH . $path, 0640);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,6 +185,7 @@ define('ICONS', [
|
||||
'SETTING' => '<i class="fa fa-cogs" aria-hidden="true"></i>',
|
||||
'FLAG' => '<i class="fa fa-flag" aria-hidden="true"></i>',
|
||||
'EXCEL' => '<i class="fa fa-file-excel-o" style="font-size:24px"></i>',
|
||||
'IMAGE_FILE' => '<i class="fa fa-file-image-o" aria-hidden="true"></i>',
|
||||
]);
|
||||
define('AUDIOS', [
|
||||
'Alram_GetEmail' => '<object width=0 height=0 data="/sound/jarvis_email.mp3" type="audio/mpeg"></object>',
|
||||
|
||||
@ -66,11 +66,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1');
|
||||
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2');
|
||||
});
|
||||
$routes->group('logger', static function ($routes) {
|
||||
$routes->get('', 'LoggerController::index');
|
||||
$routes->get('excel', 'LoggerController::excel');
|
||||
$routes->get('view/(:num)', 'LoggerController::view/$1');
|
||||
});
|
||||
$routes->group('boardconfig', static function ($routes) {
|
||||
$routes->get('', 'BoardConfigController::index');
|
||||
$routes->get('excel', 'BoardConfigController::excel/$1');
|
||||
@ -96,6 +91,22 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'BoardController::batchjob');
|
||||
$routes->get('download/(:num)', 'BoardController::download/$1');
|
||||
});
|
||||
$routes->group('hpilo', static function ($routes) {
|
||||
$routes->get('', 'HPILOController::index');
|
||||
$routes->get('excel', 'HPILOController::excel');
|
||||
$routes->get('insert', 'HPILOController::insert_form');
|
||||
$routes->post('insert', 'HPILOController::insert');
|
||||
$routes->get('update/(:num)', 'HPILOController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'HPILOController::update/$1');
|
||||
$routes->get('view/(:num)', 'HPILOController::view/$1');
|
||||
$routes->get('delete/(:num)', 'HPILOController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'HPILOController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'HPILOController::batchjob');
|
||||
$routes->get('console/(:num)', 'HPILOController::console/$1');
|
||||
$routes->get('reset/(:num)/(:alpha)', 'HPILOController::reset/$1/$2');
|
||||
$routes->get('reload/(:num)', 'HPILOController::reset/$1');
|
||||
});
|
||||
});
|
||||
/*
|
||||
|
||||
127
app/Config/Routes_HPILO.php
Normal file
127
app/Config/Routes_HPILO.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
// Create a new instance of our RouteCollection class.
|
||||
$routes = Services::routes();
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Router Setup
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
$routes->setDefaultNamespace('App\Controllers');
|
||||
$routes->setDefaultController('Home');
|
||||
$routes->setDefaultMethod('index');
|
||||
$routes->setTranslateURIDashes(false);
|
||||
$routes->set404Override();
|
||||
$routes->setAutoRoute(false);
|
||||
// The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
|
||||
// where controller filters or CSRF protection are bypassed.
|
||||
// If you don't want to define all routes, please use the Auto Routing (Improved).
|
||||
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
|
||||
// $routes->setAutoRoute(false);
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Route Definitions
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// We get a performance increase by specifying the default
|
||||
// route since we don't have to scan directories.
|
||||
|
||||
//추가 RULE UUID형식
|
||||
$routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
|
||||
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->get('/login', 'AuthController::login');
|
||||
$routes->post('/signin', 'AuthController::signin/local');
|
||||
$routes->get('/signin/(:alpha)', 'AuthController::signin/$1');
|
||||
$routes->get('/logout', 'AuthController::logout');
|
||||
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
|
||||
});
|
||||
$routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) {
|
||||
$routes->get('/', 'FrontController::index');
|
||||
});
|
||||
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:master,director,cloudflare,manager'], static function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('user', static function ($routes) {
|
||||
$routes->get('', 'UserController::index');
|
||||
$routes->get('excel', 'UserController::excel');
|
||||
$routes->get('insert', 'UserController::insert_form');
|
||||
$routes->post('insert', 'UserController::insert');
|
||||
$routes->get('update/(:uuid)', 'UserController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'UserController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'UserController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'UserController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'UserController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'UserController::batchjob');
|
||||
});
|
||||
$routes->group('usersns', static function ($routes) {
|
||||
$routes->get('', 'UserSNSController::index');
|
||||
$routes->get('excel', 'UserSNSController::excel');
|
||||
$routes->get('view/(:num)', 'UserSNSController::view/$1');
|
||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1');
|
||||
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2');
|
||||
});
|
||||
$routes->group('boardconfig', static function ($routes) {
|
||||
$routes->get('', 'BoardConfigController::index');
|
||||
$routes->get('excel', 'BoardConfigController::excel/$1');
|
||||
$routes->get('insert', 'BoardConfigController::insert_form');
|
||||
$routes->post('insert', 'BoardConfigController::insert');
|
||||
$routes->get('update/(:uuid)', 'BoardConfigController::update_form/$1');
|
||||
$routes->post('update/(:uuid)', 'BoardConfigController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'BoardConfigController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'BoardConfigController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'BoardConfigController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'BoardConfigController::batchjob');
|
||||
});
|
||||
$routes->group('board', static function ($routes) {
|
||||
$routes->get('', 'BoardController::index');
|
||||
$routes->get('excel', 'BoardController::excel/$1');
|
||||
$routes->get('insert', 'BoardController::insert_form');
|
||||
$routes->post('insert', 'BoardController::insert');
|
||||
$routes->get('update/(:num)', 'BoardController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'BoardController::update/$1');
|
||||
$routes->get('view/(:num)', 'BoardController::view/$1');
|
||||
$routes->get('reply/(:num)', 'BoardController::reply_form/$1');
|
||||
$routes->post('reply/(:num)', 'BoardController::reply/$1');
|
||||
$routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'BoardController::batchjob');
|
||||
$routes->get('download/(:num)', 'BoardController::download/$1');
|
||||
});
|
||||
$routes->group('hpilo', static function ($routes) {
|
||||
$routes->get('', 'HPILOController::index');
|
||||
$routes->get('excel', 'HPILOController::excel');
|
||||
$routes->get('insert', 'HPILOController::insert_form');
|
||||
$routes->post('insert', 'HPILOController::insert');
|
||||
$routes->get('update/(:num)', 'HPILOController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'HPILOController::update/$1');
|
||||
$routes->get('view/(:num)', 'HPILOController::view/$1');
|
||||
$routes->get('delete/(:num)', 'HPILOController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'HPILOController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'HPILOController::batchjob');
|
||||
$routes->get('console/(:num)', 'HPILOController::console/$1');
|
||||
$routes->get('reset/(:num)/(:alpha)', 'HPILOController::reset/$1/$2');
|
||||
$routes->get('reload/(:num)', 'HPILOController::reset/$1');
|
||||
});
|
||||
});
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
* --------------------------------------------------------------------
|
||||
*
|
||||
* There will often be times that you need additional routing and you
|
||||
* need it to be able to override any defaults in this file. Environment
|
||||
* based routes is one such time. require() additional route files here
|
||||
* to make that happen.
|
||||
*
|
||||
* You will have access to the $routes object within that file without
|
||||
* needing to reload it.
|
||||
*/
|
||||
if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
|
||||
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
|
||||
}
|
||||
64
app/Controllers/Admin/AdminHierarchyController.php
Normal file
64
app/Controllers/Admin/AdminHierarchyController.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Libraries\Log\Log;
|
||||
|
||||
abstract class AdminHierarchyController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
//Reply관련
|
||||
protected function reply_form_process($entity)
|
||||
{
|
||||
return $this->update_form_process($entity);
|
||||
}
|
||||
final public function reply_form($uid)
|
||||
{
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('reply');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'reply');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_viewDatas['entity'] = $this->reply_form_process($entity);
|
||||
return view($this->_viewPath . '/reply', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
return alert_CommonHelper($e->getMessage(), 'back');
|
||||
}
|
||||
}
|
||||
protected function reply_validate($entity)
|
||||
{
|
||||
return $this->update_validate($entity);
|
||||
}
|
||||
protected function reply_process($entity)
|
||||
{
|
||||
return $this->_model->reply($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
public function reply($uid)
|
||||
{
|
||||
$message = "";
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('reply');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'reply');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$entity = $this->reply_validate($entity);
|
||||
$entity = $this->reply_process($entity);
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = __FUNCTION__ . " 실패하였습니다.";
|
||||
log_message("warning", $e->getMessage());
|
||||
log_message("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}",);
|
||||
return redirect()->back()->withInput()->with("error", $message . "<br>\n{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,97 +7,16 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BoardConfigController extends \App\Controllers\Admin\AdminController
|
||||
class BoardConfigController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_className .= '/BoardConfig';
|
||||
$this->_model = new BoardConfigModel();
|
||||
|
||||
$this->_defines = [
|
||||
'insert' => [
|
||||
'fields' => $this->_model->getFields(),
|
||||
'fieldRules' => $this->_model->getFieldRules($this->_model->getFields()),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
'update' => [
|
||||
'fields' => $this->_model->getFields(),
|
||||
'fieldRules' => $this->_model->getFieldRules($this->_model->getFields()),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
'view' => [
|
||||
'fields' => $this->_model->getFields(),
|
||||
'fieldRules' => $this->_model->getFieldRules($this->_model->getFields()),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
'index' => [
|
||||
'fields' => $this->_model->getFields([], ['head', 'tail']),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
'batchjobFilters' => $this->_model->getFieldFilters($this->_model->getFields(), ['isupload', 'isdownload']),
|
||||
],
|
||||
'excel' => [
|
||||
'fields' => $this->_model->getFields(),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
];
|
||||
|
||||
helper($this->_className);
|
||||
$this->_viewPath = strtolower($this->_className);
|
||||
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
||||
$this->_viewDatas['className'] = $this->_className;
|
||||
}
|
||||
|
||||
//Field별 Form Option용
|
||||
protected function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
return parent::getFieldFormOption($field);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////Action 모음
|
||||
//Insert관련
|
||||
final public function insert()
|
||||
{
|
||||
$this->_defines[__FUNCTION__]['fieldRules']['name'] .= '|is_unique[tw_board_config.name]';
|
||||
return $this->insert_procedure();
|
||||
}
|
||||
//Update관련
|
||||
final public function update($uid)
|
||||
{
|
||||
return $this->update_procedure($uid);
|
||||
}
|
||||
//Toggle관련
|
||||
final public function toggle($uid, string $field)
|
||||
{
|
||||
return $this->toggle_procedure($uid, $field);
|
||||
}
|
||||
//Batchjob 관련
|
||||
final public function batchjob()
|
||||
{
|
||||
return $this->batchjob_procedure();
|
||||
}
|
||||
//Delete 관련
|
||||
final public function delete($uid)
|
||||
{
|
||||
return $this->delete_procedure($uid);
|
||||
}
|
||||
//View 관련
|
||||
final public function view($uid)
|
||||
{
|
||||
return $this->view_procedure($uid);
|
||||
}
|
||||
//Index 관련
|
||||
final public function index()
|
||||
{
|
||||
return $this->index_procedure();
|
||||
}
|
||||
//Excel 관련
|
||||
final public function excel()
|
||||
{
|
||||
return $this->excel_procedure();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BoardController extends \App\Controllers\Admin\AdminController
|
||||
class BoardController extends AdminHierarchyController
|
||||
{
|
||||
private $_boardConfigModel = null;
|
||||
private $_board_config_uids = null;
|
||||
@ -17,34 +17,6 @@ class BoardController extends \App\Controllers\Admin\AdminController
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_className .= '/Board';
|
||||
$this->_model = new BoardModel();
|
||||
|
||||
$this->_defines = [
|
||||
'insert' => [
|
||||
'fields' => $this->_model->getFields([], ['user_uid', 'view_cnt']),
|
||||
'fieldRules' => $this->_model->getFieldRules($this->_model->getFields()),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
'update' => [
|
||||
'fields' => $this->_model->getFields([], ['user_uid', 'view_cnt']),
|
||||
'fieldRules' => $this->_model->getFieldRules($this->_model->getFields()),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
'view' => [
|
||||
'fields' => $this->_model->getFields(),
|
||||
'fieldRules' => $this->_model->getFieldRules($this->_model->getFields()),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
'index' => [
|
||||
'fields' => $this->_model->getFields([], ['upload_file', 'passwd', 'content']),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
'batchjobFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
'excel' => [
|
||||
'fields' => $this->_model->getFields([], ['upload_file', 'passwd']),
|
||||
'fieldFilters' => $this->_model->getFieldFilters($this->_model->getFields()),
|
||||
],
|
||||
];
|
||||
|
||||
helper($this->_className);
|
||||
$this->_viewPath = strtolower($this->_className);
|
||||
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
||||
@ -65,9 +37,12 @@ class BoardController extends \App\Controllers\Admin\AdminController
|
||||
$options = $this->_board_config_uids = $this->_board_config_uids ?: $this->getBoardConfigModel()->getFieldFormOptions(['status' => 'use']);
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFieldFormOption($field);
|
||||
return parent::getFieldFormOption($field);
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
@ -79,7 +54,7 @@ class BoardController extends \App\Controllers\Admin\AdminController
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
|
||||
$this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
|
||||
break;
|
||||
case 'upload_file':
|
||||
case 'board_file':
|
||||
$this->_viewDatas['fieldDatas'][$field] = $this->single_upload_procedure($field, $entity);
|
||||
break;
|
||||
default:
|
||||
@ -89,41 +64,6 @@ class BoardController extends \App\Controllers\Admin\AdminController
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
////Action 모음
|
||||
//Insert관련
|
||||
final protected function insert_process()
|
||||
{
|
||||
return parent::insert_process();
|
||||
}
|
||||
final public function insert()
|
||||
{
|
||||
return $this->insert_procedure();
|
||||
}
|
||||
//Update관련
|
||||
final public function update($uid)
|
||||
{
|
||||
return $this->update_procedure($uid);
|
||||
}
|
||||
//Reply 관련
|
||||
final public function reply($uid)
|
||||
{
|
||||
return $this->reply_procedure($uid);
|
||||
}
|
||||
//Toggle관련
|
||||
final public function toggle($uid, string $field)
|
||||
{
|
||||
return $this->toggle_procedure($uid, $field);
|
||||
}
|
||||
//Batchjob 관련
|
||||
final public function batchjob()
|
||||
{
|
||||
return $this->batchjob_procedure();
|
||||
}
|
||||
//Delete 관련
|
||||
final public function delete($uid)
|
||||
{
|
||||
return $this->delete_procedure($uid);
|
||||
}
|
||||
//View 관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
@ -131,18 +71,21 @@ class BoardController extends \App\Controllers\Admin\AdminController
|
||||
$this->_model->increaseViewCount($entity->getPrimaryKey());
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
final public function view($uid)
|
||||
//File Download관련
|
||||
public function download($uid)
|
||||
{
|
||||
return $this->view_procedure($uid);
|
||||
}
|
||||
//Index 관련
|
||||
final public function index()
|
||||
{
|
||||
return $this->index_procedure();
|
||||
}
|
||||
//Excel 관련
|
||||
final public function excel()
|
||||
{
|
||||
return $this->excel_procedure();
|
||||
try {
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
if (!$entity->getFile()) {
|
||||
throw new \Exception("해당게시물은 첨부파일이 확인되지 않습니다.");
|
||||
}
|
||||
list($origin_filename, $filename) = explode("||", $entity->getFile());
|
||||
if (is_file(WRITEPATH . PATHS['UPLOAD'] . "/" . $origin_filename)) {
|
||||
throw new \Exception("파일이 확인되지 않습니다.");
|
||||
}
|
||||
return $this->response->download(WRITEPATH . PATHS['UPLOAD'] . "/" . $filename, null)->setFileName(date("YmdHms") . '_' . $origin_filename);
|
||||
} catch (\Exception $e) {
|
||||
return alert_CommonHelper($e->getMessage(), 'back');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,44 +18,6 @@ class HPILOController extends \App\Controllers\Admin\AdminController
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_className .= '/HPILO';
|
||||
$this->_model = new HPILOModel();
|
||||
$this->_defines = [
|
||||
'insert' => [
|
||||
'fields' => ['customer', 'id', 'passwd', 'ip', 'port', 'status'],
|
||||
'fieldFilters' => ['status'],
|
||||
'fieldRules' => [
|
||||
'customer' => 'required|min_length[4]|max_length[100]',
|
||||
'id' => 'required|min_length[4]|max_length[20]',
|
||||
'passwd' => 'required|trim|min_length[4]|max_length[150]',
|
||||
'ip' => 'required|trim|min_length[4]|max_length[50]',
|
||||
'port' => 'required|min_length[2]|max_length[20]',
|
||||
]
|
||||
],
|
||||
'update' => [
|
||||
'fields' => ['customer', 'id', 'passwd', 'ip', 'port', 'status'],
|
||||
'fieldFilters' => ['status'],
|
||||
'fieldRules' => [
|
||||
'customer' => 'required|min_length[4]|max_length[100]',
|
||||
'id' => 'required|min_length[4]|max_length[20]',
|
||||
'passwd' => 'required|trim|min_length[4]|max_length[150]',
|
||||
'ip' => 'required|trim|min_length[4]|max_length[50]',
|
||||
'port' => 'required|min_length[2]|max_length[20]',
|
||||
]
|
||||
],
|
||||
'view' => [
|
||||
'fields' => ['customer', 'id', 'ip', 'port', 'model', 'processor', 'memory', 'health', 'power', 'detail', 'status', 'updated_at', 'created_at'],
|
||||
'fieldFilters' => ['status'],
|
||||
'fieldRules' => [],
|
||||
],
|
||||
'index' => [
|
||||
'fields' => ['customer', 'ip', 'port', 'model', 'processor', 'memory', 'health', 'power', 'status', 'created_at'],
|
||||
'fieldFilters' => ['power', 'status'],
|
||||
'batchjobFilters' => [],
|
||||
],
|
||||
'excel' => [
|
||||
'fields' => ['customer', 'ip', 'port', 'model', 'processor', 'memory', 'health', 'power', 'status', 'created_at'],
|
||||
'fieldFilters' => ['status'],
|
||||
],
|
||||
];
|
||||
helper($this->_className);
|
||||
$this->_viewPath = strtolower($this->_className);
|
||||
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
||||
@ -83,47 +45,6 @@ class HPILOController extends \App\Controllers\Admin\AdminController
|
||||
}
|
||||
}
|
||||
|
||||
////Action 모음
|
||||
//Insert관련
|
||||
final public function insert()
|
||||
{
|
||||
return $this->insert_procedure();
|
||||
}
|
||||
//Update관련
|
||||
final public function update($uid)
|
||||
{
|
||||
return $this->update_procedure($uid);
|
||||
}
|
||||
//Toggle관련
|
||||
final public function toggle($uid, string $field)
|
||||
{
|
||||
return $this->toggle_procedure($uid, $field);
|
||||
}
|
||||
//Batchjob 관련
|
||||
final public function batchjob()
|
||||
{
|
||||
return $this->batchjob_procedure();
|
||||
}
|
||||
//Delete 관련
|
||||
final public function delete($uid)
|
||||
{
|
||||
return $this->delete_procedure($uid);
|
||||
}
|
||||
//View 관련
|
||||
final public function view($uid)
|
||||
{
|
||||
return $this->view_procedure($uid);
|
||||
}
|
||||
//Index 관련
|
||||
final public function index()
|
||||
{
|
||||
return $this->index_procedure();
|
||||
}
|
||||
//Excel 관련
|
||||
final public function excel()
|
||||
{
|
||||
return $this->excel_procedure();
|
||||
}
|
||||
////추가 Action
|
||||
final public function console(int $uid)
|
||||
{
|
||||
@ -143,14 +64,14 @@ class HPILOController extends \App\Controllers\Admin\AdminController
|
||||
}
|
||||
$ilo = new HPILO4($this->getAdapter($entity));
|
||||
$results = $ilo->reset($type);
|
||||
Log::add("warning", var_export($results, true));
|
||||
log_message("warning", var_export($results, true));
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다.";
|
||||
Log::add("warning", $message . "<br>\n{$e->getMessage()}");
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", false);
|
||||
log_message("warning", $message . "<br>\n{$e->getMessage()}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, 'back');
|
||||
}
|
||||
}
|
||||
@ -160,9 +81,9 @@ class HPILOController extends \App\Controllers\Admin\AdminController
|
||||
$entity = $ilo->refresh($entity);
|
||||
if ($entity->hasChanged()) {
|
||||
if (!$this->_model->save($entity)) {
|
||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
Log::add("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
log_message("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
log_message("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors()));
|
||||
}
|
||||
}
|
||||
return $entity;
|
||||
@ -175,12 +96,12 @@ class HPILOController extends \App\Controllers\Admin\AdminController
|
||||
// throw new \Exception(var_export($ilo, true));
|
||||
$entity = $this->refresh($ilo, $entity);
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 실패하였습니다.";
|
||||
Log::add("warning", $message . "<br>\n{$e->getMessage()}");
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", false);
|
||||
log_message("warning", $message . "<br>\n{$e->getMessage()}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, 'back');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\LoggerModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class LoggerController extends \App\Controllers\Admin\AdminController
|
||||
{
|
||||
private $_userModel = null;
|
||||
private $_user_uids = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_className .= '/Logger';
|
||||
$this->_model = new LoggerModel();
|
||||
|
||||
$this->_defines = [];
|
||||
$this->_defines['insert'] = [];
|
||||
$this->_defines['insert']['fields'] = $this->_model->getFields();
|
||||
$this->_defines['insert']['fieldRules'] = $this->_model->getFieldRules($this->_defines['insert']['fields']);
|
||||
$this->_defines['insert']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['update'] = [];
|
||||
$this->_defines['update']['fields'] = $this->_defines['insert']['fields'];
|
||||
$this->_defines['update']['fieldRules'] = $this->_model->getFieldRules($this->_defines['update']['fields']);
|
||||
$this->_defines['update']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['view'] = [];
|
||||
$this->_defines['view']['fields'] = [...$this->_model->getFields(), 'updated_at', 'created_at'];
|
||||
$this->_defines['view']['fieldRules'] = $this->_model->getFieldRules($this->_defines['view']['fields']);
|
||||
$this->_defines['view']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['index'] = [];
|
||||
$this->_defines['index']['fields'] = [...$this->_model->getFields(), 'created_at'];
|
||||
$this->_defines['index']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['index']['batchjobFilters'] = ['status'];
|
||||
$this->_defines['excel'] = [];
|
||||
$this->_defines['excel']['fields'] = $this->_defines['index']['fields'];
|
||||
$this->_defines['excel']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
|
||||
helper($this->_className);
|
||||
$this->_viewPath = strtolower($this->_className);
|
||||
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
||||
$this->_viewDatas['className'] = $this->_className;
|
||||
}
|
||||
|
||||
//Field별 Form Option용
|
||||
protected function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
return parent::getFieldFormOption($field);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////Action 모음
|
||||
//Insert관련
|
||||
final public function insert()
|
||||
{
|
||||
return $this->insert_procedure();
|
||||
}
|
||||
//Update관련
|
||||
final public function update($uid)
|
||||
{
|
||||
return $this->update_procedure($uid);
|
||||
}
|
||||
// //Toggle관련
|
||||
final public function toggle($uid, string $field)
|
||||
{
|
||||
return $this->toggle_procedure($uid, $field);
|
||||
}
|
||||
//Batchjob 관련
|
||||
final public function batchjob()
|
||||
{
|
||||
return $this->batchjob_procedure();
|
||||
}
|
||||
//Delete 관련
|
||||
final public function delete($uid)
|
||||
{
|
||||
return $this->delete_procedure($uid);
|
||||
}
|
||||
//View 관련
|
||||
final public function view($uid)
|
||||
{
|
||||
return $this->view_procedure($uid);
|
||||
}
|
||||
//Index 관련
|
||||
final public function index()
|
||||
{
|
||||
return $this->index_procedure();
|
||||
}
|
||||
//Excel 관련
|
||||
final public function excel()
|
||||
{
|
||||
return $this->excel_procedure();
|
||||
}
|
||||
}
|
||||
@ -7,35 +7,13 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class UserController extends \App\Controllers\Admin\AdminController
|
||||
class UserController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_className .= '/User';
|
||||
$this->_model = new UserModel();
|
||||
|
||||
$this->_defines = [];
|
||||
$this->_defines['insert'] = [];
|
||||
$this->_defines['insert']['fields'] = ['id', 'passwd', 'confirmpassword', 'name', 'email', 'role', 'status'];
|
||||
$this->_defines['insert']['fieldRules'] = $this->_model->getFieldRules($this->_defines['insert']['fields']);
|
||||
$this->_defines['insert']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['update'] = [];
|
||||
$this->_defines['update']['fields'] = ['passwd', 'confirmpassword', 'name', 'email', 'role', 'status'];
|
||||
$this->_defines['update']['fieldRules'] = $this->_model->getFieldRules($this->_defines['update']['fields']);
|
||||
$this->_defines['update']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['view'] = [];
|
||||
$this->_defines['view']['fields'] = ['updated_at', 'created_at'];
|
||||
$this->_defines['view']['fieldRules'] = $this->_model->getFieldRules($this->_defines['view']['fields']);
|
||||
$this->_defines['view']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['index'] = [];
|
||||
$this->_defines['index']['fields'] = [...$this->_model->getFields(), 'created_at'];
|
||||
$this->_defines['index']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_defines['index']['batchjobFilters'] = ['status'];
|
||||
$this->_defines['excel'] = [];
|
||||
$this->_defines['excel']['fields'] = $this->_defines['index']['fields'];
|
||||
$this->_defines['excel']['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
|
||||
helper($this->_className);
|
||||
$this->_viewPath = strtolower($this->_className);
|
||||
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
||||
@ -56,47 +34,4 @@ class UserController extends \App\Controllers\Admin\AdminController
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
////Action 모음
|
||||
//Insert관련
|
||||
final public function insert()
|
||||
{
|
||||
$this->_defines[__FUNCTION__]['fieldRules']['id'] .= '|is_unique[tw_user.id]';
|
||||
return $this->insert_procedure();
|
||||
}
|
||||
//Update관련
|
||||
final public function update($uid)
|
||||
{
|
||||
return $this->update_procedure($uid);
|
||||
}
|
||||
//Toggle관련
|
||||
final public function toggle($uid, string $field)
|
||||
{
|
||||
return $this->toggle_procedure($uid, $field);
|
||||
}
|
||||
//Batchjob 관련
|
||||
final public function batchjob()
|
||||
{
|
||||
return $this->batchjob_procedure();
|
||||
}
|
||||
//Delete 관련
|
||||
final public function delete($uid)
|
||||
{
|
||||
return $this->delete_procedure($uid);
|
||||
}
|
||||
//View 관련
|
||||
final public function view($uid)
|
||||
{
|
||||
return $this->view_procedure($uid);
|
||||
}
|
||||
//Index 관련
|
||||
final public function index()
|
||||
{
|
||||
return $this->index_procedure();
|
||||
}
|
||||
//Excel 관련
|
||||
final public function excel()
|
||||
{
|
||||
return $this->excel_procedure();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,85 +7,16 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class UserSNSController extends \App\Controllers\Admin\AdminController
|
||||
class UserSNSController extends AdminController
|
||||
{
|
||||
private $_user_uids = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_className .= '/UserSNS';
|
||||
$this->_model = new UserSNSModel();
|
||||
$this->_defines = [
|
||||
'view' => [
|
||||
'fields' => ['user_uid', 'site', 'id', 'name', 'email', 'status', 'updated_at', 'created_at', 'detail'],
|
||||
'fieldFilters' => ['user_uid', 'status'],
|
||||
'fieldRules' => [],
|
||||
],
|
||||
'index' => [
|
||||
'fields' => ['user_uid', 'site', 'id', 'name', 'email', 'status', 'created_at'],
|
||||
'fieldFilters' => ['user_uid', 'status'],
|
||||
'batchjobFilters' => [],
|
||||
],
|
||||
'excel' => [
|
||||
'fields' => ['user_uid', 'site', 'id', 'name', 'email', 'status', 'created_at'],
|
||||
'fieldFilters' => ['user_uid', 'status'],
|
||||
],
|
||||
];
|
||||
helper($this->_className);
|
||||
$this->_viewPath = strtolower($this->_className);
|
||||
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
||||
$this->_viewDatas['className'] = $this->_className;
|
||||
}
|
||||
|
||||
//Field별 Form Option용
|
||||
protected function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
return parent::getFieldFormOption($field);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////Action 모음
|
||||
// Insert관련
|
||||
final public function insert()
|
||||
{
|
||||
return $this->insert_procedure();
|
||||
}
|
||||
//Update관련
|
||||
final public function update($uid)
|
||||
{
|
||||
return $this->update_procedure($uid);
|
||||
}
|
||||
//Toggle관련
|
||||
final public function toggle($uid, string $field)
|
||||
{
|
||||
return $this->toggle_procedure($uid, $field);
|
||||
}
|
||||
//Batchjob 관련
|
||||
final public function batchjob()
|
||||
{
|
||||
return $this->batchjob_procedure();
|
||||
}
|
||||
//Delete 관련
|
||||
final public function delete($uid)
|
||||
{
|
||||
return $this->delete_procedure($uid);
|
||||
}
|
||||
//View 관련
|
||||
final public function view($uid)
|
||||
{
|
||||
return $this->view_procedure($uid);
|
||||
}
|
||||
//Index 관련
|
||||
final public function index()
|
||||
{
|
||||
return $this->index_procedure();
|
||||
}
|
||||
//Excel 관련
|
||||
final public function excel()
|
||||
{
|
||||
return $this->excel_procedure();
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,6 @@ abstract class BaseController extends Controller
|
||||
private $_user_uids = array();
|
||||
protected $_model = null;
|
||||
protected $_className = '';
|
||||
protected $_defines = array();
|
||||
protected $_viewPath = '';
|
||||
protected $_viewDatas = array();
|
||||
protected $_session = null;
|
||||
@ -112,20 +111,6 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
return $fieldFormOptions;
|
||||
}
|
||||
//Field별 Form Rule용
|
||||
// final protected function getFieldRules(array $fields, array $fieldRules): array
|
||||
// {
|
||||
// $tempRules = $this->_model->getValidationRules(['only' => $fields]);
|
||||
// foreach ($fields as $field) {
|
||||
// if (!is_string($field)) {
|
||||
// throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}가 string 아닙니다.\n" . var_export($fieldRules, true));
|
||||
// }
|
||||
// if (array_key_exists($field, $fieldRules)) {
|
||||
// $tempRules[$field] = $fieldRules[$field];
|
||||
// }
|
||||
// }
|
||||
// return $tempRules;
|
||||
// }
|
||||
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
@ -141,28 +126,20 @@ abstract class BaseController extends Controller
|
||||
//Upload FIle관련
|
||||
protected function upload_file_process(UploadedFile $upfile)
|
||||
{
|
||||
$fileName = "";
|
||||
$fileName = null;
|
||||
if ($upfile->isValid() && !$upfile->hasMoved()) {
|
||||
$fileName = $upfile->getRandomName();
|
||||
$upfile->move(PATHS['UPLOAD'], $fileName);
|
||||
$originName = $upfile->getName();
|
||||
$upfile->move(WRITEPATH . PATHS['UPLOAD'], $upfile->getRandomName());
|
||||
//move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요
|
||||
$fileName = $upfile->getRandomName();
|
||||
$fileName = $originName . "||" . $upfile->getName();
|
||||
}
|
||||
return $fileName;
|
||||
}
|
||||
protected function single_upload_procedure(string $field, $entity = null)
|
||||
{
|
||||
$upfile = $this->request->getFile($field);
|
||||
$fileName = $this->upload_file_process($upfile);
|
||||
// $fileDatas=array();
|
||||
// if ($upfile->isValid() && !$upfile->hasMoved()) {
|
||||
// $filepath = PATHS['UPLOAD'] . $upfile->store();
|
||||
// $fileDatas = [
|
||||
// 'uploaded_fileinfo' => new \CodeIgniter\Files\File($filepath)
|
||||
// ];
|
||||
// return $fileDatas;
|
||||
// }
|
||||
return $fileName;
|
||||
if ($upfile = $this->request->getFile($field)) {
|
||||
return $this->upload_file_process($upfile);
|
||||
}
|
||||
}
|
||||
protected function multiple_upload_procedure(string $field, $entity = null): array
|
||||
{
|
||||
@ -184,27 +161,15 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
|
||||
//Insert관련
|
||||
protected function insert_init()
|
||||
{
|
||||
$this->_viewDatas['fields'] = $this->_defines['insert']['fields'];;
|
||||
$this->_viewDatas['fieldRules'] = $this->_defines['insert']['fieldRules'];
|
||||
}
|
||||
protected function insert_form_init()
|
||||
{
|
||||
$this->_viewDatas['fieldFilters'] = $this->_defines['insert']['fieldFilters'];
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
helper(['form']);
|
||||
}
|
||||
protected function insert_form_process()
|
||||
{
|
||||
}
|
||||
final public function insert_form()
|
||||
{
|
||||
try {
|
||||
$this->insert_init();
|
||||
$this->insert_form_init();
|
||||
$this->insert_form_process();
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('insert');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'insert');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
helper(['form']);
|
||||
return view($this->_viewPath . '/insert', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
return alert_CommonHelper($e->getMessage(), 'back');
|
||||
@ -213,72 +178,65 @@ abstract class BaseController extends Controller
|
||||
|
||||
protected function insert_validate()
|
||||
{
|
||||
//변경된 값 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
//변경할 값 확인
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||
}
|
||||
//변경된 값 적용
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
|
||||
Log::add("info", "{$field} : " . var_export($this->_viewDatas['fieldDatas'][$field], true));
|
||||
log_message("info", "{$field} : " . var_export($this->_viewDatas['fieldDatas'][$field], true));
|
||||
}
|
||||
|
||||
// echo var_export($this->_viewDatas['fields'], true);
|
||||
// echo "<HR>";
|
||||
// echo var_export($this->_viewDatas['fieldDatas'], true);
|
||||
// echo "<HR>";
|
||||
// echo var_export($this->_viewDatas['fieldRules'], true);
|
||||
// exit;
|
||||
//변경할 값 확인
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||
}
|
||||
}
|
||||
protected function insert_process()
|
||||
{
|
||||
return $this->_model->create($this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
protected function insert_procedure()
|
||||
public function insert()
|
||||
{
|
||||
$message = "";
|
||||
try {
|
||||
$this->insert_init();
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('insert');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'insert');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->insert_validate();
|
||||
$this->insert_process();
|
||||
$message = __FUNCTION__ . " 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
//session->setTempdata의 기능은 3초간 success에 message를 보관후 사라짐
|
||||
//$this->_session->setTempdata('success', 'Page updated successfully', 3);
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = __FUNCTION__ . " 실패하였습니다.";
|
||||
Log::add("warning", $e->getMessage());
|
||||
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", 'error');
|
||||
log_message("warning", $e->getMessage());
|
||||
log_message("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return redirect()->back()->withInput()->with("error", $message . "<br>\n{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
//Update관련
|
||||
protected function update_init()
|
||||
protected function update_form_process($entity)
|
||||
{
|
||||
$this->_viewDatas['fields'] = $this->_defines['update']['fields'];;
|
||||
$this->_viewDatas['fieldRules'] = $this->_defines['update']['fieldRules'];
|
||||
}
|
||||
protected function update_form_init()
|
||||
{
|
||||
$this->_viewDatas['fieldFilters'] = $this->_defines['update']['fieldFilters'];
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
helper(['form']);
|
||||
}
|
||||
protected function update_form_process($entity)
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
final public function update_form($uid)
|
||||
{
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->update_init();
|
||||
$this->update_form_init();
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('update');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'update');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_viewDatas['entity'] = $this->update_form_process($entity);
|
||||
return view($this->_viewPath . '/update', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
@ -289,102 +247,47 @@ abstract class BaseController extends Controller
|
||||
{
|
||||
//변경된 값 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
Log::add(
|
||||
"info",
|
||||
"{$field} : {$entity->$field} => " . var_export($this->_viewDatas['fieldDatas'][$field])
|
||||
);
|
||||
}
|
||||
//변경할 값 확인
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
|
||||
}
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
log_message(
|
||||
"info",
|
||||
"{$field} : {$entity->$field} => " . var_export($this->_viewDatas['fieldDatas'][$field])
|
||||
);
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function update_process($entity)
|
||||
{
|
||||
return $this->_model->modify($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
protected function update_procedure($uid)
|
||||
public function update($uid)
|
||||
{
|
||||
$message = "";
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->update_init();
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('update');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'update');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$entity = $this->update_validate($entity);
|
||||
$entity = $this->update_process($entity);
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = __FUNCTION__ . " 실패하였습니다.";
|
||||
Log::add("warning", $e->getMessage());
|
||||
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", 'error');
|
||||
log_message("warning", $e->getMessage());
|
||||
log_message("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return redirect()->back()->withInput()->with("error", $message . "<br>\n{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
//Reply관련
|
||||
protected function reply_init()
|
||||
{
|
||||
return $this->update_init();
|
||||
}
|
||||
protected function reply_form_init()
|
||||
{
|
||||
return $this->update_form_init();
|
||||
}
|
||||
protected function reply_form_process($entity)
|
||||
{
|
||||
return $this->update_form_process($entity);
|
||||
}
|
||||
final public function reply_form($uid)
|
||||
{
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->reply_init();
|
||||
$this->reply_form_init();
|
||||
$this->_viewDatas['entity'] = $this->reply_form_process($entity);
|
||||
return view($this->_viewPath . '/reply', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
return alert_CommonHelper($e->getMessage(), 'back');
|
||||
}
|
||||
}
|
||||
protected function reply_validate($entity)
|
||||
{
|
||||
return $this->update_validate($entity);
|
||||
}
|
||||
protected function reply_process($entity)
|
||||
{
|
||||
return $this->_model->reply($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
protected function reply_procedure($uid)
|
||||
{
|
||||
$message = "";
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->reply_init();
|
||||
$entity = $this->reply_validate($entity);
|
||||
$entity = $this->reply_process($entity);
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = __FUNCTION__ . " 실패하였습니다.";
|
||||
Log::add("warning", $e->getMessage());
|
||||
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", 'error');
|
||||
return redirect()->back()->withInput()->with("error", $message . "<br>\n{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
//Toggle 관련
|
||||
protected function toggle_init($field)
|
||||
{
|
||||
$this->_viewDatas['fields'] = [$field];
|
||||
$this->_viewDatas['fieldRules'] = $this->_defines['update']['fieldRules'];
|
||||
}
|
||||
protected function toggle_validate($entity)
|
||||
{
|
||||
return $this->update_validate($entity);
|
||||
@ -393,42 +296,28 @@ abstract class BaseController extends Controller
|
||||
{
|
||||
return $this->update_process($entity);
|
||||
}
|
||||
protected function toggle_procedure($uid, string $field)
|
||||
public function toggle($uid, string $field)
|
||||
{
|
||||
$message = "";
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->toggle_init($field);
|
||||
$this->_viewDatas['fields'] = [$field];
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'toggle');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$entity = $this->toggle_validate($entity);
|
||||
$entity = $this->toggle_process($entity);
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = __FUNCTION__ . " 실패하였습니다.";
|
||||
Log::add("warning", $e->getMessage());
|
||||
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", 'error');
|
||||
log_message("warning", $e->getMessage());
|
||||
log_message("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message . "<br>\n{$e->getMessage()}", 'back');
|
||||
}
|
||||
}
|
||||
//Batchjob 관련
|
||||
protected function batchjob_init()
|
||||
{
|
||||
//fields 해당하는 field중 선택된 값이 있는경우만 fields로 정의
|
||||
$fields = array();
|
||||
foreach ($this->_defines['index']['batchjobFilters'] as $field) {
|
||||
if ($this->request->getVar($field)) {
|
||||
array_push($fields, $field);
|
||||
}
|
||||
}
|
||||
if (!is_array($fields) || count($fields) === 0) {
|
||||
throw new \Exception($this->_viewDatas['title'] . '에서 변경할 항목(field)이 선택되지 않았습니다.');
|
||||
}
|
||||
//Fields,FielRules재정의
|
||||
$this->_viewDatas['fields'] = $fields;
|
||||
$this->_viewDatas['fieldRules'] = $this->_defines['update']['fieldRules'];
|
||||
}
|
||||
protected function batchjob_validate($entity)
|
||||
{
|
||||
return $this->update_validate($entity);
|
||||
@ -437,7 +326,7 @@ abstract class BaseController extends Controller
|
||||
{
|
||||
return $this->update_process($entity);
|
||||
}
|
||||
protected function batchjob_procedure()
|
||||
public function batchjob()
|
||||
{
|
||||
$uids = $this->request->getVar('batchjob_uids');
|
||||
if (is_null($uids) || !is_array($uids) || !count($uids)) {
|
||||
@ -445,7 +334,20 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
$message = "";
|
||||
try {
|
||||
$this->batchjob_init();
|
||||
//fields 해당하는 field중 선택된 값이 있는경우만 fields로 정의
|
||||
$fields = array();
|
||||
foreach ($this->_model->getFieldBatchFilters() as $field) {
|
||||
if ($this->request->getVar($field)) {
|
||||
array_push($fields, $field);
|
||||
}
|
||||
}
|
||||
if (!is_array($fields) || count($fields) === 0) {
|
||||
throw new \Exception($this->_viewDatas['title'] . '에서 변경할 항목(field)이 선택되지 않았습니다.');
|
||||
}
|
||||
//Fields,FielRules재정의
|
||||
$this->_viewDatas['fields'] = $fields;
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'batchjob');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$entitys = array();
|
||||
foreach ($uids as $uid) {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
@ -453,17 +355,17 @@ abstract class BaseController extends Controller
|
||||
$entity = $this->batchjob_validate($entity);
|
||||
array_push($entitys, $this->batchjob_process($entity));
|
||||
} catch (\Exception $e) {
|
||||
Log::add("warning", "{$entity->getTitle()}는 다음과 같은 이유로 수정되지 않았습니다.\n<br>" . $e->getMessage());
|
||||
log_message("warning", "{$entity->getTitle()}는 다음과 같은 이유로 수정되지 않았습니다.\n<br>" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
$message = "총: " . count($entitys) . "개의 수정(Batchjob)을 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = "총: " . count($uids) . "개의 수정(Batchjob)을 실패하였습니다.";
|
||||
Log::add("warning", $e->getMessage());
|
||||
Log::add("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", 'error');
|
||||
log_message("warning", $e->getMessage());
|
||||
log_message("warning", var_export($this->_viewDatas['fieldDatas'], true));
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message . "<br>\n{$e->getMessage()}", 'back');
|
||||
}
|
||||
}
|
||||
@ -472,49 +374,44 @@ abstract class BaseController extends Controller
|
||||
protected function delete_process($entity)
|
||||
{
|
||||
if (!$this->_model->delete($entity->getPrimaryKey())) {
|
||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
Log::add("error", implode("\n", $this->_model->errors()));
|
||||
log_message("error", __FUNCTION__ . "에서 호출:" . $this->_model->getLastQuery());
|
||||
log_message("error", implode("\n", $this->_model->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->_model->errors(), true));
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function delete_procedure($uid)
|
||||
public function delete($uid)
|
||||
{
|
||||
$message = "";
|
||||
try {
|
||||
$entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->delete_process($entity);
|
||||
$message = "{$entity->getTitle()} " . __FUNCTION__ . " 완료하였습니다.";
|
||||
Log::save("{$this->_viewDatas['title']} {$message}");
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message, $this->_session->get(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$message = __FUNCTION__ . " 실패하였습니다.";
|
||||
Log::add("warning", $e->getMessage());
|
||||
Log::save("{$this->_viewDatas['title']} {$message}", 'error');
|
||||
log_message("warning", $e->getMessage());
|
||||
log_message("info", "{$this->_viewDatas['title']} {$message}");
|
||||
return alert_CommonHelper($message . "<br>\n{$e->getMessage()}", 'back');
|
||||
}
|
||||
}
|
||||
|
||||
//View 관련
|
||||
protected function view_init()
|
||||
{
|
||||
$this->_viewDatas['fields'] = $this->_defines['view']['fields'];
|
||||
$this->_viewDatas['fieldFilters'] = $this->_defines['view']['fieldFilters'];
|
||||
$this->_viewDatas['fieldRules'] = $this->_defines['view']['fieldRules'];
|
||||
helper(['form']);
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
}
|
||||
protected function view_process($entity)
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function view_procedure($uid)
|
||||
public function view($uid)
|
||||
{
|
||||
try {
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
// dd($entity);
|
||||
$this->view_init();
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('view');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'view');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
helper(['form']);
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
$this->_viewDatas['entity'] = $this->view_process($entity);
|
||||
return view($this->_viewPath . '/view', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
@ -523,42 +420,21 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
|
||||
//Index 관련
|
||||
protected function index_init()
|
||||
{
|
||||
$this->_viewDatas['fields'] = $this->_defines['index']['fields'];
|
||||
$this->_viewDatas['fieldFilters'] = $this->_defines['index']['fieldFilters'];
|
||||
$this->_viewDatas['batchjobFilters'] = $this->_defines['index']['batchjobFilters'];
|
||||
helper(['form']);
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
$this->_session->set(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery());
|
||||
foreach ($this->_viewDatas['fieldFilters'] as $field) {
|
||||
$this->_viewDatas[$field] = $this->request->getVar($field) ? $this->request->getVar($field) : DEFAULTS['EMPTY'];
|
||||
}
|
||||
$this->_viewDatas['word'] = $this->request->getVar('word') ? $this->request->getVar('word') : '';
|
||||
$this->_viewDatas['start'] = $this->request->getVar('start') ? $this->request->getVar('start') : '';
|
||||
$this->_viewDatas['end'] = $this->request->getVar('end') ? $this->request->getVar('end') : '';
|
||||
$this->_viewDatas['order_field'] = $this->request->getVar('order_field') ? $this->request->getVar('order_field') : 'uid';
|
||||
$this->_viewDatas['order_value'] = $this->request->getVar('order_value') ? $this->request->getVar('order_value') : 'DESC';
|
||||
$this->_viewDatas['page'] = $this->request->getVar('page') ? $this->request->getVar('page') : 1;
|
||||
$this->_viewDatas['per_page'] = $this->request->getVar('per_page') ? $this->request->getVar('per_page') : DEFAULTS['PERPAGE'];
|
||||
$this->_viewDatas['uri'] = $this->request->getUri();
|
||||
}
|
||||
//index 모델 전처리
|
||||
protected function index_setCondition()
|
||||
{
|
||||
foreach ($this->_viewDatas['fieldFilters'] as $field) {
|
||||
$value = $this->request->getVar($field) ? $this->request->getVar($field) : false;
|
||||
$value = $this->request->getVar($field) ?: false;
|
||||
if ($value) {
|
||||
$this->_model->where($field, $value);
|
||||
}
|
||||
}
|
||||
$word = $this->request->getVar('word') ? $this->request->getVar('word') : '';
|
||||
$word = $this->request->getVar('word') ?: '';
|
||||
if (isset($word) && $word !== '') {
|
||||
$this->_model->setIndexWordFilter($word);
|
||||
}
|
||||
$start = $this->request->getVar('start') ? $this->request->getVar('start') : '';
|
||||
$end = $this->request->getVar('end') ? $this->request->getVar('end') : '';
|
||||
$start = $this->request->getVar('start') ?: '';
|
||||
$end = $this->request->getVar('end') ?: '';
|
||||
if (isset($start) && $start !== '' && isset($end) && $end !== '') {
|
||||
$this->_model->setIndexDateFilter($start, $end);
|
||||
}
|
||||
@ -571,8 +447,8 @@ abstract class BaseController extends Controller
|
||||
//Rows 처리
|
||||
$this->index_setCondition();
|
||||
//OrderBy
|
||||
$order_field = $this->request->getVar('order_field') ? $this->request->getVar('order_field') : 'uid';
|
||||
$order_value = $this->request->getVar('order_value') ? $this->request->getVar('order_value') : 'DESC';
|
||||
$order_field = $this->request->getVar('order_field') ?: 'uid';
|
||||
$order_value = $this->request->getVar('order_value') ?: 'DESC';
|
||||
$this->_model->setIndexOrderBy($order_field, $order_value);
|
||||
//Limit
|
||||
$rows = $per_page ? $this->_model->findAll($per_page, $page * $per_page - $per_page) : $this->_model->findAll();
|
||||
@ -610,10 +486,28 @@ abstract class BaseController extends Controller
|
||||
//pagenation 처리
|
||||
$this->_viewDatas['pagination'] = $this->index_getPagination();
|
||||
}
|
||||
protected function index_procedure()
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$this->index_init();
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('index');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'index');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_viewDatas['batchjobFilters'] = $this->_model->getFieldBatchFilters();
|
||||
helper(['form']);
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
$this->_session->set(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery());
|
||||
foreach ($this->_viewDatas['fieldFilters'] as $field) {
|
||||
$this->_viewDatas[$field] = $this->request->getVar($field) ?: DEFAULTS['EMPTY'];
|
||||
}
|
||||
$this->_viewDatas['word'] = $this->request->getVar('word') ?: '';
|
||||
$this->_viewDatas['start'] = $this->request->getVar('start') ?: '';
|
||||
$this->_viewDatas['end'] = $this->request->getVar('end') ?: '';
|
||||
$this->_viewDatas['order_field'] = $this->request->getVar('order_field') ?: 'uid';
|
||||
$this->_viewDatas['order_value'] = $this->request->getVar('order_value') ?: 'DESC';
|
||||
$this->_viewDatas['page'] = $this->request->getVar('page') ?: 1;
|
||||
$this->_viewDatas['per_page'] = $this->request->getVar('per_page') ?: DEFAULTS['PERPAGE'];
|
||||
$this->_viewDatas['uri'] = $this->request->getUri();
|
||||
$this->index_process();
|
||||
return view($this->_viewPath . '/index', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
@ -622,12 +516,6 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
|
||||
//Excel 관련
|
||||
protected function excel_init()
|
||||
{
|
||||
$this->_viewDatas['fields'] = $this->_defines['excel']['fields'];
|
||||
$this->_viewDatas['fieldFilters'] = $this->_defines['excel']['fieldFilters'];
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
}
|
||||
protected function excel_spreadSheet()
|
||||
{
|
||||
//Excepl 초기화
|
||||
@ -669,19 +557,17 @@ abstract class BaseController extends Controller
|
||||
// return readfile(PATHS['EXCEL'] . '/' . $fileName);
|
||||
return $writer->save('php://output');
|
||||
}
|
||||
protected function excel_procedure()
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
$this->excel_init();
|
||||
$this->_viewDatas['fields'] = $this->_model->getFields('excel');
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'excel');
|
||||
$this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters();
|
||||
$this->_viewDatas['batchjobFilters'] = $this->_model->getFieldBatchFilters();
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
return $this->excel_process();
|
||||
} catch (\Exception $e) {
|
||||
return alert_CommonHelper($e->getMessage(), 'back');
|
||||
}
|
||||
}
|
||||
|
||||
//File Download관련
|
||||
protected function download_process($path, string $real_filename, string $download_filename = 'download')
|
||||
{
|
||||
return $this->response->download($path . "/" . $real_filename, null)->setFileName($download_filename);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
DROP TABLE IF EXISTS tw_board_config;
|
||||
CREATE TABLE tw_board_config (
|
||||
DROP TABLE IF EXISTS servermgr.tw_board_config;
|
||||
CREATE TABLE servermgr.tw_board_config (
|
||||
uid varchar(36) NOT NULL,
|
||||
name varchar(255) NOT NULL COMMENT '게시판명',
|
||||
isaccess varchar(255) NOT NULL DEFAULT 'manager|cloudflare|director|master' COMMENT '접근권한',
|
||||
@ -17,14 +17,14 @@ CREATE TABLE tw_board_config (
|
||||
PRIMARY KEY (uid)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='게시판 설정정보';
|
||||
|
||||
DROP TABLE IF EXISTS tw_board;
|
||||
DROP TABLE IF EXISTS servermgr.tw_board;
|
||||
-- 1. 게시물 추가전 grpno에 해당하는 기존게시물의 grpord를 +1씩증가 작업
|
||||
-- update tw_board set grporder=grporder+1 where grpno=그룹번호 and grporder > 선택한 grpno
|
||||
-- 2. 게시물 추가시 작업
|
||||
-- insert tw_board grpno=그룹번호,grporder=grporder+1,grpdepth=grpdepth+1
|
||||
-- 3. 게시물 조회시 작업
|
||||
-- select * from tw_board order by grpno desc,grporder asc
|
||||
CREATE TABLE tw_board (
|
||||
CREATE TABLE servermgr.tw_board (
|
||||
uid int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: uid와 Type맞춰야함 , 상위가없을시 기본 uid와 같음',
|
||||
grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 최상위시 1부터시작',
|
||||
@ -34,6 +34,7 @@ CREATE TABLE tw_board (
|
||||
title varchar(255) NOT NULL COMMENT '제목',
|
||||
content text NOT NULL COMMENT '내용',
|
||||
passwd varchar(20) NULL COMMENT '작성자 암호',
|
||||
board_file varchar(255) NULL COMMENT '파일명',
|
||||
view_cnt int(5) NOT NULL DEFAULT 0 COMMENT '조회수',
|
||||
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용, unuse: 사용않함 등등',
|
||||
updated_at timestamp NULL DEFAULT NULL,
|
||||
@ -43,8 +44,8 @@ CREATE TABLE tw_board (
|
||||
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='게시물 정보';
|
||||
|
||||
DROP TABLE IF EXISTS tw_board_file;
|
||||
CREATE TABLE tw_board_file (
|
||||
DROP TABLE IF EXISTS servermgr.tw_board_file;
|
||||
CREATE TABLE servermgr.tw_board_file (
|
||||
uid int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
board_uid int(10) unsigned NOT NULL COMMENT '게시물 정보',
|
||||
mime_type varchar(50) NOT NULL COMMENT 'Mime_Type',
|
||||
|
||||
@ -22,6 +22,10 @@ class BoardEntity extends BaseEntity
|
||||
{
|
||||
return $this->attributes['passwd'];
|
||||
}
|
||||
public function getFile()
|
||||
{
|
||||
return $this->attributes['board_file'];
|
||||
}
|
||||
public function getViews()
|
||||
{
|
||||
return $this->attributes['view_cnt'];
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
use App\Entities\BaseEntity;
|
||||
|
||||
class LoggerEntity extends BaseEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->attributes['uid'];
|
||||
}
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->attributes['title'];
|
||||
}
|
||||
}
|
||||
@ -22,11 +22,11 @@ function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions,
|
||||
case 'isreply':
|
||||
case 'isupload':
|
||||
case 'isdownload':
|
||||
foreach ($fieldFormOptions[$field] as $key => $label) {
|
||||
$checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? $value : explode("|", $value)), $attributes) . $label;
|
||||
}
|
||||
return implode(" ", $checkboxs);
|
||||
break;
|
||||
// foreach ($fieldFormOptions[$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? $value : explode("|", $value)), $attributes) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
// break;
|
||||
case 'status':
|
||||
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
|
||||
return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes);
|
||||
@ -80,15 +80,15 @@ function getFieldFilter_BoardConfigHelper($field, $value, array $fieldFormOption
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'isaccess':
|
||||
case 'isread':
|
||||
case 'iswrite':
|
||||
case 'isreply':
|
||||
case 'isupload':
|
||||
case 'isdownload':
|
||||
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
|
||||
return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes);
|
||||
break;
|
||||
// case 'isaccess':
|
||||
// case 'isread':
|
||||
// case 'iswrite':
|
||||
// case 'isreply':
|
||||
// case 'isupload':
|
||||
// case 'isdownload':
|
||||
// $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
|
||||
// return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes);
|
||||
// break;
|
||||
default:
|
||||
return getFieldForm_BoardConfigHelper($field, $value, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
@ -109,17 +109,17 @@ function getFieldIndex_Row_BoardConfigHelper($field, array $row, array $fieldFil
|
||||
case 'name':
|
||||
return anchor(current_url() . '/view/' . $row['uid'], $row[$field], [...$attributes, "target" => "_self"]);
|
||||
break;
|
||||
case 'isaccess':
|
||||
case 'isread':
|
||||
case 'iswrite':
|
||||
case 'isreply':
|
||||
case 'isupload':
|
||||
case 'isdownload':
|
||||
foreach ($fieldFormOptions[$field] as $key => $label) {
|
||||
$checkboxs[] = form_checkbox($field, $key, in_array($key, explode("|", $row[$field])), $attributes) . $label;
|
||||
}
|
||||
return '<div style="text-align:left; padding-left:%spx;">' . implode("<BR>", $checkboxs) . '</div>';
|
||||
break;
|
||||
// case 'isaccess':
|
||||
// case 'isread':
|
||||
// case 'iswrite':
|
||||
// case 'isreply':
|
||||
// case 'isupload':
|
||||
// case 'isdownload':
|
||||
// foreach ($fieldFormOptions[$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox($field, $key, in_array($key, explode("|", $row[$field])), $attributes) . $label;
|
||||
// }
|
||||
// return '<div style="text-align:left; padding-left:%spx;">' . implode("<BR>", $checkboxs) . '</div>';
|
||||
// break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return isset($row[$field]) ? str_split($row[$field], 10)[0] : "";
|
||||
|
||||
@ -37,7 +37,7 @@ function getFieldForm_BoardHelper($field, $value, array $fieldFormOptions, array
|
||||
case 'content':
|
||||
return form_textarea($field, html_entity_decode($value), [...$attributes, 'class' => 'editor', 'rows' => '20', 'cols' => '100']);
|
||||
break;
|
||||
case 'upload_file':
|
||||
case 'board_file':
|
||||
return form_upload($field);
|
||||
break;
|
||||
default:
|
||||
@ -49,6 +49,13 @@ function getFieldForm_BoardHelper($field, $value, array $fieldFormOptions, array
|
||||
function getFieldView_BoardHelper($field, $entity, array $fieldFilters, array $fieldFormOptions, array $attributes = array())
|
||||
{
|
||||
switch ($field) {
|
||||
case 'board_file':
|
||||
list($origin_filename, $filename) = explode("||", $entity->getFile());
|
||||
if (is_file(WRITEPATH . PATHS['UPLOAD'] . "/" . $origin_filename)) {
|
||||
return "파일이 확인되지 않습니다.";
|
||||
}
|
||||
return $entity->$field ? anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode("||", $entity->$field)[0], [...$attributes, "target" => "_self"]) : "";
|
||||
break;
|
||||
case 'content':
|
||||
return html_entity_decode($entity->$field);
|
||||
break;
|
||||
@ -90,6 +97,9 @@ function getFieldIndex_Row_BoardHelper($field, array $row, array $fieldFilters,
|
||||
anchor(current_url() . '/reply/' . $row['uid'], ICONS['REPLY'], [...$attributes, "target" => "_self"])
|
||||
);
|
||||
break;
|
||||
case 'board_file':
|
||||
return $row[$field] ? anchor(current_url() . '/download/' . $row['uid'], ICONS['IMAGE_FILE'] . explode("||", $row[$field])[0], [...$attributes, "target" => "_self"]) : "";
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return isset($row[$field]) ? str_split($row[$field], 10)[0] : "";
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
function getFieldLabel_LoggerHelper($field, array $fieldRules, array $attributes = array()): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($fieldRules[$field], 'required') !== false) {
|
||||
array_push($attributes, 'style="color:red";');
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", implode(" ", $attributes), lang("Admin/Logger.label.{$field}"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//header.php에서 getFieldForm_Helper사용
|
||||
function getFieldForm_LoggerHelper($field, $value, array $fieldFormOptions, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
case 'status':
|
||||
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/Logger.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
|
||||
return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes);
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
form_input($field, $value, [...$attributes, 'class' => 'calender']);
|
||||
break;
|
||||
default:
|
||||
return form_input($field, $value, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldView_LoggerHelper($field, $entity, array $fieldFilters, array $fieldFormOptions, array $attributes = array())
|
||||
{
|
||||
switch ($field) {
|
||||
case 'content':
|
||||
return html_entity_decode($entity->$field);
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
return getFieldForm_LoggerHelper($field, $entity->$field, $fieldFormOptions, $attributes);
|
||||
}
|
||||
return $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldFilter_LoggerHelper($field, $value, array $fieldFormOptions, array $attributes = array())
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
default:
|
||||
return getFieldForm_LoggerHelper($field, $value, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldIndex_Column_LoggerHelper($field, $order_field, $order_value, array $attributes = array())
|
||||
{
|
||||
$label = lang("Admin/Logger.label.{$field}");
|
||||
$label = $field == $order_field ? sprintf('%s <i class="fa fa-arrow-%s"></i>', $label, $order_value == 'ASC' ? "up" : "down") : $label;
|
||||
$order_value = $order_value == 'DESC' ? "ASC" : "DESC";
|
||||
return anchor(current_url() . "?order_field={$field}&order_value={$order_value}", $label, $attributes);
|
||||
} //
|
||||
|
||||
function getFieldIndex_Row_LoggerHelper($field, array $row, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
return anchor(current_url() . '/view/' . $row['uid'], $row[$field], [...$attributes, "target" => "_self"]);
|
||||
break;
|
||||
case 'user_uid':
|
||||
case 'status':
|
||||
return $fieldFormOptions[$field][$row[$field]];
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return isset($row[$field]) ? str_split($row[$field], 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $row['uid'], $field, $field);
|
||||
return getFieldFilter_LoggerHelper($field, $row[$field], $fieldFormOptions, $attributes);
|
||||
}
|
||||
return $row[$field] ?: DEFAULTS['EMPTY'];
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -17,6 +17,11 @@ function getFieldForm_UserHelper($field, $value, array $fieldFormOptions, array
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'role':
|
||||
// foreach ($fieldFormOptions[$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? $value : explode("|", $value)), $attributes) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
// break;
|
||||
case 'status':
|
||||
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
|
||||
return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes);
|
||||
@ -42,6 +47,12 @@ function getFieldForm_UserHelper($field, $value, array $fieldFormOptions, array
|
||||
function getFieldView_UserHelper($field, $entity, array $fieldFilters, array $fieldFormOptions, array $attributes = array())
|
||||
{
|
||||
switch ($field) {
|
||||
// case 'role':
|
||||
// foreach ($fieldFormOptions[$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode("|", $entity->$field)), $attributes) . $label;
|
||||
// }
|
||||
// return implode(" ", $checkboxs);
|
||||
// break;
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
return getFieldForm_UserHelper($field, $entity->$field, $fieldFormOptions, $attributes);
|
||||
@ -55,6 +66,10 @@ function getFieldFilter_UserHelper($field, $value, array $fieldFormOptions, arra
|
||||
{
|
||||
$value = $value ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
// case 'role':
|
||||
// $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/User.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
|
||||
// return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes);
|
||||
// break;
|
||||
default:
|
||||
return getFieldForm_UserHelper($field, $value, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
@ -75,6 +90,12 @@ function getFieldIndex_Row_UserHelper($field, array $row, array $fieldFilters, $
|
||||
case 'id':
|
||||
return anchor(current_url() . '/view/' . $row['uid'], $row[$field], [...$attributes, "target" => "_self"]);
|
||||
break;
|
||||
// case 'role':
|
||||
// foreach ($fieldFormOptions[$field] as $key => $label) {
|
||||
// $checkboxs[] = form_checkbox($field, $key, in_array($key, explode("|", $row[$field])), $attributes) . $label;
|
||||
// }
|
||||
// return '<div style="text-align:left; padding-left:%spx;">' . implode("<BR>", $checkboxs) . '</div>';
|
||||
// break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
return isset($row[$field]) ? str_split($row[$field], 10)[0] : "";
|
||||
|
||||
@ -13,7 +13,7 @@ return [
|
||||
'passwd' => "암호",
|
||||
'confirmpassword' => "암호확인",
|
||||
'view_cnt' => "조회수",
|
||||
'upload_file' => "UploadFile",
|
||||
'board_file' => "첨부파일",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
'created_at' => "작성일"
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\Log;
|
||||
|
||||
use \App\Models\LoggerModel;
|
||||
|
||||
class DataBase
|
||||
{
|
||||
private $_model = null;
|
||||
public function __construct()
|
||||
{
|
||||
$this->_model = new LoggerModel();
|
||||
}
|
||||
public function save(string $title, string $status, array $logs)
|
||||
{
|
||||
$datas = array(
|
||||
'title' => $title,
|
||||
'status' => $status,
|
||||
'content' => implode("\n", $logs)
|
||||
);
|
||||
return $this->_model->create($datas);
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\Log;
|
||||
|
||||
class Log
|
||||
{
|
||||
private static $_logs = array();
|
||||
private static $_dbInstance = null;
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
final static public function add(string $level, string $content)
|
||||
{
|
||||
$content = date("H:i:s") . "-[{$level}]:{$content}";
|
||||
if ($level !== "debug") {
|
||||
array_push(self::$_logs, $content);
|
||||
}
|
||||
log_message($level, $content);
|
||||
}
|
||||
final static public function save(string $title, string $status = 'success')
|
||||
{
|
||||
if (self::$_dbInstance === null) {
|
||||
self::$_dbInstance = new \App\Libraries\Log\DataBase();
|
||||
}
|
||||
// self::$_dbInstance->save($title, $status, self::$_logs);
|
||||
self::$_logs = array();
|
||||
}
|
||||
}
|
||||
@ -10,36 +10,19 @@ abstract class BaseHierarchyModel extends BaseModel
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
'grpno', 'grporder', 'grpdepth'
|
||||
];
|
||||
$this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth"];
|
||||
}
|
||||
protected function getFields(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
//allowedFields에서 추가했으므로 Controller에는 적용되지 않게하기위함
|
||||
$skips = ['grpno', 'grporder', 'grpdepth', ...$skips];
|
||||
return parent::getFields($fields, $skips);
|
||||
}
|
||||
protected function getFieldFilters(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
//allowedFields에서 추가했으므로 Controller에는 적용되지 않게하기위함
|
||||
$skips = ['grpno', 'grporder', 'grpdepth', ...$skips];
|
||||
return parent::getFieldFilters($fields, $skips);
|
||||
}
|
||||
|
||||
abstract function reply($parent_entity, array $formDatas): BaseEntity;
|
||||
|
||||
protected function getFieldRule(string $field, array $rules): array
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'grpno':
|
||||
case 'grporder':
|
||||
case 'grpdepth':
|
||||
$rules[$field] = 'if_exist|numeric';
|
||||
case "grpno":
|
||||
case "grporder":
|
||||
case "grpdepth":
|
||||
$rules[$field] = "if_exist|numeric";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
@ -49,7 +32,7 @@ abstract class BaseHierarchyModel extends BaseModel
|
||||
{
|
||||
$entity = parent::create_process($entity, $formDatas);
|
||||
//생성시는 grpno가 primarykey와 같음
|
||||
$this->builder()->set('grpno', $entity->getPrimaryKey());
|
||||
$this->builder()->set("grpno", $entity->getPrimaryKey());
|
||||
$this->builder()->where($this->primaryKey, $entity->getPrimaryKey());
|
||||
$this->builder()->update();
|
||||
return $entity;
|
||||
@ -59,10 +42,10 @@ abstract class BaseHierarchyModel extends BaseModel
|
||||
{
|
||||
//부모의 그룹과 grpno가 같고, 부모의 grporder보다 1 큰것을 grporder+1을 해서 update
|
||||
//escape -> false옵션 반드시 있어야함
|
||||
$this->builder()->set('grporder', 'grporder+1', false);
|
||||
$this->builder()->set("grporder", "grporder+1", false);
|
||||
$this->builder()->where([
|
||||
'grpno' => $parent_entity->grpno,
|
||||
'grporder >' => $parent_entity->grporder
|
||||
"grpno" => $parent_entity->grpno,
|
||||
"grporder >" => $parent_entity->grporder
|
||||
]);
|
||||
$this->builder()->update();
|
||||
//reply용 설정
|
||||
|
||||
@ -8,22 +8,22 @@ use App\Entities\BaseEntity;
|
||||
|
||||
abstract class BaseModel extends Model
|
||||
{
|
||||
protected $DBGroup = 'default';
|
||||
protected $table = 'default';
|
||||
protected $primaryKey = 'uid';
|
||||
protected $DBGroup = "default";
|
||||
protected $table = "default";
|
||||
protected $primaryKey = "uid";
|
||||
protected $useAutoIncrement = true;
|
||||
protected $insertID = 0;
|
||||
protected $returnType = 'array'; //object,array,entity명::class
|
||||
protected $returnType = "array"; //object,array,entity명::class
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
protected $dateFormat = "datetime";
|
||||
protected $createdField = "created_at";
|
||||
protected $updatedField = "updated_at";
|
||||
protected $deletedField = "deleted_at";
|
||||
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
@ -44,77 +44,70 @@ abstract class BaseModel extends Model
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedFields = ['updated_at', 'created_at'];
|
||||
$this->allowedFields = ["updated_at", "created_at"];
|
||||
if (!$this->useAutoIncrement) {
|
||||
array_push($this->allowedFields, $this->primaryKey);
|
||||
}
|
||||
$this->validationRules = [];
|
||||
}
|
||||
abstract public function getEntity($uid): BaseEntity;
|
||||
abstract public function getEntitys($where): array;
|
||||
protected function getFields(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
// echo var_export($fields, true);
|
||||
// echo "<HR>";
|
||||
//allowedFields에서 추가했으므로 Controller에는 적용되지 않게하기위함
|
||||
$skips = ['updated_at', 'created_at', ...$skips];
|
||||
$tempFields = array();
|
||||
foreach ($fields as $key => $field) {
|
||||
in_array($field, $skips) ?: array_push($tempFields, $field);
|
||||
}
|
||||
// echo var_export($tempFields, true);
|
||||
// exit;
|
||||
return $tempFields;
|
||||
}
|
||||
protected function getFieldFilters(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
//allowedFields에서 추가했으므로 Controller에는 적용되지 않게하기위함
|
||||
$skips = ['updated_at', 'created_at', ...$skips];
|
||||
$tempFields = array();
|
||||
foreach ($fields as $field) {
|
||||
if (!in_array($field, $skips)) {
|
||||
array_push($tempFields, $field);
|
||||
}
|
||||
}
|
||||
return $tempFields;
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules): array
|
||||
abstract public function getEntitys($conditions): array;
|
||||
abstract public function getFieldFilters(): array;
|
||||
abstract public function getFields(string $action): array;
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
$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}/]';
|
||||
case "user_uid":
|
||||
$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}/]";
|
||||
break;
|
||||
case 'passwd':
|
||||
$rules[$field] = 'if_exist|string';
|
||||
$rules['confirmpassword'] = 'if_exist|string|matches[passwd]';
|
||||
case "passwd":
|
||||
$rules[$field] = "if_exist|trim|string";
|
||||
if (!$action) {
|
||||
$rules["confirmpassword"] = "if_exist|trim|string|matches[passwd]";
|
||||
}
|
||||
break;
|
||||
case 'view_cnt':
|
||||
$rules[$field] = 'if_exist|numeric';
|
||||
case "view_cnt":
|
||||
$rules[$field] = "if_exist|numeric";
|
||||
break;
|
||||
case 'updated_at':
|
||||
case 'created_at':
|
||||
case 'deleted_at':
|
||||
$rules[$field] = 'if_exist|valid_date';
|
||||
case "updated_at":
|
||||
case "created_at":
|
||||
case "deleted_at":
|
||||
$rules[$field] = "if_exist|valid_date";
|
||||
break;
|
||||
default:
|
||||
$rules[$field] = 'if_exist|string';
|
||||
$rules[$field] = "if_exist|string";
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
final public function getFieldRules(array $fields, array $rules = array()): array
|
||||
final public function getFieldRules(array $fields, string $action = ""): array
|
||||
{
|
||||
$rules = array();
|
||||
foreach ($fields as $field) {
|
||||
$rules = $this->getFieldRule($field, $rules);
|
||||
$rules = $this->getFieldRule($field, $rules, $action);
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getFieldBatchFilters(array $skips = array()): array
|
||||
{
|
||||
//allowedFields에서 추가했으므로 Controller에는 적용되지 않게하기위함
|
||||
$fields = array();
|
||||
foreach ($this->getFieldFilters() as $field) {
|
||||
if (!in_array($field, $skips)) {
|
||||
array_push($fields, $field);
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
final public function getPrimaryKey()
|
||||
{
|
||||
return $this->primaryKey;
|
||||
}
|
||||
|
||||
final public function getFieldFormOptions($where, $options = array()): array
|
||||
final public function getFieldFormOptions($conditions, $options = array()): array
|
||||
{
|
||||
foreach ($this->getEntitys($where) as $entity) {
|
||||
foreach ($this->getEntitys($conditions) as $entity) {
|
||||
$options[$entity->getPrimaryKey()] = $entity->getTitle();
|
||||
}
|
||||
return $options;
|
||||
@ -134,7 +127,7 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
|
||||
//View관련 (게시판등의 조회수 증가함수)
|
||||
final public function increaseViewCount($uid, string $field = 'view_cnt', int $cnt = 1)
|
||||
final public function increaseViewCount($uid, string $field = "view_cnt", int $cnt = 1)
|
||||
{
|
||||
//escape -> false옵션 반드시 있어야함
|
||||
$this->builder()->set($field, "{$field}+{$cnt}", false);
|
||||
@ -153,20 +146,20 @@ abstract class BaseModel extends Model
|
||||
$entity->$pk = $this->getUUID();
|
||||
}
|
||||
break;
|
||||
case 'user_uid':
|
||||
case "user_uid":
|
||||
if (array_key_exists($field, $formDatas) && $formDatas[$field]) {
|
||||
$entity->$field = $formDatas[$field];
|
||||
} elseif (session()->get(SESSION_NAMES['ISLOGIN'])) {
|
||||
$auth = session()->get(SESSION_NAMES['AUTH']);
|
||||
$entity->$field = $auth[AUTH_FIELDS['ID']];
|
||||
} elseif (session()->get(SESSION_NAMES["ISLOGIN"])) {
|
||||
$auth = session()->get(SESSION_NAMES["AUTH"]);
|
||||
$entity->$field = $auth[AUTH_FIELDS["ID"]];
|
||||
}
|
||||
break;
|
||||
case 'passwd':
|
||||
case "passwd":
|
||||
if (array_key_exists($field, $formDatas) && $formDatas[$field]) {
|
||||
$entity->$field = password_hash($formDatas[$field], PASSWORD_DEFAULT);
|
||||
}
|
||||
break;
|
||||
case 'content':
|
||||
case "content":
|
||||
if (array_key_exists($field, $formDatas) && $formDatas[$field]) {
|
||||
$entity->$field = htmlentities($formDatas[$field]);
|
||||
}
|
||||
@ -184,8 +177,8 @@ abstract class BaseModel extends Model
|
||||
{
|
||||
if ($entity->hasChanged()) {
|
||||
if (!$this->save($entity)) {
|
||||
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getLastQuery());
|
||||
Log::add("error", implode("\n", $this->errors()));
|
||||
log_message("error", __FUNCTION__ . "에서 호출:" . $this->getLastQuery());
|
||||
log_message("error", implode("\n", $this->errors()));
|
||||
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . var_export($this->errors(), true));
|
||||
}
|
||||
//primaryKey가 자동입력이면
|
||||
@ -200,14 +193,16 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
protected function create_process($entity, array $formDatas)
|
||||
{
|
||||
// echo var_export($this->allowedFields, true);
|
||||
// exit;
|
||||
foreach ($this->allowedFields as $field) {
|
||||
$entity = $this->changeFormData($field, $formDatas, $entity);
|
||||
}
|
||||
// echo var_export($this->allowedFields);
|
||||
// echo "<HR>";
|
||||
// echo var_export($entity);
|
||||
// exit;
|
||||
return $this->save_process($entity);
|
||||
}
|
||||
protected function modify_process($entity, array $formDatas)
|
||||
final protected function modify_process($entity, array $formDatas)
|
||||
{
|
||||
foreach ($this->allowedFields as $field) {
|
||||
if ($field != $this->primaryKey) {
|
||||
@ -219,15 +214,15 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function setIndexWordFilter(string $word)
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
}
|
||||
protected function setIndexDateFilterTrit($start, $end)
|
||||
public function setIndexDateFilterTrit($start, $end)
|
||||
{
|
||||
$this->where('created_at >=', $start);
|
||||
$this->where('created_at <=', $end);
|
||||
$this->where("created_at >=", $start);
|
||||
$this->where("created_at <=", $end);
|
||||
}
|
||||
protected function setIndexOrderBy($field, $order = 'ASC')
|
||||
public function setIndexOrderBy($field, $order = "ASC")
|
||||
{
|
||||
$this->orderBy($field, $order);
|
||||
}
|
||||
|
||||
@ -6,81 +6,96 @@ use App\Entities\BoardConfigEntity;
|
||||
|
||||
class BoardConfigModel extends BaseModel
|
||||
{
|
||||
protected $table = "tw_board_config";
|
||||
protected $useAutoIncrement = false;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->table = 'tw_board_config';
|
||||
$this->useAutoIncrement = false;
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
'uid', 'name', 'isaccess', 'isread', 'iswrite',
|
||||
'isreply', 'isupload', 'isdownload',
|
||||
'status', 'head', 'tail'
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields()];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [
|
||||
"name", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "head", "tail",
|
||||
];
|
||||
$this->validationRules = [
|
||||
...$this->validationRules,
|
||||
...$this->getFieldRules($this->getFields()),
|
||||
];
|
||||
}
|
||||
public function getFields(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
$fields = [...$this->allowedFields, ...$fields];
|
||||
return parent::getFields($fields, ['uid', ...$skips]);
|
||||
}
|
||||
public function getFieldFilters(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
$skips = ['name', 'head', 'tail', ...$skips];
|
||||
return parent::getFieldFilters($fields, $skips);
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'uid':
|
||||
$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}/]';
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [
|
||||
"name", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "created_at"
|
||||
];
|
||||
break;
|
||||
case 'name':
|
||||
$rules[$field] = 'required|trim|string';
|
||||
break;
|
||||
case 'isaccess':
|
||||
case 'isread':
|
||||
case 'iswrite':
|
||||
case 'isreply':
|
||||
case 'isupload':
|
||||
case 'isdownload':
|
||||
$rules[$field] = 'required';
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(array $skips = array()): array
|
||||
{
|
||||
$skips = ["isupload", "isdownload", ...$skips];
|
||||
return parent::getFieldBatchFilters($skips);
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "uid":
|
||||
$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] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "name":
|
||||
$rules[$field] = "required|trim|string";
|
||||
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "isaccess":
|
||||
case "isread":
|
||||
case "iswrite":
|
||||
case "isreply":
|
||||
case "isupload":
|
||||
case "isdownload":
|
||||
$rules[$field] = "required";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getEntity($where): BoardConfigEntity
|
||||
public function getEntity($conditions): BoardConfigEntity
|
||||
{
|
||||
$entity = $this->asObject(BoardConfigEntity::class)->where($where)->first();
|
||||
return $entity ?: throw new \Exception("{$where}의 해당 데이터가 없습니다.\n ");
|
||||
$entity = $this->asObject(BoardConfigEntity::class)->where($conditions)->first();
|
||||
return $entity ?: throw new \Exception("{$conditions}의 해당 데이터가 없습니다.\n ");
|
||||
}
|
||||
public function getEntitys($where): array
|
||||
public function getEntitys($conditions): array
|
||||
{
|
||||
return $this->asObject(BoardConfigEntity::class)->where($where)->findAll();
|
||||
return $this->asObject(BoardConfigEntity::class)->where($conditions)->findAll();
|
||||
}
|
||||
|
||||
protected function changeFormData(string $field, array $formDatas, $entity)
|
||||
{
|
||||
switch ($field) {
|
||||
case 'isaccess':
|
||||
case 'isread':
|
||||
case 'iswrite':
|
||||
case 'isreply':
|
||||
case 'isupload':
|
||||
case 'isdownload':
|
||||
case 'isaccess':
|
||||
case "isaccess":
|
||||
case "isread":
|
||||
case "iswrite":
|
||||
case "isreply":
|
||||
case "isupload":
|
||||
case "isdownload":
|
||||
case "isaccess":
|
||||
if (array_key_exists($field, $formDatas) && $formDatas[$field]) {
|
||||
$entity->$field = is_array($formDatas[$field]) ? implode("|", $formDatas[$field]) : $formDatas[$field];
|
||||
}
|
||||
break;
|
||||
case 'head':
|
||||
case 'tail':
|
||||
case "head":
|
||||
case "tail":
|
||||
if (array_key_exists($field, $formDatas) && $formDatas[$field]) {
|
||||
$entity->$field = htmlentities($formDatas[$field]);
|
||||
}
|
||||
@ -104,15 +119,15 @@ class BoardConfigModel extends BaseModel
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
parent::setIndexWordFilter($word);
|
||||
$this->orLike('name', $word, 'both'); //befor , after , both
|
||||
$this->orLike('isaccess', $word, 'both'); //befor , after , both
|
||||
$this->orLike('isread', $word, 'both'); //befor , after , both
|
||||
$this->orLike('iswrite', $word, 'both'); //befor , after , both
|
||||
$this->orLike('isreply', $word, 'both'); //befor , after , both
|
||||
$this->orLike('isupload', $word, 'both'); //befor , after , both
|
||||
$this->orLike('isdownload', $word, 'both'); //befor , after , both
|
||||
$this->orLike("name", $word, "both"); //befor , after , both
|
||||
$this->orLike("isaccess", $word, "both"); //befor , after , both
|
||||
$this->orLike("isread", $word, "both"); //befor , after , both
|
||||
$this->orLike("iswrite", $word, "both"); //befor , after , both
|
||||
$this->orLike("isreply", $word, "both"); //befor , after , both
|
||||
$this->orLike("isupload", $word, "both"); //befor , after , both
|
||||
$this->orLike("isdownload", $word, "both"); //befor , after , both
|
||||
}
|
||||
public function setIndexOrderBy($field, $order = 'ASC')
|
||||
public function setIndexOrderBy($field, $order = "ASC")
|
||||
{
|
||||
$this->orderBy("name", "ASC");
|
||||
parent::setIndexOrderBy($field, $order);
|
||||
|
||||
@ -6,61 +6,64 @@ use App\Entities\BoardEntity;
|
||||
|
||||
class BoardModel extends BaseHierarchyModel
|
||||
{
|
||||
protected $table = "tw_board";
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->table = 'tw_board';
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
'board_config_uid', 'user_uid', 'title', 'passwd',
|
||||
'upload_file', 'status', 'view_cnt', 'content',
|
||||
];
|
||||
$this->validationRules = [
|
||||
...$this->validationRules,
|
||||
...$this->getFieldRules($this->getFields()),
|
||||
];
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getFields(array $fields = array(), array $skips = array()): array
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [...$this->allowedFields, ...$fields];
|
||||
return parent::getFields($fields, $skips);
|
||||
}
|
||||
public function getFieldFilters(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
$skips = ['title', 'passwd', 'upload_file', 'view_cnt', 'content', ...$skips];
|
||||
return parent::getFieldFilters($fields, $skips);
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'board_config_uid':
|
||||
$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}/]';
|
||||
$fields = ["board_config_uid", "title", "board_file", "passwd", "status", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["board_config_uid", "user_uid", "title", "board_file", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case 'title':
|
||||
case 'content':
|
||||
$rules[$field] = 'required|string';
|
||||
break;
|
||||
case 'upload_file':
|
||||
$rules[$field] = 'if_exist|uploaded[upload_file]|is_image[upload_file]|mime_in[upload_file,image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[upload_file,100]|max_dims[upload_file,1024,768]';
|
||||
break;
|
||||
case 'view_cnt':
|
||||
$rules[$field] = 'if_exist|numeric';
|
||||
case "view":
|
||||
return ["board_config_uid", "user_uid", "title", "board_file", "view_cnt", "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(array $fields = array()): array
|
||||
{
|
||||
return ["board_config_uid", "user_uid", "status", ...$fields];
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "board_config_uid":
|
||||
$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 "title":
|
||||
case "content":
|
||||
$rules[$field] = "required|string";
|
||||
break;
|
||||
case "board_file":
|
||||
$rules[$field] = !$action ? "if_exist|string" : "if_exist|uploaded[{$field}]|is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},100]|max_dims[{$field},1024,768]";
|
||||
break;
|
||||
case "view_cnt":
|
||||
$rules[$field] = "if_exist|numeric";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getEntity($where): BoardEntity
|
||||
public function getEntity($conditions): BoardEntity
|
||||
{
|
||||
$entity = $this->asObject(BoardEntity::class)->where($where)->first();
|
||||
return $entity ?: throw new \Exception("{$where}의 해당 데이터가 없습니다.\n ");
|
||||
$entity = $this->asObject(BoardEntity::class)->where($conditions)->first();
|
||||
return $entity ?: throw new \Exception("{$conditions}의 해당 데이터가 없습니다.\n ");
|
||||
}
|
||||
public function getEntitys($where): array
|
||||
public function getEntitys($conditions): array
|
||||
{
|
||||
return $this->asObject(BoardEntity::class)->where($where)->findAll();
|
||||
return $this->asObject(BoardEntity::class)->where($conditions)->findAll();
|
||||
}
|
||||
public function create(array $formDatas): BoardEntity
|
||||
{
|
||||
@ -79,10 +82,10 @@ class BoardModel extends BaseHierarchyModel
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
parent::setIndexWordFilter($word);
|
||||
$this->orLike('title', $word, 'both');
|
||||
$this->orLike('content', $word, 'both'); //befor , after , both
|
||||
$this->orLike("title", $word, "both");
|
||||
$this->orLike("content", $word, "both"); //befor , after , both
|
||||
}
|
||||
public function setIndexOrderBy($field, $order = 'DESC')
|
||||
public function setIndexOrderBy($field, $order = "DESC")
|
||||
{
|
||||
$this->orderBy("grpno", "DESC");
|
||||
$this->orderBy("grporder", "ASC");
|
||||
|
||||
@ -6,54 +6,84 @@ use App\Entities\HPILOEntity;
|
||||
|
||||
class HPILOModel extends BaseModel
|
||||
{
|
||||
protected $table = 'tw_hpilo';
|
||||
// protected $primaryKey = 'uid';
|
||||
// protected $useAutoIncrement = true;
|
||||
protected $allowedFields = ['customer', 'ip', 'port', 'id', 'passwd', 'model', 'processor', 'memory', 'health', 'power', 'detail', 'status', 'created_at'];
|
||||
protected $validationRules = [
|
||||
'uid' => 'if_exist|numeric',
|
||||
'customer' => 'if_exist|string',
|
||||
'id' => 'if_exist|string',
|
||||
'passwd' => 'if_exist|string',
|
||||
'ip' => 'if_exist|string',
|
||||
'port' => 'if_exist|numeric',
|
||||
'model' => 'if_exist|string',
|
||||
'processor' => 'if_exist|string',
|
||||
'memory' => 'if_exist|numeric',
|
||||
'health' => 'if_exist|string',
|
||||
'power' => 'if_exist|string',
|
||||
'detail' => 'if_exist|string',
|
||||
'status' => 'if_exist|in_list[use,unuse]',
|
||||
'updated_at' => 'if_exist|valid_date',
|
||||
'created_at' => 'if_exist|valid_date',
|
||||
];
|
||||
public function getEntityByField($field, $value): ?HPILOEntity
|
||||
protected $table = "tw_hpilo";
|
||||
public function __construct()
|
||||
{
|
||||
return $this->asObject(HPILOEntity::class)->where($field, $value)->first();
|
||||
parent::__construct();
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), 'model', 'processor', 'memory', 'health', 'power', 'detail',];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getEntity($uid): ?HPILOEntity
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
return $this->getEntityByField($this->primaryKey, $uid);
|
||||
}
|
||||
public function getFieldFormOptions(array $wheres = array(), $temps = array()): array
|
||||
{
|
||||
foreach ($this->asObject(HPILOEntity::class)->where($wheres)->findAll() as $entity) {
|
||||
$temps[$entity->getPrimaryKey()] = $entity->getTitle();
|
||||
$fields = ['customer', 'id', 'passwd', 'ip', 'port', 'status'];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ['customer', 'ip', 'port', 'model', 'processor', 'memory', 'health', 'power', 'status', 'created_at'];
|
||||
break;
|
||||
case "view":
|
||||
return ['customer', 'id', 'ip', 'port', 'model', 'processor', 'memory', 'health', 'power', 'detail', 'status', 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
return $temps;
|
||||
}
|
||||
public function create(array $datas): HPILOEntity
|
||||
public function getFieldFilters(array $fields = array()): array
|
||||
{
|
||||
return $this->create_process(new HPILOEntity($datas));
|
||||
return ["status", ...$fields];
|
||||
}
|
||||
public function modify(HPILOEntity $entity, array $datas): HPILOEntity
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
foreach ($datas as $field => $value) {
|
||||
if ($entity->$field != $datas[$field]) {
|
||||
$entity->$field = $value;
|
||||
}
|
||||
switch ($field) {
|
||||
case "customer":
|
||||
$rules[$field] = "required|trim|string";
|
||||
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "passwd":
|
||||
$rules[$field] = "required|trim|string";
|
||||
$rules["confirmpassword"] = "required|trim|string|matches[passwd]";
|
||||
break;
|
||||
case "model":
|
||||
case "processor":
|
||||
case "memory":
|
||||
case "health":
|
||||
case "power":
|
||||
case "detail":
|
||||
$rules[$field] = "required|string";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $this->modify_process($entity);
|
||||
return $rules;
|
||||
}
|
||||
public function getEntity($conditions): HPILOEntity
|
||||
{
|
||||
$entity = $this->asObject(HPILOEntity::class)->where($conditions)->first();
|
||||
return $entity ?: throw new \Exception("{$conditions}의 해당 정보가 없습니다.\n ");
|
||||
}
|
||||
public function getEntitys($conditions): array
|
||||
{
|
||||
return $this->asObject(HPILOEntity::class)->where($conditions)->findAll();
|
||||
}
|
||||
|
||||
protected function changeFormData(string $field, array $formDatas, $entity)
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
return parent::changeFormData($field, $formDatas, $entity);
|
||||
break;
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function create(array $formDatas): HPILOEntity
|
||||
{
|
||||
return $this->create_process(new HPILOEntity(), $formDatas);
|
||||
}
|
||||
public function modify(HPILOEntity $entity, array $formDatas): HPILOEntity
|
||||
{
|
||||
return $this->modify_process($entity, $formDatas);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Entities\LoggerEntity;
|
||||
|
||||
class LoggerModel extends BaseModel
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->table = 'tw_logger';
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
...$this->getFields(),
|
||||
];
|
||||
$this->validationRules = [
|
||||
...$this->validationRules,
|
||||
...$this->getFieldRules($this->getFields()),
|
||||
];
|
||||
}
|
||||
public function getFields(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
$fields = ['user_uid', 'title', 'content', 'status', ...$fields];
|
||||
return parent::getFields($fields, $skips);
|
||||
}
|
||||
public function getFieldFilters(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
$fields = ['user_uid', 'status', ...$fields];
|
||||
return parent::getFieldFilters($fields, $skips);
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'content':
|
||||
case 'status':
|
||||
$rules[$field] = 'required|string';
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function getEntity($where): LoggerEntity
|
||||
{
|
||||
$entity = $this->asObject(LoggerEntity::class)->where($where)->first();
|
||||
return $entity ?: throw new \Exception("{$where}의 해당 데이터가 없습니다.\n ");
|
||||
}
|
||||
public function getEntitys($where): array
|
||||
{
|
||||
return $this->asObject(LoggerEntity::class)->where($where)->findAll();
|
||||
}
|
||||
public function create(array $formDatas): LoggerEntity
|
||||
{
|
||||
return $this->create_process(new LoggerEntity(), $formDatas);
|
||||
}
|
||||
public function modify(LoggerEntity $entity, array $formDatas): LoggerEntity
|
||||
{
|
||||
return $this->modify_process($entity, $formDatas);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
parent::setIndexWordFilter($word);
|
||||
$this->orLike('title', $word, 'both');
|
||||
$this->orLike('content', $word, 'both'); //befor , after , both
|
||||
}
|
||||
}
|
||||
@ -6,67 +6,87 @@ use App\Entities\UserEntity;
|
||||
|
||||
class UserModel extends BaseModel
|
||||
{
|
||||
protected $table = "tw_user";
|
||||
protected $useAutoIncrement = false;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->table = 'tw_user';
|
||||
$this->useAutoIncrement = false;
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
'uid',
|
||||
...$this->getFields(),
|
||||
];
|
||||
$this->validationRules = [
|
||||
...$this->validationRules,
|
||||
...$this->getFieldRules($this->getFields()),
|
||||
];
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields()];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getFields(array $fields = array(), array $skips = array()): array
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ['id', 'email', 'passwd', 'name', 'role', 'status', ...$fields];
|
||||
return parent::getFields($fields, $skips);
|
||||
}
|
||||
public function getFieldFilters(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
$fields = ['user_uid', 'status', ...$fields];
|
||||
return parent::getFieldFilters($fields, $skips);
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'uid':
|
||||
$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}/]';
|
||||
$fields = ["id", "passwd", "name", "email", "role", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["id", "name", "email", "role", "status", 'created_at'];
|
||||
break;
|
||||
case 'id':
|
||||
$rules[$field] = 'required|trim|min_length[4]|max_length[20]';
|
||||
break;
|
||||
case 'passwd':
|
||||
$rules[$field] = 'required|string';
|
||||
$rules['confirmpassword'] = 'if_exist|string|matches[passwd]';
|
||||
break;
|
||||
case 'name':
|
||||
$rules[$field] = 'required|trim|string';
|
||||
break;
|
||||
case 'email':
|
||||
$rules[$field] = 'required|valid_email';
|
||||
break;
|
||||
case 'role':
|
||||
$rules[$field] = 'required|string';
|
||||
case "view":
|
||||
return ["id", "name", "email", "role", "status", 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(array $fields = array()): array
|
||||
{
|
||||
return ["role", "status", ...$fields];
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "uid":
|
||||
$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] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "id":
|
||||
$rules[$field] = "required|trim|min_length[4]|max_length[20]";
|
||||
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "passwd":
|
||||
$rules[$field] = "required|trim|string";
|
||||
$rules["confirmpassword"] = "required|trim|string|matches[passwd]";
|
||||
break;
|
||||
case "name":
|
||||
$rules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "email":
|
||||
$rules[$field] = "required|trim|valid_email";
|
||||
break;
|
||||
case "role":
|
||||
$rules[$field] = "required|string";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getEntity($where): UserEntity
|
||||
public function getEntity($conditions): UserEntity
|
||||
{
|
||||
$entity = $this->asObject(UserEntity::class)->where($where)->first();
|
||||
return $entity ?: throw new \Exception("{$where}의 해당 사용자가 없습니다.\n ");
|
||||
$entity = $this->asObject(UserEntity::class)->where($conditions)->first();
|
||||
return $entity ?: throw new \Exception("{$conditions}의 해당 사용자가 없습니다.\n ");
|
||||
}
|
||||
public function getEntitys($where): array
|
||||
public function getEntitys($conditions): array
|
||||
{
|
||||
return $this->asObject(UserEntity::class)->where($where)->findAll();
|
||||
return $this->asObject(UserEntity::class)->where($conditions)->findAll();
|
||||
}
|
||||
|
||||
protected function changeFormData(string $field, array $formDatas, $entity)
|
||||
{
|
||||
switch ($field) {
|
||||
case "role":
|
||||
if (array_key_exists($field, $formDatas) && $formDatas[$field]) {
|
||||
$entity->$field = is_array($formDatas[$field]) ? implode("|", $formDatas[$field]) : $formDatas[$field];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return parent::changeFormData($field, $formDatas, $entity);
|
||||
break;
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function create(array $formDatas): UserEntity
|
||||
{
|
||||
@ -81,10 +101,10 @@ class UserModel extends BaseModel
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
parent::setIndexWordFilter($word);
|
||||
$this->orLike('id', $word, 'both');
|
||||
$this->orLike('name', $word, 'both'); //befor , after , both
|
||||
$this->orLike("id", $word, "both");
|
||||
$this->orLike("name", $word, "both"); //befor , after , both
|
||||
}
|
||||
public function setIndexOrderBy($field, $order = 'ASC')
|
||||
public function setIndexOrderBy($field, $order = "ASC")
|
||||
{
|
||||
$this->orderBy("name", "ASC");
|
||||
parent::setIndexOrderBy($field, $order);
|
||||
|
||||
@ -6,59 +6,66 @@ use App\Entities\UserSNSEntity;
|
||||
|
||||
class UserSNSModel extends BaseModel
|
||||
{
|
||||
protected $table = "tw_user_sns";
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->table = 'tw_user_sns';
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
...$this->getFields()
|
||||
];
|
||||
$this->validationRules = [
|
||||
...$this->validationRules,
|
||||
...$this->getFieldRules($this->getFields()),
|
||||
];
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getFields(array $fields = array(), array $skips = array()): array
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ['user_uid', 'site', 'id', 'name', 'email', 'detail', 'status', ...$fields];
|
||||
return parent::getFields($fields, $skips);
|
||||
}
|
||||
public function getFieldFilters(array $fields = array(), array $skips = array()): array
|
||||
{
|
||||
$fields = ['user_uid', 'status', ...$fields];
|
||||
return parent::getFieldFilters($fields, $skips);
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'id':
|
||||
case 'name':
|
||||
$rules[$field] = 'required|trim|string';
|
||||
$fields = ["site", "id", "name", "email", "detail", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", "site", "id", "name", "email", "status", "created_at"];
|
||||
break;
|
||||
case 'email':
|
||||
$rules[$field] = 'required|valid_email';
|
||||
break;
|
||||
case 'detail':
|
||||
$rules[$field] = 'if_exist|string';
|
||||
break;
|
||||
case 'status':
|
||||
$rules[$field] = 'required|string';
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules);
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(array $fields = array()): array
|
||||
{
|
||||
return ["status", ...$fields];
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
case "id":
|
||||
$rules[$field] = "required|trim|string";
|
||||
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "name":
|
||||
$rules[$field] = "required|trim|string";
|
||||
break;
|
||||
case "email":
|
||||
$rules[$field] = "required|valid_email";
|
||||
break;
|
||||
case "detail":
|
||||
$rules[$field] = "if_exist|string";
|
||||
break;
|
||||
case "status":
|
||||
$rules[$field] = "required|string";
|
||||
break;
|
||||
default:
|
||||
$rules = parent::getFieldRule($field, $rules, $action);
|
||||
break;
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getEntity($where): UserSNSEntity
|
||||
public function getEntity($conditions): UserSNSEntity
|
||||
{
|
||||
$entity = $this->asObject(UserSNSEntity::class)->where($where)->first();
|
||||
return $entity ?: throw new \Exception("{$where}의 해당 데이터가 없습니다.\n ");
|
||||
$entity = $this->asObject(UserSNSEntity::class)->where($conditions)->first();
|
||||
return $entity ?: throw new \Exception("{$conditions}의 해당 데이터가 없습니다.\n ");
|
||||
}
|
||||
public function getEntitys($where): array
|
||||
public function getEntitys($conditions): array
|
||||
{
|
||||
return $this->asObject(UserSNSEntity::class)->where($where)->findAll();
|
||||
return $this->asObject(UserSNSEntity::class)->where($conditions)->findAll();
|
||||
}
|
||||
|
||||
public function create(array $formDatas): UserSNSEntity
|
||||
@ -74,10 +81,10 @@ class UserSNSModel extends BaseModel
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
parent::setIndexWordFilter($word);
|
||||
$this->orLike('name', $word, 'both');
|
||||
$this->orLike('email', $word, 'both'); //befor , after , both
|
||||
$this->orLike("name", $word, "both");
|
||||
$this->orLike("email", $word, "both"); //befor , after , both
|
||||
}
|
||||
public function setIndexOrderBy($field, $order = 'ASC')
|
||||
public function setIndexOrderBy($field, $order = "ASC")
|
||||
{
|
||||
$this->orderBy("name", "ASC");
|
||||
parent::setIndexOrderBy($field, $order);
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<?= $this->include('templates/admin/header'); ?>
|
||||
<div class="indexTable_wrapper">
|
||||
<div class="indexTable_head">
|
||||
<?= form_open(current_url(), array("method" => "get")) ?>
|
||||
<ul class="nav">
|
||||
조건검색:<?php foreach ($fieldFilters as $field) : ?><li class="nav-item"><?= getFieldFilter_LoggerHelper($field, $$field, $fieldFormOptions) ?></li><?php endforeach; ?>
|
||||
<?= $this->include('templates/admin/index_head'); ?>
|
||||
</ul>
|
||||
<?= form_close(); ?>
|
||||
</div>
|
||||
<div class="indexTable_body">
|
||||
<?= form_open(current_url() . '/batchjob', $forms['attributes'], $forms['hiddens']) ?>
|
||||
<table class="table table-bordered table-hover table-striped indexTable ">
|
||||
<tr>
|
||||
<td>번호</td>
|
||||
<?php foreach ($fields as $field) : ?><td><?= getFieldIndex_Column_LoggerHelper($field, $order_field, $order_value) ?></td><?php endforeach; ?>
|
||||
</tr>
|
||||
<?php $i = 0; ?>
|
||||
<?php foreach ($rows as $row) : ?>
|
||||
<tr id="<?= $row['uid'] ?>" onClick="indexRowCheckBoxToggle(this);">
|
||||
<td>
|
||||
<?= form_checkbox(["id" => "checkbox_uid_{$row['uid']}", "name" => "batchjob_uids[]", "value" => $row['uid'], "class" => "batchjobuids_checkboxs"]); ?>
|
||||
<?= $total_count - (($page - 1) * $per_page + $i) ?>
|
||||
</td>
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<td nowrap><?= getFieldIndex_Row_LoggerHelper($field, $row, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php $i++; ?>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($batchjobFilters as $field) : ?><li class="nav-item"><?= getFieldFilter_LoggerHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?></li><?php endforeach; ?>
|
||||
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?></li>
|
||||
</ul>
|
||||
<?= form_close(); ?>
|
||||
</div>
|
||||
<div class="indexTable_tail">
|
||||
<?= $pagination ?>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->include('templates/admin/footer'); ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,15 +0,0 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<?= $this->include('templates/admin/header'); ?>
|
||||
<table class="table table-bordered table-hover table-striped indexTable ">
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<tr>
|
||||
<td nowrap style="background-color:#e8ebe9; width:10%; text-align:right; padding-right:20px;">
|
||||
<?= getFieldLabel_LoggerHelper($field,$fieldRules) ?>
|
||||
</td>
|
||||
<td style="text-align:left; padding-left:20px;"><?= getFieldView_LoggerHelper($field,$entity,$fieldFilters,$fieldFormOptions) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?= $this->include('templates/admin/footer'); ?>
|
||||
<?= $this->endSection() ?>
|
||||
Loading…
Reference in New Issue
Block a user