Changed savePackage so it's easier to send along extra content data.

namespaces
Frode Petterson 2014-05-06 16:52:43 +02:00
parent 700fc1c67b
commit 34d65b9601
1 changed files with 12 additions and 6 deletions

View File

@ -134,7 +134,7 @@ interface H5PFrameworkInterface {
* @param int $contentId * @param int $contentId
* Framework specific id identifying the content * Framework specific id identifying the content
*/ */
public function saveContentData($contentJson, $mainJsonData, $mainLibraryId, $contentMainId = NULL, $contentId = NULL); public function saveContentData($content, $contentMainId = NULL);
/** /**
* Save what libraries a library is dependending on * Save what libraries a library is dependending on
@ -973,7 +973,7 @@ class H5PStorage {
* TRUE if one or more libraries were updated * TRUE if one or more libraries were updated
* FALSE otherwise * FALSE otherwise
*/ */
public function savePackage($contentId = NULL, $contentMainId = NULL, $skipContent = FALSE) { public function savePackage($content = NULL, $contentMainId = NULL, $skipContent = FALSE) {
// Save the libraries we processed during validation // Save the libraries we processed during validation
$library_saved = FALSE; $library_saved = FALSE;
$mayUpdateLibraries = $this->h5pF->mayUpdateLibraries(); $mayUpdateLibraries = $this->h5pF->mayUpdateLibraries();
@ -1035,10 +1035,16 @@ class H5PStorage {
$librariesInUse = array(); $librariesInUse = array();
$this->h5pC->findLibraryDependencies($librariesInUse, $this->h5pC->mainJsonData); $this->h5pC->findLibraryDependencies($librariesInUse, $this->h5pC->mainJsonData);
// Save the data in content.json // Save content
$contentJson = file_get_contents($current_path . DIRECTORY_SEPARATOR . 'content.json'); if ($content === NULL) {
$mainLibraryId = $librariesInUse['preloaded-' . $this->h5pC->mainJsonData['mainLibrary']]['library']['libraryId']; $content = array();
$contentId = $this->h5pF->saveContentData($contentJson, $this->h5pC->mainJsonData, $mainLibraryId, $contentMainId, $contentId); }
if (!is_array($content)) {
$content = array('id' => $content);
}
$content['library'] = $librariesInUse['preloaded-' . $this->h5pC->mainJsonData['mainLibrary']]['library'];
$content['params'] = file_get_contents($current_path . DIRECTORY_SEPARATOR . 'content.json');
$contentId = $this->h5pF->saveContentData($content, $contentMainId);
$this->contentId = $contentId; $this->contentId = $contentId;
$contents_path = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR . 'content'; $contents_path = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR . 'content';