<definitionname>com.woltlab.wcf.importer</definitionname>
<classname>wcf\system\importer\ArticleCommentResponseImporter</classname>
</type>
+ <type>
+ <name>com.woltlab.wcf.trophy.category</name>
+ <definitionname>com.woltlab.wcf.importer</definitionname>
+ <classname>wcf\system\importer\TrophyCategoryImporter</classname>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.trophy</name>
+ <definitionname>com.woltlab.wcf.importer</definitionname>
+ <classname>wcf\system\importer\TrophyImporter</classname>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.userTrophy</name>
+ <definitionname>com.woltlab.wcf.importer</definitionname>
+ <classname>wcf\system\importer\UserTrophyImporter</classname>
+ </type>
<!-- /importers -->
<!-- rebuild data workers -->
--- /dev/null
+<?php
+namespace wcf\system\importer;
+use wcf\data\object\type\ObjectTypeCache;
+
+/**
+ * Represents a trophy category importer.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Importer
+ * @since 3.1
+ */
+class TrophyCategoryImporter extends AbstractCategoryImporter {
+ /**
+ * @inheritDoc
+ */
+ protected $objectTypeName = 'com.woltlab.wcf.trophy.category';
+
+ /**
+ * Creates a new TrophyCategoryImporter object.
+ */
+ public function __construct() {
+ $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.category', $this->objectTypeName);
+ $this->objectTypeID = $objectType->objectTypeID;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\importer;
+use wcf\data\trophy\Trophy;
+use wcf\data\trophy\TrophyEditor;
+use wcf\system\WCF;
+use wcf\util\StringUtil;
+
+/**
+ * Represents a trophy importer.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Importer
+ * @since 3.1
+ */
+class TrophyImporter extends AbstractImporter {
+ /**
+ * @inheritDoc
+ */
+ protected $className = Trophy::class;
+
+ /**
+ * category for orphaned trophies
+ * @var integer
+ */
+ private $importCategoryID = 0;
+
+ /**
+ * @inheritDoc
+ */
+ public function import($oldID, array $data, array $additionalData = []) {
+ if (isset($data['categoryID'])) {
+ $data['categoryID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.trophy.category', $data['categoryID']);
+ }
+
+ if (!$data['categoryID']) {
+ $data['categoryID'] = $this->getImportCategoryID();
+ }
+
+ if ($data['type'] == Trophy::TYPE_IMAGE) {
+ if (!@file_exists($additionalData['fileLocation'])) {
+ return 0;
+ }
+
+ $filename = basename($additionalData['fileLocation']);
+ while (file_exists(WCF_DIR.'images/trophy/' . $filename)) {
+ $filename = substr(StringUtil::getRandomID(), 0, 5) . '_' . basename($additionalData['fileLocation']);
+ }
+
+ if (!@copy($additionalData['fileLocation'], WCF_DIR.'images/trophy/' . $filename)) {
+ return 0;
+ }
+
+ $data['iconFile'] = $filename;
+ }
+
+ $trophy = TrophyEditor::create($data);
+
+ if (!empty($additionalData['i18n'])) {
+ $values = [];
+
+ foreach (['title', 'description'] as $property) {
+ if (isset($additionalData['i18n'][$property])) {
+ $values[$property] = $additionalData['i18n'][$property];
+ }
+ }
+
+ if (!empty($values)) {
+ $updateData = [];
+ if (isset($values['title'])) $updateData['title'] = 'wcf.user.trophy.title' . $trophy->trophyID;
+ if (isset($values['description'])) $updateData['description'] = 'wcf.user.trophy.description' . $trophy->trophyID;
+
+ $items = [];
+ foreach ($values as $property => $propertyValues) {
+ foreach ($propertyValues as $languageID => $languageItemValue) {
+ $items[] = [
+ 'languageID' => $languageID,
+ 'languageItem' => 'wcf.user.trophy.' . $property . $trophy->trophyID,
+ 'languageItemValue' => $languageItemValue
+ ];
+ }
+ }
+
+ $this->importI18nValues($items, 'wcf.user.trophy', 'com.woltlab.wcf');
+
+ (new TrophyEditor($trophy))->update($updateData);
+ }
+ }
+
+ ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.trophy', $oldID, $trophy->trophyID);
+
+ return $trophy->trophyID;
+ }
+
+ /**
+ * Returns a categoryID for trophies without categoryID.
+ *
+ * @return integer
+ */
+ private function getImportCategoryID() {
+ if (!$this->importCategoryID) {
+ $objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.category', 'com.woltlab.wcf.trophy.category');
+
+ $sql = "SELECT categoryID
+ FROM wcf".WCF_N."_category
+ WHERE objectTypeID = ?
+ AND parentCategoryID = ?
+ AND title = ?
+ ORDER BY categoryID";
+ $statement = WCF::getDB()->prepareStatement($sql, 1);
+ $statement->execute([$objectTypeID, 0, 'Import']);
+ $categoryID = $statement->fetchSingleColumn();
+ if ($categoryID) {
+ $this->importCategoryID = $categoryID;
+ }
+ else {
+ $sql = "INSERT INTO wcf".WCF_N."_category
+ (objectTypeID, parentCategoryID, title, showOrder, time)
+ VALUES (?, ?, ?, ?, ?)";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([$objectTypeID, 0, 'Import', 0, TIME_NOW]);
+ $this->importCategoryID = WCF::getDB()->getInsertID("wcf".WCF_N."_category", 'categoryID');
+ }
+ }
+
+ return $this->importCategoryID;
+ }
+}
--- /dev/null
+<?php
+namespace wcf\system\importer;
+use wcf\data\user\trophy\UserTrophy;
+use wcf\data\user\trophy\UserTrophyEditor;
+
+/**
+ * Represents a user trophy importer.
+ *
+ * @author Joshua Ruesweg
+ * @copyright 2001-2017 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\System\Importer
+ * @since 3.1
+ */
+class UserTrophyImporter extends AbstractImporter {
+ /**
+ * @inheritDoc
+ */
+ protected $className = UserTrophy::class;
+
+ /**
+ * @inheritDoc
+ */
+ public function import($oldID, array $data, array $additionalData = []) {
+ if (isset($data['trophyID'])) {
+ $data['trophyID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.trophy', $data['trophyID']);
+ }
+
+ if (isset($data['userID'])) {
+ $data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
+ }
+
+ if (!$data['userID'] || !$data['trophyID']) {
+ return 0;
+ }
+
+ $userTrophy = UserTrophyEditor::create($data);
+
+ if (isset($additionalData['i18n']['description'])) {
+ $updateData['description'] = 'wcf.user.trophy.description' . $userTrophy->userTrophyID;
+
+ $items = [];
+ foreach ($additionalData['i18n']['description'] as $languageID => $languageItemValue) {
+ $items[] = [
+ 'languageID' => $languageID,
+ 'languageItem' => 'wcf.user.trophy.description' . $userTrophy->userTrophyID,
+ 'languageItemValue' => $languageItemValue
+ ];
+ }
+
+
+ $this->importI18nValues($items, 'wcf.user.trophy', 'com.woltlab.wcf');
+
+ (new UserTrophyEditor($userTrophy))->update($updateData);
+ }
+
+ ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.userTrophy', $oldID, $userTrophy->getObjectID());
+
+ return $userTrophy->getObjectID();
+ }
+}
<item name="wcf.acp.dataImport.data.com.woltlab.wcf.article.category"><![CDATA[Artikel-Kategorien]]></item>
<item name="wcf.acp.dataImport.data.com.woltlab.wcf.article.comment"><![CDATA[Artikel-Kommentare]]></item>
<item name="wcf.acp.dataImport.data.com.woltlab.wcf.media"><![CDATA[Medien]]></item>
+ <item name="wcf.acp.dataImport.data.com.woltlab.wcf.trophy.category"><![CDATA[Trophäen-Kategorien]]></item>
+ <item name="wcf.acp.dataImport.data.com.woltlab.wcf.trophy"><![CDATA[Trophäen]]></item>
+ <item name="wcf.acp.dataImport.data.com.woltlab.wcf.userTrophy"><![CDATA[Vergebene Trophäen]]></item>
<item name="wcf.acp.dataImport.existingMapping.confirmMessage"><![CDATA[{if LANGUAGE_USE_INFORMAL_VARIANT}Willst du{else}Wollen Sie{/if} die bestehenden Zuordnungen wirklich löschen?]]></item>
<item name="wcf.acp.dataImport.existingMapping.notice"><![CDATA[Es existieren Zuordnungen eines früheren Import-Vorganges, diese werden verwendet, um Inhalte aus dem importierten Forum einwandfrei zuzuordnen. Wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} den Import-Vorgang vollständig abgeschlossen {if LANGUAGE_USE_INFORMAL_VARIANT}hast{else}haben{/if}, {if LANGUAGE_USE_INFORMAL_VARIANT}kannst du{else}können Sie{/if} diese Zuordnungen <a id="deleteMapping">löschen</a>. {if LANGUAGE_USE_INFORMAL_VARIANT}Du solltest{else}Sie sollten{/if} die Zuordnungen nicht löschen, wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} jetzt oder zukünftig noch weitere Inhalte aus dem selben Forum übernehmen {if LANGUAGE_USE_INFORMAL_VARIANT}willst{else}wollen{/if}.]]></item>
<item name="wcf.acp.dataImport.exporter"><![CDATA[Datenquelle]]></item>
<item name="wcf.acp.dataImport.data.com.woltlab.wcf.article.category"><![CDATA[Article categories]]></item>
<item name="wcf.acp.dataImport.data.com.woltlab.wcf.article.comment"><![CDATA[Article comments]]></item>
<item name="wcf.acp.dataImport.data.com.woltlab.wcf.media"><![CDATA[Media]]></item>
+ <item name="wcf.acp.dataImport.data.com.woltlab.wcf.trophy.category"><![CDATA[Trophy categories]]></item>
+ <item name="wcf.acp.dataImport.data.com.woltlab.wcf.trophy"><![CDATA[Trophies]]></item>
+ <item name="wcf.acp.dataImport.data.com.woltlab.wcf.userTrophy"><![CDATA[Assigned trophies]]></item>
<item name="wcf.acp.dataImport.existingMapping.confirmMessage"><![CDATA[Do you really want to delete the existing import mappings?]]></item>
<item name="wcf.acp.dataImport.existingMapping.notice"><![CDATA[There are import mappings created by a previous import process, these mappings are used to properly handle connections between data from the imported forum and this one. In case you have imported all the desired data, you can <a id="deleteMapping">delete</a> the mappings. It is strongly recommended to keep these mappings as long as there is still data to be imported now or in the future.]]></item>
<item name="wcf.acp.dataImport.exporter"><![CDATA[Data Source]]></item>