* @subpackage system.importer
* @category Community Framework
*/
-class AbstractACLImporter implements IImporter {
+class AbstractACLImporter extends AbstractImporter {
/**
* object type id for options
* @var integer
<?php
namespace wcf\system\importer;
-use wcf\data\attachment\AttachmentAction;
use wcf\data\attachment\AttachmentEditor;
use wcf\system\exception\SystemException;
use wcf\util\StringUtil;
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractAttachmentImporter implements IImporter {
+class AbstractAttachmentImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\attachment\Attachment';
+
/**
* object type id for attachments
* @var integer
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
// save attachment
- $action = new AttachmentAction(array(), 'create', array(
- 'data' => array_merge($data, array('objectTypeID' => $this->objectTypeID))
- ));
- $returnValues = $action->executeAction();
- $attachment = $returnValues['returnValues'];
+ $attachment = AttachmentEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
// check attachment directory
// and create subdirectory if necessary
<?php
namespace wcf\system\importer;
-use wcf\data\category\CategoryAction;
+use wcf\data\category\CategoryEditor;
/**
* Imports categories.
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractCategoryImporter implements IImporter {
+class AbstractCategoryImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\category\Category';
+
/**
* object type id for categories
* @var integer
public function import($oldID, array $data, array $additionalData = array()) {
if (!empty($data['parentCategoryID'])) $data['parentCategoryID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['parentCategoryID']);
- $action = new CategoryAction(array(), 'create', array(
- 'data' => array_merge($data, array('objectTypeID' => $this->objectTypeID))
- ));
- $returnValues = $action->executeAction();
- $newID = $returnValues['returnValues']->categoryID;
+ $category = CategoryEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
- ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $newID);
+ ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $category->categoryID);
- return $newID;
+ return $category->categoryID;
}
}
<?php
namespace wcf\system\importer;
-use wcf\data\comment\CommentAction;
+use wcf\data\comment\CommentEditor;
/**
* Imports comments.
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractCommentImporter implements IImporter {
+class AbstractCommentImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\comment\Comment';
+
/**
* object type id for comments
* @var integer
public function import($oldID, array $data, array $additionalData = array()) {
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
- $action = new CommentAction(array(), 'create', array(
- 'data' => array_merge($data, array('objectTypeID' => $this->objectTypeID))
- ));
- $returnValues = $action->executeAction();
- $newID = $returnValues['returnValues']->commentID;
+ $comment = CommentEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
- ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $newID);
+ ImportHandler::getInstance()->saveNewID($this->objectTypeName, $oldID, $comment->commentID);
- return $newID;
+ return $comment->commentID;
}
}
<?php
namespace wcf\system\importer;
-use wcf\data\comment\response\CommentResponseAction;
+use wcf\data\comment\response\CommentResponseEditor;
/**
* Imports comment responses.
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractCommentResponseImporter implements IImporter {
+class AbstractCommentResponseImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\comment\response\CommentResponse';
+
/**
* object type name
* @var string
$data['commentID'] = ImportHandler::getInstance()->getNewID($this->objectTypeName, $data['commentID']);
if (!$data['commentID']) return 0;
- $action = new CommentResponseAction(array(), 'create', array(
- 'data' => $data
- ));
- $returnValues = $action->executeAction();
- $newID = $returnValues['returnValues']->responseID;
+ $response = CommentResponseEditor::create($data);
- return $newID;
+ return $response->responseID;
}
}
--- /dev/null
+<?php
+namespace wcf\system\importer;
+
+/**
+ * Basic implementation of IImporter.
+ *
+ * @author Marcel Werk
+ * @copyright 2001-2013 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.importer
+ * @category Community Framework
+ */
+abstract class AbstractImporter implements IImporter {
+ /**
+ * database object class name
+ * @var string
+ */
+ protected $className = '';
+
+ /**
+ * @see wcf\system\importer\IImporter::getClassName()
+ */
+ public function getClassName() {
+ return $this->className;
+ }
+}
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractLikeImporter implements IImporter {
+class AbstractLikeImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\like\Like';
+
/**
* object type id for likes
* @var integer
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractPollImporter implements IImporter {
+class AbstractPollImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\poll\Poll';
+
/**
* object type id for poll
* @var integer
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractPollOptionImporter implements IImporter {
+class AbstractPollOptionImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\poll\option\PollOption';
+
/**
* option object type name
* @var string
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractPollOptionVoteImporter implements IImporter {
+class AbstractPollOptionVoteImporter extends AbstractImporter {
/**
* option object type name
* @var string
<?php
namespace wcf\system\importer;
-use wcf\data\user\object\watch\UserObjectWatchAction;
+use wcf\data\user\object\watch\UserObjectWatchEditor;
/**
* Imports watched objects.
* @subpackage system.importer
* @category Community Framework
*/
-class AbstractWatchedObjectImporter implements IImporter {
+class AbstractWatchedObjectImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\user\object\watch';
+
/**
* object type id for watched objects
* @var integer
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
if (!$data['userID']) return 0;
- $action = new UserObjectWatchAction(array(), 'create', array(
- 'data' => array_merge($data, array('objectTypeID' => $this->objectTypeID))
- ));
- $returnValues = $action->executeAction();
- return $returnValues['returnValues']->watchID;
+ $watch = UserObjectWatchEditor::create(array_merge($data, array('objectTypeID' => $this->objectTypeID)));
+ return $watch->watchID;
}
}
* @return mixed new id
*/
public function import($oldID, array $data, array $additionalData = array());
+
+ /**
+ * Returns database object class name.
+ *
+ * @return string
+ */
+ public function getClassName();
}
if (!isset($this->idMappingCache[$objectTypeID]) || !array_key_exists($oldID, $this->idMappingCache[$objectTypeID])) {
$this->idMappingCache[$objectTypeID][$oldID] = null;
+ $importer = $this->getImporter($type);
+ $tableName = $indexName = '';
+ if ($importer->getClassName()) {
+ $tableName = call_user_func(array($importer->getClassName(), 'getDatabaseTableName'));
+ $indexName = call_user_func(array($importer->getClassName(), 'getDatabaseTableIndexName'));
+ }
- $sql = "SELECT newID
- FROM wcf".WCF_N."_import_mapping
- WHERE importHash = ?
- AND objectTypeID = ?
- AND oldID = ?";
+ $sql = "SELECT import_mapping.newID
+ FROM wcf".WCF_N."_import_mapping import_mapping
+ ".($tableName ? "LEFT JOIN ".$tableName." object_table ON (object_table.".$indexName." = import_mapping.newID)" : '')."
+ WHERE import_mapping.importHash = ?
+ AND import_mapping.objectTypeID = ?
+ AND import_mapping.oldID = ?
+ ".($tableName ? "AND object_table.".$indexName." IS NOT NULL" : '');
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($this->importHash, $objectTypeID, $oldID));
$row = $statement->fetchArray();
* @subpackage system.importer
* @category Community Framework
*/
-class LabelGroupImporter implements IImporter {
+class LabelGroupImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\label\group\LabelGroup';
+
/**
* @see wcf\system\importer\IImporter::import()
*/
* @subpackage system.importer
* @category Community Framework
*/
-class LabelImporter implements IImporter {
+class LabelImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\label\Label';
+
/**
* @see wcf\system\importer\IImporter::import()
*/
* @subpackage system.importer
* @category Community Framework
*/
-class SmileyImporter implements IImporter {
+class SmileyImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\smiley\Smiley';
+
/**
* known smiley codes
*
* @subpackage system.importer
* @category Community Framework
*/
-class UserAvatarImporter implements IImporter {
+class UserAvatarImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\user\avatar\UserAvatar';
+
/**
* @see wcf\system\importer\IImporter::import()
*/
if (!$data['userID']) return 0;
// save avatar
- $action = new UserAvatarAction(array(), 'create', array(
- 'data' => $data
- ));
- $returnValues = $action->executeAction();
- $avatar = $returnValues['returnValues'];
+ $avatar = UserAvatarEditor::create($data);
// check avatar directory
// and create subdirectory if necessary
* @subpackage system.importer
* @category Community Framework
*/
-class UserFollowerImporter implements IImporter {
+class UserFollowerImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\user\follow\UserFollow';
+
/**
* @see wcf\system\importer\IImporter::import()
*/
* @subpackage system.importer
* @category Community Framework
*/
-class UserGroupImporter implements IImporter {
+class UserGroupImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\user\group\UserGroup';
+
/**
* @see wcf\system\importer\IImporter::import()
*/
* @subpackage system.importer
* @category Community Framework
*/
-class UserImporter implements IImporter {
+class UserImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\user\User';
+
/**
* @see wcf\system\importer\IImporter::import()
*/
* @subpackage system.importer
* @category Community Framework
*/
-class UserOptionImporter implements IImporter {
+class UserOptionImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\user\option\UserOption';
+
/**
* language category id
* @var integer
<?php
namespace wcf\system\importer;
use wcf\data\user\group\UserGroup;
-use wcf\data\user\rank\UserRankAction;
+use wcf\data\user\rank\UserRankEditor;
/**
* Imports user ranks.
* @subpackage system.importer
* @category Community Framework
*/
-class UserRankImporter implements IImporter {
+class UserRankImporter extends AbstractImporter {
+ /**
+ * @see wcf\system\importer\AbstractImporter::$className
+ */
+ protected $className = 'wcf\data\user\rank\UserRank';
+
/**
* @see wcf\system\importer\IImporter::import()
*/
$data['groupID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user.group', $data['groupID']);
if (!$data['groupID']) $data['groupID'] = UserGroup::getGroupByType(UserGroup::USERS)->groupID;
- $action = new UserRankAction(array(), 'create', array(
- 'data' => $data
- ));
- $returnValues = $action->executeAction();
- $newID = $returnValues['returnValues']->rankID;
+ $rank = UserRankEditor::create($data);
- ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.rank', $oldID, $newID);
+ ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.rank', $oldID, $rank->rankID);
- return $newID;
+ return $rank->rankID;
}
}