_model === null) { return $this->_model = new FileModel(); } return $this->_model; } public function getBoardsEntity(): BoardsEntity { if ($this->_boards_entity === null) { throw new \Exception("Board Library가 정의되지 않았습니다."); } return $this->_boards_entity; } public function setBoardsEntity(BoardsEntity $boards_entity): void { $this->_boards_entity = $boards_entity; } public function setUserEntity(UserEntity $user_entity): void { $this->_user_entity = $user_entity; } public function getUserEntity(): UserEntity { if ($this->_user_entity === null) { throw new \Exception("User Entity가 정의되지 않았습니다."); } return $this->_user_entity; } final public function getHTMLTag(string $content = ""): string { //Board 게시판 image_path , content용 데이터 배열에 추가 후 modifyBoard에서 처리 switch ($this->getOrintginType()) { case "image": $content = sprintf( "\"%s\"", getenv("mangboard.uloads.url"), $this->getPath(), $this->getOriginName(), $this->getOriginName() ); break; case "video": $content = sprintf( "", $this->getOriginName(), getenv("mangboard.uloads.url"), $this->getPath(), $this->getOriginName(), $this->getMimeType(), ); break; } log_message("debug", sprintf( "\n--------%s--------\n%s\n--------------------\n", __FUNCTION__, $content )); return $content; } public function createByBoardLibrary(BoardEntity $board_entity, int $cnt, array $listInfos): void { try { //파일관리 table에 등록 $formDatas = []; //Board PID 넣기 $formDatas['board_pid'] = $board_entity->getPk(); $formDatas['user_pid'] = $this->getUserEntity()->getPK(); $formDatas['user_name'] = $this->getUserEntity()->getTitle(); $formDatas['board_name'] = $this->getBoardsEntity()->getTitle(); $formDatas['table_name'] = $this->getModel()->getTable(); $formDatas['file_path'] = sprintf("%s/%s", $this->getPath(), $this->getOriginName()); $formDatas['file_name'] = $this->getOriginName(); $formDatas['file_type'] = $this->getMimeType(); $formDatas['file_caption'] = $this->getOriginName(); $formDatas['file_alt'] = $this->getOriginName(); $formDatas['file_description'] = "Filedata"; $formDatas['file_size'] = $this->getFileSize(); $formDatas['file_sequence'] = $this->getOriginSequence(); $formDatas['reg_date'] = date("Y-m-d H:i:s"); $entity = $this->getModel()->create($formDatas); log_message("notice", sprintf( "게시물 %s번째[%s]의 %s번째용 파일 등록 완료", $cnt, $listInfos['title'], __FUNCTION__, $this->getOriginSequence() )); } catch (\Exception $e) { log_message("notice", sprintf( "\n---%s 게시물 %s번째[%s]의 %s번째용 파일 등록 오류---\n%s\n--------------------------------\n", __FUNCTION__, $cnt, $listInfos['title'], __FUNCTION__, $this->getOriginSequence(), $e->getMessage() )); } } private function save_smallImage(): string { $imageLibrary = new ImageLibrary(); $fullPath = WRITEPATH . $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getPath(); $imageLibrary->setDebug($this->getDebug()); $imageLibrary->setSourcePath($fullPath); $imageLibrary->setDestinationPath($fullPath); //작은이미지생성후 Path/파일명 넣기 $fileInfos = pathinfo($imageLibrary->getDestinationPath() . DIRECTORY_SEPARATOR . $this->getOriginName(), PATHINFO_ALL); $imageLibrary->setDestinationFile($fileInfos['filename'] . "_small." . $fileInfos['extension']); return $imageLibrary->create($this->getOriginName()); } public function save(): static { parent::save(); $this->save_smallImage(); return $this; } }