mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
#77. 에디터에서 파일 업로드 행동을 하였을 경우에만 getNextSequence() 를 호출하도록 하여 DB 부하를 대폭 감소.
블로그 모듈의 기본 스킨들에서 댓글의 에디터도 위지윅 에디터로 대체하였음.
기본 board모듈의 스킨은 filter/insert.xml에서 document_srl을 제거해야 함.
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@2572 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
86670c07c5
commit
9a9e86f1fa
58 changed files with 857 additions and 620 deletions
|
|
@ -11,13 +11,30 @@
|
|||
|
||||
/**
|
||||
* @brief 에디터를 return
|
||||
*
|
||||
* 에디터의 경우 내부적으로 1~30까지의 임시 editor_seuqnece를 생성한다.
|
||||
* 즉 한페이지에 30개 이상의 에디터를 출력하지는 못하도록 제한되어 있다.
|
||||
*
|
||||
* 단, 수정하는 경우 또는 파일업로드를 한 자동저장본의 경우는 getNextSequence() 값으로 저장된 editor_seqnece가
|
||||
* 설정된다.
|
||||
*
|
||||
* editor_sequence <= 30 일경우에는 무조건 가상의 번호로 판별함
|
||||
**/
|
||||
function getEditor($upload_target_srl, $option = null) {
|
||||
|
||||
/**
|
||||
* 에디터 template을 return
|
||||
* upload_target_srl은 글의 수정시 호출하면 됨.
|
||||
* 이 upload_target_srl은 첨부파일의 유무를 체크하기 위한 루틴을 구현하는데 사용됨.
|
||||
**/
|
||||
function getEditor($upload_target_srl = 0, $option = null) {
|
||||
/**
|
||||
* 기본적인 에디터의 옵션을 정리
|
||||
**/
|
||||
// 파일 업로드 유무 옵션 설정
|
||||
if(!$option->allow_fileupload) $allow_fileupload = false;
|
||||
else $allow_fileupload = true;
|
||||
|
||||
// 자동 저장 유무 옵션 설정
|
||||
// 자동 저장 유무 옵션 설정
|
||||
if(!$option->enable_autosave) $enable_autosave = false;
|
||||
else $enable_autosave = true;
|
||||
|
||||
|
|
@ -41,35 +58,66 @@
|
|||
if(!$option->skin) $skin = 'default';
|
||||
else $skin = $option->skin;
|
||||
|
||||
// 대상 문서 번호 설정
|
||||
Context::set('upload_target_srl', $upload_target_srl);
|
||||
/**
|
||||
* 자동백업 기능 체크 (글 수정일 경우는 사용하지 않음)
|
||||
**/
|
||||
if(!$upload_target_srl && $enable_autosave) {
|
||||
// 자동 저장된 데이터를 추출
|
||||
$saved_doc = $this->getSavedDoc();
|
||||
|
||||
// 업로드 가능 변수 설정
|
||||
if($allow_fileupload) {
|
||||
// 첨부파일 모듈의 정보를 구함
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->member_srl && $logged_info->is_admin == 'Y') {
|
||||
$file_config->allowed_filesize = 1024*1024*1024;
|
||||
$file_config->allowed_attach_size = 1024*1024*1024;
|
||||
$file_config->allowed_filetypes = '*.*';
|
||||
} else {
|
||||
$oModuleModel = &getModel('module');
|
||||
$file_config = $oModuleModel->getModuleConfig('file');
|
||||
$file_config->allowed_filesize = $file_config->allowed_filesize * 1024;
|
||||
$file_config->allowed_attach_size = $file_config->allowed_attach_size * 1024;
|
||||
}
|
||||
Context::set('file_config',$file_config);
|
||||
}
|
||||
Context::set('allow_fileupload', $allow_fileupload);
|
||||
// 자동저장된 데이터에 실제하는 문서 번호가 있다면 해당 문서 번호를 세팅
|
||||
if($saved_doc->document_srl) $upload_target_srl = $saved_doc->upload_target_srl;
|
||||
|
||||
// 자동백업 기능 체크
|
||||
if($enable_autosave) {
|
||||
$saved_doc = $this->getSavedDoc($upload_target_srl);
|
||||
// 자동 저장 데이터를 context setting
|
||||
Context::set('saved_doc', $saved_doc);
|
||||
}
|
||||
Context::set('enable_autosave', $enable_autosave);
|
||||
|
||||
// 에디터 컴포넌트 체크
|
||||
/**
|
||||
* 에디터의 고유 번호 추출 (한 페이지에 여러개의 에디터를 출력하는 경우를 대비)
|
||||
**/
|
||||
if($option->editor_sequence) $editor_sequence = $option->editor_sequence;
|
||||
else {
|
||||
if(!$GLOBALS['_editor_sequence_']) $GLOBALS['_editor_sequence_'] = 1;
|
||||
$editor_sequence = $GLOBALS['_editor_sequence_'] ++;
|
||||
}
|
||||
|
||||
/**
|
||||
* 업로드 활성화시 내부적으로 file 모듈의 환경설정을 이용하여 설정
|
||||
**/
|
||||
if($allow_fileupload) {
|
||||
$oFileModel = &getModel('file');
|
||||
|
||||
// SWFUploader에 세팅할 업로드 설정 구함
|
||||
$file_config = $oFileModel->getUploadConfig();
|
||||
Context::set('file_config',$file_config);
|
||||
|
||||
// 업로드 가능 용량등에 대한 정보를 세팅
|
||||
$upload_status = $oFileModel->getUploadStatus();
|
||||
Context::set('upload_status', $upload_status);
|
||||
|
||||
// upload가능하다고 설정 (내부적으로 캐싱하여 처리)
|
||||
$oFileController = &getController('file');
|
||||
$oFileController->setUploadInfo($editor_sequence, $upload_target_srl);
|
||||
}
|
||||
Context::set('allow_fileupload', $allow_fileupload);
|
||||
|
||||
// 에디터 동작을 위한 editor_sequence값 설정
|
||||
Context::set('editor_sequence', $editor_sequence);
|
||||
|
||||
// 파일 첨부 관련 행동을 하기 위해 문서 번호를 upload_target_srl로 설정
|
||||
// 신규문서일 경우 upload_target_srl=0 이고 첨부파일 관련 동작이 요청될때 이 값이 변경됨
|
||||
Context::set('upload_target_srl', $upload_target_srl);
|
||||
|
||||
// 문서 혹은 댓글의 primary key값을 세팅한다.
|
||||
Context::set('editor_primary_key_name', $option->primary_key_name);
|
||||
|
||||
// 내용을 sync 맞추기 위한 content column name을 세팅한다
|
||||
Context::set('editor_content_key_name', $option->content_key_name);
|
||||
|
||||
/**
|
||||
* 에디터 컴포넌트 체크
|
||||
**/
|
||||
if($enable_component) {
|
||||
if(!Context::get('component_list')) {
|
||||
$component_list = $this->getComponentList();
|
||||
|
|
@ -79,24 +127,24 @@
|
|||
Context::set('enable_component', $enable_component);
|
||||
Context::set('enable_default_component', $enable_default_component);
|
||||
|
||||
// resizable 가능한지 변수 설정
|
||||
/**
|
||||
* resizable 가능한지 변수 설정
|
||||
**/
|
||||
Context::set('enable_resizable', $resizable);
|
||||
|
||||
// 에디터 크기 설정
|
||||
/**
|
||||
* 에디터 세로 크기 설정
|
||||
**/
|
||||
Context::set('editor_height', $editor_height);
|
||||
|
||||
// 템플릿을 미리 컴파일해서 컴파일된 소스를 return
|
||||
/**
|
||||
* 템플릿을 미리 컴파일해서 컴파일된 소스를 하기 위해 스킨의 경로를 설정
|
||||
**/
|
||||
$tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin);
|
||||
$tpl_file = 'editor.html';
|
||||
|
||||
// editor_path를 지정
|
||||
Context::set('editor_path', $tpl_path);
|
||||
|
||||
// 만약 allow_fileupload == true 이면 upload_target_srl에 upload가능하다고 설정
|
||||
if($allow_fileupload) {
|
||||
$oFileController = &getController('file');
|
||||
$oFileController->setUploadEnable($upload_target_srl);
|
||||
}
|
||||
// tpl 파일을 compile한 결과를 return
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
|
|
@ -104,7 +152,7 @@
|
|||
/**
|
||||
* @brief 자동저장되어 있는 정보를 가져옴
|
||||
**/
|
||||
function getSavedDoc($upload_target_srl) {
|
||||
function getSavedDoc() {
|
||||
// 로그인 회원이면 member_srl, 아니면 ipaddress로 저장되어 있는 문서를 찾음
|
||||
if(Context::get('is_logged')) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
|
@ -113,17 +161,19 @@
|
|||
$auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
// DB에서 자동저장 데이터 추출
|
||||
$output = executeQuery('editor.getSavedDocument', $auto_save_args);
|
||||
$saved_doc = $output->data;
|
||||
|
||||
// 자동저장한 결과가 없으면 null값 return
|
||||
if(!$saved_doc) return;
|
||||
|
||||
// 원본 글이 저장되어 있지 않은 글일 경우 첨부된 파일이 있으면 현재 글 번호로 옮김
|
||||
$oDocumentModel = &getModel('document');
|
||||
$document = $oDocumentModel->getDocument($saved_doc->document_srl);
|
||||
if($document->document_srl != $saved_doc->document_srl) {
|
||||
// 자동저장 데이터에 문서번호가 있고 이 번호에 파일이 있다면 파일을 모두 이동하고
|
||||
// 해당 문서 번호를 editor_sequence로 세팅함
|
||||
if($saved_doc->document_srl) {
|
||||
$module_srl = Context::get('module_srl');
|
||||
$oFileController = &getController('file');
|
||||
$oFileController->moveFile($saved_doc->document_srl, $module_srl, $upload_target_srl);
|
||||
$oFileController->moveFile($saved_doc->document_srl, $module_srl, $saved_doc->document_srl);
|
||||
}
|
||||
|
||||
return $saved_doc;
|
||||
|
|
@ -132,8 +182,8 @@
|
|||
/**
|
||||
* @brief component의 객체 생성
|
||||
**/
|
||||
function getComponentObject($component, $upload_target_srl = 0) {
|
||||
if(!$this->loaded_component_list[$component][$upload_target_srl]) {
|
||||
function getComponentObject($component, $editor_sequence = 0) {
|
||||
if(!$this->loaded_component_list[$component][$editor_sequence]) {
|
||||
// 해당 컴포넌트의 객체를 생성해서 실행
|
||||
$class_path = sprintf('%scomponents/%s/', $this->module_path, $component);
|
||||
$class_file = sprintf('%s%s.class.php', $class_path, $component);
|
||||
|
|
@ -141,17 +191,17 @@
|
|||
|
||||
// 클래스 파일을 읽은 후 객체 생성
|
||||
require_once($class_file);
|
||||
$eval_str = sprintf('$oComponent = new %s("%s","%s");', $component, $upload_target_srl, $class_path);
|
||||
$eval_str = sprintf('$oComponent = new %s("%s","%s");', $component, $editor_sequence, $class_path);
|
||||
@eval($eval_str);
|
||||
if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
|
||||
|
||||
// 설정 정보를 추가
|
||||
$component_info = $this->getComponent($component);
|
||||
$oComponent->setInfo($component_info);
|
||||
$this->loaded_component_list[$component][$upload_target_srl] = $oComponent;
|
||||
$this->loaded_component_list[$component][$editor_sequence] = $oComponent;
|
||||
}
|
||||
|
||||
return $this->loaded_component_list[$component][$upload_target_srl];
|
||||
return $this->loaded_component_list[$component][$editor_sequence];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue