제로보드 데이터 이전 모듈의 다중 카테고리 적용

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3966 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
zero 2008-03-19 04:11:12 +00:00
parent 07084883c4
commit 6835a03b5f
6 changed files with 153 additions and 63 deletions

View file

@ -56,9 +56,21 @@
break;
case 'ttxml' :
// 카테고리 정보를 먼저 구함
$output = $oExtract->set($xml_file,'</setting>', '<post ', '<category><name>','</name>');
$output = $oExtract->set($xml_file,'','<author', '<category>', '<post ');
if($output->toBool()) {
$oExtract->mergeItems('category');
// ttxml 카테고리는 별도로 구함
$started = false;
$buff = '';
while(!feof($oExtract->fd)) {
$str = fgets($oExtract->fd, 1024);
if(substr($str,0,strlen('<category>'))=='<category>') $started = true;
if(substr($str,0,strlen('<post '))=='<post ') break;
if($started) $buff .= $str;
}
$buff = '<items>'.$buff.'</items>';
$oExtract->closeFile();
$category_filename = sprintf('%s/%s', $oExtract->cache_path, 'category');
FileHandler::writeFile($category_filename, $buff);
// 개별 아이템 구함
$output = $oExtract->set($xml_file,'<blog', '</blog>', '<post ', '</post>');
@ -67,7 +79,7 @@
break;
default :
// 카테고리 정보를 먼저 구함
$output = $oExtract->set($xml_file,'<categories>', '</categories>', '<category>','</category>');
$output = $oExtract->set($xml_file,'<categories>', '</categories>', '<category','</category>');
if($output->toBool()) {
$oExtract->mergeItems('category');
@ -402,14 +414,21 @@
if($categories) {
if(!is_array($categories)) $categories = array($categories);
$oDocumentController = &getController('document');
$match_sequence = array();
foreach($categories as $k => $v) {
$category = trim(base64_decode($v->body));
if(!$category || $category_titles[$category]) continue;
$sequence = $v->attrs->sequence;
$parent = $v->attrs->parent;
$obj = null;
$obj->title = $category;
$obj->module_srl = $module_srl;
if($parent) $obj->parent_srl = $match_sequence[$parent];
$output = $oDocumentController->insertCategory($obj);
if($output->toBool()) $match_sequence[$sequence] = $output->get('category_srl');
}
$oDocumentController = &getController('document');
$oDocumentController->makeCategoryFile($module_srl);
@ -755,40 +774,43 @@
}
}
// 이미지인지 기타 파일인지 체크하여 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(file_exists($file_obj->file)) {
// 디렉토리 생성
if(!FileHandler::makeDir($path)) continue;
// 이미지인지 기타 파일인지 체크하여 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(preg_match('/^\.\/files\/cache\/tmp/i',$file_obj->file)) @rename($file_obj->file, $filename);
else @copy($file_obj->file, $filename);
// 디렉토리 생성
if(!FileHandler::makeDir($path)) continue;
// DB입력
unset($file_obj->file);
if(file_exists($filename)) {
$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);
if(preg_match('/^\.\/files\/cache\/tmp/i',$file_obj->file)) @rename($file_obj->file, $filename);
else @copy($file_obj->file, $filename);
// DB입력
unset($file_obj->file);
if(file_exists($filename)) {
$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);
}
}
}
}

View file

@ -17,9 +17,9 @@
<th class="button">
<select name="unit_count">
<option value="50">50</option>
<option value="100">100</option>
<option value="100" selected="selected">100</option>
<option value="200">200</option>
<option value="300" selected="selected">300</option>
<option value="300">300</option>
<option value="400">400</option>
<option value="500">500</option>
<option value="1000">1000</option>

View file

@ -17,9 +17,9 @@
<th class="button">
<select name="unit_count">
<option value="50">50</option>
<option value="100">100</option>
<option value="100" selected="selected">100</option>
<option value="200">200</option>
<option value="300" selected="selected">300</option>
<option value="300">300</option>
<option value="400">400</option>
<option value="500">500</option>
<option value="1000">1000</option>

View file

@ -31,11 +31,11 @@
<tr>
<th class="button">
<select name="unit_count">
<option value="10">10</option>
<option value="10" selected="selected">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="100">100</option>
<option value="200">200</option>
<option value="300">300</option>
<option value="400">400</option>

View file

@ -40,11 +40,11 @@
<tr>
<th class="button">
<select name="unit_count">
<option value="10">10</option>
<option value="10" selected="selected">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="100">100</option>
<option value="200">200</option>
<option value="300">300</option>
<option value="400">400</option>

View file

@ -33,25 +33,30 @@
// xmlParser객체 생성
$xmlDoc = $this->oXmlParser->loadXmlFile($category_file);
$categories = $xmlDoc->items->category;
if($categories) {
if(!is_array($categories)) $categories = array($categories);
// 카테고리 정보를 정리
if($xmlDoc->items->category) {
$categories = array();
$idx = 0;
$this->arrangeCategory($xmlDoc->items, $categories, $idx, 0);
$oDocumentController = &getController('document');
$match_sequence = array();
foreach($categories as $k => $v) {
$category = $v->name->body;
$category = $v->name;
if(!$category || $category_titles[$category]) continue;
$obj = null;
$obj->title = $category;
$obj->module_srl = $module_srl;
if($v->parent) $obj->parent_srl = $match_sequence[$v->parent];
$output = $oDocumentController->insertCategory($obj);
if($output->toBool()) $match_sequence[$v->sequence] = $output->get('category_srl');
}
$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;
@ -111,11 +116,14 @@
$xmlDoc = $this->oXmlParser->parse('<post>'.$buff);
$category = $xmlDoc->post->category->body;
if($category_titles[$category]) $obj->category_srl = $category_titles[$category];
if($xmlDoc->post->category->body) {
$tmp_arr = explode('/',$xmlDoc->post->category->body);
$category = trim($tmp_arr[count($tmp_arr)-1]);
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->is_secret = in_array($xmlDoc->post->visibility->body, array('public','syndicated'))?'N':'Y';
$obj->title = $xmlDoc->post->title->body;
$obj->content = $xmlDoc->post->content->body;
$obj->password = md5($xmlDoc->post->password->body);
@ -152,14 +160,16 @@
// 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);
foreach($files as $key => $val) {
$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val->url.'"',$obj->content);
}
}
$obj->content = preg_replace_callback('!\[##_Movie\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTMovie'), $obj->content);
if(count($files)) {
foreach($files as $key => $val) {
$obj->content = preg_replace('/(src|href)\=(["\']?)'.preg_quote($key).'(["\']?)/i','$1="'.$val.'"',$obj->content);
}
$this->files = $files;
$obj->content = preg_replace_callback('!\[##_([a-z0-9]+)\|([^\|]*)\|([^\|]*)\|(.*?)_##\]!is', array($this, '_replaceTTAttach'), $obj->content);
}
// 역인글 입력
@ -262,14 +272,15 @@
$buff .= $str;
}
if(!file_exists($file_obj->file)) return false;
$buff .= '</attachment>';
$xmlDoc = $this->oXmlParser->parse($buff);
$file_obj->source_filename = $xmlDoc->attachment->name->body;
$file_obj->source_filename = $xmlDoc->attachment->label->body;
$file_obj->download_count = $xmlDoc->attachment->downloads->body;
$label = $xmlDoc->attachment->label->body;
$name = $xmlDoc->attachment->name->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)) {
@ -300,9 +311,10 @@
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);
if($file_obj->direct_download == 'Y') $files[$name]->url = $file_obj->uploaded_filename;
else $files[$name]->url = getUrl('','module','file','act','procFileDownload','file_srl',$file_obj->file_srl,'sid',$file_obj->sid);
$files[$name]->direct_download = $file_obj->direct_download;
$files[$name]->source_filename = $file_obj->source_filename;
return true;
}
@ -344,8 +356,43 @@
/**
* @brief ttxml의 자체 img 태그를 치환
**/
function _replaceTTImgTag($matches) {
return sprintf("<img src=\"%s\" alt=\"%s\" /><br /><br />", $matches[2], str_replace("\"","\\\"",$matches[4]));
function _replaceTTAttach($matches) {
$name = $matches[2];
if(!$name) return $matches[0];
$obj = $this->files[$name];
// 멀티미디어성 파일의 경우
if($obj->direct_download == 'Y') {
// 이미지의 경우
if(preg_match('/\.(jpg|gif|jpeg|png)$/i', $obj->source_filename)) {
return sprintf('<img editor_component="image_link" src="%s" alt="%s" />', $obj->url, str_replace('"','\\"',$matches[4]));
// 이미지 외의 멀티미디어성 파일의 경우
} else {
return sprintf('<img src="./common/tpl/images/blank.gif" editor_component="multimedia_link" multimedia_src="%s" width="400" height="320" style="display:block;width:400px;height:320px;border:2px dotted #4371B9;background:url(./modules/editor/components/multimedia_link/tpl/multimedia_link_component.gif) no-repeat center;" auto_start="false" alt="" />', $obj->url);
}
// binary파일일 경우
} else {
return sprintf('<a href="%s">%s</a>', $obj->url, $obj->source_filename);
}
}
/**
* @brief ttxml의 동영상 변환
**/
function _replaceTTMovie($matches) {
$key = $matches[1];
if(!$key) return $matches[0];
return
'<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="402">'.
'<param name="movie" value="http://flvs.daum.net/flvPlayer.swf?vid='.urlencode($key).'"/>'.
'<param name="allowScriptAccess" value="always"/>'.
'<param name="allowFullScreen" value="true"/>'.
'<param name="bgcolor" value="#000000"/>'.
'<embed src="http://flvs.daum.net/flvPlayer.swf?vid='.urlencode($key).'" width="100%" height="402" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" bgcolor="#000000"/>'.
'</object>';
}
/**
@ -409,5 +456,26 @@
}
return false;
}
// 카테고리 정리
function arrangeCategory($obj, &$category, &$idx, $parent = 0) {
if(!$obj->category) return;
if(!is_array($obj->category)) $c = array($obj->category);
else $c = $obj->category;
foreach($c as $val) {
$idx++;
$priority = $val->priority->body;
$name = $val->name->body;
$obj = null;
$obj->priority = $priority;
$obj->name = $name;
$obj->sequence = $idx;
$obj->parent = $parent;
$category[$priority] = $obj;
$this->arrangeCategory($val, $category, $idx, $idx);
}
}
}
?>