diff --git a/.gitignore b/.gitignore
index 7904fcf..84a6914 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,6 +70,17 @@ writable/HPILO/*
writable/Excel/*
!writable/Excel/index.html
+#mapurl 결과물
+public/mapurl/index.html
+
+#upload 파일
+public/uploads/*
+public/upload_images/*
+
+#leftmenu 파일
+layouts/front/left_menu/*
+layouts/main/board.php
+
#-------------------------
# User Guide Temp Files
#-------------------------
@@ -129,11 +140,4 @@ nb-configuration.xml
/results/
/phpunit*.xml
-/.phpunit.*.cache
-
-#mapurl 결과물
-public/mapurl/index.html
-
-#upload 파일
-public/uploads/*
-public/upload_images/*
\ No newline at end of file
+/.phpunit.*.cache
\ No newline at end of file
diff --git a/app/Config/Constants.php b/app/Config/Constants.php
index 5101cd8..87786f7 100644
--- a/app/Config/Constants.php
+++ b/app/Config/Constants.php
@@ -144,7 +144,39 @@ define('LAYOUTS', [
'',
'',
]
- ]
+ ],
+ 'main' => [
+ 'path' => 'layouts' . DIRECTORY_SEPARATOR . 'main',
+ 'stylesheets' => [
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ ],
+ 'javascripts' => [
+ '',
+ '',
+ '',
+ '',
+ '',
+ ]
+ ],
+]);
+
+//URL
+define('URLS', [
+ 'LOGIN' => '/front/user/login',
+ 'SIGNUP' => '/front/user/signup',
+ 'LOGOUT' => '/front/user/logout',
+ 'Order' => '/front/order',
+ 'addCart' => '/front/order/addCart',
+ 'cancelCart' => '/front/order/cancelCart',
+ 'cardPayment' => '/front/order/payment/card',
+ 'depositPayment' => '/front/order/payment/deposit',
]);
//SESSION 관련
define('SESSION_NAMES', [
@@ -154,16 +186,8 @@ define('SESSION_NAMES', [
'CART' => 'cart'
]);
define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']);
-//Category관련 Role Fields
-define('CATEGORY_ROLE_FIELDS', [
- 'ACCESS' => 'isaccess',
- 'READ' => 'isread',
- 'WRITE' => 'iswrite',
- 'REPLY' => 'isreply',
- 'UPLOAD' => 'isupload',
- 'DONWLOAD' => 'isdownload',
-]);
-
+//월이용권 상품의 Category번호
+define('RENTAL_PRODUCT_CATEGORYS', [5, 8]);
//인증 관련
define('AUTH_ADAPTERS', [
'Local' => [
@@ -189,7 +213,7 @@ define('PATHS', [
]);
foreach (PATHS as $key => $path) {
if (!is_dir($path)) {
- mkdir($path, 0640);
+ mkdir($path, 0755);
}
}
@@ -205,19 +229,39 @@ define('ICONS', [
'SETUP' => ' ',
'FLAG' => ' ',
'SEARCH' => ' ',
- 'EXCEL' => ' ',
+ 'EXCEL' => ' ',
+ 'HOME' => ' ',
+ 'PLAY' => ' ',
+ 'CART' => ' ',
+ 'CARD' => ' ',
+ 'DEPOSIT' => ' ',
+ 'UP' => ' ',
+ 'DOWN' => ' ',
+ 'LEFT' => ' ',
+ 'RIGHT' => ' ',
'IMAGE_FILE' => ' ',
]);
define('CLASS_ICONS', [
'USER' => ' ',
'USERSNS' => ' ',
- 'BOARDCONFIG' => ' ',
'BOARD' => ' ',
+ 'SITEPAGE' => ' ',
'CATEGORY' => ' ',
'PRODUCT' => ' ',
- 'CART' => ' ',
'ORDER' => ' ',
- 'BILLING' => ' ',
+ 'CART' => ' ',
+ 'CARD' => ' ',
+ 'DEPOSIT' => ' ',
+]);
+define('CLASS_TOP_BANNER', [
+ 'USER' => ' ',
+ 'USERSNS' => ' ',
+ 'ORDER' => ' ',
+ 'CARD' => ' ',
+ 'DEPOSIT' => ' ',
+ 'PRODUCT' => ' ',
+ 'SITEPAGE' => ' ',
+ 'BOARD' => ' ',
]);
define('AUDIOS', [
'Alram_GetEmail' => ' ',
@@ -225,11 +269,12 @@ define('AUDIOS', [
//Default값 정의
define('DEFAULTS', [
+ 'ORDER_CATEGORY' => getenv('default.order_category') ?: 11,
+ 'USER_CATEGORY' => getenv('default.user_category') ?: 22,
'ROLE' => getenv('default.role') ?: "guest",
'STATUS' => getenv('default.status') ?: "use",
'EMPTY' => getenv('default.empty') ?: "",
'PERPAGE' => getenv('default.perpage') ?: 20,
- 'HIERARCHY_GRPDEPTH' => getenv('default.hierarchy_grpdepth') ?: 20,
'DELIMITER_FILE' => getenv('default.delimiter.file') ?: "||",
'DELIMITER_ROLE' => getenv('default.delimiter.role') ?: ",",
]);
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index c2289ff..d8940ad 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -35,10 +35,6 @@ $routes->setAutoRoute(false);
$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('/signup', 'AuthController::signup/local');
-$routes->get('/signup/(:alpha)', 'AuthController::signup/$1');
-$routes->get('/logout', 'AuthController::logout');
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
});
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
@@ -95,10 +91,16 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
});
});
$routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) {
- $routes->group('user', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:user'], static function ($routes) {
- $routes->get('update/(:uuid)', 'UserController::update_form/$1');
- $routes->post('update/(:uuid)', 'UserController::update/R1');
- $routes->get('view/(:uuid)', 'UserController::view/$1');
+ $routes->group('user', static function ($routes) {
+ $routes->get('', 'UserController::index', ['filter' => 'authFilter:user']);
+ $routes->get('insert', 'UserController::insert_form');
+ $routes->post('insert', 'UserController::insert');
+ $routes->get('update/(:uuid)', 'UserController::update_form/$1', ['filter' => 'authFilter:user']);
+ $routes->post('update/(:uuid)', 'UserController::update/$1', ['filter' => 'authFilter:user']);
+ $routes->get('login', 'UserController::login_form');
+ $routes->post('login', 'UserController::login/local');
+ $routes->get('signup/(:alpha)', 'UserController::login/$1');
+ $routes->get('logout', 'UserController::logout', ['filter' => 'authFilter:user']);
});
$routes->group('board', static function ($routes) {
$routes->get('', 'BoardController::index');
@@ -113,6 +115,9 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
$routes->get('delete/(:num)', 'BoardController::delete/$1');
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
});
+ $routes->group('sitepage', static function ($routes) {
+ $routes->get('', 'SitepageController::index');
+ });
});
/*
* --------------------------------------------------------------------
diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php
index 8b16988..bbe1e75 100644
--- a/app/Controllers/Admin/AdminController.php
+++ b/app/Controllers/Admin/AdminController.php
@@ -13,6 +13,7 @@ abstract class AdminController extends BaseController
{
parent::initController($request, $response, $logger);
$this->_viewPath = 'admin/';
+ $this->_viewDatas['control'] = 'admin';
$this->_viewDatas['layout'] = LAYOUTS['admin'];
}
}
diff --git a/app/Controllers/Admin/BoardController.php b/app/Controllers/Admin/BoardController.php
index 86d5791..dfe7d1d 100644
--- a/app/Controllers/Admin/BoardController.php
+++ b/app/Controllers/Admin/BoardController.php
@@ -2,20 +2,25 @@
namespace App\Controllers\Admin;
+use App\Controllers\Trait\UpDownloadTrait;
use App\Models\BoardModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
-use App\Controllers\Trait\UpDownloadTrait;
class BoardController extends AdminController
{
use UpDownloadTrait;
+ private $_category_notice = 3;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
- $this->_model = new BoardModel();
parent::initController($request, $response, $logger);
- $this->_viewPath .= strtolower($this->_model->getClassName());
+ $this->_model = new BoardModel();
+ $this->_viewDatas['className'] = 'Board';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);;
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
@@ -46,12 +51,11 @@ class BoardController extends AdminController
protected function getFieldFormData(string $field, $entity = null): array
{
switch ($field) {
- case 'passwd':
- $this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
- $this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
- break;
case 'board_file':
- $this->_viewDatas['fieldDatas'][$field] = $this->upload_file_procedure($field);
+ $file = $this->upload_file_procedure($field);
+ if (!is_null($file)) {
+ $this->_viewDatas['fieldDatas'][$field] = $file;
+ }
break;
default:
return parent::getFieldFormData($field, $entity);
@@ -59,4 +63,59 @@ class BoardController extends AdminController
}
return $this->_viewDatas['fieldDatas'];
}
+
+ private function build_notice()
+ {
+ $entitys = $this->_model->getEntitys(['category_uid' => $this->_category_notice, 'status' => DEFAULTS['STATUS']]);
+ $temps = array("
");
+ foreach ($entitys as $entity) {
+ array_push($temps, sprintf(
+ "%s %s ",
+ $entity->getPrimaryKey(),
+ $entity->getTitle(),
+ $entity->created_at ? str_split($entity->created_at, 10)[0] : "",
+ ));
+ }
+ array_push($temps, " ");
+ // echo var_export($temps, true);
+ // exit;
+ file_put_contents(APPPATH . 'Views' . "/layouts/main/board.php", implode("\n", $temps));
+ }
+
+ //Insert관련
+ protected function insert_process()
+ {
+ $entity = parent::insert_process();
+ if ($entity->category_uid == $this->_category_notice) {
+ $this->build_notice();
+ }
+ return $entity;
+ }
+ //Update관련
+ protected function update_process($entity)
+ {
+ $entity = parent::update_process($entity);
+ if ($entity->category_uid == $this->_category_notice) {
+ $this->build_notice();
+ }
+ return $entity;
+ }
+ //Toggle관련
+ protected function toggle_process($entity)
+ {
+ $entity = parent::toggle_process($entity);
+ if ($entity->category_uid == $this->_category_notice) {
+ $this->build_notice();
+ }
+ return $entity;
+ }
+ //Delete 관련
+ protected function delete_process($entity)
+ {
+ $entity = parent::delete_process($entity);
+ if ($entity->category_uid->$this->_category_notice) {
+ $this->build_notice();
+ }
+ return $entity;
+ }
}
diff --git a/app/Controllers/Admin/CategoryController.php b/app/Controllers/Admin/CategoryController.php
index beb9b89..664b7ae 100644
--- a/app/Controllers/Admin/CategoryController.php
+++ b/app/Controllers/Admin/CategoryController.php
@@ -2,6 +2,8 @@
namespace App\Controllers\Admin;
+use App\Controllers\Trait\UpDownloadTrait;
+use App\Entities\CategoryEntity;
use App\Models\CategoryModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@@ -9,24 +11,29 @@ use Psr\Log\LoggerInterface;
class CategoryController extends AdminController
{
+ use UpDownloadTrait;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
- $this->_model = new CategoryModel();
parent::initController($request, $response, $logger);
- $this->_viewPath .= strtolower($this->_model->getClassName());
+ $this->_model = new CategoryModel();
+ $this->_viewDatas['className'] = 'Category';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{
$fields = [
- 'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
+ 'name', "linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"status", "head", "tail",
];
switch ($action) {
case "index":
case "excel":
return [
- 'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
+ 'name', "linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"status", "created_at"
];
break;
@@ -47,39 +54,67 @@ class CategoryController extends AdminController
return parent::getFieldBatchFilters();
}
- // private function build_leftmenu()
- // {
- // $categorys = $this->_model->getEntitys(['status' => DEFAULTS['STATUS']]);
- // $leftmenu = view($this->_viewPath . '/leftmenu', ['categorys' => $categorys]);
- // file_put_contents(APPPATH . 'Views' . '/layouts/front/left_menu/leftmenu.php', $leftmenu);
- // }
+ private function write_leftmenu($old_category, array $categorys)
+ {
+ //신규 대분류인경우 기존 카테고리 메뉴 만들기
+ // $categorys = array_reverse($categorys); //중분류의 경우 나중에 넣은것이 먼저되므로 reverse해서 처리
+ foreach ($categorys as $category) {
+ $viewDatas = [
+ 'className' => $this->_viewDatas['className'],
+ 'category' => $category,
+ 'parent_category' => $old_category,
+ 'sibling_categorys' => $categorys
+ ];
+ $leftmenu = view($this->_viewPath . '/leftmenu_template', ['viewDatas' => $viewDatas]);
+ file_put_contents(APPPATH . 'Views' . "/layouts/front/left_menu/leftmenu_{$category->getPrimaryKey()}.php", $leftmenu);
+ }
+ }
+ private function build_leftmenu()
+ {
+ $old_category = null;
+ $categorys = array();
+ foreach ($this->_model->getEntitys(['status' => DEFAULTS['STATUS']]) as $entity) {
+ if ($entity->getHierarchy_Depth() == 1) {
+ if (is_null($old_category)) {
+ $old_category = $entity;
+ } else if ($old_category->getPrimaryKey() != $entity->getPrimaryKey()) {
+ $this->write_leftmenu($old_category, $categorys);
+ $old_category = $entity;
+ $categorys = array();
+ }
+ } else {
+ array_push($categorys, $entity);
+ }
+ }
+ $this->write_leftmenu($old_category, $categorys);
+ }
- // //Insert관련
- // protected function insert_process()
- // {
- // $entity = parent::insert_process();
- // $this->build_leftmenu();
- // return $entity;
- // }
- // //Update관련
- // protected function update_process($entity)
- // {
- // $entity = parent::update_process($entity);
- // $this->build_leftmenu();
- // return $entity;
- // }
- // //Reply관련
- // protected function reply_process($entity)
- // {
- // $entity = parent::reply_process($entity);
- // $this->build_leftmenu();
- // return $entity;
- // }
- // //Delete 관련
- // protected function delete_process($entity)
- // {
- // $entity = parent::delete_process($entity);
- // $this->build_leftmenu();
- // return $entity;
- // }
+ //Insert관련
+ protected function insert_process()
+ {
+ $entity = parent::insert_process();
+ $this->build_leftmenu();
+ return $entity;
+ }
+ //Update관련
+ protected function update_process($entity)
+ {
+ $entity = parent::update_process($entity);
+ $this->build_leftmenu();
+ return $entity;
+ }
+ //Reply관련
+ protected function reply_process($entity)
+ {
+ $entity = parent::reply_process($entity);
+ $this->build_leftmenu();
+ return $entity;
+ }
+ //Delete 관련
+ protected function delete_process($entity)
+ {
+ $entity = parent::delete_process($entity);
+ $this->build_leftmenu();
+ return $entity;
+ }
}
diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php
index 7b38ee2..264b876 100644
--- a/app/Controllers/Admin/Home.php
+++ b/app/Controllers/Admin/Home.php
@@ -9,12 +9,36 @@ use Psr\Log\LoggerInterface;
class Home extends Controller
{
+ private $_session = null;
+ private $_viewDatas = array();
+ private $_viewPath = "admin/";
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
+ $this->_viewDatas['control'] = 'admin';
+ $this->_viewDatas['title'] = '쇼핑몰관리툴페이지';
+ $this->_viewDatas['layout'] = LAYOUTS['admin'];
+ $this->_session = \Config\Services::session();
+ $this->_viewDatas['session'] = $this->_session;
+ $this->_viewDatas['className'] = 'MAIN';
+ $this->_viewDatas['class_icon'] = CLASS_ICONS['USER'];
+ helper("Common");
+ // echo var_export($this->_viewDatas['layout'], true);
+ // exit;
+ //사용자 기본 Role 지정
+ $this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
+ $this->_viewDatas['currentRoles'] = [DEFAULTS["ROLE"]];
+ if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
+ $this->_viewDatas[SESSION_NAMES['ISLOGIN']] = true;
+ $this->_viewDatas['auth'] = $this->_session->get(SESSION_NAMES['AUTH']);
+ $currentRoles = explode(DEFAULTS['DELIMITER_ROLE'], $this->_viewDatas['auth'][AUTH_FIELDS['ROLE']]);
+ $this->_viewDatas['currentRoles'] = is_array($currentRoles) ? $currentRoles : [DEFAULTS["ROLE"]];
+ }
}
+
+
public function index()
{
- return view('admin/welcome_message');
+ return view($this->_viewPath . 'welcome_message', ['viewDatas' => $this->_viewDatas]);
}
}
diff --git a/app/Controllers/Admin/SitepageController.php b/app/Controllers/Admin/SitepageController.php
new file mode 100644
index 0000000..8e4d287
--- /dev/null
+++ b/app/Controllers/Admin/SitepageController.php
@@ -0,0 +1,47 @@
+_model = new SitepageModel();
+ $this->_viewDatas['className'] = 'Sitepage';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
+ }
+
+ public function getFields(string $action = ""): array
+ {
+ $fields = ["category_uid", 'title', "status", "content"];
+ switch ($action) {
+ case "index":
+ case "excel":
+ return ["category_uid", "user_uid", 'title', "status", "created_at"];
+ break;
+ case "view":
+ return ["category_uid", "user_uid", 'title', "status", "created_at", "content"];
+ break;
+ default:
+ return $fields;
+ break;
+ }
+ }
+ public function getFieldFilters(): array
+ {
+ return ["category_uid", "user_uid", "status"];
+ }
+ public function getFieldBatchFilters(): array
+ {
+ return parent::getFieldBatchFilters();
+ }
+}
diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php
index cd5d1aa..f966272 100644
--- a/app/Controllers/Admin/UserController.php
+++ b/app/Controllers/Admin/UserController.php
@@ -11,43 +11,32 @@ class UserController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
- $this->_model = new UserModel();
parent::initController($request, $response, $logger);
- $this->_viewPath .= strtolower($this->_model->getClassName());
+ $this->_model = new UserModel();
+ $this->_viewDatas['className'] = 'User';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
}
-
- //Field별 Form Datas 처리용
- protected function getFieldFormData(string $field, $entity = null): array
- {
- switch ($field) {
- case 'passwd':
- $passwd = $this->request->getVar($field) ?: false;
- $confirmpassword = $this->request->getVar('confirmpassword') ?: false;
- if ($passwd && $confirmpassword) {
- $this->_viewDatas['fieldDatas'][$field] = $passwd;
- $this->_viewDatas['fieldDatas']['confirmpassword'] = $confirmpassword;
- }
- break;
- default:
- return parent::getFieldFormData($field, $entity);
- break;
- }
- return $this->_viewDatas['fieldDatas'];
- }
-
public function getFields(string $action = ""): array
{
- $fields = ["id", "passwd", 'name', "email", "role", "status"];
switch ($action) {
+ case 'insert':
+ return ["id", "passwd", 'name', "email", "phone", "mobile", "role", "status"];
+ break;
+ case 'update':
+ return ["passwd", 'name', "email", "phone", "mobile", "role", "status"];
+ break;
case "index":
case "excel":
- return ["id", 'name', "email", "role", "status", 'created_at'];
+ return ["id", 'name', "email", "phone", "mobile", "role", "status", 'created_at'];
break;
case "view":
- return ["id", 'name', "email", "role", "status", 'updated_at', 'created_at'];
+ return ["id", 'name', "email", "phone", "mobile", "role", "status", 'updated_at', 'created_at'];
break;
default:
- return $fields;
+ return [];
break;
}
}
diff --git a/app/Controllers/Admin/UserSNSController.php b/app/Controllers/Admin/UserSNSController.php
index 9753f41..a3e89e7 100644
--- a/app/Controllers/Admin/UserSNSController.php
+++ b/app/Controllers/Admin/UserSNSController.php
@@ -11,9 +11,13 @@ class UserSNSController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
- $this->_model = new UserSNSModel();
parent::initController($request, $response, $logger);
- $this->_viewPath .= strtolower($this->_model->getClassName());
+ $this->_model = new UserSNSModel();
+ $this->_viewDatas['className'] = 'UserSNS';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
}
public function getFields(string $action = ""): array
{
diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php
index 198829e..267fd75 100644
--- a/app/Controllers/BaseController.php
+++ b/app/Controllers/BaseController.php
@@ -58,13 +58,7 @@ abstract class BaseController extends Controller
// Preload any models, libraries, etc, here.
// E.g.: $this->session = \Config\Services::session();
$this->_session = \Config\Services::session();
- $this->_viewDatas['layout'] = LAYOUTS['empty'];
$this->_viewDatas['session'] = $this->_session;
- $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
- $this->_viewDatas['className'] = $this->_model->getClassName();
- $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_model->getClassName())];
- helper($this->_model->getClassName());
-
//사용자 기본 Role 지정
$this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
$this->_viewDatas['currentRoles'] = [DEFAULTS["ROLE"]];
@@ -78,16 +72,61 @@ abstract class BaseController extends Controller
abstract public function getFields(string $action): array;
abstract public function getFieldFilters(): array;
+ //Field별 Rule용
+ protected function getFieldRule(string $field, array $rules, string $action = ""): array
+ {
+ switch ($field) {
+ default:
+ $rules = $this->_model->getFieldRule($field, $rules, $action);
+ break;
+ }
+ return $rules;
+ }
+ final public function getFieldRules(array $fields, string $action = ""): array
+ {
+ $rules = array();
+ foreach ($fields as $field) {
+ $rules = $this->getFieldRule($field, $rules, $action);
+ }
+ return $rules;
+ }
public function getFieldBatchFilters(): array
{
return $this->getFieldFilters();
}
+ //Field별 Form Option용
+ public function getFieldFormOption(string $field): array
+ {
+ switch ($field) {
+ default:
+ $options = $this->_model->getFieldFOrmOption($field);
+ break;
+ }
+ if (!is_array($options)) {
+ throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
+ }
+ return $options;
+ }
+ final public function getFieldFormOptions(array $fields): array
+ {
+ $fieldFormOptions = array();
+ foreach ($fields as $field) {
+ if (!is_string($field)) {
+ throw new \Exception(__FUNCTION__ . "에서 {$this->_viewDatas['className']}의 Field:{$field}가 string 아닙니다.\n" . var_export($fields, true));
+ }
+ $fieldFormOptions[$field] = $this->getFieldFormOption($field);
+ }
+ return $fieldFormOptions;
+ }
//Field별 Form Datas 처리용
protected function getFieldFormData(string $field, $entity = null): array
{
switch ($field) {
default:
- $this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
+ $value = $this->request->getVar($field);
+ if (!is_null($value)) {
+ $this->_viewDatas['fieldDatas'][$field] = $value;
+ }
break;
}
return $this->_viewDatas['fieldDatas'];
@@ -105,10 +144,10 @@ abstract class BaseController extends Controller
break;
}
$this->_viewDatas['fields'] = $fields ?: $this->getFields($action);
- $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action);
+ $this->_viewDatas['fieldRules'] = $this->getFieldRules($this->_viewDatas['fields'], $action);
$this->_viewDatas['fieldFilters'] = $this->getFieldFilters();
$this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters();
- $this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']);
+ $this->_viewDatas['fieldFormOptions'] = $this->getFieldFormOptions($this->_viewDatas['fieldFilters']);
return $this->_viewDatas;
}
@@ -206,11 +245,17 @@ abstract class BaseController extends Controller
$this->_viewDatas['fieldDatas'] = array();
foreach ($this->_viewDatas['fields'] as $field) {
$this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
- //보안문제,사용자정보의 update시 암호를 변경하지 않느경우를 위해
- if ($field != 'passwd') {
+ }
+ //변견된 데이터 Log로 남기기
+ foreach ($this->_viewDatas['fieldDatas'] as $field => $value) {
+ if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다.
log_message(
"info",
- "{$field} : {$entity->$field} => " . var_export($this->_viewDatas['fieldDatas'][$field])
+ sprintf(
+ "{$field} 변경: ---원본--\n%s\n---변경---\n%s",
+ $entity->$field,
+ var_export($value, true)
+ )
);
}
}
@@ -263,7 +308,14 @@ abstract class BaseController extends Controller
}
protected function reply_validate($entity)
{
- $this->update_validate($entity);
+ if (!$this->validate($this->_viewDatas['fieldRules'])) {
+ throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
+ }
+ //fieldData 적용
+ $this->_viewDatas['fieldDatas'] = array();
+ foreach ($this->_viewDatas['fields'] as $field) {
+ $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
+ }
}
protected function reply_process($entity)
{
@@ -292,11 +344,18 @@ abstract class BaseController extends Controller
//Toggle 관련
protected function toggle_validate($entity)
{
- $this->update_validate($entity);
+ if (!$this->validate($this->_viewDatas['fieldRules'])) {
+ throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
+ }
+ //fieldData 적용
+ $this->_viewDatas['fieldDatas'] = array();
+ foreach ($this->_viewDatas['fields'] as $field) {
+ $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
+ }
}
protected function toggle_process($entity)
{
- return $this->update_process($entity);
+ return $this->_model->modify($entity, $this->_viewDatas['fieldDatas']);
}
public function toggle($uid, string $field)
{
@@ -319,21 +378,29 @@ abstract class BaseController extends Controller
//Batchjob 관련
protected function batchjob_validate($entity)
{
- $this->update_validate($entity);
+ if (!$this->validate($this->_viewDatas['fieldRules'])) {
+ throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
+ }
+ //fieldData 적용
+ $this->_viewDatas['fieldDatas'] = array();
+ foreach ($this->_viewDatas['fields'] as $field) {
+ $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field, $entity);
+ }
}
protected function batchjob_process($entity)
{
- return $this->update_process($entity);
+ return $this->_model->modify($entity, $this->_viewDatas['fieldDatas']);
}
public function batchjob()
{
$msg = "";
+ $uids = array();
$entitys = array();
$batchjobs = array();
try {
//fields 해당하는 field중 선택된 값이 있는경우만 fields로 정의
$fields = array();
- foreach ($this->_model->getFieldBatchFilters() as $field) {
+ foreach ($this->getFieldBatchFilters() as $field) {
if ($this->request->getVar($field)) {
array_push($fields, $field);
}
@@ -377,6 +444,7 @@ abstract class BaseController extends Controller
count($entitys),
count($uids) - count($entitys),
__FUNCTION__,
+ $e->getMessage()
);
log_message("error", $e->getMessage());
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
@@ -449,7 +517,7 @@ abstract class BaseController extends Controller
$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_field'] = $this->request->getVar('order_field') ?: 'created_at';
$this->_viewDatas['order_value'] = $this->request->getVar('order_value') ?: 'DESC';
$this->_model->setCondition(
$filterFields,
@@ -515,6 +583,7 @@ abstract class BaseController extends Controller
//모델 처리
$this->_viewDatas['entitys'] = $this->index_getEntitys();
// echo $this->_model->getLastQuery();
+ // exit;
// log_message("debug", __METHOD__ . "에서 findAll 호출:" . $this->_model->getLastQuery());
//setting return_url to session flashdata
helper(['form']);
@@ -535,7 +604,7 @@ abstract class BaseController extends Controller
//Header용
$column = 'A';
foreach ($viewDatas['fields'] as $field) {
- $sheet->setCellValue($column++ . '1', lang($this->_model->getClassName() . '.label.' . $field));
+ $sheet->setCellValue($column++ . '1', lang($this->_viewDatas['className'] . '.label.' . $field));
}
//본문용
$line = 2;
@@ -585,6 +654,8 @@ abstract class BaseController extends Controller
throw new \Exception("첨부파일이 확인되지 않습니다.");
}
$entity = $this->download_process($entity);
+ echo "TEST";
+ exit;
list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field);
if (!is_file(PATHS['UPLOAD'] . "/" . $uploaded_filename)) {
throw new \Exception("파일이 확인되지 않습니다.\n" . PATHS['UPLOAD'] . "/" . $uploaded_filename);
diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php
index a3b02e5..530e388 100644
--- a/app/Controllers/Front/BoardController.php
+++ b/app/Controllers/Front/BoardController.php
@@ -11,9 +11,15 @@ class BoardController extends FrontController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
- $this->_model = new BoardModel($this->getFields());
parent::initController($request, $response, $logger);
- $this->_viewPath .= strtolower($this->_model->getClassName());
+ $this->_model = new BoardModel();
+ $this->_viewDatas['className'] = 'Board';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
+ // echo var_export($this->_viewDatas['layout'], true);
+ // exit;
}
public function getFields(string $action = ""): array
{
@@ -21,7 +27,7 @@ class BoardController extends FrontController
switch ($action) {
case "index":
case "excel":
- return ['title', "board_file", "view_cnt", "created_at"];
+ return ['title', "board_file", "created_at", "view_cnt"];
break;
case "view":
return ['title', "board_file", "view_cnt", "created_at", "content"];
@@ -39,19 +45,12 @@ class BoardController extends FrontController
{
return parent::getFieldBatchFilters();
}
- //Field별 Form Datas 처리용
- protected function getFieldFormData(string $field, $entity = null): array
+
+ //권한체크
+ protected function isRole($action)
{
- switch ($field) {
- case 'passwd':
- $this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field);
- $this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword');
- break;
- default:
- return parent::getFieldFormData($field, $entity);
- break;
- }
- return $this->_viewDatas['fieldDatas'];
+ $this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
+ parent::isRole($action);
}
//Insert관련
@@ -75,31 +74,42 @@ class BoardController extends FrontController
protected function update_form_process($entity)
{
//본인이 작성한글인지 최종확인용 정상접속이 아닌 위회해서 수정을 시도방지용
- if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->getUser_Uid() == $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
+ if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->user_uid != $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
throw new \Exception("작성자 본인글인지 여부가 확인되지 않습니다.");
}
- return parent::update_form_process($entity);
+ //권한체크
+ $this->isRole('update');
+ $entity = parent::update_form_process($entity);
+ $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
+ 'category' => $this->_category
+ ]];
+ return $entity;
}
protected function update_process($entity)
{
//본인이 작성한글인지 최종확인용 정상접속이 아닌 위회해서 수정을 시도방지용
- if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->getUser_Uid() == $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
+ if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->user_uid != $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
throw new \Exception("작성자 본인글인지 여부가 확인되지 않습니다.");
}
return parent::update_process($entity);
}
- //Reply관련
+ //Reply관련($entity는 부모의것임을 주의)
protected function reply_form_process($entity)
{
//권한체크
- $this->isRole('reply', $entity);
- return parent::reply_form_process($entity);
+ $this->isRole('reply');
+ $entity = parent::reply_form_process($entity);
+ $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
+ 'category_uid' => $entity->category_uid,
+ 'category' => $this->_category
+ ]];
+ return $entity;
}
//Delete 관련
protected function delete_process($entity)
{
//본인이 작성한글인지 최종확인용 정상접속이 아닌 위회해서 삭제 시도 방지용
- if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->getUser_Uid() == $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
+ if (!$this->_viewDatas[SESSION_NAMES['ISLOGIN']] || $entity->user_uid == $this->_viewDatas['auth'][AUTH_FIELDS['ID']]) {
throw new \Exception("작성자 본인글인지 여부가 확인되지 않습니다.");
}
return parent::delete_process($entity);
@@ -108,17 +118,24 @@ class BoardController extends FrontController
protected function view_process($entity)
{
//권한체크
- $this->isRole('view', $entity);
+ $this->isRole('view');
//조회수 올리기
- $this->_model->addViewCount($entity);
- return parent::view_process($entity);
+ $entity = $this->_model->addViewCount($entity);
+ $entity = parent::view_process($entity);
+ $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
+ 'category' => $this->_category
+ ]];
+ return $entity;
}
//Index관련
protected function index_process()
{
//권한체크
$this->isRole('index');
- return parent::index_process();
+ parent::index_process();
+ $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [
+ 'category' => $this->_category
+ ]];
}
//Category 및 Status 조건추가
protected function index_setCondition()
diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php
index c39edc3..dc508e4 100644
--- a/app/Controllers/Front/FrontController.php
+++ b/app/Controllers/Front/FrontController.php
@@ -3,10 +3,10 @@
namespace App\Controllers\Front;
use App\Controllers\BaseController;
+use App\Models\CategoryModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
-use App\Models\CategoryModel;
abstract class FrontController extends BaseController
{
@@ -15,7 +15,8 @@ abstract class FrontController extends BaseController
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
- $this->_viewPath .= 'front/';
+ $this->_viewPath = 'front/';
+ $this->_viewDatas['control'] = 'front';
$this->_viewDatas['layout'] = LAYOUTS['front'];
}
@@ -25,28 +26,29 @@ abstract class FrontController extends BaseController
}
//권한체크
- final protected function isRole($action, $entity = null)
+ protected function isRole($action)
{
- $this->_category = !is_null($entity) ? $entity->getCategory_Uid() : ($this->request->getVar('category') ?: throw new \Exception("범주를 지정하지 않으셨습니다."));
+ $this->_category ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
$this->_viewDatas['category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_category]);
+ $this->_viewDatas['parent_category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']->getHierarchy_ParentUID()]);
switch ($action) {
case 'insert':
- $category_field = CATEGORY_ROLE_FIELDS['WRITE'];
+ $category_field = getenv("category.role.{$action}") ?: 'iswrite';
break;
case 'reply':
- $category_field = CATEGORY_ROLE_FIELDS['REPLY'];
+ $category_field = getenv("category.role.{$action}") ?: 'isreply';
break;
case 'view':
- $category_field = CATEGORY_ROLE_FIELDS['READ'];
+ $category_field = getenv("category.role.{$action}") ?: 'isread';
break;
case 'upload':
- $category_field = CATEGORY_ROLE_FIELDS['UPLOAD'];
+ $category_field = getenv("category.role.{$action}") ?: 'isupload';
break;
case 'download':
- $category_field = CATEGORY_ROLE_FIELDS['DONWLOAD'];
+ $category_field = getenv("category.role.{$action}") ?: 'isdownload';
break;
default:
- $category_field = CATEGORY_ROLE_FIELDS['ACCESS'];
+ $category_field = getenv("category.role.{$action}") ?: 'isdaccess';
break;
}
//사용자가 Category에서 해당 게시판의 해당권한이 있는지 확인
@@ -55,13 +57,13 @@ abstract class FrontController extends BaseController
$this->_viewDatas['category'],
$category_field,
)) {
- echo var_export($this->_viewDatas['currentRoles'], true);
- echo " ";
- echo var_export($this->_viewDatas['category'], true);
- echo " ";
- echo "field->", $action . ":" . $category_field;
- exit;
- throw new \Exception("고객님은 " . lang($this->getCategoryModel()->getClassName() . ".label." . $category_field) . "이 없습니다.");
+ // echo var_export($this->_viewDatas['currentRoles'], true);
+ // echo " ";
+ // echo var_export($this->_viewDatas['category'], true);
+ // echo " ";
+ // echo "field->", $action . ":" . $category_field;
+ // exit;
+ throw new \Exception("고객님은 " . lang("Category.label." . $category_field) . "이 없습니다.");
}
}
}
diff --git a/app/Controllers/Front/SitepageController.php b/app/Controllers/Front/SitepageController.php
new file mode 100644
index 0000000..9dbdd95
--- /dev/null
+++ b/app/Controllers/Front/SitepageController.php
@@ -0,0 +1,67 @@
+_model = new SitepageModel();
+ $this->_viewDatas['className'] = 'Sitepage';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
+ }
+ public function getFields(string $action = ""): array
+ {
+ $fields = ["content"];
+ switch ($action) {
+ case "index":
+ case "excel":
+ return ['title', "created_at"];
+ break;
+ case "view":
+ return ['title', "created_at", "content"];
+ break;
+ default:
+ return $fields;
+ break;
+ }
+ }
+ public function getFieldFilters(): array
+ {
+ return [];
+ }
+ public function getFieldBatchFilters(): array
+ {
+ return parent::getFieldBatchFilters();
+ }
+
+ //권한체크
+ protected function isRole($action)
+ {
+ $this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다.");
+ parent::isRole($action);
+ }
+ //Index관련
+ protected function index_process()
+ {
+ //권한체크
+ $this->isRole('index');
+ return parent::index_process();
+ }
+ //Category 및 Status 조건추가
+ protected function index_setCondition()
+ {
+ $this->_model->where("category_uid", $this->_viewDatas['category']->getPrimaryKey());
+ $this->_model->where("status", DEFAULTS['STATUS']);
+ parent::index_setCondition();
+ }
+}
diff --git a/app/Controllers/Front/UserController.php b/app/Controllers/Front/UserController.php
index a49e403..a20b964 100644
--- a/app/Controllers/Front/UserController.php
+++ b/app/Controllers/Front/UserController.php
@@ -2,6 +2,7 @@
namespace App\Controllers\Front;
+use App\Libraries\Adapter\Auth\Auth as AuthAdapter;
use App\Models\UserModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@@ -9,11 +10,37 @@ use Psr\Log\LoggerInterface;
class UserController extends FrontController
{
+ private $_adapters = array();
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
- $this->_model = new UserModel();
parent::initController($request, $response, $logger);
- $this->_viewPath .= strtolower($this->_model->getClassName());
+ $this->_model = new UserModel();
+ $this->_viewDatas['className'] = 'User';
+ $this->_viewPath .= strtolower($this->_viewDatas['className']);
+ $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
+ $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
+ helper($this->_viewDatas['className']);
+
+ $this->initAdapters();
+ //Default 회원정보 Category
+ $this->_category = DEFAULTS['USER_CATEGORY'];
+ $this->isRole('index');
+ }
+
+ private function initAdapters()
+ {
+ foreach (array_keys(AUTH_ADAPTERS) as $adapter) {
+ $this->getAdapter($adapter);
+ }
+ }
+ private function getAdapter(string $site): AuthAdapter
+ {
+ $site = ucfirst($site);
+ if (!array_key_exists($site, $this->_adapters)) {
+ $adapterClass = sprintf("\App\Libraries\Adapter\Auth\%sAuth", $site);
+ $this->_adapters[$site] = new $adapterClass($site, AUTH_ADAPTERS[$site]['DEBUG']);
+ }
+ return $this->_adapters[$site];
}
//Field별 Form Datas 처리용
@@ -33,50 +60,82 @@ class UserController extends FrontController
public function getFields(string $action = ""): array
{
- $fields = ["id", "passwd", 'name', "email", "role", "status"];
switch ($action) {
+ case 'insert':
+ return ["id", "passwd", 'name', "email", "phone", "mobile"];
+ break;
+ case 'update':
+ return ["passwd", 'name', "email", "phone", "mobile"];
+ break;
case "index":
case "excel":
- return ["id", 'name', "email", "role", "status", 'created_at'];
+ return ["id", 'name', "email", "phone", "mobile", 'created_at'];
break;
case "view":
- return ["id", 'name', "email", "role", "status", 'updated_at', 'created_at'];
+ return ["id", 'name', "email", "phone", "mobile", 'updated_at', 'created_at'];
break;
default:
- return $fields;
+ return [];
break;
}
}
public function getFieldFilters(): array
{
- return ["role", "status"];
+ return [];
}
public function getFieldBatchFilters(): array
{
return parent::getFieldBatchFilters();
}
- protected function insert_validate()
+ //Insert관련
+ protected function insert_process()
{
- $rules = [];
- foreach ($this->_viewDatas['fieldRules'] as $field => $rule) {
- switch ($field) {
- case 'role':
- $rules[$field . '.*'] = $rule;
- break;
- default:
- $rules[$field] = $rule;
- break;
- }
+ //Role이 반드시 있어야 하기때문에
+ $this->_viewDatas['fieldDatas']['role'] = DEFAULTS['ROLE'] . ',user';
+ return parent::insert_process();
+ }
+
+ //Index관련
+ //사용자 UID 조건추가
+ protected function index_setCondition()
+ {
+ $this->_model->where("uid", $this->_viewDatas['auth'][AUTH_FIELDS['ID']]);
+ parent::index_setCondition();
+ }
+
+ //추가기능
+ public function login_form()
+ {
+ foreach ($this->_adapters as $key => $adapter) {
+ $this->_viewDatas['login_buttons'][$key] = $adapter->getAuthButton();
}
- //fieldData Rule 검사
- if (!$this->validate($rules)) {
- throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors()));
- }
- //fieldData 적용
- $this->_viewDatas['fieldDatas'] = array();
- foreach ($this->_viewDatas['fields'] as $field) {
- $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field);
+ $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []];
+ helper(['form']);
+ $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
+ return view($this->_viewPath . '/login' . $this->request->getVar('v') ?: '', ['viewDatas' => $this->_viewDatas]);
+ }
+
+ public function login(string $site)
+ {
+ try {
+ //각 Adapter별 인층체크 후 Session에 인증정보 설정
+ $this->getAdapter($site)->setFormDatas($this->request->getVar());
+ $this->getAdapter($site)->execute();
+ return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
+ } catch (\Exception $e) {
+ $this->_session->setFlashdata('return_message', $e->getMessage());
+ $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
+ return redirect()->back()->withInput();
}
}
+
+ public function logout()
+ {
+ //로그인 여부 확인후 Session에 Login 정보 삭제
+ if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
+ session_destroy();
+ }
+ return redirect()->route('/');
+ }
}
diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php
index ca4238a..4b86f99 100644
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -2,6 +2,7 @@
namespace App\Controllers;
+use App\Entities\CategoryEntity;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@@ -9,12 +10,36 @@ use Psr\Log\LoggerInterface;
class Home extends Controller
{
+ private $_session = null;
+ private $_viewDatas = array();
+ private $_viewPath = "";
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
+ $this->_viewDatas['control'] = 'main';
+ $this->_viewDatas['title'] = '쇼핑몰페이지';
+ $this->_viewDatas['layout'] = LAYOUTS['main'];
+ $this->_session = \Config\Services::session();
+ $this->_viewDatas['session'] = $this->_session;
+ $this->_viewDatas['className'] = 'MAIN';
+ // echo var_export($this->_viewDatas['layout'], true);
+ // exit;
+ //사용자 기본 Role 지정
+ $this->_viewDatas[SESSION_NAMES['ISLOGIN']] = false;
+ $this->_viewDatas['currentRoles'] = [DEFAULTS["ROLE"]];
+ if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) {
+ $this->_viewDatas[SESSION_NAMES['ISLOGIN']] = true;
+ $this->_viewDatas['auth'] = $this->_session->get(SESSION_NAMES['AUTH']);
+ $currentRoles = explode(DEFAULTS['DELIMITER_ROLE'], $this->_viewDatas['auth'][AUTH_FIELDS['ROLE']]);
+ $this->_viewDatas['currentRoles'] = is_array($currentRoles) ? $currentRoles : [DEFAULTS["ROLE"]];
+ }
+ //Default 회원정보 Category
+ $this->_viewDatas['category'] = new CategoryEntity(['uid' => 1]);
}
+
+
public function index()
{
- return view('welcome_message');
+ return view($this->_viewPath . 'welcome_message', ['viewDatas' => $this->_viewDatas]);
}
}
diff --git a/app/Controllers/Trait/UpDownloadTrait.php b/app/Controllers/Trait/UpDownloadTrait.php
index 982265d..5f86958 100644
--- a/app/Controllers/Trait/UpDownloadTrait.php
+++ b/app/Controllers/Trait/UpDownloadTrait.php
@@ -7,7 +7,7 @@ use CodeIgniter\HTTP\Files\UploadedFile;
trait UpDownloadTrait
{
//Upload FIle관련
- private function upDownload_file_process(UploadedFile $upfile): string
+ private function upDownload_file_process(UploadedFile $upfile): ?string
{
$filename = null;
$uploaded_filename = null;
@@ -17,10 +17,12 @@ trait UpDownloadTrait
$upfile->move(PATHS['UPLOAD'], $uploaded_filename);
//move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요
$uploaded_filename = $upfile->getName();
+ } else {
+ return null;
}
return $filename . DEFAULTS['DELIMITER_FILE'] . $uploaded_filename;
}
- public function upload_file_procedure(string $field): string
+ public function upload_file_procedure(string $field): ?string
{
return $this->upload_file_process($this->request->getFile($field));
}
@@ -32,7 +34,10 @@ trait UpDownloadTrait
if ($upfiles = $this->request->getFiles()) {
foreach ($upfiles[$field] as $upfile) {
if ($upfile->isValid() && !$upfile->hasMoved()) {
- array_push($files, $this->upload_file_process($upfile));
+ $file = $this->upload_file_process($upfile);
+ if (!is_null($file)) {
+ array_push($files, $file);
+ }
}
}
}
@@ -46,7 +51,7 @@ trait UpDownloadTrait
->resize($x, $y, true, 'height')
->save(PATHS['UPLOAD_IMAGE'] . $uploaded_filename);
}
- private function upload_image_process(UploadedFile $upfile): string
+ private function upload_image_process(UploadedFile $upfile): ?string
{
//참고:https://www.positronx.io/codeigniter-resize-image-with-image-manipulation-tutorial/
$filename = null;
@@ -60,11 +65,13 @@ trait UpDownloadTrait
$upfile->move(PATHS['UPLOAD_IMAGE'], $uploaded_filename);
//move시 중복된파일명이 있다면 파일명이 바뀌므로 여기서 한번더 파일명 확인 필요
$uploaded_filename = $upfile->getName();
+ } else {
+ return null;
}
return $filename . DEFAULTS['DELIMITER_FILE'] . $uploaded_filename;
}
- public function upload_image_procedure(string $field): string
+ public function upload_image_procedure(string $field): ?string
{
return $this->upload_image_process($this->request->getFile($field));
}
@@ -76,7 +83,10 @@ trait UpDownloadTrait
if ($upfiles = $this->request->getFiles()) {
foreach ($upfiles[$field] as $upfile) {
if ($upfile->isValid() && !$upfile->hasMoved()) {
- array_push($files, $this->upload_image_process($upfile));
+ $file = $this->upload_image_process($upfile);
+ if (!is_null($file)) {
+ array_push($files, $file);
+ }
}
}
}
diff --git a/app/Database/base.sql b/app/Database/base.sql
index d32f2dd..ed1812c 100644
--- a/app/Database/base.sql
+++ b/app/Database/base.sql
@@ -7,6 +7,8 @@ CREATE TABLE baseproject.tw_user (
passwd varchar(100) NOT NULL,
name varchar(20) NOT NULL COMMENT "사용자명",
email varchar(50) NOT NULL,
+ phone varchar(20) NULL COMMENT '연락처',
+ mobile varchar(20) NULL COMMENT '핸드폰',
role varchar(255) NOT NULL DEFAULT 'user' COMMENT '사용자등급',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,unuse: 사용않함',
updated_at timestamp NULL DEFAULT NULL,
@@ -50,7 +52,9 @@ CREATE TABLE baseproject.tw_category (
grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함',
grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
- name varchar(255) NOT NULL COMMENT '범주명',
+ parent_uid int(10) UNSIGNED NULL COMMENT '부모UID',
+ name varchar(255) NOT NULL COMMENT '분류명',
+ linkurl varchar(100) NOT NULL DEFAULT '/front/board' COMMENT 'Front Link URL',
isaccess varchar(30) NOT NULL DEFAULT 'guest' COMMENT '접근권한',
isread varchar(30) NOT NULL DEFAULT 'guest' COMMENT '읽기권한',
iswrite varchar(30) NOT NULL DEFAULT 'guest' COMMENT '쓰기권한',
@@ -64,7 +68,7 @@ CREATE TABLE baseproject.tw_category (
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (uid)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='범주';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='분류';
DROP TABLE IF EXISTS baseproject.tw_board;
-- 1. 게시물 추가전 grpno에 해당하는 max(grporder)+1씩증가 작업
@@ -78,7 +82,8 @@ CREATE TABLE baseproject.tw_board (
grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함',
grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
- category_uid int(10) UNSIGNED NOT NULL COMMENT '범주 UID',
+ parent_uid int(10) UNSIGNED NULL COMMENT '부모UID',
+ category_uid int(10) UNSIGNED NOT NULL COMMENT '분류 UID',
user_uid varchar(36) NULL COMMENT '작성자 정보',
title varchar(255) NOT NULL COMMENT '제목',
content text NOT NULL COMMENT '내용',
@@ -92,4 +97,20 @@ CREATE TABLE baseproject.tw_board (
PRIMARY KEY (uid),
CONSTRAINT FOREIGN KEY (category_uid) REFERENCES tw_category (uid),
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='게시물 정보';
\ No newline at end of file
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='게시물 정보';
+
+DROP TABLE IF EXISTS baseproject.tw_sitepage;
+CREATE TABLE baseproject.tw_sitepage (
+ uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ category_uid int(10) UNSIGNED NOT NULL COMMENT '분류 UID',
+ user_uid varchar(36) NULL COMMENT '작성자 정보',
+ title varchar(255) NOT NULL COMMENT '제목',
+ content text NOT NULL COMMENT '내용',
+ status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용, unuse: 사용않함 등등',
+ updated_at timestamp NULL DEFAULT NULL,
+ created_at timestamp NOT NULL DEFAULT current_timestamp(),
+ deleted_at timestamp NULL DEFAULT NULL,
+ PRIMARY KEY (uid),
+ CONSTRAINT FOREIGN KEY (category_uid) REFERENCES tw_category (uid),
+ CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='사이트페이지 정보';
\ No newline at end of file
diff --git a/app/Database/hpilo.sql b/app/Database/hpilo.sql
index 5f6b756..2efdb04 100644
--- a/app/Database/hpilo.sql
+++ b/app/Database/hpilo.sql
@@ -7,6 +7,8 @@ CREATE TABLE servermgr.tw_user (
passwd varchar(100) NOT NULL,
name varchar(20) NOT NULL COMMENT "사용자명",
email varchar(50) NOT NULL,
+ phone varchar(20) NULL COMMENT '연락처',
+ mobile varchar(20) NULL COMMENT '핸드폰',
role varchar(255) NOT NULL DEFAULT 'user' COMMENT '사용자등급',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,unuse: 사용않함',
updated_at timestamp NULL DEFAULT NULL,
@@ -50,7 +52,9 @@ CREATE TABLE servermgr.tw_category (
grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함',
grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
- name varchar(255) NOT NULL COMMENT '범주명',
+ parent_uid int(10) UNSIGNED NULL COMMENT '부모UID',
+ name varchar(255) NOT NULL COMMENT '분류명',
+ linkurl varchar(100) NOT NULL DEFAULT '/front/board' COMMENT 'Front Link URL',
isaccess varchar(30) NOT NULL DEFAULT 'guest' COMMENT '접근권한',
isread varchar(30) NOT NULL DEFAULT 'guest' COMMENT '읽기권한',
iswrite varchar(30) NOT NULL DEFAULT 'guest' COMMENT '쓰기권한',
@@ -64,7 +68,7 @@ CREATE TABLE servermgr.tw_category (
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (uid)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='범주';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='분류';
DROP TABLE IF EXISTS servermgr.tw_board;
-- 1. 게시물 추가전 grpno에 해당하는 max(grporder)+1씩증가 작업
@@ -78,7 +82,8 @@ CREATE TABLE servermgr.tw_board (
grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함',
grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작',
grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요',
- category_uid int(10) UNSIGNED NOT NULL COMMENT '범주 UID',
+ parent_uid int(10) UNSIGNED NULL COMMENT '부모UID',
+ category_uid int(10) UNSIGNED NOT NULL COMMENT '분류 UID',
user_uid varchar(36) NULL COMMENT '작성자 정보',
title varchar(255) NOT NULL COMMENT '제목',
content text NOT NULL COMMENT '내용',
@@ -94,6 +99,22 @@ CREATE TABLE servermgr.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 servermgr.tw_sitepage;
+CREATE TABLE servermgr.tw_sitepage (
+ uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ category_uid int(10) UNSIGNED NOT NULL COMMENT '분류 UID',
+ user_uid varchar(36) NULL COMMENT '작성자 정보',
+ title varchar(255) NOT NULL COMMENT '제목',
+ content text NOT NULL COMMENT '내용',
+ status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용, unuse: 사용않함 등등',
+ updated_at timestamp NULL DEFAULT NULL,
+ created_at timestamp NOT NULL DEFAULT current_timestamp(),
+ deleted_at timestamp NULL DEFAULT NULL,
+ PRIMARY KEY (uid),
+ CONSTRAINT FOREIGN KEY (category_uid) REFERENCES tw_category (uid),
+ CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='사이트페이지 정보';
+
DROP TABLE IF EXISTS servermgr.tw_hpilo;
CREATE TABLE
diff --git a/app/Entities/BaseEntity.php b/app/Entities/BaseEntity.php
index f3f4b05..3e6972d 100644
--- a/app/Entities/BaseEntity.php
+++ b/app/Entities/BaseEntity.php
@@ -6,6 +6,14 @@ use CodeIgniter\Entity\Entity;
abstract class BaseEntity extends Entity
{
- abstract public function getPrimaryKey();
abstract public function getTitle(): string;
+ final public function getPrimaryKey()
+ {
+ return $this->attributes['uid'];
+ }
+ //조화수관련 Field전용
+ final public function getViews($field = 'view_cnt')
+ {
+ return $this->attributes[$field];
+ }
}
diff --git a/app/Entities/BaseHierarchyEntity.php b/app/Entities/BaseHierarchyEntity.php
index ff5ebc7..5eb3bec 100644
--- a/app/Entities/BaseHierarchyEntity.php
+++ b/app/Entities/BaseHierarchyEntity.php
@@ -16,4 +16,8 @@ abstract class BaseHierarchyEntity extends BaseEntity
{
return $this->attributes['grpdepth'];
}
+ final public function getHierarchy_ParentUID()
+ {
+ return $this->attributes['parent_uid'];
+ }
}
diff --git a/app/Entities/BoardEntity.php b/app/Entities/BoardEntity.php
index a459f73..09f5b2f 100644
--- a/app/Entities/BoardEntity.php
+++ b/app/Entities/BoardEntity.php
@@ -9,42 +9,26 @@ class BoardEntity extends BaseHierarchyEntity
protected $casts = [];
//기본기능
- public function getPrimaryKey()
- {
- return $this->attributes['uid'];
- }
public function getTitle(): string
{
return $this->attributes['title'];
}
- public function getStatus(): string
- {
- return $this->attributes['status'];
- }
-
//추가기능
- public function getCategory_Uid()
- {
- return $this->attributes['category_uid'];
- }
- public function getUser_Uid()
- {
- return $this->attributes['user_uid'];
- }
public function getPassword()
{
return $this->attributes['passwd'];
}
- public function getViews()
+ //파일관련 Field전용
+ final public function getFileDownload($url, $field = "upload_file")
{
- return $this->attributes['view_cnt'];
- }
- public function getBoardFile()
- {
- return $this->attributes['board_file'];
- }
- public function getBoardFileName()
- {
- return explode(DEFAULTS['DELIMITER_FILE'], $this->getBoardFile())[1];
+ if (is_null($this->attributes[$field])) {
+ return "";
+ }
+ $files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]);
+ return anchor(
+ $url,
+ ICONS['IMAGE_FILE'] . $files[0],
+ ["target" => "_self"]
+ );
}
}
diff --git a/app/Entities/CategoryEntity.php b/app/Entities/CategoryEntity.php
index 8f92b43..994b647 100644
--- a/app/Entities/CategoryEntity.php
+++ b/app/Entities/CategoryEntity.php
@@ -2,8 +2,6 @@
namespace App\Entities;
-use App\Entities\Trait\HierarchyTrait;
-
class CategoryEntity extends BaseHierarchyEntity
{
protected $datamap = [];
@@ -11,28 +9,12 @@ class CategoryEntity extends BaseHierarchyEntity
protected $casts = [];
//기본기능
- public function getPrimaryKey()
- {
- return $this->attributes['uid'];
- }
public function getTitle(): string
{
return $this->attributes['name'];
}
- public function getStatus(): string
- {
- return $this->attributes['status'];
- }
-
//추가기능
- public function getHead()
- {
- return $this->attributes['head'];
- }
- public function getTail()
- {
- return $this->attributes['tail'];
- }
+ //CommonHelper에서 사용
public function getRole($field = 'isaccess')
{
return array_key_exists(
diff --git a/app/Entities/SitepageEntity.php b/app/Entities/SitepageEntity.php
new file mode 100644
index 0000000..e8e289a
--- /dev/null
+++ b/app/Entities/SitepageEntity.php
@@ -0,0 +1,17 @@
+attributes['title'];
+ }
+ //추가기능
+}
diff --git a/app/Entities/UserEntity.php b/app/Entities/UserEntity.php
index 9344533..dc04d58 100644
--- a/app/Entities/UserEntity.php
+++ b/app/Entities/UserEntity.php
@@ -9,25 +9,11 @@ class UserEntity extends BaseEntity
protected $casts = [];
//기본기능
- public function getPrimaryKey()
- {
- return $this->attributes['uid'];
- }
public function getTitle(): string
{
return $this->attributes['name'];
}
- public function getStatus(): string
- {
- return $this->attributes['status'];
- }
-
//추가기능
- public function getRole()
- {
- return $this->attributes['role'];
- }
-
public function getPassword()
{
return $this->attributes['passwd'];
diff --git a/app/Entities/UserSNSEntity.php b/app/Entities/UserSNSEntity.php
index d1e02ec..cb5b5c8 100644
--- a/app/Entities/UserSNSEntity.php
+++ b/app/Entities/UserSNSEntity.php
@@ -9,18 +9,9 @@ class UserSNSEntity extends BaseEntity
protected $casts = [];
//기본기능
- public function getPrimaryKey()
- {
- return $this->attributes['uid'];
- }
public function getTitle(): string
{
return $this->attributes['name'];
}
- public function getStatus(): string
- {
- return $this->attributes['status'];
- }
-
//추가기능
}
diff --git a/app/Filters/AuthFilter.php b/app/Filters/AuthFilter.php
index e76c6da..93639ee 100644
--- a/app/Filters/AuthFilter.php
+++ b/app/Filters/AuthFilter.php
@@ -30,7 +30,7 @@ class AuthFilter implements FilterInterface
$auth = session()->get(SESSION_NAMES['AUTH']);
// 회원 ROLES이 필요ROLE($arguments[0]) 목록에 존재하지 않으면(ACL)
if (!in_array($arguments[0], explode(DEFAULTS['DELIMITER_ROLE'], $auth[AUTH_FIELDS['ROLE']]))) {
- return redirect()->to('/login')->with(
+ return redirect()->to(URLS['LOGIN'])->with(
'return_message',
sprintf(
"%s,%s회원님은 접속에 필요한 권한[%s]이 없습니다. ",
@@ -42,7 +42,7 @@ class AuthFilter implements FilterInterface
}
} else {
session()->setFlashdata(SESSION_NAMES['RETURN_URL'], $request->getUri()->getPath() . '?' . $request->getUri()->getQuery());
- return redirect()->to('/login')->with('return_message', '로그인을하셔야합니다.');
+ return redirect()->to(URLS['LOGIN'])->with('return_message', '로그인을하셔야합니다.');
}
}
diff --git a/app/Helpers/Board_helper.php b/app/Helpers/Board_helper.php
index b0abf09..08fb08c 100644
--- a/app/Helpers/Board_helper.php
+++ b/app/Helpers/Board_helper.php
@@ -73,28 +73,18 @@ function getFieldView_BoardHelper($field, $entity, array $viewDatas)
}
return $value;
break;
- case 'title':
- case 'name':
- $reply = anchor(
- current_url() . '/reply/' . $entity->getPrimaryKey(),
- ICONS['REPLY'],
- ["target" => "_self"]
- );
- $view = anchor(
- current_url() . '/view/' . $entity->getPrimaryKey(),
- $value,
- ["target" => "_self"]
- );
- return sprintf(
- "%s %s
",
- $entity->getHierarchy_Depth() * DEFAULTS['HIERARCHY_GRPDEPTH'],
- $reply,
- $view
- );
- break;
case 'board_file':
case 'upload_file':
- return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]);
+ return $entity->getFileDownload(
+ base_url() .
+ $viewDatas['control'] .
+ "/board/download/{$field}/{$entity->getPrimaryKey()}" .
+ '?category=' . $viewDatas['category']->getPrimaryKey(),
+ $field
+ );
+ break;
+ case 'photo':
+ return $entity->getFileImage('middle', $field);
break;
case 'view_cnt':
return number_format(!$value ? 0 : $value);
@@ -121,22 +111,79 @@ function getFieldFilter_BoardHelper($field, $value, array $viewDatas)
function getFieldIndex_Column_BoardHelper($field, array $viewDatas)
{
$label = lang("{$viewDatas['className']}.label.{$field}");
- $label = $field == $viewDatas['order_field'] ? sprintf('%s ', $label, $viewDatas['order_value'] == 'ASC' ? "up" : "down") : $label;
+ if ($field == $viewDatas['order_field']) {
+ $label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
+ }
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
- return anchor(current_url() . "?order_field={$field}&order_value={$value}", $label);
+ $viewDatas['uri']->addQuery('order_field', $field);
+ $viewDatas['uri']->addQuery('order_value', $value);
+ $columnData = anchor($viewDatas['uri'], $label);
+ switch ($field) {
+ case 'title':
+ case 'name':
+ return sprintf("%s ", $columnData);
+ break;
+ default:
+ return sprintf("%s ", $columnData);
+ break;
+ }
} //
-
+//Front용
function getFieldIndex_Row_BoardHelper($field, $entity, array $viewDatas): string
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
+ case 'title':
+ case 'name':
+ $depth = " ";
+ for ($i = 1; $i < $entity->getHierarchy_Depth(); $i++) {
+ $depth .= " ";
+ }
+ $reply = anchor(
+ current_url() . '/reply/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
+ ICONS['REPLY'],
+ ["target" => "_self"]
+ );
+ $view = anchor(
+ current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
+ $value,
+ ["target" => "_self"]
+ );
+ return sprintf("%s%s %s", $depth, $reply, $view);
+ break;
default:
return getFieldView_BoardHelper($field, $entity, $viewDatas);
break;
}
} //
+
+//Admin용
function getFieldIndex_Row_BoardHelper_Admin($field, $entity, array $viewDatas): string
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
+ case 'title':
+ case 'name':
+ $depth = " ";
+ for ($i = 1; $i < $entity->getHierarchy_Depth(); $i++) {
+ $depth .= " ";
+ }
+ $reply = anchor(
+ current_url() . '/reply/' . $entity->getPrimaryKey(),
+ ICONS['REPLY'],
+ ["target" => "_self"]
+ );
+ $view = anchor(
+ current_url() . '/view/' . $entity->getPrimaryKey(),
+ $value,
+ ["target" => "_self"]
+ );
+ return sprintf("%s%s %s", $depth, $reply, $view);
+ break;
+ case 'board_file':
+ case 'upload_file':
+ return $entity->getFileDownload(base_url() . $viewDatas['control'] . '/board', $field);
+ break;
default:
if (in_array($field, $viewDatas['fieldFilters'])) {
$attributes["onChange"] = sprintf(
@@ -148,7 +195,7 @@ function getFieldIndex_Row_BoardHelper_Admin($field, $entity, array $viewDatas):
);
return getFieldForm_BoardHelper($field, $entity->$field, $viewDatas, $attributes);
}
- return getFieldView_BoardHelper($field, $entity, $viewDatas);
+ return getFieldIndex_Row_BoardHelper($field, $entity, $viewDatas);
break;
}
} //
\ No newline at end of file
diff --git a/app/Helpers/Category_helper.php b/app/Helpers/Category_helper.php
index f4d16f9..efca5ac 100644
--- a/app/Helpers/Category_helper.php
+++ b/app/Helpers/Category_helper.php
@@ -40,10 +40,15 @@ function getFieldForm_CategoryHelper($field, $value, array $viewDatas, array $at
case 'content':
case 'head':
case 'tail':
- return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
+ return form_textarea(
+ $field,
+ html_entity_decode($value),
+ ['class' => 'editor', 'rows' => '20', 'cols' => '100']
+ );
break;
case 'upload_file':
case 'board_file':
+ case 'photo':
return form_upload($field);
break;
case 'view_cnt':
@@ -67,29 +72,6 @@ function getFieldView_CategoryHelper($field, $entity, array $viewDatas)
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
- case 'title':
- case 'name':
- $reply = anchor(
- current_url() . '/reply/' . $entity->getPrimaryKey(),
- ICONS['REPLY'],
- ["target" => "_self"]
- );
- $view = anchor(
- current_url() . '/view/' . $entity->getPrimaryKey(),
- $value,
- ["target" => "_self"]
- );
- return sprintf(
- "%s %s
",
- $entity->getHierarchy_Depth() * DEFAULTS['HIERARCHY_GRPDEPTH'],
- $reply,
- $view
- );
- break;
- case 'board_file':
- case 'upload_file':
- return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]);
- break;
case 'view_cnt':
return number_format(!$value ? 0 : $value);
break;
@@ -115,11 +97,25 @@ function getFieldFilter_CategoryHelper($field, $value, array $viewDatas)
function getFieldIndex_Column_CategoryHelper($field, array $viewDatas)
{
$label = lang("{$viewDatas['className']}.label.{$field}");
- $label = $field == $viewDatas['order_field'] ? sprintf('%s ', $label, $viewDatas['order_value'] == 'ASC' ? "up" : "down") : $label;
+ if ($field == $viewDatas['order_field']) {
+ $label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
+ }
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
- return anchor(current_url() . "?order_field={$field}&order_value={$value}", $label);
+ $viewDatas['uri']->addQuery('order_field', $field);
+ $viewDatas['uri']->addQuery('order_value', $value);
+ $columnData = anchor($viewDatas['uri'], $label);
+ switch ($field) {
+ case 'title':
+ case 'name':
+ return sprintf("%s ", $columnData);
+ break;
+ default:
+ return sprintf("%s ", $columnData);
+ break;
+ }
} //
+//Front용
function getFieldIndex_Row_CategoryHelper($field, $entity, array $viewDatas): string
{
switch ($field) {
@@ -128,9 +124,29 @@ function getFieldIndex_Row_CategoryHelper($field, $entity, array $viewDatas): st
break;
}
} //
+//Admin용
function getFieldIndex_Row_CategoryHelper_Admin($field, $entity, array $viewDatas): string
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
+ case 'title':
+ case 'name':
+ $depth = " ";
+ for ($i = 1; $i < $entity->getHierarchy_Depth(); $i++) {
+ $depth .= " ";
+ }
+ $reply = anchor(
+ current_url() . '/reply/' . $entity->getPrimaryKey(),
+ ICONS['REPLY'],
+ ["target" => "_self"]
+ );
+ $view = anchor(
+ current_url() . '/view/' . $entity->getPrimaryKey(),
+ $value,
+ ["target" => "_self"]
+ );
+ return sprintf("%s%s %s", $depth, $reply, $view);
+ break;
default:
if (in_array($field, $viewDatas['fieldFilters'])) {
$attributes["onChange"] = sprintf(
@@ -142,7 +158,7 @@ function getFieldIndex_Row_CategoryHelper_Admin($field, $entity, array $viewData
);
return getFieldForm_CategoryHelper($field, $entity->$field, $viewDatas, $attributes);
}
- return getFieldView_CategoryHelper($field, $entity, $viewDatas);
+ return getFieldIndex_Row_CategoryHelper($field, $entity, $viewDatas);
break;
}
} //
\ No newline at end of file
diff --git a/app/Helpers/Common_helper.php b/app/Helpers/Common_helper.php
index 1f03706..51c03f0 100644
--- a/app/Helpers/Common_helper.php
+++ b/app/Helpers/Common_helper.php
@@ -148,17 +148,6 @@ function alert_CommonHelper(string $msg, $url = null)
return "";
} //
-function imageSubmit_CommonHelper(string $src, array $attributes = [])
-{
- return form_input([
- 'type' => 'image',
- 'src' => base_url() . $src,
- 'name' => array_key_exists('name', $attributes) ? $attributes['name'] : "",
- 'value' => array_key_exists('value', $attributes) ? $attributes['value'] : "",
- ...$attributes,
- ]);
-}
-
// STATUS가 use가 아닐때 option을 disabled되게 하기위함 (override form_dropdown)
function form_dropdown_test($data = '', $options = [], $selected = [], $extra = ''): string
{
diff --git a/app/Helpers/Sitepage_helper.php b/app/Helpers/Sitepage_helper.php
new file mode 100644
index 0000000..c4af69c
--- /dev/null
+++ b/app/Helpers/Sitepage_helper.php
@@ -0,0 +1,161 @@
+%s", implode(" ", $attributes), lang("{$viewDatas['className']}.label.{$field}"));
+ break;
+ }
+}
+//header.php에서 getFieldForm_Helper사용
+function getFieldForm_SitepageHelper($field, $value, array $viewDatas, array $attributes = array())
+{
+ $value = $value ?: DEFAULTS['EMPTY'];
+ switch ($field) {
+ case "category_uid":
+ case "user_uid":
+ $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
+ return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
+ break;
+ case 'title':
+ case 'name':
+ return form_input($field, $value, ["placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
+ break;
+ case 'passwd':
+ return sprintf(
+ "%s %s %s",
+ form_password($field, DEFAULTS['EMPTY']),
+ lang("{$viewDatas['className']}.label.confirmpassword"),
+ form_password('confirmpassword', DEFAULTS['EMPTY']),
+ );
+ break;
+ case 'content':
+ case 'head':
+ case 'tail':
+ return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']);
+ break;
+ case 'upload_file':
+ case 'board_file':
+ return form_upload($field);
+ break;
+ case 'view_cnt':
+ return form_input($field, $value, ['type' => 'number']);
+ break;
+ case "status":
+ $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
+ return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, $attributes);
+ break;
+ case 'updated_at':
+ case 'created_at':
+ return form_input($field, $value, ['class' => 'calender']);
+ break;
+ default:
+ return form_input($field, $value);
+ break;
+ }
+} //
+
+function getFieldView_SitepageHelper($field, $entity, array $viewDatas)
+{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
+ switch ($field) {
+ case 'category_uid':
+ foreach (array_values($viewDatas['fieldFormOptions'][$field]) as $category_2depths) {
+ foreach ($category_2depths as $key => $label) {
+ if ($key == $value) {
+ return $label;
+ }
+ }
+ }
+ return $value;
+ break;
+ case 'view_cnt':
+ return number_format(!$value ? 0 : $value);
+ break;
+ case 'content':
+ return html_entity_decode($value);
+ break;
+ case 'updated_at':
+ case 'created_at':
+ return $value ? str_split($value, 10)[0] : "";
+ break;
+ default:
+ return in_array($field, $viewDatas['fieldFilters']) && $value ? $viewDatas['fieldFormOptions'][$field][$value] : $value;
+ break;
+ }
+} //
+
+function getFieldFilter_SitepageHelper($field, $value, array $viewDatas)
+{
+ $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
+ return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, ['class' => "select-field"]);
+} //
+
+function getFieldIndex_Column_SitepageHelper($field, array $viewDatas)
+{
+ $label = lang("{$viewDatas['className']}.label.{$field}");
+ if ($field == $viewDatas['order_field']) {
+ $label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
+ }
+ $value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
+ $viewDatas['uri']->addQuery('order_field', $field);
+ $viewDatas['uri']->addQuery('order_value', $value);
+ $columnData = anchor($viewDatas['uri'], $label);
+ switch ($field) {
+ case 'title':
+ case 'name':
+ return sprintf("%s ", $columnData);
+ break;
+ default:
+ return sprintf("%s ", $columnData);
+ break;
+ }
+} //
+
+//Front용
+function getFieldIndex_Row_SitepageHelper($field, $entity, array $viewDatas): string
+{
+ //front쪽은 table을 사용하지 않음 주의
+ switch ($field) {
+ case 'content':
+ return getFieldView_SitepageHelper($field, $entity, $viewDatas);
+ break;
+ default:
+ return getFieldView_SitepageHelper($field, $entity, $viewDatas);
+ break;
+ }
+} //
+
+//Admin용
+function getFieldIndex_Row_SitepageHelper_Admin($field, $entity, array $viewDatas): string
+{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
+ switch ($field) {
+ case 'title':
+ case 'name':
+ return anchor(
+ current_url() . '/view/' . $entity->getPrimaryKey(),
+ $value,
+ ["target" => "_self"]
+ );
+ break;
+ default:
+ if (in_array($field, $viewDatas['fieldFilters'])) {
+ $attributes["onChange"] = sprintf(
+ 'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
+ current_url(),
+ $entity->getPrimaryKey(),
+ $field,
+ $field
+ );
+ return getFieldForm_SitepageHelper($field, $entity->$field, $viewDatas, $attributes);
+ }
+ //front쪽은 table을 사용하지 않음 주의
+ return getFieldIndex_Row_SitepageHelper($field, $entity, $viewDatas);
+ break;
+ }
+} //
\ No newline at end of file
diff --git a/app/Helpers/UserSNS_helper.php b/app/Helpers/UserSNS_helper.php
index 9a45ba5..7696248 100644
--- a/app/Helpers/UserSNS_helper.php
+++ b/app/Helpers/UserSNS_helper.php
@@ -71,21 +71,6 @@ function getFieldView_UserSNSHelper($field, $entity, array $viewDatas)
}
return $categorys[$value];
break;
- case 'title':
- case 'name':
- return anchor(
- current_url() . '/view/' . $entity->getPrimaryKey(),
- $value,
- ["target" => "_self"]
- );
- break;
- case 'board_file':
- case 'upload_file':
- return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]);
- break;
- case 'view_cnt':
- return number_format(!$value ? 0 : $value);
- break;
case 'content':
return html_entity_decode($value);
break;
@@ -108,19 +93,43 @@ function getFieldFilter_UserSNSHelper($field, $value, array $viewDatas)
function getFieldIndex_Column_UserSNSHelper($field, array $viewDatas)
{
$label = lang("{$viewDatas['className']}.label.{$field}");
- $label = $field == $viewDatas['order_field'] ? sprintf('%s ', $label, $viewDatas['order_value'] == 'ASC' ? "up" : "down") : $label;
+ if ($field == $viewDatas['order_field']) {
+ $label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
+ }
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
- return anchor(current_url() . "?order_field={$field}&order_value={$value}", $label);
+ $viewDatas['uri']->addQuery('order_field', $field);
+ $viewDatas['uri']->addQuery('order_value', $value);
+ $columnData = anchor($viewDatas['uri'], $label);
+ switch ($field) {
+ case 'title':
+ case 'name':
+ return sprintf("%s ", $columnData);
+ break;
+ default:
+ return sprintf("%s ", $columnData);
+ break;
+ }
} //
+//Front용
function getFieldIndex_Row_UserSNSHelper($field, $entity, array $viewDatas): string
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
+ case 'title':
+ case 'name':
+ return anchor(
+ current_url() . '/view/' . $entity->getPrimaryKey(),
+ $value,
+ ["target" => "_self"]
+ );
+ break;
default:
return getFieldView_UserSNSHelper($field, $entity, $viewDatas);
break;
}
} //
+//Admin용
function getFieldIndex_Row_UserSNSHelper_Admin($field, $entity, array $viewDatas): string
{
switch ($field) {
@@ -135,7 +144,7 @@ function getFieldIndex_Row_UserSNSHelper_Admin($field, $entity, array $viewDatas
);
return getFieldForm_UserSNSHelper($field, $entity->$field, $viewDatas, $attributes);
}
- return getFieldView_UserSNSHelper($field, $entity, $viewDatas);
+ return getFieldIndex_Row_UserSNSHelper($field, $entity, $viewDatas);
break;
}
} //
\ No newline at end of file
diff --git a/app/Helpers/User_helper.php b/app/Helpers/User_helper.php
index 0d62bff..9469838 100644
--- a/app/Helpers/User_helper.php
+++ b/app/Helpers/User_helper.php
@@ -77,18 +77,6 @@ function getFieldView_UserHelper($field, $entity, array $viewDatas)
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
- case 'title':
- case 'name':
- return anchor(
- current_url() . '/view/' . $entity->getPrimaryKey(),
- $value,
- ["target" => "_self"]
- );
- break;
- case 'board_file':
- case 'upload_file':
- return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]);
- break;
case 'view_cnt':
return number_format(!$value ? 0 : $value);
break;
@@ -114,24 +102,41 @@ function getFieldFilter_UserHelper($field, $value, array $viewDatas)
function getFieldIndex_Column_UserHelper($field, array $viewDatas)
{
$label = lang("{$viewDatas['className']}.label.{$field}");
- $label = $field == $viewDatas['order_field'] ? sprintf('%s ', $label, $viewDatas['order_value'] == 'ASC' ? "up" : "down") : $label;
+ if ($field == $viewDatas['order_field']) {
+ $label .= $viewDatas['order_value'] == 'ASC' ? ICONS['UP'] : ICONS['DOWN'];
+ }
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
- return anchor(current_url() . "?order_field={$field}&order_value={$value}", $label);
+ $viewDatas['uri']->addQuery('order_field', $field);
+ $viewDatas['uri']->addQuery('order_value', $value);
+ $columnData = anchor($viewDatas['uri'], $label);
+ switch ($field) {
+ case 'title':
+ case 'name':
+ return sprintf("%s ", $columnData);
+ break;
+ default:
+ return sprintf("%s ", $columnData);
+ break;
+ }
} //
+//Front용
function getFieldIndex_Row_UserHelper($field, $entity, array $viewDatas): string
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
default:
return getFieldView_UserHelper($field, $entity, $viewDatas);
break;
}
} //
+
+//Admin용
function getFieldIndex_Row_UserHelper_Admin($field, $entity, array $viewDatas): string
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'role':
- $value = $entity->$field ?: DEFAULTS['EMPTY'];
// $viewDatas['fieldFormOptions'][$field] = [DEFAULTS['EMPTY'] => lang("{$viewDatas['className']}.label.{$field}") . " 선택", ...$viewDatas['fieldFormOptions'][$field]];
// return form_dropdown($field, $viewDatas['fieldFormOptions'][$field], $value, [...$attributes, 'class' => "select-field"]);
// return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
@@ -151,7 +156,7 @@ function getFieldIndex_Row_UserHelper_Admin($field, $entity, array $viewDatas):
);
return getFieldForm_UserHelper($field, $entity->$field, $viewDatas, $attributes);
}
- return getFieldView_UserHelper($field, $entity, $viewDatas);
+ return getFieldIndex_Row_UserHelper($field, $entity, $viewDatas);
break;
}
} //
\ No newline at end of file
diff --git a/app/Language/ko/Board.php b/app/Language/ko/Board.php
index 1bd2233..2ceec00 100644
--- a/app/Language/ko/Board.php
+++ b/app/Language/ko/Board.php
@@ -6,7 +6,7 @@ return [
'grpno' => "그룹번호",
'grpord' => "부모번호",
'grpdpt' => "그룸Depth",
- 'category_uid' => "범주",
+ 'category_uid' => "분류",
'user_uid' => "작성자",
'title' => "제목",
'content' => "내용",
diff --git a/app/Language/ko/Category.php b/app/Language/ko/Category.php
index 548bc6e..51d7fef 100644
--- a/app/Language/ko/Category.php
+++ b/app/Language/ko/Category.php
@@ -1,14 +1,16 @@
'비회원', 'user' => '일반회원', 'vip' => 'VIP회원',
- 'bronze' => '일반판매자', 'silver' => '고급판매자', 'gold' => '파워리셀러',
- 'manager' => '관리자', 'cloudflare' => "Cloudflare관리자", 'director' => '감독자', 'master' => "마스터",
+ 'manager' => '관리자', 'cloudflare' => "Cloudflare관리자",
+ 'director' => '감독자', 'master' => "마스터",
];
return [
- 'title' => "범주 정보",
+ 'title' => "분류 정보",
'label' => [
'uid' => "번호",
- 'name' => "범주제목",
+ 'name' => "분류제목",
+ 'linkurl' => "LinkURL",
+ 'photo' => "이미지",
'isaccess' => "접속권한",
'isread' => "읽기권한",
'iswrite' => "쓰기권한",
diff --git a/app/Language/ko/Sitepage.php b/app/Language/ko/Sitepage.php
new file mode 100644
index 0000000..b0b8210
--- /dev/null
+++ b/app/Language/ko/Sitepage.php
@@ -0,0 +1,15 @@
+ "사이트페이지 정보",
+ 'label' => [
+ 'uid' => "번호",
+ 'category_uid' => "분류",
+ 'user_uid' => "작성자",
+ 'title' => "제목",
+ 'content' => "내용",
+ 'status' => "상태",
+ 'updated_at' => "수정일",
+ 'created_at' => "작성일"
+ ],
+ 'STATUS' => ['use' => '사용', 'unuse' => '사용않함'],
+];
diff --git a/app/Language/ko/User.php b/app/Language/ko/User.php
index 0a45307..d138478 100644
--- a/app/Language/ko/User.php
+++ b/app/Language/ko/User.php
@@ -1,8 +1,8 @@
'비회원', 'user' => '일반회원', 'vip' => 'VIP회원',
- 'bronze' => '일반판매자', 'silver' => '고급판매자', 'gold' => '파워리셀러',
- 'manager' => '관리자', 'cloudflare' => "Cloudflare관리자", 'director' => '감독자', 'master' => "마스터",
+ 'manager' => '관리자', 'cloudflare' => "Cloudflare관리자",
+ 'director' => '감독자', 'master' => "마스터",
];
return [
'title' => '회원 정보',
@@ -12,6 +12,8 @@ return [
'passwd' => '암호',
'confirmpassword' => '암호확인',
'email' => '메일',
+ 'phone' => '연락처',
+ 'mobile' => '휴대폰',
'role' => '권한',
'name' => '이름',
'status' => '상태',
diff --git a/app/Libraries/Adapter/API/API.php b/app/Libraries/Adapter/API/API.php
new file mode 100644
index 0000000..bec3c38
--- /dev/null
+++ b/app/Libraries/Adapter/API/API.php
@@ -0,0 +1,82 @@
+_url = $url;
+ }
+ final public function getURL(): string
+ {
+ return $this->_url;
+ }
+ final public function setMethod(string $method)
+ {
+ $this->_method = $method;
+ }
+ final public function getMethod(): string
+ {
+ return $this->_method;
+ }
+ final public function setDatas(array $datas)
+ {
+ $this->_datas = $datas;
+ }
+ final public function getDatas(): array
+ {
+ return $this->_datas;
+ }
+ final public function setHeader($key, $value, $delimiter = ":")
+ {
+ array_push($this->_headers, "{$key}{$delimiter} {$value}");
+ }
+ final public function getHeaders(): array
+ {
+ return $this->_headers;
+ }
+
+ final public function setServerInfo($ip, $port)
+ {
+ $this->_serverInfo['ip'] = $ip;
+ $this->_serverInfo['port'] = $port;
+ }
+ final protected function getServerInfo($scheme = "https://", $delimeter = ":"): string
+ {
+ return $scheme . $this->_serverInfo['ip'] . $delimeter . $this->_serverInfo['port'];
+ }
+ final public function setAccountInfo($id, $password)
+ {
+ $this->_serverInfo['id'] = $id;
+ $this->_serverInfo['password'] = $password;
+ }
+ final protected function getAccountInfo($authType = 'basic'): array
+ {
+ //type: basic , digest
+ return array($this->_serverInfo['id'], $this->_serverInfo['password'], $authType);
+ }
+
+ final public function execute(): object
+ {
+ return $this->execute_process();
+ }
+}
diff --git a/app/Libraries/Adapter/API/CurlAPI.php b/app/Libraries/Adapter/API/CurlAPI.php
new file mode 100644
index 0000000..69b86e9
--- /dev/null
+++ b/app/Libraries/Adapter/API/CurlAPI.php
@@ -0,0 +1,209 @@
+_debug) {
+ return false;
+ }
+ if ($response === false) {
+ log_message('error', curl_error($this->getChannel()));
+ }
+ $info = curl_getinfo($this->getChannel());
+ log_message('debug', var_export($info, true));
+ log_message('debug', var_export($this->getDatas(), true));
+ log_message('debug', "{$info['total_time']}초, url:{$info['url']}, return:{$info['http_code']}");
+ switch ($info['http_code']) {
+ case 100:
+ log_message('debug', "{$info['http_code']} Continue");
+ break;
+ case 101:
+ log_message('debug', "{$info['http_code']} Switching Protocols");
+ break;
+ case 200:
+ log_message('debug', "{$info['http_code']} OK");
+ break;
+ case 201:
+ log_message('debug', "{$info['http_code']} Created");
+ break;
+ case 202:
+ log_message('debug', "{$info['http_code']} Accepted");
+ break;
+ case 203:
+ log_message('debug', "{$info['http_code']} Non-Authoritative Information");
+ break;
+ case 204:
+ log_message('debug', "{$info['http_code']} No Content");
+ break;
+ case 205:
+ log_message('debug', "{$info['http_code']} Reset Content");
+ break;
+ case 206:
+ log_message('debug', "{$info['http_code']} Partial Content");
+ break;
+ case 300:
+ log_message('debug', "{$info['http_code']} Multiple Choices");
+ break;
+ case 301:
+ log_message('debug', "{$info['http_code']} Moved Permanently");
+ break;
+ case 302:
+ log_message('debug', "{$info['http_code']} Found");
+ break;
+ case 303:
+ log_message('debug', "{$info['http_code']} See Other");
+ break;
+ case 304:
+ log_message('debug', "{$info['http_code']} Not Modified");
+ break;
+ case 305:
+ log_message('debug', "{$info['http_code']} Use Proxy");
+ break;
+ case 306:
+ log_message('debug', "{$info['http_code']} (Unused)");
+ break;
+ case 307:
+ log_message('debug', "{$info['http_code']} Temporary Redirect");
+ break;
+ case 400:
+ log_message('debug', "{$info['http_code']} Bad Request");
+ break;
+ case 401:
+ log_message('debug', "{$info['http_code']} Unauthorized");
+ break;
+ case 402:
+ log_message('debug', "{$info['http_code']} Payment Required");
+ break;
+ case 403:
+ log_message('debug', "{$info['http_code']} Forbidden");
+ break;
+ case 404:
+ log_message('debug', "{$info['http_code']} Not Found");
+ break;
+ case 405:
+ log_message('debug', "{$info['http_code']} Method Not Allowed");
+ break;
+ case 406:
+ log_message('debug', "{$info['http_code']} Not Acceptable");
+ break;
+ case 407:
+ log_message('debug', "{$info['http_code']} Proxy Authentication Required");
+ break;
+ case 408:
+ log_message('debug', "{$info['http_code']} Request Timeout");
+ break;
+ case 409:
+ log_message('debug', "{$info['http_code']} Conflict");
+ break;
+ case 410:
+ log_message('debug', "{$info['http_code']} Gone");
+ break;
+ case 411:
+ log_message('debug', "{$info['http_code']} Length Required");
+ break;
+ case 412:
+ log_message('debug', "{$info['http_code']} Precondition Failed");
+ break;
+ case 413:
+ log_message('debug', "{$info['http_code']} Request Entity Too Large");
+ break;
+ case 414:
+ log_message('debug', "{$info['http_code']} Request-URI Too Long");
+ break;
+ case 415:
+ log_message('debug', "{$info['http_code']} Unsupported Media Type");
+ break;
+ case 416:
+ log_message('debug', "{$info['http_code']} Requested Range Not Satisfiable");
+ break;
+ case 417:
+ log_message('debug', "{$info['http_code']} Expectation Failed");
+ break;
+ case 500:
+ log_message('debug', "{$info['http_code']} Internal Server Error");
+ break;
+ case 501:
+ log_message('debug', "{$info['http_code']} Not Implemented");
+ break;
+ case 502:
+ log_message('debug', "{$info['http_code']} Bad Gateway");
+ break;
+ case 503:
+ log_message('debug', "{$info['http_code']} Service Unavailable");
+ break;
+ case 504:
+ log_message('debug', "{$info['http_code']} Gateway Timeout");
+ break;
+ case 505:
+ log_message('debug', "{$info['http_code']} HTTP Version Not Supported");
+ break;
+ default:
+ log_message('debug', "Return Code : {$info['http_code']}");
+ break;
+ }
+ }
+ protected function getChannel()
+ {
+ if (is_null($this->_channel)) {
+ $this->_channel = curl_init();
+ }
+ return $this->_channel;
+ }
+ public function setSSLVerifay()
+ {
+ //SSL 확인여부용
+ curl_setopt($this->getChannel(), CURLOPT_SSL_VERIFYPEER, API['SSL_VERIFY']);
+ curl_setopt($this->getChannel(), CURLOPT_SSL_VERIFYHOST, API['SSL_VERIFY']);
+ }
+ public function setCookie()
+ {
+ //cookie값 전달용
+ foreach (curl_getinfo($this->getChannel(), CURLINFO_COOKIELIST) as $cookie_line) {
+ curl_setopt($this->getChannel(), CURLOPT_COOKIELIST, $cookie_line);
+ }
+ }
+ public function setAUthentication()
+ {
+ //접속인증 정보값 전달용
+ curl_setopt($this->getChannel(), CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+ curl_setopt($this->getChannel(), CURLOPT_USERPWD, implode(":", $this->getAccountInfo()));
+ }
+ protected function execute_process(): object
+ {
+ curl_setopt($this->getChannel(), CURLOPT_URL, $this->getServerInfo() . $this->getURL());
+ switch ($this->getMethod()) {
+ case 'POST':
+ curl_setopt($this->getChannel(), CURLOPT_POST, TRUE);
+ curl_setopt($this->getChannel(), CURLOPT_CUSTOMREQUEST, 'PATCH');
+ //cookie값 파일저장용
+ curl_setopt($this->getChannel(), CURLOPT_COOKIEJAR, API['COOKIE_FILE']);
+ curl_setopt($this->getChannel(), CURLOPT_COOKIEFILE, API['COOKIE_FILE']);
+ break;
+ default:
+ curl_setopt($this->getChannel(), CURLOPT_POST, false);
+ break;
+ }
+ curl_setopt($this->getChannel(), CURLOPT_POSTFIELDS, json_encode($this->getDatas(), true));
+ curl_setopt($this->getChannel(), CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($this->getChannel(), CURLOPT_CONNECTTIMEOUT, 3);
+ curl_setopt($this->getChannel(), CURLOPT_TIMEOUT, 20);
+ curl_setopt($this->getChannel(), CURLOPT_HTTPHEADER, $this->getHeaders());
+ $response = curl_exec($this->getChannel());
+ $this->debugging($response);
+ curl_close($this->getChannel());
+ if (is_null($response)) {
+ throw new \Exception("해당서버[{$this->getServerInfo()}]의 ILO접속 오류가 발생하였습니다.");
+ }
+ return json_decode($response);
+ }
+}
diff --git a/app/Libraries/Adapter/API/GuzzleAPI.php b/app/Libraries/Adapter/API/GuzzleAPI.php
new file mode 100644
index 0000000..72fb597
--- /dev/null
+++ b/app/Libraries/Adapter/API/GuzzleAPI.php
@@ -0,0 +1,85 @@
+_jar)) {
+ $this->_jar = new \GuzzleHttp\Cookie\CookieJar();
+ }
+ return $this->_jar;
+ }
+ protected function setLocalCookie(): void
+ {
+ // dd($this->getCookieJar(), true);
+ foreach (['Key', 'Lang', 'Url'] as $key) {
+ log_message('debug', var_export($this->getCookieJar()->getCookieByName('session' . $key), true));
+ }
+ }
+
+ protected function getChannel() //Guzzle이용시
+ {
+ if (is_null($this->_channel)) {
+ // 참조:https://docs.guzzlephp.org/en/stable/request-options.html
+ // ex:)$options = [ 'base_uri' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]
+ $options = [
+ 'base_uri' => $this->getServerInfo(),
+ 'auth' => $this->getAccountInfo(),
+ 'verify' => API['SSL_VERIFY'],
+ 'cookie' => API['COOKIE_FILE'],
+ // \GuzzleHttp\RequestOptions::ALLOW_REDIRECTS => [
+ // 'max' => 10, // allow at most 10 redirects.
+ // 'strict' => true, // use "strict" RFC compliant redirects.
+ // 'referer' => true, // add a Referer header
+ // 'track_redirects' => true,
+ // ],
+ ];
+ $this->_channel = new \GuzzleHttp\Client($options);
+ }
+ return $this->_channel;
+ }
+
+ protected function execute_process(): object
+ {
+ try {
+ $options = array();
+ if ($this->_debug) {
+ $options['debug'] = fopen('php://stderr', 'w'); //or true
+ }
+ switch ($this->getMethod()) {
+ case 'POST':
+ $options['json'] = $this->getDatas();
+ break;
+ case 'HEAD':
+ break;
+ }
+ $response = $this->getChannel()->request($this->getMethod(), $this->getURL(), $options);
+ if ($response->getStatusCode() != 200) {
+ throw new \Exception(sprintf(
+ "오류가 발생하였습니다.\n%s\n%s",
+ $response->getHeaderLine('content-type'),
+ $response->getBody()
+ ));
+ }
+ $this->setLocalCookie($this->getURL());
+ // echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
+ // echo $response->getBody()=>'{"id": 1420053, "name": "guzzle", ...}
+ return json_decode($response->getBody()->getContents());
+ } catch (ClientException $e) {
+ throw new \Exception(
+ Psr7\Message::toString($e->getRequest()) . "\n" .
+ Psr7\Message::toString($e->getResponse())
+ );
+ }
+ }
+}
diff --git a/app/Libraries/Adapter/API/LocalAdapter.php b/app/Libraries/Adapter/API/LocalAdapter.php
index 9b20475..c788146 100644
--- a/app/Libraries/Adapter/API/LocalAdapter.php
+++ b/app/Libraries/Adapter/API/LocalAdapter.php
@@ -2,16 +2,16 @@
namespace App\Libraries\Adapter\API;
-class LocalAdapter extends Adapter
+class LocalAPI extends API
{
public function __construct($debug = false)
{
parent::__construct($debug);
}
- protected function getClient() //Codeigniter4 Service의 curlrequest이용시
+ protected function getChannel() //Codeigniter4 Service의 curlrequest이용시
{
- if (is_null($this->_client)) {
+ if (is_null($this->_channel)) {
// 참조:https://www.codeigniter.com/user_guide/libraries/curlrequest.html?highlight=curl#
// ex:)$options = [ 'baseURI' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]
$options = [
@@ -23,21 +23,21 @@ class LocalAdapter extends Adapter
if ($this->_debug) {
$options['debug'] = API['DEBUG_FILE'];
}
- $this->_client = \Config\Services::curlrequest($options);
+ $this->_channel = \Config\Services::curlrequest($options);
}
- return $this->_client;
+ return $this->_channel;
}
- protected function requestURL(string $url, string $method, array $datas = []): object
+ protected function execute_process(): object
{
$options = array();
- switch ($method) {
+ switch ($this->getMethod()) {
case 'POST':
- $response = $this->getClient()->setBody($datas)->request($method, $url, $options);
+ $response = $this->getChannel()->setBody($this->getDatas())->request($this->getMethod(), $this->getURL(), $options);
break;
case 'HEAD':
break;
default:
- $response = $this->getClient()->request($method, $url, $options);
+ $response = $this->getChannel()->request($this->getMethod(), $this->getURL(), $options);
break;
}
dd($response);
diff --git a/app/Libraries/Adapter/Adapter.php b/app/Libraries/Adapter/Adapter.php
new file mode 100644
index 0000000..6f32ceb
--- /dev/null
+++ b/app/Libraries/Adapter/Adapter.php
@@ -0,0 +1,15 @@
+_debug = $debug;
+ $this->_session = \Config\Services::session();
+ }
+ abstract public function execute();
+}
diff --git a/app/Libraries/Adapter/Auth/Auth.php b/app/Libraries/Adapter/Auth/Auth.php
new file mode 100644
index 0000000..16c3778
--- /dev/null
+++ b/app/Libraries/Adapter/Auth/Auth.php
@@ -0,0 +1,82 @@
+_site = $site;
+ }
+ final public function getSiteName(): string
+ {
+ if (is_null($this->_site)) {
+ throw new \Exception("Auth Adpater Site명이 정의 되지 않았습니다.");
+ }
+ return ucfirst($this->_site);
+ }
+ abstract public function getAuthButton();
+ abstract protected function execute_process(): UserEntity;
+
+ final protected function getUserModel(): UserModel
+ {
+ if (is_null($this->_userModel)) {
+ $this->_userModel = new UserModel();
+ }
+ return $this->_userModel;
+ }
+
+ final protected function getUserSNSModel(): UserSNSModel
+ {
+ if (is_null($this->_userSNSModel)) {
+ $this->_userSNSModel = new UserSNSModel();
+ }
+ return $this->_userSNSModel;
+ }
+
+ final public function setFormDatas(array $formDatas)
+ {
+ $this->_formDatas = $formDatas;
+ }
+ final public function getFormDatas(): array
+ {
+ return $this->_formDatas;
+ }
+
+ protected function setSession_process(UserEntity $entity): UserEntity
+ {
+ $this->_session->set(SESSION_NAMES['ISLOGIN'], true);
+ $auths = [];
+ foreach (array_values(AUTH_FIELDS) as $field) {
+ switch ($field) {
+ case 'id':
+ $auths[$field] = $entity->getPrimaryKey();
+ break;
+ case 'title':
+ $auths[$field] = $entity->getTitle();
+ break;
+ case 'role':
+ $auths[$field] = $entity->$field;
+ break;
+ }
+ }
+ $this->_session->set(SESSION_NAMES['AUTH'], $auths);
+ return $entity;
+ }
+
+ final public function execute(): UserEntity
+ {
+ return $this->execute_process();
+ }
+}
diff --git a/app/Libraries/Adapter/Auth/GoogleAuth.php b/app/Libraries/Adapter/Auth/GoogleAuth.php
new file mode 100644
index 0000000..420329a
--- /dev/null
+++ b/app/Libraries/Adapter/Auth/GoogleAuth.php
@@ -0,0 +1,131 @@
+_client)) {
+ $this->_client = new \Google_Client();
+ $this->_client->setClientId(AUTH_ADAPTERS[$this->getSiteName()]['CLIENT_ID']);
+ $this->_client->setClientSecret(AUTH_ADAPTERS[$this->getSiteName()]['CLIENT_KEY']);
+ $this->_client->setRedirectUri(base_url() . AUTH_ADAPTERS[$this->getSiteName()]['CALLBACK_URL']);
+ $this->_client->addScope('email');
+ $this->_client->addScope('profile');
+ }
+ return $this->_client;
+ }
+
+ private function setAccessToken()
+ {
+ $formDatas = $this->getFormDatas();
+ //1. Google 로그인후 인증코드 확인
+ if (!isset($formDatas['code']) || !$formDatas['code']) {
+ throw new \Exception($this->getSiteName() . " 인증 CallBack Code가 필요합니다.");
+ }
+ //2.토큰정보 가져오기
+ $tokenInfo = $this->getClient()->fetchAccessTokenWithAuthCode($formDatas['code']);
+ if (isset($tokenInfo['error'])) {
+ throw new \Exception($tokenInfo['error']);
+ }
+ $token = $tokenInfo[AUTH_ADAPTERS[$this->getSiteName()]['TOKEN_NAME']];
+ //3. Google Service에 접근하기위해 Access Token을 설정
+ $this->getClient()->setAccessToken($token);
+
+ //4. Google에 로그인이 했으므로 세션에 Token값 설정
+ $this->_session->set(AUTH_ADAPTERS[$this->getSiteName()]['TOKEN_NAME'], $token);
+ }
+ private function getAccessToken(): ?string
+ {
+ return $this->_session->get(AUTH_ADAPTERS[$this->getSiteName()]['TOKEN_NAME']);
+ }
+
+ public function getAuthButton()
+ {
+ $button = "";
+ if (!$this->getAccessToken()) {
+ $button = anchor($this->getClient()->createAuthUrl(), AUTH_ADAPTERS[$this->getSiteName()]['ICON'], ["target" => "_self"]);
+ }
+ return $button;
+ }
+
+ protected function execute_process(): UserEntity
+ {
+ try {
+ //Google 접근 권한 설정.
+ $this->setAccessToken();
+ //Google 서비스 설정
+ $service = new \Google\Service\Oauth2($this->getClient());
+ $result = $service->userinfo->get();
+ if ($this->_debug) {
+ log_message("debug", var_export($result, true));
+ }
+ // throw new \Exception(__METHOD__ . "에서 데이터 처리 필요");
+ // DEBUG - 2023-07-13 12:54:51 --> \Google\Service\Oauth2\Userinfo::__set_state(array(
+ // 'internal_gapi_mappings' =>
+ // array (
+ // 'familyName' => 'family_name',
+ // 'givenName' => 'given_name',
+ // 'verifiedEmail' => 'verified_email',
+ // ),
+ // 'modelData' =>
+ // array (
+ // 'verified_email' => true,
+ // 'given_name' => '이름',
+ // 'family_name' => '성',
+ // ),
+ // 'processed' =>
+ // array (
+ // ),
+ // 'email' => 'twsdfsew342s@gmail.com',
+ // 'familyName' => '성',
+ // 'gender' => NULL,
+ // 'givenName' => '이름',
+ // 'hd' => NULL,
+ // 'id' => '103667492432234234236838324',
+ // 'link' => NULL,
+ // 'locale' => 'ko',
+ // 'name' => '성이름',
+ // 'picture' => 'https://lh3.googleusercontent.com/a/AAcHTteFSgefsdfsdRJBkJA2tBEmg4PQrvI1Ta_5IXu5=s96-c',
+ // 'verifiedEmail' => true,
+ // ))
+ //조건에 해당하는 이미 등록된 사용자가 있는지 검사
+ $snsEntity = $this->getUserSNSModel()->asObject(UserSNSEntity::class)->where(
+ array("site" => $this->getSiteName(), "id" => $result['id'])
+ )->first();
+ //snsEntity 없으면 신규등록
+ if (is_null($snsEntity)) {
+ $snsEntity = $this->getUserSNSModel()->create([
+ 'site' => $this->getSiteName(),
+ 'id' => $result['id'],
+ 'name' => $result['name'],
+ 'email' => $result['email'],
+ 'detail' => json_encode($result),
+ 'status' => 'standby'
+ ]);
+ }
+ //상태가 use(승인완료)가 아니라면
+ if ($snsEntity->status !== DEFAULTS['STATUS']) {
+ throw new \Exception($this->getSiteName() . "의{$result['email']}:{$result['name']}님은 " . lang("Admin/UserSNS.label." . $snsEntity->status) . "입니다");
+ }
+ //user_id가 연결되어있지 않았다면
+ if (!$snsEntity->user_id) {
+ throw new \Exception($this->getSiteName() . "의{$result['email']}:{$result['name']}님은 아직 사용자 지정이 되지 않았습니다. ");
+ }
+ //인증된 사용자 정보를 가져온후 로그인처리
+ $entity = $this->getUserModel()->getEntity($snsEntity->user_id);
+ return $this->setSession_process($entity);;
+ } catch (\Exception $e) {
+ throw new \Exception("관리자에게 문의하시기 바랍니다. {$e->getMessage()}");
+ }
+ }
+}
diff --git a/app/Libraries/Adapter/Auth/LocalAuth.php b/app/Libraries/Adapter/Auth/LocalAuth.php
new file mode 100644
index 0000000..9061201
--- /dev/null
+++ b/app/Libraries/Adapter/Auth/LocalAuth.php
@@ -0,0 +1,32 @@
+getFormDatas();
+ if (!isset($formDatas['id']) || !$formDatas['id'] || !isset($formDatas['passwd']) || !$formDatas['passwd']) {
+ throw new \Exception("ID 나 암호의 값이 없습니다.");
+ }
+ $entity = $this->getUserModel()->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']]);
+ if (!password_verify($formDatas['passwd'], $entity->passwd)) {
+ throw new \Exception("암호가 맞지않습니다.");
+ }
+ //Session에 인증정보 설정
+ return $this->setSession_process($entity);;
+ }
+}
diff --git a/app/Libraries/Adapter/Payment/CookiePayment.php b/app/Libraries/Adapter/Payment/CookiePayment.php
new file mode 100644
index 0000000..603637f
--- /dev/null
+++ b/app/Libraries/Adapter/Payment/CookiePayment.php
@@ -0,0 +1,66 @@
+setHeader("content-type", "application/json; charset=utf-8");
+ /* 토큰 발행 API */
+ $adapter->setURL(getenv("payment.card.pay2.token_url") ?: "{TOKEN 발행 URL}");
+ $adapter->setDatas(array(
+ 'pay2_id' => getenv("payment.card.pay2.id") ?: 'cookiepayments에서 발급받은 ID',
+ 'pay2_key' => getenv("payment.card.pay2.key") ?: 'cookiepayments에서 발급받은 연동키',
+ ));
+ $token = $adapter->execute();
+ /* 여기 까지 */
+ if ($token['RTN_CD'] != '0000') {
+ throw new \Exception("Cookipay에서 Token을 받는데 실패했습니다.");
+ }
+ return $token;
+ }
+ protected function execute_process(): object
+ {
+ $adapter = new APIAdapter();
+ $adapter->setHeader("content-type", "application/json; charset=utf-8");
+ $adapter->setHeader("ApiKey", getenv("payment.card.pay2.apikey") ?: "COOKIEPAY에서 발급받은 연동키");
+ $adapter->setHeader("TOKEN", $this->getToken());
+ $adapter->setURL(getenv("payment.card.pay2.url") ?: "{요청도메인}/keyin/payment");
+
+ $datas = $this->getDatas();
+ // array(
+ // 'API_ID' => 'COOKIEPAY에서 발급받은 가맹점연동 ID',
+ // 'ORDERNO' => '주문번호',
+ // 'PRODUCTNAME' => '상품명',
+ // 'AMOUNT' => '결제금액',
+ // 'BUYERNAME' => '고객명',
+ // 'BUYEREMAIL' => '고객 E-MAIL',
+ // 'CARDNO' => '카드번호',
+ // 'EXPIREDT' => '카드유효기간',
+ // 'PRODUCTCODE' => '상품코드',
+ // 'BUYERID' => '고객 ID',
+ // 'BUYERADDRESS' => '고객 주소',
+ // 'BUYERPHONE' => '고객 휴대폰번호',
+ // 'QUOTA' => '할부개월',
+ // 'ETC1' => '추가필드 1',
+ // 'ETC2' => '추가필드 2',
+ // 'ETC3' => '추가필드 3',
+ // 'ETC4' => '추가필드 4',
+ // 'ETC5' => '추가필드 5',
+ // )
+ $adapter->setDatas($datas);
+ return $adapter->execute();
+ }
+}
diff --git a/app/Libraries/Adapter/Payment/Payment.php b/app/Libraries/Adapter/Payment/Payment.php
new file mode 100644
index 0000000..eba99b4
--- /dev/null
+++ b/app/Libraries/Adapter/Payment/Payment.php
@@ -0,0 +1,29 @@
+_datas = $datas;
+ }
+ final public function getDatas(): array
+ {
+ return $this->_datas;
+ }
+ final public function execute(): object
+ {
+ return $this->execute_process();
+ }
+}
diff --git a/app/Models/BaseHierarchyModel.php b/app/Models/BaseHierarchyModel.php
index d56cdce..afc11b8 100644
--- a/app/Models/BaseHierarchyModel.php
+++ b/app/Models/BaseHierarchyModel.php
@@ -10,12 +10,16 @@ abstract class BaseHierarchyModel extends BaseModel
protected function __construct(string $className)
{
parent::__construct($className);
- $this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth"];
+ $this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth", "parent_uid"];
$this->validationRules = [...$this->validationRules,];
}
abstract public function getContentField();
abstract public function reply($parent_entity, array $formDatas): BaseEntity;
- protected function getFieldRule(string $field, array $rules, string $action = ""): array
+ public function getSiblingEntitys($entity)
+ {
+ return $this->getEntitys(['grpno' => $entity->getHierarchy_No()]);
+ }
+ public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "grpno":
@@ -23,6 +27,9 @@ abstract class BaseHierarchyModel extends BaseModel
case "grpdepth":
$rules[$field] = "if_exist|numeric"; //반드시숫자여야함
break;
+ case "parent_uid":
+ $rules[$field] = "if_exist";
+ break;
default:
$rules = parent::getFieldRule($field, $rules, $action);
break;
@@ -51,6 +58,7 @@ abstract class BaseHierarchyModel extends BaseModel
]);
$this->update();
//reply용 설정
+ $entity->parent_uid = $parent_entity->getPrimaryKey();
$entity->grpno = $parent_entity->grpno;
$entity->grporder = $parent_entity->grporder + 1;
$entity->grpdepth = $parent_entity->grpdepth + 1;
diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php
index 1a14ba6..399d882 100644
--- a/app/Models/BaseModel.php
+++ b/app/Models/BaseModel.php
@@ -56,7 +56,7 @@ abstract class BaseModel extends Model
$this->_session = \Config\Services::session();
$this->_validation = \Config\Services::validation();
}
- final public function getClassName()
+ final protected function getClassName()
{
return $this->_className;
}
@@ -73,10 +73,11 @@ abstract class BaseModel extends Model
{
return $this->where($conditions)->findAll();
}
- protected function getFieldRule(string $field, array $rules, string $action = ""): array
+ public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case $this->primaryKey:
+ //수동입력인경우
if (!$this->useAutoIncrement) {
$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}]" : "";
@@ -154,17 +155,17 @@ abstract class BaseModel extends Model
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 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()
{
@@ -184,8 +185,8 @@ abstract class BaseModel extends Model
{
switch ($field) {
case $this->primaryKey:
- //primaryKey가 자동입력이 아니면
- if (!$this->useAutoIncrement) {
+ //primaryKey가 수동입력이고 추가(Reply도 결국엔 create_process를 상용)시에만
+ if ($action == 'create' && !$this->useAutoIncrement) {
$pk = $this->primaryKey;
$entity->$pk = $this->getUUID();
}
@@ -229,11 +230,6 @@ abstract class BaseModel extends Model
log_message("error", implode("\n", $this->errors()));
throw new \Exception(__FUNCTION__ . " 오류 발생.\n" . $this->getLastQuery() . "\n" . var_export($this->errors(), true));
}
- //primaryKey가 자동입력이면
- if ($this->useAutoIncrement) {
- $pk = $this->primaryKey;
- $entity->$pk = $this->insertID();
- }
} else {
throw new \Exception(__FUNCTION__ . " 오류 발생.\n 기존정보와 동일하여 수정되지 않았습니다.");
}
@@ -241,21 +237,21 @@ abstract class BaseModel extends Model
}
protected function create_process($entity, array $formDatas)
{
- // echo var_export($entity);
- // exit;
foreach ($this->allowedFields as $field) {
$entity = $this->changeFormData('create', $field, $formDatas, $entity);
}
- // echo var_export($this->allowedFields);
- // exit
- return $this->save_process($entity);
+ $entity = $this->save_process($entity);
+ //primaryKey가 자동입력이면
+ if ($this->useAutoIncrement) {
+ $pk = $this->primaryKey;
+ $entity->$pk = $this->insertID();
+ }
+ return $entity;
}
final protected function modify_process($entity, array $formDatas)
{
foreach ($this->allowedFields as $field) {
- if ($field != $this->primaryKey) {
- $entity = $this->changeFormData('modify', $field, $formDatas, $entity);
- }
+ $entity = $this->changeFormData('modify', $field, $formDatas, $entity);
}
$entity->updated_at = time();
return $this->save_process($entity);
@@ -272,13 +268,9 @@ abstract class BaseModel extends Model
$this->where("created_at <=", $end);
}
}
- public function setIndexOrderBy(?string $field, ?string $order)
+ public function setIndexOrderBy(string $field, string $order)
{
- if ($this->useAutoIncrement) {
- $this->orderBy($field ?: $this->primaryKey, $order ?: "DESC");
- } else {
- $this->orderBy($field ?: "created_at", $order ?: "DESC");
- }
+ $this->orderBy($field, $order);
}
final public function setCondition(array $filterFields, $word, $start, $end, $order_field, $order_value)
{
diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php
index a3164fb..dceda43 100644
--- a/app/Models/BoardModel.php
+++ b/app/Models/BoardModel.php
@@ -28,7 +28,7 @@ class BoardModel extends BaseHierarchyModel
{
return 'content';
}
- protected function getFieldRule(string $field, array $rules, string $action = ""): array
+ public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "category_uid":
diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php
index 50b7108..1c8bc88 100644
--- a/app/Models/CategoryModel.php
+++ b/app/Models/CategoryModel.php
@@ -13,7 +13,7 @@ class CategoryModel extends BaseHierarchyModel
parent::__construct('Category');
$this->allowedFields = [
...$this->allowedFields,
- 'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
+ 'name', "linkurl", "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"head", "tail", "status"
];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
@@ -26,13 +26,16 @@ class CategoryModel extends BaseHierarchyModel
{
return 'head';
}
- protected function getFieldRule(string $field, array $rules, string $action = ""): array
+ public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case $this->getTitleField():
$rules[$field] = "required|trim|string";
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break;
+ case 'photo':
+ $rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]";
+ break;
case "isaccess":
case "isread":
case "iswrite":
@@ -55,6 +58,7 @@ class CategoryModel extends BaseHierarchyModel
{
//대분류 부분은 선택이 되지 않게 하기위해 따로 만듬 (form_dropdown의 optgroup 기능)
$old_title = "";
+ $options = array();
foreach ($this->getEntitys($conditions) as $entity) {
if ($entity->getHierarchy_Depth() == 1) {
$options[$entity->getTitle()] = [];
diff --git a/app/Models/SitepageModel.php b/app/Models/SitepageModel.php
new file mode 100644
index 0000000..d11cf36
--- /dev/null
+++ b/app/Models/SitepageModel.php
@@ -0,0 +1,90 @@
+allowedFields = [
+ ...$this->allowedFields,
+ "category_uid",
+ "user_uid", 'title', "content",
+ "status"
+ ];
+ $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
+ }
+ public function getTitleField(): string
+ {
+ return 'title';
+ }
+ public function getContentField(): string
+ {
+ return 'content';
+ }
+ public function getFieldRule(string $field, array $rules, string $action = ""): array
+ {
+ switch ($field) {
+ case "category_uid":
+ $rules[$field] = "required|numeric";
+ break;
+ case $this->getTitleField():
+ case "content":
+ $rules[$field] = "required|string";
+ break;
+ default:
+ $rules = parent::getFieldRule($field, $rules, $action);
+ break;
+ }
+ return $rules;
+ }
+ //Field별 Form Option용
+ public function getFieldFormOption(string $field): array
+ {
+ switch ($field) {
+ case 'category_uid':
+ if (is_null($this->_category_options)) {
+ $categoryModel = new CategoryModel();
+ $this->_category_options = $categoryModel->getOptions();
+ }
+ $options = $this->_category_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): SitepageEntity
+ {
+ return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
+ }
+
+ public function create(array $formDatas): SitepageEntity
+ {
+ return $this->create_process(new SitepageEntity(), $formDatas);
+ }
+ public function modify(SitepageEntity $entity, array $formDatas): SitepageEntity
+ {
+ return $this->modify_process($entity, $formDatas);
+ }
+
+ //Index관련
+ public function setIndexWordFilter(string $word)
+ {
+ if ($word !== DEFAULTS['EMPTY']) {
+ parent::setIndexWordFilter($word);
+ $this->orLike($this->getTitleField(), $word, "both");
+ $this->orLike("content", $word, "both"); //befor , after , both
+ }
+ }
+}
diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php
index 9990dd1..e0c428a 100644
--- a/app/Models/UserModel.php
+++ b/app/Models/UserModel.php
@@ -15,7 +15,7 @@ class UserModel extends BaseModel
parent::__construct('User');
$this->allowedFields = [
...$this->allowedFields,
- "id", "passwd", 'name', "email", "role", "status"
+ "id", "passwd", 'name', "email", "phone", "mobile", "role", "status"
];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
}
@@ -23,7 +23,7 @@ class UserModel extends BaseModel
{
return 'name';
}
- protected function getFieldRule(string $field, array $rules, string $action = ""): array
+ public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "id":
@@ -92,8 +92,10 @@ class UserModel extends BaseModel
//Index관련
public function setIndexWordFilter(string $word)
{
- parent::setIndexWordFilter($word);
- $this->orLike($this->getTitleField(), $word, "both"); //befor , after , both
- $this->orLike("id", $word, "both");
+ if ($word !== DEFAULTS['EMPTY']) {
+ parent::setIndexWordFilter($word);
+ $this->orLike($this->getTitleField(), $word, "both"); //befor , after , both
+ $this->orLike("id", $word, "both");
+ }
}
}
diff --git a/app/Models/UserSNSModel.php b/app/Models/UserSNSModel.php
index df81626..3a3ca16 100644
--- a/app/Models/UserSNSModel.php
+++ b/app/Models/UserSNSModel.php
@@ -22,7 +22,7 @@ class UserSNSModel extends BaseModel
return 'name';
}
- protected function getFieldRule(string $field, array $rules, string $action = ""): array
+ public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "id":
diff --git a/app/Views/admin/board/index.php b/app/Views/admin/board/index.php
index 71fa1cc..2b28781 100644
--- a/app/Views/admin/board/index.php
+++ b/app/Views/admin/board/index.php
@@ -1,33 +1,32 @@
= $this->extend('layouts/admin') ?>
= $this->section('content') ?>
-
-
- = form_open(current_url(), array("method" => "get")) ?>
-
+
+
+
+
조건검색:= getFieldFilter_BoardHelper($field, $viewDatas[$field], $viewDatas) ?>
- = $this->include('templates/admin/index_head') ?>
-
- = form_close() ?>
+
+ = $this->include('templates/admin/index_head') ?>
= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
-
+
- 번호
- = getFieldIndex_Column_BoardHelper($field, $viewDatas) ?>
- 작업
+ #
+ = getFieldIndex_Column_BoardHelper($field, $viewDatas) ?>
+ @
- getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
-
+ status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
+
= form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
- = getFieldIndex_Row_BoardHelper_Admin($field, $entity, $viewDatas) ?>
+ = getFieldIndex_Row_BoardHelper_Admin($field, $entity, $viewDatas) ?>
= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
diff --git a/app/Views/admin/board/insert.php b/app/Views/admin/board/insert.php
index aa4f729..462fb1c 100644
--- a/app/Views/admin/board/insert.php
+++ b/app/Views/admin/board/insert.php
@@ -1,21 +1,24 @@
= $this->extend('layouts/admin') ?>
= $this->section('content') ?>
-
+
+
= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
-