mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +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
|
|
@ -10,8 +10,7 @@
|
|||
border: 1px solid #d7d8d8;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* dropzone */
|
||||
/* dropzone */
|
||||
.xefu-dropzone {
|
||||
padding: 12px;
|
||||
border: 1px solid #fafafa;
|
||||
|
|
@ -70,12 +69,42 @@
|
|||
height: 60px;
|
||||
border: 3px solid #DDD;
|
||||
}
|
||||
.xefu-list-images input,
|
||||
.xefu-list-images button {
|
||||
.xefu-list-images input {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.xefu-act-set-cover:hover {
|
||||
color: red;
|
||||
}
|
||||
.xefu-list-images .xefu-act-set-cover {
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: auto;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
padding: 1px 0 1px 2px;
|
||||
border-radius: 0 0 0 5px;
|
||||
font-size: 15px;
|
||||
line-height: 15px;
|
||||
background-color: #6cbd7e;
|
||||
}
|
||||
.xefu-list-images li:hover .xefu-act-set-cover {
|
||||
display: inline;
|
||||
color: #666;
|
||||
background-color: #ddd;
|
||||
}
|
||||
.xefu-list-images .xefu-is-cover-image:hover .xefu-act-set-cover,
|
||||
.xefu-is-cover-image .xefu-act-set-cover {
|
||||
display: inline;
|
||||
color: #fff;
|
||||
background-color: #6cbd7e;
|
||||
}
|
||||
.xefu-is-cover-image {
|
||||
border-color: #6cbd7e !important;
|
||||
}
|
||||
.xefu-list-images .xefu-file-name,
|
||||
.xefu-list-images .xefu-file-size {
|
||||
display: none;
|
||||
|
|
@ -87,7 +116,6 @@
|
|||
|
||||
|
||||
.selected {
|
||||
border-color: #6CBD7E !important;
|
||||
}
|
||||
/* END:images */
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@
|
|||
actSelectedInsertContent : '.xefu-act-link-selected',
|
||||
actSelectedDeleteFile : '.xefu-act-delete-selected',
|
||||
actDeleteFile : '.xefu-act-delete',
|
||||
actSetCover : '.xefu-act-set-cover',
|
||||
|
||||
tmplXeUploaderFileitem : '<li class="xefu-file xe-clearfix" data-file-srl="{{file_srl}}"><span class="xefu-file-name">{{source_filename}}</span><span class="xefu-file-info"><span>{{disp_file_size}}</span><span><input type="checkbox" data-file-srl="{{file_srl}}"> 선택</span></span></li>',
|
||||
tmplXeUploaderFileitemImage: '<li class="xefu-file xefu-file-image" data-file-srl="{{file_srl}}"><strong class="xefu-file-name">{{source_filename}}</strong><span class="xefu-file-info"><span class="xefu-file-size">{{disp_file_size}}</span><span><img src="{{download_url}}" alt=""></span><span><input type="checkbox" data-file-srl="{{file_srl}}"></span></span></li>'
|
||||
tmplXeUploaderFileitemImage: '<li class="xefu-file xefu-file-image {{#if cover_image}}xefu-is-cover-image{{/if}}" data-file-srl="{{file_srl}}"><strong class="xefu-file-name">{{source_filename}}</strong><span class="xefu-file-info"><span class="xefu-file-size">{{disp_file_size}}</span><span><img src="{{download_url}}" alt=""></span><span><input type="checkbox" data-file-srl="{{file_srl}}"></span><button class="xefu-act-set-cover" data-file-srl="{{file_srl}}" title="커버이미지로 선택"><i class="xi-check-circle"></i></button></span></li>'
|
||||
};
|
||||
|
||||
var _elements = [
|
||||
|
|
@ -30,6 +31,7 @@
|
|||
'actSelectedInsertContent',
|
||||
'actSelectedDeleteFile',
|
||||
'actDeleteFile',
|
||||
'actSetCover',
|
||||
'controll',
|
||||
'dropZone',
|
||||
'filelist',
|
||||
|
|
@ -150,7 +152,6 @@
|
|||
|
||||
// finderSelect
|
||||
var fileselect = data.settings.fileList.finderSelect({children:"li", enableDesktopCtrlDefault:true});
|
||||
console.log(data.settings.fileList);
|
||||
data.settings.fileList.on("mousedown", 'img', function(e){ e.preventDefault(); });
|
||||
|
||||
fileselect.finderSelect('addHook','highlight:after', function(el) {
|
||||
|
|
@ -169,6 +170,11 @@
|
|||
e.preventDefault();
|
||||
});
|
||||
|
||||
fileselect.on("click", ".xefu-act-set-cover", function(e){
|
||||
e.preventDefault();
|
||||
self.setCover($container, e.currentTarget);
|
||||
});
|
||||
|
||||
|
||||
$(document).bind('dragover', function (e) {
|
||||
var timeout = window.dropZoneTimeout,
|
||||
|
|
@ -273,7 +279,7 @@
|
|||
/**
|
||||
* 파일 목록 갱신
|
||||
*/
|
||||
loadFilelist: function($container) {
|
||||
loadFilelist: function($container) {
|
||||
var self = this;
|
||||
var data = $container.data();
|
||||
var obj = {};
|
||||
|
|
@ -281,6 +287,7 @@
|
|||
obj.editor_sequence = data.editorSequence;
|
||||
|
||||
$.exec_json('file.getFileList', obj, function(res){
|
||||
console.log(res);
|
||||
data.uploadTargetSrl = res.upload_target_srl;
|
||||
editorRelKeys[data.editorSequence].primary.value = res.upload_target_srl;
|
||||
data.uploadTargetSrl = res.uploadTargetSrl;
|
||||
|
|
@ -330,6 +337,21 @@
|
|||
data.settings.controll.show()
|
||||
data.settings.fileList.show();
|
||||
});
|
||||
},
|
||||
setCover: function($container, selected_el) {
|
||||
var data = $container.data();
|
||||
var $el = $(selected_el);
|
||||
var file_srl = $el.data().fileSrl;
|
||||
|
||||
exec_json('file.procFileSetCoverImage', {'file_srl': file_srl}, function(res) {
|
||||
if(res.error != 0) return;
|
||||
|
||||
data.settings.filelistImages.find('li').removeClass('xefu-is-cover-image');
|
||||
|
||||
var $parentLi = $el.closest('li');
|
||||
$parentLi.addClass('xefu-is-cover-image');
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -543,6 +543,11 @@ class commentItem extends Object
|
|||
return;
|
||||
}
|
||||
|
||||
if($this->isSecret() && !$this->isGranted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If signiture height setting is omitted, create a square
|
||||
if(!$height)
|
||||
{
|
||||
|
|
@ -587,30 +592,33 @@ class commentItem extends Object
|
|||
if($this->hasUploadedFiles())
|
||||
{
|
||||
$file_list = $this->getUploadedFiles();
|
||||
if(count($file_list))
|
||||
{
|
||||
foreach($file_list as $file)
|
||||
{
|
||||
if($file->direct_download != 'Y')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i", $file->source_filename))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$first_image = null;
|
||||
foreach($file_list as $file)
|
||||
{
|
||||
if($file->direct_download !== 'Y') continue;
|
||||
|
||||
if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
|
||||
{
|
||||
$source_file = $file->uploaded_filename;
|
||||
if(!file_exists($source_file))
|
||||
break;
|
||||
}
|
||||
|
||||
if($first_image) continue;
|
||||
|
||||
if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
|
||||
{
|
||||
if(file_exists($file->uploaded_filename))
|
||||
{
|
||||
$source_file = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
$first_image = $file->uploaded_filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$source_file && $first_image)
|
||||
{
|
||||
$source_file = $first_image;
|
||||
}
|
||||
}
|
||||
|
||||
// get an image file from the doc content if no file attached.
|
||||
|
|
|
|||
|
|
@ -773,6 +773,12 @@ class documentItem extends Object
|
|||
{
|
||||
// Return false if the document doesn't exist
|
||||
if(!$this->document_srl) return;
|
||||
|
||||
if($this->isSecret() && !$this->isGranted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If not specify its height, create a square
|
||||
if(!$height) $height = $width;
|
||||
// Return false if neither attachement nor image files in the document
|
||||
|
|
@ -799,27 +805,44 @@ class documentItem extends Object
|
|||
if(filesize($thumbnail_file)<1) return false;
|
||||
else return $thumbnail_url;
|
||||
}
|
||||
|
||||
// Target File
|
||||
$source_file = null;
|
||||
$is_tmp_file = false;
|
||||
// Find an iamge file among attached files if exists
|
||||
if($this->get('uploaded_count'))
|
||||
{
|
||||
$oFileModel = getModel('file');
|
||||
$file_list = $oFileModel->getFiles($this->document_srl, array(), 'file_srl', true);
|
||||
if(count($file_list))
|
||||
{
|
||||
foreach($file_list as $file)
|
||||
{
|
||||
if($file->direct_download!='Y') continue;
|
||||
if(!preg_match("/\.(jpg|png|jpeg|gif|bmp)$/i",$file->source_filename)) continue;
|
||||
|
||||
// Find an iamge file among attached files if exists
|
||||
if($this->hasUploadedFiles())
|
||||
{
|
||||
$file_list = $this->getUploadedFiles();
|
||||
|
||||
$first_image = null;
|
||||
foreach($file_list as $file)
|
||||
{
|
||||
if($file->direct_download !== 'Y') continue;
|
||||
|
||||
if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
|
||||
{
|
||||
$source_file = $file->uploaded_filename;
|
||||
if(!file_exists($source_file)) $source_file = null;
|
||||
else break;
|
||||
break;
|
||||
}
|
||||
|
||||
if($first_image) continue;
|
||||
|
||||
if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
|
||||
{
|
||||
if(file_exists($file->uploaded_filename))
|
||||
{
|
||||
$first_image = $file->uploaded_filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$source_file && $first_image)
|
||||
{
|
||||
$source_file = $first_image;
|
||||
}
|
||||
}
|
||||
|
||||
// If not exists, file an image file from the content
|
||||
if(!$source_file)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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