From: Tim Düsterhus Date: Wed, 11 Sep 2013 19:25:32 +0000 (+0200) Subject: Export threads (SMF) X-Git-Tag: 2.0.0_Beta_6~5^2~16 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5f481e683ec15f7936098a43a5efed1f37176bbf;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.exporter.git Export threads (SMF) --- diff --git a/files/lib/system/exporter/SMF2xExporter.class.php b/files/lib/system/exporter/SMF2xExporter.class.php index 0e98877..b436255 100644 --- a/files/lib/system/exporter/SMF2xExporter.class.php +++ b/files/lib/system/exporter/SMF2xExporter.class.php @@ -94,8 +94,7 @@ class SMF2xExporter extends AbstractExporter { 'com.woltlab.wbb.attachment', 'com.woltlab.wbb.poll', 'com.woltlab.wbb.watchedThread', - 'com.woltlab.wbb.like', - 'com.woltlab.wcf.label'*/ + 'com.woltlab.wbb.like'*/ ), 'com.woltlab.wcf.conversation' => array( 'com.woltlab.wcf.conversation.label' @@ -163,9 +162,8 @@ class SMF2xExporter extends AbstractExporter { // board if (in_array('com.woltlab.wbb.board', $this->selectedData)) { $queue[] = 'com.woltlab.wbb.board'; - /*if (in_array('com.woltlab.wcf.label', $this->selectedData)) $queue[] = 'com.woltlab.wcf.label'; $queue[] = 'com.woltlab.wbb.thread'; - $queue[] = 'com.woltlab.wbb.post'; + /*$queue[] = 'com.woltlab.wbb.post'; if (in_array('com.woltlab.wbb.acl', $this->selectedData)) $queue[] = 'com.woltlab.wbb.acl'; if (in_array('com.woltlab.wbb.attachment', $this->selectedData)) $queue[] = 'com.woltlab.wbb.attachment'; @@ -628,11 +626,53 @@ class SMF2xExporter extends AbstractExporter { 'posts' => $board['num_posts'], 'threads' => $board['num_topics'] )); - + $this->exportBoardsRecursively($board['id_board']); } } + /** + * Counts threads. + */ + public function countThreads() { + $sql = "SELECT COUNT(*) AS count + FROM ".$this->databasePrefix."topics"; + $statement = $this->database->prepareStatement($sql); + $statement->execute(); + $row = $statement->fetchArray(); + return $row['count']; + } + + /** + * Exports threads. + */ + public function exportThreads($offset, $limit) { + // get threads + $sql = "SELECT topic.*, post.subject, post.poster_time AS time, post.poster_name AS username + FROM ".$this->databasePrefix."topics topic + LEFT JOIN ".$this->databasePrefix."messages post + ON (post.id_msg = topic.id_first_msg) + ORDER BY id_topic ASC"; + $statement = $this->database->prepareStatement($sql, $limit, $offset); + $statement->execute(); + while ($row = $statement->fetchArray()) { + ImportHandler::getInstance()->getImporter('com.woltlab.wbb.thread')->import($row['id_topic'], array( + 'boardID' => $row['id_board'], + 'topic' => $row['subject'], + 'time' => $row['time'], + 'userID' => $row['id_member_started'] ?: null, + 'username' => $row['username'], + 'views' => $row['num_views'], + 'isAnnouncement' => 0, + 'isSticky' => $row['is_sticky'] ? 1 : 0, + 'isDisabled' => $row['approved'] ? 0 : 1, + 'isClosed' => $row['locked'] ? 1 : 0, + 'movedThreadID' => null, // TODO: Maybe regex this out of the body? + 'movedTime' => 0 + )); + } + } + private static function fixBBCodes($message) { // TODO: This is a identity function right now... return $message;