From 02f42c85cdade1d7218f0e349dbec60940bb011c Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 15 Jul 2013 21:06:56 +0200 Subject: [PATCH] Added smiley import --- com.woltlab.wcf/objectType.xml | 5 +++ .../exporter/AbstractExporter.class.php | 35 +++++++++++++++++++ .../system/importer/ImportHandler.class.php | 11 ++++++ .../system/importer/SmileyImporter.class.php | 29 +++++++++++++++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 6 files changed, 82 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/importer/SmileyImporter.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 2b6f800839..0c0a13e81c 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -262,6 +262,11 @@ com.woltlab.wcf.importer + + com.woltlab.wcf.smiley + com.woltlab.wcf.importer + + diff --git a/wcfsetup/install/files/lib/system/exporter/AbstractExporter.class.php b/wcfsetup/install/files/lib/system/exporter/AbstractExporter.class.php index 8a9a6d7499..cd4f252c90 100644 --- a/wcfsetup/install/files/lib/system/exporter/AbstractExporter.class.php +++ b/wcfsetup/install/files/lib/system/exporter/AbstractExporter.class.php @@ -76,6 +76,12 @@ abstract class AbstractExporter implements IExporter { */ protected $defaultLimit = 1000; + /** + * selected import data + * @var array + */ + protected $selectedData = array(); + /** * @see wcf\system\exporter\IExporter::setData() */ @@ -133,4 +139,33 @@ abstract class AbstractExporter implements IExporter { $limit = (isset($this->limits[$objectType]) ? $this->limits[$objectType] : $this->defaultLimit); call_user_func(array($this, 'export'.$this->methods[$objectType]), $loopCount * $limit, $limit); } + + /** + * @see wcf\system\exporter\IExporter::validateSelectedData() + */ + public function validateSelectedData(array $selectedData) { + $this->selectedData = $selectedData; + + if (!count($this->selectedData)) { + return false; + } + + $supportedData = $this->getSupportedData(); + foreach ($this->selectedData as $name) { + if (isset($supportedData[$name])) break; + + foreach ($supportedData as $key => $data) { + if (in_array($name, $data)) { + if (!in_array($key, $selectedData)) return false; + + break 2; + } + } + + return false; + } + + return true; + } + } diff --git a/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php b/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php index eded45a950..fe4ee88e17 100644 --- a/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php +++ b/wcfsetup/install/files/lib/system/importer/ImportHandler.class.php @@ -110,6 +110,17 @@ class ImportHandler extends SingletonFactory { unset($this->idMappingCache[$objectTypeID][$oldID]); } + /** + * Resets the mapping. + */ + public function resetMapping() { + $sql = "DELETE FROM wcf".WCF_N."_import_mapping"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(); + + $this->idMappingCache = array(); + } + /** * Sets the user merge mode. * diff --git a/wcfsetup/install/files/lib/system/importer/SmileyImporter.class.php b/wcfsetup/install/files/lib/system/importer/SmileyImporter.class.php new file mode 100644 index 0000000000..10dbde0b6f --- /dev/null +++ b/wcfsetup/install/files/lib/system/importer/SmileyImporter.class.php @@ -0,0 +1,29 @@ + + * @package com.woltlab.wcf + * @subpackage system.importer + * @category Community Framework + */ +class SmileyImporter implements IImporter { + /** + * @see wcf\system\importer\IImporter::import() + */ + public function import($oldID, array $data, array $additionalData = array()) { + // copy smiley + $data['smileyPath'] = 'images/smilies/'.basename($additionalData['fileLocation']); + if (!@copy($additionalData['fileLocation'], WCF_DIR.$data['smileyPath'])) return 0; + + // save smiley + $smiley = SmileyEditor::create($data); + + return $smiley->smileyID; + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 4cc28baed5..b043f85534 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -177,6 +177,7 @@ + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 8265381a94..5c09bbb344 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -176,6 +176,7 @@ Examples for medium ID detection: + -- 2.20.1