vhost init...1
This commit is contained in:
parent
cdcb113eda
commit
d7c3c48c11
@ -67,13 +67,13 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->get('excel', 'CategoryController::excel');
|
||||
$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->get('update/(:alpha)', 'CategoryController::update_form/$1');
|
||||
$routes->post('update/(:alpha)', 'CategoryController::update/$1');
|
||||
$routes->get('reply/(:alpha)', 'CategoryController::reply_form/$1');
|
||||
$routes->post('reply/(:alpha)', 'CategoryController::reply/$1');
|
||||
$routes->get('view/(:alpha)', 'CategoryController::view/$1');
|
||||
$routes->get('delete/(:alpha)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']);
|
||||
$routes->get('toggle/(:alpha)/(:hash)', 'CategoryController::toggle/$1/$2');
|
||||
$routes->post('batchjob', 'CategoryController::batchjob');
|
||||
});
|
||||
$routes->group('board', static function ($routes) {
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
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;
|
||||
@ -11,14 +9,13 @@ use Psr\Log\LoggerInterface;
|
||||
|
||||
class CategoryController extends AdminController
|
||||
{
|
||||
use UpDownloadTrait;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_model = new CategoryModel();
|
||||
$this->_viewDatas['className'] = 'Category';
|
||||
$this->_model = new CategoryModel();
|
||||
$this->_viewDatas['className'] = 'Category';
|
||||
$this->_viewPath .= strtolower($this->_viewDatas['className']);
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
|
||||
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
|
||||
helper($this->_viewDatas['className']);
|
||||
}
|
||||
@ -26,15 +23,33 @@ class CategoryController extends AdminController
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = [
|
||||
'name', "linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "head", "tail",
|
||||
'uid',
|
||||
'name',
|
||||
"linkurl",
|
||||
"isaccess",
|
||||
"isread",
|
||||
"iswrite",
|
||||
"isreply",
|
||||
"isupload",
|
||||
"isdownload",
|
||||
"status",
|
||||
"head",
|
||||
"tail",
|
||||
];
|
||||
switch ($action) {
|
||||
case "index":
|
||||
case "excel":
|
||||
return [
|
||||
'name', "linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
||||
"status", "created_at"
|
||||
'name',
|
||||
"linkurl",
|
||||
"isaccess",
|
||||
"isread",
|
||||
"iswrite",
|
||||
"isreply",
|
||||
"isupload",
|
||||
"isdownload",
|
||||
"status",
|
||||
"created_at",
|
||||
];
|
||||
break;
|
||||
case "view":
|
||||
@ -53,74 +68,4 @@ class CategoryController extends AdminController
|
||||
{
|
||||
return parent::getFieldBatchFilters();
|
||||
}
|
||||
|
||||
private function write_leftmenu($old_category, array $categorys)
|
||||
{
|
||||
//신규 대분류인경우 기존 카테고리 메뉴 만들기
|
||||
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/common/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;
|
||||
}
|
||||
//Toggle관련
|
||||
protected function toggle_process($entity)
|
||||
{
|
||||
$entity = parent::toggle_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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ CREATE TABLE vhost.tw_board (
|
||||
DROP TABLE IF EXISTS vhost.tw_sitepage;
|
||||
|
||||
CREATE TABLE vhost.tw_sitepage (
|
||||
uid int(10) unsigned NOT NULL,
|
||||
uid int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
category_uid varchar(50) NOT NULL COMMENT '범주_UID',
|
||||
user_uid varchar(36) DEFAULT NULL COMMENT '작성자 정보',
|
||||
title varchar(255) NOT NULL COMMENT '제목',
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
app/Database/vhost-20240507.sql
Normal file
BIN
app/Database/vhost-20240507.sql
Normal file
Binary file not shown.
@ -145,7 +145,7 @@ function getFieldIndex_Row_CategoryHelper_Admin($field, $entity, array $viewData
|
||||
$value,
|
||||
["target" => "_self"]
|
||||
);
|
||||
return sprintf("%s%s %s", $depth, $reply, $view);
|
||||
return sprintf("%s%s %s(%s)", $depth, $reply, $view, $entity->getPrimaryKey());
|
||||
break;
|
||||
default:
|
||||
if (in_array($field, $viewDatas['fieldFilters'])) {
|
||||
|
||||
@ -7,7 +7,8 @@ $roles = [
|
||||
return [
|
||||
'title' => "분류 정보",
|
||||
'label' => [
|
||||
'uid' => "번호",
|
||||
'uid' => "분류코드",
|
||||
'parent' => "상단코드",
|
||||
'name' => "분류제목",
|
||||
'linkurl' => "LinkURL",
|
||||
'photo' => "이미지",
|
||||
|
||||
@ -10,7 +10,7 @@ abstract class BaseHierarchyModel extends BaseModel
|
||||
protected function __construct(string $className)
|
||||
{
|
||||
parent::__construct($className);
|
||||
$this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth", "parent_uid"];
|
||||
$this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth", "parent"];
|
||||
$this->validationRules = [...$this->validationRules,];
|
||||
}
|
||||
abstract public function getContentField();
|
||||
@ -27,7 +27,7 @@ abstract class BaseHierarchyModel extends BaseModel
|
||||
case "grpdepth":
|
||||
$rules[$field] = "if_exist|numeric"; //반드시숫자여야함
|
||||
break;
|
||||
case "parent_uid":
|
||||
case "parent":
|
||||
$rules[$field] = "if_exist";
|
||||
break;
|
||||
default:
|
||||
@ -57,7 +57,7 @@ abstract class BaseHierarchyModel extends BaseModel
|
||||
final protected function reply_process($parent_entity, $entity, array $formDatas)
|
||||
{
|
||||
//reply용 설정
|
||||
$entity->parent_uid = $parent_entity->getPrimaryKey();
|
||||
$entity->parent = $parent_entity->getPrimaryKey();
|
||||
$entity->grpno = $parent_entity->grpno;
|
||||
//Reply시는 grpno가 부모와 같고 grporder의 max값을 구해서 넣는다.
|
||||
$entity->grporder = $this->getMax('grporder', ['grpno' => $parent_entity->grpno]);
|
||||
|
||||
@ -7,6 +7,7 @@ use App\Entities\CategoryEntity;
|
||||
class CategoryModel extends BaseHierarchyModel
|
||||
{
|
||||
protected $table = "tw_category";
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = CategoryEntity::class;
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
BIN
public/images/sub/com_icon4.png
Normal file
BIN
public/images/sub/com_icon4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
Loading…
Reference in New Issue
Block a user