From: Tim Düsterhus Date: Sun, 15 Sep 2013 14:18:55 +0000 (+0200) Subject: Export smileys (SMF) X-Git-Tag: 2.0.0_Beta_6~5^2~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9d637b140e810276286b0a6418ee2d6ae02c6439;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.exporter.git Export smileys (SMF) --- diff --git a/files/lib/system/exporter/SMF2xExporter.class.php b/files/lib/system/exporter/SMF2xExporter.class.php index d3c35a0..2e65052 100644 --- a/files/lib/system/exporter/SMF2xExporter.class.php +++ b/files/lib/system/exporter/SMF2xExporter.class.php @@ -98,7 +98,7 @@ class SMF2xExporter extends AbstractExporter { 'com.woltlab.wcf.conversation' => array( 'com.woltlab.wcf.conversation.label' ), - /*'com.woltlab.wcf.smiley' => array()*/ + 'com.woltlab.wcf.smiley' => array() ); } @@ -174,9 +174,9 @@ class SMF2xExporter extends AbstractExporter { } } - /*// smiley + // smiley if (in_array('com.woltlab.wcf.smiley', $this->selectedData)) $queue[] = 'com.woltlab.wcf.smiley'; - */ + return $queue; } @@ -381,6 +381,7 @@ class SMF2xExporter extends AbstractExporter { while ($row = $statement->fetchArray()) { switch ($row['type']) { case 'attachment': + // TODO: read option attachmentUploadDir $fileLocation = $this->fileSystemPath.'attachments/'.$row['filename']; break; case 'user': @@ -745,6 +746,7 @@ class SMF2xExporter extends AbstractExporter { $statement = $this->database->prepareStatement($sql, $limit, $offset); $statement->execute(array(0, 0)); while ($row = $statement->fetchArray()) { + // TODO: read option attachmentUploadDir $fileLocation = $this->fileSystemPath.'attachments/'.$row['id_attach'].'_'.$row['file_hash']; if ($imageSize = getimagesize($fileLocation)) { @@ -904,6 +906,49 @@ class SMF2xExporter extends AbstractExporter { } } + /** + * Counts smilies. + */ + public function countSmilies() { + $sql = "SELECT COUNT(DISTINCT filename) AS count + FROM ".$this->databasePrefix."smileys"; + $statement = $this->database->prepareStatement($sql); + $statement->execute(); + $row = $statement->fetchArray(); + return $row['count']; + } + + /** + * Exports smilies. + */ + public function exportSmilies($offset, $limit) { + $sql = "SELECT MIN(id_smiley) AS id_smiley, + GROUP_CONCAT(code SEPARATOR '\n') AS aliases, + filename, + MIN(smiley_order) AS smiley_order, + GROUP_CONCAT(description SEPARATOR '\n') AS description + FROM ".$this->databasePrefix."smileys + GROUP BY filename + ORDER BY id_smiley ASC"; + $statement = $this->database->prepareStatement($sql, $limit, $offset); + $statement->execute(array()); + while ($row = $statement->fetchArray()) { + // TODO: read options: smileys_dir, smiley_sets_default + $fileLocation = $this->fileSystemPath.'Smileys/default/'.$row['filename']; + + $aliases = explode("\n", $row['aliases']); + $code = array_shift($aliases); + $description = mb_substr($row['description'], 0, mb_strpos($row['description'], "\n") ?: mb_strlen($row['description'])); // we had to GROUP_CONCAT it because of SQL strict mode + + ImportHandler::getInstance()->getImporter('com.woltlab.wcf.smiley')->import($row['id_smiley'], array( + 'smileyTitle' => $description, + 'smileyCode' => $code, + 'showOrder' => $row['smiley_order'], + 'aliases' => implode("\n", $aliases) + ), array('fileLocation' => $fileLocation)); + } + } + private static function fixBBCodes($message) { $message = str_replace(array( '
',