Added smiley import
authorMarcel Werk <burntime@woltlab.com>
Mon, 15 Jul 2013 19:06:56 +0000 (21:06 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 15 Jul 2013 19:06:56 +0000 (21:06 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/exporter/AbstractExporter.class.php
wcfsetup/install/files/lib/system/importer/ImportHandler.class.php
wcfsetup/install/files/lib/system/importer/SmileyImporter.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 2b6f800839cd4ec653e60b2d4e0652780e0f5097..0c0a13e81c76ce33642042997173b3eed60b00a6 100644 (file)
                        <definitionname>com.woltlab.wcf.importer</definitionname>
                        <classname><![CDATA[wcf\system\importer\LabelImporter]]></classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.smiley</name>
+                       <definitionname>com.woltlab.wcf.importer</definitionname>
+                       <classname><![CDATA[wcf\system\importer\SmileyImporter]]></classname>
+               </type>
                <!-- /importers -->
                
                <!-- rebuild data workers -->
index 8a9a6d749984a360a87fda514b6f9975ad6c8982..cd4f252c9082839b8f1009945f5d54866b288d22 100644 (file)
@@ -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;
+       }
+       
 }
index eded45a9504423239b9125bfbcb0cbd56f956f39..fe4ee88e1787fdc5ae7d23eed1dc0fa4ca67b4c3 100644 (file)
@@ -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 (file)
index 0000000..10dbde0
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+namespace wcf\system\importer;
+use wcf\data\smiley\SmileyEditor;
+
+/**
+ * Imports smilies.
+ *
+ * @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
+ */
+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;
+       }
+}
index 4cc28baed59b2efe94d0d889dc1aed1c2adde843..b043f85534e093f7e417f4aac83c945c52c59024 100644 (file)
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.comment"><![CDATA[Pinnwand-Kommentare]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.comment.response"><![CDATA[Pinnwand-Kommentar-Antworten]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.label"><![CDATA[Labels]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.smiley"><![CDATA[Smileys]]></item>
                <item name="wcf.acp.dataImport.configure.database"><![CDATA[Datenbank-Zugang]]></item>
                <item name="wcf.acp.dataImport.configure.database.host"><![CDATA[Hostname]]></item>
                <item name="wcf.acp.dataImport.configure.database.user"><![CDATA[Benutzername]]></item>
index 8265381a941aab271b7da81d2608b289006794e4..5c09bbb3447f3d7dded3d3f3a3f85ab733a214f5 100644 (file)
@@ -176,6 +176,7 @@ Examples for medium ID detection:
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.comment"><![CDATA[TODO: Pinwand-Kommentare]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.user.comment.response"><![CDATA[TODO: Pinwand-Kommentar-Antworten]]></item>
                <item name="wcf.acp.dataImport.data.com.woltlab.wcf.label"><![CDATA[TODO: Labels]]></item>
+               <item name="wcf.acp.dataImport.data.com.woltlab.wcf.smiley"><![CDATA[Smilies]]></item>
                <item name="wcf.acp.dataImport.configure.database"><![CDATA[TODO: Datenbank-Zugang]]></item>
                <item name="wcf.acp.dataImport.configure.database.host"><![CDATA[TODO: Hostname]]></item>
                <item name="wcf.acp.dataImport.configure.database.user"><![CDATA[TODO: Benutzername]]></item>