mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Xpresseditor에서 자동저장된 문서 첨부 파일 불러오기
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6498 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
567d648f5a
commit
d56181c9ec
9 changed files with 7877 additions and 7846 deletions
|
|
@ -1,397 +1,414 @@
|
|||
<?php
|
||||
/**
|
||||
* @class editor
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief editor 모듈의 controller class
|
||||
**/
|
||||
|
||||
class editorController extends editor {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 자동 저장
|
||||
**/
|
||||
function procEditorSaveDoc() {
|
||||
|
||||
$this->deleteSavedDoc();
|
||||
|
||||
$args->document_srl = Context::get('document_srl');
|
||||
$args->content = Context::get('content');
|
||||
$args->title = Context::get('title');
|
||||
$output = $this->doSaveDoc($args);
|
||||
|
||||
$this->setMessage('msg_auto_saved');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 자동저장된 문서 삭제
|
||||
**/
|
||||
function procEditorRemoveSavedDoc() {
|
||||
$oEditorController = &getController('editor');
|
||||
$oEditorController->deleteSavedDoc();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 컴포넌트에서 ajax요청시 해당 컴포넌트의 method를 실행
|
||||
**/
|
||||
function procEditorCall() {
|
||||
$component = Context::get('component');
|
||||
$method = Context::get('method');
|
||||
if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
|
||||
|
||||
$oEditorModel = &getModel('editor');
|
||||
$oComponent = &$oEditorModel->getComponentObject($component);
|
||||
if(!$oComponent->toBool()) return $oComponent;
|
||||
|
||||
if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
|
||||
|
||||
//$output = call_user_method($method, $oComponent);
|
||||
//$output = call_user_func(array($oComponent, $method));
|
||||
if(method_exists($oComponent, $method)) $output = $oComponent->{$method}();
|
||||
else return new Object(-1,sprintf('%s method is not exists', $method));
|
||||
|
||||
if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output;
|
||||
|
||||
$this->setError($oComponent->getError());
|
||||
$this->setMessage($oComponent->getMessage());
|
||||
|
||||
$vars = $oComponent->getVariables();
|
||||
if(count($vars)) {
|
||||
foreach($vars as $key=>$val) $this->add($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터의 모듈별 추가 확장 폼을 저장
|
||||
**/
|
||||
function procEditorInsertModuleConfig() {
|
||||
$module_srl = Context::get('target_module_srl');
|
||||
|
||||
// 여러개의 모듈 일괄 설정일 경우
|
||||
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
|
||||
else $module_srl = array($module_srl);
|
||||
|
||||
$editor_config = null;
|
||||
|
||||
$editor_config->editor_skin = Context::get('editor_skin');
|
||||
$editor_config->comment_editor_skin = Context::get('comment_editor_skin');
|
||||
$editor_config->content_style = Context::get('content_style');
|
||||
$editor_config->content_font = Context::get('content_font');
|
||||
if($editor_config->content_font) {
|
||||
$font_list = array();
|
||||
$fonts = explode(',',$editor_config->content_font);
|
||||
for($i=0,$c=count($fonts);$i<$c;$i++) {
|
||||
$font = trim(str_replace(array('"','\''),'',$fonts[$i]));
|
||||
if(!$font) continue;
|
||||
$font_list[] = $font;
|
||||
}
|
||||
if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"';
|
||||
}
|
||||
$editor_config->content_font_size = Context::get('content_font_size');
|
||||
$editor_config->sel_editor_colorset = Context::get('sel_editor_colorset');
|
||||
$editor_config->sel_comment_editor_colorset = Context::get('sel_comment_editor_colorset');
|
||||
|
||||
$enable_html_grant = trim(Context::get('enable_html_grant'));
|
||||
if($enable_html_grant) $editor_config->enable_html_grant = explode('|@|', $enable_html_grant);
|
||||
else $editor_config->enable_html_grant = array();
|
||||
|
||||
$enable_comment_html_grant = trim(Context::get('enable_comment_html_grant'));
|
||||
if($enable_comment_html_grant) $editor_config->enable_comment_html_grant = explode('|@|', $enable_comment_html_grant);
|
||||
else $editor_config->enable_comment_html_grant = array();
|
||||
|
||||
$upload_file_grant = trim(Context::get('upload_file_grant'));
|
||||
if($upload_file_grant) $editor_config->upload_file_grant = explode('|@|', $upload_file_grant);
|
||||
else $editor_config->upload_file_grant = array();
|
||||
|
||||
$comment_upload_file_grant = trim(Context::get('comment_upload_file_grant'));
|
||||
if($comment_upload_file_grant) $editor_config->comment_upload_file_grant = explode('|@|', $comment_upload_file_grant);
|
||||
else $editor_config->comment_upload_file_grant = array();
|
||||
|
||||
$enable_default_component_grant = trim(Context::get('enable_default_component_grant'));
|
||||
if($enable_default_component_grant) $editor_config->enable_default_component_grant = explode('|@|', $enable_default_component_grant);
|
||||
else $editor_config->enable_default_component_grant = array();
|
||||
|
||||
$enable_comment_default_component_grant = trim(Context::get('enable_comment_default_component_grant'));
|
||||
if($enable_comment_default_component_grant) $editor_config->enable_comment_default_component_grant = explode('|@|', $enable_comment_default_component_grant);
|
||||
else $editor_config->enable_comment_default_component_grant = array();
|
||||
|
||||
$enable_component_grant = trim(Context::get('enable_component_grant'));
|
||||
if($enable_component_grant) $editor_config->enable_component_grant = explode('|@|', $enable_component_grant);
|
||||
else $editor_config->enable_component_grant = array();
|
||||
|
||||
$enable_comment_component_grant = trim(Context::get('enable_comment_component_grant'));
|
||||
if($enable_comment_component_grant) $editor_config->enable_comment_component_grant = explode('|@|', $enable_comment_component_grant);
|
||||
else $editor_config->enable_comment_component_grant = array();
|
||||
|
||||
$editor_config->editor_height = (int)Context::get('editor_height');
|
||||
|
||||
$editor_config->comment_editor_height = (int)Context::get('comment_editor_height');
|
||||
|
||||
$editor_config->enable_autosave = Context::get('enable_autosave');
|
||||
|
||||
if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N';
|
||||
|
||||
$oModuleController = &getController('module');
|
||||
for($i=0;$i<count($module_srl);$i++) {
|
||||
$srl = trim($module_srl[$i]);
|
||||
if(!$srl) continue;
|
||||
$oModuleController->insertModulePartConfig('editor',$srl,$editor_config);
|
||||
}
|
||||
|
||||
$this->setError(-1);
|
||||
$this->setMessage('success_updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터컴포넌트의 코드를 결과물로 변환 + 문서서식 style 지정
|
||||
**/
|
||||
function triggerEditorComponentCompile(&$content) {
|
||||
if(Context::getResponseMethod()!='HTML') return new Object();
|
||||
|
||||
$module_info = Context::get('module_info');
|
||||
$module_srl = $module_info->module_srl;
|
||||
if($module_srl) {
|
||||
$oEditorModel = &getModel('editor');
|
||||
$editor_config = $oEditorModel->getEditorConfig($module_srl);
|
||||
$content_style = $editor_config->content_style;
|
||||
if($content_style) {
|
||||
$path = _XE_PATH_.'modules/editor/styles/'.$content_style.'/';
|
||||
if(is_dir($path) && file_exists($path.'style.ini')) {
|
||||
$ini = file($path.'style.ini');
|
||||
for($i=0,$c=count($ini);$i<$c;$i++) {
|
||||
$file = trim($ini[$i]);
|
||||
if(!$file) continue;
|
||||
if(preg_match('/\.css$/i',$file)) Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
elseif(preg_match('/\.js/i',$file)) Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
$content_font = $editor_config->content_font;
|
||||
$content_font_size = $editor_config->content_font_size;
|
||||
if($content_font || $content_font_size) {
|
||||
$buff = '<style type="text/css" charset="UTF-8"> .xe_content { ';
|
||||
if($content_font) $buff .= 'font-family:'.$content_font.';';
|
||||
if($content_font_size) $buff .= 'font-size:'.$content_font_size.';';
|
||||
$buff .= ' }; </style>';
|
||||
Context::addHtmlHeader($buff);
|
||||
}
|
||||
}
|
||||
|
||||
$content = $this->transComponent($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터 컴포넌트코드를 결과물로 변환
|
||||
**/
|
||||
function transComponent($content) {
|
||||
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($this,'transEditorComponent'), $content);
|
||||
$content = preg_replace_callback('!<img([^\>]*)editor_component=([^\>]*?)\>!is', array($this,'transEditorComponent'), $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 내용의 에디터 컴포넌트 코드를 변환
|
||||
**/
|
||||
function transEditorComponent($matches) {
|
||||
$script = sprintf(' %s editor_component=%s', $matches[1], $matches[2]);
|
||||
$script = preg_replace_callback('/([^=^"^ ]*)=([^ ^>]*)/i', fixQuotation, $script);
|
||||
preg_match_all('/([a-z0-9\-\_]+)\=\"([^\"]+)\"/is', $script, $m);
|
||||
for($i=0,$c=count($m[0]);$i<$c;$i++) {
|
||||
$xml_obj->attrs->{$m[1][$i]} = $m[2][$i];
|
||||
}
|
||||
$xml_obj->body = $matches[3];
|
||||
|
||||
if(!$xml_obj->attrs->editor_component) return $matches[0];
|
||||
|
||||
// component::transHTML() 을 이용하여 변환된 코드를 받음
|
||||
$oEditorModel = &getModel('editor');
|
||||
$oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0);
|
||||
if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $matches[0];
|
||||
|
||||
return $oComponent->transHTML($xml_obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 자동 저장
|
||||
**/
|
||||
function doSaveDoc($args) {
|
||||
|
||||
if(Context::get('is_logged')) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
} else {
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
// 저장
|
||||
return executeQuery('editor.insertSavedDoc', $args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 게시글의 입력/수정이 일어났을 경우 자동 저장문서를 제거하는 trigger
|
||||
**/
|
||||
function triggerDeleteSavedDoc(&$obj) {
|
||||
$this->deleteSavedDoc();
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 자동 저장된 글을 삭제
|
||||
* 현재 접속한 사용자를 기준
|
||||
**/
|
||||
function deleteSavedDoc() {
|
||||
if(Context::get('is_logged')) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
} else {
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
// 일단 이전 저장본 삭제
|
||||
return executeQuery('editor.deleteSavedDoc', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 가상 사이트에서 사용된 에디터 컴포넌트 정보를 제거
|
||||
**/
|
||||
function removeEditorConfig($site_srl) {
|
||||
$args->site_srl = $site_srl;
|
||||
executeQuery('editor.deleteSiteComponent', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터 컴포넌트 목록 캐싱 (editorModel::getComponentList)
|
||||
* 에디터 컴포넌트 목록의 경우 DB query + Xml Parsing 때문에 캐싱 파일을 이용하도록 함
|
||||
**/
|
||||
function makeCache($filter_enabled = true, $site_srl) {
|
||||
$oEditorModel = &getModel('editor');
|
||||
|
||||
if($filter_enabled) $args->enabled = "Y";
|
||||
|
||||
if($site_srl) {
|
||||
$args->site_srl = $site_srl;
|
||||
$output = executeQuery('editor.getSiteComponentList', $args);
|
||||
} else $output = executeQuery('editor.getComponentList', $args);
|
||||
$db_list = $output->data;
|
||||
|
||||
// 파일목록을 구함
|
||||
$downloaded_list = FileHandler::readDir(_XE_PATH_.'modules/editor/components');
|
||||
|
||||
// 로그인 여부 및 소속 그룹 구함
|
||||
$is_logged = Context::get('is_logged');
|
||||
if($is_logged) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->group_list && is_array($logged_info->group_list)) {
|
||||
$group_list = array_keys($logged_info->group_list);
|
||||
} else $group_list = array();
|
||||
}
|
||||
|
||||
// DB 목록을 loop돌면서 xml정보까지 구함
|
||||
if(!is_array($db_list)) $db_list = array($db_list);
|
||||
foreach($db_list as $component) {
|
||||
if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue;
|
||||
|
||||
$component_name = $component->component_name;
|
||||
if(!$component_name) continue;
|
||||
|
||||
if(!in_array($component_name, $downloaded_list)) continue;
|
||||
|
||||
unset($xml_info);
|
||||
$xml_info = $oEditorModel->getComponentXmlInfo($component_name);
|
||||
$xml_info->enabled = $component->enabled;
|
||||
|
||||
if($component->extra_vars) {
|
||||
$extra_vars = unserialize($component->extra_vars);
|
||||
|
||||
// 사용권한이 있으면 권한 체크
|
||||
if($extra_vars->target_group) {
|
||||
// 사용권한이 체크되어 있는데 로그인이 되어 있지 않으면 무조건 사용 중지
|
||||
if(!$is_logged) continue;
|
||||
|
||||
// 대상 그룹을 구해서 현재 로그인 사용자의 그룹과 비교
|
||||
$target_group = $extra_vars->target_group;
|
||||
unset($extra_vars->target_group);
|
||||
|
||||
$is_granted = false;
|
||||
foreach($group_list as $group_srl) {
|
||||
if(in_array($group_srl, $target_group)) {
|
||||
$is_granted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$is_granted) continue;
|
||||
}
|
||||
|
||||
// 대상 모듈이 있으면 체크
|
||||
if($extra_vars->mid_list && count($extra_vars->mid_list) && Context::get('mid')) {
|
||||
if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue;
|
||||
}
|
||||
|
||||
// 에디터 컴포넌트의 설정 정보를 체크
|
||||
if($xml_info->extra_vars) {
|
||||
foreach($xml_info->extra_vars as $key => $val) {
|
||||
$xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$component_list->{$component_name} = $xml_info;
|
||||
|
||||
// 버튼, 아이콘 이미지 구함
|
||||
$icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif';
|
||||
$component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif';
|
||||
if(file_exists($icon_file)) $component_list->{$component_name}->icon = true;
|
||||
if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true;
|
||||
}
|
||||
|
||||
// enabled만 체크하도록 하였으면 그냥 return
|
||||
if($filter_enabled) {
|
||||
$cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl);
|
||||
$buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list)));
|
||||
FileHandler::writeFile($cache_file, $buff);
|
||||
return $component_list;
|
||||
}
|
||||
|
||||
// 다운로드된 목록의 xml_info를 마저 구함
|
||||
foreach($downloaded_list as $component_name) {
|
||||
if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue;
|
||||
|
||||
// 설정된 것이라면 패스
|
||||
if($component_list->{$component_name}) continue;
|
||||
|
||||
// DB에 입력
|
||||
$oEditorController = &getAdminController('editor');
|
||||
$oEditorController->insertComponent($component_name, false, $site_srl);
|
||||
|
||||
// component_list에 추가
|
||||
unset($xml_info);
|
||||
$xml_info = $oEditorModel->getComponentXmlInfo($component_name);
|
||||
$xml_info->enabled = 'N';
|
||||
|
||||
$component_list->{$component_name} = $xml_info;
|
||||
}
|
||||
|
||||
$cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl);
|
||||
$buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list)));
|
||||
FileHandler::writeFile($cache_file, $buff);
|
||||
|
||||
return $component_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 캐시 파일 삭제
|
||||
**/
|
||||
function removeCache($site_srl = 0) {
|
||||
$oEditorModel = &getModel('editor');
|
||||
FileHandler::removeFile($oEditorModel->getCacheFile(true, $site_srl));
|
||||
FileHandler::removeFile($oEditorModel->getCacheFile(false, $site_srl));
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @class editor
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief editor 모듈의 controller class
|
||||
**/
|
||||
|
||||
class editorController extends editor {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 자동 저장
|
||||
**/
|
||||
function procEditorSaveDoc() {
|
||||
|
||||
$this->deleteSavedDoc();
|
||||
|
||||
$args->document_srl = Context::get('document_srl');
|
||||
$args->content = Context::get('content');
|
||||
$args->title = Context::get('title');
|
||||
$output = $this->doSaveDoc($args);
|
||||
|
||||
$this->setMessage('msg_auto_saved');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 자동저장된 문서 삭제
|
||||
**/
|
||||
function procEditorRemoveSavedDoc() {
|
||||
$oEditorController = &getController('editor');
|
||||
$oEditorController->deleteSavedDoc();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 컴포넌트에서 ajax요청시 해당 컴포넌트의 method를 실행
|
||||
**/
|
||||
function procEditorCall() {
|
||||
$component = Context::get('component');
|
||||
$method = Context::get('method');
|
||||
if(!$component) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
|
||||
|
||||
$oEditorModel = &getModel('editor');
|
||||
$oComponent = &$oEditorModel->getComponentObject($component);
|
||||
if(!$oComponent->toBool()) return $oComponent;
|
||||
|
||||
if(!method_exists($oComponent, $method)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
|
||||
|
||||
//$output = call_user_method($method, $oComponent);
|
||||
//$output = call_user_func(array($oComponent, $method));
|
||||
if(method_exists($oComponent, $method)) $output = $oComponent->{$method}();
|
||||
else return new Object(-1,sprintf('%s method is not exists', $method));
|
||||
|
||||
if((is_a($output, 'Object') || is_subclass_of($output, 'Object')) && !$output->toBool()) return $output;
|
||||
|
||||
$this->setError($oComponent->getError());
|
||||
$this->setMessage($oComponent->getMessage());
|
||||
|
||||
$vars = $oComponent->getVariables();
|
||||
if(count($vars)) {
|
||||
foreach($vars as $key=>$val) $this->add($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터의 모듈별 추가 확장 폼을 저장
|
||||
**/
|
||||
function procEditorInsertModuleConfig() {
|
||||
$module_srl = Context::get('target_module_srl');
|
||||
|
||||
// 여러개의 모듈 일괄 설정일 경우
|
||||
if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
|
||||
else $module_srl = array($module_srl);
|
||||
|
||||
$editor_config = null;
|
||||
|
||||
$editor_config->editor_skin = Context::get('editor_skin');
|
||||
$editor_config->comment_editor_skin = Context::get('comment_editor_skin');
|
||||
$editor_config->content_style = Context::get('content_style');
|
||||
$editor_config->content_font = Context::get('content_font');
|
||||
if($editor_config->content_font) {
|
||||
$font_list = array();
|
||||
$fonts = explode(',',$editor_config->content_font);
|
||||
for($i=0,$c=count($fonts);$i<$c;$i++) {
|
||||
$font = trim(str_replace(array('"','\''),'',$fonts[$i]));
|
||||
if(!$font) continue;
|
||||
$font_list[] = $font;
|
||||
}
|
||||
if(count($font_list)) $editor_config->content_font = '"'.implode('","',$font_list).'"';
|
||||
}
|
||||
$editor_config->content_font_size = Context::get('content_font_size');
|
||||
$editor_config->sel_editor_colorset = Context::get('sel_editor_colorset');
|
||||
$editor_config->sel_comment_editor_colorset = Context::get('sel_comment_editor_colorset');
|
||||
|
||||
$enable_html_grant = trim(Context::get('enable_html_grant'));
|
||||
if($enable_html_grant) $editor_config->enable_html_grant = explode('|@|', $enable_html_grant);
|
||||
else $editor_config->enable_html_grant = array();
|
||||
|
||||
$enable_comment_html_grant = trim(Context::get('enable_comment_html_grant'));
|
||||
if($enable_comment_html_grant) $editor_config->enable_comment_html_grant = explode('|@|', $enable_comment_html_grant);
|
||||
else $editor_config->enable_comment_html_grant = array();
|
||||
|
||||
$upload_file_grant = trim(Context::get('upload_file_grant'));
|
||||
if($upload_file_grant) $editor_config->upload_file_grant = explode('|@|', $upload_file_grant);
|
||||
else $editor_config->upload_file_grant = array();
|
||||
|
||||
$comment_upload_file_grant = trim(Context::get('comment_upload_file_grant'));
|
||||
if($comment_upload_file_grant) $editor_config->comment_upload_file_grant = explode('|@|', $comment_upload_file_grant);
|
||||
else $editor_config->comment_upload_file_grant = array();
|
||||
|
||||
$enable_default_component_grant = trim(Context::get('enable_default_component_grant'));
|
||||
if($enable_default_component_grant) $editor_config->enable_default_component_grant = explode('|@|', $enable_default_component_grant);
|
||||
else $editor_config->enable_default_component_grant = array();
|
||||
|
||||
$enable_comment_default_component_grant = trim(Context::get('enable_comment_default_component_grant'));
|
||||
if($enable_comment_default_component_grant) $editor_config->enable_comment_default_component_grant = explode('|@|', $enable_comment_default_component_grant);
|
||||
else $editor_config->enable_comment_default_component_grant = array();
|
||||
|
||||
$enable_component_grant = trim(Context::get('enable_component_grant'));
|
||||
if($enable_component_grant) $editor_config->enable_component_grant = explode('|@|', $enable_component_grant);
|
||||
else $editor_config->enable_component_grant = array();
|
||||
|
||||
$enable_comment_component_grant = trim(Context::get('enable_comment_component_grant'));
|
||||
if($enable_comment_component_grant) $editor_config->enable_comment_component_grant = explode('|@|', $enable_comment_component_grant);
|
||||
else $editor_config->enable_comment_component_grant = array();
|
||||
|
||||
$editor_config->editor_height = (int)Context::get('editor_height');
|
||||
|
||||
$editor_config->comment_editor_height = (int)Context::get('comment_editor_height');
|
||||
|
||||
$editor_config->enable_autosave = Context::get('enable_autosave');
|
||||
|
||||
if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N';
|
||||
|
||||
$oModuleController = &getController('module');
|
||||
for($i=0;$i<count($module_srl);$i++) {
|
||||
$srl = trim($module_srl[$i]);
|
||||
if(!$srl) continue;
|
||||
$oModuleController->insertModulePartConfig('editor',$srl,$editor_config);
|
||||
}
|
||||
|
||||
$this->setError(-1);
|
||||
$this->setMessage('success_updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터컴포넌트의 코드를 결과물로 변환 + 문서서식 style 지정
|
||||
**/
|
||||
function triggerEditorComponentCompile(&$content) {
|
||||
if(Context::getResponseMethod()!='HTML') return new Object();
|
||||
|
||||
$module_info = Context::get('module_info');
|
||||
$module_srl = $module_info->module_srl;
|
||||
if($module_srl) {
|
||||
$oEditorModel = &getModel('editor');
|
||||
$editor_config = $oEditorModel->getEditorConfig($module_srl);
|
||||
$content_style = $editor_config->content_style;
|
||||
if($content_style) {
|
||||
$path = _XE_PATH_.'modules/editor/styles/'.$content_style.'/';
|
||||
if(is_dir($path) && file_exists($path.'style.ini')) {
|
||||
$ini = file($path.'style.ini');
|
||||
for($i=0,$c=count($ini);$i<$c;$i++) {
|
||||
$file = trim($ini[$i]);
|
||||
if(!$file) continue;
|
||||
if(preg_match('/\.css$/i',$file)) Context::addCSSFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
elseif(preg_match('/\.js/i',$file)) Context::addJsFile('./modules/editor/styles/'.$content_style.'/'.$file, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
$content_font = $editor_config->content_font;
|
||||
$content_font_size = $editor_config->content_font_size;
|
||||
if($content_font || $content_font_size) {
|
||||
$buff = '<style type="text/css" charset="UTF-8"> .xe_content { ';
|
||||
if($content_font) $buff .= 'font-family:'.$content_font.';';
|
||||
if($content_font_size) $buff .= 'font-size:'.$content_font_size.';';
|
||||
$buff .= ' }; </style>';
|
||||
Context::addHtmlHeader($buff);
|
||||
}
|
||||
}
|
||||
|
||||
$content = $this->transComponent($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터 컴포넌트코드를 결과물로 변환
|
||||
**/
|
||||
function transComponent($content) {
|
||||
$content = preg_replace_callback('!<div([^\>]*)editor_component=([^\>]*)>(.*?)\<\/div\>!is', array($this,'transEditorComponent'), $content);
|
||||
$content = preg_replace_callback('!<img([^\>]*)editor_component=([^\>]*?)\>!is', array($this,'transEditorComponent'), $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 내용의 에디터 컴포넌트 코드를 변환
|
||||
**/
|
||||
function transEditorComponent($matches) {
|
||||
$script = sprintf(' %s editor_component=%s', $matches[1], $matches[2]);
|
||||
$script = preg_replace_callback('/([^=^"^ ]*)=([^ ^>]*)/i', fixQuotation, $script);
|
||||
preg_match_all('/([a-z0-9\-\_]+)\=\"([^\"]+)\"/is', $script, $m);
|
||||
for($i=0,$c=count($m[0]);$i<$c;$i++) {
|
||||
$xml_obj->attrs->{$m[1][$i]} = $m[2][$i];
|
||||
}
|
||||
$xml_obj->body = $matches[3];
|
||||
|
||||
if(!$xml_obj->attrs->editor_component) return $matches[0];
|
||||
|
||||
// component::transHTML() 을 이용하여 변환된 코드를 받음
|
||||
$oEditorModel = &getModel('editor');
|
||||
$oComponent = &$oEditorModel->getComponentObject($xml_obj->attrs->editor_component, 0);
|
||||
if(!is_object($oComponent)||!method_exists($oComponent, 'transHTML')) return $matches[0];
|
||||
|
||||
return $oComponent->transHTML($xml_obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 자동 저장
|
||||
**/
|
||||
function doSaveDoc($args) {
|
||||
|
||||
if(!$args->document_srl) $args->document_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
|
||||
if(Context::get('is_logged')) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
} else {
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
// 저장
|
||||
return executeQuery('editor.insertSavedDoc', $args);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 자동 저장글 로드
|
||||
**/
|
||||
function loadSaveDoc() {
|
||||
$editor_sequence = Context::get('editor_sequence');
|
||||
|
||||
$oEditorModel = &getModel('editor');
|
||||
$saved_doc = $oEditorModel->getSavedDoc(null);
|
||||
$vars = $this->getVariables();
|
||||
$this->add("title", $saved_doc->title);
|
||||
$this->add("content", $saved_doc->content);
|
||||
$this->add("document_srl", $saved_doc->document_srl);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 게시글의 입력/수정이 일어났을 경우 자동 저장문서를 제거하는 trigger
|
||||
**/
|
||||
function triggerDeleteSavedDoc(&$obj) {
|
||||
$this->deleteSavedDoc();
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 자동 저장된 글을 삭제
|
||||
* 현재 접속한 사용자를 기준
|
||||
**/
|
||||
function deleteSavedDoc() {
|
||||
if(Context::get('is_logged')) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
} else {
|
||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
// 일단 이전 저장본 삭제
|
||||
return executeQuery('editor.deleteSavedDoc', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 가상 사이트에서 사용된 에디터 컴포넌트 정보를 제거
|
||||
**/
|
||||
function removeEditorConfig($site_srl) {
|
||||
$args->site_srl = $site_srl;
|
||||
executeQuery('editor.deleteSiteComponent', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터 컴포넌트 목록 캐싱 (editorModel::getComponentList)
|
||||
* 에디터 컴포넌트 목록의 경우 DB query + Xml Parsing 때문에 캐싱 파일을 이용하도록 함
|
||||
**/
|
||||
function makeCache($filter_enabled = true, $site_srl) {
|
||||
$oEditorModel = &getModel('editor');
|
||||
|
||||
if($filter_enabled) $args->enabled = "Y";
|
||||
|
||||
if($site_srl) {
|
||||
$args->site_srl = $site_srl;
|
||||
$output = executeQuery('editor.getSiteComponentList', $args);
|
||||
} else $output = executeQuery('editor.getComponentList', $args);
|
||||
$db_list = $output->data;
|
||||
|
||||
// 파일목록을 구함
|
||||
$downloaded_list = FileHandler::readDir(_XE_PATH_.'modules/editor/components');
|
||||
|
||||
// 로그인 여부 및 소속 그룹 구함
|
||||
$is_logged = Context::get('is_logged');
|
||||
if($is_logged) {
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->group_list && is_array($logged_info->group_list)) {
|
||||
$group_list = array_keys($logged_info->group_list);
|
||||
} else $group_list = array();
|
||||
}
|
||||
|
||||
// DB 목록을 loop돌면서 xml정보까지 구함
|
||||
if(!is_array($db_list)) $db_list = array($db_list);
|
||||
foreach($db_list as $component) {
|
||||
if(in_array($component->component_name, array('colorpicker_text','colorpicker_bg'))) continue;
|
||||
|
||||
$component_name = $component->component_name;
|
||||
if(!$component_name) continue;
|
||||
|
||||
if(!in_array($component_name, $downloaded_list)) continue;
|
||||
|
||||
unset($xml_info);
|
||||
$xml_info = $oEditorModel->getComponentXmlInfo($component_name);
|
||||
$xml_info->enabled = $component->enabled;
|
||||
|
||||
if($component->extra_vars) {
|
||||
$extra_vars = unserialize($component->extra_vars);
|
||||
|
||||
// 사용권한이 있으면 권한 체크
|
||||
if($extra_vars->target_group) {
|
||||
// 사용권한이 체크되어 있는데 로그인이 되어 있지 않으면 무조건 사용 중지
|
||||
if(!$is_logged) continue;
|
||||
|
||||
// 대상 그룹을 구해서 현재 로그인 사용자의 그룹과 비교
|
||||
$target_group = $extra_vars->target_group;
|
||||
unset($extra_vars->target_group);
|
||||
|
||||
$is_granted = false;
|
||||
foreach($group_list as $group_srl) {
|
||||
if(in_array($group_srl, $target_group)) {
|
||||
$is_granted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$is_granted) continue;
|
||||
}
|
||||
|
||||
// 대상 모듈이 있으면 체크
|
||||
if($extra_vars->mid_list && count($extra_vars->mid_list) && Context::get('mid')) {
|
||||
if(!in_array(Context::get('mid'), $extra_vars->mid_list)) continue;
|
||||
}
|
||||
|
||||
// 에디터 컴포넌트의 설정 정보를 체크
|
||||
if($xml_info->extra_vars) {
|
||||
foreach($xml_info->extra_vars as $key => $val) {
|
||||
$xml_info->extra_vars->{$key}->value = $extra_vars->{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$component_list->{$component_name} = $xml_info;
|
||||
|
||||
// 버튼, 아이콘 이미지 구함
|
||||
$icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/icon.gif';
|
||||
$component_icon_file = _XE_PATH_.'modules/editor/components/'.$component_name.'/component_icon.gif';
|
||||
if(file_exists($icon_file)) $component_list->{$component_name}->icon = true;
|
||||
if(file_exists($component_icon_file)) $component_list->{$component_name}->component_icon = true;
|
||||
}
|
||||
|
||||
// enabled만 체크하도록 하였으면 그냥 return
|
||||
if($filter_enabled) {
|
||||
$cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl);
|
||||
$buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list)));
|
||||
FileHandler::writeFile($cache_file, $buff);
|
||||
return $component_list;
|
||||
}
|
||||
|
||||
// 다운로드된 목록의 xml_info를 마저 구함
|
||||
foreach($downloaded_list as $component_name) {
|
||||
if(in_array($component_name, array('colorpicker_text','colorpicker_bg'))) continue;
|
||||
|
||||
// 설정된 것이라면 패스
|
||||
if($component_list->{$component_name}) continue;
|
||||
|
||||
// DB에 입력
|
||||
$oEditorController = &getAdminController('editor');
|
||||
$oEditorController->insertComponent($component_name, false, $site_srl);
|
||||
|
||||
// component_list에 추가
|
||||
unset($xml_info);
|
||||
$xml_info = $oEditorModel->getComponentXmlInfo($component_name);
|
||||
$xml_info->enabled = 'N';
|
||||
|
||||
$component_list->{$component_name} = $xml_info;
|
||||
}
|
||||
|
||||
$cache_file = $oEditorModel->getCacheFile($filter_enabled, $site_srl);
|
||||
$buff = sprintf('<?php if(!defined("__ZBXE__")) exit(); $component_list = unserialize("%s"); ?>', str_replace('"','\\"',serialize($component_list)));
|
||||
FileHandler::writeFile($cache_file, $buff);
|
||||
|
||||
return $component_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 캐시 파일 삭제
|
||||
**/
|
||||
function removeCache($site_srl = 0) {
|
||||
$oEditorModel = &getModel('editor');
|
||||
FileHandler::removeFile($oEditorModel->getCacheFile(true, $site_srl));
|
||||
FileHandler::removeFile($oEditorModel->getCacheFile(false, $site_srl));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -28,6 +28,7 @@
|
|||
<!-- 자동저장용 폼 -->
|
||||
|
||||
<!--@if($enable_autosave)-->
|
||||
<input type="hidden" name="_saved_doc_srl" value="{$saved_doc->document_srl}" />
|
||||
<input type="hidden" name="_saved_doc_title" value="{htmlspecialchars($saved_doc->title)}" />
|
||||
<input type="hidden" name="_saved_doc_content" value="{htmlspecialchars($saved_doc->content)}" />
|
||||
<input type="hidden" name="_saved_doc_message" value="{$lang->msg_load_saved_doc}" />
|
||||
|
|
@ -483,8 +484,7 @@
|
|||
<!--%import("../../tpl/js/uploader.js",optimized=false)-->
|
||||
<!--%import("../../tpl/js/swfupload.js",optimized=false)-->
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
editorUploadInit(
|
||||
{
|
||||
var uploadSettingObj = {
|
||||
"editorSequence" : {$editor_sequence},
|
||||
"sessionName" : "{session_name()}",
|
||||
"allowedFileSize" : "{$file_config->allowed_filesize}",
|
||||
|
|
@ -495,7 +495,9 @@
|
|||
"fileListAreaID" : "uploaded_file_list_{$editor_sequence}",
|
||||
"previewAreaID" : "preview_uploaded_{$editor_sequence}",
|
||||
"uploaderStatusID" : "uploader_status_{$editor_sequence}"
|
||||
}
|
||||
};
|
||||
editorUploadInit(
|
||||
uploadSettingObj
|
||||
);
|
||||
//]]></script>
|
||||
<!-- 파일 업로드 영역 -->
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,277 +1,280 @@
|
|||
if (!window.xe) xe = {};
|
||||
|
||||
xe.Editors = [];
|
||||
|
||||
function editorStart_xe(editor_sequence, primary_key, content_key, editor_height, colorset, content_style, content_font, content_font_size) {
|
||||
if(typeof(colorset)=='undefined') colorset = 'white';
|
||||
if(typeof(content_style)=='undefined') content_style = 'xeStyle';
|
||||
if(typeof(content_font)=='undefined') content_font= '';
|
||||
if(typeof(content_font_size)=='undefined') content_font_size= '';
|
||||
|
||||
var target_src = request_uri+'modules/editor/styles/'+content_style+'/editor.html';
|
||||
|
||||
var textarea = jQuery("#xpress-editor-"+editor_sequence);
|
||||
var iframe = jQuery('<iframe id="editor_iframe_'+editor_sequence+'" allowTransparency="true" frameborder="0" src="'+target_src+'" scrolling="yes" style="width:100%;height:'+editor_height+'px">');
|
||||
var htmlsrc = jQuery('<textarea rows="10" cols="20" class="input_syntax '+colorset+'" style="display:none"></textarea>');
|
||||
var form = textarea.get(0).form;
|
||||
form.setAttribute('editor_sequence', editor_sequence);
|
||||
textarea.css("display","none");
|
||||
|
||||
var saved_content = '';
|
||||
if(jQuery("input[name=content]",form).size()>0){
|
||||
saved_content=jQuery("input[name=content]",form).val().replace(/src=\"files\/attach/g,'src="'+request_uri+'files/attach'); //'
|
||||
jQuery("#xpress-editor-"+editor_sequence).val(saved_content);
|
||||
}
|
||||
|
||||
/*
|
||||
// remove procFilter
|
||||
if(form.comment_srl){
|
||||
form.onsubmit=function(){
|
||||
var content = editorGetContent(editor_sequence);
|
||||
editorRelKeys[editor_sequence]['content'].value = content;
|
||||
insert_comment(form);
|
||||
return false;
|
||||
};
|
||||
}else{
|
||||
form.onsubmit=function(){
|
||||
var content = editorGetContent(editor_sequence);
|
||||
editorRelKeys[editor_sequence]['content'].value = content;
|
||||
insert(form);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
// hide textarea
|
||||
textarea.hide().css('width', '99%').before(iframe).after(htmlsrc);
|
||||
|
||||
// create an editor
|
||||
var oEditor = new xe.XpressCore();
|
||||
var oWYSIWYGIFrame = iframe.get(0);
|
||||
var oIRTextarea = textarea.get(0);
|
||||
var oHTMLSrcTextarea = htmlsrc.get(0);
|
||||
var elAppContainer = jQuery('.xpress-editor', form).get(0);
|
||||
|
||||
oEditor.getFrame = function(){ return oWYSIWYGIFrame;}
|
||||
|
||||
var content = form[content_key].value;
|
||||
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3).replace(/^\.\//,'');
|
||||
if(/^(http|https|ftp|telnet|mms|\/|\.\.)/i.test(val)) return m0;
|
||||
return m1+m2+request_uri+val+m4+m5;
|
||||
});
|
||||
|
||||
form[content_key].value = content;
|
||||
jQuery("#xpress-editor-"+editor_sequence).val(content);
|
||||
|
||||
// Set standard API
|
||||
editorRelKeys[editor_sequence] = new Array();
|
||||
editorRelKeys[editor_sequence]["primary"] = form[primary_key];
|
||||
editorRelKeys[editor_sequence]["content"] = form[content_key];
|
||||
editorRelKeys[editor_sequence]["func"] = editorGetContentTextarea_xe;
|
||||
editorRelKeys[editor_sequence]["editor"] = oEditor;
|
||||
editorRelKeys[editor_sequence]["pasteHTML"] = function(text){
|
||||
oEditor.exec('PASTE_HTML',[text]);
|
||||
}
|
||||
xe.Editors[editor_sequence] = oEditor;
|
||||
|
||||
// register plugins
|
||||
oEditor.registerPlugin(new xe.CorePlugin(null));
|
||||
|
||||
oEditor.registerPlugin(new xe.XE_PreservTemplate(jQuery("#xpress-editor-"+editor_sequence).val()));
|
||||
oEditor.registerPlugin(new xe.StringConverterManager());
|
||||
oEditor.registerPlugin(new xe.XE_EditingAreaManager("WYSIWYG", oIRTextarea, {nHeight:parseInt(editor_height), nMinHeight:205}, null, elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_EditingArea_HTMLSrc(oHTMLSrcTextarea));
|
||||
oEditor.registerPlugin(new xe.XE_EditingAreaVerticalResizer(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.Utils());
|
||||
oEditor.registerPlugin(new xe.DialogLayerManager());
|
||||
oEditor.registerPlugin(new xe.ActiveLayerManager());
|
||||
oEditor.registerPlugin(new xe.Hotkey());
|
||||
oEditor.registerPlugin(new xe.XE_WYSIWYGStyler());
|
||||
oEditor.registerPlugin(new xe.XE_WYSIWYGStyleGetter());
|
||||
oEditor.registerPlugin(new xe.MessageManager(oMessageMap));
|
||||
oEditor.registerPlugin(new xe.XE_Toolbar(elAppContainer));
|
||||
|
||||
oEditor.registerPlugin(new xe.XE_XHTMLFormatter);
|
||||
oEditor.registerPlugin(new xe.XE_GET_WYSYWYG_MODE(editor_sequence));
|
||||
oEditor.registerPlugin(new xe.XE_GET_WYSYWYG_CONTENT());
|
||||
|
||||
if(jQuery("ul.extra1").length) {
|
||||
oEditor.registerPlugin(new xe.XE_ColorPalette(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FontColor(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_BGColor(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_Quote(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FontNameWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FontSizeWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_LineHeightWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_UndoRedo());
|
||||
oEditor.registerPlugin(new xe.XE_Table(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_Hyperlink(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FindReplacePlugin(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FormatWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_SCharacter(elAppContainer));
|
||||
}
|
||||
|
||||
if(jQuery("ul.extra2").length) {
|
||||
oEditor.registerPlugin(new xe.XE_Extension(elAppContainer, editor_sequence));
|
||||
}
|
||||
|
||||
if(jQuery("ul.extra3").length) {
|
||||
oEditor.registerPlugin(new xe.XE_EditingModeToggler(elAppContainer));
|
||||
}
|
||||
|
||||
|
||||
//oEditor.registerPlugin(new xe.XE_Preview(elAppContainer));
|
||||
|
||||
if (!jQuery.browser.msie && !jQuery.browser.opera) {
|
||||
oEditor.registerPlugin(new xe.XE_WYSIWYGEnterKey(oWYSIWYGIFrame));
|
||||
}
|
||||
|
||||
// 자동 저장 사용
|
||||
if (s=form._saved_doc_title) {
|
||||
oEditor.registerPlugin(new xe.XE_AutoSave(oIRTextarea, elAppContainer));
|
||||
}
|
||||
|
||||
function load_proc() {
|
||||
try {
|
||||
var doc = oWYSIWYGIFrame.contentWindow.document, str;
|
||||
if (doc.location == 'about:blank') throw 'blank';
|
||||
|
||||
// get innerHTML
|
||||
str = doc.body.innerHTML;
|
||||
|
||||
// register plugin
|
||||
oEditor.registerPlugin(new xe.XE_EditingArea_WYSIWYG(oWYSIWYGIFrame));
|
||||
oEditor.registerPlugin(new xe.XpressRangeManager(oWYSIWYGIFrame));
|
||||
oEditor.registerPlugin(new xe.XE_ExecCommand(oWYSIWYGIFrame));
|
||||
|
||||
if(content_font && !doc.body.style.fontFamily) {
|
||||
doc.body.style.fontFamily = content_font;
|
||||
}
|
||||
if(content_font_size && !doc.body.style.fontSize) {
|
||||
doc.body.style.fontSize = content_font_size;
|
||||
}
|
||||
|
||||
// run
|
||||
oEditor.run();
|
||||
} catch(e) {
|
||||
setTimeout(load_proc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
load_proc();
|
||||
|
||||
return oEditor;
|
||||
}
|
||||
|
||||
function editorGetContentTextarea_xe(editor_sequence) {
|
||||
var oEditor = xe.Editors[editor_sequence] || null;
|
||||
|
||||
if (!oEditor) return '';
|
||||
|
||||
return oEditor.getIR();
|
||||
}
|
||||
|
||||
function editorGetIframe(srl) {
|
||||
return jQuery('iframe#editor_iframe_'+srl).get(0);
|
||||
}
|
||||
|
||||
function editorReplaceHTML(iframe_obj, content) {
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3).replace(/^\.\//,'');
|
||||
if(/^(http|https|ftp|telnet|mms|\/|\.\.)/i.test(val)) return m0;
|
||||
return m1+m2+request_uri+val+m4+m5;
|
||||
});
|
||||
|
||||
var srl = parseInt(iframe_obj.id.replace(/^.*_/,''),10);
|
||||
editorRelKeys[srl]["pasteHTML"](content);
|
||||
}
|
||||
|
||||
// WYSIWYG 모드를 저장하는 확장기능
|
||||
xe.XE_GET_WYSYWYG_MODE = jQuery.Class({
|
||||
name : "XE_GET_WYSYWYG_MODE",
|
||||
|
||||
$init : function(editor_sequence) {
|
||||
this.editor_sequence = editor_sequence;
|
||||
},
|
||||
|
||||
$ON_CHANGE_EDITING_MODE : function(mode) {
|
||||
editorMode[this.editor_sequence] = (mode =='HTMLSrc') ? 'html' : 'wysiwyg';
|
||||
}
|
||||
});
|
||||
|
||||
// 이미지등의 상대경로를 절대경로로 바꾸는 플러그인
|
||||
xe.XE_GET_WYSYWYG_CONTENT = jQuery.Class({
|
||||
name : "XE_GET_WYSYWYG_CONTENT",
|
||||
|
||||
$ON_MSG_APP_READY : function() {
|
||||
this.oApp.addConverter("IR_TO_WYSIWYG", this.TO_WYSIWYG_SET);
|
||||
this.oApp.addConverter("IR_TO_HTMLSrc", this.IR_TO_HTMLSrc);
|
||||
},
|
||||
|
||||
TO_WYSIWYG_SET : function(content) {
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3).replace(/^\.\//,'');
|
||||
if(/^(http|https|ftp|telnet|mms|\/|\.\.)/i.test(val)) return m0;
|
||||
return m1+m2+request_uri+val+m4+m5;
|
||||
});
|
||||
|
||||
return content;
|
||||
},
|
||||
|
||||
IR_TO_HTMLSrc : function(content) {
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>|\))*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
var uriReg = new RegExp('^'+request_uri.replace('\/','\\/'),'ig');
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3);
|
||||
if(uriReg.test(val)) val = val.replace(uriReg,'');
|
||||
else val = m3;
|
||||
return m1+m2+val+m4+m5;
|
||||
});
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// 서식 기본 내용을 보존
|
||||
xe.XE_PreservTemplate = jQuery.Class({
|
||||
name : "XE_PreservTemplate",
|
||||
isRun : false,
|
||||
|
||||
$BEFORE_SET_IR : function(content) {
|
||||
if(!this.isRun && !content) {
|
||||
this.isRun = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 미리보기 확장기능
|
||||
xe.XE_Preview = jQuery.Class({
|
||||
name : "XE_Preview",
|
||||
elPreviewButton : null,
|
||||
|
||||
$init : function(elAppContainer) {
|
||||
this._assignHTMLObjects(elAppContainer);
|
||||
},
|
||||
|
||||
_assignHTMLObjects : function(elAppContainer) {
|
||||
this.elPreviewButton = jQuery("BUTTON.xpress_xeditor_preview_button", elAppContainer);
|
||||
},
|
||||
|
||||
$ON_MSG_APP_READY : function() {
|
||||
this.oApp.registerBrowserEvent(this.elPreviewButton.get(0), "click", "EVENT_PREVIEW", []);
|
||||
},
|
||||
|
||||
$ON_EVENT_PREVIEW : function() {
|
||||
// TODO : 버튼이 눌렸을 때의 동작 정의
|
||||
}
|
||||
});
|
||||
if (!window.xe) xe = {};
|
||||
|
||||
xe.Editors = [];
|
||||
|
||||
function editorStart_xe(editor_sequence, primary_key, content_key, editor_height, colorset, content_style, content_font, content_font_size) {
|
||||
if(typeof(colorset)=='undefined') colorset = 'white';
|
||||
if(typeof(content_style)=='undefined') content_style = 'xeStyle';
|
||||
if(typeof(content_font)=='undefined') content_font= '';
|
||||
if(typeof(content_font_size)=='undefined') content_font_size= '';
|
||||
|
||||
var target_src = request_uri+'modules/editor/styles/'+content_style+'/editor.html';
|
||||
|
||||
var textarea = jQuery("#xpress-editor-"+editor_sequence);
|
||||
var iframe = jQuery('<iframe id="editor_iframe_'+editor_sequence+'" allowTransparency="true" frameborder="0" src="'+target_src+'" scrolling="yes" style="width:100%;height:'+editor_height+'px">');
|
||||
var htmlsrc = jQuery('<textarea rows="10" cols="20" class="input_syntax '+colorset+'" style="display:none"></textarea>');
|
||||
var form = textarea.get(0).form;
|
||||
form.setAttribute('editor_sequence', editor_sequence);
|
||||
textarea.css("display","none");
|
||||
|
||||
var saved_content = '';
|
||||
if(jQuery("input[name=content]",form).size()>0){
|
||||
saved_content=jQuery("input[name=content]",form).val().replace(/src=\"files\/attach/g,'src="'+request_uri+'files/attach'); //'
|
||||
jQuery("#xpress-editor-"+editor_sequence).val(saved_content);
|
||||
}
|
||||
|
||||
/*
|
||||
// remove procFilter
|
||||
if(form.comment_srl){
|
||||
form.onsubmit=function(){
|
||||
var content = editorGetContent(editor_sequence);
|
||||
editorRelKeys[editor_sequence]['content'].value = content;
|
||||
insert_comment(form);
|
||||
return false;
|
||||
};
|
||||
}else{
|
||||
form.onsubmit=function(){
|
||||
var content = editorGetContent(editor_sequence);
|
||||
editorRelKeys[editor_sequence]['content'].value = content;
|
||||
insert(form);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
// hide textarea
|
||||
textarea.hide().css('width', '99%').before(iframe).after(htmlsrc);
|
||||
|
||||
// create an editor
|
||||
var oEditor = new xe.XpressCore();
|
||||
var oWYSIWYGIFrame = iframe.get(0);
|
||||
var oIRTextarea = textarea.get(0);
|
||||
var oHTMLSrcTextarea = htmlsrc.get(0);
|
||||
var elAppContainer = jQuery('.xpress-editor', form).get(0);
|
||||
|
||||
oEditor.getFrame = function(){ return oWYSIWYGIFrame;}
|
||||
|
||||
var content = form[content_key].value;
|
||||
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3).replace(/^\.\//,'');
|
||||
if(/^(http|https|ftp|telnet|mms|\/|\.\.)/i.test(val)) return m0;
|
||||
return m1+m2+request_uri+val+m4+m5;
|
||||
});
|
||||
|
||||
form[content_key].value = content;
|
||||
jQuery("#xpress-editor-"+editor_sequence).val(content);
|
||||
|
||||
// Set standard API
|
||||
editorRelKeys[editor_sequence] = new Array();
|
||||
editorRelKeys[editor_sequence]["primary"] = form[primary_key];
|
||||
editorRelKeys[editor_sequence]["content"] = form[content_key];
|
||||
editorRelKeys[editor_sequence]["func"] = editorGetContentTextarea_xe;
|
||||
editorRelKeys[editor_sequence]["editor"] = oEditor;
|
||||
editorRelKeys[editor_sequence]["pasteHTML"] = function(text){
|
||||
oEditor.exec('PASTE_HTML',[text]);
|
||||
}
|
||||
xe.Editors[editor_sequence] = oEditor;
|
||||
|
||||
var response_tags = new Array("error","message","title","content","document_srl");
|
||||
exec_xml('editor',"loadSaveDoc", null, function (a,b,c) { editorRelKeys[editor_sequence]["primary"].value = a['document_srl']; }, response_tags, null);
|
||||
|
||||
// register plugins
|
||||
oEditor.registerPlugin(new xe.CorePlugin(null));
|
||||
|
||||
oEditor.registerPlugin(new xe.XE_PreservTemplate(jQuery("#xpress-editor-"+editor_sequence).val()));
|
||||
oEditor.registerPlugin(new xe.StringConverterManager());
|
||||
oEditor.registerPlugin(new xe.XE_EditingAreaManager("WYSIWYG", oIRTextarea, {nHeight:parseInt(editor_height), nMinHeight:205}, null, elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_EditingArea_HTMLSrc(oHTMLSrcTextarea));
|
||||
oEditor.registerPlugin(new xe.XE_EditingAreaVerticalResizer(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.Utils());
|
||||
oEditor.registerPlugin(new xe.DialogLayerManager());
|
||||
oEditor.registerPlugin(new xe.ActiveLayerManager());
|
||||
oEditor.registerPlugin(new xe.Hotkey());
|
||||
oEditor.registerPlugin(new xe.XE_WYSIWYGStyler());
|
||||
oEditor.registerPlugin(new xe.XE_WYSIWYGStyleGetter());
|
||||
oEditor.registerPlugin(new xe.MessageManager(oMessageMap));
|
||||
oEditor.registerPlugin(new xe.XE_Toolbar(elAppContainer));
|
||||
|
||||
oEditor.registerPlugin(new xe.XE_XHTMLFormatter);
|
||||
oEditor.registerPlugin(new xe.XE_GET_WYSYWYG_MODE(editor_sequence));
|
||||
oEditor.registerPlugin(new xe.XE_GET_WYSYWYG_CONTENT());
|
||||
|
||||
if(jQuery("ul.extra1").length) {
|
||||
oEditor.registerPlugin(new xe.XE_ColorPalette(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FontColor(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_BGColor(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_Quote(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FontNameWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FontSizeWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_LineHeightWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_UndoRedo());
|
||||
oEditor.registerPlugin(new xe.XE_Table(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_Hyperlink(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FindReplacePlugin(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_FormatWithSelectUI(elAppContainer));
|
||||
oEditor.registerPlugin(new xe.XE_SCharacter(elAppContainer));
|
||||
}
|
||||
|
||||
if(jQuery("ul.extra2").length) {
|
||||
oEditor.registerPlugin(new xe.XE_Extension(elAppContainer, editor_sequence));
|
||||
}
|
||||
|
||||
if(jQuery("ul.extra3").length) {
|
||||
oEditor.registerPlugin(new xe.XE_EditingModeToggler(elAppContainer));
|
||||
}
|
||||
|
||||
|
||||
//oEditor.registerPlugin(new xe.XE_Preview(elAppContainer));
|
||||
|
||||
if (!jQuery.browser.msie && !jQuery.browser.opera) {
|
||||
oEditor.registerPlugin(new xe.XE_WYSIWYGEnterKey(oWYSIWYGIFrame));
|
||||
}
|
||||
|
||||
// 자동 저장 사용
|
||||
if (s=form._saved_doc_title) {
|
||||
oEditor.registerPlugin(new xe.XE_AutoSave(oIRTextarea, elAppContainer));
|
||||
}
|
||||
|
||||
function load_proc() {
|
||||
try {
|
||||
var doc = oWYSIWYGIFrame.contentWindow.document, str;
|
||||
if (doc.location == 'about:blank') throw 'blank';
|
||||
|
||||
// get innerHTML
|
||||
str = doc.body.innerHTML;
|
||||
|
||||
// register plugin
|
||||
oEditor.registerPlugin(new xe.XE_EditingArea_WYSIWYG(oWYSIWYGIFrame));
|
||||
oEditor.registerPlugin(new xe.XpressRangeManager(oWYSIWYGIFrame));
|
||||
oEditor.registerPlugin(new xe.XE_ExecCommand(oWYSIWYGIFrame));
|
||||
|
||||
if(content_font && !doc.body.style.fontFamily) {
|
||||
doc.body.style.fontFamily = content_font;
|
||||
}
|
||||
if(content_font_size && !doc.body.style.fontSize) {
|
||||
doc.body.style.fontSize = content_font_size;
|
||||
}
|
||||
|
||||
// run
|
||||
oEditor.run();
|
||||
} catch(e) {
|
||||
setTimeout(load_proc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
load_proc();
|
||||
|
||||
return oEditor;
|
||||
}
|
||||
|
||||
function editorGetContentTextarea_xe(editor_sequence) {
|
||||
var oEditor = xe.Editors[editor_sequence] || null;
|
||||
|
||||
if (!oEditor) return '';
|
||||
|
||||
return oEditor.getIR();
|
||||
}
|
||||
|
||||
function editorGetIframe(srl) {
|
||||
return jQuery('iframe#editor_iframe_'+srl).get(0);
|
||||
}
|
||||
|
||||
function editorReplaceHTML(iframe_obj, content) {
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3).replace(/^\.\//,'');
|
||||
if(/^(http|https|ftp|telnet|mms|\/|\.\.)/i.test(val)) return m0;
|
||||
return m1+m2+request_uri+val+m4+m5;
|
||||
});
|
||||
|
||||
var srl = parseInt(iframe_obj.id.replace(/^.*_/,''),10);
|
||||
editorRelKeys[srl]["pasteHTML"](content);
|
||||
}
|
||||
|
||||
// WYSIWYG 모드를 저장하는 확장기능
|
||||
xe.XE_GET_WYSYWYG_MODE = jQuery.Class({
|
||||
name : "XE_GET_WYSYWYG_MODE",
|
||||
|
||||
$init : function(editor_sequence) {
|
||||
this.editor_sequence = editor_sequence;
|
||||
},
|
||||
|
||||
$ON_CHANGE_EDITING_MODE : function(mode) {
|
||||
editorMode[this.editor_sequence] = (mode =='HTMLSrc') ? 'html' : 'wysiwyg';
|
||||
}
|
||||
});
|
||||
|
||||
// 이미지등의 상대경로를 절대경로로 바꾸는 플러그인
|
||||
xe.XE_GET_WYSYWYG_CONTENT = jQuery.Class({
|
||||
name : "XE_GET_WYSYWYG_CONTENT",
|
||||
|
||||
$ON_MSG_APP_READY : function() {
|
||||
this.oApp.addConverter("IR_TO_WYSIWYG", this.TO_WYSIWYG_SET);
|
||||
this.oApp.addConverter("IR_TO_HTMLSrc", this.IR_TO_HTMLSrc);
|
||||
},
|
||||
|
||||
TO_WYSIWYG_SET : function(content) {
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>)*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3).replace(/^\.\//,'');
|
||||
if(/^(http|https|ftp|telnet|mms|\/|\.\.)/i.test(val)) return m0;
|
||||
return m1+m2+request_uri+val+m4+m5;
|
||||
});
|
||||
|
||||
return content;
|
||||
},
|
||||
|
||||
IR_TO_HTMLSrc : function(content) {
|
||||
// src, href, url의 XE 상대경로를 http로 시작하는 full path로 변경
|
||||
content = content.replace(/(src=|href=|url\()("|\')*([^"\'\)]+)("|\'|\))*(\s|>|\))*/ig, function(m0,m1,m2,m3,m4,m5) {
|
||||
var uriReg = new RegExp('^'+request_uri.replace('\/','\\/'),'ig');
|
||||
if(m1=="url(") { m2=''; m4=')'; } else { if(typeof(m2)=='undefined') m2 = '"'; if(typeof(m4)=='undefined') m4 = '"'; if(typeof(m5)=='undefined') m5 = ''; }
|
||||
var val = jQuery.trim(m3);
|
||||
if(uriReg.test(val)) val = val.replace(uriReg,'');
|
||||
else val = m3;
|
||||
return m1+m2+val+m4+m5;
|
||||
});
|
||||
return content;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// 서식 기본 내용을 보존
|
||||
xe.XE_PreservTemplate = jQuery.Class({
|
||||
name : "XE_PreservTemplate",
|
||||
isRun : false,
|
||||
|
||||
$BEFORE_SET_IR : function(content) {
|
||||
if(!this.isRun && !content) {
|
||||
this.isRun = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 미리보기 확장기능
|
||||
xe.XE_Preview = jQuery.Class({
|
||||
name : "XE_Preview",
|
||||
elPreviewButton : null,
|
||||
|
||||
$init : function(elAppContainer) {
|
||||
this._assignHTMLObjects(elAppContainer);
|
||||
},
|
||||
|
||||
_assignHTMLObjects : function(elAppContainer) {
|
||||
this.elPreviewButton = jQuery("BUTTON.xpress_xeditor_preview_button", elAppContainer);
|
||||
},
|
||||
|
||||
$ON_MSG_APP_READY : function() {
|
||||
this.oApp.registerBrowserEvent(this.elPreviewButton.get(0), "click", "EVENT_PREVIEW", []);
|
||||
},
|
||||
|
||||
$ON_EVENT_PREVIEW : function() {
|
||||
// TODO : 버튼이 눌렸을 때의 동작 정의
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,41 +1,41 @@
|
|||
function editorStartTextarea(editor_sequence, content_key, primary_key) {
|
||||
var obj = xGetElementById('editor_'+editor_sequence);
|
||||
var use_html = xGetElementById('htm_'+editor_sequence).value;
|
||||
obj.form.setAttribute('editor_sequence', editor_sequence);
|
||||
|
||||
obj.style.width = '99%';
|
||||
|
||||
editorRelKeys[editor_sequence] = new Array();
|
||||
editorRelKeys[editor_sequence]["primary"] = obj.form[primary_key];
|
||||
editorRelKeys[editor_sequence]["content"] = obj.form[content_key];
|
||||
editorRelKeys[editor_sequence]["func"] = editorGetContentTextarea;
|
||||
|
||||
var content = obj.form[content_key].value;
|
||||
if(use_html) {
|
||||
content = content.replace(/<br([^>]*)>/ig,"\n");
|
||||
if(use_html!='br') {
|
||||
content = content.replace(/</g, "<");
|
||||
content = content.replace(/>/g, ">");
|
||||
content = content.replace(/"/g, '"');
|
||||
content = content.replace(/&/g, "&");
|
||||
}
|
||||
}
|
||||
obj.value = content;
|
||||
}
|
||||
|
||||
function editorGetContentTextarea(editor_sequence) {
|
||||
var obj = xGetElementById('editor_'+editor_sequence);
|
||||
var use_html = xGetElementById('htm_'+editor_sequence).value;
|
||||
var content = obj.value.trim();
|
||||
if(use_html) {
|
||||
if(use_html!='br') {
|
||||
content = content.replace(/&/g, "&");
|
||||
content = content.replace(/</g, "<");
|
||||
content = content.replace(/>/g, ">");
|
||||
content = content.replace(/\"/g, """);
|
||||
}
|
||||
content = content.replace(/(\r\n|\n)/g, "<br />");
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
function editorStartTextarea(editor_sequence, content_key, primary_key) {
|
||||
var obj = xGetElementById('editor_'+editor_sequence);
|
||||
var use_html = xGetElementById('htm_'+editor_sequence).value;
|
||||
obj.form.setAttribute('editor_sequence', editor_sequence);
|
||||
|
||||
obj.style.width = '99%';
|
||||
|
||||
editorRelKeys[editor_sequence] = new Array();
|
||||
editorRelKeys[editor_sequence]["primary"] = obj.form[primary_key];
|
||||
editorRelKeys[editor_sequence]["content"] = obj.form[content_key];
|
||||
editorRelKeys[editor_sequence]["func"] = editorGetContentTextarea;
|
||||
|
||||
var content = obj.form[content_key].value;
|
||||
if(use_html) {
|
||||
content = content.replace(/<br([^>]*)>/ig,"\n");
|
||||
if(use_html!='br') {
|
||||
content = content.replace(/</g, "<");
|
||||
content = content.replace(/>/g, ">");
|
||||
content = content.replace(/"/g, '"');
|
||||
content = content.replace(/&/g, "&");
|
||||
}
|
||||
}
|
||||
obj.value = content;
|
||||
}
|
||||
|
||||
function editorGetContentTextarea(editor_sequence) {
|
||||
var obj = xGetElementById('editor_'+editor_sequence);
|
||||
var use_html = xGetElementById('htm_'+editor_sequence).value;
|
||||
var content = obj.value.trim();
|
||||
if(use_html) {
|
||||
if(use_html!='br') {
|
||||
content = content.replace(/&/g, "&");
|
||||
content = content.replace(/</g, "<");
|
||||
content = content.replace(/>/g, ">");
|
||||
content = content.replace(/\"/g, """);
|
||||
}
|
||||
content = content.replace(/(\r\n|\n)/g, "<br />");
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,110 +1,110 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<skin version="0.2">
|
||||
<title xml:lang="ko">XpressEditor Skin</title>
|
||||
<title xml:lang="es">XpressEditor Skin</title>
|
||||
<title xml:lang="en">XpressEditor Skin</title>
|
||||
<title xml:lang="jp">XpressEditorスキン</title>
|
||||
<title xml:lang="zh-CN">XpressEditor皮肤</title>
|
||||
<title xml:lang="zh-TW">XpressEditor面板</title>
|
||||
<description xml:lang="ko">
|
||||
XpressEditor based on SmartEditor Basic by 행복한고니
|
||||
</description>
|
||||
<description xml:lang="en">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="es">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="jp">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="zh-CN">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="zh-TW">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<version>0.3.16</version>
|
||||
<date>2009-03-22</date>
|
||||
<author email_address="gonom9@gmail.com" link="http://mygony.com">
|
||||
<name xml:lang="ko">행복한고니</name>
|
||||
<name xml:lang="es">gony</name>
|
||||
<name xml:lang="en">gony</name>
|
||||
<name xml:lang="jp">gony</name>
|
||||
<name xml:lang="zh-CN">gony</name>
|
||||
<name xml:lang="zh-TW">gony</name>
|
||||
</author>
|
||||
<colorset>
|
||||
<color name="white">
|
||||
<title xml:lang="ko">하얀색(기본)</title>
|
||||
<title xml:lang="jp">白(デフォルト)</title>
|
||||
<title xml:lang="zh-CN">白色(基本)</title>
|
||||
<title xml:lang="en">White (default)</title>
|
||||
<title xml:lang="es">Blanco (por defecto)</title>
|
||||
<title xml:lang="zh-TW">白色(預設)</title>
|
||||
</color>
|
||||
<color name="black">
|
||||
<title xml:lang="ko">검은색</title>
|
||||
<title xml:lang="jp">黒</title>
|
||||
<title xml:lang="en">Black</title>
|
||||
<title xml:lang="ru">Черного</title>
|
||||
<title xml:lang="es">Negro</title>
|
||||
<title xml:lang="zh-CN">黑色</title>
|
||||
<title xml:lang="zh-TW">黑色</title>
|
||||
</color>
|
||||
<color name="white_texteditor">
|
||||
<title xml:lang="ko">하얀색 텍스트편집기(자동 줄 바꿈)</title>
|
||||
<title xml:lang="jp">白色テキストエディター(自動に改行を入れる)</title>
|
||||
<title xml:lang="en">White Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="ru">White Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="es">Editor de texto en blanco (Auto de línea)</title>
|
||||
<title xml:lang="zh-CN">白色文本编辑器(自动换行)</title>
|
||||
<title xml:lang="zh-TW">白色文字編輯器(Auto Line Break)</title>
|
||||
</color>
|
||||
<color name="black_texteditor">
|
||||
<title xml:lang="ko">검은색 텍스트편집기(자동 줄 바꿈)</title>
|
||||
<title xml:lang="jp">黒色テキストエディター(自動に改行を入れる)</title>
|
||||
<title xml:lang="en">Black Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="ru">Black Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="es">Editor de texto negro (salto de línea automático)</title>
|
||||
<title xml:lang="zh-CN">黑色文本编辑器(自动换行)</title>
|
||||
<title xml:lang="zh-TW">黑色文字編輯器(Auto Line Break)</title>
|
||||
</color>
|
||||
<color name="white_text_usehtml">
|
||||
<title xml:lang="ko">하얀색 텍스트편집기(HTML 사용)</title>
|
||||
<title xml:lang="jp">白色テキストエディター(HTMLタグを使う)</title>
|
||||
<title xml:lang="en">White Text Editor(Use HTML)</title>
|
||||
<title xml:lang="ru">White Text Editor(Use HTML)</title>
|
||||
<title xml:lang="es">Editor de texto en blanco (Uso de HTML)</title>
|
||||
<title xml:lang="zh-CN">白色文本编辑器(使用HTML)</title>
|
||||
<title xml:lang="zh-TW">白色文字編輯器(Use HTML)</title>
|
||||
</color>
|
||||
<color name="black_text_usehtml">
|
||||
<title xml:lang="ko">검은색 텍스트편집기(HTML 사용)</title>
|
||||
<title xml:lang="jp">黒色テキストエディター(HTMLタグを使う)</title>
|
||||
<title xml:lang="en">Black Text Editor(Use HTML)</title>
|
||||
<title xml:lang="ru">Black Text Editor(Use HTML)</title>
|
||||
<title xml:lang="es">Editor de texto negro (Uso de HTML)</title>
|
||||
<title xml:lang="zh-CN">黑色文本编辑器(使用HTML)</title>
|
||||
<title xml:lang="zh-TW">黑色文字編輯器(Use HTML)</title>
|
||||
</color>
|
||||
<color name="white_text_nohtml">
|
||||
<title xml:lang="ko">하얀색 텍스트편집기(HTML 사용 안함)</title>
|
||||
<title xml:lang="jp">白色テキストエディター(HTMLタグを使わない)</title>
|
||||
<title xml:lang="en">White Text Editor(No HTML)</title>
|
||||
<title xml:lang="ru">White Text Editor(No HTML)</title>
|
||||
<title xml:lang="es">Editor de texto en blanco (no HTML)</title>
|
||||
<title xml:lang="zh-CN">白色文本编辑器(不使用HTML)</title>
|
||||
<title xml:lang="zh-TW">白色文字編輯器(No HTML)</title>
|
||||
</color>
|
||||
<color name="black_text_nohtml">
|
||||
<title xml:lang="ko">검은색 텍스트편집기(HTML 사용 안함)</title>
|
||||
<title xml:lang="jp">黒色テキストエディター(HTMLタグを使わない)</title>
|
||||
<title xml:lang="en">Black Text Editor(No HTML)</title>
|
||||
<title xml:lang="ru">Black Text Editor(No HTML)</title>
|
||||
<title xml:lang="es">Editor de texto negro (no HTML)</title>
|
||||
<title xml:lang="zh-CN">黑色文本编辑器(不使用HTML)</title>
|
||||
<title xml:lang="zh-TW">黑色文字編輯器(No HTML)</title>
|
||||
</color>
|
||||
</colorset>
|
||||
</skin>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<skin version="0.2">
|
||||
<title xml:lang="ko">XpressEditor Skin</title>
|
||||
<title xml:lang="es">XpressEditor Skin</title>
|
||||
<title xml:lang="en">XpressEditor Skin</title>
|
||||
<title xml:lang="jp">XpressEditorスキン</title>
|
||||
<title xml:lang="zh-CN">XpressEditor皮肤</title>
|
||||
<title xml:lang="zh-TW">XpressEditor面板</title>
|
||||
<description xml:lang="ko">
|
||||
XpressEditor based on SmartEditor Basic by 행복한고니
|
||||
</description>
|
||||
<description xml:lang="en">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="es">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="jp">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="zh-CN">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<description xml:lang="zh-TW">
|
||||
XpressEditor based on SmartEditor Basic by gony
|
||||
</description>
|
||||
<version>0.3.16</version>
|
||||
<date>2009-03-22</date>
|
||||
<author email_address="gonom9@gmail.com" link="http://mygony.com">
|
||||
<name xml:lang="ko">행복한고니</name>
|
||||
<name xml:lang="es">gony</name>
|
||||
<name xml:lang="en">gony</name>
|
||||
<name xml:lang="jp">gony</name>
|
||||
<name xml:lang="zh-CN">gony</name>
|
||||
<name xml:lang="zh-TW">gony</name>
|
||||
</author>
|
||||
<colorset>
|
||||
<color name="white">
|
||||
<title xml:lang="ko">하얀색(기본)</title>
|
||||
<title xml:lang="jp">白(デフォルト)</title>
|
||||
<title xml:lang="zh-CN">白色(基本)</title>
|
||||
<title xml:lang="en">White (default)</title>
|
||||
<title xml:lang="es">Blanco (por defecto)</title>
|
||||
<title xml:lang="zh-TW">白色(預設)</title>
|
||||
</color>
|
||||
<color name="black">
|
||||
<title xml:lang="ko">검은색</title>
|
||||
<title xml:lang="jp">黒</title>
|
||||
<title xml:lang="en">Black</title>
|
||||
<title xml:lang="ru">Черного</title>
|
||||
<title xml:lang="es">Negro</title>
|
||||
<title xml:lang="zh-CN">黑色</title>
|
||||
<title xml:lang="zh-TW">黑色</title>
|
||||
</color>
|
||||
<color name="white_texteditor">
|
||||
<title xml:lang="ko">하얀색 텍스트편집기(자동 줄 바꿈)</title>
|
||||
<title xml:lang="jp">白色テキストエディター(自動に改行を入れる)</title>
|
||||
<title xml:lang="en">White Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="ru">White Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="es">Editor de texto en blanco (Auto de línea)</title>
|
||||
<title xml:lang="zh-CN">白色文本编辑器(自动换行)</title>
|
||||
<title xml:lang="zh-TW">白色文字編輯器(Auto Line Break)</title>
|
||||
</color>
|
||||
<color name="black_texteditor">
|
||||
<title xml:lang="ko">검은색 텍스트편집기(자동 줄 바꿈)</title>
|
||||
<title xml:lang="jp">黒色テキストエディター(自動に改行を入れる)</title>
|
||||
<title xml:lang="en">Black Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="ru">Black Text Editor(Auto Line Break)</title>
|
||||
<title xml:lang="es">Editor de texto negro (salto de línea automático)</title>
|
||||
<title xml:lang="zh-CN">黑色文本编辑器(自动换行)</title>
|
||||
<title xml:lang="zh-TW">黑色文字編輯器(Auto Line Break)</title>
|
||||
</color>
|
||||
<color name="white_text_usehtml">
|
||||
<title xml:lang="ko">하얀색 텍스트편집기(HTML 사용)</title>
|
||||
<title xml:lang="jp">白色テキストエディター(HTMLタグを使う)</title>
|
||||
<title xml:lang="en">White Text Editor(Use HTML)</title>
|
||||
<title xml:lang="ru">White Text Editor(Use HTML)</title>
|
||||
<title xml:lang="es">Editor de texto en blanco (Uso de HTML)</title>
|
||||
<title xml:lang="zh-CN">白色文本编辑器(使用HTML)</title>
|
||||
<title xml:lang="zh-TW">白色文字編輯器(Use HTML)</title>
|
||||
</color>
|
||||
<color name="black_text_usehtml">
|
||||
<title xml:lang="ko">검은색 텍스트편집기(HTML 사용)</title>
|
||||
<title xml:lang="jp">黒色テキストエディター(HTMLタグを使う)</title>
|
||||
<title xml:lang="en">Black Text Editor(Use HTML)</title>
|
||||
<title xml:lang="ru">Black Text Editor(Use HTML)</title>
|
||||
<title xml:lang="es">Editor de texto negro (Uso de HTML)</title>
|
||||
<title xml:lang="zh-CN">黑色文本编辑器(使用HTML)</title>
|
||||
<title xml:lang="zh-TW">黑色文字編輯器(Use HTML)</title>
|
||||
</color>
|
||||
<color name="white_text_nohtml">
|
||||
<title xml:lang="ko">하얀색 텍스트편집기(HTML 사용 안함)</title>
|
||||
<title xml:lang="jp">白色テキストエディター(HTMLタグを使わない)</title>
|
||||
<title xml:lang="en">White Text Editor(No HTML)</title>
|
||||
<title xml:lang="ru">White Text Editor(No HTML)</title>
|
||||
<title xml:lang="es">Editor de texto en blanco (no HTML)</title>
|
||||
<title xml:lang="zh-CN">白色文本编辑器(不使用HTML)</title>
|
||||
<title xml:lang="zh-TW">白色文字編輯器(No HTML)</title>
|
||||
</color>
|
||||
<color name="black_text_nohtml">
|
||||
<title xml:lang="ko">검은색 텍스트편집기(HTML 사용 안함)</title>
|
||||
<title xml:lang="jp">黒色テキストエディター(HTMLタグを使わない)</title>
|
||||
<title xml:lang="en">Black Text Editor(No HTML)</title>
|
||||
<title xml:lang="ru">Black Text Editor(No HTML)</title>
|
||||
<title xml:lang="es">Editor de texto negro (no HTML)</title>
|
||||
<title xml:lang="zh-CN">黑色文本编辑器(不使用HTML)</title>
|
||||
<title xml:lang="zh-TW">黑色文字編輯器(No HTML)</title>
|
||||
</color>
|
||||
</colorset>
|
||||
</skin>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ var swfUploadObjs = new Array();
|
|||
* 이 함수는 editor.html 에서 파일 업로드 가능할 경우 호출됨
|
||||
**/
|
||||
// window.load 이벤트일 경우 && 문서 번호가 가상의 번호가 아니면 기존에 저장되어 있을지도 모르는 파일 목록을 가져옴
|
||||
function editorUploadInit(obj) {
|
||||
function editorUploadInit(obj, exe) {
|
||||
if(typeof(obj["editorSequence"])=="undefined") return;
|
||||
if(typeof(obj["sessionName"])=="undefined") obj["sessionName"]= "PHPSESSID";
|
||||
if(typeof(obj["allowedFileSize"])=="undefined") obj["allowedFileSize"]= 2*1024*1024;
|
||||
|
|
@ -22,6 +22,7 @@ function editorUploadInit(obj) {
|
|||
if(typeof(obj["replaceButtonID"])=="undefined") obj["replaceButtonID"] = "swfUploadButton"+obj["editorSequence"];
|
||||
if(typeof(obj["insertedFiles"])=="undefined") obj["insertedFiles"] = 0;
|
||||
xAddEventListener(window,"load",function() { XEUploaderStart(obj) });
|
||||
if(exe) XEUploaderStart(obj);
|
||||
}
|
||||
|
||||
// 파일 업로드를 위한 기본 준비를 함
|
||||
|
|
@ -87,7 +88,7 @@ function XEUploaderStart(obj) {
|
|||
settings["previewAreaID"] = obj["previewAreaID"];
|
||||
settings["uploaderStatusID"] = obj["uploaderStatusID"];
|
||||
|
||||
uploaderSettings[obj["editorSequence"]] = settings;
|
||||
uploaderSettings[obj["editorSequence"]] = settings;
|
||||
|
||||
var swfu = new SWFUpload(settings);
|
||||
var swfObj = xGetElementById(swfu.movieName);
|
||||
|
|
@ -102,7 +103,7 @@ function XEUploaderStart(obj) {
|
|||
swfObj.style.width = btnWidth+"px";
|
||||
swfObj.style.height = btnHeight+"px";
|
||||
|
||||
if(obj["insertedFiles"]>0) reloadFileList(settings);
|
||||
if(obj["insertedFiles"]>0 || editorRelKeys[obj["editorSequence"]]["primary"].value > 0) reloadFileList(settings);
|
||||
}
|
||||
|
||||
function fileQueued(file) {
|
||||
|
|
@ -224,7 +225,7 @@ function queueComplete(numFilesUploaded) {
|
|||
}
|
||||
|
||||
function reloadFileList(settings) {
|
||||
var params = new Array();
|
||||
var params = new Array();
|
||||
params["file_list_area_id"] = settings["fileListAreaID"];
|
||||
params["editor_sequence"] = settings["editorSequence"];
|
||||
params["mid"] = current_mid;
|
||||
|
|
|
|||
|
|
@ -1,211 +1,214 @@
|
|||
<?php
|
||||
/**
|
||||
* @class fileModel
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief file 모듈의 model 클래스
|
||||
**/
|
||||
|
||||
class fileModel extends file {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 첨부파일 목록을 return
|
||||
**/
|
||||
function getFileList() {
|
||||
|
||||
$mid = Context::get("mid");
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleInfoByMid($mid);
|
||||
Context::set("module_srl",$config->module_srl);
|
||||
|
||||
$editor_sequence = Context::get("editor_sequence");
|
||||
$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
|
||||
if($upload_target_srl) {
|
||||
$tmp_files = $this->getFiles($upload_target_srl);
|
||||
$file_count = count($tmp_files);
|
||||
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
$file_info = $tmp_files[$i];
|
||||
if(!$file_info->file_srl) continue;
|
||||
|
||||
$obj = null;
|
||||
$obj->file_srl = $file_info->file_srl;
|
||||
$obj->source_filename = $file_info->source_filename;
|
||||
$obj->file_size = $file_info->file_size;
|
||||
$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
|
||||
if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid);
|
||||
else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
|
||||
$obj->direct_download = $file_info->direct_download;
|
||||
$files[] = $obj;
|
||||
$attached_size += $file_info->file_size;
|
||||
}
|
||||
} else {
|
||||
$upload_target_srl = 0;
|
||||
$attached_size = 0;
|
||||
$files = array();
|
||||
}
|
||||
|
||||
// 업로드 상태 표시 작성
|
||||
$upload_status = $this->getUploadStatus($attached_size);
|
||||
|
||||
// 남은 용량 체크
|
||||
$file_config = $this->getUploadConfig();
|
||||
$left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size;
|
||||
|
||||
// 필요한 정보들 세팅
|
||||
$this->add("files",$files);
|
||||
$this->add("editor_sequence",$editor_sequence);
|
||||
$this->add("upload_target_srl",$upload_target_srl);
|
||||
$this->add("upload_status",$upload_status);
|
||||
$this->add("left_size",$left_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 첨부파일의 개수를 return
|
||||
**/
|
||||
function getFilesCount($upload_target_srl) {
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
$output = executeQuery('file.getFilesCount', $args);
|
||||
return (int)$output->data->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 다운로드 경로를 구함
|
||||
**/
|
||||
function getDownloadUrl($file_srl, $sid) {
|
||||
return sprintf('?module=%s&act=%s&file_srl=%s&sid=%s', 'file', 'procFileDownload', $file_srl, $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 파일 설정 정보를 구함
|
||||
**/
|
||||
function getFileConfig($module_srl = null) {
|
||||
// 설정 정보를 받아옴 (module model 객체를 이용)
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
$file_module_config = $oModuleModel->getModuleConfig('file');
|
||||
|
||||
if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl);
|
||||
if(!$file_config) $file_config = $file_module_config;
|
||||
|
||||
if($file_config) {
|
||||
$config->allowed_filesize = $file_config->allowed_filesize;
|
||||
$config->allowed_attach_size = $file_config->allowed_attach_size;
|
||||
$config->allowed_filetypes = $file_config->allowed_filetypes;
|
||||
$config->download_grant = $file_config->download_grant;
|
||||
$config->allow_outlink = $file_config->allow_outlink;
|
||||
$config->allow_outlink_site = $file_config->allow_outlink_site;
|
||||
$config->allow_outlink_format = $file_config->allow_outlink_format;
|
||||
}
|
||||
|
||||
// 전체 파일첨부 속성을 먼저 따른다
|
||||
if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize;
|
||||
if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size;
|
||||
if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes;
|
||||
if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink;
|
||||
if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site;
|
||||
if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format;
|
||||
if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant;
|
||||
|
||||
// 그래도 없으면 default로
|
||||
if(!$config->allowed_filesize) $config->allowed_filesize = '2';
|
||||
if(!$config->allowed_attach_size) $config->allowed_attach_size = '3';
|
||||
if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*';
|
||||
if(!$config->allow_outlink) $config->allow_outlink = 'Y';
|
||||
if(!$config->download_grant) $config->download_grant = array();
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 파일 정보를 구함
|
||||
**/
|
||||
function getFile($file_srl) {
|
||||
$args->file_srl = $file_srl;
|
||||
$output = executeQuery('file.getFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$file = $output->data;
|
||||
$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 파일을 모두 return
|
||||
**/
|
||||
function getFiles($upload_target_srl) {
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
$args->sort_index = 'file_srl';
|
||||
$output = executeQuery('file.getFiles', $args);
|
||||
if(!$output->data) return;
|
||||
|
||||
$file_list = $output->data;
|
||||
|
||||
if($file_list && !is_array($file_list)) $file_list = array($file_list);
|
||||
|
||||
$file_count = count($file_list);
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
$file = $file_list[$i];
|
||||
$file->source_filename = stripslashes($file->source_filename);
|
||||
$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid);
|
||||
$file_list[$i] = $file;
|
||||
}
|
||||
|
||||
return $file_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 첨부파일에 대한 설정을 return (관리자/비관리자 자동 구분)
|
||||
**/
|
||||
function getUploadConfig() {
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->is_admin == 'Y') {
|
||||
$file_config->allowed_filesize = preg_replace("/[a-z]/is","",ini_get('upload_max_filesize'));
|
||||
$file_config->allowed_attach_size = preg_replace("/[a-z]/is","",ini_get('upload_max_filesize'));
|
||||
$file_config->allowed_filetypes = '*.*';
|
||||
} else {
|
||||
$module_srl = Context::get('module_srl');
|
||||
// module_srl이 없으면 현재 모듈
|
||||
if(!$module_srl) {
|
||||
$current_module_info = Context::get('current_module_info');
|
||||
$module_srl = $current_module_info->module_srl;
|
||||
}
|
||||
$file_config = $this->getFileConfig($module_srl);
|
||||
}
|
||||
return $file_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 파일 업로드를 위한 관리자/비관리자에 따른 안내문구 return
|
||||
**/
|
||||
function getUploadStatus($attached_size = 0) {
|
||||
$file_config = $this->getUploadConfig();
|
||||
|
||||
// 업로드 상태 표시 작성
|
||||
$upload_status = sprintf(
|
||||
'%s : %s/ %s<br /> %s : %s (%s : %s)',
|
||||
Context::getLang('allowed_attach_size'),
|
||||
FileHandler::filesize($attached_size),
|
||||
FileHandler::filesize($file_config->allowed_attach_size*1024*1024),
|
||||
Context::getLang('allowed_filesize'),
|
||||
FileHandler::filesize($file_config->allowed_filesize*1024*1024),
|
||||
Context::getLang('allowed_filetypes'),
|
||||
$file_config->allowed_filetypes
|
||||
);
|
||||
return $upload_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 모듈의 file 설정을 return
|
||||
**/
|
||||
function getFileModuleConfig($module_srl) {
|
||||
return $this->getFileConfig($module_srl);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* @class fileModel
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief file 모듈의 model 클래스
|
||||
**/
|
||||
|
||||
class fileModel extends file {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 첨부파일 목록을 return
|
||||
**/
|
||||
function getFileList() {
|
||||
|
||||
$mid = Context::get("mid");
|
||||
$oModuleModel = &getModel('module');
|
||||
$config = $oModuleModel->getModuleInfoByMid($mid);
|
||||
Context::set("module_srl",$config->module_srl);
|
||||
|
||||
$editor_sequence = Context::get("editor_sequence");
|
||||
$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
|
||||
if(!$upload_target_srl) {
|
||||
$_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = Context::get('uploadTargetSrl');
|
||||
}
|
||||
if($upload_target_srl) {
|
||||
$tmp_files = $this->getFiles($upload_target_srl);
|
||||
$file_count = count($tmp_files);
|
||||
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
$file_info = $tmp_files[$i];
|
||||
if(!$file_info->file_srl) continue;
|
||||
|
||||
$obj = null;
|
||||
$obj->file_srl = $file_info->file_srl;
|
||||
$obj->source_filename = $file_info->source_filename;
|
||||
$obj->file_size = $file_info->file_size;
|
||||
$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
|
||||
if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid);
|
||||
else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
|
||||
$obj->direct_download = $file_info->direct_download;
|
||||
$files[] = $obj;
|
||||
$attached_size += $file_info->file_size;
|
||||
}
|
||||
} else {
|
||||
$upload_target_srl = 0;
|
||||
$attached_size = 0;
|
||||
$files = array();
|
||||
}
|
||||
|
||||
// 업로드 상태 표시 작성
|
||||
$upload_status = $this->getUploadStatus($attached_size);
|
||||
|
||||
// 남은 용량 체크
|
||||
$file_config = $this->getUploadConfig();
|
||||
$left_size = $file_config->allowed_attach_size*1024*1024 - $attached_size;
|
||||
|
||||
// 필요한 정보들 세팅
|
||||
$this->add("files",$files);
|
||||
$this->add("editor_sequence",$editor_sequence);
|
||||
$this->add("upload_target_srl",$upload_target_srl);
|
||||
$this->add("upload_status",$upload_status);
|
||||
$this->add("left_size",$left_size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 첨부파일의 개수를 return
|
||||
**/
|
||||
function getFilesCount($upload_target_srl) {
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
$output = executeQuery('file.getFilesCount', $args);
|
||||
return (int)$output->data->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 다운로드 경로를 구함
|
||||
**/
|
||||
function getDownloadUrl($file_srl, $sid) {
|
||||
return sprintf('?module=%s&act=%s&file_srl=%s&sid=%s', 'file', 'procFileDownload', $file_srl, $sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 파일 설정 정보를 구함
|
||||
**/
|
||||
function getFileConfig($module_srl = null) {
|
||||
// 설정 정보를 받아옴 (module model 객체를 이용)
|
||||
$oModuleModel = &getModel('module');
|
||||
|
||||
$file_module_config = $oModuleModel->getModuleConfig('file');
|
||||
|
||||
if($module_srl) $file_config = $oModuleModel->getModulePartConfig('file',$module_srl);
|
||||
if(!$file_config) $file_config = $file_module_config;
|
||||
|
||||
if($file_config) {
|
||||
$config->allowed_filesize = $file_config->allowed_filesize;
|
||||
$config->allowed_attach_size = $file_config->allowed_attach_size;
|
||||
$config->allowed_filetypes = $file_config->allowed_filetypes;
|
||||
$config->download_grant = $file_config->download_grant;
|
||||
$config->allow_outlink = $file_config->allow_outlink;
|
||||
$config->allow_outlink_site = $file_config->allow_outlink_site;
|
||||
$config->allow_outlink_format = $file_config->allow_outlink_format;
|
||||
}
|
||||
|
||||
// 전체 파일첨부 속성을 먼저 따른다
|
||||
if(!$config->allowed_filesize) $config->allowed_filesize = $file_module_config->allowed_filesize;
|
||||
if(!$config->allowed_attach_size) $config->allowed_attach_size = $file_module_config->allowed_attach_size;
|
||||
if(!$config->allowed_filetypes) $config->allowed_filetypes = $file_module_config->allowed_filetypes;
|
||||
if(!$config->allow_outlink) $config->allow_outlink = $file_module_config->allow_outlink;
|
||||
if(!$config->allow_outlink_site) $config->allow_outlink_site = $file_module_config->allow_outlink_site;
|
||||
if(!$config->allow_outlink_format) $config->allow_outlink_format = $file_module_config->allow_outlink_format;
|
||||
if(!$config->download_grant) $config->download_grant = $file_module_config->download_grant;
|
||||
|
||||
// 그래도 없으면 default로
|
||||
if(!$config->allowed_filesize) $config->allowed_filesize = '2';
|
||||
if(!$config->allowed_attach_size) $config->allowed_attach_size = '3';
|
||||
if(!$config->allowed_filetypes) $config->allowed_filetypes = '*.*';
|
||||
if(!$config->allow_outlink) $config->allow_outlink = 'Y';
|
||||
if(!$config->download_grant) $config->download_grant = array();
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 파일 정보를 구함
|
||||
**/
|
||||
function getFile($file_srl) {
|
||||
$args->file_srl = $file_srl;
|
||||
$output = executeQuery('file.getFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
$file = $output->data;
|
||||
$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 문서에 속한 파일을 모두 return
|
||||
**/
|
||||
function getFiles($upload_target_srl) {
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
$args->sort_index = 'file_srl';
|
||||
$output = executeQuery('file.getFiles', $args);
|
||||
if(!$output->data) return;
|
||||
|
||||
$file_list = $output->data;
|
||||
|
||||
if($file_list && !is_array($file_list)) $file_list = array($file_list);
|
||||
|
||||
$file_count = count($file_list);
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
$file = $file_list[$i];
|
||||
$file->source_filename = stripslashes($file->source_filename);
|
||||
$file->download_url = $this->getDownloadUrl($file->file_srl, $file->sid);
|
||||
$file_list[$i] = $file;
|
||||
}
|
||||
|
||||
return $file_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 첨부파일에 대한 설정을 return (관리자/비관리자 자동 구분)
|
||||
**/
|
||||
function getUploadConfig() {
|
||||
$logged_info = Context::get('logged_info');
|
||||
if($logged_info->is_admin == 'Y') {
|
||||
$file_config->allowed_filesize = preg_replace("/[a-z]/is","",ini_get('upload_max_filesize'));
|
||||
$file_config->allowed_attach_size = preg_replace("/[a-z]/is","",ini_get('upload_max_filesize'));
|
||||
$file_config->allowed_filetypes = '*.*';
|
||||
} else {
|
||||
$module_srl = Context::get('module_srl');
|
||||
// module_srl이 없으면 현재 모듈
|
||||
if(!$module_srl) {
|
||||
$current_module_info = Context::get('current_module_info');
|
||||
$module_srl = $current_module_info->module_srl;
|
||||
}
|
||||
$file_config = $this->getFileConfig($module_srl);
|
||||
}
|
||||
return $file_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 파일 업로드를 위한 관리자/비관리자에 따른 안내문구 return
|
||||
**/
|
||||
function getUploadStatus($attached_size = 0) {
|
||||
$file_config = $this->getUploadConfig();
|
||||
|
||||
// 업로드 상태 표시 작성
|
||||
$upload_status = sprintf(
|
||||
'%s : %s/ %s<br /> %s : %s (%s : %s)',
|
||||
Context::getLang('allowed_attach_size'),
|
||||
FileHandler::filesize($attached_size),
|
||||
FileHandler::filesize($file_config->allowed_attach_size*1024*1024),
|
||||
Context::getLang('allowed_filesize'),
|
||||
FileHandler::filesize($file_config->allowed_filesize*1024*1024),
|
||||
Context::getLang('allowed_filetypes'),
|
||||
$file_config->allowed_filetypes
|
||||
);
|
||||
return $upload_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 모듈의 file 설정을 return
|
||||
**/
|
||||
function getFileModuleConfig($module_srl) {
|
||||
return $this->getFileConfig($module_srl);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue