servermgrv2 init...
This commit is contained in:
parent
00805c8b4e
commit
f53a847780
@ -149,6 +149,7 @@ define('SESSION_NAMES', [
|
||||
'RETURN_URL' => "return_url",
|
||||
'ISLOGIN' => "islogined",
|
||||
'AUTH' => 'auth',
|
||||
'CART' => 'cart'
|
||||
]);
|
||||
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
|
||||
|
||||
|
||||
@ -39,6 +39,10 @@ $routes->get('/login', 'AuthController::login');
|
||||
$routes->post('/signup', 'AuthController::signup/local');
|
||||
$routes->get('/signup/(:alpha)', 'AuthController::signup/$1');
|
||||
$routes->get('/logout', 'AuthController::logout');
|
||||
$routes->group('cart', ['namespace' => 'App\Controllers'], static function ($routes) {
|
||||
$routes->post('addCart', 'CartController::addCart');
|
||||
$routes->get('cancelCart/(:uuid)', 'CartController::cancelCart/$1');
|
||||
});;
|
||||
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
|
||||
});
|
||||
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
|
||||
@ -91,10 +95,23 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->post('batchjob', 'BoardController::batchjob');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$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::reload/$1');
|
||||
});
|
||||
});
|
||||
$routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
});
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
|
||||
@ -36,14 +36,15 @@ $routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}
|
||||
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->get('/login', 'AuthController::login');
|
||||
$routes->post('/signin', 'AuthController::signin/local');
|
||||
$routes->get('/signin/(:alpha)', 'AuthController::signin/$1');
|
||||
$routes->post('/signup', 'AuthController::signup/local');
|
||||
$routes->get('/signup/(:alpha)', 'AuthController::signup/$1');
|
||||
$routes->get('/logout', 'AuthController::logout');
|
||||
$routes->group('cart', ['namespace' => 'App\Controllers'], static function ($routes) {
|
||||
$routes->post('addCart', 'CartController::addCart');
|
||||
$routes->get('cancelCart/(:uuid)', 'CartController::cancelCart/$1');
|
||||
});;
|
||||
$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');
|
||||
@ -65,6 +66,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->get('view/(:num)', 'UserSNSController::view/$1');
|
||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1');
|
||||
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'UserSNSController::batchjob');
|
||||
});
|
||||
$routes->group('boardconfig', static function ($routes) {
|
||||
$routes->get('', 'BoardConfigController::index');
|
||||
@ -91,7 +93,7 @@ $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->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('hpilo', static function ($routes) {
|
||||
$routes->get('', 'HPILOController::index');
|
||||
@ -109,6 +111,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->get('reload/(:num)', 'HPILOController::reload/$1');
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Additional Routing
|
||||
|
||||
@ -29,32 +29,4 @@ class Services extends BaseService
|
||||
* return new \CodeIgniter\Example();
|
||||
* }
|
||||
*/
|
||||
public static function user($getShared = true)
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance('user');
|
||||
}
|
||||
return new \App\Backend\UserBackend();
|
||||
}
|
||||
public static function usersns($getShared = true)
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance('usersns');
|
||||
}
|
||||
return new \App\Backend\UserSNSBackend();
|
||||
}
|
||||
public static function board($getShared = true)
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance('board');
|
||||
}
|
||||
return new \App\Backend\BoardBackend();
|
||||
}
|
||||
public static function boardconfig($getShared = true)
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance('boardconfig');
|
||||
}
|
||||
return new \App\Backend\BoardConfigBackend();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\BoardConfigModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -10,8 +11,41 @@ class BoardConfigController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_backend = service('boardconfig');
|
||||
$this->_model = new BoardConfigModel();
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_backend->getClassName());
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [
|
||||
'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "head", "tail",
|
||||
];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [
|
||||
'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "created_at"
|
||||
];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\BoardConfigModel;
|
||||
use App\Models\BoardModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -10,11 +12,37 @@ class BoardController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_backend = service('board');
|
||||
$this->_model = new BoardModel();
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_backend->getClassName());
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$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 "view":
|
||||
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["board_config_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\UserModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -10,9 +11,11 @@ class UserController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_backend = service('user');
|
||||
$this->_model = new UserModel();
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_backend->getClassName());
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
|
||||
//Field별 Form Datas 처리용
|
||||
@ -29,4 +32,29 @@ class UserController extends AdminController
|
||||
}
|
||||
return $this->_viewDatas['fieldDatas'];
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["id", "passwd", 'name', "email", "role", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["id", 'name', "email", "role", "status", 'created_at'];
|
||||
break;
|
||||
case "view":
|
||||
return ["id", 'name', "email", "role", "status", 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["role", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\UserSNSModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@ -10,8 +11,34 @@ class UserSNSController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_backend = service('usersns');
|
||||
$this->_model = new UserSNSModel();
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_backend->getClassName());
|
||||
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
helper($this->_model->getClassName());
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$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 "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,18 +3,51 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\Adapter\Auth\Adapter;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class AuthController extends BaseController
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $helpers = ['Common'];
|
||||
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
private $_session = null;
|
||||
private $_viewDatas = array();
|
||||
private $_adapters = array();
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_backend = service('user');
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_backend->getClassName());
|
||||
$this->_session = \Config\Services::session();
|
||||
$this->_viewDatas['title'] = 'Auth';
|
||||
$this->_viewDatas['layout'] = LAYOUTS['empty'];
|
||||
$this->_viewDatas['session'] = $this->_session;
|
||||
$this->initAdapters();
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
|
||||
use App\Models\UserModel;
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\Files\UploadedFile;
|
||||
@ -48,7 +49,7 @@ abstract class BaseController extends Controller
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
protected $_backend = null;
|
||||
protected $_model = null;
|
||||
protected $_session = null;
|
||||
protected $_viewPath = '';
|
||||
protected $_viewDatas = array();
|
||||
@ -60,11 +61,15 @@ abstract class BaseController extends Controller
|
||||
// E.g.: $this->session = \Config\Services::session();
|
||||
$this->_session = \Config\Services::session();
|
||||
$this->_viewDatas['layout'] = LAYOUTS['empty'];
|
||||
$this->_viewDatas['title'] = lang($this->_backend->getClassName() . '.title');
|
||||
$this->_viewDatas['session'] = $this->_session;
|
||||
helper($this->_backend->getClassName());
|
||||
}
|
||||
|
||||
abstract public function getFields(string $action): array;
|
||||
abstract public function getFieldFilters(): array;
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return $this->getFieldFilters();
|
||||
}
|
||||
//Field별 Form Datas 처리용
|
||||
protected function getFieldFormData(string $field, $entity = null): array
|
||||
{
|
||||
@ -121,15 +126,14 @@ abstract class BaseController extends Controller
|
||||
$action = 'update';
|
||||
break;
|
||||
}
|
||||
$this->_viewDatas['fields'] = $fields ?: $this->_backend->getFields($action);
|
||||
$this->_viewDatas['fieldRules'] = $this->_backend->getFieldRules($this->_viewDatas['fields'], $action);
|
||||
$this->_viewDatas['fieldFilters'] = $this->_backend->getFieldFilters();
|
||||
$this->_viewDatas['batchjobFilters'] = $this->_backend->getFieldBatchFilters();
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->_backend->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
$this->_viewDatas['fields'] = $fields ?: $this->getFields($action);
|
||||
$this->_viewDatas['fieldFilters'] = $this->getFieldFilters();
|
||||
$this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters();
|
||||
$this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action);
|
||||
$this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']);
|
||||
return $this->_viewDatas;
|
||||
}
|
||||
|
||||
|
||||
//Insert관련
|
||||
final public function insert_form()
|
||||
{
|
||||
@ -140,10 +144,11 @@ abstract class BaseController extends Controller
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/insert', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']))->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function insert_process()
|
||||
protected function insert_validate()
|
||||
{
|
||||
//fieldData Rule 검사
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
@ -155,13 +160,17 @@ abstract class BaseController extends Controller
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
|
||||
}
|
||||
}
|
||||
protected function insert_process()
|
||||
{
|
||||
return $this->_model->create($this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
public function insert()
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$this->insert_process();
|
||||
$entity = $this->_backend->insert($this->_viewDatas['fieldDatas']);
|
||||
$this->insert_validate();
|
||||
$entity = $this->insert_process();
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.";
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
@ -180,14 +189,15 @@ abstract class BaseController extends Controller
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
$this->_viewDatas['entity'] = $this->_backend->getEntity($uid);
|
||||
$$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
$this->_viewDatas['entity'] = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
return view($this->_viewPath . '/update', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']))->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function update_process()
|
||||
protected function update_validate($entity)
|
||||
{
|
||||
//fieldData Rule 검사
|
||||
if (!$this->validate($this->_viewDatas['fieldRules'])) {
|
||||
@ -196,21 +206,25 @@ abstract class BaseController extends Controller
|
||||
//fieldData 적용
|
||||
$this->_viewDatas['fieldDatas'] = array();
|
||||
foreach ($this->_viewDatas['fields'] as $field) {
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $this->_viewDatas['entity']);
|
||||
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
|
||||
log_message(
|
||||
"info",
|
||||
"{$field} : {$this->_viewDatas['entity']->$field} => " . var_export($this->_viewDatas['fieldDatas'][$field])
|
||||
"{$field} : {$entity->$field} => " . var_export($this->_viewDatas['fieldDatas'][$field])
|
||||
);
|
||||
}
|
||||
}
|
||||
protected function update_process($entity)
|
||||
{
|
||||
return $this->_model->modify($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
public function update($uid)
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$entity = $this->_viewDatas['entity'] = $this->_backend->getEntity($uid);
|
||||
$this->update_process();
|
||||
$entity = $this->_backend->update($entity, $this->_viewDatas['fieldDatas']);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->update_validate($entity);
|
||||
$entity = $this->update_process($entity);
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.";
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
@ -230,29 +244,34 @@ abstract class BaseController extends Controller
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
helper(['form']);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
$entity = $this->_backend->getEntity($uid);
|
||||
$titleField = $this->_backend->getTitleField();
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$titleField = $this->_model->getTitleField();
|
||||
$entity->$titleField = "RE: " . $entity->$titleField;
|
||||
$contentField = $this->_backend->getContentField();
|
||||
$contentField = $this->_model->getContentField();
|
||||
$entity->$contentField .= "\n----------------------------------------------\n";
|
||||
$this->_viewDatas['entity'] = $entity;
|
||||
return view($this->_viewPath . '/reply', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']))->with('return_message', $e->getMessage());
|
||||
}
|
||||
}
|
||||
protected function reply_process()
|
||||
protected function reply_validate($entity)
|
||||
{
|
||||
$this->update_process();
|
||||
$this->update_validate($entity);
|
||||
}
|
||||
protected function reply_process($entity)
|
||||
{
|
||||
return $this->_model->reply($entity, $this->_viewDatas['fieldDatas']);
|
||||
}
|
||||
public function reply($uid)
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
$entity = $this->_viewDatas['entity'] = $this->_backend->getEntity($uid);
|
||||
$this->reply_process();
|
||||
$entity = $this->_backend->reply($entity, $this->_viewDatas['fieldDatas']);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->reply_validate($entity);
|
||||
$entity = $this->reply_process($entity);
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.";
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
@ -265,31 +284,40 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
|
||||
//Toggle 관련
|
||||
protected function toggle_process()
|
||||
protected function toggle_validate($entity)
|
||||
{
|
||||
$this->update_process();
|
||||
$this->update_validate($entity);
|
||||
}
|
||||
protected function toggle_process($entity)
|
||||
{
|
||||
return $this->update_process($entity);
|
||||
}
|
||||
public function toggle($uid, string $field)
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas = $this->init(__FUNCTION__, [$field]);
|
||||
$entity = $this->_viewDatas['entity'] = $this->_backend->getEntity($uid);
|
||||
$this->toggle_process();
|
||||
$entity = $this->_backend->update($entity, $this->_viewDatas['fieldDatas']);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->toggle_validate($entity);
|
||||
$entity = $this->toggle_process($entity);
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.";
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage();
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} finally {
|
||||
$this->_session->setFlashdata("return_message", $msg);
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
}
|
||||
}
|
||||
//Batchjob 관련
|
||||
protected function batchjob_process()
|
||||
protected function batchjob_validate($entity)
|
||||
{
|
||||
$this->update_process();
|
||||
$this->update_validate($entity);
|
||||
}
|
||||
protected function batchjob_process($entity)
|
||||
{
|
||||
return $this->update_process($entity);
|
||||
}
|
||||
public function batchjob()
|
||||
{
|
||||
@ -299,7 +327,7 @@ abstract class BaseController extends Controller
|
||||
try {
|
||||
//fields 해당하는 field중 선택된 값이 있는경우만 fields로 정의
|
||||
$fields = array();
|
||||
foreach ($this->_backend->getFieldBatchFilters() as $field) {
|
||||
foreach ($this->_model->getFieldBatchFilters() as $field) {
|
||||
if ($this->request->getVar($field)) {
|
||||
array_push($fields, $field);
|
||||
}
|
||||
@ -309,15 +337,15 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
$this->_viewDatas = $this->init(__FUNCTION__, $fields);
|
||||
$uids = $this->request->getVar('batchjob_uids') ?: throw new \Exception($this->_viewDatas['title'] . '에서 변경할 항목(uid)이 선택되지 않았습니다.');
|
||||
|
||||
$cnt = 1;
|
||||
//Transaction 시작
|
||||
$this->_backend->transStart();
|
||||
$this->_model->transStart();
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entity = $this->_viewDatas['entity'] = $this->_backend->getEntity($uid);
|
||||
$this->batchjob_process();
|
||||
array_push($entitys, $this->_backend->update($entity, $this->_viewDatas['fieldDatas']));
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->batchjob_validate($entity);
|
||||
$entity = $this->batchjob_process($entity);
|
||||
array_push($entitys, $this->_model->modify($entity, $this->_viewDatas['fieldDatas']));
|
||||
array_push($batchjobs, "{$cnt}. {$uid}->{$entity->getTitle()}는 완료.");
|
||||
} catch (\Exception $e) {
|
||||
array_push($batchjobs, "{$cnt}. {$uid}는 실패.");
|
||||
@ -325,16 +353,17 @@ abstract class BaseController extends Controller
|
||||
$cnt++;
|
||||
}
|
||||
//Transaction Commit
|
||||
$this->_backend->transCommit();
|
||||
$this->_model->transComplete();
|
||||
$msg = sprintf(
|
||||
"%s에서 총:%s개의 %s 완료하였습니다.",
|
||||
$this->_viewDatas['title'],
|
||||
count($entitys),
|
||||
__FUNCTION__
|
||||
);
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
//Transaction Rollback
|
||||
$this->_backend->transRollback();
|
||||
$this->_model->transRollback();
|
||||
log_message('error', sprintf("---------batchjob 작업결과--------\n%s\n", implode("\n", $batchjobs)));
|
||||
return sprintf(
|
||||
"총:%s개의 작업중 %s개는 성공하였지만 , %s개가 실패하여 %s 취소되었습니다.\n%s",
|
||||
@ -344,25 +373,36 @@ abstract class BaseController extends Controller
|
||||
__FUNCTION__,
|
||||
);
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} finally {
|
||||
$this->_session->setFlashdata("return_message", $msg);
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
}
|
||||
}
|
||||
|
||||
//Delete 관련
|
||||
protected function delete_process($entity)
|
||||
{
|
||||
if (!$this->_model->delete($entity->getPrimaryKey())) {
|
||||
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;
|
||||
}
|
||||
public function delete($uid)
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$entity = $this->_backend->delete($this->_backend->getEntity($uid));
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->delete_process($entity);
|
||||
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 " . __FUNCTION__ . " 완료하였습니다.";
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} catch (\Exception $e) {
|
||||
$msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage();
|
||||
log_message("error", $e->getMessage());
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
} finally {
|
||||
$this->_session->setFlashdata("return_message", $msg);
|
||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']));
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,8 +417,7 @@ abstract class BaseController extends Controller
|
||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||
helper(['form']);
|
||||
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
||||
$entity = $this->_viewDatas['entity'] = $this->_backend->getEntity($uid);
|
||||
$this->_viewDatas['entity'] = $this->_backend->view($entity);
|
||||
$this->_viewDatas['entity'] = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
|
||||
return view($this->_viewPath . '/view', $this->_viewDatas);
|
||||
} catch (\Exception $e) {
|
||||
@ -387,26 +426,7 @@ abstract class BaseController extends Controller
|
||||
}
|
||||
|
||||
//Index 관련
|
||||
private function index_getPagination($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): string
|
||||
{
|
||||
// 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성
|
||||
// 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full',
|
||||
// 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가
|
||||
$pager = \Config\Services::pager();
|
||||
// $this->_backend->paginate($this->_viewDatas['per_page'], $pager_group, $this->_viewDatas['page'], $segment);
|
||||
$pager->makeLinks(
|
||||
$this->_viewDatas['page'],
|
||||
$this->_viewDatas['per_page'],
|
||||
$this->_viewDatas['total_count'],
|
||||
$template,
|
||||
$segment,
|
||||
$pager_group
|
||||
);
|
||||
$this->_viewDatas['page'] = $pager->getCurrentPage($pager_group);
|
||||
$this->_viewDatas['total_page'] = $pager->getPageCount($pager_group);
|
||||
return $pager->links($pager_group, $template);
|
||||
}
|
||||
private function index_setCondition()
|
||||
protected function index_setCondition()
|
||||
{
|
||||
//조건절 처리
|
||||
$filterFields = array();
|
||||
@ -420,12 +440,34 @@ abstract class BaseController extends Controller
|
||||
$end = $this->request->getVar('end');
|
||||
$order_field = $this->request->getVar('order_field');
|
||||
$order_value = $this->request->getVar('order_value');
|
||||
$this->_backend->setCondition($filterFields, $word, $start, $end, $order_field, $order_value);
|
||||
$this->_model->setCondition($filterFields, $word, $start, $end, $order_field, $order_value);
|
||||
}
|
||||
private function index_getEntitys(int $page = 0, int $per_page = 0)
|
||||
private function index_getPagination($pager_group = 'default', int $segment = 0, $template = 'bootstrap_full'): string
|
||||
{
|
||||
// 1.Views/Pagers/에 bootstrap_full.php,bootstrap_simple.php 생성
|
||||
// 2.app/Config/Pager.php/$templates에 'bootstrap_full => 'Pagers\bootstrap_full',
|
||||
// 'bootstrap_simple' => 'Pagers\bootstrap_simple', 추가
|
||||
$pager = \Config\Services::pager();
|
||||
// $this->_model->paginate($this->_viewDatas['per_page'], $pager_group, $this->_viewDatas['page'], $segment);
|
||||
$pager->makeLinks(
|
||||
$this->_viewDatas['page'],
|
||||
$this->_viewDatas['per_page'],
|
||||
$this->_viewDatas['total_count'],
|
||||
$template,
|
||||
$segment,
|
||||
$pager_group
|
||||
);
|
||||
$this->_viewDatas['page'] = $pager->getCurrentPage($pager_group);
|
||||
$this->_viewDatas['total_page'] = $pager->getPageCount($pager_group);
|
||||
return $pager->links($pager_group, $template);
|
||||
}
|
||||
private function index_getEntitys(): array
|
||||
{
|
||||
$this->index_setCondition();
|
||||
return $this->_backend->getFindEntitys($page, $per_page);
|
||||
return $this->_viewDatas['page'] ? $this->_model->findAll(
|
||||
$this->_viewDatas['per_page'],
|
||||
$this->_viewDatas['page'] * $this->_viewDatas['per_page'] - $this->_viewDatas['per_page']
|
||||
) : $this->_model->findAll();
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
@ -441,12 +483,13 @@ abstract class BaseController extends Controller
|
||||
$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['page'] = (int)$this->request->getVar('page') ?: 1;
|
||||
$this->_viewDatas['per_page'] = (int)$this->request->getVar('per_page') ?: DEFAULTS['PERPAGE'];
|
||||
$this->_viewDatas['uri'] = $this->request->getUri();
|
||||
//Totalcount 처리
|
||||
$this->index_setCondition();
|
||||
$this->_viewDatas['total_count'] = $this->_backend->getTotalCount();
|
||||
$this->_viewDatas['total_count'] = $this->_model->countAllResults();
|
||||
// log_message("debug", __METHOD__ . "에서 TotalCount 호출:" . $this->_model->getLastQuery());
|
||||
//줄수 처리용
|
||||
$this->_viewDatas['pageOptions'] = array("" => "줄수선택");
|
||||
for ($i = 10; $i <= $this->_viewDatas['total_count'] + $this->_viewDatas['per_page']; $i += 10) {
|
||||
@ -455,8 +498,9 @@ abstract class BaseController extends Controller
|
||||
//pagenation 처리
|
||||
$this->_viewDatas['pagination'] = $this->index_getPagination();
|
||||
//모델 처리
|
||||
$this->_viewDatas['entitys'] = $this->index_getEntitys((int)$this->_viewDatas['page'], (int)$this->_viewDatas['per_page']);
|
||||
// log_message("debug", __METHOD__ . "에서 호출:" . $this->_backend->getLastQuery());
|
||||
$this->_viewDatas['entitys'] = $this->index_getEntitys();
|
||||
// echo $this->_model->getLastQuery();
|
||||
// log_message("debug", __METHOD__ . "에서 findAll 호출:" . $this->_model->getLastQuery());
|
||||
//setting return_url to session flashdata
|
||||
$this->_session->setFlashdata(SESSION_NAMES['RETURN_URL'], current_url() . '?' . $this->request->getUri()->getQuery() ?: "");
|
||||
return view($this->_viewPath . '/index', $this->_viewDatas);
|
||||
@ -474,7 +518,7 @@ abstract class BaseController extends Controller
|
||||
//Header용
|
||||
$column = 'A';
|
||||
foreach ($viewDatas['fields'] as $field) {
|
||||
$sheet->setCellValue($column++ . '1', lang($this->_backend->getClassName() . '.label.' . $field));
|
||||
$sheet->setCellValue($column++ . '1', lang($this->_model->getClassName() . '.label.' . $field));
|
||||
}
|
||||
//본문용
|
||||
$line = 2;
|
||||
@ -515,7 +559,7 @@ abstract class BaseController extends Controller
|
||||
final public function download(string $field, $uid)
|
||||
{
|
||||
try {
|
||||
$entity = $this->_backend->getEntity($uid);
|
||||
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
||||
if (!$entity->$field) {
|
||||
throw new \Exception("첨부파일이 확인되지 않습니다.");
|
||||
}
|
||||
|
||||
@ -7,13 +7,12 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class FrontController extends BaseController
|
||||
abstract class FrontController extends BaseController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower('Front/');
|
||||
$this->_viewPath .= 'front/';
|
||||
$this->_viewDatas['layout'] = LAYOUTS['front'];
|
||||
$this->_viewDatas['title'] = "사용자페이지";
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,6 @@ use CodeIgniter\Entity\Entity;
|
||||
abstract class BaseEntity extends Entity
|
||||
{
|
||||
abstract public function getPrimaryKey();
|
||||
abstract public function getTitle();
|
||||
abstract public function getStatus();
|
||||
abstract public function getTitle(): string;
|
||||
abstract public function getStatus(): string;
|
||||
}
|
||||
|
||||
@ -13,11 +13,11 @@ class BoardConfigEntity extends BaseEntity
|
||||
{
|
||||
return $this->attributes['uid'];
|
||||
}
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
public function getStatus()
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->attributes['status'];
|
||||
}
|
||||
|
||||
@ -13,11 +13,11 @@ class BoardEntity extends BaseHierarchyEntity
|
||||
{
|
||||
return $this->attributes['uid'];
|
||||
}
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['title'];
|
||||
}
|
||||
public function getStatus()
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->attributes['status'];
|
||||
}
|
||||
@ -31,4 +31,8 @@ class BoardEntity extends BaseHierarchyEntity
|
||||
{
|
||||
return $this->attributes['view_cnt'];
|
||||
}
|
||||
public function getUser_Uid()
|
||||
{
|
||||
return $this->attributes['user_uid'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,11 +13,11 @@ class UserEntity extends BaseEntity
|
||||
{
|
||||
return $this->attributes['uid'];
|
||||
}
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
public function getStatus()
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->attributes['status'];
|
||||
}
|
||||
|
||||
@ -13,11 +13,11 @@ class UserSNSEntity extends BaseEntity
|
||||
{
|
||||
return $this->attributes['uid'];
|
||||
}
|
||||
public function getTitle()
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['name'];
|
||||
}
|
||||
public function getStatus()
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->attributes['status'];
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ function getFieldView_BoardConfigHelper($field, $entity, array $fieldFilters, ar
|
||||
return html_entity_decode($value);
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $fieldFilters) ? $fieldFormOptions[$field][$value] : $value;
|
||||
return in_array($field, $fieldFilters) && $value ? $fieldFormOptions[$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -108,11 +108,20 @@ function getFieldIndex_Row_BoardConfigHelper($field, $entity, array $fieldFilter
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_BoardConfigHelper($field, $entity->$field, $fieldFormOptions, [...$attributes, 'style' => 'width:100%']);
|
||||
}
|
||||
return getFieldView_BoardConfigHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldIndex_Row_BoardConfigHelper_Admin($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_BoardConfigHelper($field, $entity->$field, $fieldFormOptions, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_BoardConfigHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -98,7 +98,7 @@ function getFieldView_BoardHelper($field, $entity, array $fieldFilters, array $f
|
||||
return $value ? str_split($value, 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $fieldFilters) ? $fieldFormOptions[$field][$value] : $value;
|
||||
return in_array($field, $fieldFilters) && $value ? $fieldFormOptions[$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -125,11 +125,20 @@ function getFieldIndex_Row_BoardHelper($field, $entity, array $fieldFilters, $fi
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_BoardHelper($field, $entity->$field, $fieldFormOptions, [...$attributes, 'style' => 'width:100%']);
|
||||
}
|
||||
return getFieldView_BoardHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldIndex_Row_BoardHelper_Admin($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_BoardHelper($field, $entity->$field, $fieldFormOptions, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_BoardHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -71,7 +71,7 @@ function getFieldView_UserSNSHelper($field, $entity, array $fieldFilters, array
|
||||
return isset($value) ? str_split($value, 10)[0] : "";
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $fieldFilters) ? $fieldFormOptions[$field][$value] : $value;
|
||||
return in_array($field, $fieldFilters) && $value ? $fieldFormOptions[$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -98,11 +98,20 @@ function getFieldIndex_Row_UserSNSHelper($field, $entity, array $fieldFilters, $
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_UserSNSHelper($field, $entity->$field, $fieldFormOptions, [...$attributes, 'style' => 'width:100%']);
|
||||
}
|
||||
return getFieldView_UserSNSHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldIndex_Row_UserSNSHelper_Admin($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_UserSNSHelper($field, $entity->$field, $fieldFormOptions, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_UserSNSHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -77,7 +77,7 @@ function getFieldView_UserHelper($field, $entity, array $fieldFilters, array $fi
|
||||
return html_entity_decode($value);
|
||||
break;
|
||||
default:
|
||||
return in_array($field, $fieldFilters) ? $fieldFormOptions[$field][$value] : $value;
|
||||
return in_array($field, $fieldFilters) && $value ? $fieldFormOptions[$field][$value] : $value;
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -104,11 +104,20 @@ function getFieldIndex_Row_UserHelper($field, $entity, array $fieldFilters, $fie
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_UserHelper($field, $entity->$field, $fieldFormOptions, [...$attributes, 'style' => 'width:100%']);
|
||||
}
|
||||
return getFieldView_UserHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
function getFieldIndex_Row_UserHelper_Admin($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
if (in_array($field, $fieldFilters)) {
|
||||
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
|
||||
return getFieldFilter_UserHelper($field, $entity->$field, $fieldFormOptions, $attributes);
|
||||
}
|
||||
return getFieldIndex_Row_UserHelper($field, $entity, $fieldFormOptions, $attributes);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Libraries\Adapter\Auth;
|
||||
|
||||
use App\Entities\UserEntity;
|
||||
use App\Models\UserModel;
|
||||
use App\Models\UserSNSModel;
|
||||
use App\Entities\UserEntity;
|
||||
|
||||
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
||||
abstract class Adapter
|
||||
@ -50,7 +50,7 @@ abstract class Adapter
|
||||
{
|
||||
$this->_session->set(SESSION_NAMES['ISLOGIN'], true);
|
||||
$auths = [];
|
||||
foreach (AUTH_FIELDS as $key => $field) {
|
||||
foreach (array_values(AUTH_FIELDS) as $field) {
|
||||
switch ($field) {
|
||||
case 'id':
|
||||
$auths[$field] = $entity->getPrimaryKey();
|
||||
|
||||
@ -7,9 +7,9 @@ use App\Entities\BaseEntity;
|
||||
//계층형구조구현용 모델(게시판,카테고리 등등)
|
||||
abstract class BaseHierarchyModel extends BaseModel
|
||||
{
|
||||
protected function __construct()
|
||||
protected function __construct(string $className)
|
||||
{
|
||||
parent::__construct();
|
||||
parent::__construct($className);
|
||||
$this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth"];
|
||||
$this->validationRules = [...$this->validationRules,];
|
||||
}
|
||||
|
||||
@ -40,28 +40,36 @@ abstract class BaseModel extends Model
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
private $_user_options = null;
|
||||
private $_className = null;
|
||||
protected $_session = null;
|
||||
protected function __construct()
|
||||
protected function __construct(string $className)
|
||||
{
|
||||
$this->_className = $className;
|
||||
parent::__construct();
|
||||
$this->allowedFields = ["updated_at", "created_at"];
|
||||
$this->allowedFields = ["uid", "updated_at", "created_at"];
|
||||
if (!$this->useAutoIncrement) {
|
||||
array_push($this->allowedFields, $this->primaryKey);
|
||||
}
|
||||
$this->validationRules = [];
|
||||
$this->_session = \Config\Services::session();
|
||||
}
|
||||
final public function getClassName()
|
||||
{
|
||||
return $this->_className;
|
||||
}
|
||||
final public function getPrimaryKey(): string
|
||||
{
|
||||
return $this->primaryKey;
|
||||
}
|
||||
abstract public function getTitleField(): string;
|
||||
abstract public function getEntity($uid): BaseEntity;
|
||||
abstract public function getFieldFilters(): array;
|
||||
abstract public function getFields(string $action): array;
|
||||
final public function getEntitys($conditions = false): array
|
||||
public function getEntity($conditions): BaseEntity
|
||||
{
|
||||
return $conditions ? $this->where($conditions)->findAll() : $this->findAll();
|
||||
return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다.\n" . var_export($conditions, true));
|
||||
}
|
||||
final public function getEntitys(array $conditions = array()): array
|
||||
{
|
||||
return $this->where($conditions)->findAll();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
@ -106,18 +114,45 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return $this->getFieldFilters();
|
||||
}
|
||||
|
||||
public function getFieldFormOptions($conditions, $options = array()): array
|
||||
//Field별 Form Option용
|
||||
public function getOptions(array $conditions = array(), $options = array()): array
|
||||
{
|
||||
foreach ($this->getEntitys($conditions) as $entity) {
|
||||
$options[$entity->getPrimaryKey()] = $entity->getTitle();
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
public function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'user_uid':
|
||||
if (is_null($this->_user_options)) {
|
||||
$userModel = new UserModel([$this->getPrimaryKey(), $this->getTitleField()]);
|
||||
$this->_user_options = $userModel->getOptions();
|
||||
}
|
||||
$options = $this->_user_options;
|
||||
break;
|
||||
default:
|
||||
$options = lang($this->getClassName() . '.' . strtoupper($field));
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//Field별 Form Option용
|
||||
final public function getFieldFormOptions(array $fields): array
|
||||
{
|
||||
$fieldFormOptions = array();
|
||||
foreach ($fields as $field) {
|
||||
if (!is_string($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
|
||||
}
|
||||
$fieldFormOptions[$field] = $this->getFieldFormOption($field);
|
||||
}
|
||||
return $fieldFormOptions;
|
||||
}
|
||||
|
||||
final public function getUUID()
|
||||
{
|
||||
@ -132,15 +167,6 @@ abstract class BaseModel extends Model
|
||||
);
|
||||
}
|
||||
|
||||
//View관련 (게시판등의 조회수 증가함수)
|
||||
final public function increaseViewCount($uid, string $field = "view_cnt", int $cnt = 1)
|
||||
{
|
||||
//escape -> false옵션 반드시 있어야함
|
||||
$this->builder()->set($field, "{$field}+{$cnt}", false);
|
||||
$this->builder()->where($this->primaryKey, $uid);
|
||||
$this->builder()->update();
|
||||
}
|
||||
|
||||
//create , modify 직전 작업용 작업
|
||||
protected function changeFormData(string $action, string $field, array $formDatas, $entity)
|
||||
{
|
||||
@ -152,10 +178,12 @@ abstract class BaseModel extends Model
|
||||
$entity->$pk = $this->getUUID();
|
||||
}
|
||||
break;
|
||||
case "user_uid": //입력데이터로 있을시 추가, 없을시는 입력의 경우에만 자동으로 추가
|
||||
case "user_uid": //입력데이터로 있을시 관리툴에서 (사용자,등)추가, 없을시는 입력의 경우에만 자동(장바구니,등)으로 추가
|
||||
if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) {
|
||||
//관리툴 USERSNS에서 사용자 연동 시 추가기능등에 사용
|
||||
$entity->$field = $formDatas[$field];
|
||||
} elseif ($action == 'create' && $this->_session->get(SESSION_NAMES["ISLOGIN"])) {
|
||||
//Front에서 장바구니,게시판등에 추가시 로그온한경우 자동 추가기능등에 사용
|
||||
$auth = $this->_session->get(SESSION_NAMES["AUTH"]);
|
||||
$entity->$field = $auth[AUTH_FIELDS["ID"]];
|
||||
}
|
||||
@ -227,15 +255,30 @@ abstract class BaseModel extends Model
|
||||
public function setIndexWordFilter(string $word)
|
||||
{
|
||||
}
|
||||
public function setIndexDateFilterTrit($start, $end)
|
||||
public function setIndexDateFilter($start, $end)
|
||||
{
|
||||
$this->where("created_at >=", $start);
|
||||
$this->where("created_at <=", $end);
|
||||
}
|
||||
public function setIndexOrderBy(?string $field, ?string $order)
|
||||
{
|
||||
if (!is_null($field) && !is_null($order)) {
|
||||
if ($this->useAutoIncrement) {
|
||||
$this->orderBy($field ?: $this->primaryKey, $order ?: "DESC");
|
||||
} else {
|
||||
$this->orderBy($field ?: "created_at", $order ?: "DESC");
|
||||
}
|
||||
}
|
||||
final public function setCondition(array $filterFields, $word, $start, $end, $order_field, $order_value)
|
||||
{
|
||||
foreach ($filterFields as $field => $value) {
|
||||
$this->where($field, $value);
|
||||
}
|
||||
if (!is_null($word)) {
|
||||
$this->setIndexWordFilter($word);
|
||||
}
|
||||
if (!is_null($start) && !is_null($end)) {
|
||||
$this->setIndexDateFilter($start, $end);
|
||||
}
|
||||
$this->setIndexOrderBy($order_field, $order_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,44 +11,18 @@ class BoardConfigModel extends BaseModel
|
||||
protected $returnType = BoardConfigEntity::class;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields()];
|
||||
parent::__construct('BoardConfig');
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"head", "tail", "status"
|
||||
];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [
|
||||
$this->getTitleField(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "head", "tail",
|
||||
];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [
|
||||
$this->getTitleField(), "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "created_at"
|
||||
];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
@ -76,7 +50,7 @@ class BoardConfigModel extends BaseModel
|
||||
}
|
||||
public function getEntity($conditions): BoardConfigEntity
|
||||
{
|
||||
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
|
||||
return parent::getEntity($conditions);
|
||||
}
|
||||
|
||||
protected function changeFormData(string $action, string $field, array $formDatas, $entity)
|
||||
|
||||
@ -6,13 +6,18 @@ use App\Entities\BoardEntity;
|
||||
|
||||
class BoardModel extends BaseHierarchyModel
|
||||
{
|
||||
//BaseHierarchyModel를 확장하면 grpno가 숫자이고, primarykey를 대분류 생성시 copy하여 grpno에 넣고 sorting하므로
|
||||
private $_boardconfig_options = null;
|
||||
protected $table = "tw_board";
|
||||
protected $returnType = BoardEntity::class;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
|
||||
parent::__construct('Board');
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
"board_config_uid",
|
||||
"user_uid", 'title', "content",
|
||||
"passwd", "board_file", "view_cnt", "status"
|
||||
];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
@ -23,30 +28,6 @@ class BoardModel extends BaseHierarchyModel
|
||||
{
|
||||
return 'content';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["board_config_uid", $this->getTitleField(), "board_file", "passwd", "status", "content"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["board_config_uid", "user_uid", $this->getTitleField(), "board_file", "view_cnt", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return ["board_config_uid", "user_uid", $this->getTitleField(), "board_file", "view_cnt", "status", "created_at", "content"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["board_config_uid", "user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
@ -69,7 +50,26 @@ class BoardModel extends BaseHierarchyModel
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
//Field별 Form Option용
|
||||
public function getFieldFormOption(string $field): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'board_config_uid':
|
||||
if (is_null($this->_boardconfig_options)) {
|
||||
$boardConfigModel = new BoardConfigModel([$this->getPrimaryKey(), $this->getTitleField()]);
|
||||
$this->_boardconfig_options = $boardConfigModel->getOptions();
|
||||
}
|
||||
$options = $this->_boardconfig_options;
|
||||
break;
|
||||
default:
|
||||
return parent::getFieldFormOption($field);
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
public function getEntity($conditions): BoardEntity
|
||||
{
|
||||
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
|
||||
|
||||
@ -9,41 +9,20 @@ class UserModel extends BaseModel
|
||||
protected $table = "tw_user";
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = UserEntity::class;
|
||||
protected $useSoftDeletes = false;
|
||||
protected $useSoftDeletes = true;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedFields = ["uid", ...$this->allowedFields, ...$this->getFields()];
|
||||
parent::__construct('User');
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
"id", "passwd", 'name', "email", "role", "status"
|
||||
];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["id", "passwd", $this->getTitleField(), "email", "role", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["id", $this->getTitleField(), "email", "role", "status", 'created_at'];
|
||||
break;
|
||||
case "view":
|
||||
return ["id", $this->getTitleField(), "email", "role", "status", 'updated_at', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["role", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
@ -74,7 +53,7 @@ class UserModel extends BaseModel
|
||||
}
|
||||
public function getEntity($conditions): UserEntity
|
||||
{
|
||||
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
|
||||
return parent::getEntity($conditions);
|
||||
}
|
||||
|
||||
protected function changeFormData(string $action, string $field, array $formDatas, $entity)
|
||||
|
||||
@ -10,38 +10,18 @@ class UserSNSModel extends BaseModel
|
||||
protected $returnType = UserSNSEntity::class;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedFields = [...$this->allowedFields, ...$this->getFields(), "user_uid"];
|
||||
parent::__construct('UserSNS');
|
||||
$this->allowedFields = [
|
||||
...$this->allowedFields,
|
||||
"site", "id", 'name', "email", "detail", "status"
|
||||
];
|
||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||
}
|
||||
public function getTitleField(): string
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["site", "id", $this->getTitleField(), "email", "detail", "status"];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return ["user_uid", "site", "id", $this->getTitleField(), "email", "status", "created_at"];
|
||||
break;
|
||||
case "view":
|
||||
return [...$fields, "updated_at", "created_at"];
|
||||
break;
|
||||
default:
|
||||
return $fields;
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function getFieldFilters(): array
|
||||
{
|
||||
return ["user_uid", "status"];
|
||||
}
|
||||
public function getFieldBatchFilters(): array
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
protected function getFieldRule(string $field, array $rules, string $action = ""): array
|
||||
{
|
||||
switch ($field) {
|
||||
@ -69,7 +49,7 @@ class UserSNSModel extends BaseModel
|
||||
}
|
||||
public function getEntity($conditions): UserSNSEntity
|
||||
{
|
||||
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
|
||||
return parent::getEntity($conditions);
|
||||
}
|
||||
|
||||
public function create(array $formDatas): UserSNSEntity
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<?= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
||||
</td>
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<td nowrap><?= getFieldIndex_Row_BoardHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<td nowrap><?= getFieldIndex_Row_BoardHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?></td>
|
||||
</tr>
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<?= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
||||
</td>
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<td nowrap><?= getFieldIndex_Row_BoardConfigHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<td nowrap><?= getFieldIndex_Row_BoardConfigHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?></td>
|
||||
</tr>
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<?= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
||||
</td>
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<td nowrap><?= getFieldIndex_Row_UserHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<td nowrap><?= getFieldIndex_Row_UserHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?></td>
|
||||
</tr>
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
<?= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
||||
</td>
|
||||
<?php foreach ($fields as $field) : ?>
|
||||
<td nowrap><?= getFieldIndex_Row_UserSNSHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<td nowrap><?= getFieldIndex_Row_UserSNSHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
|
||||
<?php endforeach; ?>
|
||||
<td><?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?></td>
|
||||
</tr>
|
||||
|
||||
@ -6,40 +6,44 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<?php foreach ($layout['stylesheets'] as $stylesheet) : ?>
|
||||
<?php echo $stylesheet ?>
|
||||
<?= $stylesheet ?>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($layout['javascripts'] as $javascript) : ?>
|
||||
<?php echo $javascript ?>
|
||||
<?= $javascript ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<link href="/css/front.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/front.js"></script>
|
||||
<link href="/css/admin.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/admin.js"></script>
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<title><?php echo $title ?></title>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<title><?= $title ?></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- layout_content Start -->
|
||||
<div id="layout_content">
|
||||
<!-- layout_content Top Start -->
|
||||
<?php echo $this->include($layout['path'] . '/top_logo'); ?>
|
||||
<!-- Layout Top Menu 시작-->
|
||||
<?php echo $this->include($layout['path'] . '/top_menu'); ?>
|
||||
<!-- Layout Top Menu 끝 -->
|
||||
<!-- layout_content Top End -->
|
||||
<!-- layout_content Body Start -->
|
||||
<?php echo $this->renderSection('content') ?>
|
||||
<!-- layout_content Body Content End -->
|
||||
<!-- layout_content Bottom Start -->
|
||||
<?php echo $this->include($layout['path'] . '/copyright'); ?>
|
||||
<!-- layout_content Bottom End -->
|
||||
<div id="head" class="row">
|
||||
<?= $this->include($layout['path'] . '/top_menu'); ?>
|
||||
</div>
|
||||
<!-- layout_content End -->
|
||||
<table id="layout">
|
||||
<tr>
|
||||
<td id="left" valign="top" width="160">
|
||||
<?= $this->include($layout['path'] . '/left_menu'); ?>
|
||||
</td>
|
||||
<td id="body" valign="top" width="*">
|
||||
<?= $this->include('templates/front/header'); ?>
|
||||
<?= $this->renderSection('content') ?>
|
||||
<?= $this->include('templates/front/footer'); ?>
|
||||
<?= $this->include($layout['path'] . '/copyright'); ?>
|
||||
</td>
|
||||
<td id="right" valign="top" width="50">
|
||||
<?= $this->include($layout['path'] . '/right_menu'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="tail" class="row"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -1,19 +1,19 @@
|
||||
<!-- Copyright 시작-->
|
||||
<div style="magin-top:5px; margin-bottom:5px; border:1px solid silver;"></div>
|
||||
<div style="margin-top:5px; margin-bottom:5px; border:1px solid silver;"></div>
|
||||
<div id="footer">
|
||||
<img src="logo_gray.png">
|
||||
<span style="color:#999; font-size: 11px;">
|
||||
<a href="/sitecontent/?sitecategory=39">会社紹介 </a> |
|
||||
<a href="/sitecontent/?sitecategory=40">利用約款</a> |
|
||||
<a href="/sitecontent/?sitecategory=41">個人情報保護政策</a> |
|
||||
<a href="mailto:idc@idcjp.jp">eメール</a>
|
||||
<a href="/sitecontent/?sitecategory=39">会社紹介 </a> |
|
||||
<a href="/sitecontent/?sitecategory=40">利用約款</a> |
|
||||
<a href="/sitecontent/?sitecategory=41">個人情報保護政策</a> |
|
||||
<a href="mailto:idc@idcjp.jp">eメール</a>
|
||||
</span>
|
||||
<div style="font-size: 11px; margin-top: 5px; line-height: 160%;">
|
||||
社名 : <span class="cpy">TRi-aBility(株)</span> 代表者 : <span class="cpy">笹 生 勝</span>
|
||||
住所 : <span class="cpy">東京都 大田区平和島6-5</span><br/>
|
||||
TEL: <span class="cpy">043-307-5390</span> EMAIL : <span class="cpy"><a href="mailto:idc@idcjp.jp" style="color:darkblue;">idc@idcjp.jp</a></span><br/>
|
||||
<!-- 事業者登録番号 : <span class="cpy">887-81-00973</span><br/> -->
|
||||
<!-- Copyright © 2012, YYY, All rights Reserved -->
|
||||
社名 : <span class="cpy">TRi-aBility(株)</span> 代表者 : <span class="cpy">笹 生 勝</span>
|
||||
住所 : <span class="cpy">東京都 大田区平和島6-5</span><br />
|
||||
TEL: <span class="cpy">043-307-5390</span> EMAIL : <span class="cpy"><a href="mailto:idc@idcjp.jp" style="color:darkblue;">idc@idcjp.jp</a></span><br />
|
||||
<!-- 事業者登録番号 : <span class="cpy">887-81-00973</span><br/> -->
|
||||
<!-- Copyright © 2012, YYY, All rights Reserved -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- Copyright 끝-->
|
||||
<!-- Copyright 끝-->
|
||||
10
app/Views/layouts/front/left_menu.php
Normal file
10
app/Views/layouts/front/left_menu.php
Normal file
@ -0,0 +1,10 @@
|
||||
<!-- left menu start -->
|
||||
<link href="/css/admin/left_menu.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/side_menu.js"></script>
|
||||
<div id="left_menu" class="shadow-lg rounded">
|
||||
<div class="accordion accordion-flush">
|
||||
<?= $this->include($layout['path'] . '/left_menu/base'); ?>
|
||||
<?= $this->include($layout['path'] . '/left_menu/board'); ?>
|
||||
<?= $this->include($layout['path'] . '/left_menu/shoppingmall'); ?>
|
||||
</div>
|
||||
</div>
|
||||
6
app/Views/layouts/front/left_menu/base.php
Normal file
6
app/Views/layouts/front/left_menu/base.php
Normal file
@ -0,0 +1,6 @@
|
||||
<div class="accordion-item" style="background-color: #eaeaea;">
|
||||
<h2><a href=" /front"><i class="fa fa-home"></i>Main</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/user/view"><?= CLASS_ICONS['USER'] ?></i>계정 관리</a></h2>
|
||||
</div>
|
||||
3
app/Views/layouts/front/left_menu/board.php
Normal file
3
app/Views/layouts/front/left_menu/board.php
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/board"><?= CLASS_ICONS['BOARD'] ?>게시글 관리</a></h2>
|
||||
</div>
|
||||
9
app/Views/layouts/front/left_menu/shoppingmall.php
Normal file
9
app/Views/layouts/front/left_menu/shoppingmall.php
Normal file
@ -0,0 +1,9 @@
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/product"><?= CLASS_ICONS['PRODUCT'] ?>상품 관리</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/order"><?= CLASS_ICONS['ORDER'] ?></i>주문 관리</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/billing"><?= CLASS_ICONS['BILLING'] ?></i>결제 관리</a></h2>
|
||||
</div>
|
||||
7
app/Views/layouts/front/right_menu.php
Normal file
7
app/Views/layouts/front/right_menu.php
Normal file
@ -0,0 +1,7 @@
|
||||
<!-- right menu start -->
|
||||
<link href="/css/admin/right_menu.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="/js/side_menu.js"></script>
|
||||
<div id="right_menu" class="shadow-lg rounded">
|
||||
<div class="accordion accordion-flush">
|
||||
</div>
|
||||
</div>
|
||||
14
app/Views/layouts/front/top_menu.php
Normal file
14
app/Views/layouts/front/top_menu.php
Normal file
@ -0,0 +1,14 @@
|
||||
<nav class="navbar navbar-expand-lg bg-light" style="border-bottom:1px solid silver;">
|
||||
<div class="container-fluid">
|
||||
<a href="/admin" class="navbar-brand">BaseProject 관리 Site</a>
|
||||
<div class="input-group custom-search-form" style="width:270px;">
|
||||
<?= $this->include($layout['path'] . '/top_menu/search'); ?>
|
||||
</div>
|
||||
<div class="input-group custom-search-form" style="width:270px;">
|
||||
<?= $this->include($layout['path'] . '/top_menu/make_password'); ?>
|
||||
</div>
|
||||
<div style="float: right;">
|
||||
<?= $this->include($layout['path'] . '/top_menu/member_link'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
3
app/Views/layouts/front/top_menu/make_password.php
Normal file
3
app/Views/layouts/front/top_menu/make_password.php
Normal file
@ -0,0 +1,3 @@
|
||||
<span><?= ICONS['LOCK'] ?></span>
|
||||
<input type="text" class="form-control" value="<?= getPasswordString_CommonHelper() ?>" id="makePassword">
|
||||
<span class="input-group-btn" id="mkbutton"><button class="btn btn-default border border-dark" type="button" id="totSearchBtn" onClick="window.location.reload();"><?= ICONS['SEARCH'] ?></button></span>
|
||||
16
app/Views/layouts/front/top_menu/member_link.php
Normal file
16
app/Views/layouts/front/top_menu/member_link.php
Normal file
@ -0,0 +1,16 @@
|
||||
<ul class="navbar-nav me-auto my-2 my-lg-0 navbar-nav-scroll" style="--bs-scroll-height: 100px;">
|
||||
<li class="nav-item dropdown">
|
||||
<?php if ($session->get(SESSION_NAMES['ISLOGIN'])) : ?>
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<?= ICONS['LOGIN'] ?><?= $session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['TITLE']] ?>
|
||||
</a>
|
||||
<ul class="dropdown-menu dropdown-menu-end">
|
||||
<li><a class="dropdown-item" href="/admin/user/update/<?= $session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']] ?>"><?= ICONS['SETUP'] ?>수정</a></li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a class="dropdown-item" href="/logout"><?= ICONS['LOGOUT'] ?>Logout</a></li>
|
||||
</ul>
|
||||
<?php else : ?><a class="nav-link dropdown-toggle" href="/login" role="button"><?= ICONS['LOGIN'] ?>Login</a><?php endif ?>
|
||||
</li>
|
||||
</ul>
|
||||
4
app/Views/layouts/front/top_menu/search.php
Normal file
4
app/Views/layouts/front/top_menu/search.php
Normal file
@ -0,0 +1,4 @@
|
||||
<form class="d-flex me-20" role="search">
|
||||
<input class="form-control" type="search" placeholder="Search" aria-label="Search">
|
||||
<button class="btn btn-outline-success" type="submit">Search</button>
|
||||
</form>
|
||||
35
app/Views/templates/front/footer.php
Normal file
35
app/Views/templates/front/footer.php
Normal file
@ -0,0 +1,35 @@
|
||||
<div class="footer"></div>
|
||||
<?= $session->getFlashdata('return_message') ? alert_CommonHelper($session->getFlashdata('return_message')) : "" ?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
//class가 calender인 inputbox용,날짜field용
|
||||
$(".calender").datepicker({
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
yearRange: "-10:+0",
|
||||
dateFormat: "yy-mm-dd"
|
||||
});
|
||||
//id가 batchjobuids_checkbox인 버튼을 클릭시 class가 batchjobuids_checkboxs인 checkbox용
|
||||
$('#batchjobuids_checkbox').click(function(event) {
|
||||
if (this.checked) {
|
||||
$('.batchjobuids_checkboxs').each(function() { //loop checkbox
|
||||
$(this).prop('checked', true); //check
|
||||
});
|
||||
} else {
|
||||
$('.batchjobuids_checkboxs').each(function() { //loop checkbox
|
||||
$(this).prop('checked', false); //uncheck
|
||||
});
|
||||
}
|
||||
});
|
||||
//class가 select-field인 SelectBox용
|
||||
$(".select-field").select2({
|
||||
theme: "bootstrap-5",
|
||||
});
|
||||
//class가 editor인 textarea용
|
||||
tinymce.init({
|
||||
selector: '.editor',
|
||||
theme: 'silver',
|
||||
height: 500
|
||||
});
|
||||
});
|
||||
</script>
|
||||
3
app/Views/templates/front/header.php
Normal file
3
app/Views/templates/front/header.php
Normal file
@ -0,0 +1,3 @@
|
||||
<div class="header">
|
||||
<h4><i class="bi bi-cast"></i><?= $title ?></h4>
|
||||
</div>
|
||||
6
app/Views/templates/front/index_head.php
Normal file
6
app/Views/templates/front/index_head.php
Normal file
@ -0,0 +1,6 @@
|
||||
<li class="nav-item">검색어:<?= form_input('word', $word) ?></li>
|
||||
<li class="nav-item">검색일:
|
||||
<?= form_input('start', $start, ["class" => "calender"]) ?><?= form_input('end', $end, ["class" => "calender"]) ?>
|
||||
<?= form_submit('', '검색', array("class" => "btn btn-outline btn-primary")); ?><?= anchor(current_url() . '/excel?' . $uri->getQuery(), '<i class="bi bi-file-excel"></i>', ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
|
||||
</li>
|
||||
<li class="nav-item">page:<?= $page ?> / total:<?= $total_page ?> <?= form_dropdown('per_page', $pageOptions, $per_page, array('onChange' => 'this.form.submit()')) ?> / 총:<?= $total_count ?></li>
|
||||
Loading…
Reference in New Issue
Block a user