git-svn-id: http://xe-core.googlecode.com/svn/trunk@126 201d5d3c-b55e-5fd7-737f-ddc643e51545

This commit is contained in:
zero 2007-02-20 07:41:44 +00:00
parent ee2a89b7ce
commit e7d5dd84e8
27 changed files with 395 additions and 279 deletions

View file

@ -48,6 +48,7 @@
// 모듈 정보에서 module 이름을 구해움 // 모듈 정보에서 module 이름을 구해움
$module = $module_info->module; $module = $module_info->module;
$mid = $module_info->mid;
} }
// 만약 모듈이 없다면 잘못된 모듈 호출에 대한 오류를 message 모듈을 통해 호출 // 만약 모듈이 없다면 잘못된 모듈 호출에 대한 오류를 message 모듈을 통해 호출
@ -68,6 +69,7 @@
// act값을 Context에 세팅 // act값을 Context에 세팅
Context::set('act', $act, true); Context::set('act', $act, true);
Context::set('mid', $mid, true);
// 모듈 객체 생성 // 모듈 객체 생성
$oModule = &$this->getModuleInstance($module, $type); $oModule = &$this->getModuleInstance($module, $type);
@ -77,6 +79,7 @@
if(!is_object($oModule)) return; if(!is_object($oModule)) return;
$act = Context::get('act');
$oModule->proc($act); $oModule->proc($act);
$this->oModule = $oModule; $this->oModule = $oModule;

View file

@ -230,7 +230,6 @@ function XmlJsFilterProc(confirm_msg) {
var response = this.response; var response = this.response;
if(confirm_msg && !confirm(confirm_msg)) return false; if(confirm_msg && !confirm(confirm_msg)) return false;
if(!this.act) { if(!this.act) {
this.user_func(this.fo_obj, params); this.user_func(this.fo_obj, params);
return true; return true;

View file

@ -19,7 +19,16 @@
* @brief debug mode = true 일때 files/_debug_message.php 디버그 내용이 쌓임 * @brief debug mode = true 일때 files/_debug_message.php 디버그 내용이 쌓임
**/ **/
define('__DEBUG__', true); define('__DEBUG__', true);
if(__DEBUG__) define('__StartTime__', getMicroTime()); if(__DEBUG__) {
// php5이상이면 error handling을 handleError() 로 set
if (version_compare(phpversion(), '5.0') > 0) {
set_error_handler("handleError");
}
// 여기서부터 시작 시간으로 설정
define('__StartTime__', getMicroTime());
}
/** /**
* @brief 세션 설정 * @brief 세션 설정

View file

@ -142,4 +142,22 @@
return $var; return $var;
} }
/**
* @brief php5 이상에서 error_handing을 debugPrint로 변경
* @param errno
* @param errstr
* @return file
* @return line
**/
function handleError($errno, $errstr, $file, $line) {
if(!__DEBUG__) return;
$errors = array(E_USER_ERROR, E_ERROR, E_PARSE);
if(!in_array($errno,$errors)) return;
$output = sprintf("Fatal error : %s - %d", $file, $line);
$output .= sprintf("%d - %s", $errno, $errstr);
debugPrint($output);
}
?> ?>

View file

@ -5,20 +5,20 @@
var iframe_id = 'editor_iframe_'; var iframe_id = 'editor_iframe_';
// srl값에 해당하는 iframe의 object를 return // srl값에 해당하는 iframe의 object를 return
function editorGetIFrame(document_srl) {/*{{{*/ function editorGetIFrame(document_srl) {
var obj_id = iframe_id+document_srl; var obj_id = iframe_id+document_srl;
return xGetElementById(obj_id); return xGetElementById(obj_id);
}/*}}}*/ }
// editor 초기화를 onload이벤트 후에 시작시킴 // editor 초기화를 onload이벤트 후에 시작시킴
function editorInit(document_srl) {/*{{{*/ function editorInit(document_srl) {
var start_func = function _editorStart() { editorStart(document_srl); } var start_func = function _editorStart() { editorStart(document_srl); }
var init_func = function _editorInit() { setTimeout(start_func, 300); } var init_func = function _editorInit() { setTimeout(start_func, 300); }
xAddEventListener(window, 'load', init_func); xAddEventListener(window, 'load', init_func);
}/*}}}*/ }
// editor 초기화 (document_srl로 iframe객체를 얻어서 쓰기 모드로 전환) // editor 초기화 (document_srl로 iframe객체를 얻어서 쓰기 모드로 전환)
function editorStart(document_srl) {/*{{{*/ function editorStart(document_srl) {
// iframe obj를 찾음 // iframe obj를 찾음
var iframe_obj = editorGetIFrame(document_srl); var iframe_obj = editorGetIFrame(document_srl);
if(!iframe_obj) return; if(!iframe_obj) return;
@ -82,14 +82,14 @@ function editorStart(document_srl) {/*{{{*/
// 에디터의 내용을 지속적으로 fo_obj.content.value에 입력 // 에디터의 내용을 지속적으로 fo_obj.content.value에 입력
editorSyncContent(fo_obj.content, document_srl); editorSyncContent(fo_obj.content, document_srl);
}/*}}}*/ }
var _editorSyncList = new Array(); /*{{{*/ var _editorSyncList = new Array();
function editorSyncContent(obj, document_srl) { function editorSyncContent(obj, document_srl) {
_editorSyncList[_editorSyncList.length] = {field:obj, document_srl:document_srl} _editorSyncList[_editorSyncList.length] = {field:obj, document_srl:document_srl}
}/*}}}*/ }
function _editorSync() {/*{{{*/ function _editorSync() {
for(var i=0;i<_editorSyncList.length;i++) { for(var i=0;i<_editorSyncList.length;i++) {
var field = _editorSyncList[i].field; var field = _editorSyncList[i].field;
var document_srl = _editorSyncList[i].document_srl; var document_srl = _editorSyncList[i].document_srl;
@ -98,26 +98,26 @@ function _editorSync() {/*{{{*/
field.value = content; field.value = content;
} }
setTimeout(_editorSync, 1000); setTimeout(_editorSync, 1000);
}/*}}}*/ }
xAddEventListener(window, 'load', _editorSync); xAddEventListener(window, 'load', _editorSync);
// 문단기능 toggle // 문단기능 toggle
function editorUseParagraph(obj, document_srl) { /*{{{*/ function editorUseParagraph(obj, document_srl) {
toggleDisplay('editor_paragraph_'+document_srl); toggleDisplay('editor_paragraph_'+document_srl);
}/*}}}*/ }
// 에디터의 내용 return // 에디터의 내용 return
function editorGetContent(document_srl) {/*{{{*/ function editorGetContent(document_srl) {
var iframe_obj = editorGetIFrame(document_srl); var iframe_obj = editorGetIFrame(document_srl);
if(!iframe_obj) return; if(!iframe_obj) return;
var html = ''; var html = '';
html = xInnerHtml(iframe_obj.contentWindow.document.body); html = xInnerHtml(iframe_obj.contentWindow.document.body);
if(!html) return; if(!html) return;
return html.trim(); return html.trim();
}/*}}}*/ }
// 에디터 내의 선택된 부분의 html 코드를 return // 에디터 내의 선택된 부분의 html 코드를 return
function editorGetSelectedHtml(document_srl) {/*{{{*/ function editorGetSelectedHtml(document_srl) {
var iframe_obj = editorGetIFrame(document_srl); var iframe_obj = editorGetIFrame(document_srl);
if(xIE4Up) { if(xIE4Up) {
var range = iframe_obj.contentWindow.document.selection.createRange(); var range = iframe_obj.contentWindow.document.selection.createRange();
@ -131,10 +131,10 @@ function editorGetSelectedHtml(document_srl) {/*{{{*/
var html = xInnerHtml(dummy); var html = xInnerHtml(dummy);
return html; return html;
} }
}/*}}}*/ }
// 에디터 내의 선택된 부분의 html코드를 변경 // 에디터 내의 선택된 부분의 html코드를 변경
function editorReplaceHTML(iframe_obj, html) {/*{{{*/ function editorReplaceHTML(iframe_obj, html) {
iframe_obj.contentWindow.focus(); iframe_obj.contentWindow.focus();
if(xIE4Up) { if(xIE4Up) {
var range = iframe_obj.contentWindow.document.selection.createRange(); var range = iframe_obj.contentWindow.document.selection.createRange();
@ -144,10 +144,10 @@ function editorReplaceHTML(iframe_obj, html) {/*{{{*/
range.deleteContents(); range.deleteContents();
range.insertNode(range.createContextualFragment(html)); range.insertNode(range.createContextualFragment(html));
} }
}/*}}}*/ }
// 입력 키에 대한 이벤트 체크 // 입력 키에 대한 이벤트 체크
function editorKeyPress(evt) {/*{{{*/ function editorKeyPress(evt) {
var e = new xEvent(evt); var e = new xEvent(evt);
if (e.keyCode == 13) { if (e.keyCode == 13) {
if(xIE4Up && e.shiftKey == false && !xGetElementById("use_paragraph").checked ) { if(xIE4Up && e.shiftKey == false && !xGetElementById("use_paragraph").checked ) {
@ -186,10 +186,10 @@ function editorKeyPress(evt) {/*{{{*/
break; break;
} }
} }
}/*}}}*/ }
// 에디터 상단의 버튼 클릭시 action 처리 // 에디터 상단의 버튼 클릭시 action 처리
var editorPrevObj = null;/*{{{*/ var editorPrevObj = null;
var editorPrevSrl = null; var editorPrevSrl = null;
function editorEventCheck(evt) { function editorEventCheck(evt) {
var e = new xEvent(evt); var e = new xEvent(evt);
@ -269,38 +269,38 @@ function editorEventCheck(evt) {
} }
} }
return; return;
}/*}}}*/ }
// focus // focus
function editorFocus(document_srl) {/*{{{*/ function editorFocus(document_srl) {
var iframe_obj = editorGetIFrame(document_srl); var iframe_obj = editorGetIFrame(document_srl);
iframe_obj.contentWindow.focus(); iframe_obj.contentWindow.focus();
} }
/*}}}*/
// 편집 기능 실행 // 편집 기능 실행
function editorDo(name, value, target) {/*{{{*/ function editorDo(name, value, target) {
if(typeof(target)=='object') _editorDoObject(name, value, target); if(typeof(target)=='object') _editorDoObject(name, value, target);
else _editorDoSrl(name, value, target); else _editorDoSrl(name, value, target);
}/*}}}*/ }
function _editorDoSrl(name, value, document_srl) {/*{{{*/ function _editorDoSrl(name, value, document_srl) {
var iframe_obj = editorGetIFrame(document_srl); var iframe_obj = editorGetIFrame(document_srl);
editorFocus(document_srl); editorFocus(document_srl);
if(xIE4Up) iframe_obj.contentWindow.document.execCommand(name, false, value); if(xIE4Up) iframe_obj.contentWindow.document.execCommand(name, false, value);
else iframe_obj.contentWindow.document.execCommand(name, false, value); else iframe_obj.contentWindow.document.execCommand(name, false, value);
editorFocus(document_srl); editorFocus(document_srl);
}/*}}}*/ }
function _editorDoObject(name, value, obj) {/*{{{*/ function _editorDoObject(name, value, obj) {
if(xIE4Up) { if(xIE4Up) {
obj.parentElement.document.execCommand(name, false, value); obj.parentElement.document.execCommand(name, false, value);
} else { } else {
obj.parentNode.execCommand(name, false, value); obj.parentNode.execCommand(name, false, value);
} }
}/*}}}*/ }
function editorHideObject(evt) {/*{{{*/ function editorHideObject(evt) {
if(!editorPrevObj) return; if(!editorPrevObj) return;
var e = new xEvent(evt); var e = new xEvent(evt);
var tobj = e.target; var tobj = e.target;
@ -313,47 +313,47 @@ function editorHideObject(evt) {/*{{{*/
editorPrevObj.style.visibility = 'hidden'; editorPrevObj.style.visibility = 'hidden';
editorPrevObj = null; editorPrevObj = null;
return; return;
}/*}}}*/ }
function editorChangeFontName(obj,srl) {/*{{{*/ function editorChangeFontName(obj,srl) {
var value = obj.options[obj.selectedIndex].value; var value = obj.options[obj.selectedIndex].value;
if(!value) return; if(!value) return;
editorDo('FontName',value,srl); editorDo('FontName',value,srl);
obj.selectedIndex = 0; obj.selectedIndex = 0;
}/*}}}*/ }
function editorChangeFontSize(obj,srl) {/*{{{*/ function editorChangeFontSize(obj,srl) {
var value = obj.options[obj.selectedIndex].value; var value = obj.options[obj.selectedIndex].value;
if(!value) return; if(!value) return;
editorDo('FontSize',value,srl); editorDo('FontSize',value,srl);
obj.selectedIndex = 0; obj.selectedIndex = 0;
}/*}}}*/ }
function editorSetForeColor(color_code) {/*{{{*/ function editorSetForeColor(color_code) {
editorDo("ForeColor",color_code,editorPrevSrl); editorDo("ForeColor",color_code,editorPrevSrl);
editorPrevObj.style.visibility = 'hidden'; editorPrevObj.style.visibility = 'hidden';
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
}/*}}}*/ }
function editorSetBackColor(color_code) {/*{{{*/ function editorSetBackColor(color_code) {
if(xIE4Up) editorDo("BackColor",color_code,editorPrevSrl); if(xIE4Up) editorDo("BackColor",color_code,editorPrevSrl);
else editorDo("hilitecolor",color_code,editorPrevSrl); else editorDo("hilitecolor",color_code,editorPrevSrl);
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
}/*}}}*/ }
function editorInsertEmoticon(obj) {/*{{{*/ function editorInsertEmoticon(obj) {
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
editorDo("InsertImage",obj.src,editorPrevSrl); editorDo("InsertImage",obj.src,editorPrevSrl);
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
}/*}}}*/ }
function editorDoInsertUrl(link, document_srl) {/*{{{*/ function editorDoInsertUrl(link, document_srl) {
editorFocus(document_srl); editorFocus(document_srl);
var iframe_obj = editorGetIFrame(srl); var iframe_obj = editorGetIFrame(srl);
editorReplaceHTML(iframe_obj, link); editorReplaceHTML(iframe_obj, link);
}/*}}}*/ }
function editorInsertUrl(text, url, link_type) {/*{{{*/ function editorInsertUrl(text, url, link_type) {
if(!text || !url) return; if(!text || !url) return;
//if(!/^(http|ftp)/i.test(url)) url = 'http://'+url; //if(!/^(http|ftp)/i.test(url)) url = 'http://'+url;
@ -364,9 +364,9 @@ function editorInsertUrl(text, url, link_type) {/*{{{*/
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
var obj = editorGetIFrame(editorPrevSrl) var obj = editorGetIFrame(editorPrevSrl)
editorReplaceHTML(obj, link); editorReplaceHTML(obj, link);
}/*}}}*/ }
function editorInsertImage(url, src_align) {/*{{{*/ function editorInsertImage(url, src_align) {
if(!url) return; if(!url) return;
//if(!/^(http|ftp)/i.test(url)) url = 'http://'+url; //if(!/^(http|ftp)/i.test(url)) url = 'http://'+url;
@ -377,9 +377,9 @@ function editorInsertImage(url, src_align) {/*{{{*/
html += " />"; html += " />";
var obj = editorGetIFrame(editorPrevSrl); var obj = editorGetIFrame(editorPrevSrl);
editorReplaceHTML(obj, html); editorReplaceHTML(obj, html);
}/*}}}*/ }
function editorGetMultimediaHtml(url, width, height, source_filename) {/*{{{*/ function editorGetMultimediaHtml(url, width, height, source_filename) {
if(typeof(width)=='undefined'||!width) width = 540; if(typeof(width)=='undefined'||!width) width = 540;
if(typeof(height)=='undefined'||!height) height= 420; if(typeof(height)=='undefined'||!height) height= 420;
@ -396,9 +396,9 @@ function editorGetMultimediaHtml(url, width, height, source_filename) {/*{{{*/
} }
var html = "<embed src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" autostart=\"0\" type=\""+type+"\" pluginspage=\""+pluginspace+"\"></embed><BR />"; var html = "<embed src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" autostart=\"0\" type=\""+type+"\" pluginspage=\""+pluginspace+"\"></embed><BR />";
return html; return html;
}/*}}}*/ }
function editorInsertMultimedia(url, width, height) {/*{{{*/ function editorInsertMultimedia(url, width, height) {
if(url) { if(url) {
var html = editorGetMultimediaHtml(url, width, height); var html = editorGetMultimediaHtml(url, width, height);
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
@ -406,18 +406,18 @@ function editorInsertMultimedia(url, width, height) {/*{{{*/
editorReplaceHTML(obj, html); editorReplaceHTML(obj, html);
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
} }
}/*}}}*/ }
function editorInsertHTML(html) {/*{{{*/ function editorInsertHTML(html) {
if(!html) return; if(!html) return;
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
var obj = editorGetIFrame(editorPrevSrl) var obj = editorGetIFrame(editorPrevSrl)
editorReplaceHTML(obj, html); editorReplaceHTML(obj, html);
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
}/*}}}*/ }
function editorInsertQuotation(html) {/*{{{*/ function editorInsertQuotation(html) {
if(!html) return; if(!html) return;
if(!xIE4Up) html += "<br />"; if(!xIE4Up) html += "<br />";
@ -425,14 +425,14 @@ function editorInsertQuotation(html) {/*{{{*/
var obj = editorGetIFrame(editorPrevSrl) var obj = editorGetIFrame(editorPrevSrl)
editorReplaceHTML(obj, html); editorReplaceHTML(obj, html);
editorFocus(editorPrevSrl); editorFocus(editorPrevSrl);
}/*}}}*/ }
function editorHighlight(ret_obj, response_tags, obj) {/*{{{*/ function editorHighlight(ret_obj, response_tags, obj) {
var html = ret_obj['html']; var html = ret_obj['html'];
html = "<div class='php_code'>"+html+"</div>"; html = "<div class='php_code'>"+html+"</div>";
if(!xIE4Up) html += "<br />"; if(!xIE4Up) html += "<br />";
editorReplaceHTML(obj, html); editorReplaceHTML(obj, html);
}/*}}}*/ }
/** /**
* iframe 드래그 관련 * iframe 드래그 관련
@ -443,7 +443,7 @@ var editorDragObj = null;
var editorDragID = ''; var editorDragID = '';
xAddEventListener(document, 'mousedown', editorDragStart); xAddEventListener(document, 'mousedown', editorDragStart);
xAddEventListener(document, 'mouseup', editorDragStop); xAddEventListener(document, 'mouseup', editorDragStop);
function editorDragStart(evt) {/*{{{*/ function editorDragStart(evt) {
var e = new xEvent(evt); var e = new xEvent(evt);
var obj = e.target; var obj = e.target;
if(typeof(obj.id)=='undefined'||!obj.id) return; if(typeof(obj.id)=='undefined'||!obj.id) return;
@ -459,9 +459,9 @@ function editorDragStart(evt) {/*{{{*/
var iframe_obj = editorGetIFrame(editorDragID); var iframe_obj = editorGetIFrame(editorDragID);
xAddEventListener(iframe_obj, 'mousemove', editorDragMove); xAddEventListener(iframe_obj, 'mousemove', editorDragMove);
}/*}}}*/ }
function editorDragStop(evt) {/*{{{*/ function editorDragStop(evt) {
var iframe_obj = editorGetIFrame(editorDragID); var iframe_obj = editorGetIFrame(editorDragID);
xRemoveEventListener(document, 'mousemove', editorDragMove); xRemoveEventListener(document, 'mousemove', editorDragMove);
xRemoveEventListener(iframe_obj, 'mousemove', editorDragMove); xRemoveEventListener(iframe_obj, 'mousemove', editorDragMove);
@ -470,9 +470,9 @@ function editorDragStop(evt) {/*{{{*/
editorDragY = 0; editorDragY = 0;
editorDragObj = null; editorDragObj = null;
editorDragID = ''; editorDragID = '';
}/*}}}*/ }
function editorDragMove(evt) {/*{{{*/ function editorDragMove(evt) {
if(typeof(editorIsDrag)=='undefined'||!editorIsDrag) return; if(typeof(editorIsDrag)=='undefined'||!editorIsDrag) return;
var e = new xEvent(evt); var e = new xEvent(evt);
var iframe_obj = editorGetIFrame(editorDragID); var iframe_obj = editorGetIFrame(editorDragID);
@ -484,7 +484,7 @@ function editorDragMove(evt) {/*{{{*/
var editorHeight = xHeight(iframe_obj); var editorHeight = xHeight(iframe_obj);
xHeight(iframe_obj, editorHeight+yy); xHeight(iframe_obj, editorHeight+yy);
}/*}}}*/ }
/** /**
* 파일 업로드 관련 * 파일 업로드 관련
@ -493,12 +493,12 @@ var uploading_file = false;
var uploaded_files = new Array(); var uploaded_files = new Array();
// 업로드를 하기 위한 준비 시작 // 업로드를 하기 위한 준비 시작
function editor_upload_init(document_srl) {/*{{{*/ function editor_upload_init(document_srl) {
xAddEventListener(window,'load',function _change_form_target() {editor_upload_form_set(document_srl);} ); xAddEventListener(window,'load',function _change_form_target() {editor_upload_form_set(document_srl);} );
}/*}}}*/ }
// document_srl에 해당하는 form의 action을 iframe으로 변경 // document_srl에 해당하는 form의 action을 iframe으로 변경
function editor_upload_form_set(document_srl) {/*{{{*/ function editor_upload_form_set(document_srl) {
// 업로드용 iframe을 생성 // 업로드용 iframe을 생성
if(!xGetElementById('tmp_upload_iframe')) { if(!xGetElementById('tmp_upload_iframe')) {
if(xIE4Up) { if(xIE4Up) {
@ -533,10 +533,10 @@ function editor_upload_form_set(document_srl) {/*{{{*/
if(!iframe_obj) return; if(!iframe_obj) return;
iframe_obj.contentWindow.document.location.href=url; iframe_obj.contentWindow.document.location.href=url;
}/*}}}*/ }
// 파일 업로드 // 파일 업로드
function editor_file_upload(field_obj, document_srl) {/*{{{*/ function editor_file_upload(field_obj, document_srl) {
if(uploading_file) return; if(uploading_file) return;
var fo_obj = field_obj.parentNode; var fo_obj = field_obj.parentNode;
@ -550,20 +550,20 @@ function editor_file_upload(field_obj, document_srl) {/*{{{*/
var string = 'wait for uploading...'; var string = 'wait for uploading...';
var opt_obj = new Option(string, '', true, true); var opt_obj = new Option(string, '', true, true);
sel_obj.options[sel_obj.options.length] = opt_obj; sel_obj.options[sel_obj.options.length] = opt_obj;
}/*}}}*/ }
// 업로드된 파일 목록을 삭제 // 업로드된 파일 목록을 삭제
function editor_upload_clear_list(document_srl) {/*{{{*/ function editor_upload_clear_list(document_srl) {
var obj = xGetElementById('uploaded_file_list_'+document_srl); var obj = xGetElementById('uploaded_file_list_'+document_srl);
while(obj.options.length) { while(obj.options.length) {
obj.remove(0); obj.remove(0);
} }
var preview_obj = xGetElementById('uploaded_file_preview_box_'+document_srl); var preview_obj = xGetElementById('uploaded_file_preview_box_'+document_srl);
xInnerHtml(preview_obj,'') xInnerHtml(preview_obj,'')
}/*}}}*/ }
// 업로드된 파일 정보를 목록에 추가 // 업로드된 파일 정보를 목록에 추가
function editor_insert_uploaded_file(document_srl, file_srl, filename, file_size, disp_file_size, uploaded_filename, sid) {/*{{{*/ function editor_insert_uploaded_file(document_srl, file_srl, filename, file_size, disp_file_size, uploaded_filename, sid) {
var obj = xGetElementById('uploaded_file_list_'+document_srl); var obj = xGetElementById('uploaded_file_list_'+document_srl);
var string = filename+' ('+disp_file_size+')'; var string = filename+' ('+disp_file_size+')';
var opt_obj = new Option(string, file_srl, true, true); var opt_obj = new Option(string, file_srl, true, true);
@ -573,10 +573,10 @@ function editor_insert_uploaded_file(document_srl, file_srl, filename, file_size
uploaded_files[file_srl] = file_obj; uploaded_files[file_srl] = file_obj;
editor_preview(obj, document_srl); editor_preview(obj, document_srl);
}/*}}}*/ }
// 파일 목록창에서 클릭 되었을 경우 미리 보기 // 파일 목록창에서 클릭 되었을 경우 미리 보기
function editor_preview(sel_obj, document_srl) {/*{{{*/ function editor_preview(sel_obj, document_srl) {
if(sel_obj.options.length<1) return; if(sel_obj.options.length<1) return;
var file_srl = sel_obj.options[sel_obj.selectedIndex].value; var file_srl = sel_obj.options[sel_obj.selectedIndex].value;
var obj = uploaded_files[file_srl]; var obj = uploaded_files[file_srl];
@ -605,10 +605,10 @@ function editor_preview(sel_obj, document_srl) {/*{{{*/
html = "<img src=\""+uploaded_filename+"\" border=\"0\" width=\"120\" height=\"120\" />"; html = "<img src=\""+uploaded_filename+"\" border=\"0\" width=\"120\" height=\"120\" />";
} }
xInnerHtml(preview_obj, html); xInnerHtml(preview_obj, html);
}/*}}}*/ }
// 업로드된 파일 삭제 // 업로드된 파일 삭제
function editor_remove_file(document_srl) {/*{{{*/ function editor_remove_file(document_srl) {
var obj = xGetElementById('uploaded_file_list_'+document_srl); var obj = xGetElementById('uploaded_file_list_'+document_srl);
if(obj.options.length<1) return; if(obj.options.length<1) return;
var file_srl = obj.options[obj.selectedIndex].value; var file_srl = obj.options[obj.selectedIndex].value;
@ -626,10 +626,10 @@ function editor_remove_file(document_srl) {/*{{{*/
if(!iframe_obj) return; if(!iframe_obj) return;
iframe_obj.contentWindow.document.location.href=url; iframe_obj.contentWindow.document.location.href=url;
}/*}}}*/ }
// 업로드 목록의 선택된 파일을 내용에 추가 // 업로드 목록의 선택된 파일을 내용에 추가
function editor_insert_file(document_srl, align) {/*{{{*/ function editor_insert_file(document_srl, align) {
var obj = xGetElementById('uploaded_file_list_'+document_srl); var obj = xGetElementById('uploaded_file_list_'+document_srl);
if(obj.options.length<1) return; if(obj.options.length<1) return;
var file_srl = obj.options[obj.selectedIndex].value; var file_srl = obj.options[obj.selectedIndex].value;
@ -691,16 +691,16 @@ function editor_insert_file(document_srl, align) {/*{{{*/
if(editor_popup) editor_popup.focus(); if(editor_popup) editor_popup.focus();
} }
}/*}}}*/ }
/** /**
* 글을 쓰다가 페이지 이동시 첨부파일에 대한 정리 * 글을 쓰다가 페이지 이동시 첨부파일에 대한 정리
**/ **/
function editorRemoveAttachFiles(mid, document_srl) {/*{{{*/ function editorRemoveAttachFiles(mid, document_srl) {
var obj = xGetElementById('uploaded_file_list_'+document_srl); var obj = xGetElementById('uploaded_file_list_'+document_srl);
if(obj.options.length<1) return; if(obj.options.length<1) return;
var params = new Array(); var params = new Array();
params['document_srl'] = document_srl; params['document_srl'] = document_srl;
exec_xml(mid, 'procClearFile', params, null, null, null); exec_xml(mid, 'procClearFile', params, null, null, null);
}/*}}}*/ }

View file

@ -14,6 +14,7 @@
* - 공식홈페이지 : http://www.zeroboard.com * - 공식홈페이지 : http://www.zeroboard.com
* - 개발자 포험 : http://dev.zeroboard.com * - 개발자 포험 : http://dev.zeroboard.com
* - 이슈트래킹 : http://www.zeroboard.com/trac * - 이슈트래킹 : http://www.zeroboard.com/trac
* - pdf 문서 : http://dev.zeroboard.com/doc/zeroboard.pdf
* *
**/ **/

View file

@ -12,7 +12,7 @@
**/ **/
function init() { function init() {
// 파일 업로드일 경우 $act값을 procUploadFile() 로 변경 // 파일 업로드일 경우 $act값을 procUploadFile() 로 변경
if(Context::isUploaded() && $this->grant->fileupload) $this->act = 'procUploadFile'; if(Context::isUploaded() && $this->grant->fileupload) Context::set('act', 'procUploadFile');
} }
/** /**
@ -433,7 +433,7 @@
/** /**
* @brief 게시판 추가 * @brief 게시판 추가
**/ **/
function procBoardInsert() { function procInsertBoard() {
// 일단 입력된 값들을 모두 받아서 db 입력항목과 그외 것으로 분리 // 일단 입력된 값들을 모두 받아서 db 입력항목과 그외 것으로 분리
$args = Context::gets('module_srl','mid','skin','use_category','browser_title','description','is_default','header_text','footer_text','admin_id'); $args = Context::gets('module_srl','mid','skin','use_category','browser_title','description','is_default','header_text','footer_text','admin_id');
$args->module = 'board'; $args->module = 'board';
@ -483,7 +483,7 @@
/** /**
* @brief 게시판 삭제 * @brief 게시판 삭제
**/ **/
function procBoardDelete() { function procDeleteBoard() {
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
// 원본을 구해온다 // 원본을 구해온다

View file

@ -11,7 +11,7 @@
* @brief 초기화 * @brief 초기화
**/ **/
function init() { function init() {
// 카테고리를 사용한다면 카테고리 목록을 구해옴 // 카테고리를 사용하는지 확인후 사용시 카테고리 목록을 구해와서 Context에 세팅
if($this->module_info->use_category=='Y') { if($this->module_info->use_category=='Y') {
$oDocumentModel = &getModel('document'); $oDocumentModel = &getModel('document');
$this->category_list = $oDocumentModel->getCategoryList($this->module_srl); $this->category_list = $oDocumentModel->getCategoryList($this->module_srl);
@ -27,8 +27,6 @@
// 스킨 디렉토리 세팅 // 스킨 디렉토리 세팅
$skin_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin); $skin_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
$this->setTemplatePath($skin_path); $this->setTemplatePath($skin_path);
return true;
} }
/** /**
@ -47,86 +45,34 @@
// document_srl이 있다면 해당 글을 구해오자 // document_srl이 있다면 해당 글을 구해오자
if($this->grant->view && $document_srl) { if($this->grant->view && $document_srl) {
$document = $oDocumentModel->getDocument($document_srl);
// 글이 찾아지지 않으면 무효화
if(!$document) {
Context::set('document_srl','');
$document_srl = NULL;
unset($document);
}
}
// 글이 찾아지면 조회수 업데이트 및 기타 등등
if($document) {
// 비밀글이고 권한이 없을 경우 인증페이지로
if($document->is_secret=='Y' && !$document->is_granted) return $this->setTemplateFile('input_password_form');
// 조회수 업데이트
if($oDocument->updateReadedCount($document_srl)) $document->readed_count++;
// 댓글 가져오기
if($document->comment_count && $document->allow_comment == 'Y') {
$oCommentModel = &getModel('comment');
$comment_list = $oCommentModel->getCommentList($document_srl);
Context::set('comment_list', $comment_list);
}
// 트랙백 가져오기
if($document->trackback_count && $document->allow_trackback == 'Y') {
$oTrackback = &getModule('trackback');
$trackback_list = $oTrackback->getTrackbackList($document_srl);
Context::set('trackback_list', $trackback_list);
}
// 첨부파일 가져오기
if($document->uploaded_count) {
$file_list = $oDocument->getFiles($document_srl);
$document->uploaded_list = $file_list;
}
$document = $oDocumentModel->getDocument($document_srl, $this->grant->manager, true);
Context::set('document', $document); Context::set('document', $document);
} }
// 만약 document_srl은 있는데 page가 없다면 글만 호출된 경우, // 만약 document_srl은 있는데 page가 없다면 글만 호출된 경우 page를 구해서 세팅해주자..
// 그럼 page를 구해서 세팅해주자..
if($document_srl && !$page) { if($document_srl && !$page) {
$page = $oDocument->getDocumentPage($document_srl, $this->module_srl, $this->list_count); $page = $oDocumentModel->getDocumentPage($document_srl, $this->module_srl, $this->list_count);
Context::set('page', $page); Context::set('page', $page);
} }
// 검색옵션 // 목록을 구하기 위한 옵션
$search_target = Context::get('search_target'); $args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
$keyword = Context::get('keyword'); $args->page = $page; ///< 페이지
if($search_target && $keyword) { $args->list_count = $this->list_count; ///< 한페이지에 보여줄 글 수
$keyword = str_replace(' ','%',$keyword); $args->page_count = $this->page_count; ///< 페이지 네비게이션에 나타날 페이지의 수
switch($search_target) {
case 'title' :
$search_obj->s_title = $keyword;
break;
case 'content' :
$search_obj->s_content = $keyword;
break;
case 'title_content' :
$search_obj->s_title = $keyword;
$search_obj->s_content = $keyword;
break;
case 'user_name' :
$search_obj->s_user_name = $keyword;
break;
}
}
// 카테고리 $args->search_target = Context::get('search_target'); ///< 검색 대상 (title, contents...)
$category = Context::get('category'); $args->search_keyword = Context::get('search_keyword'); ///< 검색어
if($category) $search_obj->category_srl = $category; if($this->module_info->use_category=='Y') $args->category_srl = Context::get('category'); ///< 카테고리 사용시 선택된 카테고리
// 목록의 경우 document->getDocumentList 에서 걍 알아서 다 해버리는 구조이다... (아.. 이거 나쁜 버릇인데.. ㅡ.ㅜ 어쩔수 없다) $args->sort_index = 'list_order'; ///< 소팅 값
$oDocumentModel = &getModel('document');
$output = $oDocumentModel->getDocumentList($this->module_srl, 'list_order', $page, $this->list_count, $this->page_count, $search_obj);
// 템플릿에 쓰기 위해서 context::set // 목록 구함, document->getDocumentList 에서 걍 알아서 다 해버리는 구조이다... (아.. 이거 나쁜 버릇인데.. ㅡ.ㅜ 어쩔수 없다)
$output = $oDocumentModel->getDocumentList($args);
// 템플릿에 쓰기 위해서 document_model::getDocumentList() 의 return object에 있는 값들을 세팅
Context::set('total_count', $output->total_count); Context::set('total_count', $output->total_count);
Context::set('total_page', $output->total_page); Context::set('total_page', $output->total_page);
Context::set('page', $output->page); Context::set('page', $output->page);
@ -139,6 +85,7 @@
$search_option[$this->search_option[$i]] = Context::getLang($this->search_option[$i]); $search_option[$this->search_option[$i]] = Context::getLang($this->search_option[$i]);
} }
Context::set('search_option', $search_option); Context::set('search_option', $search_option);
$this->setTemplateFile('list'); $this->setTemplateFile('list');
} }
@ -149,24 +96,25 @@
// 권한 체크 // 권한 체크
if(!$this->grant->write_document) return $this->dispMessage('msg_not_permitted'); if(!$this->grant->write_document) return $this->dispMessage('msg_not_permitted');
// 목록 구현에 필요한 변수들을 가져온다 // GET parameter에서 document_srl을 가져옴
$document_srl = Context::get('document_srl'); $document_srl = Context::get('document_srl');
// document 모듈 객체 생성 // document 모듈 객체 생성
$oDocument = &getModule('document'); $oDocumentModel = &getModel('document');
// 지정된 글이 없다면 (신규) 새로운 번호를 만든다 // 지정된 글이 없다면 (신규) 새로운 번호를 만든다
if($document_srl) {
$document = $oDocumentModel->getDocument($document_srl);
if(!$document) {
unset($document_srl);
Context::set('document_srl','');
}
}
// 문서 번호가 없으면 새로운 값을 받아옴
if(!$document_srl) { if(!$document_srl) {
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$document_srl = $oDB->getNextSequence(); $document_srl = $oDB->getNextSequence();
// 글의 수정일 경우 원본 글을 가져와서 확인을 한다
} else {
$document = $oDocument->getDocument($document_srl);
if(!$document) {
$oDB = &DB::getInstance();
$document_srl = $oDB->getNextSequence();
}
} }
// 글을 수정하려고 할 경우 권한이 없는 경우 비밀번호 입력화면으로 // 글을 수정하려고 할 경우 권한이 없는 경우 비밀번호 입력화면으로
@ -190,8 +138,8 @@
// 지정된 글이 있는지 확인 // 지정된 글이 있는지 확인
if($document_srl) { if($document_srl) {
$oDocument = &getModule('document'); $oDocumentModel = &getModel('document');
$document = $oDocument->getDocument($document_srl); $document = $oDocumentModel->getDocument($document_srl);
} }
// 삭제하려는 글이 없으면 에러 // 삭제하려는 글이 없으면 에러
@ -220,11 +168,11 @@
if(!$parent_srl) return new Object(-1, 'msg_invalid_request'); if(!$parent_srl) return new Object(-1, 'msg_invalid_request');
// 해당 댓글를 찾아본다 // 해당 댓글를 찾아본다
$oComment = &getModule('comment'); $oCommentModel = &getModel('comment');
$source_comment = $oComment->getComment($parent_srl); $source_comment = $oCommentModel->getComment($parent_srl);
// 댓글이 없다면 오류 // 댓글이 없다면 오류
if(!$source_comment) return new Object(-1, 'msg_invalid_request'); if(!$source_comment) return $this->dispMessage('msg_invalid_request');
// 필요한 정보들 세팅 // 필요한 정보들 세팅
Context::set('document_srl',$document_srl); Context::set('document_srl',$document_srl);
@ -250,14 +198,14 @@
if(!$comment_srl) return new Object(-1, 'msg_invalid_request'); if(!$comment_srl) return new Object(-1, 'msg_invalid_request');
// 해당 댓글를 찾아본다 // 해당 댓글를 찾아본다
$oComment = &getModule('comment'); $oCommentModel = &getModel('comment');
$comment = $oComment->getComment($comment_srl); $comment = $oCommentModel->getComment($comment_srl);
// 댓글이 없다면 오류 // 댓글이 없다면 오류
if(!$comment) return new Object(-1, 'msg_invalid_request'); if(!$comment) return $this->dispMessage('msg_invalid_request');
// 글을 수정하려고 할 경우 권한이 없는 경우 비밀번호 입력화면으로 // 글을 수정하려고 할 경우 권한이 없는 경우 비밀번호 입력화면으로
if($comment_srl&&$comment&&!$_SESSION['own_comment'][$comment_srl]) return $this->setTemplateFile('input_password_form'); if($comment_srl&&$comment&&!$comment->is_granted) return $this->setTemplateFile('input_password_form');
// 필요한 정보들 세팅 // 필요한 정보들 세팅
Context::set('document_srl',$document_srl); Context::set('document_srl',$document_srl);
@ -279,26 +227,46 @@
// 삭제하려는 댓글가 있는지 확인 // 삭제하려는 댓글가 있는지 확인
if($comment_srl) { if($comment_srl) {
$oComment = &getModule('comment'); $oCommentModel = &getModel('comment');
$comment = $oComment->getComment($comment_srl); $comment = $oCommentModel->getComment($comment_srl);
} }
// 삭제하려는 글이 없으면 에러 // 삭제하려는 글이 없으면 에러
if(!$comment) return $this->list(); if(!$comment) return $this->list();
// 권한이 없는 경우 비밀번호 입력화면으로 // 권한이 없는 경우 비밀번호 입력화면으로
if($comment_srl&&$comment&&!$_SESSION['own_comment'][$comment_srl]) return $this->setTemplateFile('input_password_form'); if($comment_srl&&$comment&&!$comment->is_granted) return $this->setTemplateFile('input_password_form');
Context::set('comment',$comment); Context::set('comment',$comment);
$this->setTemplateFile('delete_comment_form'); $this->setTemplateFile('delete_comment_form');
} }
/**
* @brief 엮인글 삭제 화면 출력
**/
function dispTrackbackDelete() {
// 삭제할 댓글번호를 가져온다
$trackback_srl = Context::get('trackback_srl');
// 삭제하려는 댓글가 있는지 확인
$oTrackbackModel = &getModel('trackback');
$output = $oTrackbackModel->getTrackback($trackback_srl);
$trackback = $output->data;
// 삭제하려는 글이 없으면 에러
if(!$trackback) return $this->dispContent();
Context::set('trackback',$trackback);
$this->setTemplateFile('delete_trackback_form');
}
/** /**
* @brief 로그인 출력 * @brief 로그인 출력
**/ **/
function dispLogin() { function dispLogin() {
if(Context::get('is_logged')) return $this->list(); if(Context::get('is_logged')) return $this->dispContent();
$this->setTemplateFile('login_form'); $this->setTemplateFile('login_form');
} }
@ -306,7 +274,7 @@
* @brief 로그아웃 화면 출력 * @brief 로그아웃 화면 출력
**/ **/
function dispLogout() { function dispLogout() {
if(!Context::get('is_logged')) return $this->list(); if(!Context::get('is_logged')) return $this->dispContent();
$this->setTemplateFile('logout'); $this->setTemplateFile('logout');
} }
@ -321,26 +289,6 @@
$this->setTemplateFile('message'); $this->setTemplateFile('message');
} }
/**
* @brief 엮인글 삭제 화면 출력
**/
function dispTrackbackDelete() {
// 삭제할 댓글번호를 가져온다
$trackback_srl = Context::get('trackback_srl');
// 삭제하려는 댓글가 있는지 확인
$oTrackback = &getModule('trackback');
$output = $oTrackback->getTrackback($trackback_srl);
$trackback = $output->data;
// 삭제하려는 글이 없으면 에러
if(!$trackback) return $this->list();
Context::set('trackback',$trackback);
$this->setTemplateFile('delete_trackback_form');
}
/** /**
* @brief RSS 출력 * @brief RSS 출력
**/ **/
@ -348,7 +296,21 @@
// 권한 체크 // 권한 체크
if(!$this->grant->list) return $this->dispMessage('msg_not_permitted'); if(!$this->grant->list) return $this->dispMessage('msg_not_permitted');
$page = Context::get('page'); // 컨텐츠 추출
$args->module_srl = $this->module_srl; ///< 현재 모듈의 module_srl
$args->page = Context::get('page'); ///< 페이지
$args->list_count = $this->list_count; ///< 한페이지에 보여줄 글 수
$args->page_count = $this->page_count; ///< 페이지 네비게이션에 나타날 페이지의 수
$args->search_target = Context::get('search_target'); ///< 검색 대상 (title, contents...)
$args->search_keyword = Context::get('search_keyword'); ///< 검색어
if($this->module_info->use_category=='Y') $args->category_srl = Context::get('category'); ///< 카테고리 사용시 선택된 카테고리
$args->sort_index = 'list_order'; ///< 소팅 값
$oDocumentModel = &getModel('document');
$output = $oDocumentModel->getDocumentList($args);
$document_list = $output->data;
// rss 제목 및 정보등을 추출 // rss 제목 및 정보등을 추출
$info->title = Context::getBrowserTitle(); $info->title = Context::getBrowserTitle();
@ -356,15 +318,12 @@
$info->language = Context::getLangType(); $info->language = Context::getLangType();
$info->date = gmdate("D, d M Y H:i:s"); $info->date = gmdate("D, d M Y H:i:s");
$info->link = sprintf("%s?mid=%s", Context::getRequestUri(), Context::get('mid')); $info->link = sprintf("%s?mid=%s", Context::getRequestUri(), Context::get('mid'));
$info->total_count = $output->total_count;
// 컨텐츠 추출 $info->total_page = $output->total_page;
$oDocument = &getModule('document');
$output = $oDocument->getDocumentList($this->module_srl, 'update_order', $page, 20, 20, NULL);
$document_list = $output->data;
// 출력하고 끝내기 // 출력하고 끝내기
$oRss = &getView('rss'); $oRssView = &getView('rss');
$oRss->dispRss($info, $document_list); $oRssView->dispRss($info, $document_list);
} }
/** /**
@ -373,9 +332,10 @@
function dispAdminContent() { function dispAdminContent() {
// module_srl이 있으면 미리 체크하여 존재하는 모듈이면 module_info 세팅 // module_srl이 있으면 미리 체크하여 존재하는 모듈이면 module_info 세팅
$module_srl = Context::get('module_srl'); $module_srl = Context::get('module_srl');
if($module_srl) { if($module_srl) {
$oModule = &getModule('module_manager'); $oModuleModel = &getModel('module');
$module_info = $oModule->getModuleInfoByModuleSrl($module_srl); $module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
if(!$module_info) { if(!$module_info) {
Context::set('module_srl',''); Context::set('module_srl','');
$this->act = 'list'; $this->act = 'list';

View file

@ -35,7 +35,7 @@
<action name="dispCommentDelete" type="view" /> <action name="dispCommentDelete" type="view" />
<action name="dispTrackbackDelete" type="view" /> <action name="dispTrackbackDelete" type="view" />
<action name="dispLogin" type="view" /> <action name="dispLogin" type="view" />
<action name="dispLogout" type="view" /> <action name="dispLogout" type="view" grant="member" />
<action name="dispMessage" type="view" /> <action name="dispMessage" type="view" />
<action name="dispRss" type="view" /> <action name="dispRss" type="view" />
<action name="dispAdminContent" type="view" grant="root" /> <action name="dispAdminContent" type="view" grant="root" />
@ -45,5 +45,25 @@
<action name="dispAdminSkinInfo" type="view" grant="root" /> <action name="dispAdminSkinInfo" type="view" grant="root" />
<action name="dispAdminCategoryInfo" type="view" grant="root" /> <action name="dispAdminCategoryInfo" type="view" grant="root" />
<action name="dispAdminGrantInfo" type="view" grant="root" /> <action name="dispAdminGrantInfo" type="view" grant="root" />
<action name="procLogin" type="controller" />
<action name="procLogout" type="controller" grant="member" />
<action name="procInsertDocument" type="controller" />
<action name="procDeleteDocument" type="controller" />
<action name="procVoteDocument" type="controller" />
<action name="procInsertComment" type="controller" />
<action name="procDeleteComment" type="controller" />
<action name="procReceiveTrackback" type="controller" />
<action name="procDeleteTrackback" type="controller" />
<action name="procVerificationPassword" type="controller" />
<action name="procDeleteFile" type="controller" />
<action name="procUploadFile" type="controller" />
<action name="procDownload" type="controller" />
<action name="procClearFile" type="controller" />
<action name="procInsertGrant" type="controller" grant="root"/>
<action name="procUpdateSkinInfo" type="controller" grant="root"/>
<action name="procInsertBoard" type="controller" grant="root"/>
<action name="procDeleteBoard" type="controller" grant="root"/>
<action name="procInsertCategory" type="controller" grant="root"/>
<action name="procUpdateCategory" type="controller" grant="root"/>
</actions> </actions>
</module> </module>

View file

@ -1,4 +1,4 @@
<filter name="insert" module="board" act="procInsert" confirm_msg_code="confirm_submit"> <filter name="insert" module="board" act="procInsertDocument" confirm_msg_code="confirm_submit">
<form> <form>
<node target="document_srl" required="true" /> <node target="document_srl" required="true" />
<node target="user_name" required="true" /> <node target="user_name" required="true" />
@ -8,7 +8,7 @@
<node target="title" required="true" minlength="1" maxlength="250" /> <node target="title" required="true" minlength="1" maxlength="250" />
<node target="content" required="true" /> <node target="content" required="true" />
</form> </form>
<response> <response callback_func="completeDocumentInserted">
<tag name="error" /> <tag name="error" />
<tag name="message" /> <tag name="message" />
<tag name="mid" /> <tag name="mid" />

View file

@ -5,7 +5,7 @@
**/ **/
/* 글쓰기 작성후 */ /* 글쓰기 작성후 */
function procInsert(ret_obj, response_tags) { function completeDocumentInserted(ret_obj) {
var error = ret_obj['error']; var error = ret_obj['error'];
var message = ret_obj['message']; var message = ret_obj['message'];
var mid = ret_obj['mid']; var mid = ret_obj['mid'];
@ -17,6 +17,13 @@ function procInsert(ret_obj, response_tags) {
location.href = url; location.href = url;
} }
/* 글 삭제 */ /* 글 삭제 */
function procDeleteDocument(ret_obj, response_tags) { function procDeleteDocument(ret_obj, response_tags) {
var error = ret_obj['error']; var error = ret_obj['error'];

View file

@ -1,4 +1,4 @@
<!--%import("filter/filter.insert.xml")--> <!--%import("filter/insert.xml")-->
<!--#include("header.html")--> <!--#include("header.html")-->
<form action="./" method="post" onsubmit="return procFilter(this, insert)" <!--@if($grant->fileupload)-->enctype="multipart/form-data"<!--@end-->> <form action="./" method="post" onsubmit="return procFilter(this, insert)" <!--@if($grant->fileupload)-->enctype="multipart/form-data"<!--@end-->>

View file

@ -185,14 +185,41 @@
/** /**
* @brief 해당 document의 조회수 증가 * @brief 해당 document의 조회수 증가
**/ **/
function updateReadedCount($document_srl) { function updateReadedCount($document) {
if($_SESSION['readed_document'][$document_srl]) return false; $document_srl = $document->document_srl;
// session에 정보로 조회수를 증가하였다고 생각하면 패스
if($_SESSION['readed_document'][$document_srl]) return;
// member model 객체 생성
$oMemberModel = &getModel('member');
$member_srl = $oMemberModel->getLoggedMemberSrl();
// 글쓴이와 현재 로그인 사용자의 정보가 일치하면 읽었다고 생각하고 세션 등록후 패스
if($member_srl && $member_srl == $document->member_srl) return $_SESSION['readed_document'][$document_srl] = true;
// DB 객체 생성
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$args->document_srl = $document_srl; // 로그인 사용자이면 member_srl, 비회원이면 ipaddress로 판단
if($member_srl) {
$args->member_srl = $member_srl;
} else {
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
}
$output = $oDB->executeQuery('document.getDocumentReadedLogInfo', $args);
// 로그 정보에 조회 로그가 있으면 세션 등록후 패스
if($output->data->count) return $_SESSION['readed_document'][$document_srl] = true;
// 조회수 업데이트
$output = $oDB->executeQuery('document.updateReadedCount', $args); $output = $oDB->executeQuery('document.updateReadedCount', $args);
return $_SESSION['readed_document'][$document_srl] = true;
// 로그 남기기
$output = $oDB->executeQuery('document.insertDocumentReadedLog', $args);
// 세션 정보에 남김
$_SESSION['readed_document'][$document_srl] = true;
} }
/** /**

View file

@ -23,28 +23,61 @@
/** /**
* @brief 문서 가져오기 * @brief 문서 가져오기
**/ **/
function getDocument($document_srl) { function getDocument($document_srl, $is_admin=false, $get_extra_info=false) {
// DB에서 가져옴 // DB에서 가져옴
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$output = $oDB->executeQuery('document.getDocument', $args); $output = $oDB->executeQuery('document.getDocument', $args);
$document = $output->data; $document = $output->data;
if(!$get_extra_info) return $document;
// document controller 객체 생성
$oDocumentController = &getController('document');
// 조회수 업데이트
$oDocumentController->updateReadedCount($document);
// 이 문서에 대한 권한이 있는지 확인 // 이 문서에 대한 권한이 있는지 확인
if($this->isGranted($document->document_srl)) { if($this->isGranted($document->document_srl) || $is_admin) {
$document->is_granted = true; $document->is_granted = true;
} elseif($document->member_srl) { } elseif($document->member_srl) {
$oMemberModel = &getMemberModel('member'); $oMemberModel = &getMemberModel('member');
$member_srl = $oMemberModel->getMemberSrl(); $member_srl = $oMemberModel->getMemberSrl();
if($member_srl && $member_srl ==$document->member_srl) $document->is_granted = true; if($member_srl && $member_srl ==$document->member_srl) $document->is_granted = true;
} }
// 비밀글이고 권한이 없을 경우 제목과 내용을 숨김
if($document->is_secret=='Y' && !$document->is_granted) {
$document->title = $document->content = Context::getLang('msg_is_secret');
}
// 댓글 가져오기
if($document->comment_count && $document->allow_comment == 'Y') {
$oCommentModel = &getModel('comment');
$document->comment_list = $oCommentModel->getCommentList($document_srl);
}
// 트랙백 가져오기
if($document->trackback_count && $document->allow_trackback == 'Y') {
$oTrackback = &getModule('trackback');
$document->trackback_list = $oTrackback->getTrackbackList($document_srl);
}
// 첨부파일 가져오기
if($document->uploaded_count) {
$oFileModel = &getModel('file');
$file_list = $oFileModel->getFiles($document_srl);
$document->uploaded_list = $file_list;
}
return $document; return $document;
} }
/** /**
* @brief 여러개의 문서들을 가져옴 (페이징 아님) * @brief 여러개의 문서들을 가져옴 (페이징 아님)
**/ **/
function getDocuments($document_srl_list) { function getDocuments($document_srl_list, $is_admin=false) {
if(is_array($document_srl_list)) $document_srls = implode(',',$document_srl_list); if(is_array($document_srl_list)) $document_srls = implode(',',$document_srl_list);
// DB에서 가져옴 // DB에서 가져옴
@ -63,7 +96,7 @@
$document = $document_list[$i]; $document = $document_list[$i];
$is_granted = false; $is_granted = false;
if($this->isGranted($document->document_srl)) { if($this->isGranted($document->document_srl) || $is_admin) {
$is_granted = true; $is_granted = true;
} elseif($member_srl && $member_srl == $document->member_srl) { } elseif($member_srl && $member_srl == $document->member_srl) {
$is_granted = true; $is_granted = true;
@ -73,30 +106,79 @@
return $document_list; return $document_list;
} }
/**
* @brief module_srl값을 가지는 문서의 목록을 가져옴
**/
function getDocumentList($obj) {
// 검색 키워드가 있으면 공백을 % 로 변경하여 키워드 or 연산이 되도록 수정
if($obj->keyword) $obj->keyword = str_replace(' ','%',$obj->keyword);
if($obj->search_target && $obj->keyword) {
switch($obj->search_target) {
case 'title' :
$search_obj->s_title = $obj->keyword;
break;
case 'content' :
$search_obj->s_content = $obj->keyword;
break;
case 'title_content' :
$search_obj->s_title = $obj->keyword;
$search_obj->s_content = $obj->keyword;
break;
case 'user_name' :
$search_obj->s_user_name = $obj->keyword;
break;
}
}
// DB 객체 생성
$oDB = &DB::getInstance();
// 변수 설정
$args->module_srl = $obj->module_srl;
$args->s_title = $obj->search_target=='title'?$obj->keyword:'';
$args->s_content = $obj->search_target=='content'?$obj->keyword:'';
$args->s_user_name = $obj->search_target=='user_name'?$obj->keyword:'';
$args->s_member_srl = $obj->search_target=='member'?$obj->keyword:'';
$args->s_ipaddress = $obj->search_target=='ipaddress'?$obj->keyword:'';
$args->s_regdate = $obj->search_target=='regdate'?$obj->keyword:'';
$args->category_srl = $obj->category_srl?$obj->category_srl:'';
$args->sort_index = $obj->sort_index;
$args->page = $obj->page?$obj->page:1;
$args->list_count = $obj->list_count?$obj->list_count:20;
$args->page_count = $obj->page_count?$obj->page_count:10;
// document.getDocumentList 쿼리 실행
$output = $oDB->executeQuery('document.getDocumentList', $args);
// 결과가 없거나 오류 발생시 그냥 return
if(!$output->toBool()||!count($output->data)) return $output;
// 권한 체크
$oMemberModel = &getModel('member');
$member_srl = $oMemberModel->getMemberSrl();
foreach($output->data as $key => $document) {
$is_granted = false;
if($this->isGranted($document->document_srl) || $is_admin) $is_granted = true;
elseif($member_srl && $member_srl == $document->member_srl) $is_granted = true;
$output->data[$key]->is_granted = $is_granted;
}
return $output;
}
/** /**
* @brief module_srl에 해당하는 문서의 전체 갯수를 가져옴 * @brief module_srl에 해당하는 문서의 전체 갯수를 가져옴
**/ **/
function getDocumentCount($module_srl, $search_obj = NULL) { function getDocumentCount($module_srl, $search_obj = NULL) {
// DB 객체 생성
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$args->module_srl = $module_srl; // 검색 옵션 추가
$args->s_title = $search_obj->s_title;
$args->s_content = $search_obj->s_content;
$args->s_user_name = $search_obj->s_user_name;
$args->s_member_srl = $search_obj->s_member_srl;
$args->s_ipaddress = $search_obj->s_ipaddress;
$args->s_regdate = $search_obj->s_regdate;
$output = $oDB->executeQuery('document.getDocumentCount', $args);
$total_count = $output->data->count;
return (int)$total_count;
}
/**
* @brief module_srl값을 가지는 문서의 목록을 가져옴
**/
function getDocumentList($module_srl, $sort_index = 'list_order', $page = 1, $list_count = 20, $page_count = 10, $search_obj = NULL) {
$oDB = &DB::getInstance();
$args->module_srl = $module_srl; $args->module_srl = $module_srl;
$args->s_title = $search_obj->s_title; $args->s_title = $search_obj->s_title;
$args->s_content = $search_obj->s_content; $args->s_content = $search_obj->s_content;
@ -106,39 +188,25 @@
$args->s_regdate = $search_obj->s_regdate; $args->s_regdate = $search_obj->s_regdate;
$args->category_srl = $search_obj->category_srl; $args->category_srl = $search_obj->category_srl;
$args->sort_index = $sort_index; $output = $oDB->executeQuery('document.getDocumentCount', $args);
$args->page = $page;
$args->list_count = $list_count;
$args->page_count = $page_count;
$output = $oDB->executeQuery('document.getDocumentList', $args);
if(!count($output->data)) return $output; // 전체 갯수를 return
$total_count = $output->data->count;
// 권한 체크 return (int)$total_count;
$oMemberModel = &getModel('member');
$member_srl = $oMemberModel->getMemberSrl();
foreach($output->data as $key => $document) {
$is_granted = false;
if($this->isGranted($document->document_srl)) $is_granted = true;
elseif($member_srl && $member_srl == $document->member_srl) $is_granted = true;
$output->data[$key]->is_granted = $is_granted;
} }
return $output;
}
/** /**
* @brief 해당 document의 page 가져오기, module_srl이 없으면 전체에서.. * @brief 해당 document의 page 가져오기, module_srl이 없으면 전체에서..
**/ **/
function getDocumentPage($document_srl, $module_srl=0, $list_count) { function getDocumentPage($document_srl, $module_srl=0, $list_count) {
// DB 객체 생성
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
// 변수 설정
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$args->module_srl = $module_srl; $args->module_srl = $module_srl;
$output = $oDB->executeQuery('document.getDocumentPage', $args);
// 전체 갯수를 구한후 해당 글의 페이지를 검색
$output = $oDB->executeQuery('document.getDocumentPage', $args);
$count = $output->data->count; $count = $output->data->count;
$page = (int)(($count-1)/$list_count)+1; $page = (int)(($count-1)/$list_count)+1;
return $page; return $page;

View file

@ -5,4 +5,6 @@
* @desc : 문서(document) 모듈의 기본 언어팩 * @desc : 문서(document) 모듈의 기본 언어팩
**/ **/
$lang->msg_category_not_moved = "이동할 수가 없습니다"; $lang->msg_category_not_moved = "이동할 수가 없습니다";
$lang->msg_is_secret = '비밀글입니다';
?> ?>

View file

@ -7,6 +7,7 @@
</columns> </columns>
<conditions> <conditions>
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" /> <condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
<condition operation="equal" column="category_srl" var="category_srl" />
<group pipe="and"> <group pipe="and">
<condition operation="like" column="title" var="s_title" /> <condition operation="like" column="title" var="s_title" />
<condition operation="like" column="content" var="s_content" pipe="and" /> <condition operation="like" column="content" var="s_content" pipe="and" />

View file

@ -17,8 +17,6 @@
* @brief 첨부파일 추가 * @brief 첨부파일 추가
**/ **/
function insertFile($module_srl, $document_srl) { function insertFile($module_srl, $document_srl) {
$oDB = &DB::getInstance();
$file_info = Context::get('file'); $file_info = Context::get('file');
// 정상적으로 업로드된 파일이 아니면 오류 출력 // 정상적으로 업로드된 파일이 아니면 오류 출력
@ -43,7 +41,10 @@
// 사용자 정보를 구함 // 사용자 정보를 구함
$oMemberModel = &getModel('member'); $oMemberModel = &getModel('member');
$member_srl = $oMemberModel->getMemberSrl(); $member_srl = $oMemberModel->getLoggedMemberSrl();
// DB 객체 생성
$oDB = &DB::getInstance();
// 파일 정보를 정리 // 파일 정보를 정리
$args->file_srl = $oDB->getNextSequence(); $args->file_srl = $oDB->getNextSequence();
@ -55,9 +56,9 @@
$args->file_size = filesize($filename); $args->file_size = filesize($filename);
$args->comment = NULL; $args->comment = NULL;
$args->member_srl = $member_srl; $args->member_srl = $member_srl;
$args->sid = md5($args->source_filename); $args->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999)));
$output = $oDB->executeQuery('document.insertFile', $args); $output = $oDB->executeQuery('file.insertFile', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
$output->add('file_srl', $args->file_srl); $output->add('file_srl', $args->file_srl);
@ -74,7 +75,7 @@
// 파일 정보를 가져옴 // 파일 정보를 가져옴
$args->file_srl = $file_srl; $args->file_srl = $file_srl;
$output = $oDB->executeQuery('document.getFile', $args); $output = $oDB->executeQuery('file.getFile', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
$file_info = $output->data; $file_info = $output->data;
if(!$file_info) return new Object(-1, 'file_not_founded'); if(!$file_info) return new Object(-1, 'file_not_founded');
@ -83,7 +84,7 @@
$uploaded_filename = $output->data->uploaded_filename; $uploaded_filename = $output->data->uploaded_filename;
// DB에서 삭제 // DB에서 삭제
$output = $oDB->executeQuery('document.deleteFile', $args); $output = $oDB->executeQuery('file.deleteFile', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
// 삭제 성공하면 파일 삭제 // 삭제 성공하면 파일 삭제
@ -99,7 +100,7 @@
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$output = $oDB->executeQuery('document.deleteFiles', $args); $output = $oDB->executeQuery('file.deleteFiles', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
// 실제 파일 삭제 // 실제 파일 삭제
@ -119,7 +120,7 @@
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$args->module_srl = $module_srl; $args->module_srl = $module_srl;
$output = $oDB->executeQuery('document.deleteModuleFiles', $args); $output = $oDB->executeQuery('file.deleteModuleFiles', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
// 실제 파일 삭제 // 실제 파일 삭제

View file

@ -20,7 +20,7 @@
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$output = $oDB->executeQuery('document.getFilesCount', $args); $output = $oDB->executeQuery('file.getFilesCount', $args);
return (int)$output->data->count; return (int)$output->data->count;
} }
@ -31,7 +31,7 @@
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$args->file_srl = $file_srl; $args->file_srl = $file_srl;
$output = $oDB->executeQuery('document.getFile', $args); $output = $oDB->executeQuery('file.getFile', $args);
return $output->data; return $output->data;
} }
@ -43,7 +43,7 @@
$args->document_srl = $document_srl; $args->document_srl = $document_srl;
$args->sort_index = 'file_srl'; $args->sort_index = 'file_srl';
$output = $oDB->executeQuery('document.getFiles', $args); $output = $oDB->executeQuery('file.getFiles', $args);
$file_list = $output->data; $file_list = $output->data;
@ -73,7 +73,7 @@
// 이상이 없으면 download_count 증가 // 이상이 없으면 download_count 증가
$args->file_srl = $file_srl; $args->file_srl = $file_srl;
$oDB = &DB::getInstance(); $oDB = &DB::getInstance();
$oDB->executeQuery('document.updateFileDownloadCount', $args); $oDB->executeQuery('file.updateFileDownloadCount', $args);
// 파일 출력 // 파일 출력
$filename = $file_obj->source_filename; $filename = $file_obj->source_filename;