Add media category importer
authorMatthias Schmidt <gravatronics@live.com>
Sun, 8 Sep 2019 17:24:47 +0000 (19:24 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 8 Sep 2019 17:24:47 +0000 (19:24 +0200)
Close #3069

com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/importer/MediaCategoryImporter.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/importer/MediaImporter.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index fa07ea4b5bf6be45c9169276a050c00c9b755185..8393c09d834ffcedd34930a78bcbe50e2046b2a6 100644 (file)
                        <definitionname>com.woltlab.wcf.importer</definitionname>
                        <classname>wcf\system\importer\ArticleImporter</classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.media.category</name>
+                       <definitionname>com.woltlab.wcf.importer</definitionname>
+                       <classname>wcf\system\importer\MediaCategoryImporter</classname>
+               </type>
                <type>
                        <name>com.woltlab.wcf.media</name>
                        <definitionname>com.woltlab.wcf.importer</definitionname>
diff --git a/wcfsetup/install/files/lib/system/importer/MediaCategoryImporter.class.php b/wcfsetup/install/files/lib/system/importer/MediaCategoryImporter.class.php
new file mode 100644 (file)
index 0000000..70f8a46
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+namespace wcf\system\importer;
+use wcf\data\object\type\ObjectTypeCache;
+
+/**
+ * Imports media categories.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2019 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Importer
+ */
+class MediaCategoryImporter extends AbstractCategoryImporter {
+       /**
+        * @inheritDoc
+        */
+       protected $objectTypeName = 'com.woltlab.wcf.media.category';
+       
+       /**
+        * Creates a new `MediaCategoryImporter` object.
+        */
+       public function __construct() {
+               $this->objectTypeID = ObjectTypeCache::getInstance()->getObjectTypeByName(
+                       'com.woltlab.wcf.category',
+                       'com.woltlab.wcf.media.category'
+               )->objectTypeID;
+       }
+}
index bf32652ee86def4aee635a7a301acbb3b76832ab..b34514b44c5dbecdbfc59a0a23e98b62007e3a4c 100644 (file)
@@ -70,6 +70,15 @@ class MediaImporter extends AbstractImporter {
                        if (!$media->mediaID) $data['mediaID'] = $oldID;
                }
                
+               // category
+               $categoryID = null;
+               if (!empty($data['categoryID'])) {
+                       $categoryID = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.media.category', $data['categoryID']);
+               }
+               if ($categoryID !== null) {
+                       $data['categoryID'] = $categoryID;
+               }
+               
                // save media
                $media = MediaEditor::create($data);
                
index c7fd1c25b77e44f9a9401ae569b0e3c982cadb57..28ff5d69ab824a0263790f48bbaaed3e7e7a9370 100644 (file)
                <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.article.comment.response"><![CDATA[Artikel-Kommentar-Antworten]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.media.category"><![CDATA[Medien-Kategorien]]></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>
index ed54fdc3b2c8cba02e7b8e51ee04bed81b2bbcec..330a49bc2004317977731039a010d35477689951 100644 (file)
                <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.article.comment.response"><![CDATA[Replies to article comments]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.media.category"><![CDATA[Media categories]]></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>