diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php index b830078..b6c6a77 100644 --- a/app/Controllers/Front/FrontController.php +++ b/app/Controllers/Front/FrontController.php @@ -58,12 +58,12 @@ abstract class FrontController extends BaseController $this->_viewDatas['category'], $category_field, )) { - echo var_export($this->_viewDatas['currentRoles'], true); - echo "
"; - echo var_export($this->_viewDatas['category'], true); - echo "
"; - echo "field->", $action . ":" . $category_field; - exit; + // echo var_export($this->_viewDatas['currentRoles'], true); + // echo "
"; + // echo var_export($this->_viewDatas['category'], true); + // echo "
"; + // echo "field->", $action . ":" . $category_field; + // exit; throw new \Exception("고객님은 " . lang($this->getCategoryModel()->getClassName() . ".label." . $category_field) . "이 없습니다."); } } diff --git a/app/Entities/BaseEntity.php b/app/Entities/BaseEntity.php index f3f4b05..7c7822e 100644 --- a/app/Entities/BaseEntity.php +++ b/app/Entities/BaseEntity.php @@ -8,4 +8,30 @@ abstract class BaseEntity extends Entity { abstract public function getPrimaryKey(); abstract public function getTitle(): string; + + //조화수관련 Field전용 + final public function getViews($field = 'view_cnt') + { + return $this->attributes[$field]; + } + + //파일관련 Field전용 + + final public function getFileDownload($field = "upload_file") + { + return anchor( + current_url() . "/download/{$field}/{$this->getPrimaryKey()}", + ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field])[1], + ["target" => "_self"] + ); + } + //이미지관련 Field전용 + final public function getFileImage($field = "photo", $size = false) + { + return sprintf( + "", + $size ? $size . '_' : '', + explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field])[1] + ); + } } diff --git a/app/Entities/BoardEntity.php b/app/Entities/BoardEntity.php index a459f73..bbe81d6 100644 --- a/app/Entities/BoardEntity.php +++ b/app/Entities/BoardEntity.php @@ -35,16 +35,8 @@ class BoardEntity extends BaseHierarchyEntity { return $this->attributes['passwd']; } - public function getViews() - { - return $this->attributes['view_cnt']; - } public function getBoardFile() { return $this->attributes['board_file']; } - public function getBoardFileName() - { - return explode(DEFAULTS['DELIMITER_FILE'], $this->getBoardFile())[1]; - } } diff --git a/app/Entities/CategoryEntity.php b/app/Entities/CategoryEntity.php index 1f117c6..477b319 100644 --- a/app/Entities/CategoryEntity.php +++ b/app/Entities/CategoryEntity.php @@ -42,16 +42,4 @@ class CategoryEntity extends BaseHierarchyEntity { 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 bcf634b..3c310a2 100644 --- a/app/Entities/ProductEntity.php +++ b/app/Entities/ProductEntity.php @@ -47,26 +47,10 @@ class ProductEntity extends BaseEntity { 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] - ); - } public function getContent() { return $this->attributes['content']; } - public function getViews() - { - return $this->attributes['view_cnt']; - } public function getStock() { return $this->attributes['stock']; diff --git a/app/Helpers/Board_helper.php b/app/Helpers/Board_helper.php index b0abf09..016eddb 100644 --- a/app/Helpers/Board_helper.php +++ b/app/Helpers/Board_helper.php @@ -94,7 +94,10 @@ function getFieldView_BoardHelper($field, $entity, array $viewDatas) break; case 'board_file': case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]); + return $entity->getFileDownload($field); + break; + case 'photo': + return $entity->getFileImage($field, 'middle'); break; case 'view_cnt': return number_format(!$value ? 0 : $value); diff --git a/app/Helpers/Category_helper.php b/app/Helpers/Category_helper.php index 5c7e801..8468f10 100644 --- a/app/Helpers/Category_helper.php +++ b/app/Helpers/Category_helper.php @@ -40,7 +40,11 @@ function getFieldForm_CategoryHelper($field, $value, array $viewDatas, array $at case 'content': case 'head': case 'tail': - return form_textarea($field, html_entity_decode($value), ['class' => 'editor', 'rows' => '20', 'cols' => '100']); + return form_textarea( + $field, + html_entity_decode($value), + ['class' => 'editor', 'rows' => '20', 'cols' => '100'] + ); break; case 'upload_file': case 'board_file': @@ -89,11 +93,10 @@ function getFieldView_CategoryHelper($field, $entity, array $viewDatas) break; case 'board_file': case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]); + return $entity->getFileDownload($field); break; case 'photo': - // return $entity->getPhotoFileName(); - return $entity->getPhotoFileName('middle'); + return $entity->getFileImage($field, 'middle'); break; case 'view_cnt': return number_format(!$value ? 0 : $value); diff --git a/app/Helpers/Product_helper.php b/app/Helpers/Product_helper.php index 57c8917..950af29 100644 --- a/app/Helpers/Product_helper.php +++ b/app/Helpers/Product_helper.php @@ -89,11 +89,10 @@ function getFieldView_ProductHelper($field, $entity, array $viewDatas) break; case 'board_file': case 'upload_file': - return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . "/download/{$field}/{$entity->getPrimaryKey()}", ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $value)[0], ["target" => "_self"]); + return $entity->getFileDownload($field); break; case 'photo': - // return $entity->getPhotoFileName(); - return $entity->getPhotoFileName('middle'); + return $entity->getFileImage($field, 'middle'); break; case 'cost': case 'price': diff --git a/app/Views/layouts/front.php b/app/Views/layouts/front.php index c42ed07..a074435 100644 --- a/app/Views/layouts/front.php +++ b/app/Views/layouts/front.php @@ -34,7 +34,7 @@ include($viewDatas['layout']['path'] . '/top_navigator'); ?> include($viewDatas['layout']['path'] . '/top_menu'); ?> - getPhotoFileName() ?> + getFileImage() ?>