mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-01 00:02:21 +09:00
#1331 커버 이미지를 선택할 수 있는 기능 추가
- files 테이블에 cover_image 컬럼 추가 - 썸네일 생성 로직에 cover_image 값을 참조하여 이미지 선택 사용 - 파일 업로드 기능에 UI 추가
This commit is contained in:
parent
cc5207423e
commit
4faa291880
14 changed files with 225 additions and 39 deletions
|
|
@ -19,6 +19,7 @@
|
|||
<action name="procFileAdminInsertModuleConfig" type="controller" ruleset="fileModuleConfig" />
|
||||
<action name="procFileAdminAddCart" type="controller" />
|
||||
<action name="procFileGetList" type="controller" />
|
||||
<action name="procFileSetCoverImage" type="controller" />
|
||||
</actions>
|
||||
<menus>
|
||||
<menu name="file">
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ class file extends ModuleObject
|
|||
// 2012. 08. 29 Add a trigger to copy additional setting when the module is copied
|
||||
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after')) return true;
|
||||
|
||||
if(!$oDB->isColumnExists('files', 'cover_image')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -139,6 +141,8 @@ class file extends ModuleObject
|
|||
$oModuleController->insertTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after');
|
||||
}
|
||||
|
||||
if(!$oDB->isColumnExists('files', 'cover_image')) $oDB->addColumn('files', 'cover_image', 'char', '1', 'N');
|
||||
|
||||
return new Object(0, 'success_updated');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -935,6 +935,68 @@ class fileController extends file
|
|||
}
|
||||
}
|
||||
|
||||
public function procFileSetCoverImage()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
$upload_target_srl = null;
|
||||
|
||||
$oFileModel = &getModel('file');
|
||||
$oDocumentModel = &getModel('document');
|
||||
$oCommentModel = &getModel('comment');
|
||||
|
||||
$file_info = $oFileModel->getFile($vars->file_srl);
|
||||
if(!$file_info) return new Object(-1, 'msg_not_founded');
|
||||
|
||||
$oDocument = $oDocumentModel->getDocument($file_info->upload_target_srl);
|
||||
if($oDocument->isExists())
|
||||
{
|
||||
if(!$oDocument->isGranted()) return new Object(-1, 'msg_not_permitted');
|
||||
|
||||
$upload_target_srl = $oDocument->document_srl;
|
||||
}
|
||||
else
|
||||
{
|
||||
$oComment = $oCommentModel->getComment($file_info->upload_target_srl);
|
||||
if($oDocument->isExists())
|
||||
{
|
||||
if(!$oComment->isGranted()) return new Object(-1, 'msg_not_permitted');
|
||||
|
||||
$upload_target_srl = $oComment->document_srl;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$upload_target_srl) return new Object(-1, 'msg_not_founded');
|
||||
|
||||
$args = new stdClass();
|
||||
$args->file_srl = $vars->file_srl;
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
|
||||
$oDB = &DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
$args->cover_image = 'N';
|
||||
$output = executeQuery('file.updateClearCoverImage', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$args->cover_image = 'Y';
|
||||
$output = executeQuery('file.updateCoverImage', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
// 썸네일 삭제
|
||||
$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($upload_target_srl, 3));
|
||||
Filehandler::removeFilesInDir($thumbnail_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the attachment where a key is upload_target_srl and then return java script code
|
||||
*
|
||||
|
|
@ -965,3 +1027,4 @@ class fileController extends file
|
|||
}
|
||||
/* End of file file.controller.php */
|
||||
/* Location: ./modules/file/file.controller.php */
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class fileModel extends file
|
|||
if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid, $file_info->module_srl);
|
||||
else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
|
||||
$obj->direct_download = $file_info->direct_download;
|
||||
$obj->cover_image = ($file_info->cover_image === 'Y') ? true : false;
|
||||
$files[] = $obj;
|
||||
$attached_size += $file_info->file_size;
|
||||
}
|
||||
|
|
|
|||
9
modules/file/queries/getCoverImage.xml
Normal file
9
modules/file/queries/getCoverImage.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<query id="getCoverImage" action="select">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="upload_target_srl" var="upload_target_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="equal" column="cover_image" default="Y" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
<column name="comment" var="comment" />
|
||||
<column name="download_count" var="download_count" default="0" />
|
||||
<column name="member_srl" var="member_srl" default="0" />
|
||||
<column name="cover_image" var="is_cover" default="N" />
|
||||
<column name="regdate" var="regdate" default="curdate()" />
|
||||
<column name="ipaddress" var="ipaddress" default="ipaddress()" />
|
||||
<column name="isvalid" var="isvalid" default="N" />
|
||||
|
|
|
|||
13
modules/file/queries/updateClearCoverImage.xml
Normal file
13
modules/file/queries/updateClearCoverImage.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<query id="updateClearCoverImage" action="update">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="cover_image" default="N" notnull="notnull" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="upload_target_srl" var="upload_target_srl" notnull="notnull" />
|
||||
<condition operation="equal" column="cover_image" default="Y" notnull="notnull" pipe="and" />
|
||||
<condition operation="notequal" column="file_srl" var="cover_file_srl" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
11
modules/file/queries/updateCoverImage.xml
Normal file
11
modules/file/queries/updateCoverImage.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="updateCoverImage" action="update">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="cover_image" var="cover_image" default="Y" notnull="notnull" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
<column name="upload_target_type" var="upload_target_type" />
|
||||
<column name="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
<column name="uploaded_filename" var="uploaded_filename" notnull="notnull" minlength="1" maxlength="250" />
|
||||
<column name="cover_image" var="is_cover" default="N" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="file_srl" var="file_srl" filter="number" notnull="notnull" />
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
<column name="file_size" type="number" size="11" default="0" notnull="notnull" index="idx_file_size" />
|
||||
<column name="comment" type="varchar" size="250" />
|
||||
<column name="isvalid" type="char" size="1" default="N" index="idx_is_valid" />
|
||||
<column name="cover_image" type="char" size="1" default="N" notnull="notnull" index="idx_list_order" />
|
||||
<column name="regdate" type="date" index="idx_regdate" />
|
||||
<column name="ipaddress" type="varchar" size="128" notnull="notnull" index="idx_ipaddress"/>
|
||||
</table>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue