servermgrv2 init...

This commit is contained in:
최준흠git config git config --helpgit config --global user.name 최준흠 2023-08-03 22:32:00 +09:00
parent e1411ae9de
commit d2a11bc1ed
19 changed files with 192 additions and 184 deletions

View File

@ -133,6 +133,8 @@ define('LAYOUTS', [
'<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">',
'<link href="//cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">',
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css">',
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" />',
'<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/boxicons@latest/css/boxicons.min.css" />',
'<link rel="stylesheet" href="css/style.css" />',
],
'javascripts' => [

View File

@ -39,10 +39,6 @@ $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('ecommerce', ['namespace' => 'App\Controllers'], static function ($routes) {
$routes->post('addCart', 'EcommerceController::addCart');
$routes->get('cancelCart/(:uuid)', 'EcommerceController::cancelCart/$1');
});;
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
});
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
@ -68,32 +64,19 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2');
$routes->post('batchjob', 'UserSNSController::batchjob');
});
$routes->group('boardconfig', static function ($routes) {
$routes->get('', 'BoardConfigController::index');
$routes->get('excel', 'BoardConfigController::excel/$1');
$routes->get('insert', 'BoardConfigController::insert_form');
$routes->post('insert', 'BoardConfigController::insert');
$routes->get('update/(:uuid)', 'BoardConfigController::update_form/$1');
$routes->post('update/(:uuid)', 'BoardConfigController::update/$1');
$routes->get('view/(:uuid)', 'BoardConfigController::view/$1');
$routes->get('delete/(:uuid)', 'BoardConfigController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:uuid)/(:hash)', 'BoardConfigController::toggle/$1/$2');
$routes->post('batchjob', 'BoardConfigController::batchjob');
});
$routes->group('board', static function ($routes) {
$routes->get('', 'BoardController::index');
$routes->get('excel', 'BoardController::excel/$1');
$routes->get('insert', 'BoardController::insert_form');
$routes->post('insert', 'BoardController::insert');
$routes->get('update/(:num)', 'BoardController::update_form/$1');
$routes->post('update/(:num)', 'BoardController::update/$1');
$routes->get('view/(:num)', 'BoardController::view/$1');
$routes->get('reply/(:num)', 'BoardController::reply_form/$1');
$routes->post('reply/(:num)', 'BoardController::reply/$1');
$routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2');
$routes->post('batchjob', 'BoardController::batchjob');
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
$routes->group('category', static function ($routes) {
$routes->get('', 'CategoryController::index');
$routes->get('excel', 'CategoryController::excel/$1');
$routes->get('insert', 'CategoryController::insert_form');
$routes->post('insert', 'CategoryController::insert');
$routes->get('update/(:num)', 'CategoryController::update_form/$1');
$routes->post('update/(:num)', 'CategoryController::update/$1');
$routes->get('reply/(:num)', 'CategoryController::reply_form/$1');
$routes->post('reply/(:num)', 'CategoryController::reply/$1');
$routes->get('view/(:num)', 'CategoryController::view/$1');
$routes->get('delete/(:num)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:num)/(:hash)', 'CategoryController::toggle/$1/$2');
$routes->post('batchjob', 'CategoryController::batchjob');
});
$routes->group('hpilo', static function ($routes) {
$routes->get('', 'HPILOController::index');

View File

@ -39,10 +39,6 @@ $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('ecommerce', ['namespace' => 'App\Controllers'], static function ($routes) {
$routes->post('addCart', 'EcommerceController::addCart');
$routes->get('cancelCart/(:uuid)', 'EcommerceController::cancelCart/$1');
});;
$routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) {
});
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
@ -68,32 +64,19 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2');
$routes->post('batchjob', 'UserSNSController::batchjob');
});
$routes->group('boardconfig', static function ($routes) {
$routes->get('', 'BoardConfigController::index');
$routes->get('excel', 'BoardConfigController::excel/$1');
$routes->get('insert', 'BoardConfigController::insert_form');
$routes->post('insert', 'BoardConfigController::insert');
$routes->get('update/(:uuid)', 'BoardConfigController::update_form/$1');
$routes->post('update/(:uuid)', 'BoardConfigController::update/$1');
$routes->get('view/(:uuid)', 'BoardConfigController::view/$1');
$routes->get('delete/(:uuid)', 'BoardConfigController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:uuid)/(:hash)', 'BoardConfigController::toggle/$1/$2');
$routes->post('batchjob', 'BoardConfigController::batchjob');
});
$routes->group('board', static function ($routes) {
$routes->get('', 'BoardController::index');
$routes->get('excel', 'BoardController::excel/$1');
$routes->get('insert', 'BoardController::insert_form');
$routes->post('insert', 'BoardController::insert');
$routes->get('update/(:num)', 'BoardController::update_form/$1');
$routes->post('update/(:num)', 'BoardController::update/$1');
$routes->get('view/(:num)', 'BoardController::view/$1');
$routes->get('reply/(:num)', 'BoardController::reply_form/$1');
$routes->post('reply/(:num)', 'BoardController::reply/$1');
$routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:num)/(:hash)', 'BoardController::toggle/$1/$2');
$routes->post('batchjob', 'BoardController::batchjob');
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
$routes->group('category', static function ($routes) {
$routes->get('', 'CategoryController::index');
$routes->get('excel', 'CategoryController::excel/$1');
$routes->get('insert', 'CategoryController::insert_form');
$routes->post('insert', 'CategoryController::insert');
$routes->get('update/(:num)', 'CategoryController::update_form/$1');
$routes->post('update/(:num)', 'CategoryController::update/$1');
$routes->get('reply/(:num)', 'CategoryController::reply_form/$1');
$routes->post('reply/(:num)', 'CategoryController::reply/$1');
$routes->get('view/(:num)', 'CategoryController::view/$1');
$routes->get('delete/(:num)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']);
$routes->get('toggle/(:num)/(:hash)', 'CategoryController::toggle/$1/$2');
$routes->post('batchjob', 'CategoryController::batchjob');
});
$routes->group('hpilo', static function ($routes) {
$routes->get('', 'HPILOController::index');

View File

@ -21,14 +21,14 @@ class BoardController extends AdminController
public function getFields(string $action = ""): array
{
$fields = ["board_config_uid", 'title', "board_file", "passwd", "status", "content"];
$fields = ["category_uid", 'title', "board_file", "passwd", "status", "content"];
switch ($action) {
case "index":
case "excel":
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"];
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"];
break;
case "view":
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
break;
default:
return $fields;
@ -37,7 +37,7 @@ class BoardController extends AdminController
}
public function getFieldFilters(): array
{
return ["board_config_uid", "user_uid", "status"];
return ["category_uid", "user_uid", "status"];
}
public function getFieldBatchFilters(): array
{

View File

@ -2,16 +2,16 @@
namespace App\Controllers\Admin;
use App\Models\BoardConfigModel;
use App\Models\CategoryModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class BoardConfigController extends AdminController
class CategoryController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new BoardConfigModel();
$this->_model = new CategoryModel();
parent::initController($request, $response, $logger);
$this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title');
$this->_viewPath .= strtolower($this->_model->getClassName());
@ -21,14 +21,14 @@ class BoardConfigController extends AdminController
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;

View File

@ -6,7 +6,6 @@ use App\Models\BoardModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Models\BoardConfigModel;
class BoardController extends FrontController
{
@ -21,14 +20,14 @@ class BoardController extends FrontController
public function getFields(string $action = ""): array
{
$fields = ["board_config_uid", 'title', "board_file", "passwd", "content"];
$fields = ["category_uid", 'title', "board_file", "passwd", "content"];
switch ($action) {
case "index":
case "excel":
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "created_at"];
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "created_at"];
break;
case "view":
return ["board_config_uid", "user_uid", 'title', "board_file", "view_cnt", "created_at", "content"];
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "created_at", "content"];
break;
default:
return $fields;
@ -37,7 +36,7 @@ class BoardController extends FrontController
}
public function getFieldFilters(): array
{
return ["board_config_uid", "user_uid"];
return ["category_uid", "user_uid"];
}
public function getFieldBatchFilters(): array
{

View File

@ -19,19 +19,6 @@ CREATE TABLE servermgr.tw_user (
-- insert into tw_user (uid,id,passwd,name,email,role,status) select uuid(),id,passwd,name,email,role,status from cfmgr.user;
DROP TABLE IF EXISTS servermgr.tw_user_profile;
CREATE TABLE servermgr.tw_user_profile (
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
user_uid varchar(36) NULL COMMENT '사용자 정보',
type varchar(10) NOT NULL COMMENT 'ICON|ADDRESS|PHONE|MOBILE|EMAIL 등등',
content varchar(255) NULL,
priority int(3) NOT NULL DEFAULT 1 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(),
PRIMARY KEY (uid),
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='사용자 추가정보';
DROP TABLE IF EXISTS servermgr.tw_user_sns;
CREATE TABLE servermgr.tw_user_sns (
@ -51,26 +38,37 @@ CREATE TABLE servermgr.tw_user_sns (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='SNS 로그인 후 정보';
DROP TABLE IF EXISTS servermgr.tw_board_config;
CREATE TABLE servermgr.tw_board_config (
uid varchar(36) NOT NULL,
name varchar(255) NOT NULL COMMENT '게시판명',
isaccess varchar(255) NOT NULL DEFAULT 'manager|cloudflare|director|master' COMMENT '접근권한',
isread varchar(255) NOT NULL DEFAULT 'manager|cloudflare|director|master' COMMENT '읽기권한',
iswrite varchar(255) NOT NULL DEFAULT 'manager|cloudflare|director|master' COMMENT '쓰기권한',
isreply varchar(255) NOT NULL DEFAULT 'manager|cloudflare|director|master' COMMENT '답글권한',
isupload varchar(255) NOT NULL DEFAULT 'manager|cloudflare|director|master' COMMENT 'Upload권한',
isdownload varchar(255) NOT NULL DEFAULT 'manager|cloudflare|director|master' COMMENT 'Download권한',
head text NOT NULL DEFAULT '&nbsp;' COMMENT '게시판 위 내용',
tail text NOT NULL DEFAULT '&nbsp;' COMMENT '게시판 아래 내용',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용, unuse: 사용않함 등등',
DROP TABLE IF EXISTS servermgr.tw_category;
-- 1. 게시물 추가전 grpno에 해당하는 max(grporder)+1씩증가 작업
-- update tw_category set grporder=grporder+1 where grpno=그룹번호 and grporder > 선택한 grpno
-- 2. 게시물 추가시 작업
-- insert tw_category grpno=그룹번호,grporder=grporder+1,grpdepth=grpdepth+1
-- 3. 게시물 조회시 작업
-- select * from tw_category order by grpno desc,grporder asc
CREATE TABLE servermgr.tw_category (
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
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 '범주명',
linkurl varchar(255) NULL COMMENT '연결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 '쓰기권한',
isreply varchar(30) NOT NULL DEFAULT 'guest' COMMENT '답글권한',
isupload varchar(30) NOT NULL DEFAULT 'guest' COMMENT 'Upload권한',
isdownload varchar(30) NOT NULL DEFAULT 'guest' COMMENT 'Download권한',
head text NULL COMMENT '위 내용',
tail text 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)
) 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에 해당하는 기존게시물의 grpord를 +1씩증가 작업
-- 1. 게시물 추가전 grpno에 해당하는 max(grporder)+1씩증가 작업
-- update tw_board set grporder=grporder+1 where grpno=그룹번호 and grporder > 선택한 grpno
-- 2. 게시물 추가시 작업
-- insert tw_board grpno=그룹번호,grporder=grporder+1,grpdepth=grpdepth+1
@ -81,7 +79,7 @@ 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씩 추가필요',
board_config_uid varchar(36) NOT NULL COMMENT '게시판구분',
cartory_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 '내용',
@ -91,21 +89,8 @@ CREATE TABLE servermgr.tw_board (
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 (board_config_uid) REFERENCES tw_board_config (uid),
CONSTRAINT FOREIGN KEY (cartory_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_board_file;
CREATE TABLE servermgr.tw_board_file (
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
board_uid int(10) UNSIGNED NOT NULL COMMENT '게시물 정보',
mime_type varchar(50) NOT NULL COMMENT 'Mime_Type',
name varchar(255) NOT NULL COMMENT '파일명',
real_name varchar(255) 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(),
PRIMARY KEY (uid),
CONSTRAINT FOREIGN KEY (board_uid) REFERENCES tw_board (uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='게시판 File정보';
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='게시물 정보';

View File

@ -2,7 +2,7 @@
namespace App\Entities;
class BoardConfigEntity extends BaseEntity
class CategoryEntity extends BaseHierarchyEntity
{
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
@ -23,6 +23,10 @@ class BoardConfigEntity extends BaseEntity
}
//추가기능
public function getLinkURL()
{
return $this->attributes['linkurl'];
}
public function getHead()
{
return $this->attributes['head'];

View File

@ -1,18 +1,18 @@
<?php
function getFieldLabel_BoardConfigHelper($field, array $fieldRules, array $attributes = array()): string
function getFieldLabel_CategoryHelper($field, array $fieldRules, array $attributes = array()): string
{
switch ($field) {
default:
if (strpos($fieldRules[$field], 'required') !== false) {
array_push($attributes, 'style="color:red";');
}
return sprintf("<span %s>%s</span>", implode(" ", [...$attributes]), lang("BoardConfig.label.{$field}"));
return sprintf("<span %s>%s</span>", implode(" ", [...$attributes]), lang("Category.label.{$field}"));
break;
}
}
//header.php에서 getFieldForm_Helper사용
function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions, array $attributes = array())
function getFieldForm_CategoryHelper($field, $value, array $fieldFormOptions, array $attributes = array())
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
@ -22,7 +22,7 @@ function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions,
case 'isreply':
case 'isupload':
case 'isdownload':
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Category.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]);
// return form_multiselect($field, $fieldFormOptions[$field], $value, [...$attributes]);
// foreach ($fieldFormOptions[$field] as $key => $label) {
@ -31,7 +31,7 @@ function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions,
// return implode("&nbsp;", $checkboxs);
break;
case "status":
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Category.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
return form_dropdown($field, $fieldFormOptions[$field], $value, $attributes);
break;
case 'updated_at':
@ -42,7 +42,7 @@ function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions,
return sprintf(
"%s %s %s",
form_password($field, DEFAULTS['EMPTY'], [...$attributes]),
lang("BoardConfig.label.confirmpassword"),
lang("Category.label.confirmpassword"),
form_password('confirmpassword', DEFAULTS['EMPTY'], [...$attributes]),
);
break;
@ -56,18 +56,37 @@ function getFieldForm_BoardConfigHelper($field, $value, array $fieldFormOptions,
case 'name':
return form_input($field, $value, [...$attributes, "placeholder" => "예)", "style" => "width:60%; ::placeholder{ color:silver; opacity: 1; }"]);
break;
case 'linkurl':
return form_input($field, $value, [...$attributes, "placeholder" => "예)/front/board", "style" => "width:100%; ::placeholder{ color:silver; opacity: 1; }"]);
break;
default:
return form_input($field, $value, [...$attributes]);
break;
}
} //
function getFieldView_BoardConfigHelper($field, $entity, array $fieldFilters, array $fieldFormOptions, array $attributes = array())
function getFieldView_CategoryHelper($field, $entity, array $fieldFilters, array $fieldFormOptions, array $attributes = array())
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'name':
return anchor(current_url() . '/view/' . $entity->getPrimaryKey(), $value, [...$attributes, "target" => "_self"]);
return sprintf(
"<div style=\"text-align:left;\">%s %s</div>",
anchor(
current_url() . '/reply/' . $entity->getPrimaryKey(),
ICONS['REPLY'],
[
...$attributes,
"style" => sprintf("padding-left:%spx", $entity->getHierarchy_Depth() * DEFAULTS['HIERARCHY_GRPDEPTH']),
"target" => "_self"
]
),
anchor(
current_url() . '/view/' . $entity->getPrimaryKey(),
$value,
["target" => "_self"]
)
);
break;
case 'upload_file':
return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], [...$attributes, "target" => "_self"]);
@ -86,7 +105,7 @@ function getFieldView_BoardConfigHelper($field, $entity, array $fieldFilters, ar
}
} //
function getFieldFilter_BoardConfigHelper($field, $value, array $fieldFormOptions, array $attributes = array())
function getFieldFilter_CategoryHelper($field, $value, array $fieldFormOptions, array $attributes = array())
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
@ -96,41 +115,41 @@ function getFieldFilter_BoardConfigHelper($field, $value, array $fieldFormOption
case 'isreply':
case 'isupload':
case 'isdownload':
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("BoardConfig.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
$fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Category.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
return form_dropdown($field, $fieldFormOptions[$field], $value, [...$attributes, 'class' => "select-field"]);
break;
default:
return getFieldForm_BoardConfigHelper($field, $value, $fieldFormOptions, $attributes);
return getFieldForm_CategoryHelper($field, $value, $fieldFormOptions, $attributes);
break;
}
} //
function getFieldIndex_Column_BoardConfigHelper($field, $order_field, $order_value, array $attributes = array())
function getFieldIndex_Column_CategoryHelper($field, $order_field, $order_value, array $attributes = array())
{
$label = lang("BoardConfig.label.{$field}");
$label = lang("Category.label.{$field}");
$label = $field == $order_field ? sprintf('%s <i class="fa fa-arrow-%s"></i>', $label, $order_value == 'ASC' ? "up" : "down") : $label;
$order_value = $order_value == 'DESC' ? "ASC" : "DESC";
return anchor(current_url() . "?order_field={$field}&order_value={$order_value}", $label, [...$attributes]);
} //
function getFieldIndex_Row_BoardConfigHelper($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
function getFieldIndex_Row_CategoryHelper($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
{
switch ($field) {
default:
return getFieldView_BoardConfigHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes);
return getFieldView_CategoryHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes);
break;
}
} //
function getFieldIndex_Row_BoardConfigHelper_Admin($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
function getFieldIndex_Row_CategoryHelper_Admin($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
{
switch ($field) {
default:
if (in_array($field, $fieldFilters)) {
$attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
return getFieldForm_BoardConfigHelper($field, $entity->$field, $fieldFormOptions, $attributes);
return getFieldForm_CategoryHelper($field, $entity->$field, $fieldFormOptions, $attributes);
}
return getFieldIndex_Row_BoardConfigHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes);
return getFieldIndex_Row_CategoryHelper($field, $entity, $fieldFilters, $fieldFormOptions, $attributes);
break;
}
} //

View File

@ -6,7 +6,7 @@ return [
'grpno' => "그룹번호",
'grpord' => "부모번호",
'grpdpt' => "그룸Depth",
'board_config_uid' => "설정",
'category_uid' => "범주",
'user_uid' => "작성자",
'title' => "제목",
'content' => "내용",

View File

@ -5,10 +5,11 @@ $roles = [
'manager' => '관리자', 'cloudflare' => "Cloudflare관리자", 'director' => '감독자', 'master' => "마스터",
];
return [
'title' => "게시판설정 정보",
'title' => "범주 정보",
'label' => [
'uid' => "번호",
'name' => "게시판제목",
'name' => "범주제목",
'linkurl' => "연결URL",
'isaccess' => "접속권한",
'isread' => "읽기권한",
'iswrite' => "쓰기권한",

View File

@ -6,7 +6,7 @@ use App\Entities\BoardEntity;
class BoardModel extends BaseHierarchyModel
{
private $_boardconfig_options = null;
private $_category_options = null;
protected $table = "tw_board";
protected $returnType = BoardEntity::class;
public function __construct()
@ -14,7 +14,7 @@ class BoardModel extends BaseHierarchyModel
parent::__construct('Board');
$this->allowedFields = [
...$this->allowedFields,
"board_config_uid",
"category_uid",
"user_uid", 'title', "content",
"passwd", "board_file", "view_cnt", "status"
];
@ -31,8 +31,8 @@ class BoardModel extends BaseHierarchyModel
protected function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "board_config_uid":
$rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
case "category_uid":
$rules[$field] = "required|numeric";
break;
case $this->getTitleField():
case "content":
@ -55,11 +55,11 @@ class BoardModel extends BaseHierarchyModel
{
switch ($field) {
case 'board_config_uid':
if (is_null($this->_boardconfig_options)) {
$boardConfigModel = new BoardConfigModel();
$this->_boardconfig_options = $boardConfigModel->getOptions();
if (is_null($this->_category_options)) {
$categoryModel = new CategoryModel();
$this->_category_options = $categoryModel->getOptions();
}
$options = $this->_boardconfig_options;
$options = $this->_category_options;
break;
default:
return parent::getFieldFormOption($field);

View File

@ -2,19 +2,18 @@
namespace App\Models;
use App\Entities\BoardConfigEntity;
use App\Entities\CategoryEntity;
class BoardConfigModel extends BaseModel
class CategoryModel extends BaseHierarchyModel
{
protected $table = "tw_board_config";
protected $useAutoIncrement = false;
protected $returnType = BoardConfigEntity::class;
protected $table = "tw_category";
protected $returnType = CategoryEntity::class;
public function __construct()
{
parent::__construct('BoardConfig');
parent::__construct('Category');
$this->allowedFields = [
...$this->allowedFields,
'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
'name', "linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"head", "tail", "status"
];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
@ -23,17 +22,21 @@ class BoardConfigModel extends BaseModel
{
return 'name';
}
public function getContentField(): string
{
return 'head';
}
protected function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case "uid":
$rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break;
case $this->getTitleField():
$rules[$field] = "required|trim|string";
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break;
case "linkurl":
$rules[$field] = "if_exist|trim|string";
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break;
case "isaccess":
case "isread":
case "iswrite":
@ -52,19 +55,20 @@ class BoardConfigModel extends BaseModel
return $rules;
}
//Form 선택용 Options Data용
public function getOptions_TEST(array $conditions = array(), $options = array()): array
public function getOptions(array $conditions = array(), $options = array()): array
{
foreach ($this->getEntitys($conditions) as $entity) {
// STATUS가 use가 아닐때 option을 disabled되게 하기위함
if ($entity->getStatus() != DEFAULTS['STATUS']) {
$options[$entity->getPrimaryKey() . "\" disabled=\"disabled"] = $entity->getTitle();
//대분류 부분은 선택이 되지 않게 하기위해 따로 만듬 (form_dropdown의 optgroup 기능)
$old_title = "";
foreach ($this->where($conditions)->orderby("grpno DESC, grporder ASC")->findAll() as $entity) {
if ($entity->getHierarchy_Depth() == 1) {
$options[$entity->getTitle()] = [];
$old_title = $entity->getTitle();
} else {
$options[$entity->getPrimaryKey()] = $entity->getTitle();
$options[$old_title][$entity->getPrimaryKey()] = $entity->getTitle();
}
}
return $options;
}
//Field별 Form Option용
protected function changeFormData(string $action, string $field, array $formDatas, $entity)
{
@ -93,24 +97,31 @@ class BoardConfigModel extends BaseModel
return $entity;
}
public function getEntity($conditions): BoardConfigEntity
public function getEntity($conditions): CategoryEntity
{
return parent::getEntity($conditions);
}
public function create(array $formDatas): BoardConfigEntity
public function create(array $formDatas): CategoryEntity
{
return $this->create_process(new BoardConfigEntity(), $formDatas);
return $this->create_process(new CategoryEntity(), $formDatas);
}
public function modify(BoardConfigEntity $entity, array $formDatas): BoardConfigEntity
public function modify(CategoryEntity $entity, array $formDatas): CategoryEntity
{
return $this->modify_process($entity, $formDatas);
}
public function reply($parent_entity, array $formDatas): CategoryEntity
{
return $this->reply_process($parent_entity, new CategoryEntity(), $formDatas);
}
//Index관련
public function setIndexWordFilter(string $word)
{
parent::setIndexWordFilter($word);
$this->orLike($this->getTitle(), $word, "both"); //befor , after , both
$this->orLike("linkurl", $word, "both"); //befor , after , both
$this->orLike("head", $word, "both"); //befor , after , both
$this->orLike("tail", $word, "both"); //befor , after , both
$this->orLike("isaccess", $word, "both"); //befor , after , both
$this->orLike("isread", $word, "both"); //befor , after , both
$this->orLike("iswrite", $word, "both"); //befor , after , both

View File

@ -4,7 +4,7 @@
<div class="top">
<?= form_open(current_url(), array("method" => "get")) ?>
<ul class="nav">
조건검색:<?php foreach ($fieldFilters as $field) : ?><li class="nav-item"><?= getFieldFilter_BoardConfigHelper($field, $$field, $fieldFormOptions) ?></li><?php endforeach; ?>
조건검색:<?php foreach ($fieldFilters as $field) : ?><li class="nav-item"><?= getFieldFilter_CategoryHelper($field, $$field, $fieldFormOptions) ?></li><?php endforeach; ?>
<?= $this->include('templates/admin/index_head'); ?>
</ul>
<?= form_close(); ?>
@ -13,7 +13,7 @@
<table class="table table-bordered table-hover table-striped">
<tr>
<th>번호</th>
<?php foreach ($fields as $field) : ?><th><?= getFieldIndex_Column_BoardConfigHelper($field, $order_field, $order_value) ?></th><?php endforeach; ?>
<?php foreach ($fields as $field) : ?><th><?= getFieldIndex_Column_CategoryHelper($field, $order_field, $order_value) ?></th><?php endforeach; ?>
<th>작업</th>
</tr>
<?php $i = 0; ?>
@ -24,7 +24,7 @@
<?= anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
</td>
<?php foreach ($fields as $field) : ?>
<td nowrap><?= getFieldIndex_Row_BoardConfigHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
<td nowrap><?= getFieldIndex_Row_CategoryHelper_Admin($field, $entity, $fieldFilters, $fieldFormOptions) ?></td>
<?php endforeach; ?>
<td><?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?></td>
</tr>
@ -34,9 +34,9 @@
<div class="bottom">
<ul class="nav justify-content-center">
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
<?php foreach ($batchjobFilters as $field) : ?><li class="nav-item"><?= getFieldFilter_BoardConfigHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?></li><?php endforeach; ?>
<?php foreach ($batchjobFilters as $field) : ?><li class="nav-item"><?= getFieldFilter_CategoryHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?></li><?php endforeach; ?>
<li class="nav-item"><?= form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?></li>
<li class="nav-item"><?= anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?></li>
<li class="nav-item"><?= anchor(current_url() . '/insert', '대범주추가', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?></li>
</ul>
<?= $pagination ?>
</div>

View File

@ -5,9 +5,9 @@
<table class="form table table-bordered table-hover table-striped">
<?php foreach ($fields as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_BoardConfigHelper($field, $fieldRules) ?></td>
<td class="label"><?= getFieldLabel_CategoryHelper($field, $fieldRules) ?></td>
<td class="column">
<?= getFieldForm_BoardConfigHelper($field, old($field, DEFAULTS['EMPTY']), $fieldFormOptions) ?>
<?= getFieldForm_CategoryHelper($field, old($field, DEFAULTS['EMPTY']), $fieldFormOptions) ?>
<?= validation_show_error($field); ?>
</td>
</tr>

View File

@ -0,0 +1,21 @@
<?= $this->extend('layouts/admin') ?>
<?= $this->section('content') ?>
<div class="content">
<?= form_open_multipart(current_url(), $forms['attributes'], $forms['hiddens']) ?>
<table class="form table table-bordered table-hover table-striped">
<?php foreach ($fields as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_CategoryHelper($field, $fieldRules) ?></td>
<td class="column">
<?= getFieldForm_CategoryHelper($field, old($field, $entity->$field), $fieldFormOptions) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '중범주추가', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</table>
</div>
<?= form_close(); ?>
<?= $this->endSection() ?>

View File

@ -5,15 +5,15 @@
<table class="form table table-bordered table-hover table-striped">
<?php foreach ($fields as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_BoardConfigHelper($field, $fieldRules) ?></td>
<td class="label"><?= getFieldLabel_CategoryHelper($field, $fieldRules) ?></td>
<td class="column">
<?= getFieldForm_BoardConfigHelper($field, old($field, $entity->$field), $fieldFormOptions) ?>
<?= getFieldForm_CategoryHelper($field, old($field, $entity->$field), $fieldFormOptions) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?></td>
<td valign="bottom" colspan="2"><?= form_submit('', '범주수정', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</table>
</div>

View File

@ -4,9 +4,9 @@
<table class="form table table-bordered table-hover table-striped">
<?php foreach ($fields as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_BoardConfigHelper($field, $fieldRules) ?></td>
<td class="label"><?= getFieldLabel_CategoryHelper($field, $fieldRules) ?></td>
<td class="column">
<?= getFieldView_BoardConfigHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?>
<?= getFieldView_CategoryHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?>
<?= validation_show_error($field); ?>
</td>
</tr>

View File

@ -4,7 +4,7 @@
</h2>
<div id="flush-heading-Board" class="accordion-collapse collapse show" aria-labelledby="flush-heading-Board">
<div class="accordion-item">
<h2><a href="/admin/boardconfig"><?= CLASS_ICONS['BOARDCONFIG'] ?>설정 관리</a></h2>
<h2><a href="/admin/category"><?= CLASS_ICONS['CATEGORY'] ?>범주 관리</a></h2>
</div>
<div class="accordion-item">
<h2><a href="/admin/board"><?= CLASS_ICONS['BOARD'] ?>게시글 관리</a></h2>