add phpDoc comment in importer module

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10790 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ovclas 2012-06-25 06:52:16 +00:00
parent 812f059823
commit 0280c474e4
5 changed files with 312 additions and 127 deletions

View file

@ -1,33 +1,97 @@
<?php <?php
/** /**
* @class extract * extract class
* Class to save each file by using tags in the large xml
*
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief Class to save each file by using tags in the large xml * @package /modules/importer
**/ * @version 0.1
*/
class extract { class extract {
/**
* Temp file's key. made by md5 with filename
* @var string
*/
var $key = ''; var $key = '';
/**
* Temp cache file path
* @var string
*/
var $cache_path = './files/cache/importer'; var $cache_path = './files/cache/importer';
/**
* Temp index cache file path
* @var string
*/
var $cache_index_file = './files/cache/importer'; var $cache_index_file = './files/cache/importer';
/**
* File name
* @var string
*/
var $filename = null; var $filename = null;
/**
* Start tag
* @var string
*/
var $startTag = ''; var $startTag = '';
/**
* End tag
* @var string
*/
var $endTag = ''; var $endTag = '';
/**
* Item start tag
* @var string
*/
var $itemStartTag = ''; var $itemStartTag = '';
/**
* Item end tag
* @var string
*/
var $itemEndTag = ''; var $itemEndTag = '';
/**
* File resource
* @var string
*/
var $fd = null; var $fd = null;
/**
* Index file resource
* @var string
*/
var $index_fd = null; var $index_fd = null;
/**
* Start tag open status
* @var bool
*/
var $isStarted = false; var $isStarted = false;
/**
* End tag close status
* @var bool
*/
var $isFinished = true; var $isFinished = true;
/**
* Buffer
* @var string
*/
var $buff = 0; var $buff = 0;
/**
* File count
* @var int
*/
var $index = 0; var $index = 0;
/** /**
* @brief Get arguments for constructor, file name, start tag, end tag, tag name for each item * Get arguments for constructor, file name, start tag, end tag, tag name for each item
**/ * @param string $filename
* @param string $startTag
* @param string $endTag
* @param string $itemTag
* @param string $itemEndTag
* @return Object
*/
function set($filename, $startTag, $endTag, $itemTag, $itemEndTag) { function set($filename, $startTag, $endTag, $itemTag, $itemEndTag) {
$this->filename = $filename; $this->filename = $filename;
@ -47,8 +111,9 @@
} }
/** /**
* @brief Open an indicator of the file * Open an indicator of the file
**/ * @return Object
*/
function openFile() { function openFile() {
FileHandler::removeFile($this->cache_index_file); FileHandler::removeFile($this->cache_index_file);
$this->index_fd = fopen($this->cache_index_file,"a"); $this->index_fd = fopen($this->cache_index_file,"a");
@ -105,6 +170,10 @@
return new Object(); return new Object();
} }
/**
* Close an indicator of the file
* @return void
*/
function closeFile() { function closeFile() {
$this->isFinished = true; $this->isFinished = true;
fclose($this->fd); fclose($this->fd);
@ -115,6 +184,10 @@
return $this->isFinished || !$this->fd || feof($this->fd); return $this->isFinished || !$this->fd || feof($this->fd);
} }
/**
* Save item
* @return void
*/
function saveItems() { function saveItems() {
FileHandler::removeDir($this->cache_path.$this->key); FileHandler::removeDir($this->cache_path.$this->key);
$this->index = 0; $this->index = 0;
@ -123,6 +196,10 @@
} }
} }
/**
* Merge item
* @return void
*/
function mergeItems($filename) { function mergeItems($filename) {
$this->saveItems(); $this->saveItems();
@ -144,6 +221,10 @@
fclose($fd); fclose($fd);
} }
/**
* Get item. Put data to buff
* @return void
*/
function getItem() { function getItem() {
if($this->isFinished()) return; if($this->isFinished()) return;

View file

@ -1,26 +1,37 @@
<?php <?php
/**
* @class importerAdminController
* @author NHN (developers@xpressengine.com)
* @brief admin controller class of importer module
**/
@set_time_limit(0); @set_time_limit(0);
require_once('./modules/importer/extract.class.php'); require_once('./modules/importer/extract.class.php');
/**
* importerAdminController class
* admin controller class of importer module
*
* @author NHN (developers@xpressengine.com)
* @package /modules/importer
* @version 0.1
*/
class importerAdminController extends importer { class importerAdminController extends importer {
/**
* Unit count
* @var int
*/
var $unit_count = 300; var $unit_count = 300;
/**
* Xml parser
* @var XmlParser
*/
var $oXmlParser = null; var $oXmlParser = null;
/** /**
* @brief Initialization * Initialization
**/ * @return void
*/
function init() { function init() {
} }
/** /**
* @brief Check whether the passing filename exists or not. Detect the file type, too. * Check whether the passing filename exists or not. Detect the file type, too.
* @return void
*/ */
function procImporterAdminCheckXmlFile() { function procImporterAdminCheckXmlFile() {
global $lang; global $lang;
@ -78,8 +89,9 @@
} }
/** /**
* @brief sync member information with document information * Sync member information with document information
**/ * @return void
*/
function procImporterAdminSync() { function procImporterAdminSync() {
/* DBMS가 CUBRID인 경우 MySQL과 동일한 방법으로는 문서 댓글에 대한 사용자 정보를 동기화 없으므로 예외 처리 합니다. /* DBMS가 CUBRID인 경우 MySQL과 동일한 방법으로는 문서 댓글에 대한 사용자 정보를 동기화 없으므로 예외 처리 합니다.
CUBRID를 사용하지 않는 경우에만 보편적인 기존 질의문을 사용합니다. */ CUBRID를 사용하지 않는 경우에만 보편적인 기존 질의문을 사용합니다. */
@ -132,8 +144,9 @@
} }
/** /**
* @brief Pre-analyze the xml file and cache it * Pre-analyze the xml file and cache it
**/ * @return void
*/
function procImporterAdminPreProcessing() { function procImporterAdminPreProcessing() {
// Get the target xml file to import // Get the target xml file to import
$xml_file = Context::get('xml_file'); $xml_file = Context::get('xml_file');
@ -231,8 +244,9 @@
} }
/** /**
* @brief Migrate data after completing xml file extraction * Migrate data after completing xml file extraction
**/ * @return void
*/
function procImporterAdminImport() { function procImporterAdminImport() {
// Variable setting // Variable setting
$type = Context::get('type'); $type = Context::get('type');
@ -285,8 +299,12 @@
} }
/** /**
* @brief Import member information * Import member information
**/ * @param int $key
* @param int $cur
* @param string $index_file
* @return int
*/
function importMember($key, $cur, $index_file) { function importMember($key, $cur, $index_file) {
if(!$cur) $cur = 0; if(!$cur) $cur = 0;
// Create the xmlParser object // Create the xmlParser object
@ -427,8 +445,12 @@
} }
/** /**
* @brief Import message information parsed from a given xml file * Import message information parsed from a given xml file
**/ * @param int $key
* @param int $cur
* @param string $index_file
* @return int
*/
function importMessage($key, $cur, $index_file) { function importMessage($key, $cur, $index_file) {
if(!$cur) $cur = 0; if(!$cur) $cur = 0;
// Create the xmlParser object // Create the xmlParser object
@ -516,8 +538,13 @@
} }
/** /**
* @brief Import data in module.xml format * Import data in module.xml format
**/ * @param int $key
* @param int $cur
* @param string $index_file
* @param int $module_srl
* @return int
*/
function importModule($key, $cur, $index_file, $module_srl) { function importModule($key, $cur, $index_file, $module_srl) {
// Pre-create the objects needed // Pre-create the objects needed
$this->oXmlParser = new XmlParser(); $this->oXmlParser = new XmlParser();
@ -721,8 +748,12 @@
} }
/** /**
* @brief Trackbacks * Trackbacks
**/ * @param resource $fp
* @param int $module_srl
* @param int $document_srl
* @return int
*/
function importTrackbacks($fp, $module_srl, $document_srl) { function importTrackbacks($fp, $module_srl, $document_srl) {
$started = false; $started = false;
$buff = null; $buff = null;
@ -762,8 +793,12 @@
} }
/** /**
* @brief Comments * Comments
**/ * @param resource $fp
* @param int $module_srl
* @param int $document_srl
* @return int
*/
function importComments($fp, $module_srl, $document_srl) { function importComments($fp, $module_srl, $document_srl) {
$started = false; $started = false;
$buff = null; $buff = null;
@ -871,8 +906,13 @@
} }
/** /**
* @brief Import attachment * Import attachment
**/ * @param resource $fp
* @param int $module_srl
* @param int $upload_target_srl
* @param array $files
* @return int
*/
function importAttaches($fp, $module_srl, $upload_target_srl, &$files) { function importAttaches($fp, $module_srl, $upload_target_srl, &$files) {
$uploaded_count = 0; $uploaded_count = 0;
@ -974,8 +1014,9 @@
} }
/** /**
* @biref Return a filename to temporarily use * Return a filename to temporarily use
**/ * @return string
*/
function getTmpFilename() { function getTmpFilename() {
$path = "./files/cache/importer"; $path = "./files/cache/importer";
if(!is_dir($path)) FileHandler::makeDir($path); if(!is_dir($path)) FileHandler::makeDir($path);
@ -985,8 +1026,10 @@
} }
/** /**
* @brief Read buff until key value comes out from a specific file point * Read buff until key value comes out from a specific file point
**/ * @param resource $fp
* @return string
*/
function saveTemporaryFile($fp) { function saveTemporaryFile($fp) {
$temp_filename = $this->getTmpFilename(); $temp_filename = $this->getTmpFilename();
$f = fopen($temp_filename, "w"); $f = fopen($temp_filename, "w");
@ -1009,8 +1052,10 @@
/** /**
* @brief Set extra variables * Set extra variables
**/ * @param resource $fp
* @return array
*/
function importExtraVars($fp) { function importExtraVars($fp) {
$buff = null; $buff = null;
while(!feof($fp)) { while(!feof($fp)) {

View file

@ -1,23 +1,25 @@
<?php <?php
/** /**
* @class importerAdminView * importerAdminView class
* @author NHN (developers@xpressengine.com) * admin view class of the importer module
* @brief admin view class of the importer module
**/
class importerAdminView extends importer {
/**
* @brief Initialization
* *
* @author NHN (developers@xpressengine.com)
* @package /modules/importer
* @version 0.1
*/
class importerAdminView extends importer {
/**
* Initialization
* Importer module is divided by general use and administrative use \n * Importer module is divided by general use and administrative use \n
**/ * @return void
*/
function init() { function init() {
} }
/** /**
* @brief Display a form to upload the xml file * Display a form to upload the xml file
**/ * @return void
*/
function dispImporterAdminContent() { function dispImporterAdminContent() {
$this->setTemplatePath($this->module_path.'tpl'); $this->setTemplatePath($this->module_path.'tpl');
@ -55,8 +57,9 @@
} }
/** /**
* @brief Display a form to upload the xml file * Display a form to upload the xml file
**/ * @return void
*/
function dispImporterAdminImportForm() { function dispImporterAdminImportForm() {
$oDocumentModel = &getModel('document'); //for document lang use in this page $oDocumentModel = &getModel('document'); //for document lang use in this page

View file

@ -1,36 +1,41 @@
<?php <?php
/** /**
* @class importer * importer
* high class of importer module
*
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief high class of importer module * @package /modules/importer
**/ * @version 0.1
*/
class importer extends ModuleObject { class importer extends ModuleObject {
/** /**
* @brief Implement if additional tasks are necessary when installing * Implement if additional tasks are necessary when installing
**/ * @return Object
*/
function moduleInstall() { function moduleInstall() {
return new Object(); return new Object();
} }
/** /**
* @brief a method to check if successfully installed * A method to check if successfully installed
**/ * @return bool
*/
function checkUpdate() { function checkUpdate() {
return false; return false;
} }
/** /**
* @brief Execute update * Execute update
**/ * @return Object
*/
function moduleUpdate() { function moduleUpdate() {
return new Object(); return new Object();
} }
/** /**
* @brief Re-generate the cache file * Re-generate the cache file
**/ * @return void
*/
function recompileCache() { function recompileCache() {
} }
} }

View file

@ -1,20 +1,34 @@
<?php <?php
/**
* @class ttimport
* @author NHN (developers@xpressengine.com)
* @brief ttxml import class
**/
@set_time_limit(0); @set_time_limit(0);
@require_once('./modules/importer/extract.class.php'); @require_once('./modules/importer/extract.class.php');
/**
* ttimport class
* ttxml import class
*
* @author NHN (developers@xpressengine.com)
* @package /modules/importer
* @version 0.1
*/
class ttimport { class ttimport {
/**
* Xml Parse
* @var XmlParser
*/
var $oXmlParser = null; var $oXmlParser = null;
/** /**
* @brief import data in module.xml format * Import data in module.xml format
**/ * @param int $key
* @param int $cur
* @param string $index_file
* @param int $unit_count
* @param int $module_srl
* @param int $guestbook_module_srl
* @param string $user_id
* @param string $module_name
* @return int
*/
function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name=null) { function importModule($key, $cur, $index_file, $unit_count, $module_srl, $guestbook_module_srl, $user_id, $module_name=null) {
// Pre-create the objects needed // Pre-create the objects needed
$this->oXmlParser = new XmlParser(); $this->oXmlParser = new XmlParser();
@ -330,7 +344,16 @@
return $idx-1; return $idx-1;
} }
/**
* Insert textyle guest book
* @param object $val
* @param int $module_srl
* @param object $member_info
* @param int $textyle_guestbook_srl
* @param int $parent_srl
* @param int $author_xml_id
* @return int|bool
*/
function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl,$parent_srl = 0, $author_xml_id=null) { function insertTextyleGuestbookItem($val, $module_srl, $member_info, $textyle_guestbook_srl,$parent_srl = 0, $author_xml_id=null) {
$tobj = null; $tobj = null;
if($textyle_guestbook_srl>0){ if($textyle_guestbook_srl>0){
@ -373,8 +396,14 @@
/** /**
* @brief Attachment * Attachment
**/ * @param resource $fp
* @param int $module_srl
* @param int $upload_target_srl
* @param array $files
* @param string $buff
* @return bool
*/
function importAttaches($fp, $module_srl, $upload_target_srl, &$files, $buff) { function importAttaches($fp, $module_srl, $upload_target_srl, &$files, $buff) {
$uploaded_count = 0; $uploaded_count = 0;
@ -442,8 +471,9 @@
} }
/** /**
* @biref Return a filename to temporarily use * Return a filename to temporarily use
**/ * @return string
*/
function getTmpFilename() { function getTmpFilename() {
$path = "./files/cache/importer"; $path = "./files/cache/importer";
if(!is_dir($path)) FileHandler::makeDir($path); if(!is_dir($path)) FileHandler::makeDir($path);
@ -453,8 +483,11 @@
} }
/** /**
* @brief Read buff until key value comes out from a specific file point * Read buff until key value comes out from a specific file point
**/ * @param resource $fp
* @param string $buff
* @return string
*/
function saveTemporaryFile($fp, $buff) { function saveTemporaryFile($fp, $buff) {
$temp_filename = $this->getTmpFilename(); $temp_filename = $this->getTmpFilename();
$buff = substr($buff, 9); $buff = substr($buff, 9);
@ -474,8 +507,10 @@
} }
/** /**
* @brief Replace img tag in the ttxml * Replace img tag in the ttxml
**/ * @param array $matches
* @return string
*/
function _replaceTTAttach($matches) { function _replaceTTAttach($matches) {
$name = $matches[2]; $name = $matches[2];
if(!$name) return $matches[0]; if(!$name) return $matches[0];
@ -497,8 +532,9 @@
} }
/** /**
* @brief Convert the video file * Convert the video file
**/ * @return string
*/
function _replaceTTMovie($matches) { function _replaceTTMovie($matches) {
$key = $matches[1]; $key = $matches[1];
if(!$key) return $matches[0]; if(!$key) return $matches[0];
@ -514,8 +550,15 @@
} }
/** /**
* @brief Comment * Comment
**/ * @param object $val
* @param int $module_srl
* @param int $document_srl
* @param object $member_info
* @param int $parent_srl
* @param int $author_xml_id
* @return bool|int|object
*/
function insertComment($val, $module_srl, $document_srl, $member_info, $parent_srl = 0, $author_xml_id) { function insertComment($val, $module_srl, $document_srl, $member_info, $parent_srl = 0, $author_xml_id) {
$tobj = null; $tobj = null;
$tobj->comment_srl = getNextSequence(); $tobj->comment_srl = getNextSequence();
@ -580,7 +623,15 @@
} }
return false; return false;
} }
// List category
/**
* List category
* @param object $obj
* @param array $category
* @param int $idx
* @param int $parent
* @return void
*/
function arrangeCategory($obj, &$category, &$idx, $parent = 0) { function arrangeCategory($obj, &$category, &$idx, $parent = 0) {
if(!$obj->category) return; if(!$obj->category) return;
if(!is_array($obj->category)) $c = array($obj->category); if(!is_array($obj->category)) $c = array($obj->category);