Use content array instead of just id
Makes it easier when additional properties are needed. Also, don't try to translate PHP exception messages. h5p/h5p-moodle-plugin#112JI-92-path-fix
parent
c88c049438
commit
fd34af6964
|
@ -53,11 +53,11 @@ class H5PDefaultStorage implements \H5PFileStorage {
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* Path on file system to content directory.
|
* Path on file system to content directory.
|
||||||
* @param int $id
|
* @param array $content
|
||||||
* What makes this content unique.
|
* Content properties
|
||||||
*/
|
*/
|
||||||
public function saveContent($source, $id) {
|
public function saveContent($source, $content) {
|
||||||
$dest = "{$this->path}/content/{$id}";
|
$dest = "{$this->path}/content/{$content['id']}";
|
||||||
|
|
||||||
// Remove any old content
|
// Remove any old content
|
||||||
\H5PCore::deleteFileTree($dest);
|
\H5PCore::deleteFileTree($dest);
|
||||||
|
@ -68,11 +68,11 @@ class H5PDefaultStorage implements \H5PFileStorage {
|
||||||
/**
|
/**
|
||||||
* Remove content folder.
|
* Remove content folder.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param array $content
|
||||||
* Content identifier
|
* Content properties
|
||||||
*/
|
*/
|
||||||
public function deleteContent($id) {
|
public function deleteContent($content) {
|
||||||
\H5PCore::deleteFileTree("{$this->path}/content/{$id}");
|
\H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,18 +22,18 @@ interface H5PFileStorage {
|
||||||
*
|
*
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* Path on file system to content directory.
|
* Path on file system to content directory.
|
||||||
* @param int $id
|
* @param array $content
|
||||||
* What makes this content unique.
|
* Content properties
|
||||||
*/
|
*/
|
||||||
public function saveContent($source, $id);
|
public function saveContent($source, $content);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove content folder.
|
* Remove content folder.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param array $content
|
||||||
* Content identifier
|
* Content properties
|
||||||
*/
|
*/
|
||||||
public function deleteContent($id);
|
public function deleteContent($content);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a stored copy of the content folder.
|
* Creates a stored copy of the content folder.
|
||||||
|
|
|
@ -1311,15 +1311,15 @@ class H5PStorage {
|
||||||
if (isset($options['disable'])) {
|
if (isset($options['disable'])) {
|
||||||
$content['disable'] = $options['disable'];
|
$content['disable'] = $options['disable'];
|
||||||
}
|
}
|
||||||
$contentId = $this->h5pC->saveContent($content, $contentMainId);
|
$content['id'] = $this->h5pC->saveContent($content, $contentMainId);
|
||||||
$this->contentId = $contentId;
|
$this->contentId = $content['id'];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Save content folder contents
|
// Save content folder contents
|
||||||
$this->h5pC->fs->saveContent($current_path, $contentId);
|
$this->h5pC->fs->saveContent($current_path, $content);
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
$this->h5pF->setErrorMessage($this->h5pF->t($e->getMessage()));
|
$this->h5pF->setErrorMessage($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove temp content folder
|
// Remove temp content folder
|
||||||
|
@ -1433,7 +1433,7 @@ class H5PStorage {
|
||||||
* @param $content
|
* @param $content
|
||||||
*/
|
*/
|
||||||
public function deletePackage($content) {
|
public function deletePackage($content) {
|
||||||
$this->h5pC->fs->deleteContent($content['id']);
|
$this->h5pC->fs->deleteContent($content);
|
||||||
$this->h5pC->fs->deleteExport(($content['slug'] ? $content['slug'] . '-' : '') . $content['id'] . '.h5p');
|
$this->h5pC->fs->deleteExport(($content['slug'] ? $content['slug'] . '-' : '') . $content['id'] . '.h5p');
|
||||||
$this->h5pF->deleteContentData($content['id']);
|
$this->h5pF->deleteContentData($content['id']);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue