parent
7b38c3571e
commit
325ea27562
|
@ -257,6 +257,26 @@ class H5PDefaultStorage implements \H5PFileStorage {
|
||||||
return file_get_contents($this->path . $file_path);
|
return file_get_contents($this->path . $file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save files uploaded through the editor.
|
||||||
|
* The files must be marked as temporary until the content form is saved.
|
||||||
|
*
|
||||||
|
* @param \H5peditorFile $file
|
||||||
|
* @param int $contentid
|
||||||
|
*/
|
||||||
|
public function saveFile($file, $contentId) {
|
||||||
|
$path = $this->path . '/' . ($contentId === 0 ? 'editor' : 'content') . '/' . $file->getType() . 's/' . $file->getName();
|
||||||
|
self::dirReady($path);
|
||||||
|
|
||||||
|
$fileData = $file->getData();
|
||||||
|
if ($fileData) {
|
||||||
|
file_put_contents($path, $fileData);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
copy($_FILES['file']['tmp_name'], $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursive function for copying directories.
|
* Recursive function for copying directories.
|
||||||
*
|
*
|
||||||
|
|
|
@ -125,4 +125,13 @@ interface H5PFileStorage {
|
||||||
* @return string contents
|
* @return string contents
|
||||||
*/
|
*/
|
||||||
public function getContent($file_path);
|
public function getContent($file_path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save files uploaded through the editor.
|
||||||
|
* The files must be marked as temporary until the content form is saved.
|
||||||
|
*
|
||||||
|
* @param \H5peditorFile $file
|
||||||
|
* @param int $contentid
|
||||||
|
*/
|
||||||
|
public function saveFile($file, $contentId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue