BUGFIX: Fixes #51 by moving export filename building for contents to a single place.

pull/52/head
Bastian Heist 2018-07-20 12:52:36 +02:00
parent 9ee5fb9907
commit 284c722e04
1 changed files with 12 additions and 4 deletions

View File

@ -1688,7 +1688,7 @@ Class H5PExport {
$zip->close();
H5PCore::deleteFileTree($tmpPath);
$filename = $content['slug'] . '-' . $content['id'] . '.h5p';
$filename = self::buildExportFileName($content);
try {
// Save export
$this->h5pC->fs->saveExport($tmpFile, $filename);
@ -1733,13 +1733,21 @@ Class H5PExport {
}
}
/**
* @param array $content object
* @return string the export filename
*/
public static function buildExportFileName($content) {
return ($content['slug'] ? $content['slug'] . '-' : '') . $content['id'] . '.h5p';
}
/**
* Delete .h5p file
*
* @param array $content object
*/
public function deleteExport($content) {
$this->h5pC->fs->deleteExport(($content['slug'] ? $content['slug'] . '-' : '') . $content['id'] . '.h5p');
$this->h5pC->fs->deleteExport(self::buildExportFileName($content));
}
/**
@ -1947,7 +1955,7 @@ class H5PCore {
if (!empty($content['filtered']) &&
(!$this->exportEnabled ||
($content['slug'] &&
$this->fs->hasExport($content['slug'] . '-' . $content['id'] . '.h5p')))) {
$this->fs->hasExport(H5PExport::buildExportFileName($content))))) {
return $content['filtered'];
}
@ -1976,7 +1984,7 @@ class H5PCore {
$content['slug'] = $this->generateContentSlug($content);
// Remove old export file
$this->fs->deleteExport($content['id'] . '.h5p');
$this->fs->deleteExport(H5PExport::buildExportFileName($content));
}
if ($this->exportEnabled) {