@@ -357,15 +357,14 @@ public function cloneContentFile($file, $fromId, $toId) {
357
357
* content from the current temporary upload folder to the editor path.
358
358
*
359
359
* @param string $source path to source directory
360
- * @param string $contentId Id of content
361
- *
362
- * @return object Object containing h5p json and content json data
360
+ * @param string $contentId Id of contentarray
363
361
*/
364
362
public function moveContentDirectory ($ source , $ contentId = NULL ) {
365
363
if ($ source === NULL ) {
366
364
return NULL ;
367
365
}
368
366
367
+ // TODO: Remove $contentId and never copy temporary files into content folder. JI-366
369
368
if ($ contentId === NULL || $ contentId == 0 ) {
370
369
$ target = $ this ->getEditorPath ();
371
370
}
@@ -385,14 +384,7 @@ public function moveContentDirectory($source, $contentId = NULL) {
385
384
}
386
385
}
387
386
388
- // Successfully loaded content json of file into editor
389
- $ h5pJson = $ this ->getContent ($ source . DIRECTORY_SEPARATOR . 'h5p.json ' );
390
- $ contentJson = $ this ->getContent ($ contentSource . DIRECTORY_SEPARATOR . 'content.json ' );
391
-
392
- return (object ) array (
393
- 'h5pJson ' => $ h5pJson ,
394
- 'contentJson ' => $ contentJson
395
- );
387
+ // TODO: Return list of all files so that they can be marked as temporary. JI-366
396
388
}
397
389
398
390
/**
@@ -476,6 +468,26 @@ public function getUpgradeScript($machineName, $majorVersion, $minorVersion) {
476
468
}
477
469
}
478
470
471
+ /**
472
+ * Store the given stream into the given file.
473
+ *
474
+ * @param string $path
475
+ * @param string $file
476
+ * @param resource $stream
477
+ * @return bool
478
+ */
479
+ public function saveFileFromZip ($ path , $ file , $ stream ) {
480
+ $ filePath = $ path . '/ ' . $ file ;
481
+
482
+ // Make sure the directory exists first
483
+ $ matches = array ();
484
+ preg_match ('/(.+)\/[^\/]*$/ ' , $ filePath , $ matches );
485
+ self ::dirReady ($ matches [1 ]);
486
+
487
+ // Store in local storage folder
488
+ return file_put_contents ($ filePath , $ stream );
489
+ }
490
+
479
491
/**
480
492
* Recursive function for copying directories.
481
493
*
0 commit comments