diff --git a/app/Config/Constants.php b/app/Config/Constants.php
index 5101cd8..ce16c0c 100644
--- a/app/Config/Constants.php
+++ b/app/Config/Constants.php
@@ -206,6 +206,7 @@ define('ICONS', [
'FLAG' => '',
'SEARCH' => '',
'EXCEL' => '',
+ 'HOME' => '',
'IMAGE_FILE' => '',
]);
define('CLASS_ICONS', [
diff --git a/app/Controllers/Admin/CategoryController.php b/app/Controllers/Admin/CategoryController.php
index beb9b89..ebdad7e 100644
--- a/app/Controllers/Admin/CategoryController.php
+++ b/app/Controllers/Admin/CategoryController.php
@@ -2,6 +2,7 @@
namespace App\Controllers\Admin;
+use App\Controllers\Trait\UpDownloadTrait;
use App\Models\CategoryModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@@ -9,6 +10,7 @@ use Psr\Log\LoggerInterface;
class CategoryController extends AdminController
{
+ use UpDownloadTrait;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new CategoryModel();
@@ -19,14 +21,14 @@ class CategoryController extends AdminController
public function getFields(string $action = ""): array
{
$fields = [
- 'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
+ 'name', "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"status", "head", "tail",
];
switch ($action) {
case "index":
case "excel":
return [
- 'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
+ 'name', 'photo', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"status", "created_at"
];
break;
@@ -46,6 +48,19 @@ class CategoryController extends AdminController
{
return parent::getFieldBatchFilters();
}
+ //Field별 Form Datas 처리용
+ protected function getFieldFormData(string $field, $entity = null): array
+ {
+ switch ($field) {
+ case 'photo':
+ $this->_viewDatas['fieldDatas'][$field] = $this->upload_image_procedure($field);
+ break;
+ default:
+ return parent::getFieldFormData($field, $entity);
+ break;
+ }
+ return $this->_viewDatas['fieldDatas'];
+ }
// private function build_leftmenu()
// {
diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php
index c39edc3..b830078 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
{
@@ -29,6 +29,9 @@ abstract class FrontController extends BaseController
{
$this->_category = !is_null($entity) ? $entity->getCategory_Uid() : ($this->request->getVar('category') ?: 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);
+ $this->_viewDatas['sibling_categorys'] = $categorys;
switch ($action) {
case 'insert':
$category_field = CATEGORY_ROLE_FIELDS['WRITE'];
diff --git a/app/Database/shoppingmall.sql b/app/Database/shoppingmall.sql
index 3aaf112..45b3e42 100644
--- a/app/Database/shoppingmall.sql
+++ b/app/Database/shoppingmall.sql
@@ -50,6 +50,7 @@ CREATE TABLE shoppingmall.tw_category (
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 '범주명',
+ photo varchar(255) NULL COMMENT '이미지',
isaccess varchar(30) NOT NULL DEFAULT 'guest' COMMENT '접근권한',
isread varchar(30) NOT NULL DEFAULT 'guest' COMMENT '읽기권한',
iswrite varchar(30) NOT NULL DEFAULT 'guest' COMMENT '쓰기권한',
diff --git a/app/Entities/CategoryEntity.php b/app/Entities/CategoryEntity.php
index 8f92b43..1f117c6 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 = [];
@@ -40,4 +38,20 @@ class CategoryEntity extends BaseHierarchyEntity
$this->attributes
) ? $this->attributes[$field] : DEFAULTS['ROLE'];
}
+ public function getPhoto()
+ {
+ return $this->attributes['photo'];
+ }
+ public function getPhotoFileName($size = false)
+ {
+ $photo = $this->getPhoto();
+ if (is_null($photo)) {
+ return "";
+ }
+ return sprintf(
+ "
",
+ $size ? $size . '_' : '',
+ explode(DEFAULTS['DELIMITER_FILE'], $this->getPhoto())[1]
+ );
+ }
}
diff --git a/app/Entities/ProductEntity.php b/app/Entities/ProductEntity.php
index 9fef019..bcf634b 100644
--- a/app/Entities/ProductEntity.php
+++ b/app/Entities/ProductEntity.php
@@ -47,9 +47,17 @@ class ProductEntity extends BaseEntity
{
return $this->attributes['photo'];
}
- public function getPhotoFileName($size = 'small')
+ public function getPhotoFileName($size = false)
{
- return $size . '_' . explode(DEFAULTS['DELIMITER_FILE'], $this->getPhoto())[1];
+ $photo = $this->getPhoto();
+ if (is_null($photo)) {
+ return "";
+ }
+ return sprintf(
+ "
",
+ $size ? $size . '_' : '',
+ explode(DEFAULTS['DELIMITER_FILE'], $this->getPhoto())[1]
+ );
}
public function getContent()
{
diff --git a/app/Helpers/Category_helper.php b/app/Helpers/Category_helper.php
index f4d16f9..5c7e801 100644
--- a/app/Helpers/Category_helper.php
+++ b/app/Helpers/Category_helper.php
@@ -44,6 +44,7 @@ function getFieldForm_CategoryHelper($field, $value, array $viewDatas, array $at
break;
case 'upload_file':
case 'board_file':
+ case 'photo':
return form_upload($field);
break;
case 'view_cnt':
@@ -90,6 +91,10 @@ function getFieldView_CategoryHelper($field, $entity, array $viewDatas)
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 'photo':
+ // return $entity->getPhotoFileName();
+ return $entity->getPhotoFileName('middle');
+ break;
case 'view_cnt':
return number_format(!$value ? 0 : $value);
break;
diff --git a/app/Helpers/Product_helper.php b/app/Helpers/Product_helper.php
index f2e4752..8656220 100644
--- a/app/Helpers/Product_helper.php
+++ b/app/Helpers/Product_helper.php
@@ -93,7 +93,7 @@ function getFieldView_ProductHelper($field, $entity, array $viewDatas)
break;
case 'photo':
// return $entity->getPhotoFileName();
- return "
getPhotoFileName() . "\">";
+ return $entity->getPhotoFileName('middle');
break;
case 'cost':
case 'price':
diff --git a/app/Language/ko/Category.php b/app/Language/ko/Category.php
index 548bc6e..3e26440 100644
--- a/app/Language/ko/Category.php
+++ b/app/Language/ko/Category.php
@@ -9,6 +9,7 @@ return [
'label' => [
'uid' => "번호",
'name' => "범주제목",
+ 'photo' => "이미지",
'isaccess' => "접속권한",
'isread' => "읽기권한",
'iswrite' => "쓰기권한",
diff --git a/app/Models/BaseHierarchyModel.php b/app/Models/BaseHierarchyModel.php
index d56cdce..2d3f41e 100644
--- a/app/Models/BaseHierarchyModel.php
+++ b/app/Models/BaseHierarchyModel.php
@@ -15,6 +15,10 @@ abstract class BaseHierarchyModel extends BaseModel
}
abstract public function getContentField();
abstract public function reply($parent_entity, array $formDatas): BaseEntity;
+ public function getSiblingEntitys($entity)
+ {
+ return $this->getEntitys(['grpno' => $entity->getHierarchy_No()]);
+ }
protected function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php
index 50b7108..b09b430 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', "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"head", "tail", "status"
];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
@@ -33,6 +33,9 @@ class CategoryModel extends BaseHierarchyModel
$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":
diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php
index 2a6848c..d3e921b 100644
--- a/app/Models/ProductModel.php
+++ b/app/Models/ProductModel.php
@@ -41,7 +41,7 @@ class ProductModel extends BaseModel
$rules[$field] = "required|trim|string";
break;
case 'photo':
- $rules[$field] = !$action ? "if_exist|string" : "uploaded[$field]|is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},100]|max_dims[{$field},1024,768]";
+ $rules[$field] = !$action ? "if_exist|string" : "uploaded[$field]|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 'cost':
case 'price':
diff --git a/app/Views/front/product/index.php b/app/Views/front/product/index.php
index 77717e4..f9e34d2 100644
--- a/app/Views/front/product/index.php
+++ b/app/Views/front/product/index.php
@@ -2,7 +2,7 @@
= $this->section('content') ?>
= html_entity_decode($viewDatas['category']->getHead()) ?>
-
+
= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . 'order_field=price,order_value=ASC', '판매가순', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?>
diff --git a/app/Views/front/product/index_list.php b/app/Views/front/product/index_list.php
index 608bf72..30fdb9f 100644
--- a/app/Views/front/product/index_list.php
+++ b/app/Views/front/product/index_list.php
@@ -2,7 +2,7 @@
= $this->section('content') ?>
= html_entity_decode($viewDatas['category']->getHead()) ?>
-
+
= anchor(current_url() . '?category=' . $viewDatas['category']->getPrimaryKey() . 'order_field=price,order_value=ASC', '판매가순', ["class" => "btn btn-sm btn-info btn-circle", "target" => "_self"]) ?>
diff --git a/app/Views/layouts/admin/top_menu.php b/app/Views/layouts/admin/top_menu.php
deleted file mode 100644
index 9a55593..0000000
--- a/app/Views/layouts/admin/top_menu.php
+++ /dev/null
@@ -1,20 +0,0 @@
-
\ No newline at end of file
diff --git a/app/Views/layouts/front.php b/app/Views/layouts/front.php
index ca2ac72..8f1755e 100644
--- a/app/Views/layouts/front.php
+++ b/app/Views/layouts/front.php
@@ -30,23 +30,33 @@
- = $this->include($viewDatas['layout']['path'] . '/top_navigator'); ?>
- = $this->include($viewDatas['layout']['path'] . '/top_menu'); ?>
-
-
- |
- = $this->include($viewDatas['layout']['path'] . '/left_menu'); ?>
- |
-
- = $this->include('templates/admin/header'); ?>
- = $this->renderSection('content') ?>
- = $this->include('templates/admin/footer'); ?>
- |
-
-
-
- = $this->include($viewDatas['layout']['path'] . '/copyright'); ?>
+
+ = $this->include($viewDatas['layout']['path'] . '/top_navigator'); ?>
+ = $this->include($viewDatas['layout']['path'] . '/top_menu'); ?>
+
+ = $viewDatas['parent_category']->getPhotoFileName() ?>
+
+
+
+
+
+
+ |
+ = $this->include($viewDatas['layout']['path'] . '/left_menu'); ?>
+ |
+
+ = $this->include('templates/front/header'); ?>
+ = $this->renderSection('content') ?>
+ = $this->include('templates/front/footer'); ?>
+ |
+
+
+
+
+
+ = $this->include($viewDatas['layout']['path'] . '/copyright'); ?>
+
| |