mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 08:49:56 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@1728 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
51279ae647
commit
e5ed227984
9 changed files with 435 additions and 0 deletions
12
modules/ttimporter/conf/info.xml
Normal file
12
modules/ttimporter/conf/info.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module version="0.1">
|
||||
<title xml:lang="ko">TatterTools XML Importer</title>
|
||||
<author email_address="zero@zeroboard.com" link="http://www.zeroboard.com" date="2007. 2. 28">
|
||||
<name xml:lang="ko">제로</name>
|
||||
<description xml:lang="ko">
|
||||
태터툴즈의 백업파일을 제로보드XE에 입력을 하는 모듈입니다.
|
||||
첨부파일 포함하지 않은 백업파일이 필요합니다.
|
||||
첨부파일은 원주소에서 직접 다운로드를 하게 됩니다.
|
||||
</description>
|
||||
</author>
|
||||
</module>
|
||||
7
modules/ttimporter/conf/module.xml
Normal file
7
modules/ttimporter/conf/module.xml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<module>
|
||||
<actions>
|
||||
<action name="dispTtimporterAdminContent" type="view" standalone="true" admin_index="true" />
|
||||
<action name="procTtimporterAdminImport" type="controller" standalone="true" />
|
||||
</actions>
|
||||
</module>
|
||||
20
modules/ttimporter/lang/ko.lang.php
Normal file
20
modules/ttimporter/lang/ko.lang.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @file ko.lang.php
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief Ttimporter 모듈의 기본 언어팩
|
||||
**/
|
||||
|
||||
$lang->about_tt_importer = "태터툴즈 데이터를 원하는 모듈에 입력을 할 수 있습니다.\n첨부파일은 웹으로 직접 다운로드를 받으니 꼭 원래 태터툴즈 블로그를 활성화 시켜 주셔야 합니다.";
|
||||
|
||||
$lang->target_module = "대상 모듈";
|
||||
$lang->target_file = "대상 xml파일";
|
||||
$lang->target_url = "블로그URL";
|
||||
|
||||
$lang->cmd_continue = '계속진행';
|
||||
|
||||
$lang->msg_no_xml_file = 'XML파일을 찾을 수 없습니다. 경로를 다시 확인해주세요';
|
||||
$lang->msg_invalid_xml_file = '잘못된 형식의 XML파일입니다';
|
||||
$lang->msg_importing = '%d개를 입력중입니다. (계속 멈추어 있으면 "계속진행" 버튼을 클릭해주세요)';
|
||||
$lang->msg_import_finished = '%d개의 데이터 입력이 완료되었습니다. 상황에 따라 입력되지 못한 데이터가 있을 수 있습니다.';
|
||||
?>
|
||||
14
modules/ttimporter/tpl/filter/import_tt.xml
Normal file
14
modules/ttimporter/tpl/filter/import_tt.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<filter name="import_tt" module="ttimporter" act="procTtimporterAdminImport">
|
||||
<form>
|
||||
<node target="xml_file" required="true" />
|
||||
<node target="url" required="true" />
|
||||
<node target="module_srl" required="true" />
|
||||
</form>
|
||||
<parameter />
|
||||
<response callback_func="completeImport">
|
||||
<tag name="error" />
|
||||
<tag name="message" />
|
||||
<tag name="is_finished" />
|
||||
<tag name="position" />
|
||||
</response>
|
||||
</filter>
|
||||
40
modules/ttimporter/tpl/index.html
Normal file
40
modules/ttimporter/tpl/index.html
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<!--%import("js/importer_admin.js")-->
|
||||
<!--%import("filter/import_tt.xml")-->
|
||||
|
||||
<!-- 설명 -->
|
||||
<div style="border:1px solid #CCCCCC;margin-bottom:10px;padding:10px;">
|
||||
{nl2br($lang->about_tt_importer)}
|
||||
</div>
|
||||
|
||||
<form action="./" method="get" onsubmit="return procFilter(this, import_tt);" id="fo_import">
|
||||
<input type="hidden" name="position" value="0" />
|
||||
|
||||
<div style="font-weight:bold">{$lang->target_module}</div>
|
||||
<div>
|
||||
<select name="module_srl">
|
||||
<!--@foreach($module_list as $key => $val)-->
|
||||
<option value="{$val->module_srl}">{$val->browser_title} - {$key}</option>
|
||||
<!--@end-->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div style="font-weight:bold">{$lang->target_file}</div>
|
||||
<div>
|
||||
<input type="text" name="xml_file" value="../rainnypub.com.xml" />
|
||||
</div>
|
||||
|
||||
<div style="font-weight:bold">{$lang->target_url}</div>
|
||||
<div>
|
||||
<input type="text" name="url" value="http://rainny.n4blog.com" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="submit" value="{$lang->cmd_registration}" />
|
||||
</div>
|
||||
|
||||
<div id="import_status" style="display:none">
|
||||
<div id="step2_position"></div>
|
||||
<div><input type="button" onclick="doManualProcess(); return false" value="{$lang->cmd_continue}" /></div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
31
modules/ttimporter/tpl/js/importer_admin.js
Normal file
31
modules/ttimporter/tpl/js/importer_admin.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* @file modules/ttimporter/js/importer_admin.js
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief importer에서 사용하는 javascript
|
||||
**/
|
||||
|
||||
/* Step Complete Import */
|
||||
function completeImport(ret_obj) {
|
||||
var message = ret_obj['message'];
|
||||
var is_finished = ret_obj['is_finished'];
|
||||
var position = ret_obj['position'];
|
||||
alert(message);
|
||||
alert(position);
|
||||
|
||||
xGetElementById("import_status").style.display = "block";
|
||||
|
||||
if(is_finished=='Y') {
|
||||
alert(ret_obj["message"]);
|
||||
location.href = location.href;
|
||||
} else {
|
||||
var fo_obj = xGetElementById('fo_import');
|
||||
fo_obj.position.value = position;
|
||||
xInnerHtml('import_status', message);
|
||||
procFilter(fo_obj, import_tt);
|
||||
}
|
||||
}
|
||||
|
||||
function doManualProcess() {
|
||||
var fo_obj = xGetElementById('fo_import');
|
||||
procFilter(fo_obj, import_tt);
|
||||
}
|
||||
243
modules/ttimporter/ttimporter.admin.controller.php
Normal file
243
modules/ttimporter/ttimporter.admin.controller.php
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
<?php
|
||||
/**
|
||||
* @class ttimporterAdminController
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief ttimporter 모듈의 admin controller class
|
||||
**/
|
||||
|
||||
class ttimporterAdminController extends ttimporter {
|
||||
|
||||
var $oXml = null;
|
||||
|
||||
var $oDocumentController = null;
|
||||
var $oFileController = null;
|
||||
var $oCommentController = null;
|
||||
var $oTrackbackController = null;
|
||||
|
||||
var $position = 0;
|
||||
var $imported_count = 0;
|
||||
var $limit_count = 20;
|
||||
var $url = '';
|
||||
|
||||
var $module_srl = 0;
|
||||
var $category_srl = 0;
|
||||
var $category_list = array();
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief import 실행
|
||||
**/
|
||||
function procTtimporterAdminImport() {
|
||||
// 실행시간 무한대로 설정
|
||||
@set_time_limit(0);
|
||||
|
||||
// 변수 체크
|
||||
$this->module_srl = Context::get('module_srl');
|
||||
$xml_file = Context::get('xml_file');
|
||||
$this->url = Context::get('url');
|
||||
$this->position = (int)Context::get('position');
|
||||
if(substr($this->url,-1)!='/') $this->url .= '/';
|
||||
|
||||
// 파일을 찾을 수 없으면 에러 표시
|
||||
if(!file_exists($xml_file)) return new Object(-1,'msg_no_xml_file');
|
||||
|
||||
$this->oXml = new XmlParser();
|
||||
|
||||
$oDocumentModel = &getModel('document');
|
||||
$tmp_category_list = $oDocumentModel->getCategoryList($this->module_srl);
|
||||
if(count($tmp_category_list)) {
|
||||
foreach($tmp_category_list as $key => $val) $this->category_list[$val->title] = $key;
|
||||
} else {
|
||||
$this->category_list = array();
|
||||
}
|
||||
|
||||
// module_srl이 있으면 module데이터로 판단하여 처리, 아니면 회원정보로..
|
||||
$is_finished = $this->importDocument($xml_file);
|
||||
|
||||
if($is_finished) {
|
||||
$this->add('is_finished', 'Y');
|
||||
$this->setMessage( sprintf(Context::getLang('msg_import_finished'), $this->imported_count) );
|
||||
} else {
|
||||
$this->add('position', $this->imported_count);
|
||||
$this->add('is_finished', 'N');
|
||||
$this->setMessage( sprintf(Context::getLang('msg_importing'), $this->imported_count) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 게시물정보 import
|
||||
**/
|
||||
function importDocument($xml_file) {
|
||||
$filesize = filesize($xml_file);
|
||||
|
||||
if($filesize<1) return;
|
||||
|
||||
$this->oDocumentController = &getController('document');
|
||||
$this->oFileController = &getController('file');
|
||||
$this->oCommentController = &getController('comment');
|
||||
$this->oTrackbackController = &getController('trackback');
|
||||
|
||||
$is_finished = true;
|
||||
|
||||
$fp = @fopen($xml_file, "r");
|
||||
if($fp) {
|
||||
$buff = '';
|
||||
while(!feof($fp)) {
|
||||
$str = fread($fp,1024);
|
||||
$buff .= $str;
|
||||
|
||||
$buff = preg_replace_callback("!<category>(.*?)<\/category>!is", array($this, '_parseCategoryInfo'), trim($buff));
|
||||
$buff = preg_replace_callback("!<post (.*?)<\/post>!is", array($this, '_importDocument'), trim($buff));
|
||||
|
||||
if($this->position+$this->limit_count <= $this->imported_count) {
|
||||
$is_finished = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
return $is_finished;
|
||||
}
|
||||
|
||||
function _insertAttachment($matches) {
|
||||
$xml_doc = $this->oXml->parse($matches[0]);
|
||||
|
||||
$filename = $xml_doc->attachment->name->body;
|
||||
$url = sprintf("%sattach/1/%s", $this->url, $filename);
|
||||
|
||||
$tmp_filename = './files/cache/tmp_uploaded_file';
|
||||
if(FileHandler::getRemoteFile($url, $tmp_filename)) {
|
||||
$file_info['tmp_name'] = $tmp_filename;
|
||||
$file_info['name'] = $filename;
|
||||
$this->oFileController->insertFile($file_info, $this->module_srl, $this->document_srl, 0, true);
|
||||
$this->uploaded_count++;
|
||||
}
|
||||
@unlink($tmp_filename);
|
||||
}
|
||||
|
||||
function _importDocument($matches) {
|
||||
if($this->position > $this->imported_count) {
|
||||
$this->imported_count++;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->uploaded_count = 0;
|
||||
|
||||
$xml_doc = $this->oXml->parse($matches[0]);
|
||||
|
||||
// 문서 번호와 내용 미리 구해 놓기
|
||||
$this->document_srl = $args->document_srl = getNextSequence();
|
||||
$args->content = $xml_doc->post->content->body;
|
||||
|
||||
// 첨부파일 미리 등록
|
||||
preg_replace_callback("!<attachment (.*?)<\/attachment>!is", array($this, '_insertAttachment'), $matches[0]);
|
||||
|
||||
// 컨텐츠의 내용 수정 (이미지 첨부파일 관련)
|
||||
$args->content = preg_replace("!(\[##\_1)([a-zA-Z]){1}\|([^\|]*)\|([^\|]*)\|([^\]]*)\]!is", sprintf('<img src="./files/attach/images/%s/%s/$3" $4 />', $this->module_srl, $args->document_srl), $args->content);
|
||||
|
||||
if($xml_doc->post->comment && !is_array($xml_doc->post->comment)) $xml_doc->post->comment = array($xml_doc->post->comment);
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
// 문서 입력
|
||||
$args->module_srl = $this->module_srl;
|
||||
$args->category_srl = $this->category_list[$xml_doc->post->category->body];
|
||||
$args->is_notice = 'N';
|
||||
$args->is_secret = 'N';
|
||||
$args->title = $xml_doc->post->title->body;
|
||||
$args->readed_count = 0;
|
||||
$args->voted_count = 0;
|
||||
$args->comment_count = count($xml_doc->post->comment);
|
||||
$args->trackback_count = 0;
|
||||
$args->uploaded_count = $this->uploaded_count;
|
||||
$args->password = '';
|
||||
$args->nick_name = $logged_info->nick_name;
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
$args->user_id = $logged_info->user_id;
|
||||
$args->user_name = $logged_info->user_name;
|
||||
$args->email_address = $logged_info->email_address;
|
||||
$args->homepage = $logged_info->homepage;
|
||||
|
||||
$tag_list = array();
|
||||
for($i=0;$i<count($xml_doc->post->tag);$i++) {
|
||||
$tag_list[] = $xml_doc->post->tag[$i]->body;
|
||||
}
|
||||
$args->tags = implode(',',$tag_list);
|
||||
$args->regdate = date("YmdHis", $xml_doc->post->created->body);
|
||||
$args->ipaddress = '';
|
||||
$args->allow_comment = $xml_doc->post->acceptcomment->body?'Y':'N';
|
||||
$args->lock_comment = 'N';
|
||||
$args->allow_trackback = $xml_doc->post->accepttrackback->body?'Y':'N';
|
||||
|
||||
$output = $this->oDocumentController->insertDocument($args, true);
|
||||
|
||||
if($output->toBool()) {
|
||||
|
||||
// 코멘트 입력
|
||||
$comments = $xml_doc->post->comment;
|
||||
if(count($comments)) {
|
||||
foreach($comments as $key => $val) {
|
||||
unset($comment_args);
|
||||
$comment_args->document_srl = $args->document_srl;
|
||||
$comment_args->comment_srl = getNextSequence();
|
||||
$comment_args->module_srl = $this->module_srl;
|
||||
$comment_args->parent_srl = 0;
|
||||
$comment_args->content = $val->content->body;
|
||||
$comment_args->password = '';
|
||||
$comment_args->nick_name = $val->commenter->name->body;
|
||||
$comment_args->user_id = '';
|
||||
$comment_args->user_name = '';
|
||||
$comment_args->member_srl = 0;
|
||||
$comment_args->email_address = '';
|
||||
$comment_args->regdate = date("YmdHis",$val->written->body);
|
||||
$comment_args->ipaddress = $val->commenter->ip->body;
|
||||
$this->oCommentController->insertComment($comment_args, true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// 트랙백 입력
|
||||
$trackbacks = $xml_doc->document->trackbacks->trackback;
|
||||
if($trackbacks && !is_array($trackbacks)) $trackbacks = array($trackbacks);
|
||||
if(count($trackbacks)) {
|
||||
foreach($trackbacks as $key => $val) {
|
||||
$trackback_args->document_srl = $args->document_srl;
|
||||
$trackback_args->module_srl = $this->module_srl;
|
||||
$trackback_args->url = $val->url->body;
|
||||
$trackback_args->title = $val->title->body;
|
||||
$trackback_args->blog_name = $val->blog_name->body;
|
||||
$trackback_args->excerpt = $val->excerpt->body;
|
||||
$trackback_args->regdate = $val->regdate->body;
|
||||
$trackback_args->ipaddress = $val->ipaddress->body;
|
||||
$this->oTrackbackController->insertTrackback($trackback_args, true);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
$this->imported_count ++;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief <categories>정보를 읽어서 정보를 구함
|
||||
**/
|
||||
function _parseCategoryInfo($matches) {
|
||||
$xml_doc = $this->oXml->parse($matches[0]);
|
||||
if(!$xml_doc->category->priority) return;
|
||||
|
||||
$title = trim($xml_doc->category->name->body);
|
||||
if(!$title || $this->category_list[$title]) return;
|
||||
|
||||
$oDocumentController = &getAdminController('document');
|
||||
$output = $oDocumentController->insertCategory($this->module_srl, $title);
|
||||
$this->category_list[$title] = $output->get('category_srl');
|
||||
}
|
||||
}
|
||||
?>
|
||||
32
modules/ttimporter/ttimporter.admin.view.php
Normal file
32
modules/ttimporter/ttimporter.admin.view.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* @class ttimporterAdminView
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief ttimporter 모듈의 admin view class
|
||||
**/
|
||||
|
||||
class ttimporterAdminView extends ttimporter {
|
||||
|
||||
/**
|
||||
* @brief 초기화
|
||||
*
|
||||
* importer 모듈은 일반 사용과 관리자용으로 나누어진다.\n
|
||||
**/
|
||||
function init() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief XML 파일을 업로드하는 form 출력
|
||||
**/
|
||||
function dispTtimporterAdminContent() {
|
||||
// 모듈 목록을 구함
|
||||
$oModuleModel = &getModel('module');
|
||||
$module_list = $oModuleModel->getMidList();
|
||||
Context::set('module_list', $module_list);
|
||||
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
$this->setTemplateFile('index');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
36
modules/ttimporter/ttimporter.class.php
Normal file
36
modules/ttimporter/ttimporter.class.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* @class ttimporter
|
||||
* @author zero (zero@nzeo.com)
|
||||
* @brief ttimporter 모듈의 high class
|
||||
**/
|
||||
|
||||
class ttimporter extends ModuleObject {
|
||||
|
||||
/**
|
||||
* @brief 설치시 추가 작업이 필요할시 구현
|
||||
**/
|
||||
function moduleInstall() {
|
||||
// action forward에 등록 (관리자 모드에서 사용하기 위함)
|
||||
$oModuleController = &getController('module');
|
||||
$oModuleController->insertActionForward('ttimporter', 'view', 'dispTtimporterAdminContent');
|
||||
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 설치가 이상이 없는지 체크하는 method
|
||||
**/
|
||||
function moduleIsInstalled() {
|
||||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 업데이트 실행
|
||||
**/
|
||||
function moduleUpdate() {
|
||||
return new Object();
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue