mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 02:31:40 +09:00
기본 마이그레이션용 XML및 ttxml에 대해 importing 100% 가능하도록 수정. importer 0.2 commit
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3947 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
1b8c765148
commit
c37932cc71
27 changed files with 1593 additions and 1294 deletions
|
|
@ -3,6 +3,9 @@
|
|||
<actions>
|
||||
<action name="dispImporterAdminContent" type="view" standalone="true" admin_index="true" />
|
||||
|
||||
<action name="procImporterAdminImport" type="controller" standalone="true" />
|
||||
<action name="procImporterAdminPreProcessing" type="controller" standalone="true" />
|
||||
|
||||
<action name="procImporterAdminSync" type="controller" standalone="true" />
|
||||
<action name="procImporterAdminMemberImport" type="controller" standalone="true" />
|
||||
<action name="procImporterAdminMessageImport" type="controller" standalone="true" />
|
||||
|
|
|
|||
207
modules/importer/extract.class.php
Normal file
207
modules/importer/extract.class.php
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
/**
|
||||
* @class extract
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief 대용량의 xml파일을 특정 태그를 중심으로 개별 파일로 저장하는 클래스
|
||||
**/
|
||||
class extract {
|
||||
var $key = '';
|
||||
var $cache_path = './files/cache/tmp';
|
||||
var $cache_index_file = './files/cache/tmp';
|
||||
|
||||
var $filename = null;
|
||||
var $startTag = '';
|
||||
var $endTag = '';
|
||||
var $itemStartTag = '';
|
||||
var $itemEndTag = '';
|
||||
|
||||
var $fd = null;
|
||||
var $index_fd = null;
|
||||
|
||||
var $isStarted = false;
|
||||
var $isFinished = true;
|
||||
|
||||
var $buff = 0;
|
||||
|
||||
var $index = 0;
|
||||
|
||||
/**
|
||||
* @brief 생성자, 대상 파일이름과 시작-끝 태그명, 그리고 각 개별 아이템 태그명을 인자로 받음
|
||||
**/
|
||||
function set($filename, $startTag, $endTag, $itemTag, $itemEndTag) {
|
||||
$this->filename = $filename;
|
||||
|
||||
$this->startTag = $startTag;
|
||||
if($endTag) $this->endTag = $endTag;
|
||||
$this->itemStartTag = $itemTag;
|
||||
$this->itemEndTag = $itemEndTag;
|
||||
|
||||
$this->key = md5($filename);
|
||||
|
||||
$this->cache_path = './files/cache/tmp/'.$this->key;
|
||||
$this->cache_index_file = $this->cache_path.'/index';
|
||||
|
||||
if(!is_dir($this->cache_path)) FileHandler::makeDir($this->cache_path);
|
||||
|
||||
return $this->openFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 지정된 파일의 지시자를 염
|
||||
**/
|
||||
function openFile() {
|
||||
@unlink($this->cache_index_file);
|
||||
$this->index_fd = fopen($this->cache_index_file,"a");
|
||||
|
||||
// local 파일일 경우
|
||||
if(!preg_match('/^http:/i',$this->filename)) {
|
||||
if(!file_exists($this->filename)) return new Object(-1,'msg_no_xml_file');
|
||||
$this->fd = fopen($this->filename,"r");
|
||||
|
||||
// remote 파일일 경우
|
||||
} else {
|
||||
$url_info = parse_url($this->filename);
|
||||
if(!$url_info['port']) $url_info['port'] = 80;
|
||||
if(!$url_info['path']) $url_info['path'] = '/';
|
||||
|
||||
$this->fd = @fsockopen($url_info['host'], $url_info['port']);
|
||||
if(!$this->fd) return new Object(-1,'msg_no_xml_file');
|
||||
|
||||
// 한글 파일이 있으면 한글파일 부분만 urlencode하여 처리 (iconv 필수)
|
||||
$path = $url_info['path'];
|
||||
if(preg_match('/[\xEA-\xED][\x80-\xFF]{2}/', $path)&&function_exists('iconv')) {
|
||||
$path_list = explode('/',$path);
|
||||
$cnt = count($path_list);
|
||||
$filename = $path_list[$cnt-1];
|
||||
$filename = urlencode(iconv("UTF-8","EUC-KR",$filename));
|
||||
$path_list[$cnt-1] = $filename;
|
||||
$path = implode('/',$path_list);
|
||||
$url_info['path'] = $path;
|
||||
}
|
||||
|
||||
$header = sprintf("GET %s?%s HTTP/1.0\r\nHost: %s\r\nReferer: %s://%s\r\nConnection: Close\r\n\r\n", $url_info['path'], $url_info['query'], $url_info['host'], $url_info['scheme'], $url_info['host']);
|
||||
@fwrite($this->fd, $header);
|
||||
$buff = '';
|
||||
while(!feof($this->fd)) {
|
||||
$buff .= $str = fgets($this->fd, 1024);
|
||||
if(!trim($str)) break;
|
||||
}
|
||||
if(preg_match('/404 Not Found/i',$buff)) return new Object(-1,'msg_no_xml_file');
|
||||
}
|
||||
|
||||
if($this->startTag) {
|
||||
while(!feof($this->fd)) {
|
||||
$str = fgets($this->fd, 1024);
|
||||
$pos = strpos($str, $this->startTag);
|
||||
if($pos !== false) {
|
||||
$this->buff = substr($this->buff, $pos+strlen($this->startTag));
|
||||
$this->isStarted = true;
|
||||
$this->isFinished = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->isStarted = true;
|
||||
$this->isFinished = false;
|
||||
}
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
function closeFile() {
|
||||
$this->isFinished = true;
|
||||
fclose($this->fd);
|
||||
fclose($this->index_fd);
|
||||
}
|
||||
|
||||
function isFinished() {
|
||||
return $this->isFinished || !$this->fd || feof($this->fd);
|
||||
}
|
||||
|
||||
function saveItems() {
|
||||
$this->index = 0;
|
||||
while(!$this->isFinished()) {
|
||||
$this->getItem();
|
||||
}
|
||||
}
|
||||
|
||||
function mergeItems($filename) {
|
||||
$this->saveItems();
|
||||
|
||||
$filename = sprintf('%s/%s', $this->cache_path, $filename);
|
||||
|
||||
$index_fd = fopen($this->cache_index_file,"r");
|
||||
$fd = fopen($filename,'w');
|
||||
|
||||
fwrite($fd, '<items>');
|
||||
while(!feof($index_fd)) {
|
||||
$target_file = trim(fgets($index_fd,1024));
|
||||
if(!file_exists($target_file)) continue;
|
||||
$buff = FileHandler::readFile($target_file);
|
||||
fwrite($fd, FileHandler::readFile($target_file));
|
||||
|
||||
@unlink($target_file);
|
||||
}
|
||||
fwrite($fd, '</items>');
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
function getItem() {
|
||||
if($this->isFinished()) return;
|
||||
|
||||
while(!feof($this->fd)) {
|
||||
$startPos = strpos($this->buff, $this->itemStartTag);
|
||||
if($startPos !== false) {
|
||||
$this->buff = substr($this->buff, $startPos);
|
||||
break;
|
||||
} elseif($this->endTag) {
|
||||
$endPos = strpos($this->buff, $this->endTag);
|
||||
if($endPos !== false) {
|
||||
$this->closeFile();
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->buff .= fgets($this->fd, 1024);
|
||||
}
|
||||
|
||||
$startPos = strpos($this->buff, $this->itemStartTag);
|
||||
if($startPos === false) {
|
||||
$this->closeFile();
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = sprintf('%s/%s.xml',$this->cache_path, $this->index++);
|
||||
fwrite($this->index_fd, $filename."\r\n");
|
||||
|
||||
$fd = fopen($filename,'w');
|
||||
|
||||
while(!feof($this->fd)) {
|
||||
$endPos = strpos($this->buff, $this->itemEndTag);
|
||||
if($endPos !== false) {
|
||||
$endPos += strlen($this->itemEndTag);
|
||||
$buff = substr($this->buff, 0, $endPos);
|
||||
fwrite($fd, $this->_addTagCRTail($buff));
|
||||
fclose($fd);
|
||||
$this->buff = substr($this->buff, $endPos);
|
||||
break;
|
||||
}
|
||||
|
||||
fwrite($fd, $this->_addTagCRTail($this->buff));
|
||||
$this->buff = fgets($this->fd, 1024);
|
||||
}
|
||||
}
|
||||
|
||||
function getTotalCount() {
|
||||
return $this->index;
|
||||
}
|
||||
|
||||
function getKey() {
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
function _addTagCRTail($str) {
|
||||
$str = preg_replace('/<\/([^>]*)></i', "</$1>\r\n<", $str);
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -50,6 +50,7 @@
|
|||
$template_filename = "index";
|
||||
break;
|
||||
}
|
||||
|
||||
$this->setTemplateFile($template_filename);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// words for button
|
||||
$lang->cmd_sync_member = 'Synchronize';
|
||||
$lang->cmd_continue = 'Continue';
|
||||
$lang->preprocessing = '데이터 이전을 위한 사전 준비중입니다.';
|
||||
|
||||
// items
|
||||
$lang->importer = 'Transfer Zeroboard Data';
|
||||
|
|
@ -51,7 +52,7 @@
|
|||
$lang->about_ttxml_user_id = 'Please input user ID to set as author on transfering TTXML. (user ID must be already signed up)';
|
||||
$lang->about_type_module = 'If you are transfering the board or articles information, select this option';
|
||||
$lang->about_type_syncmember = 'If you are trying to synchronize the member information after transfering member and article information, select this option';
|
||||
$lang->about_importer = "You can transfer Zeroboard4, Zeroboard5 Beta or other program's data into ZeroboardXE's data.\nIn order to tranfer, you have to use <a href=\"#\" onclick=\"winopen('');return false;\">XML Exporter</a> to convert the data you want into XML File then upload it.";
|
||||
$lang->about_importer = "You can transfer Zeroboard4, Zeroboard5 Beta or other program's data into ZeroboardXE's data.\nIn order to tranfer, you have to use <a href=\"http://svn.zeroboard.com/zeroboard_xe/migration_tools/\" onclick=\"winopen(this.href);return false;\">XML Exporter</a> to convert the data you want into XML File then upload it.";
|
||||
|
||||
$lang->about_target_path = "To get attachments from Zeroboard4, please input the address where Zeroboard4 is installed.\nIf it is located in the same server, input Zeroboard4's path such as /home/USERID/public_html/bbs\nIf it is not located in the same server, input the address where Zeroboard4 is installed. ex. http://Domain/bbs";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// Palabras para los botones
|
||||
$lang->cmd_sync_member = 'Sincronizar';
|
||||
$lang->cmd_continue = 'Continuar';
|
||||
$lang->preprocessing = '데이터 이전을 위한 사전 준비중입니다.';
|
||||
|
||||
// Especificaciones
|
||||
$lang->importer = 'Transferir los datos de zeroboard';
|
||||
|
|
@ -51,7 +52,7 @@
|
|||
$lang->about_ttxml_user_id = 'Por favor, de entrada ID de usuario establecer como autor de la transferencia de TTXML. (Identificación de usuario debe ser firmado ya en marcha)';
|
||||
$lang->about_type_module = 'Seleccione esta opción si estas transfeririendo información del documento de los tableros';
|
||||
$lang->about_type_syncmember = 'Seleccione esta opción cuando tenga que sincronizar la información del usuario luego de haber transferido la información del usuario y del artículo.';
|
||||
$lang->about_importer = "Es posible trasferir los datos de Zeroboard4, zb5beta o de otros programas a ZeroBoardXE.\nPara la transferencia debe utilizar <a href=\"#\" onclick=\"winopen('');return false;\">Exportador XML</a> para transformar los datos en archivo XML, y luego subir ese archivo.";
|
||||
$lang->about_importer = "Es posible trasferir los datos de Zeroboard4, zb5beta o de otros programas a ZeroBoardXE.\nPara la transferencia debe utilizar <a href=\"http://svn.zeroboard.com/zeroboard_xe/migration_tools/\" onclick=\"winopen(this.href);return false;\">XML Exporter</a> para transformar los datos en archivo XML, y luego subir ese archivo.";
|
||||
|
||||
$lang->about_target_path = "Para descargar los archivos adjuntos de ZeroBoard4, ingresa la ubicación de ZeroBoard4 instalado.\nSi esta en el mismo servidor escriba la ubicación de ZeroBoard4 como por ejemplo: /home/ID/public_html/bbs o si esta en otro servidor escriba la ubicación de ZeroBoard4 instalado como por ejemplo: http://dominio/bbs";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// words for button
|
||||
$lang->cmd_sync_member = 'Synchroniser';
|
||||
$lang->cmd_continue = 'Continuer';
|
||||
$lang->preprocessing = '데이터 이전을 위한 사전 준비중입니다.';
|
||||
|
||||
// items
|
||||
$lang->importer = 'Transférer des Données du Zeroboard';
|
||||
|
|
@ -51,7 +52,7 @@
|
|||
$lang->about_ttxml_user_id = 'Please input user ID to set as author on transfering TTXML. (user ID must be already signed up)';
|
||||
$lang->about_type_module = 'If you are transfering the board or articles information, select this option';
|
||||
$lang->about_type_syncmember = 'If you are trying to synchronize the member information after transfering member and article information, select this option';
|
||||
$lang->about_importer = "You can transfer Zeroboard4, Zeroboard5 Beta or other program's data into ZeroboardXE's data.\nIn order to tranfer, you have to use <a href=\"#\" onclick=\"winopen('');return false;\">XML Exporter</a> to convert the data you want into XML File then upload it.";
|
||||
$lang->about_importer = "You can transfer Zeroboard4, Zeroboard5 Beta or other program's data into ZeroboardXE's data.\nIn order to tranfer, you have to use <a href=\"http://svn.zeroboard.com/zeroboard_xe/migration_tools/\" onclick=\"winopen(this.href);return false;\">XML Exporter</a> to convert the data you want into XML File then upload it.";
|
||||
|
||||
$lang->about_target_path = "To get attachments from Zeroboard4, please input the address where Zeroboard4 is installed.\nIf it is located in the same server, input Zeroboard4's path such as /home/USERID/public_html/bbs\nIf it is not located in the same server, input the address where Zeroboard4 is installed. ex. http://Domain/bbs";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// ボタンに使用する用語
|
||||
$lang->cmd_sync_member = '同期化';
|
||||
$lang->cmd_continue = '続ける';
|
||||
$lang->preprocessing = '데이터 이전을 위한 사전 준비중입니다.';
|
||||
|
||||
// 項目
|
||||
$lang->importer = 'ZBデータ変換';
|
||||
|
|
@ -51,7 +52,7 @@
|
|||
$lang->about_ttxml_user_id = 'TTXML移転時に投稿者として指定するユーザIDを入力してください(すでに加入されているIDでなければなりません)。';
|
||||
$lang->about_type_module = 'データ変換の対象が書き込みデータである場合は選択してください。';
|
||||
$lang->about_type_syncmember = '会員情報と書き込みデータなどの変換を行った後、会員情報を同期化する必要がある場合は、選択してください。';
|
||||
$lang->about_importer = "ゼロボード4、zb5betaまたは他のプログラムの書き込みデータをゼロボードXEのデータに変換することができます。\n変換するためには、<a href=\"#\" onclick=\"winopen('');return false;\">XML Exporter</a>を利用して変換したい書き込みデータをXMLファイルで作成してアップロードしてください。";
|
||||
$lang->about_importer = "ゼロボード4、zb5betaまたは他のプログラムの書き込みデータをゼロボードXEのデータに変換することができます。\n変換するためには、<a href=\"http://svn.zeroboard.com/zeroboard_xe/migration_tools/\" onclick=\"winopen(this.href);return false;\">XML Exporter</a>を利用して変換したい書き込みデータをXMLファイルで作成してアップロードしてください。";
|
||||
|
||||
$lang->about_target_path = "添付ファイルをダウンロードするためには、ゼロボード4がインストールされた場所を入力してください。同じサーバ上にある場合は「/home/ID/public_html/bbs」のように入力し、他のサーバにある場合は、「http://ドメイン/bbs」のようにゼロボードがインストールされているURLを入力してください。";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// 버튼에 사용되는 언어
|
||||
$lang->cmd_sync_member = '동기화';
|
||||
$lang->cmd_continue = '계속진행';
|
||||
$lang->preprocessing = '데이터 이전을 위한 사전 준비중입니다.';
|
||||
|
||||
// 항목
|
||||
$lang->importer = '제로보드 데이터 이전';
|
||||
|
|
@ -26,6 +27,7 @@
|
|||
13 => 'Step 1-3. 대상 분류 선택',
|
||||
2 => 'Step 2. XML파일 지정',
|
||||
3 => 'Step 2. 회원정보와 게시물의 정보 동기화',
|
||||
99 => '데이터 이전',
|
||||
);
|
||||
|
||||
$lang->import_step_desc = array(
|
||||
|
|
@ -34,6 +36,7 @@
|
|||
13 => '데이터 이전을 할 대상 분류를 선택해주세요.',
|
||||
2 => "데이터 이전을 할 XML파일의 경로를 입력해주세요.\n상대 또는 절대 경로를 입력하시면 됩니다",
|
||||
3 => '회원정보와 게시물의 정보가 이전후에 맞지 않을 수 있습니다. 이 때 동기화를 하시면 user_id를 기반으로 올바르게 동작하도록 합니다.',
|
||||
99 => '데이터를 이전중입니다',
|
||||
);
|
||||
|
||||
// 안내/경고
|
||||
|
|
@ -51,6 +54,6 @@
|
|||
$lang->about_ttxml_user_id = 'TTXML이전시에 글쓴이로 지정할 사용자 아이디를 입력해주세요. (이미 가입된 아이디여야 합니다)';
|
||||
$lang->about_type_module = '데이터 이전 대상이 게시판등의 게시물 정보일 경우 선택해주세요';
|
||||
$lang->about_type_syncmember = '회원정보와 게시물정보등을 이전후 회원정보 동기화 해야 할때 선택해주세요';
|
||||
$lang->about_importer = "제로보드4, zb5beta 또는 다른 프로그램의 데이터를 제로보드XE 데이터로 이전할 수 있습니다.\n이전을 위해서는 <a href=\"#\" onclick=\"winopen('');return false;\">XML Exporter</a>를 이용해서 원하는 데이터를 XML파일로 생성후 업로드해주셔야 합니다.";
|
||||
$lang->about_importer = "제로보드4, zb5beta 또는 다른 프로그램의 데이터를 제로보드XE 데이터로 이전할 수 있습니다.\n이전을 위해서는 <a href=\"http://svn.zeroboard.com/zeroboard_xe/migration_tools/\" onclick=\"winopen(this.href);return false;\">XML Exporter</a>를 이용해서 원하는 데이터를 XML파일로 생성후 업로드해주셔야 합니다.";
|
||||
$lang->about_target_path = "첨부파일을 받기 위해 제로보드4가 설치된 위치를 입력해주세요.\n같은 서버에 있을 경우 /home/아이디/public_html/bbs 등과 같이 제로보드4의 위치를 입력하시고\n다른 서버일 경우 http://도메인/bbs 처럼 제로보드가 설치된 곳의 url을 입력해주세요";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// слова для кнопок
|
||||
$lang->cmd_sync_member = 'Синхронизировать';
|
||||
$lang->cmd_continue = 'Продолжить';
|
||||
$lang->preprocessing = '데이터 이전을 위한 사전 준비중입니다.';
|
||||
|
||||
// объекты
|
||||
$lang->importer = 'Импортировать данные zeroboard';
|
||||
|
|
@ -51,7 +52,7 @@
|
|||
$lang->about_ttxml_user_id = 'TTXML이전시에 글쓴이로 지정할 사용자 아이디를 입력해주세요. (이미 가입된 아이디여야 합니다)';
|
||||
$lang->about_type_module = 'Если Вы импортируете информацию форума или статей, выберите эту опцию';
|
||||
$lang->about_type_syncmember = 'Если Вы пытаетесь синхронизировать информацию пользователей после импорта информации пользователей и статей, выберите эту опцию';
|
||||
$lang->about_importer = "Вы можете импортировать данные Zeroboard4, Zeroboard5 Beta или других программ в ZeroboardXE.\nЧтобы импортировать, Вам следует использовать <a href=\"#\" onclick=\"winopen('');return false;\">XML Экспортер (XML Exporter)</a>, чтобы конвертировать нужные данные в XML Файл и затем загрузить его.";
|
||||
$lang->about_importer = "Вы можете импортировать данные Zeroboard4, Zeroboard5 Beta или других программ в ZeroboardXE.\nЧтобы импортировать, Вам следует использовать <a href=\"http://svn.zeroboard.com/zeroboard_xe/migration_tools/\" onclick=\"winopen(this.href);return false;\">XML Экспортер (XML Exporter)</a>, чтобы конвертировать нужные данные в XML Файл и затем загрузить его.";
|
||||
|
||||
$lang->about_target_path = "Чтобы получить вложения с Zeroboard4, пожалуйста, введите адрес, где установлена Zeroboard4.\nЕсли она раположена на том же сервере, введите путь к Zeroboard4 как /home/USERID/public_html/bbs\nЕсли нет, введите адрес, где Zeroboard4 установлена. Например: http://Domain/bbs";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// 按钮上使用的语言
|
||||
$lang->cmd_sync_member = '同步';
|
||||
$lang->cmd_continue = '继续进行';
|
||||
$lang->preprocessing = '데이터 이전을 위한 사전 준비중입니다.';
|
||||
|
||||
// 项目
|
||||
$lang->importer = '数据导入';
|
||||
|
|
@ -51,7 +52,7 @@
|
|||
$lang->about_ttxml_user_id = '请输入导入TTXML数据时指定为主题发布者的ID(必须是已注册会员)。';
|
||||
$lang->about_type_module = '数据导入对象为版面主题时请选择此项。';
|
||||
$lang->about_type_syncmember = '导入会员信息和文章信息后需要同步会员信息时请选择此项。';
|
||||
$lang->about_importer = "不仅可以导入Zeroboard 4,Zb5beta的数据,也可以把其他程序数据导入到Zeroboard XE当中。\n导入数据时请利用 <a href=\"#\" onclick=\"winopen('');return false;\">XML Exporter</a>生成XML文件后再上传。";
|
||||
$lang->about_importer = "不仅可以导入Zeroboard 4,Zb5beta的数据,也可以把其他程序数据导入到Zeroboard XE当中。\n导入数据时请利用 <a href=\"http://svn.zeroboard.com/zeroboard_xe/migration_tools/\" onclick=\"winopen(this.href);return false;\">XML Exporter</a>生成XML文件后再上传。";
|
||||
|
||||
$lang->about_target_path = "为了下载附件请输入Zeroboard 4的安装位置。\n位置在同一个服务器时,请输入如 /home/id/public_html/bbs的路径,在不同服务器时,请输入如 http://域名/bbs的url地址。";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
@charset "utf-8";
|
||||
|
||||
#step2_position { height:150px; overflow-y:scroll; border:2px solid #DDDDDD; }
|
||||
|
||||
div.progressBox { width:700px; margin:30px auto; border:1px solid #DDDDDD; white-space:nowrap; overflow:hidden; height:20px;}
|
||||
div.progress1 { float:left; border-right:1px solid #DDDDDD; text-align:right; overflow:hidden; background-color:#361DB5; color:#FFFFFF; font-family:tahoma; font-family:tahoma; font-size:9pt; white-space:nowrap; height:20px;}
|
||||
div.progress2 { float:left; text-align:left; overflow:hidden; white-space:nowrap; color:#444444; font-family:tahoma; font-size:9pt; height:20px;}
|
||||
|
||||
.w700 { width:700px; }
|
||||
|
|
|
|||
18
modules/importer/tpl/header.html
Normal file
18
modules/importer/tpl/header.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!--%import("js/importer_admin.js")-->
|
||||
<!--%import("css/importer.css")-->
|
||||
|
||||
{@ $type_list = array('module'=>$lang->type_module, 'ttxml'=>$lang->type_ttxml, 'member'=>$lang->type_member, 'sync'=>$lang->type_syncmember, 'message'=>$lang->type_message) }
|
||||
|
||||
<h3>{$lang->importer} <span class="gray">{$lang->cmd_management}</span></h3>
|
||||
|
||||
<!-- 설명 -->
|
||||
<div class="infoText">{nl2br($lang->about_importer)}</div>
|
||||
|
||||
<div class="header4">
|
||||
<ul class="localNavigation">
|
||||
<!--@foreach($type_list as $key => $val)-->
|
||||
<li <!--@if($source_type==$key)-->class="on"<!--@end-->><a href="{getUrl('source_type',$key)}">{$val}</a></li>
|
||||
<!--@end-->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
@ -16,25 +16,25 @@
|
|||
<col />
|
||||
<caption>{$lang->import_step_title[1]} - {$lang->import_step_desc[1]}</caption>
|
||||
<tr>
|
||||
<th scope="col"><label for="source_type_module">{$lang->type_module}</label></th>
|
||||
<th scope="col"><label for="source_type_module">1. {$lang->type_module}</label></th>
|
||||
<td class="left"><input type="radio" name="source_type" value="module" id="source_type_module" /> <label for="source_type_module">{$lang->about_type_module}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><label for="source_type_member">{$lang->type_member}</label></th>
|
||||
<td class="left"><input type="radio" name="source_type" value="member" id="source_type_member" /> <label for="source_type_member">{$lang->about_type_member}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><label for="source_type_message">{$lang->type_message}</label></th>
|
||||
<td class="left"><input type="radio" name="source_type" value="message" id="source_type_message" /> <label for="source_type_message">{$lang->about_type_message}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><label for="source_type_ttxml">{$lang->type_ttxml}</label></th>
|
||||
<th scope="col"><label for="source_type_ttxml">1. {$lang->type_ttxml}</label></th>
|
||||
<td class="left"><input type="radio" name="source_type" value="ttxml" id="source_type_ttxml" /> <label for="source_type_ttxml">{$lang->about_type_ttxml}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><label for="source_type_syncmember">{$lang->type_syncmember}</label></th>
|
||||
<th scope="col"><label for="source_type_member">2. {$lang->type_member}</label></th>
|
||||
<td class="left"><input type="radio" name="source_type" value="member" id="source_type_member" /> <label for="source_type_member">{$lang->about_type_member}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><label for="source_type_syncmember">3. {$lang->type_syncmember}</label></th>
|
||||
<td class="left"><input type="radio" name="source_type" value="sync" id="source_type_syncmember" /> <label for="source_type_syncmember">{$lang->about_type_syncmember}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="col"><label for="source_type_message">4. {$lang->type_message}</label></th>
|
||||
<td class="left"><input type="radio" name="source_type" value="message" id="source_type_message" /> <label for="source_type_message">{$lang->about_type_message}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" colspan="2" class="button">
|
||||
<span class="button"><input type="submit" value="{$lang->cmd_next}" /></span>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
* @author zero (zero@nzeo.com)
|
||||
* @brief importer에서 사용하는 javascript
|
||||
**/
|
||||
/* 회원정보와 게시물의 싱크 */
|
||||
|
||||
/**
|
||||
* 회원정보와 게시글/댓글등의 동기화 요청 및 결과 처리 함수
|
||||
**/
|
||||
function doSync(fo_obj) {
|
||||
exec_xml('importer','procImporterAdminSync', new Array(), completeSync);
|
||||
return false;
|
||||
|
|
@ -15,203 +18,144 @@ function completeSync(ret_obj) {
|
|||
}
|
||||
|
||||
|
||||
/* 회원정보 데이터 import */
|
||||
function doImportMember(fo_obj) {
|
||||
/**
|
||||
* xml파일을 DB입력전에 extract를 통해 분할 캐싱을 요청하는 함수
|
||||
**/
|
||||
var prepared = false;
|
||||
function doPreProcessing(fo_obj) {
|
||||
var xml_file = fo_obj.xml_file.value;
|
||||
if(!xml_file) return false;
|
||||
|
||||
var type = fo_obj.type.value;
|
||||
|
||||
xDisplay('importForm','none');
|
||||
xDisplay('process','block');
|
||||
xInnerHtml('status','');
|
||||
setTimeout(doPrepareDot, 50);
|
||||
|
||||
var params = new Array();
|
||||
params['xml_file'] = xml_file;
|
||||
params['total_count'] = fo_obj.total_count.value;
|
||||
params['success_count'] = fo_obj.success_count.value;
|
||||
params['readed_line'] = fo_obj.readed_line.value;
|
||||
params['type'] = type;
|
||||
|
||||
var response_tags = new Array("error","message", "total_count", "success_count", "readed_line", "is_finished");
|
||||
|
||||
exec_xml('importer','procImporterAdminMemberImport', params, completeImportMember, response_tags);
|
||||
var response_tags = new Array('error','message','type','total','cur','key','status');
|
||||
exec_xml('importer','procImporterAdminPreProcessing', params, completePreProcessing, response_tags);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function completeImportMember(ret_obj) {
|
||||
var total_count = ret_obj['total_count'];
|
||||
var success_count = ret_obj['success_count'];
|
||||
var readed_line = ret_obj['readed_line'];
|
||||
var is_finished = ret_obj['is_finished'];
|
||||
/* 준비중일때 .(dot) 찍어주는.. */
|
||||
function doPrepareDot() {
|
||||
if(prepared) return;
|
||||
|
||||
if(is_finished == '1') {
|
||||
var fo_obj = xGetElementById("fo_import");
|
||||
fo_obj.total_count.value = 0;
|
||||
fo_obj.success_count.value = 0;
|
||||
fo_obj.readed_line.value = 0;
|
||||
fo_obj.xml_file.disabled = false;
|
||||
xGetElementById("status").style.display = "none";
|
||||
xGetElementById("status_button_prev").style.display = "block";
|
||||
xGetElementById("status_button").style.display = "none";
|
||||
|
||||
|
||||
xInnerHtml("status", ret_obj['message']);
|
||||
alert(ret_obj['message']);
|
||||
} else {
|
||||
var fo_obj = xGetElementById("fo_import");
|
||||
fo_obj.total_count.value = total_count;
|
||||
fo_obj.success_count.value = success_count;
|
||||
fo_obj.readed_line.value = readed_line;
|
||||
fo_obj.xml_file.disabled = true;
|
||||
xGetElementById("status").style.display = "block";
|
||||
xGetElementById("status_button_prev").style.display = "none";
|
||||
xGetElementById("status_button").style.display = "block";
|
||||
xInnerHtml("status", ret_obj['message']);
|
||||
|
||||
doImportMember(fo_obj);
|
||||
}
|
||||
var str = xInnerHtml('status');
|
||||
if(str.length<1 || str.length - preProcessingMsg.length > 50) str = preProcessingMsg;
|
||||
else str += ".";
|
||||
xInnerHtml('status', str);
|
||||
setTimeout(doPrepareDot, 50);
|
||||
}
|
||||
|
||||
/* 쪽지 데이터 import */
|
||||
function doImportMessage(fo_obj) {
|
||||
var xml_file = fo_obj.xml_file.value;
|
||||
if(!xml_file) return false;
|
||||
/* 준비가 끝났을때 호출되는 함수 */
|
||||
function completePreProcessing(ret_obj, response_tags) {
|
||||
prepared = true;
|
||||
xInnerHtml('status','');
|
||||
|
||||
var status = ret_obj['status'];
|
||||
var message = ret_obj['message'];
|
||||
var type = ret_obj['type'];
|
||||
var total = parseInt(ret_obj['total'],10);
|
||||
var cur = parseInt(ret_obj['cur'],10);
|
||||
var key = ret_obj['key'];
|
||||
|
||||
if(status == -1) {
|
||||
xDisplay('importForm','block');
|
||||
xDisplay('process','none');
|
||||
xDisplay('btn_reload','block');
|
||||
xDisplay('btn_continue','none');
|
||||
alert(message);
|
||||
return;
|
||||
}
|
||||
|
||||
xDisplay('btn_reload','none');
|
||||
xDisplay('btn_continue','block');
|
||||
|
||||
var fo_obj = xGetElementById('fo_process');
|
||||
fo_obj.type.value = type;
|
||||
fo_obj.total.value = total;
|
||||
fo_obj.cur.value = cur;
|
||||
fo_obj.key.value = key;
|
||||
|
||||
var fo_import = xGetElementById('fo_import');
|
||||
if(fo_import && fo_import.target_module) fo_obj.target_module.value = fo_import.target_module.options[fo_import.target_module.selectedIndex].value;
|
||||
if(fo_import && fo_import.user_id) fo_obj.user_id.value = fo_import.user_id.value;
|
||||
|
||||
fo_obj.unit_count.value = fo_import.unit_count.options[fo_import.unit_count.selectedIndex].value;
|
||||
|
||||
// extract된 파일을 이용해서 import
|
||||
doImport();
|
||||
}
|
||||
|
||||
/* @brief 임포트 시작 */
|
||||
function doImport() {
|
||||
var fo_obj = xGetElementById('fo_process');
|
||||
|
||||
var params = new Array();
|
||||
params['xml_file'] = xml_file;
|
||||
params['total_count'] = fo_obj.total_count.value;
|
||||
params['success_count'] = fo_obj.success_count.value;
|
||||
params['readed_line'] = fo_obj.readed_line.value;
|
||||
|
||||
var response_tags = new Array("error","message", "total_count", "success_count", "readed_line", "is_finished");
|
||||
|
||||
exec_xml('importer','procImporterAdminMessageImport', params, completeImportMessage, response_tags);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function completeImportMessage(ret_obj) {
|
||||
var total_count = ret_obj['total_count'];
|
||||
var success_count = ret_obj['success_count'];
|
||||
var readed_line = ret_obj['readed_line'];
|
||||
var is_finished = ret_obj['is_finished'];
|
||||
|
||||
if(is_finished == '1') {
|
||||
var fo_obj = xGetElementById("fo_import");
|
||||
fo_obj.total_count.value = 0;
|
||||
fo_obj.success_count.value = 0;
|
||||
fo_obj.readed_line.value = 0;
|
||||
fo_obj.xml_file.disabled = false;
|
||||
xGetElementById("status").style.display = "none";
|
||||
xGetElementById("status_button_prev").style.display = "block";
|
||||
xGetElementById("status_button").style.display = "none";
|
||||
|
||||
|
||||
xInnerHtml("status", ret_obj['message']);
|
||||
alert(ret_obj['message']);
|
||||
} else {
|
||||
var fo_obj = xGetElementById("fo_import");
|
||||
fo_obj.total_count.value = total_count;
|
||||
fo_obj.success_count.value = success_count;
|
||||
fo_obj.readed_line.value = readed_line;
|
||||
fo_obj.xml_file.disabled = true;
|
||||
xGetElementById("status").style.display = "block";
|
||||
xGetElementById("status_button_prev").style.display = "none";
|
||||
xGetElementById("status_button").style.display = "block";
|
||||
xInnerHtml("status", ret_obj['message']);
|
||||
|
||||
doImportMessage(fo_obj);
|
||||
}
|
||||
}
|
||||
|
||||
/* 모듈 데이터 import */
|
||||
function doImportModule(fo_obj) {
|
||||
var target_module = fo_obj.target_module.options[fo_obj.target_module.selectedIndex].value;
|
||||
if(!target_module) return false;
|
||||
|
||||
var xml_file = fo_obj.xml_file.value;
|
||||
if(!xml_file) return false;
|
||||
|
||||
var params = new Array();
|
||||
params['xml_file'] = xml_file;
|
||||
params['target_module'] = target_module;
|
||||
params['total_count'] = fo_obj.total_count.value;
|
||||
params['success_count'] = fo_obj.success_count.value;
|
||||
params['readed_line'] = fo_obj.readed_line.value;
|
||||
|
||||
var response_tags = new Array("error","message", "total_count", "success_count", "readed_line", "is_finished");
|
||||
|
||||
exec_xml('importer','procImporterAdminModuleImport', params, completeImportModule, response_tags);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function completeImportModule(ret_obj, response_tags) {
|
||||
var total_count = ret_obj['total_count'];
|
||||
var success_count = ret_obj['success_count'];
|
||||
var readed_line = ret_obj['readed_line'];
|
||||
var is_finished = ret_obj['is_finished'];
|
||||
|
||||
if(is_finished == '1') {
|
||||
var fo_obj = xGetElementById("fo_import");
|
||||
fo_obj.target_module.disabled = false;
|
||||
fo_obj.xml_file.disabled = false;
|
||||
fo_obj.total_count.value = 0;
|
||||
fo_obj.success_count.value = 0;
|
||||
fo_obj.readed_line.value = 0;
|
||||
|
||||
xGetElementById("status").style.display = "none";
|
||||
xGetElementById("status_button_prev").style.display = "block";
|
||||
xGetElementById("status_button").style.display = "none";
|
||||
|
||||
|
||||
xInnerHtml("status", ret_obj['message']);
|
||||
|
||||
alert(ret_obj['message']);
|
||||
} else {
|
||||
var fo_obj = xGetElementById("fo_import");
|
||||
fo_obj.target_module.disabled = true;
|
||||
fo_obj.xml_file.disabled = true;
|
||||
fo_obj.total_count.value = total_count;
|
||||
fo_obj.success_count.value = success_count;
|
||||
fo_obj.readed_line.value = readed_line;
|
||||
|
||||
xGetElementById("status").style.display = "block";
|
||||
xGetElementById("status_button_prev").style.display = "none";
|
||||
xGetElementById("status_button").style.display = "block";
|
||||
|
||||
xInnerHtml("status", ret_obj['message']);
|
||||
|
||||
doImportModule(fo_obj);
|
||||
}
|
||||
}
|
||||
|
||||
/* TTXML 데이터 import */
|
||||
function doImportTTXML(fo_obj) {
|
||||
var target_module = fo_obj.target_module.options[fo_obj.target_module.selectedIndex].value;
|
||||
if(!target_module) return false;
|
||||
|
||||
var xml_file = fo_obj.xml_file.value;
|
||||
if(!xml_file) return false;
|
||||
|
||||
var params = new Array();
|
||||
params['xml_file'] = xml_file;
|
||||
params['target_module'] = target_module;
|
||||
params['total_count'] = fo_obj.total_count.value;
|
||||
params['success_count'] = fo_obj.success_count.value;
|
||||
params['readed_line'] = fo_obj.readed_line.value;
|
||||
params['type'] = fo_obj.type.value;
|
||||
params['total'] = fo_obj.total.value;
|
||||
params['cur'] = fo_obj.cur.value;
|
||||
params['key'] = fo_obj.key.value;
|
||||
params['target_module'] = fo_obj.target_module.value;
|
||||
params['unit_count'] = fo_obj.unit_count.value;
|
||||
params['user_id'] = fo_obj.user_id.value;
|
||||
|
||||
var response_tags = new Array("error","message", "total_count", "success_count", "readed_line", "is_finished");
|
||||
displayProgress(params['total'], params['cur']);
|
||||
|
||||
exec_xml('importer','procImporterAdminTTXMLImport', params, completeImportTTXML, response_tags);
|
||||
var response_tags = new Array('error','message','type','total','cur','key');
|
||||
|
||||
show_waiting_message = false;
|
||||
exec_xml('importer','procImporterAdminImport', params, completeImport, response_tags);
|
||||
show_waiting_message = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function completeImportTTXML(ret_obj, response_tags) {
|
||||
var total_count = ret_obj['total_count'];
|
||||
var success_count = ret_obj['success_count'];
|
||||
var readed_line = ret_obj['readed_line'];
|
||||
var is_finished = ret_obj['is_finished'];
|
||||
|
||||
xGetElementById("status").style.display = 'block';
|
||||
xInnerHtml("status", ret_obj['message']);
|
||||
/* import중 표시 */
|
||||
function completeImport(ret_obj, response_tags) {
|
||||
var message = ret_obj['message'];
|
||||
var type = ret_obj['type'];
|
||||
var total = parseInt(ret_obj['total'],10);
|
||||
var cur = parseInt(ret_obj['cur'],10);
|
||||
var key = ret_obj['key'];
|
||||
|
||||
alert(ret_obj['message']);
|
||||
displayProgress(total, cur);
|
||||
|
||||
var fo_obj = xGetElementById('fo_process');
|
||||
fo_obj.type.value = type;
|
||||
fo_obj.total.value = total;
|
||||
fo_obj.cur.value = cur;
|
||||
fo_obj.key.value = key;
|
||||
|
||||
// extract된 파일을 이용해서 import
|
||||
if(total>cur) doImport();
|
||||
else {
|
||||
alert(message);
|
||||
fo_obj.reset();
|
||||
xDisplay('process','none');
|
||||
xDisplay('importForm','block');
|
||||
xGetElementById('fo_import').reset();
|
||||
}
|
||||
}
|
||||
|
||||
/* 상태 표시 함수 */
|
||||
function displayProgress(total, cur) {
|
||||
// 진행률 구함
|
||||
var per = 0;
|
||||
if(total > 0) per = Math.round(cur/total*100);
|
||||
else per = 100;
|
||||
if(!per) per = 1;
|
||||
|
||||
var status = '<div class="progressBox"><div class="progress1" style="width:'+per+'%;">'+per+'% </div>';
|
||||
status += '<div class="progress2">'+cur+'/'+total+'</div>';
|
||||
status += '<div class="clear"></div></div>';
|
||||
xInnerHtml('status', status);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,34 @@
|
|||
<!--%import("js/importer_admin.js")-->
|
||||
<!--%import("css/importer.css")-->
|
||||
<!--#include("header.html")-->
|
||||
|
||||
<h3>{$lang->importer} <span class="gray">{$lang->cmd_management}</span></h3>
|
||||
|
||||
<div class="infoText">{nl2br($lang->about_importer)}</div>
|
||||
|
||||
<div>
|
||||
<form action="./" method="get" onsubmit="return doImportMember(this)" id="fo_import">
|
||||
<input type="hidden" name="total_count" value="0" />
|
||||
<input type="hidden" name="success_count" value="0" />
|
||||
<input type="hidden" name="readed_line" value="0" />
|
||||
<div id="importForm">
|
||||
<form action="./" method="get" onsubmit="return doPreProcessing(this)" id="fo_import">
|
||||
<input type="hidden" name="type" value="member" />
|
||||
|
||||
<table cellspacing="0" class="adminTable">
|
||||
<caption>{$lang->import_step_title[2]} - {$lang->import_step_desc[2]}</caption>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w400" />
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w700" />
|
||||
<p>ex1) ../member.xml</p>
|
||||
<p>ex2) http://...../member.xml</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="button">
|
||||
<div id="status_button_prev"><span class="button"><input type="submit" value="{$lang->cmd_next}" /></span></div>
|
||||
<div id="status_button" style="display:none"><span class="button"><input type="submit" value="{$lang->cmd_continue}" /></span></div>
|
||||
<select name="unit_count">
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
<option value="200">200</option>
|
||||
<option value="300" selected="selected">300</option>
|
||||
<option value="400">400</option>
|
||||
<option value="500">500</option>
|
||||
<option value="1000">1000</option>
|
||||
</select>
|
||||
<span class="button"><input type="submit" value="{$lang->cmd_next}" /></span>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="status" style="display:none"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!--#include("./process.html")-->
|
||||
|
|
|
|||
|
|
@ -1,33 +1,34 @@
|
|||
<!--%import("js/importer_admin.js")-->
|
||||
<!--%import("css/importer.css")-->
|
||||
<!--#include("header.html")-->
|
||||
|
||||
<h3>{$lang->importer} <span class="gray">{$lang->cmd_management}</span></h3>
|
||||
|
||||
<div class="infoText">{nl2br($lang->about_importer)}</div>
|
||||
|
||||
<div>
|
||||
<form action="./" method="get" onsubmit="return doImportMessage(this)" id="fo_import">
|
||||
<input type="hidden" name="total_count" value="0" />
|
||||
<input type="hidden" name="success_count" value="0" />
|
||||
<input type="hidden" name="readed_line" value="0" />
|
||||
<div id="importForm">
|
||||
<form action="./" method="get" onsubmit="return doPreProcessing(this)" id="fo_import">
|
||||
<input type="hidden" name="type" value="message" />
|
||||
|
||||
<table cellspacing="0" class="adminTable">
|
||||
<caption>{$lang->import_step_title[2]} - {$lang->import_step_desc[2]}</caption>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w400" />
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w700" />
|
||||
<p>ex1) ../message.xml</p>
|
||||
<p>ex2) http://...../message.xml</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="button">
|
||||
<div id="status_button_prev"><span class="button"><input type="submit" value="{$lang->cmd_next}" /></span></div>
|
||||
<div id="status_button" style="display:none"><span class="button"><input type="submit" value="{$lang->cmd_continue}" /></span></div>
|
||||
<select name="unit_count">
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
<option value="200">200</option>
|
||||
<option value="300" selected="selected">300</option>
|
||||
<option value="400">400</option>
|
||||
<option value="500">500</option>
|
||||
<option value="1000">1000</option>
|
||||
</select>
|
||||
<span class="button"><input type="submit" value="{$lang->cmd_next}" /></span>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="status" style="display:none"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!--#include("./process.html")-->
|
||||
|
|
|
|||
|
|
@ -1,23 +1,15 @@
|
|||
<!--%import("js/importer_admin.js")-->
|
||||
<!--%import("css/importer.css")-->
|
||||
|
||||
<h3>{$lang->importer} <span class="gray">{$lang->cmd_management}</span></h3>
|
||||
|
||||
<!-- 설명 -->
|
||||
<div class="infoText">{nl2br($lang->about_importer)}</div>
|
||||
<!--#include("header.html")-->
|
||||
|
||||
<!-- step 1-2. 대상이 게시물 정보일 경우 대상 모듈 목록을 선택하도록 함 -->
|
||||
<div>
|
||||
<form action="./" method="get" onsubmit="return doImportModule(this)" id="fo_import">
|
||||
<input type="hidden" name="total_count" value="0" />
|
||||
<input type="hidden" name="success_count" value="0" />
|
||||
<input type="hidden" name="readed_line" value="0" />
|
||||
<div id="importForm">
|
||||
<form action="./" method="get" onsubmit="return doPreProcessing(this)" id="fo_import">
|
||||
<input type="hidden" name="type" value="module" />
|
||||
|
||||
<table cellspacing="0" class="adminTable">
|
||||
<caption>{$lang->import_step_title[1]} - {$lang->import_step_desc[12]}</caption>
|
||||
<tr>
|
||||
<td>
|
||||
<select name="target_module">
|
||||
<select name="target_module" class="w400">
|
||||
<option value="">====================</option>
|
||||
<!--@foreach($mid_list as $key => $val)-->
|
||||
<option value="{$val->module_srl}">{$val->browser_title}</option>
|
||||
|
|
@ -31,21 +23,31 @@
|
|||
<caption>{$lang->import_step_title[2]} - {$lang->import_step_desc[2]}</caption>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w400" />
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w700" />
|
||||
<p>ex1) ../module.xml</p>
|
||||
<p>ex2) http://...../module.xml</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="button">
|
||||
<div id="status_button_prev"><span class="button"><input type="submit" value="{$lang->cmd_next}" /></span></div>
|
||||
<div id="status_button" style="display:none"><span class="button"><input type="submit" value="{$lang->cmd_continue}" /></span></div>
|
||||
<select name="unit_count">
|
||||
<option value="10">10</option>
|
||||
<option value="20">20</option>
|
||||
<option value="30">30</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100" selected="select">100</option>
|
||||
<option value="200">200</option>
|
||||
<option value="300">300</option>
|
||||
<option value="400">400</option>
|
||||
<option value="500">500</option>
|
||||
<option value="1000">1000</option>
|
||||
</select>
|
||||
<span class="button"><input type="submit" value="{$lang->cmd_next}" /></span>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="status" style="display:none"></div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!--#include("./process.html")-->
|
||||
|
|
|
|||
30
modules/importer/tpl/process.html
Normal file
30
modules/importer/tpl/process.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<script type="text/javascript">
|
||||
var preProcessingMsg = "{$lang->preprocessing}";
|
||||
</script>
|
||||
|
||||
<div id="process" style="display:none;">
|
||||
<form action="./" method="get" onsubmit="return doImport()" id="fo_process">
|
||||
<input type="hidden" name="type" value="" />
|
||||
<input type="hidden" name="total" value="" />
|
||||
<input type="hidden" name="cur" value="" />
|
||||
<input type="hidden" name="key" value="" />
|
||||
<input type="hidden" name="target_module" value="" />
|
||||
<input type="hidden" name="unit_count" value="" />
|
||||
<input type="hidden" name="user_id" value="" />
|
||||
|
||||
<table cellspacing="0" class="adminTable">
|
||||
<caption>{$lang->import_step_title[99]} - {$lang->import_step_desc[99]}</caption>
|
||||
<tr>
|
||||
<td>
|
||||
<div id="status"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="button">
|
||||
<div id="btn_reload" style="display:block;"><span class="button"><input type="button" value="{$lang->cmd_reload}" onclick="location.reload(); return false;"/></span></div>
|
||||
<div id="btn_continue" style="display:none;"><span class="button"><input type="submit" value="{$lang->cmd_continue}" /></span></div>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -1,16 +1,10 @@
|
|||
<!--%import("js/importer_admin.js")-->
|
||||
<!--%import("css/importer.css")-->
|
||||
<!--#include("header.html")-->
|
||||
|
||||
<h3>{$lang->importer} <span class="gray">{$lang->cmd_management}</span></h3>
|
||||
|
||||
<!-- 설명 -->
|
||||
<div class="infoText">{nl2br($lang->about_importer)}</div>
|
||||
|
||||
<form action="./" method="get" onsubmit="return doSync(this)">
|
||||
<table cellspacing="0" class="adminTable">
|
||||
<caption>{$lang->import_step_title[3]} - {$lang->import_step_desc[3]}</caption>
|
||||
<tr>
|
||||
<td><span class="button"><input type="submit" value="{$lang->cmd_sync_member}" /></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<form action="./" method="get" onsubmit="return doSync(this)">
|
||||
<table cellspacing="0" class="adminTable">
|
||||
<caption>{$lang->import_step_title[3]} - {$lang->import_step_desc[3]}</caption>
|
||||
<tr>
|
||||
<td><span class="button"><input type="submit" value="{$lang->cmd_sync_member}" /></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,17 +1,9 @@
|
|||
<!--%import("js/importer_admin.js")-->
|
||||
<!--%import("css/importer.css")-->
|
||||
|
||||
<h3>{$lang->importer} <span class="gray">{$lang->cmd_management}</span></h3>
|
||||
|
||||
<!-- 설명 -->
|
||||
<div class="infoText">{nl2br($lang->about_importer)}</div>
|
||||
<!--#include("header.html")-->
|
||||
|
||||
<!-- step 1-2. 대상이 게시물 정보일 경우 대상 모듈 목록을 선택하도록 함 -->
|
||||
<div>
|
||||
<form action="./" method="get" onsubmit="return doImportTTXML(this)" id="fo_import">
|
||||
<input type="hidden" name="total_count" value="0" />
|
||||
<input type="hidden" name="success_count" value="0" />
|
||||
<input type="hidden" name="readed_line" value="0" />
|
||||
<div id="importForm">
|
||||
<form action="./" method="get" onsubmit="return doPreProcessing(this)" id="fo_import">
|
||||
<input type="hidden" name="type" value="ttxml" />
|
||||
|
||||
<table cellspacing="0" class="adminTable">
|
||||
<caption>{$lang->import_step_title[1]} - {$lang->import_step_desc[12]}</caption>
|
||||
|
|
@ -40,21 +32,30 @@
|
|||
<caption>{$lang->import_step_title[2]} - {$lang->import_step_desc[2]}</caption>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w400" />
|
||||
<input type="text" name="xml_file" value="./" class="inputTypeText w700" />
|
||||
<p>ex1) ../module.xml</p>
|
||||
<p>ex2) http://...../module.xml</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="button">
|
||||
<div id="status_button_prev"><span class="button"><input type="submit" value="{$lang->cmd_next}" /></span></div>
|
||||
<div id="status_button" style="display:none"><span class="button"><input type="submit" value="{$lang->cmd_continue}" /></span></div>
|
||||
<select name="unit_count">
|
||||
<option value="10">10</option>
|
||||
<option value="20">20</option>
|
||||
<option value="30">30</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100" selected="selected">100</option>
|
||||
<option value="200">200</option>
|
||||
<option value="300">300</option>
|
||||
<option value="400">400</option>
|
||||
<option value="500">500</option>
|
||||
<option value="1000">1000</option>
|
||||
</select>
|
||||
<span class="button"><input type="submit" value="{$lang->cmd_next}" /></span>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="status" style="display:none"></div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!--#include("./process.html")-->
|
||||
|
|
|
|||
413
modules/importer/ttimport.class.php
Normal file
413
modules/importer/ttimport.class.php
Normal file
|
|
@ -0,0 +1,413 @@
|
|||
<?php
|
||||
/**
|
||||
* @class ttimport
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief ttxml import class
|
||||
**/
|
||||
|
||||
@set_time_limit(0);
|
||||
@require_once('./modules/importer/extract.class.php');
|
||||
|
||||
class ttimport {
|
||||
|
||||
var $oXmlParser = null;
|
||||
|
||||
/**
|
||||
* @brief module.xml 형식의 데이터 import
|
||||
**/
|
||||
function importModule($key, $cur, $index_file, $unit_count, $module_srl, $user_id) {
|
||||
// 필요한 객체 미리 생성
|
||||
$this->oXmlParser = new XmlParser();
|
||||
|
||||
// 타겟 모듈의 카테고리 정보 구함
|
||||
$oDocumentModel = &getModel('document');
|
||||
$category_list = $category_titles = array();
|
||||
$category_list = $oDocumentModel->getCategoryList($module_srl);
|
||||
if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
|
||||
|
||||
// 먼저 카테고리 정보를 입력함
|
||||
$category_file = preg_replace('/index$/i', 'category', $index_file);
|
||||
if(file_exists($category_file)) {
|
||||
$buff = FileHandler::readFile($category_file);
|
||||
|
||||
// xmlParser객체 생성
|
||||
$xmlDoc = $this->oXmlParser->loadXmlFile($category_file);
|
||||
|
||||
$categories = $xmlDoc->items->category;
|
||||
if($categories) {
|
||||
if(!is_array($categories)) $categories = array($categories);
|
||||
$oDocumentController = &getController('document');
|
||||
foreach($categories as $k => $v) {
|
||||
$category = $v->name->body;
|
||||
if(!$category || $category_titles[$category]) continue;
|
||||
|
||||
$obj = null;
|
||||
$obj->title = $category;
|
||||
$obj->module_srl = $module_srl;
|
||||
$output = $oDocumentController->insertCategory($obj);
|
||||
}
|
||||
$oDocumentController = &getController('document');
|
||||
$oDocumentController->makeCategoryFile($module_srl);
|
||||
}
|
||||
@unlink($category_file);
|
||||
}
|
||||
|
||||
$category_list = $category_titles = array();
|
||||
$category_list = $oDocumentModel->getCategoryList($module_srl);
|
||||
if(count($category_list)) foreach($category_list as $key => $val) $category_titles[$val->title] = $val->category_srl;
|
||||
|
||||
// 관리자 정보를 구함
|
||||
$oMemberModel = &getModel('member');
|
||||
$member_info = $oMemberModel->getMemberInfoByUserID($user_id);
|
||||
|
||||
if(!$cur) $cur = 0;
|
||||
|
||||
// index파일을 염
|
||||
$f = fopen($index_file,"r");
|
||||
|
||||
// 이미 읽혀진 것은 패스
|
||||
for($i=0;$i<$cur;$i++) fgets($f, 1024);
|
||||
|
||||
// 라인단위로 읽어들이면서 $cur보다 커지고 $cur+$unit_count개보다 작으면 중지
|
||||
for($idx=$cur;$idx<$cur+$unit_count;$idx++) {
|
||||
if(feof($f)) break;
|
||||
|
||||
// 정해진 위치를 찾음
|
||||
$target_file = trim(fgets($f, 1024));
|
||||
|
||||
if(!file_exists($target_file)) continue;
|
||||
|
||||
// 이제부터 데이터를 가져오면서 처리
|
||||
$fp = fopen($target_file,"r");
|
||||
if(!$fp) continue;
|
||||
|
||||
$obj = null;
|
||||
$obj->module_srl = $module_srl;
|
||||
$obj->document_srl = getNextSequence();
|
||||
$obj->uploaded_count = 0;
|
||||
|
||||
$files = array();
|
||||
|
||||
$started = false;
|
||||
$buff = null;
|
||||
|
||||
// 본문 데이터부터 처리 시작
|
||||
while(!feof($fp)) {
|
||||
$str = fgets($fp, 1024);
|
||||
|
||||
// 한 아이템 준비 시작
|
||||
if(substr($str,0,5) == '<post') {
|
||||
$started = true;
|
||||
continue;
|
||||
|
||||
// 첨부파일 입력
|
||||
} else if(substr($str,0,12) == '<attachment ') {
|
||||
if($this->importAttaches($fp, $module_srl, $obj->document_srl, $files, $str)) $obj->uploaded_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if($started) $buff .= $str;
|
||||
}
|
||||
|
||||
$xmlDoc = $this->oXmlParser->parse('<post>'.$buff);
|
||||
|
||||
$category = $xmlDoc->post->category->body;
|
||||
if($category_titles[$category]) $obj->category_srl = $category_titles[$category];
|
||||
|
||||
$obj->is_notice = 'N';
|
||||
$obj->is_secret = $xmlDoc->post->visibility->body=='syndicated'?'N':'Y';
|
||||
$obj->title = $xmlDoc->post->title->body;
|
||||
$obj->content = $xmlDoc->post->content->body;
|
||||
$obj->password = md5($xmlDoc->post->password->body);
|
||||
//$obj->allow_comment = $xmlDoc->post->acceptComment->body==1?'Y':'N';
|
||||
$obj->allow_comment = 'Y';
|
||||
//$obj->allow_trackback = $xmlDoc->post->acceptTrackback->body==1?'Y':'N';
|
||||
$obj->allow_trackback = 'Y';
|
||||
$obj->regdate = date("YmdHis",$xmlDoc->post->published->body);
|
||||
$obj->last_update = date("YmdHis", $xmlDoc->post->modified->body);
|
||||
if(!$obj->last_update) $obj->last_update = $obj->regdate;
|
||||
|
||||
$tag = null;
|
||||
$tmp_tags = null;
|
||||
$tag = $xmlDoc->post->tag;
|
||||
if($tag) {
|
||||
if(!is_array($tag)) $tag = array($tag);
|
||||
foreach($tag as $key => $val) $tmp_tags[] = $val->body;
|
||||
$obj->tags = implode(',',$tmp_tags);
|
||||
}
|
||||
|
||||
$obj->readed_count = 0;
|
||||
$obj->voted_count = 0;
|
||||
$obj->nick_name = $member_info->nick_name;
|
||||
$obj->user_name = $member_info->user_name;
|
||||
$obj->user_id = $member_info->user_id;
|
||||
$obj->member_srl = $member_info->member_srl;
|
||||
$obj->email_address = $member_info->email_address;
|
||||
$obj->homepage = $member_info->homepage;
|
||||
$obj->ipaddress = $_REMOTE['SERVER_ADDR'];
|
||||
$obj->list_order = $obj->update_order = $obj->document_srl*-1;
|
||||
$obj->lock_comment = 'N';
|
||||
$obj->notify_message = 'N';
|
||||
|
||||
// content 정보 변경 (첨부파일)
|
||||
$obj->content = str_replace('[##_ATTACH_PATH_##]/','',$obj->content);
|
||||
if(count($files)) {
|
||||
foreach($files as $label => $filename) {
|
||||
$obj->content = preg_replace_callback('!\[##_([a-z0-9]+)\|([^\|]*)\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTImgTag'), $obj->content);
|
||||
}
|
||||
}
|
||||
if(count($files)) {
|
||||
foreach($files as $key => $val) {
|
||||
$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val.'"',$obj->content);
|
||||
}
|
||||
}
|
||||
|
||||
// 역인글 입력
|
||||
$obj->trackback_count = 0;
|
||||
if($xmlDoc->post->trackback) {
|
||||
$trackbacks = $xmlDoc->post->trackback;
|
||||
if(!is_array($trackbacks)) $trackbacks = array($trackbacks);
|
||||
if(count($trackbacks)) {
|
||||
foreach($trackbacks as $key => $val) {
|
||||
$tobj = null;
|
||||
$tobj->trackback_srl = getNextSequence();
|
||||
$tobj->module_srl = $module_srl;
|
||||
$tobj->document_srl = $obj->document_srl;
|
||||
$tobj->url = $val->url->body;
|
||||
$tobj->title = $val->title->body;
|
||||
$tobj->blog_name = $val->site->body;
|
||||
$tobj->excerpt = $val->excerpt->body;
|
||||
$tobj->regdate = date("YmdHis",$val->received->body);
|
||||
$tobj->ipaddress = $val->ip->body;
|
||||
$tobj->list_order = -1*$tobj->trackback_srl;
|
||||
$output = executeQuery('trackback.insertTrackback', $tobj);
|
||||
if($output->toBool()) $obj->trackback_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 댓글입력
|
||||
$obj->comment_count = 0;
|
||||
if($xmlDoc->post->comment) {
|
||||
$comment = $xmlDoc->post->comment;
|
||||
if(!is_array($comment)) $comment = array($comment);
|
||||
foreach($comment as $key => $val) {
|
||||
$parent_srl = $this->insertComment($val, $module_srl, $obj->document_srl, 0);
|
||||
if($parent_srl === false) continue;
|
||||
|
||||
$obj->comment_count++;
|
||||
if($val->comment) {
|
||||
$child_comment = $val->comment;
|
||||
if(!is_array($child_comment)) $child_comment = array($child_comment);
|
||||
foreach($child_comment as $k => $v) {
|
||||
$result = $this->insertComment($v, $module_srl, $obj->document_srl, $parent_srl);
|
||||
if($result !== false) $obj->comment_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 문서 입력
|
||||
$output = executeQuery('document.insertDocument', $obj);
|
||||
|
||||
if($output->toBool()) {
|
||||
// 태그 입력
|
||||
if($obj->tags) {
|
||||
$tag_list = explode(',',$obj->tags);
|
||||
$tag_count = count($tag_list);
|
||||
for($i=0;$i<$tag_count;$i++) {
|
||||
$args = null;
|
||||
$args->tag_srl = getNextSequence();
|
||||
$args->module_srl = $module_srl;
|
||||
$args->document_srl = $obj->document_srl;
|
||||
$args->tag = trim($tag_list[$i]);
|
||||
$args->regdate = $obj->regdate;
|
||||
if(!$args->tag) continue;
|
||||
$output = executeQuery('tag.insertTag', $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
@unlink($target_file);
|
||||
}
|
||||
|
||||
fclose($f);
|
||||
|
||||
return $idx-1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 첨부파일 정리
|
||||
**/
|
||||
function importAttaches($fp, $module_srl, $upload_target_srl, &$files, $buff) {
|
||||
$uploaded_count = 0;
|
||||
|
||||
$file_obj = null;
|
||||
$file_obj->file_srl = getNextSequence();
|
||||
$file_obj->upload_target_srl = $upload_target_srl;
|
||||
$file_obj->module_srl = $module_srl;
|
||||
|
||||
while(!feof($fp)) {
|
||||
$str = fgets($fp, 1024);
|
||||
|
||||
// </attaches>로 끝나면 중단
|
||||
if(trim($str) == '</attachment>') break;
|
||||
|
||||
// <file>로 시작하면 xml파일내의 첨부파일로 처리
|
||||
if(substr($str, 0, 9)=='<content>') {
|
||||
$file_obj->file = $this->saveTemporaryFile($fp, $str);
|
||||
continue;
|
||||
}
|
||||
|
||||
$buff .= $str;
|
||||
}
|
||||
|
||||
$buff .= '</attachment>';
|
||||
|
||||
$xmlDoc = $this->oXmlParser->parse($buff);
|
||||
|
||||
$file_obj->source_filename = $xmlDoc->attachment->name->body;
|
||||
$file_obj->download_count = $xmlDoc->attachment->downloads->body;
|
||||
$label = $xmlDoc->attachment->label->body;
|
||||
|
||||
// 이미지인지 기타 파일인지 체크하여 upload path 지정
|
||||
if(preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp3|asaf|wav|asx|midi|asf)$/i", $file_obj->source_filename)) {
|
||||
$path = sprintf("./files/attach/images/%s/%s/", $module_srl,$upload_target_srl);
|
||||
$filename = $path.$file_obj->source_filename;
|
||||
$file_obj->direct_download = 'Y';
|
||||
} else {
|
||||
$path = sprintf("./files/attach/binaries/%s/%s/", $module_srl, $upload_target_srl);
|
||||
$filename = $path.md5(crypt(rand(1000000,900000), rand(0,100)));
|
||||
$file_obj->direct_download = 'N';
|
||||
}
|
||||
|
||||
// 디렉토리 생성
|
||||
if(!FileHandler::makeDir($path)) continue;
|
||||
|
||||
@rename($file_obj->file, $filename);
|
||||
|
||||
// DB입력
|
||||
unset($file_obj->file);
|
||||
$file_obj->uploaded_filename = $filename;
|
||||
$file_obj->file_size = filesize($filename);
|
||||
$file_obj->comment = NULL;
|
||||
$file_obj->member_srl = 0;
|
||||
$file_obj->sid = md5(rand(rand(1111111,4444444),rand(4444445,9999999)));
|
||||
$file_obj->isvalid = 'Y';
|
||||
$output = executeQuery('file.insertFile', $file_obj);
|
||||
|
||||
if($output->toBool()) {
|
||||
$uploaded_count++;
|
||||
$tmp_obj = null;
|
||||
$tmp_obj->source_filename = $file_obj->source_filename;
|
||||
if($file_obj->direct_download == 'Y') $files[$file_obj->source_filename] = $file_obj->uploaded_filename;
|
||||
else $files[$file_obj->source_filename] = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @biref 임의로 사용할 파일이름을 return
|
||||
**/
|
||||
function getTmpFilename() {
|
||||
$path = "./files/cache/tmp";
|
||||
if(!is_dir($path)) FileHandler::makeDir($path);
|
||||
$filename = sprintf("%s/%d", $path, rand(11111111,99999999));
|
||||
if(file_exists($filename)) $filename .= rand(111,999);
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 파일포인트로부터 key에 해당하는 값이 나타날때까지 buff를 읽음
|
||||
**/
|
||||
function saveTemporaryFile($fp, $buff) {
|
||||
$temp_filename = $this->getTmpFilename();
|
||||
$buff = substr($buff, 9);
|
||||
|
||||
while(!feof($fp)) {
|
||||
$str = trim(fgets($fp, 1024));
|
||||
$buff .= $str;
|
||||
if(substr($str, -10) == '</content>') break;
|
||||
}
|
||||
|
||||
$buff = substr($buff, 0, -10);
|
||||
|
||||
$f = fopen($temp_filename, "w");
|
||||
fwrite($f, base64_decode($buff));
|
||||
fclose($f);
|
||||
return $temp_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ttxml의 자체 img 태그를 치환
|
||||
**/
|
||||
function _replaceTTImgTag($matches) {
|
||||
return sprintf("<img src=\"%s\" alt=\"%s\" /><br /><br />", $matches[2], str_replace("\"","\\\"",$matches[4]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 댓글 입력
|
||||
**/
|
||||
function insertComment($val, $module_srl, $document_srl, $parent_srl = 0) {
|
||||
$tobj = null;
|
||||
$tobj->comment_srl = getNextSequence();
|
||||
$tobj->module_srl = $module_srl;
|
||||
$tobj->document_srl = $document_srl;
|
||||
$tobj->is_secret = $val->secret->body==1?'Y':'N';
|
||||
$tobj->notify_message = 'N';
|
||||
$tobj->content = nl2br($val->content->body);
|
||||
$tobj->voted_count = 0;
|
||||
$tobj->password = $val->password->body;
|
||||
$tobj->nick_name = $val->commenter->name->body;
|
||||
$tobj->member_srl = 0;
|
||||
$tobj->homepage = $val->commenter->homepage->body;
|
||||
$tobj->last_update = $tobj->regdate = date("YmdHis",$val->written->body);
|
||||
$tobj->ipaddress = $val->commenter->ip->body;
|
||||
$tobj->list_order = $tobj->comment_srl*-1;
|
||||
$tobj->sequence = $sequence;
|
||||
$tobj->parent_srl = $parent_srl;
|
||||
|
||||
// 댓글 목록 부분을 먼저 입력
|
||||
$list_args = null;
|
||||
$list_args->comment_srl = $tobj->comment_srl;
|
||||
$list_args->document_srl = $tobj->document_srl;
|
||||
$list_args->module_srl = $tobj->module_srl;
|
||||
$list_args->regdate = $tobj->regdate;
|
||||
|
||||
// 부모댓글이 없으면 바로 데이터를 설정
|
||||
if(!$tobj->parent_srl) {
|
||||
$list_args->head = $list_args->arrange = $tobj->comment_srl;
|
||||
$list_args->depth = 0;
|
||||
|
||||
// 부모댓글이 있으면 부모글의 정보를 구해옴
|
||||
} else {
|
||||
// 부모댓글의 정보를 구함
|
||||
$parent_args->comment_srl = $tobj->parent_srl;
|
||||
$parent_output = executeQuery('comment.getCommentListItem', $parent_args);
|
||||
|
||||
// 부모댓글이 존재하지 않으면 return
|
||||
if(!$parent_output->toBool() || !$parent_output->data) continue;
|
||||
$parent = $parent_output->data;
|
||||
|
||||
$list_args->head = $parent->head;
|
||||
$list_args->depth = $parent->depth+1;
|
||||
if($list_args->depth<2) $list_args->arrange = $tobj->comment_srl;
|
||||
else {
|
||||
$list_args->arrange = $parent->arrange;
|
||||
$output = executeQuery('comment.updateCommentListArrange', $list_args);
|
||||
if(!$output->toBool()) return $output;
|
||||
}
|
||||
}
|
||||
|
||||
$output = executeQuery('comment.insertCommentList', $list_args);
|
||||
if($output->toBool()) {
|
||||
$output = executeQuery('comment.insertComment', $tobj);
|
||||
if($output->toBool()) return $tobj->comment_srl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue