_imageLibrary = new SmallImageLibrary();
$fullPath = WRITEPATH . $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getPath();
$this->_imageLibrary->setDebug($this->getDebug());
$this->_imageLibrary->setSourcePath($fullPath);
$this->_imageLibrary->setDestinationPath($fullPath);
}
public function getModel(): FileModel
{
if ($this->_model === null) {
return $this->_model = new FileModel();
}
return $this->_model;
}
public function getEntity(): FileEntity
{
return $this->_entity;
}
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 getBoardEntity(): BoardEntity
{
if ($this->_board_entity === null) {
throw new \Exception("Board Entity가 정의되지 않았습니다.");
}
return $this->_board_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;
}
public function setBoardEntity(BoardEntity $board_entity): void
{
$this->_board_entity = $board_entity;
}
final public function getHTMLTag(string $content = ""): string
{
//Board 게시판 image_path , content용 데이터 배열에 추가 후 modifyBoard에서 처리
switch ($this->getOrintginType()) {
case "image":
$content = sprintf(
"
",
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 save(): static
{
parent::save();
//파일관리 table에 등록
$formDatas = [];
//Board PID 넣기
$formDatas['board_pid'] = $this->getBoardEntity()->getPk();
//작은이미지생성후 Path/파일명 넣기
$fileInfos = pathinfo($this->_imageLibrary->getDestinationPath() . DIRECTORY_SEPARATOR . $this->getOriginName(), PATHINFO_ALL);
$dstFile = $fileInfos['filename'] . "_small." . $fileInfos['extension'];
$this->_imageLibrary->setDestinationFile($dstFile);
$formDatas['file_path'] = sprintf(
"%s/%s",
$this->getPath(),
$this->_imageLibrary->create($this->getOriginName())
);
$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_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번째 작업 완료",
__FUNCTION__,
$this->getOriginSequence()
));
return $this;
}
}