From 7a938996a232e48dbb0da32f71963afe6da3a9e6 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 8 Sep 2019 19:24:47 +0200 Subject: [PATCH] Add media category importer Close #3069 --- com.woltlab.wcf/objectType.xml | 5 ++++ .../importer/MediaCategoryImporter.class.php | 28 +++++++++++++++++++ .../system/importer/MediaImporter.class.php | 9 ++++++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 5 files changed, 44 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/importer/MediaCategoryImporter.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index fa07ea4b5b..8393c09d83 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -451,6 +451,11 @@ com.woltlab.wcf.importer wcf\system\importer\ArticleImporter + + com.woltlab.wcf.media.category + com.woltlab.wcf.importer + wcf\system\importer\MediaCategoryImporter + com.woltlab.wcf.media com.woltlab.wcf.importer 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 index 0000000000..70f8a4631c --- /dev/null +++ b/wcfsetup/install/files/lib/system/importer/MediaCategoryImporter.class.php @@ -0,0 +1,28 @@ + + * @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; + } +} diff --git a/wcfsetup/install/files/lib/system/importer/MediaImporter.class.php b/wcfsetup/install/files/lib/system/importer/MediaImporter.class.php index bf32652ee8..b34514b44c 100644 --- a/wcfsetup/install/files/lib/system/importer/MediaImporter.class.php +++ b/wcfsetup/install/files/lib/system/importer/MediaImporter.class.php @@ -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); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index c7fd1c25b7..28ff5d69ab 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -382,6 +382,7 @@ + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index ed54fdc3b2..330a49bc20 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -358,6 +358,7 @@ + -- 2.20.1