diff --git a/classes/file/FileHandler.class.php b/classes/file/FileHandler.class.php index 489f61b69..5e29a3bff 100644 --- a/classes/file/FileHandler.class.php +++ b/classes/file/FileHandler.class.php @@ -14,11 +14,21 @@ **/ function readFile($file_name) { if(!file_exists($file_name)) return; - if(filesize($file_name)<1) return; + + $filesize = filesize($file_name); + + if($filesize<1) return; + $fp = fopen($file_name, "r"); - $buff = fread($fp, filesize($file_name)); - fclose($fp); - return trim($buff); + $buff = ''; + if($fp) { + while(!feof($fp) || strlen($buff)<$filesize) { + $str = fgets($fp, 1024); + $buff .= $str; + } + fclose($fp); + } + return $buff; } /** diff --git a/classes/xml/XmlParser.class.php b/classes/xml/XmlParser.class.php index 0c7a7f410..9303ae96a 100644 --- a/classes/xml/XmlParser.class.php +++ b/classes/xml/XmlParser.class.php @@ -23,7 +23,6 @@ **/ function loadXmlFile($filename) { if(!file_exists($filename)) return; - $buff = FileHandler::readFile($filename); $oXmlParser = new XmlParser(); @@ -59,7 +58,6 @@ unset($this->lang); } - $this->oParser = xml_parser_create(); xml_set_object($this->oParser, $this); diff --git a/modules/importer/conf/module.xml b/modules/importer/conf/module.xml index a65b3b133..677f07c62 100644 --- a/modules/importer/conf/module.xml +++ b/modules/importer/conf/module.xml @@ -3,6 +3,8 @@ + + diff --git a/modules/importer/importer.class.php b/modules/importer/importer.class.php index e1954b597..1390d3619 100644 --- a/modules/importer/importer.class.php +++ b/modules/importer/importer.class.php @@ -14,7 +14,6 @@ // action forward에 등록 (관리자 모드에서 사용하기 위함) $oModuleController = &getController('module'); $oModuleController->insertActionForward('importer', 'view', 'dispImporterAdminContent'); - $oModuleController->insertActionForward('importer', 'controller', 'procImporterAdminImport'); return new Object(); } diff --git a/modules/importer/importer.controller.php b/modules/importer/importer.controller.php index 6cc238ed6..cee6ee9b1 100644 --- a/modules/importer/importer.controller.php +++ b/modules/importer/importer.controller.php @@ -14,10 +14,85 @@ } /** - * @brief import + * @brief import step1 + * import하려는 대상에 따라 결과값을 구해서 return + * 회원정보 : next_step=2, module_list = null + * 모듈정보 : next_step=12, module_list = modules.. + * 회원정보 동기화 : next_step=3 **/ - function procImporterAdminImport() { + function procImporterAdminStep1() { + $source_type = Context::get('source_type'); + switch($source_type) { + case 'module' : + // 모듈 목록을 구함 + $oModuleModel = &getModel('module'); + $module_list = $oModuleModel->getMidList(); + foreach($module_list as $key => $val) { + $module_list_arr[] = sprintf('%d,%s (%s)', $val->module_srl, $val->browser_title, $val->mid); + } + if(count($module_list_arr)) $module_list = implode("\n",$module_list_arr); + $next_step = 12; + break; + case 'member' : + $next_step = 2; + break; + case 'syncmember' : + $next_step = 3; + break; + } + + $this->add('next_step', $next_step); + $this->add('module_list', $module_list); } + /** + * @brief import step12 + * module_srl을 이용하여 대상 모듈에 카테고리값이 있는지 확인하여 + * 있으면 카테고리 정보를 return, 아니면 파일 업로드 단계로 이동 + **/ + function procImporterAdminStep12() { + $target_module= Context::get('target_module'); + + // 대상 모듈의 카테고리 목록을 구해옴 + $oDocumentModel = &getModel('document'); + $category_list = $oDocumentModel->getCategoryList($target_module); + + if(count($category_list)) { + foreach($category_list as $key => $val) { + $category_list_arr[] = sprintf('%d,%s', $val->category_srl, $val->title); + } + if(count($category_list_arr)) { + $category_list = implode("\n",$category_list_arr); + $next_step = 13; + } + } else { + $category_list = null; + $next_step = 2; + } + + $this->add('next_step', $next_step); + $this->add('category_list', $category_list); + } + + /** + * @brief import xml file + * XML File을 읽어서 파싱 후 입력.. + **/ + function procImporterAdminImport() { + set_time_limit(0); + + $module_srl = Context::get('module_srl'); + $category_srl = Context::get('category_srl'); + $xml_file = Context::get('xml_file'); + + // 파일을 찾을 수 없으면 에러 표시 + if(!file_exists($xml_file)) return new Object(-1,'msg_no_xml_file'); + + // XML Parser로 XML을 읽음 + $xml_doc = XmlParser::loadXmlFile($xml_file); + + $this->setError(-1); + $this->setMessage('haha'); + } } ?> diff --git a/modules/importer/lang/ko.lang.php b/modules/importer/lang/ko.lang.php index f9be0c691..779d85809 100644 --- a/modules/importer/lang/ko.lang.php +++ b/modules/importer/lang/ko.lang.php @@ -6,27 +6,39 @@ **/ // 버튼에 사용되는 언어 - $lang->cmd_importer_list = 'Importer 목록'; - $lang->cmd_module_config = 'Importer 공통 설정'; - $lang->cmd_view_info = 'Importer 정보'; - $lang->cmd_manage_menu = '메뉴관리'; - $lang->cmd_make_child = '하위 카테고리 추가'; - $lang->cmd_enable_move_category = "카테고리 위치 변경 (선택후 위 메뉴를 드래그하세요)"; - $lang->cmd_remake_cache = '캐시파일 재생성'; - $lang->cmd_layout_setup = '레이아웃 설정'; - $lang->cmd_layout_edit = '레이아웃 편집'; + $lang->cmd_sync_member = '동기화'; // 항목 - $lang->parent_category_name = '상위 카테고리명'; - $lang->category_name = '분류명'; - $lang->expand = '펼침'; - $lang->category_group_srls = '그룹제한'; + $lang->source_type = '이전 대상'; + $lang->type_member = '회원 정보'; + $lang->type_module = '게시물 정보'; + $lang->type_syncmember = '회원정보 동기화'; + $lang->target_module = '대상 모듈'; + $lang->xml_file = 'XML 파일'; + + $lang->import_step_title = array( + 1 => 'Step 1. 이전 대상 선택', + 12 => 'Step 1-2. 대상 모듈 선택', + 13 => 'Step 1-3. 대상 분류 선택', + 2 => 'Step 2. XML파일 업로드', + 3 => 'Step 2. 회원정보와 게시물의 정보 동기화', + ); + + $lang->import_step_desc = array( + 1 => '이전을 하려는 XML파일의 종류를 선택해주세요.', + 12 => '데이터 이전을 할 대상 모듈을 선택해주세요.', + 13 => '데이터 이전을 할 대상 분류를 선택해주세요.', + 2 => "데이터 이전을 할 XML파일의 위치를 입력해주세요.\n같은 계정일 경우 상대 또는 절대 경로를, 다른 서버에 업로드 되어 있으면 http://주소.. 를 입력해주세요", + 3 => '회원정보와 게시물의 정보가 이전후에 맞지 않을 수 있습니다. 이 때 동기화를 하시면 user_id를 기반으로 올바르게 동작하도록 합니다.', + ); + + // 안내/경고 + $lang->msg_sync_member = '동기화 버튼을 클릭하시면 회원정보와 게시물정보의 동기화를 시작합니다.'; + $lang->msg_no_xml_file = 'XML파일을 찾을 수 없습니다. 경로를 다시 확인해주세요'; // 주절 주절.. - $lang->about_category_name = '카테고리 이름을 입력해주세요'; - $lang->about_expand = '선택하시면 늘 펼쳐진 상태로 있게 합니다'; - $lang->about_category_group_srls = '선택하신 그룹만 현재 카테고리가 보이게 됩니다. (xml파일을 직접 열람하면 노출이 됩니다)'; - $lang->about_layout_setup = 'Importer의 레이아웃 코드를 직접 수정할 수 있습니다. 플러그인 코드를 원하는 곳에 삽입하시거나 관리하세요'; - - $lang->about_importer = "Importer를 만드시고 관리할 수 있는 Importer 모듈입니다.\nImporter 모듈은 Importer 스킨에 포함된 레이아웃을 이용하니 생성후 꼭 분류 및 스킨 관리를 통해서 Importer를 꾸미시기 바랍니다.\nImporter내에 다른 게시판을 연결하시고 싶을때에는 메뉴모듈로 메뉴를 만들고 나서 스킨관리에 연결해 주시면 됩니다"; + $lang->about_type_member = '데이터 이전 대상이 회원정보일 경우 선택해주세요'; + $lang->about_type_module = '데이터 이전 대상이 게시판등의 게시물 정보일 경우 선택해주세요'; + $lang->about_type_syncmember = '회원정보와 게시물정보등을 이전후 회원정보 동기화 해야 할때 선택해주세요'; + $lang->about_importer = "제로보드4, zb5beta 또는 다른 프로그램의 데이터를 제로보드XE 데이터로 이전할 수 있습니다.\n이전을 위해서는 XML Exporter를 이용해서 원하는 데이터를 XML파일로 생성후 업로드해주셔야 합니다."; ?> diff --git a/modules/importer/tpl/filter/import_xml.xml b/modules/importer/tpl/filter/import_xml.xml new file mode 100644 index 000000000..bd2ba9f3a --- /dev/null +++ b/modules/importer/tpl/filter/import_xml.xml @@ -0,0 +1,10 @@ + +
+ + + + + + + +
diff --git a/modules/importer/tpl/filter/step1.xml b/modules/importer/tpl/filter/step1.xml new file mode 100644 index 000000000..2030a9f7b --- /dev/null +++ b/modules/importer/tpl/filter/step1.xml @@ -0,0 +1,12 @@ + +
+ + + + + + + + + +
diff --git a/modules/importer/tpl/filter/step12.xml b/modules/importer/tpl/filter/step12.xml new file mode 100644 index 000000000..91c0e12f6 --- /dev/null +++ b/modules/importer/tpl/filter/step12.xml @@ -0,0 +1,12 @@ + +
+ + + + + + + + + +
diff --git a/modules/importer/tpl/index.html b/modules/importer/tpl/index.html index b80e6e067..6b46b49c0 100644 --- a/modules/importer/tpl/index.html +++ b/modules/importer/tpl/index.html @@ -1,3 +1,109 @@ -
+ + + + + +
+ {nl2br($lang->about_importer)} +
+ + +
+
+ +
{$lang->import_step_title[1]}
+
{$lang->import_step_desc[1]}
+ + + + + + + + + + + + + + + + + +
+ + + {$lang->about_type_module}
+ + + {$lang->about_type_member}
+ + + {$lang->about_type_syncmember}
+ +
+ +
+
+ + + + + + + + + + + + + + + diff --git a/modules/importer/tpl/js/importer_admin.js b/modules/importer/tpl/js/importer_admin.js new file mode 100644 index 000000000..c7b17e473 --- /dev/null +++ b/modules/importer/tpl/js/importer_admin.js @@ -0,0 +1,86 @@ +/** + * @file modules/importer/js/importer_admin.js + * @author zero (zero@nzeo.com) + * @brief importer에서 사용하는 javascript + **/ + +/* Step 1 처리 */ +function completeStep1(ret_obj) { + var error = ret_obj['error']; + var message = ret_obj['message']; + var next_step = ret_obj['next_step']; + var module_list = ret_obj['module_list']; + + if(module_list) { + var sel = xGetElementById("target_module"); + var module_list_arr = module_list.split("\n"); + for(var i=0;i0) { + var module_srl = sel_module.options[sel_module.selectedIndex].value; + fo_obj.module_srl.value = module_srl; + } + + var sel_category = xGetElementById("target_category"); + if(sel_category.options.length>1) { + var category_srl = sel_category.options[sel_category.selectedIndex].value; + fo_obj.category_srl.value = category_srl; + } + + procFilter(fo_obj, import_xml); + return false; +} + +/* Step Complete Import */ +function completeImport(ret_obj) { + alert(ret_obj["message"]); + location.href = location.href; +}