Merge branch 'master' of b.amendor.com:h5p
Conflicts: example_content/boardgame/H5P.Boardgame example_content/boardgame/H5P.MultiChoice example_content/boardgame/H5P.QuestionSet example_content/boardgame/h5p.json example_content/summary/h5p.json h5p.classes.inc h5p.install h5p.modulenamespaces
commit
9c934a752a
|
@ -102,10 +102,10 @@ interface H5PFrameworkInterface {
|
||||||
* @param int $contentMainId
|
* @param int $contentMainId
|
||||||
* Any contentMainId defined by the framework, for instance to support revisioning
|
* Any contentMainId defined by the framework, for instance to support revisioning
|
||||||
*/
|
*/
|
||||||
public function saveContentData($contentId, $contentJson, $mainJsonData, $contentMainId = NULL);
|
public function saveContentData($contentId, $contentJson, $mainJsonData, $mainLibraryId, $contentMainId = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies content data
|
* Copies library usage
|
||||||
*
|
*
|
||||||
* @param int $contentId
|
* @param int $contentId
|
||||||
* Framework specific id identifying the content
|
* Framework specific id identifying the content
|
||||||
|
@ -116,7 +116,7 @@ interface H5PFrameworkInterface {
|
||||||
* That supports versioning. (In this case the content id will typically be
|
* That supports versioning. (In this case the content id will typically be
|
||||||
* the version id, and the contentMainId will be the frameworks content id
|
* the version id, and the contentMainId will be the frameworks content id
|
||||||
*/
|
*/
|
||||||
public function copyContentData($contentId, $copyFromId, $contentMainId = NULL);
|
public function copyLibraryUsage($contentId, $copyFromId, $contentMainId = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes content data
|
* Deletes content data
|
||||||
|
@ -689,17 +689,30 @@ class H5PStorage {
|
||||||
$this->h5pC->delTree($destination_path);
|
$this->h5pC->delTree($destination_path);
|
||||||
rename($current_path, $destination_path);
|
rename($current_path, $destination_path);
|
||||||
}
|
}
|
||||||
|
foreach ($this->h5pC->librariesJsonData as $key => &$library) {
|
||||||
|
// All libraries have been saved, we now save all the dependencies
|
||||||
|
if (isset($library['preloadedDependencies'])) {
|
||||||
|
$this->h5pF->saveLibraryDependencies($library['libraryId'], $library['preloadedDependencies'], 'preloaded');
|
||||||
|
}
|
||||||
|
if (isset($library['dynamicDependencies'])) {
|
||||||
|
$this->h5pF->saveLibraryDependencies($library['libraryId'], $library['dynamicDependencies'], 'dynamic');
|
||||||
|
}
|
||||||
|
if (isset($library['editorDependencies'])) {
|
||||||
|
$this->h5pF->saveLibraryDependencies($library['libraryId'], $library['editorDependencies'], 'editor');
|
||||||
|
}
|
||||||
|
}
|
||||||
$current_path = $this->h5pF->getUploadedH5pFolderPath() . DIRECTORY_SEPARATOR . 'content';
|
$current_path = $this->h5pF->getUploadedH5pFolderPath() . DIRECTORY_SEPARATOR . 'content';
|
||||||
$destination_path = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . $contentId;
|
$destination_path = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . $contentId;
|
||||||
rename($current_path, $destination_path);
|
rename($current_path, $destination_path);
|
||||||
|
|
||||||
$contentJson = file_get_contents($destination_path . DIRECTORY_SEPARATOR . 'content.json');
|
|
||||||
$this->h5pF->saveContentData($contentId, $contentJson, $this->h5pC->mainJsonData, $contentMainId);
|
|
||||||
|
|
||||||
$librariesInUse = array();
|
$librariesInUse = array();
|
||||||
$this->getLibraryUsage($librariesInUse, $this->h5pC->mainJsonData);
|
$this->getLibraryUsage($librariesInUse, $this->h5pC->mainJsonData);
|
||||||
$this->h5pF->saveLibraryUsage($contentId, $librariesInUse);
|
$this->h5pF->saveLibraryUsage($contentId, $librariesInUse);
|
||||||
$this->h5pC->delTree($this->h5pF->getUploadedH5pFolderPath());
|
$this->h5pC->delTree($this->h5pF->getUploadedH5pFolderPath());
|
||||||
|
|
||||||
|
$contentJson = file_get_contents($destination_path . DIRECTORY_SEPARATOR . 'content.json');
|
||||||
|
$mainLibraryId = $librariesInUse[$this->h5pC->mainJsonData['mainLibrary']]['library']['libraryId'];
|
||||||
|
$this->h5pF->saveContentData($contentId, $contentJson, $this->h5pC->mainJsonData, $mainLibraryId, $contentMainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deletePackage($contentId) {
|
public function deletePackage($contentId) {
|
||||||
|
@ -717,7 +730,7 @@ class H5PStorage {
|
||||||
$destination_path = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . $contentId;
|
$destination_path = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR . 'content' . DIRECTORY_SEPARATOR . $contentId;
|
||||||
$this->h5pC->copyTree($source_path, $destination_path);
|
$this->h5pC->copyTree($source_path, $destination_path);
|
||||||
|
|
||||||
$this->h5pF->copyContentData($contentId, $copyFromId, $contentMainId);
|
$this->h5pF->copyLibraryUsage($contentId, $copyFromId, $contentMainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLibraryUsage(&$librariesInUse, $jsonData, $dynamic = FALSE) {
|
public function getLibraryUsage(&$librariesInUse, $jsonData, $dynamic = FALSE) {
|
||||||
|
|
21
js/h5p.js
21
js/h5p.js
|
@ -58,6 +58,27 @@ H5P.Coords = function(x, y, w, h) {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@param {string} library
|
||||||
|
* library in the format machineName majorVersion.minorVersion
|
||||||
|
* @returns
|
||||||
|
* library as an object with machineName, majorVersion and minorVersion properties
|
||||||
|
* return false if the library parameter is invalid
|
||||||
|
*/
|
||||||
|
H5P.libraryFromString = function (library) {
|
||||||
|
var regExp = /(.+)\s(\d)+\.(\d)$/g;
|
||||||
|
var res = regExp.exec(library);
|
||||||
|
if (res !== null) {
|
||||||
|
return {
|
||||||
|
'machineName': res[1],
|
||||||
|
'majorVersion': res[2],
|
||||||
|
'minorVersion': res[3]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
// Play a video. $target is jQuery object to attach video to. (Appended).
|
// Play a video. $target is jQuery object to attach video to. (Appended).
|
||||||
// Params are video-params from content. cp is content path. onEnded is
|
// Params are video-params from content. cp is content path. onEnded is
|
||||||
// function to call when finished.
|
// function to call when finished.
|
||||||
|
|
Loading…
Reference in New Issue