Automation init...3
This commit is contained in:
parent
d442bf2765
commit
24bb1fca5d
@ -19,7 +19,7 @@ class FileLibrary extends MyStorageLibrary
|
|||||||
{
|
{
|
||||||
return $this->_path;
|
return $this->_path;
|
||||||
}
|
}
|
||||||
public function getFileEntity(): FileEntity
|
public function createFileEntity(): FileEntity
|
||||||
{
|
{
|
||||||
return new FileEntity();
|
return new FileEntity();
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ class FileLibrary extends MyStorageLibrary
|
|||||||
if (!file_put_contents($saveFilePath, $content)) {
|
if (!file_put_contents($saveFilePath, $content)) {
|
||||||
throw new \Exception(__FUNCTION__ . "파일저장 실패:{$saveFilePath}");
|
throw new \Exception(__FUNCTION__ . "파일저장 실패:{$saveFilePath}");
|
||||||
}
|
}
|
||||||
$entity = $this->getFileEntity();
|
$entity = $this->createFileEntity();
|
||||||
$entity->setPath($this->getPath());
|
$entity->setPath($this->getPath());
|
||||||
$entity->setTitle($fileName);
|
$entity->setTitle($fileName);
|
||||||
$entity->setMimeType(mime_content_type($saveFilePath));
|
$entity->setMimeType(mime_content_type($saveFilePath));
|
||||||
|
|||||||
@ -27,10 +27,6 @@ class MangboardLibrary extends FileLibrary
|
|||||||
}
|
}
|
||||||
return $this->_model;
|
return $this->_model;
|
||||||
}
|
}
|
||||||
public function getFileEntity(): FileEntity
|
|
||||||
{
|
|
||||||
return new FileEntity();
|
|
||||||
}
|
|
||||||
public function getUser(): UserEntity
|
public function getUser(): UserEntity
|
||||||
{
|
{
|
||||||
if ($this->_user === null) {
|
if ($this->_user === null) {
|
||||||
@ -75,6 +71,12 @@ class MangboardLibrary extends FileLibrary
|
|||||||
{
|
{
|
||||||
$this->_boardLevel = $boardLevel;
|
$this->_boardLevel = $boardLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//주의:Override함
|
||||||
|
public function createFileEntity(): FileEntity
|
||||||
|
{
|
||||||
|
return new FileEntity();
|
||||||
|
}
|
||||||
private function create_small_image(FileEntity $entity, int $file_sequence): FileEntity
|
private function create_small_image(FileEntity $entity, int $file_sequence): FileEntity
|
||||||
{
|
{
|
||||||
$fullPath = WRITEPATH . $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getPath();
|
$fullPath = WRITEPATH . $this->getUploadPath() . DIRECTORY_SEPARATOR . $this->getPath();
|
||||||
@ -85,8 +87,9 @@ class MangboardLibrary extends FileLibrary
|
|||||||
$image->setDebug($this->getDebug());
|
$image->setDebug($this->getDebug());
|
||||||
//Small 디렉토리 생성
|
//Small 디렉토리 생성
|
||||||
$image->makeDirectory($image->getDestinationPath());
|
$image->makeDirectory($image->getDestinationPath());
|
||||||
$dstfile = $image->make_small_image($entity->getTitle());
|
if (!$image->make_small_image($entity->getTitle())) {
|
||||||
log_message("notice", __FUNCTION__ . " {$file_sequence}번째 {$dstfile} 작업 완료");
|
log_message("notice", __FUNCTION__ . " {$file_sequence}번째 " . $entity->getTitle() . " 작업 완료");
|
||||||
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//망보드 파일관리 table에 등록
|
//망보드 파일관리 table에 등록
|
||||||
@ -100,6 +103,8 @@ class MangboardLibrary extends FileLibrary
|
|||||||
$entity->reg_date = date("Y-m-d H:i:s");
|
$entity->reg_date = date("Y-m-d H:i:s");
|
||||||
$entity->file_caption = $entity->getTitle();
|
$entity->file_caption = $entity->getTitle();
|
||||||
$entity->file_alt = $entity->getTitle();
|
$entity->file_alt = $entity->getTitle();
|
||||||
|
//mb_files에서 file_path가 망보드 게시판 파일관리에서 image로 표시되어 file_path+file_name로 설정
|
||||||
|
$entity->file_path = $entity->getPath() . DIRECTORY_SEPARATOR . $entity->getTitle();
|
||||||
$entity->file_description = "Filedata";
|
$entity->file_description = "Filedata";
|
||||||
$entity = $this->getModel()->create($entity);
|
$entity = $this->getModel()->create($entity);
|
||||||
log_message("notice", __FUNCTION__ . " {$file_sequence}번째 작업 완료");
|
log_message("notice", __FUNCTION__ . " {$file_sequence}번째 작업 완료");
|
||||||
@ -108,8 +113,8 @@ class MangboardLibrary extends FileLibrary
|
|||||||
public function save(string $fileName, string $mediaType, string $content, int $file_sequence): FileEntity
|
public function save(string $fileName, string $mediaType, string $content, int $file_sequence): FileEntity
|
||||||
{
|
{
|
||||||
$entity = parent::save($fileName, $mediaType, $content, $file_sequence);
|
$entity = parent::save($fileName, $mediaType, $content, $file_sequence);
|
||||||
|
$entity = $this->create_db($$entity, $file_sequence);
|
||||||
$entity = $this->create_small_image($entity, $file_sequence);
|
$entity = $this->create_small_image($entity, $file_sequence);
|
||||||
$entity = $this->create_db($entity, $file_sequence);
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
public function setBoardPID(array $fileEntitys, int $board_pid)
|
public function setBoardPID(array $fileEntitys, int $board_pid)
|
||||||
@ -117,6 +122,8 @@ class MangboardLibrary extends FileLibrary
|
|||||||
//망보드 파일관리툴에 등록된 파일게시물에 등록한 게시판번호 수정하기
|
//망보드 파일관리툴에 등록된 파일게시물에 등록한 게시판번호 수정하기
|
||||||
foreach ($fileEntitys as $fileEntity) {
|
foreach ($fileEntitys as $fileEntity) {
|
||||||
$fileEntity->board_pid = $board_pid;
|
$fileEntity->board_pid = $board_pid;
|
||||||
|
//수정시 mb_files에서 file_path가 변경하지 못하게 하기위함
|
||||||
|
$this->getModel()->setFields($this->getModel()->getFields(['file_path']));
|
||||||
$this->getModel()->modify($fileEntity);
|
$this->getModel()->modify($fileEntity);
|
||||||
}
|
}
|
||||||
log_message("notice", __FUNCTION__ . " 작업 완료");
|
log_message("notice", __FUNCTION__ . " 작업 완료");
|
||||||
|
|||||||
@ -107,10 +107,13 @@ class ImageLibrary extends MyUtilLibrary
|
|||||||
imagedestroy($this->_image);
|
imagedestroy($this->_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function make_small_image(string $file, int $width = 480, int $height = 319): string
|
public function make_small_image(string $file, int $width = 480, int $height = 319): bool
|
||||||
{
|
{
|
||||||
|
if (!$this->isFileType($this->getSourcePath(), $file)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//소스파일
|
//소스파일
|
||||||
$srcfile = $this->getSourcePath() . DIRECTORY_SEPARATOR . $file;
|
$srcfile = $this->getSourcePath() . DIRECTORY_SEPARATOR . $file;
|
||||||
$fileInfos = pathinfo($srcfile, PATHINFO_ALL);
|
$fileInfos = pathinfo($srcfile, PATHINFO_ALL);
|
||||||
//저장파일
|
//저장파일
|
||||||
$dstfile = $this->getDestinationPath() . DIRECTORY_SEPARATOR . $fileInfos['filename'] . "_small." . $fileInfos['extension'];
|
$dstfile = $this->getDestinationPath() . DIRECTORY_SEPARATOR . $fileInfos['filename'] . "_small." . $fileInfos['extension'];
|
||||||
@ -119,6 +122,6 @@ class ImageLibrary extends MyUtilLibrary
|
|||||||
$this->save($dstfile); // 저장
|
$this->save($dstfile); // 저장
|
||||||
$this->destroy(); // 메모리 해제
|
$this->destroy(); // 메모리 해제
|
||||||
log_message("notice", __FUNCTION__ . " 작업 완료");
|
log_message("notice", __FUNCTION__ . " 작업 완료");
|
||||||
return $dstfile;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,9 +46,10 @@ abstract class CommonModel extends Model
|
|||||||
protected $afterDelete = [];
|
protected $afterDelete = [];
|
||||||
|
|
||||||
private $_action = DB_ACTION["CREATE"];
|
private $_action = DB_ACTION["CREATE"];
|
||||||
protected function __construct()
|
protected function __construct(array $fields)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->setFields($fields);
|
||||||
}
|
}
|
||||||
abstract public function getTitleField(): string;
|
abstract public function getTitleField(): string;
|
||||||
|
|
||||||
@ -73,6 +74,14 @@ abstract class CommonModel extends Model
|
|||||||
}
|
}
|
||||||
return $this->allowedFields;
|
return $this->allowedFields;
|
||||||
}
|
}
|
||||||
|
final public function setFields(array $fields): void
|
||||||
|
{
|
||||||
|
$this->allowedFields = $fields;
|
||||||
|
//array_unshift는 array의 맨앞에 넣기위함
|
||||||
|
if (!$this->useAutoIncrement) {
|
||||||
|
array_unshift($this->allowedFields, $this->getPKField());
|
||||||
|
}
|
||||||
|
}
|
||||||
final public function getFieldRules(array $fields, array $rules = []): array
|
final public function getFieldRules(array $fields, array $rules = []): array
|
||||||
{
|
{
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
|
|||||||
@ -71,24 +71,24 @@ class BoardModel extends CommonModel
|
|||||||
// protected $table = 'mb_board_free';
|
// protected $table = 'mb_board_free';
|
||||||
protected $primaryKey = 'pid';
|
protected $primaryKey = 'pid';
|
||||||
protected $returnType = BoardEntity::class;
|
protected $returnType = BoardEntity::class;
|
||||||
protected $allowedFields = [
|
|
||||||
"gid",
|
|
||||||
"title",
|
|
||||||
"user_pid",
|
|
||||||
"user_id",
|
|
||||||
"user_name",
|
|
||||||
"level",
|
|
||||||
"data_type",
|
|
||||||
"editor_type",
|
|
||||||
"image_path",
|
|
||||||
"reg_date",
|
|
||||||
"hit",
|
|
||||||
"content"
|
|
||||||
];
|
|
||||||
public function __construct(string $table)
|
public function __construct(string $table)
|
||||||
{
|
{
|
||||||
$this->table = $table;
|
$this->table = $table;
|
||||||
parent::__construct();
|
$fields = [
|
||||||
|
"gid",
|
||||||
|
"title",
|
||||||
|
"user_pid",
|
||||||
|
"user_id",
|
||||||
|
"user_name",
|
||||||
|
"level",
|
||||||
|
"data_type",
|
||||||
|
"editor_type",
|
||||||
|
"image_path",
|
||||||
|
"reg_date",
|
||||||
|
"hit",
|
||||||
|
"content"
|
||||||
|
];
|
||||||
|
parent::__construct($fields);
|
||||||
}
|
}
|
||||||
public function getTitleField(): string
|
public function getTitleField(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -35,26 +35,25 @@ class FileModel extends CommonModel
|
|||||||
protected $table = 'mb_files';
|
protected $table = 'mb_files';
|
||||||
protected $primaryKey = 'pid';
|
protected $primaryKey = 'pid';
|
||||||
protected $returnType = FileEntity::class;
|
protected $returnType = FileEntity::class;
|
||||||
protected $allowedFields = [
|
|
||||||
"user_pid",
|
|
||||||
"user_name",
|
|
||||||
"board_pid",
|
|
||||||
"board_name",
|
|
||||||
"table_name",
|
|
||||||
"file_name",
|
|
||||||
"file_path",
|
|
||||||
"file_type",
|
|
||||||
"file_caption",
|
|
||||||
"file_alt",
|
|
||||||
"file_description",
|
|
||||||
"file_size",
|
|
||||||
"file_sequence",
|
|
||||||
"reg_date"
|
|
||||||
];
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$fields = [
|
||||||
|
"user_pid",
|
||||||
|
"user_name",
|
||||||
|
"board_pid",
|
||||||
|
"board_name",
|
||||||
|
"table_name",
|
||||||
|
"file_name",
|
||||||
|
"file_path",
|
||||||
|
"file_type",
|
||||||
|
"file_caption",
|
||||||
|
"file_alt",
|
||||||
|
"file_description",
|
||||||
|
"file_size",
|
||||||
|
"file_sequence",
|
||||||
|
"reg_date"
|
||||||
|
];
|
||||||
|
parent::__construct($fields);
|
||||||
}
|
}
|
||||||
public function getTitleField(): string
|
public function getTitleField(): string
|
||||||
{
|
{
|
||||||
@ -109,7 +108,7 @@ class FileModel extends CommonModel
|
|||||||
}
|
}
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case "file_path":
|
case "file_path":
|
||||||
$entity->$field = $entity->$field . DIRECTORY_SEPARATOR . $entity->getTitle();
|
$entity->$field .= DIRECTORY_SEPARATOR . $entity->getTitle();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$entity = parent::convertEntityData($entity, $field);
|
$entity = parent::convertEntityData($entity, $field);
|
||||||
|
|||||||
@ -99,19 +99,18 @@ class UserModel extends CommonModel
|
|||||||
protected $table = 'mb_users';
|
protected $table = 'mb_users';
|
||||||
protected $primaryKey = 'pid';
|
protected $primaryKey = 'pid';
|
||||||
protected $returnType = UserEntity::class;
|
protected $returnType = UserEntity::class;
|
||||||
protected $allowedFields = [
|
|
||||||
"user_id",
|
|
||||||
"passwd",
|
|
||||||
"user_name",
|
|
||||||
"user_email",
|
|
||||||
"user_state",
|
|
||||||
"user_level",
|
|
||||||
"user_point"
|
|
||||||
];
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$fields = [
|
||||||
|
"user_id",
|
||||||
|
"passwd",
|
||||||
|
"user_name",
|
||||||
|
"user_email",
|
||||||
|
"user_state",
|
||||||
|
"user_level",
|
||||||
|
"user_point"
|
||||||
|
];
|
||||||
|
parent::__construct($fields);
|
||||||
}
|
}
|
||||||
public function getTitleField(): string
|
public function getTitleField(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,18 +10,17 @@ class SNSUserModel extends CommonModel
|
|||||||
protected $table = 'sns_users';
|
protected $table = 'sns_users';
|
||||||
protected $primaryKey = 'uid';
|
protected $primaryKey = 'uid';
|
||||||
protected $returnType = SNSUSerEntity::class;
|
protected $returnType = SNSUSerEntity::class;
|
||||||
protected $allowedFields = [
|
|
||||||
"id",
|
|
||||||
"passwd",
|
|
||||||
"name",
|
|
||||||
"email",
|
|
||||||
"detail",
|
|
||||||
"status"
|
|
||||||
];
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$fields = [
|
||||||
|
"id",
|
||||||
|
"passwd",
|
||||||
|
"name",
|
||||||
|
"email",
|
||||||
|
"detail",
|
||||||
|
"status"
|
||||||
|
];
|
||||||
|
parent::__construct($fields);
|
||||||
}
|
}
|
||||||
public function getTitleField(): string
|
public function getTitleField(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,20 +10,19 @@ class UserModel extends CommonModel
|
|||||||
protected $table = 'users';
|
protected $table = 'users';
|
||||||
protected $primaryKey = 'uid';
|
protected $primaryKey = 'uid';
|
||||||
protected $returnType = UserEntity::class;
|
protected $returnType = UserEntity::class;
|
||||||
protected $allowedFields = [
|
|
||||||
"id",
|
|
||||||
"passwd",
|
|
||||||
"name",
|
|
||||||
"email",
|
|
||||||
"pohne",
|
|
||||||
"mobild",
|
|
||||||
"role",
|
|
||||||
"status"
|
|
||||||
];
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
$fields = [
|
||||||
|
"id",
|
||||||
|
"passwd",
|
||||||
|
"name",
|
||||||
|
"email",
|
||||||
|
"pohne",
|
||||||
|
"mobild",
|
||||||
|
"role",
|
||||||
|
"status"
|
||||||
|
];
|
||||||
|
parent::__construct($fields);
|
||||||
}
|
}
|
||||||
public function getTitleField(): string
|
public function getTitleField(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,8 +13,7 @@ trait FileTrait
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//디렉토리에 속한 파일 List
|
public function isFileType(string $path, string $file, $type = "image"): bool
|
||||||
public function getFilesByExtentionType(string $path, string $type = "image"): array
|
|
||||||
{
|
{
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "audio":
|
case "audio":
|
||||||
@ -28,12 +27,18 @@ trait FileTrait
|
|||||||
$exts = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
|
$exts = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$ext = pathinfo($path . DIRECTORY_SEPARATOR . $file, PATHINFO_EXTENSION);
|
||||||
|
return in_array($ext, $exts);
|
||||||
|
}
|
||||||
|
|
||||||
|
//디렉토리에 속한 파일 List
|
||||||
|
public function getFilesByExtentionType(string $path, string $type = "image"): array
|
||||||
|
{
|
||||||
// 디렉토리에서 파일 목록 가져오기
|
// 디렉토리에서 파일 목록 가져오기
|
||||||
$files = [];
|
$files = [];
|
||||||
foreach (scandir($path) as $file) {
|
foreach (scandir($path) as $file) {
|
||||||
$ext = pathinfo($path . DIRECTORY_SEPARATOR . $file, PATHINFO_EXTENSION);
|
|
||||||
// 확장자가 이미지 형식인지 확인
|
// 확장자가 이미지 형식인지 확인
|
||||||
if (in_array($ext, $exts)) {
|
if ($this->isFileType($path, $file, $type)) {
|
||||||
$files[] = $file;
|
$files[] = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user