From e79e9dae0e5588883ce09fa5130f016ccefe48e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 3 Sep 2013 17:37:46 +0200 Subject: [PATCH] Add SMF 2 exporter barebone --- .../system/exporter/SMF2xExporter.class.php | 192 ++++++++++++++++++ language/de.xml | 1 + language/en.xml | 1 + objectType.xml | 6 + 4 files changed, 200 insertions(+) create mode 100644 files/lib/system/exporter/SMF2xExporter.class.php diff --git a/files/lib/system/exporter/SMF2xExporter.class.php b/files/lib/system/exporter/SMF2xExporter.class.php new file mode 100644 index 0000000..bd11f18 --- /dev/null +++ b/files/lib/system/exporter/SMF2xExporter.class.php @@ -0,0 +1,192 @@ + + * @package com.woltlab.wcf.exporter + * @subpackage system.exporter + * @category Community Framework (commercial) + */ +class SMF2xExporter extends AbstractExporter { + /** + * board cache + * @var array + */ + protected $boardCache = array(); + + /** + * @see wcf\system\exporter\AbstractExporter::$methods + */ + protected $methods = array( + 'com.woltlab.wcf.user' => 'Users', + 'com.woltlab.wcf.user.group' => 'UserGroups', + 'com.woltlab.wcf.user.rank' => 'UserRanks', + 'com.woltlab.wcf.user.follower' => 'Followers', + 'com.woltlab.wcf.user.avatar' => 'UserAvatars', + 'com.woltlab.wcf.user.option' => 'UserOptions', + 'com.woltlab.wcf.conversation.label' => 'ConversationFolders', + 'com.woltlab.wcf.conversation' => 'Conversations', + 'com.woltlab.wcf.conversation.message' => 'ConversationMessages', + 'com.woltlab.wcf.conversation.user' => 'ConversationUsers', + 'com.woltlab.wcf.conversation.attachment' => 'ConversationAttachments', + 'com.woltlab.wbb.board' => 'Boards', + 'com.woltlab.wbb.thread' => 'Threads', + 'com.woltlab.wbb.post' => 'Posts', + 'com.woltlab.wbb.attachment' => 'PostAttachments', + 'com.woltlab.wbb.watchedThread' => 'WatchedThreads', + 'com.woltlab.wbb.poll' => 'Polls', + 'com.woltlab.wbb.poll.option' => 'PollOptions', + 'com.woltlab.wbb.poll.option.vote' => 'PollOptionVotes', + 'com.woltlab.wbb.like' => 'Likes', + 'com.woltlab.wcf.label' => 'Labels', + 'com.woltlab.wbb.acl' => 'ACLs', + 'com.woltlab.wcf.smiley' => 'Smilies' + ); + + /** + * @see wcf\system\exporter\AbstractExporter::$limits + */ + protected $limits = array( + 'com.woltlab.wcf.user' => 200, + 'com.woltlab.wcf.user.avatar' => 100, + 'com.woltlab.wcf.user.follower' => 100 + ); + + /** + * @see wcf\system\exporter\IExporter::getSupportedData() + */ + public function getSupportedData() { + return array( + /*'com.woltlab.wcf.user' => array( + 'com.woltlab.wcf.user.group', + 'com.woltlab.wcf.user.avatar', + 'com.woltlab.wcf.user.option', + 'com.woltlab.wcf.user.follower', + 'com.woltlab.wcf.user.rank' + ), + 'com.woltlab.wbb.board' => array( + 'com.woltlab.wbb.acl', + 'com.woltlab.wbb.attachment', + 'com.woltlab.wbb.poll', + 'com.woltlab.wbb.watchedThread', + 'com.woltlab.wbb.like', + 'com.woltlab.wcf.label' + ), + 'com.woltlab.wcf.conversation' => array( + 'com.woltlab.wcf.conversation.label' + ), + 'com.woltlab.wcf.smiley' => array()*/ + ); + } + + /** + * @see wcf\system\exporter\IExporter::validateDatabaseAccess() + */ + public function validateDatabaseAccess() { + parent::validateDatabaseAccess(); + + $sql = "SELECT value + FROM ".$this->databasePrefix."settings + WHERE Variable = ?"; + $statement = $this->database->prepareStatement($sql); + $statement->execute(array('smfVersion')); + $row = $statement->fetchArray(); + + if (version_compare('2.0.0', $row['value'], '<=')) throw new DatabaseException('Cannot import less than SMF 2.x', $this->database); + } + + /** + * @see wcf\system\exporter\IExporter::validateFileAccess() + */ + public function validateFileAccess() { + if (in_array('com.woltlab.wcf.user.avatar', $this->selectedData) || in_array('com.woltlab.wbb.attachment', $this->selectedData) || in_array('com.woltlab.wcf.smiley', $this->selectedData)) { + if (empty($this->fileSystemPath) || !@file_exists($this->fileSystemPath . 'SSI.php')) return false; + } + + return true; + } + + /** + * @see wcf\system\exporter\IExporter::getQueue() + */ + public function getQueue() { + $queue = array(); + /* + // user + if (in_array('com.woltlab.wcf.user', $this->selectedData)) { + if (in_array('com.woltlab.wcf.user.group', $this->selectedData)) { + $queue[] = 'com.woltlab.wcf.user.group'; + if (in_array('com.woltlab.wcf.user.rank', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.rank'; + } + + if (in_array('com.woltlab.wcf.user.option', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.option'; + $queue[] = 'com.woltlab.wcf.user'; + if (in_array('com.woltlab.wcf.user.avatar', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.avatar'; + + if (in_array('com.woltlab.wcf.user.follower', $this->selectedData)) $queue[] = 'com.woltlab.wcf.user.follower'; + + // conversation + if (in_array('com.woltlab.wcf.conversation', $this->selectedData)) { + if (in_array('com.woltlab.wcf.conversation.label', $this->selectedData)) $queue[] = 'com.woltlab.wcf.conversation.label'; + + $queue[] = 'com.woltlab.wcf.conversation'; + $queue[] = 'com.woltlab.wcf.conversation.user'; + } + } + + // 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'; + + 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'; + if (in_array('com.woltlab.wbb.watchedThread', $this->selectedData)) $queue[] = 'com.woltlab.wbb.watchedThread'; + if (in_array('com.woltlab.wbb.poll', $this->selectedData)) { + $queue[] = 'com.woltlab.wbb.poll'; + $queue[] = 'com.woltlab.wbb.poll.option'; + $queue[] = 'com.woltlab.wbb.poll.option.vote'; + } + if (in_array('com.woltlab.wbb.like', $this->selectedData)) $queue[] = 'com.woltlab.wbb.like'; + } + + // smiley + if (in_array('com.woltlab.wcf.smiley', $this->selectedData)) $queue[] = 'com.woltlab.wcf.smiley'; + */ + return $queue; + } + + /** + * @see wcf\system\exporter\IExporter::getDefaultDatabasePrefix() + */ + public function getDefaultDatabasePrefix() { + return 'smf_'; + } +} diff --git a/language/de.xml b/language/de.xml index 1486f84..fa38495 100644 --- a/language/de.xml +++ b/language/de.xml @@ -4,5 +4,6 @@ + diff --git a/language/en.xml b/language/en.xml index bbd560a..4c2784e 100644 --- a/language/en.xml +++ b/language/en.xml @@ -4,5 +4,6 @@ + diff --git a/objectType.xml b/objectType.xml index 89be81b..d9e9d02 100644 --- a/objectType.xml +++ b/objectType.xml @@ -18,5 +18,11 @@ com.woltlab.wcf.exporter wcf\system\exporter\MyBB16xExporter + + + com.woltlab.wcf.exporter.smf2x + com.woltlab.wcf.exporter + wcf\system\exporter\SMF2xExporter + \ No newline at end of file -- 2.20.1