public function savePackage($content = NULL, $contentMainId = NULL, $skipContent = FALSE, $options = array()) {
    if ($this->h5pC->mayUpdateLibraries()) {
      // Save the libraries we processed during validation
      $this->saveLibraries();
    }

    if (!$skipContent) {
      $basePath = $this->h5pF->getUploadedH5pFolderPath();
      $current_path = $basePath . DIRECTORY_SEPARATOR . 'content';

      // Save content
      if ($content === NULL) {
        $content = array();
      }
      if (!is_array($content)) {
        $content = array('id' => $content);
      }

      // Find main library version
      foreach ($this->h5pC->mainJsonData['preloadedDependencies'] as $dep) {
        if ($dep['machineName'] === $this->h5pC->mainJsonData['mainLibrary']) {
          $dep['libraryId'] = $this->h5pC->getLibraryId($dep);
          $content['library'] = $dep;
          break;
        }
      }

      $content['params'] = file_get_contents($current_path . DIRECTORY_SEPARATOR . 'content.json');

      if (isset($options['disable'])) {
        $content['disable'] = $options['disable'];
      }
      $content['id'] = $this->h5pC->saveContent($content, $contentMainId);
      $this->contentId = $content['id'];

      try {
        // Save content folder contents
        $this->h5pC->fs->saveContent($current_path, $content);
      }
      catch (Exception $e) {
        $this->h5pF->setErrorMessage($e->getMessage(), 'save-content-failed');
      }

      // Remove temp content folder
      H5PCore::deleteFileTree($basePath);
    }
  }
public function savePackage($content = NULL, $contentMainId = NULL, $skipContent = FALSE, $options = array()) {
    if ($this->h5pC->mayUpdateLibraries()) {
      // Save the libraries we processed during validation
      $this->saveLibraries();
    }

    if (!$skipContent) {
      $basePath = $this->h5pF->getUploadedH5pFolderPath();
      $current_path = $basePath . DIRECTORY_SEPARATOR . 'content';

      // Save content
      if ($content === NULL) {
        $content = array();
      }
      if (!is_array($content)) {
        $content = array('id' => $content);
      }

      // Find main library version
      foreach ($this->h5pC->mainJsonData['preloadedDependencies'] as $dep) {
        if ($dep['machineName'] === $this->h5pC->mainJsonData['mainLibrary']) {
          $dep['libraryId'] = $this->h5pC->getLibraryId($dep);
          $content['library'] = $dep;
          break;
        }
      }

      $content['params'] = file_get_contents($current_path . DIRECTORY_SEPARATOR . 'content.json');

      if (isset($options['disable'])) {
        $content['disable'] = $options['disable'];
      }
      $content['id'] = $this->h5pC->saveContent($content, $contentMainId);
      $this->contentId = $content['id'];

      try {
        // Save content folder contents
        $this->h5pC->fs->saveContent($current_path, $content);
      }
      catch (Exception $e) {
        $this->h5pF->setErrorMessage($e->getMessage(), 'save-content-failed');
      }

      // Remove temp content folder
      H5PCore::deleteFileTree($basePath);
    }
  }
public function savePackage ( $ content = NULL , $ contentMainId = NULL , $ skipContent = FALSE , $ options = array ( ) ) { if ( $ this -> h5pC -> mayUpdateLibraries ( ) ) { // Save the libraries we processed during validation $ this -> saveLibraries ( ) ; } if ( ! $ skipContent ) { $ basePath = $ this -> h5pF -> getUploadedH5pFolderPath ( ) ; $ current_path = $ basePath . DIRECTORY_SEPARATOR . 'content' ; // Save content if ( $ content === NULL ) { $ content = array ( ) ; } if ( ! is_array ( $ content ) ) { $ content = array ( 'id' => $ content ) ; } // Find main library version foreach ( $ this -> h5pC -> mainJsonData [ 'preloadedDependencies' ] as $ dep ) { if ( $ dep [ 'machineName' ] === $ this -> h5pC -> mainJsonData [ 'mainLibrary' ] ) { $ dep [ 'libraryId' ] = $ this -> h5pC -> getLibraryId ( $ dep ) ; $ content [ 'library' ] = $ dep ; break ; } } $ content [ 'params' ] = file_get_contents ( $ current_path . DIRECTORY_SEPARATOR . 'content.json' ) ; if ( isset ( $ options [ 'disable' ] ) ) { $ content [ 'disable' ] = $ options [ 'disable' ] ; } $ content [ 'id' ] = $ this -> h5pC -> saveContent ( $ content , $ contentMainId ) ; $ this -> contentId = $ content [ 'id' ] ; try { // Save content folder contents $ this -> h5pC -> fs -> saveContent ( $ current_path , $ content ) ; } catch ( Exception $ e ) { $ this -> h5pF -> setErrorMessage ( $ e -> getMessage ( ) , 'save-content-failed' ) ; } // Remove temp content folder H5PCore :: deleteFileTree ( $ basePath ) ; } }
Saves a H5P file

@param null $content
@param int $contentMainId
The main id for the content we are saving. This is used if the framework
we're integrating with uses content id's and version id's
@param bool $skipContent
@param array $options
@return bool TRUE if one or more libraries were updated
TRUE if one or more libraries were updated
FALSE otherwise
Saves a H5P file