*/
public function exportFilebaseFiles($offset, $limit)
{
- if (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '6.1.0 Alpha 1', '>=')) {
- $this->exportFilebaseFiles61($offset, $limit);
-
- return;
- } elseif (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '5.3.0 Alpha 1', '>=')) {
+ if (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '5.3.0 Alpha 1', '>=')) {
$this->exportFilebaseFiles53($offset, $limit);
return;
}
/**
- * Exports filebase files from 5.3 to 6.0.
+ * Exports filebase files from 5.3+.
*
* @param integer $offset
* @param integer $limit
return;
}
- // get file contents
- $fileContents = $fileContentIDs = [];
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('fileID IN (?)', [$fileIDs]);
- $sql = "SELECT file_content.*, language.languageCode
- FROM filebase" . $this->dbNo . "_file_content file_content
- LEFT JOIN wcf" . $this->dbNo . "_language language
- ON language.languageID = file_content.languageID
- " . $conditionBuilder;
- $statement = $this->database->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- while ($row = $statement->fetchArray()) {
- $fileContents[$row['fileID']][$row['languageCode'] ?: ''] = $row;
- $fileContentIDs[] = $row['fileContentID'];
- }
-
- // get tags
- $tags = $this->getTags('com.woltlab.filebase.file', $fileContentIDs);
- // get files
- $sql = "SELECT *
- FROM filebase" . $this->dbNo . "_file
- " . $conditionBuilder;
- $statement = $this->database->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- while ($row = $statement->fetchArray()) {
- $contents = [];
- if (isset($fileContents[$row['fileID']])) {
- foreach ($fileContents[$row['fileID']] as $languageCode => $fileContent) {
- $contents[$languageCode ?: ''] = [
- 'subject' => $fileContent['subject'],
- 'teaser' => $fileContent['teaser'],
- 'message' => $fileContent['message'],
- 'tags' => $tags[$fileContent['fileContentID']] ?? [],
- ];
- }
- }
-
- $this->exportFilebaseFilesHelper($row, $contents, [$row['categoryID']]);
- }
- }
-
- /**
- * Exports filebase files from 6.1+.
- */
- public function exportFilebaseFiles61(int $offset, int $limit): void
- {
- // get file ids
- $fileIDs = [];
- $sql = "SELECT fileID
- FROM filebase" . $this->dbNo . "_file
- WHERE fileID BETWEEN ? AND ?
- ORDER BY fileID";
- $statement = $this->database->prepareStatement($sql);
- $statement->execute([$offset + 1, $offset + $limit]);
- while ($row = $statement->fetchArray()) {
- $fileIDs[] = $row['fileID'];
- }
- if (empty($fileIDs)) {
- return;
+ $coreFiles = [];
+ if (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '6.1.0 Alpha 1', '>=')) {
+ $sql = "SELECT fileIconID
+ FROM filebase" . $this->dbNo . "_file
+ " . $conditionBuilder;
+ $statement = $this->database->prepareStatement($sql);
+ $statement->execute($conditionBuilder->getParameters());
+ $coreFiles = $this->getFileLocations($statement->fetchAll(\PDO::FETCH_COLUMN));
}
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('fileID IN (?)', [$fileIDs]);
-
- $sql = "SELECT fileIconID
- FROM filebase" . $this->dbNo . "_file
- " . $conditionBuilder;
- $statement = $this->database->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- $coreFiles = $this->getFileLocations($statement->fetchAll(\PDO::FETCH_COLUMN));
// get file contents
$fileContents = $fileContentIDs = [];
*/
public function exportFilebaseFileVersions($offset, $limit)
{
- if (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '6.1.0 Alpha 1', '>=')) {
- $this->exportFilebaseFileVersions61($offset, $limit);
-
- return;
- } elseif (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '5.3.0 Alpha 1', '>=')) {
+ if (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '5.3.0 Alpha 1', '>=')) {
$this->exportFilebaseFileVersions53($offset, $limit);
return;
}
/**
- * Exports filebase file versions from 5.3 up to 6.0.
+ * Exports filebase file versions from 5.3+.
*
* @param integer $offset
* @param integer $limit
return;
}
- // get version contents
- $versionContents = [];
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('versionID IN (?)', [$versionIDs]);
- $sql = "SELECT version_content.*, language.languageCode
- FROM filebase" . $this->dbNo . "_file_version_content version_content
- LEFT JOIN wcf" . $this->dbNo . "_language language
- ON language.languageID = version_content.languageID
- " . $conditionBuilder;
- $statement = $this->database->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- while ($row = $statement->fetchArray()) {
- $versionContents[$row['versionID']][$row['languageCode'] ?: ''] = $row;
- }
-
- // get versions
- $sql = "SELECT *
- FROM filebase" . $this->dbNo . "_file_version
- " . $conditionBuilder;
- $statement = $this->database->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- while ($row = $statement->fetchArray()) {
- $contents = [];
- if (isset($versionContents[$row['versionID']])) {
- foreach ($versionContents[$row['versionID']] as $languageCode => $versionContent) {
- $contents[$languageCode ?: ''] = [
- 'description' => $versionContent['description'],
- ];
- }
- }
-
- $this->exportFilebaseFileVersionsHelper($row, $contents);
- }
- }
- /**
- * Exports filebase file versions from 6.1+.
- *
- * @param int $offset
- * @param int $limit
- */
- public function exportFilebaseFileVersions61($offset, $limit)
- {
- // get version ids
- $versionIDs = [];
- $sql = "SELECT versionID
- FROM filebase" . $this->dbNo . "_file_version
- WHERE versionID BETWEEN ? AND ?
- ORDER BY versionID";
- $statement = $this->database->prepareStatement($sql);
- $statement->execute([$offset + 1, $offset + $limit]);
- while ($row = $statement->fetchArray()) {
- $versionIDs[] = $row['versionID'];
- }
- if (empty($versionIDs)) {
- return;
+ $coreFiles = [];
+ if (\version_compare($this->getPackageVersion('com.woltlab.filebase'), '6.1.0 Alpha 1', '>=')) {
+ $sql = "SELECT coreFileID
+ FROM filebase" . $this->dbNo . "_file_version
+ " . $conditionBuilder;
+ $statement = $this->database->prepareStatement($sql);
+ $statement->execute($conditionBuilder->getParameters());
+ $coreFiles = $this->getFileLocations($statement->fetchAll(\PDO::FETCH_COLUMN));
}
- $conditionBuilder = new PreparedStatementConditionBuilder();
- $conditionBuilder->add('versionID IN (?)', [$versionIDs]);
-
- $sql = "SELECT coreFileID
- FROM filebase" . $this->dbNo . "_file_version
- " . $conditionBuilder;
- $statement = $this->database->prepareStatement($sql);
- $statement->execute($conditionBuilder->getParameters());
- $coreFiles = $this->getFileLocations($statement->fetchAll(\PDO::FETCH_COLUMN));
// get version contents
$versionContents = [];
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ $conditionBuilder->add('versionID IN (?)', [$versionIDs]);
$sql = "SELECT version_content.*, language.languageCode
FROM filebase" . $this->dbNo . "_file_version_content version_content
LEFT JOIN wcf" . $this->dbNo . "_language language