shoppingmallv2 init...
This commit is contained in:
parent
3e4a49f505
commit
02f4fc7123
@ -212,8 +212,8 @@ define('ICONS', [
|
||||
define('CLASS_ICONS', [
|
||||
'USER' => '<i class="bi bi-person-vcard"></i>',
|
||||
'USERSNS' => '<i class="bi bi-globe"></i>',
|
||||
'BOARDCONFIG' => '<i class="bi bi-gear"></i>',
|
||||
'BOARD' => '<i class="bi bi-pencil-square"></i>',
|
||||
'SITEPAGE' => '<i class="bi bi-body-text"></i>',
|
||||
'CATEGORY' => '<i class="bi bi-boxes"></i>',
|
||||
'PRODUCT' => '<i class="bi bi-box2"></i>',
|
||||
'CART' => '<i class="bi bi-cart4"></i>',
|
||||
|
||||
@ -97,6 +97,18 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->post('batchjob', 'BoardController::batchjob');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('sitepage', static function ($routes) {
|
||||
$routes->get('', 'SitepageController::index');
|
||||
$routes->get('excel', 'SitepageController::excel/$1');
|
||||
$routes->get('insert', 'SitepageController::insert_form');
|
||||
$routes->post('insert', 'SitepageController::insert');
|
||||
$routes->get('update/(:num)', 'SitepageController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'SitepageController::update/$1');
|
||||
$routes->get('view/(:num)', 'SitepageController::view/$1');
|
||||
$routes->get('delete/(:num)', 'SitepageController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'SitepageController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'SitepageController::batchjob');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
@ -137,6 +149,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');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
|
||||
@ -46,7 +46,7 @@ $routes->group('ecommerce', ['namespace' => 'App\Controllers'], function ($route
|
||||
$routes->get('cancelCart', 'EcommerceController::cancelCart');
|
||||
});
|
||||
// authGuard는 App\Config\Filters.php의 $aliases에 선언한 이름이어야 함
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:master,director,cloudflare,manager'], static function ($routes) {
|
||||
$routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], static function ($routes) {
|
||||
$routes->get('/', 'Home::index');
|
||||
$routes->group('user', static function ($routes) {
|
||||
$routes->get('', 'UserController::index');
|
||||
@ -57,16 +57,16 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->post('update/(:uuid)', 'UserController::update/$1');
|
||||
$routes->get('view/(:uuid)', 'UserController::view/$1');
|
||||
$routes->get('delete/(:uuid)', 'UserController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'UserController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'UserController::batchjob');
|
||||
$routes->get('toggle/(:uuid)/(:hash)', 'UserController::toggle/$1/$2', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob', 'UserController::batchjob', ['filter' => 'authFilter:master']);
|
||||
});
|
||||
$routes->group('usersns', static function ($routes) {
|
||||
$routes->get('', 'UserSNSController::index');
|
||||
$routes->get('excel', 'UserSNSController::excel');
|
||||
$routes->get('view/(:num)', 'UserSNSController::view/$1');
|
||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1');
|
||||
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'UserSNSController::batchjob');
|
||||
$routes->get('delete/(:num)', 'UserSNSController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'UserSNSController::toggle/$1/$2', ['filter' => 'authFilter:master']);
|
||||
$routes->post('batchjob', 'UserSNSController::batchjob', ['filter' => 'authFilter:master']);
|
||||
});
|
||||
$routes->group('category', static function ($routes) {
|
||||
$routes->get('', 'CategoryController::index');
|
||||
@ -97,6 +97,18 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->post('batchjob', 'BoardController::batchjob');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('sitepage', static function ($routes) {
|
||||
$routes->get('', 'SitepageController::index');
|
||||
$routes->get('excel', 'SitepageController::excel/$1');
|
||||
$routes->get('insert', 'SitepageController::insert_form');
|
||||
$routes->post('insert', 'SitepageController::insert');
|
||||
$routes->get('update/(:num)', 'SitepageController::update_form/$1');
|
||||
$routes->post('update/(:num)', 'SitepageController::update/$1');
|
||||
$routes->get('view/(:num)', 'SitepageController::view/$1');
|
||||
$routes->get('delete/(:num)', 'SitepageController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:num)/(:hash)', 'SitepageController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'SitepageController::batchjob');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
@ -119,7 +131,7 @@ $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:master,director,cloudflare,manager,gold,silver,brone,vip,user'], static 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');
|
||||
@ -134,9 +146,12 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
|
||||
$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('delete/(:num)', 'BoardController::delete/$1');
|
||||
$routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2');
|
||||
});
|
||||
$routes->group('sitepage', static function ($routes) {
|
||||
$routes->get('', 'SitepageController::index');
|
||||
});
|
||||
$routes->group('product', static function ($routes) {
|
||||
$routes->get('', 'ProductController::index');
|
||||
$routes->get('excel', 'ProductController::excel/$1');
|
||||
|
||||
43
app/Controllers/Admin/SitepageController.php
Normal file
43
app/Controllers/Admin/SitepageController.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Models\SitepageModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class SitepageController extends AdminController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new SitepageModel();
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -337,12 +337,13 @@ abstract class BaseController extends Controller
|
||||
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);
|
||||
}
|
||||
@ -386,6 +387,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']) ?: "/");
|
||||
|
||||
@ -51,7 +51,7 @@ class EcommerceController extends Controller
|
||||
}
|
||||
private function getOrderModel()
|
||||
{
|
||||
return $this->_orderModel = $this->_orderModel ?: new OrderModel(["product_uid", "quantity", "price", "status"]);
|
||||
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
|
||||
}
|
||||
private function getProductModel()
|
||||
{
|
||||
@ -76,7 +76,7 @@ class EcommerceController extends Controller
|
||||
{
|
||||
$msg = "";
|
||||
try {
|
||||
$this->_viewDatas['fields'] = ["product_uid", "quantity", "price", "status"];
|
||||
$this->_viewDatas['fields'] = ["product_uid", "quantity", "price"];
|
||||
$this->_viewDatas['fieldRules'] = $this->getOrderModel()->getFieldRules($this->_viewDatas['fields']);
|
||||
//Transaction 시작
|
||||
$this->getOrderModel()->transStart();
|
||||
|
||||
@ -28,7 +28,10 @@ abstract class FrontController extends BaseController
|
||||
//권한체크
|
||||
final protected function isRole($action, $entity = null)
|
||||
{
|
||||
$this->_category = !is_null($entity) ? $entity->category_uid : ($this->request->getVar('category') ?: throw new \Exception("범주를 지정하지 않으셨습니다."));
|
||||
$this->_category = $this->request->getVar('category');
|
||||
if (is_null($this->_category)) {
|
||||
$this->_category = !is_null($entity) ? $entity->category_uid : throw new \Exception("분류를 지정하지 않으셨습니다.");
|
||||
}
|
||||
$this->_viewDatas['category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_category]);
|
||||
$categorys = $this->getCategoryModel()->getSiblingEntitys($this->_viewDatas['category']);
|
||||
$this->_viewDatas['parent_category'] = array_shift($categorys);
|
||||
|
||||
@ -39,10 +39,23 @@ class OrderController extends FrontController
|
||||
return ["status"];
|
||||
}
|
||||
|
||||
//View관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('view', $entity);
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
//권한체크
|
||||
$this->isRole('index');
|
||||
return parent::index_process();
|
||||
}
|
||||
protected function index_setCondition()
|
||||
{
|
||||
parent::index_setCondition();
|
||||
//세션에 Cart정보(order_uids)가 있으면
|
||||
$uids = $this->_session->get(SESSION_NAMES['CART']) ?: array('NONE');
|
||||
//또는 Login했으면 사용자정보(user_uid)에 맞는 Order정보 가져오기
|
||||
@ -54,5 +67,6 @@ class OrderController extends FrontController
|
||||
} elseif (count($uids)) {
|
||||
$this->_model->whereIn('uid', $uids);
|
||||
}
|
||||
parent::index_setCondition();
|
||||
}
|
||||
}
|
||||
|
||||
56
app/Controllers/Front/SitepageController.php
Normal file
56
app/Controllers/Front/SitepageController.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Front;
|
||||
|
||||
use App\Models\SitepageModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class SitepageController extends FrontController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new SitepageModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
}
|
||||
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();
|
||||
}
|
||||
//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();
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,6 @@ CREATE TABLE shoppingmall.tw_user (
|
||||
UNIQUE KEY (email)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='사용자 정보';
|
||||
-- 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 shoppingmall.tw_user_profile;
|
||||
|
||||
DROP TABLE IF EXISTS shoppingmall.tw_user_sns;
|
||||
|
||||
@ -94,6 +93,22 @@ CREATE TABLE shoppingmall.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 shoppingmall.tw_sitepage;
|
||||
CREATE TABLE shoppingmall.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 shoppingmall.tw_product;
|
||||
CREATE TABLE shoppingmall.tw_product (
|
||||
uid varchar(36) NOT NULL,
|
||||
|
||||
17
app/Entities/SitepageEntity.php
Normal file
17
app/Entities/SitepageEntity.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class SitepageEntity extends BaseEntity
|
||||
{
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [];
|
||||
|
||||
//기본기능
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->attributes['title'];
|
||||
}
|
||||
//추가기능
|
||||
}
|
||||
@ -103,7 +103,7 @@ function getFieldIndex_Row_OrderHelper($field, $entity, array $viewDatas): strin
|
||||
case 'title':
|
||||
case 'name':
|
||||
return anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey(),
|
||||
current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(),
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
|
||||
150
app/Helpers/Sitepage_helper.php
Normal file
150
app/Helpers/Sitepage_helper.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
function getFieldLabel_SitepageHelper($field, array $viewDatas): string
|
||||
{
|
||||
$attributes = [];
|
||||
switch ($field) {
|
||||
default:
|
||||
if (strpos($viewDatas['fieldRules'][$field], 'required') !== false) {
|
||||
$attributes = ['style="color:red";'];
|
||||
}
|
||||
return sprintf("<span %s>%s</span>", 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 'board_file':
|
||||
case 'upload_file':
|
||||
return $entity->getFileDownload(base_url() . $viewDatas['control'] . '/board', $field);
|
||||
break;
|
||||
case 'photo':
|
||||
return $entity->getFileImage('middle', $field);
|
||||
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}");
|
||||
$label = $field == $viewDatas['order_field'] ? sprintf('%s <i class="fa fa-arrow-%s"></i>', $label, $viewDatas['order_value'] == 'ASC' ? "up" : "down") : $label;
|
||||
$value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
|
||||
return anchor(current_url() . "?order_field={$field}&order_value={$value}", $label);
|
||||
} //
|
||||
|
||||
//Front용
|
||||
function getFieldIndex_Row_SitepageHelper($field, $entity, array $viewDatas): string
|
||||
{
|
||||
$value = $entity->$field ?: DEFAULTS['EMPTY'];
|
||||
switch ($field) {
|
||||
case 'title':
|
||||
case 'name':
|
||||
return anchor(
|
||||
current_url() . '/view/' . $entity->getPrimaryKey(),
|
||||
$value ? str_split($value, 66)[0] . "..." : "",
|
||||
["target" => "_self"]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return getFieldView_SitepageHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
|
||||
//Admin용
|
||||
function getFieldIndex_Row_SitepageHelper_Admin($field, $entity, array $viewDatas): string
|
||||
{
|
||||
switch ($field) {
|
||||
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);
|
||||
}
|
||||
return getFieldIndex_Row_SitepageHelper($field, $entity, $viewDatas);
|
||||
break;
|
||||
}
|
||||
} //
|
||||
@ -6,7 +6,7 @@ return [
|
||||
'grpno' => "그룹번호",
|
||||
'grpord' => "부모번호",
|
||||
'grpdpt' => "그룸Depth",
|
||||
'category_uid' => "범주",
|
||||
'category_uid' => "분류",
|
||||
'user_uid' => "작성자",
|
||||
'title' => "제목",
|
||||
'content' => "내용",
|
||||
|
||||
15
app/Language/ko/Sitepage.php
Normal file
15
app/Language/ko/Sitepage.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
return [
|
||||
'title' => "사이트페이지 정보",
|
||||
'label' => [
|
||||
'uid' => "번호",
|
||||
'category_uid' => "분류",
|
||||
'user_uid' => "작성자",
|
||||
'title' => "제목",
|
||||
'content' => "내용",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
'created_at' => "작성일"
|
||||
],
|
||||
'STATUS' => ['use' => '사용', 'unuse' => '사용않함'],
|
||||
];
|
||||
@ -230,7 +230,7 @@ abstract class BaseModel extends Model
|
||||
}
|
||||
protected function create_process($entity, array $formDatas)
|
||||
{
|
||||
foreach ($this->formDatas as $field => $value) {
|
||||
foreach (array_keys($formDatas) as $field) {
|
||||
$entity = $this->changeFormData('create', $field, $formDatas, $entity);
|
||||
}
|
||||
//primaryKey가 수동입력이면
|
||||
|
||||
90
app/Models/SitepageModel.php
Normal file
90
app/Models/SitepageModel.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Entities\SitepageEntity;
|
||||
|
||||
class SitepageModel extends BaseModel
|
||||
{
|
||||
private $_category_options = null;
|
||||
protected $table = "tw_sitepage";
|
||||
protected $returnType = SitepageEntity::class;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('Sitepage');
|
||||
$this->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';
|
||||
}
|
||||
protected 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
|
||||
}
|
||||
}
|
||||
}
|
||||
49
app/Views/admin/sitepage/index.php
Normal file
49
app/Views/admin/sitepage/index.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<div class="top">
|
||||
<?= form_open(current_url(), array("method" => "get")) ?>
|
||||
<ul class="nav">
|
||||
조건검색:<?php foreach ($viewDatas['fieldFilters'] as $field) : ?><?= getFieldFilter_SitepageHelper($field, $viewDatas[$field], $viewDatas) ?><?php endforeach ?>
|
||||
<?= $this->include('templates/admin/index_head') ?>
|
||||
</ul>
|
||||
<?= form_close() ?>
|
||||
</div>
|
||||
<?= form_open(current_url() . '/batchjob', $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="table table-bordered table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>번호</th>
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?><th><?= getFieldIndex_Column_SitepageHelper($field, $viewDatas) ?></th><?php endforeach ?>
|
||||
<th>작업</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $cnt = 0 ?>
|
||||
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
|
||||
<tr id="<?= $entity->getPrimaryKey() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
|
||||
<td>
|
||||
<?= 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"]) ?>
|
||||
</td>
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<td nowrap><?= getFieldIndex_Row_SitepageHelper_Admin($field, $entity, $viewDatas) ?></td>
|
||||
<?php endforeach ?>
|
||||
<td><?= anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?></td>
|
||||
</tr>
|
||||
<?php $cnt++ ?>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="bottom">
|
||||
<ul class="nav justify-content-center">
|
||||
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
|
||||
<?php foreach ($viewDatas['batchjobFilters'] as $field) : ?><?= getFieldFilter_SitepageHelper($field, DEFAULTS['EMPTY'], $viewDatas) ?><?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>
|
||||
</ul>
|
||||
<?= $viewDatas['pagination'] ?>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
21
app/Views/admin/sitepage/insert.php
Normal file
21
app/Views/admin/sitepage/insert.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_SitepageHelper($field, $viewDatas) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_SitepageHelper($field, old($field, DEFAULTS['EMPTY']), $viewDatas) ?>
|
||||
<?= 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>
|
||||
<?= form_close(); ?>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
21
app/Views/admin/sitepage/update.php
Normal file
21
app/Views/admin/sitepage/update.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_SitepageHelper($field, $viewDatas) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldForm_SitepageHelper($field, old($field, $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']), $viewDatas) ?>
|
||||
<?= 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>
|
||||
<?= form_close(); ?>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
16
app/Views/admin/sitepage/view.php
Normal file
16
app/Views/admin/sitepage/view.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<tr>
|
||||
<td class="label"><?= getFieldLabel_SitepageHelper($field, $viewDatas) ?></td>
|
||||
<td class="column">
|
||||
<?= getFieldView_SitepageHelper($field, $viewDatas['entity'], $viewDatas) ?>
|
||||
<?= validation_show_error($field); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@ -2,20 +2,9 @@
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<div id="content">
|
||||
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
|
||||
<div class="top">
|
||||
<?= $this->include('templates/front/index_head') ?>
|
||||
<nav class="navbar navbar-expand-lg">
|
||||
<div class="container-fluid">
|
||||
<nav class="nav">
|
||||
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . '&order_field=price&order_value=ASC', '판매가순', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?>
|
||||
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . '&order_field=view_cnt&order_value=DESC', '인기순', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
|
||||
</nav>
|
||||
<nav class="nav justify-content-center"></nav>
|
||||
<nav class="nav justify-content-end">
|
||||
<?= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey(), 'Block', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
|
||||
</nav>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
@ -40,5 +29,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
|
||||
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,7 +1,9 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<link href="/css/front/content.css" media="screen" rel="stylesheet" ype="text/css" />
|
||||
|
||||
<div id="content">
|
||||
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
|
||||
<table class="form table table-bordered table-striped">
|
||||
<tbody>
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
@ -15,5 +17,6 @@
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
17
app/Views/front/sitepage/index.php
Normal file
17
app/Views/front/sitepage/index.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<div id="content">
|
||||
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
|
||||
<div class="top">
|
||||
<?= $this->include('templates/front/index_head') ?>
|
||||
</div>
|
||||
<?php $cnt = 0 ?>
|
||||
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
|
||||
<?= getFieldIndex_Row_SitepageHelper('content', $entity, $viewDatas) ?>
|
||||
<?php $cnt++ ?>
|
||||
<?php endforeach ?>
|
||||
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
|
||||
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@ -2,6 +2,7 @@
|
||||
<?= $this->section('content') ?>
|
||||
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
<div id="content">
|
||||
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
|
||||
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
@ -18,5 +19,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
<?= form_close(); ?>
|
||||
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@ -4,10 +4,13 @@
|
||||
</h2>
|
||||
<div id="flush-heading-Board" class="accordion-collapse collapse show" aria-labelledby="flush-heading-Board">
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/admin/category"><?= CLASS_ICONS['CATEGORY'] ?>범주 관리</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>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/admin/sitepage"><?= CLASS_ICONS['SITEPAGE'] ?>SitePage 관리</a></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -5,8 +5,8 @@
|
||||
About US
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDarkDropdownMenuLink">
|
||||
<li><a class="dropdown-item" href="#">인사말</a></li>
|
||||
<li><a class="dropdown-item" href="#">회사소개</a></li>
|
||||
<li><a class="dropdown-item" href="/front/sitepage?category=15">인사말</a></li>
|
||||
<li><a class="dropdown-item" href="/front/sitepage?category=14">회사소개</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user