english comments added

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0_english@8278 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
mosmartin 2011-04-06 16:48:06 +00:00
parent 693e215bc1
commit 4d272994dd
219 changed files with 6407 additions and 8705 deletions

View file

@ -2,7 +2,7 @@
/**
* @class editorModel
* @author NHN (developers@xpressengine.com)
* @brief editor 모듈의 model 클래스
* @brief model class of the editor odule
**/
class editorModel extends editor {
@ -10,21 +10,21 @@
var $loaded_component_list = array();
/**
* @brief 에디터를 return
* @brief Return the editor
*
* 에디터의 경우 내부적으로 1~30까지의 임시 editor_seuqnece를 생성한다.
* 한페이지에 30 이상의 에디터를 출력하지는 못하도록 제한되어 있다.
* Editor internally generates editor_sequence from 1 to 30 for temporary use.
* That means there is a limitation that more than 30 editors cannot be displayed on a single page.
*
* , 수정하는 경우 또는 파일업로드를 자동저장본의 경우는 getNextSequence() 값으로 저장된 editor_seqnece가
* 설정된다.
* However, editor_sequence can be value from getNextSequence() in case of the modified or the auto-saved for file upload
*
**/
/**
* @brief 모듈별 에디터 설정을 return
* @brief Return editor setting for each module
**/
function getEditorConfig($module_srl) {
if(!$GLOBALS['__editor_module_config__'][$module_srl]) {
// 선택된 모듈의 trackback설정을 가져옴
// Get trackback settings of the selected module
$oModuleModel = &getModel('module');
$GLOBALS['__editor_module_config__'][$module_srl] = $oModuleModel->getModulePartConfig('editor', $module_srl);
}
@ -75,20 +75,17 @@
function getDrComponentXmlInfo($drComponentName){
$lang_type = Context::getLangType();
// 요청된 컴포넌트의 xml파일 위치를 구함
// Get the xml file path of requested component
$component_path = sprintf('%s/skins/dreditor/drcomponents/%s/', $this->module_path, $drComponentName);
$xml_file = sprintf('%sinfo.xml', $component_path);
$cache_file = sprintf('./files/cache/editor/dr_%s.%s.php', $drComponentName, $lang_type);
// 캐시된 xml파일이 있으면 include 후 정보 return
// Return information after including it after cached xml file exists
if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) {
include($cache_file);
return $xml_info;
}
// 캐시된 파일이 없으면 파싱후 캐싱 후 return
// Return after parsing and caching if the cached file does not exist
$oParser = new XmlParser();
$xml_doc = $oParser->loadXmlFile($xml_file);
@ -111,7 +108,7 @@
$buff .= sprintf('$xml_info->license = "%s";', $component_info->license);
$buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link);
// 작성자 정보
// Author information
if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author;
else $author_list = $xml_doc->component->author;
@ -154,8 +151,7 @@
}
}
}
// 추가 변수 정리 (에디터 컴포넌트에서는 text형만 가능)
// List extra variables (text type only in the editor component)
$extra_vars = $xml_doc->component->extra_vars->var;
if($extra_vars) {
if(!is_array($extra_vars)) $extra_vars = array($extra_vars);
@ -182,48 +178,40 @@
}
/**
* @brief 에디터 template을 return
* upload_target_srl은 글의 수정시 호출하면 .
* upload_target_srl은 첨부파일의 유무를 체크하기 위한 루틴을 구현하는데 사용됨.
* @brief Return the editor template
* You can call upload_target_srl when modifying content
* The upload_target_srl is used for a routine to check if an attachment exists
**/
function getEditor($upload_target_srl = 0, $option = null) {
/**
* 기본적인 에디터의 옵션을 정리
* Editor's default options
**/
// 파일 업로드 유무 옵션 설정
// Option setting to allow file upload
if(!$option->allow_fileupload) $allow_fileupload = false;
else $allow_fileupload = true;
// content_style 세팅
// content_style setting
if(!$option->content_style) $option->content_style = 'default';
Context::set('content_style', $option->content_style);
// 기본 글꼴 지정
// Default font setting
Context::set('content_font', $option->content_font);
Context::set('content_font_size', $option->content_font_size);
// 자동 저장 유무 옵션 설정 글 수정시는 사용 안함
// Option setting to allow auto-save
if(!$option->enable_autosave) $enable_autosave = false;
elseif(Context::get($option->primary_key_name)) $enable_autosave = false;
else $enable_autosave = true;
// 기본 에디터 컴포넌트 사용 설정
// Option setting to allow the default editor component
if(!$option->enable_default_component) $enable_default_component = false;
else $enable_default_component = true;
// 확장 컴포넌트 사용 설정
// Option setting to allow other extended components
if(!$option->enable_component) $enable_component = false;
else $enable_component = true;
// html 모드 조절
// Setting for html-mode
if($option->disable_html) $html_mode = false;
else $html_mode = true;
// 높이 설정
// Set Height
if(!$option->height) $editor_height = 400;
else $editor_height = $option->height;
// 스킨 설정
// Skin Setting
$skin = $option->skin;
if(!$skin) $skin = 'xpresseditor';
@ -236,19 +224,18 @@
}
/**
* 자동백업 기능 체크 ( 수정일 경우는 사용하지 않음)
* Check the automatic backup feature (do not use if the post is edited)
**/
if($enable_autosave) {
// 자동 저장된 데이터를 추출
// Extract auto-saved data
$saved_doc = $this->getSavedDoc($upload_target_srl);
// 자동 저장 데이터를 context setting
// Context setting auto-saved data
Context::set('saved_doc', $saved_doc);
}
Context::set('enable_autosave', $enable_autosave);
/**
* 에디터의 고유 번호 추출 ( 페이지에 여러개의 에디터를 출력하는 경우를 대비)
* Extract editor's unique number (in order to display multiple editors on a single page)
**/
if($option->editor_sequence) $editor_sequence = $option->editor_sequence;
else {
@ -257,50 +244,42 @@
}
/**
* 업로드 활성화시 내부적으로 file 모듈의 환경설정을 이용하여 설정
* Upload setting by using configuration of the file module internally
**/
$files_count = 0;
if($allow_fileupload) {
$oFileModel = &getModel('file');
// SWFUploader에 세팅할 업로드 설정 구함
// Get upload configuration to set on SWFUploader
$file_config = $oFileModel->getUploadConfig();
$file_config->allowed_attach_size = $file_config->allowed_attach_size*1024*1024;
$file_config->allowed_filesize = $file_config->allowed_filesize*1024*1024;
Context::set('file_config',$file_config);
// 업로드 가능 용량등에 대한 정보를 세팅
// Configure upload status such as file size
$upload_status = $oFileModel->getUploadStatus();
Context::set('upload_status', $upload_status);
// upload가능하다고 설정 (내부적으로 캐싱하여 처리)
// Upload enabled (internally caching)
$oFileController = &getController('file');
$oFileController->setUploadInfo($editor_sequence, $upload_target_srl);
// 이미 등록된 파일이 있는지 검사
// Check if the file already exists
if($upload_target_srl) $files_count = $oFileModel->getFilesCount($upload_target_srl);
}
Context::set('files_count', (int)$files_count);
Context::set('allow_fileupload', $allow_fileupload);
// 에디터 동작을 위한 editor_sequence값 설정
// Set editor_sequence value
Context::set('editor_sequence', $editor_sequence);
// 파일 첨부 관련 행동을 하기 위해 문서 번호를 upload_target_srl로 설정
// 신규문서일 경우 upload_target_srl=0 이고 첨부파일 관련 동작이 요청될때 이 값이 변경됨
// Set the document number to upload_target_srl for file attachments
// If a new document, upload_target_srl = 0. The value becomes changed when file attachment is requested
Context::set('upload_target_srl', $upload_target_srl);
// 문서 혹은 댓글의 primary key값을 세팅한다.
// Set the primary key valueof the document or comments
Context::set('editor_primary_key_name', $option->primary_key_name);
// 내용을 sync 맞추기 위한 content column name을 세팅한다
// Set content column name to sync contents
Context::set('editor_content_key_name', $option->content_key_name);
/**
* 에디터 컴포넌트 체크
* Check editor component
**/
$site_module_info = Context::get('site_module_info');
$site_srl = (int)$site_module_info->site_srl;
@ -314,20 +293,19 @@
Context::set('enable_default_component', $enable_default_component);
/**
* html_mode 가능한지 변수 설정
* Variable setting if html_mode is available
**/
Context::set('html_mode', $html_mode);
/**
* 에디터 세로 크기 설정
* Set a height of editor
**/
Context::set('editor_height', $editor_height);
// 에디터의 초기화를 수동으로하는 것에 대한 값 체크
// Check an option whether to start the editor manually
Context::set('editor_manual_start', $option->manual_start);
/**
* 템플릿을 미리 컴파일해서 컴파일된 소스를 하기 위해 스킨의 경로를 설정
* Set a skin path to pre-compile the template
?**/
$tpl_path = sprintf('%sskins/%s/', $this->module_path, $skin);
$tpl_file = 'editor.html';
@ -340,24 +318,22 @@
// load editor skin lang
Context::loadLang($tpl_path.'lang');
// tpl 파일을 compile한 결과를 return
// Return the compiled result from tpl file
$oTemplate = new TemplateHandler();
return $oTemplate->compile($tpl_path, $tpl_file);
}
/**
* @brief 모듈별 설정이 반영된 에디터 template을 return
* getEditor() 동일한 결과물을 return하지만 getModuleEditor() 모듈별 추가 설정을 통해 직접 제어되는 설정을 이용하여 에디터를 생성함
* @brief Return editor template which contains settings of each module
* Result of getModuleEditor() is as same as getEditor(). But getModuleEditor()uses additional settings of each module to generate an editor
*
* document/ comment 2가지 종류를 이용함.
* 굳이 나눈 이유는 하나의 모듈에서 2 종류의 에디터 사용을 위해서인데 게시판이나 블로그등 원글과 그에 연관된 (댓글) 위한 용도임.
* 2 types of editors supported; document and comment.
* 2 types of editors can be used on a single module. For instance each for original post and reply port.
**/
function getModuleEditor($type = 'document', $module_srl, $upload_target_srl, $primary_key_name, $content_key_name) {
// 지정된 모듈의 에디터 설정을 구해옴
// Get editor settings of the module
$editor_config = $this->getEditorConfig($module_srl);
// type에 따른 설정 정리
// Configurations listed according to a type
if($type == 'document') {
$config->editor_skin = $editor_config->editor_skin;
$config->content_style = $editor_config->content_style;
@ -383,23 +359,20 @@
$config->editor_height = $editor_config->comment_editor_height;
$config->enable_autosave = 'N';
}
// 권한 체크를 위한 현재 로그인 사용자의 그룹 설정 체크
// Check a group_list of the currently logged-in user for permission check
if(Context::get('is_logged')) {
$logged_info = Context::get('logged_info');
$group_list = $logged_info->group_list;
} else {
$group_list = array();
}
// 에디터 옵션 변수를 미리 설정
// Pre-set option variables of editor
$option->skin = $config->editor_skin;
$option->content_style = $config->content_style;
$option->content_font = $config->content_font;
$option->content_font_size = $config->content_font_size;
$option->colorset = $config->sel_editor_colorset;
// 파일 업로드 권한 체크
// Permission check for file upload
$option->allow_fileupload = false;
if(count($config->upload_file_grant)) {
foreach($group_list as $group_srl => $group_info) {
@ -409,8 +382,7 @@
}
}
} else $option->allow_fileupload = true;
// 기본 컴포넌트 사용 권한
// Permission check for using default components
$option->enable_default_component = false;
if(count($config->enable_default_component_grant)) {
foreach($group_list as $group_srl => $group_info) {
@ -420,8 +392,7 @@
}
}
} else $option->enable_default_component = true;
// 확장 컴포넌트 사용 권한
// Permisshion check for using extended components
$option->enable_component = false;
if(count($config->enable_component_grant)) {
foreach($group_list as $group_srl => $group_info) {
@ -431,8 +402,7 @@
}
}
} else $option->enable_component = true;
// HTML 편집 권한
// HTML editing privileges
$enable_html = false;
if(count($config->enable_html_grant)) {
foreach($group_list as $group_srl => $group_info) {
@ -445,14 +415,11 @@
if($enable_html) $option->disable_html = false;
else $option->disable_html = true;
// 높이 설정
// Set Height
$option->height = $config->editor_height;
// 자동 저장 유무 옵션 설정
// Set an option for Auto-save
$option->enable_autosave = $config->enable_autosave=='Y'?true:false;
// 기타 설정
// Other settings
$option->primary_key_name = $primary_key_name;
$option->content_key_name = $content_key_name;
@ -460,10 +427,10 @@
}
/**
* @brief 자동저장되어 있는 정보를 가져옴
* @brief Get information which has been auto-saved
**/
function getSavedDoc($upload_target_srl) {
// 로그인 회원이면 member_srl, 아니면 ipaddress로 저장되어 있는 문서를 찾음
// Find a document by using member_srl for logged-in user and ipaddress for non-logged user
if(Context::get('is_logged')) {
$logged_info = Context::get('logged_info');
$auto_save_args->member_srl = $logged_info->member_srl;
@ -471,34 +438,29 @@
$auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR'];
}
$auto_save_args->module_srl = Context::get('module_srl');
// module_srl이 없으면 현재 모듈
// Get the current module if module_srl doesn't exist
if(!$auto_save_args->module_srl) {
$current_module_info = Context::get('current_module_info');
$auto_save_args->module_srl = $current_module_info->module_srl;
}
// DB에서 자동저장 데이터 추출
// Extract auto-saved data from the DB
$output = executeQuery('editor.getSavedDocument', $auto_save_args);
$saved_doc = $output->data;
// 자동저장한 결과가 없으면 null값 return
// Return null if no result is auto-saved
if(!$saved_doc) return;
// 자동저장된 값이 혹시 이미 등록된 글인지 확인
// Check if the auto-saved document already exists
$oDocumentModel = &getModel('document');
$oSaved = $oDocumentModel->getDocument($saved_doc->document_srl);
if($oSaved->isExists()) return;
// 자동저장 데이터에 문서번호가 있고 이 번호에 파일이 있다면 파일을 모두 이동하고
// 해당 문서 번호를 editor_sequence로 세팅함
// Move all the files if the auto-saved data contains document_srl and file
// Then set document_srl to editor_sequence
if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl')) {
$saved_doc->module_srl = $auto_save_args->module_srl;
$oFileController = &getController('file');
$oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl);
}
else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl;
// 자동 저장 데이터 변경
// Change auto-saved data
$oEditorController = &getController('editor');
$oEditorController->deleteSavedDoc(false);
$oEditorController->doSaveDoc($saved_doc);
@ -507,24 +469,22 @@
}
/**
* @brief component의 객체 생성
* @brief create objects of the component
**/
function getComponentObject($component, $editor_sequence = 0, $site_srl = 0) {
if(!preg_match('/^[a-zA-Z0-9_-]+$/',$component) || !preg_match('/^[0-9]+$/', $editor_sequence . $site_srl)) return;
if(!$this->loaded_component_list[$component][$editor_sequence]) {
// 해당 컴포넌트의 객체를 생성해서 실행
// Create an object of the component and execute
$class_path = sprintf('%scomponents/%s/', $this->module_path, $component);
$class_file = sprintf('%s%s.class.php', $class_path, $component);
if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
// 클래스 파일을 읽은 후 객체 생성
// Create an object after loading the class file
require_once($class_file);
$tmp_fn = create_function('$seq,$path', "return new {$component}(\$seq,\$path);");
$oComponent = $tmp_fn($editor_sequence, $class_path);
if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component));
// 설정 정보를 추가
// Add configuration information
$component_info = $this->getComponent($component, $site_srl);
$oComponent->setInfo($component_info);
$this->loaded_component_list[$component][$editor_sequence] = $oComponent;
@ -534,14 +494,14 @@
}
/**
* @brief editor skin 목록을 return
* @brief Return a list of the editor skin
**/
function getEditorSkinList() {
return FileHandler::readDir('./modules/editor/skins');
}
/**
* @brief 에디터 컴포넌트 목록 캐시 파일 이름 return
* @brief Return the cache file name of editor component list
**/
function getCacheFile($filter_enabled= true, $site_srl = 0) {
$lang = Context::getLangType();
@ -555,7 +515,7 @@
}
/**
* @brief component 목록을 return (DB정보 보함)
* @brief Return a component list (DB Information included)
**/
function getComponentList($filter_enabled = true, $site_srl=0, $from_db=false) {
$cache_file = $this->getCacheFile(false, $site_srl);
@ -619,7 +579,7 @@
}
/**
* @brief compnent의 xml+db정보를 구함
* @brief Get xml and db information of the component
**/
function getComponent($component_name, $site_srl = 0) {
$args->component_name = $component_name;
@ -667,28 +627,24 @@
}
/**
* @brief component의 xml정보를 읽음
* @brief Read xml information of the component
**/
function getComponentXmlInfo($component) {
$lang_type = Context::getLangType();
// 요청된 컴포넌트의 xml파일 위치를 구함
// Get xml file path of the requested components
$component_path = sprintf('%s/components/%s/', $this->module_path, $component);
$xml_file = sprintf('%sinfo.xml', $component_path);
$cache_file = sprintf('./files/cache/editor/%s.%s.php', $component, $lang_type);
// 캐시된 xml파일이 있으면 include 후 정보 return
// Include and return xml file information if cached file exists
if(file_exists($cache_file) && file_exists($xml_file) && filemtime($cache_file) > filemtime($xml_file)) {
include($cache_file);
return $xml_info;
}
// 캐시된 파일이 없으면 파싱후 캐싱 후 return
// Parse, cache and then return if the cached file doesn't exist
$oParser = new XmlParser();
$xml_doc = $oParser->loadXmlFile($xml_file);
// 정보 정리
// Component information listed
if($xml_doc->component->version && $xml_doc->component->attrs->version == '0.2') {
$component_info->component_name = $component;
$component_info->title = $xml_doc->component->title->body;
@ -708,8 +664,7 @@
$buff .= sprintf('$xml_info->homepage = "%s";', $component_info->homepage);
$buff .= sprintf('$xml_info->license = "%s";', $component_info->license);
$buff .= sprintf('$xml_info->license_link = "%s";', $component_info->license_link);
// 작성자 정보
// Author information
if(!is_array($xml_doc->component->author)) $author_list[] = $xml_doc->component->author;
else $author_list = $xml_doc->component->author;
@ -776,8 +731,7 @@
$buff .= sprintf('$xml_info->author[0]->email_address = "%s";', $xml_info->author->email_address);
$buff .= sprintf('$xml_info->author[0]->homepage = "%s";', $xml_info->author->homepage);
}
// 추가 변수 정리 (에디터 컴포넌트에서는 text형만 가능)
// List extra variables (text type only for editor component)
$extra_vars = $xml_doc->component->extra_vars->var;
if($extra_vars) {
if(!is_array($extra_vars)) $extra_vars = array($extra_vars);