BUGFIX: Fixes #51 by moving export filename building for contents to a single place.
parent
9ee5fb9907
commit
284c722e04
|
@ -1688,7 +1688,7 @@ Class H5PExport {
|
||||||
$zip->close();
|
$zip->close();
|
||||||
H5PCore::deleteFileTree($tmpPath);
|
H5PCore::deleteFileTree($tmpPath);
|
||||||
|
|
||||||
$filename = $content['slug'] . '-' . $content['id'] . '.h5p';
|
$filename = self::buildExportFileName($content);
|
||||||
try {
|
try {
|
||||||
// Save export
|
// Save export
|
||||||
$this->h5pC->fs->saveExport($tmpFile, $filename);
|
$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
|
* Delete .h5p file
|
||||||
*
|
*
|
||||||
* @param array $content object
|
* @param array $content object
|
||||||
*/
|
*/
|
||||||
public function deleteExport($content) {
|
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']) &&
|
if (!empty($content['filtered']) &&
|
||||||
(!$this->exportEnabled ||
|
(!$this->exportEnabled ||
|
||||||
($content['slug'] &&
|
($content['slug'] &&
|
||||||
$this->fs->hasExport($content['slug'] . '-' . $content['id'] . '.h5p')))) {
|
$this->fs->hasExport(H5PExport::buildExportFileName($content))))) {
|
||||||
return $content['filtered'];
|
return $content['filtered'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1976,7 +1984,7 @@ class H5PCore {
|
||||||
$content['slug'] = $this->generateContentSlug($content);
|
$content['slug'] = $this->generateContentSlug($content);
|
||||||
|
|
||||||
// Remove old export file
|
// Remove old export file
|
||||||
$this->fs->deleteExport($content['id'] . '.h5p');
|
$this->fs->deleteExport(H5PExport::buildExportFileName($content));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->exportEnabled) {
|
if ($this->exportEnabled) {
|
||||||
|
|
Loading…
Reference in New Issue