private function findLibraries($path) {
    $this->libraries = array();

    if (is_dir($path) === FALSE) {
      return;
    }

    $contents = scandir($path);

    for ($i = 0, $s = count($contents); $i < $s; $i++) {
      if ($contents[$i]{0} === '.') {
        continue; // Skip hidden stuff.
      }

      $libraryPath = $path . '/' . $contents[$i];
      $libraryJSON = $this->getFileContents($libraryPath . '/library.json');
      if ($libraryJSON === NULL) {
        continue; // No JSON file, skip.
      }

      $library = json_decode($libraryJSON, TRUE);
      if ($library === NULL) {
        continue; // Invalid JSON.
      }

      // TODO: Validate props? Not really needed, is it? this is a dev site.

      $library['libraryId'] = $this->h5pF->getLibraryId($library['machineName'], $library['majorVersion'], $library['minorVersion']);

      // Convert metadataSettings values to boolean & json_encode it before saving
      $library['metadataSettings'] = isset($library['metadataSettings']) ?
        H5PMetadata::boolifyAndEncodeSettings($library['metadataSettings']) :
        NULL;

      // Save/update library.
      $this->h5pF->saveLibraryData($library, $library['libraryId'] === FALSE);

      // Need to decode it again, since it is served from here.
      $library['metadataSettings'] = json_decode($library['metadataSettings']);

      $library['path'] = 'development/' . $contents[$i];
      $this->libraries[H5PDevelopment::libraryToString($library['machineName'], $library['majorVersion'], $library['minorVersion'])] = $library;
    }

    // TODO: Should we remove libraries without files? Not really needed, but must be cleaned up some time, right?

    // Go trough libraries and insert dependencies. Missing deps. will just be ignored and not available. (I guess?!)
    $this->h5pF->lockDependencyStorage();
    foreach ($this->libraries as $library) {
      $this->h5pF->deleteLibraryDependencies($library['libraryId']);
      // This isn't optimal, but without it we would get duplicate warnings.
      // TODO: You might get PDOExceptions if two or more requests does this at the same time!!
      $types = array('preloaded', 'dynamic', 'editor');
      foreach ($types as $type) {
        if (isset($library[$type . 'Dependencies'])) {
          $this->h5pF->saveLibraryDependencies($library['libraryId'], $library[$type . 'Dependencies'], $type);
        }
      }
    }
    $this->h5pF->unlockDependencyStorage();
    // TODO: Deps must be inserted into h5p_nodes_libraries as well... ? But only if they are used?!
  }
private function findLibraries($path) {
    $this->libraries = array();

    if (is_dir($path) === FALSE) {
      return;
    }

    $contents = scandir($path);

    for ($i = 0, $s = count($contents); $i < $s; $i++) {
      if ($contents[$i]{0} === '.') {
        continue; // Skip hidden stuff.
      }

      $libraryPath = $path . '/' . $contents[$i];
      $libraryJSON = $this->getFileContents($libraryPath . '/library.json');
      if ($libraryJSON === NULL) {
        continue; // No JSON file, skip.
      }

      $library = json_decode($libraryJSON, TRUE);
      if ($library === NULL) {
        continue; // Invalid JSON.
      }

      // TODO: Validate props? Not really needed, is it? this is a dev site.

      $library['libraryId'] = $this->h5pF->getLibraryId($library['machineName'], $library['majorVersion'], $library['minorVersion']);

      // Convert metadataSettings values to boolean & json_encode it before saving
      $library['metadataSettings'] = isset($library['metadataSettings']) ?
        H5PMetadata::boolifyAndEncodeSettings($library['metadataSettings']) :
        NULL;

      // Save/update library.
      $this->h5pF->saveLibraryData($library, $library['libraryId'] === FALSE);

      // Need to decode it again, since it is served from here.
      $library['metadataSettings'] = json_decode($library['metadataSettings']);

      $library['path'] = 'development/' . $contents[$i];
      $this->libraries[H5PDevelopment::libraryToString($library['machineName'], $library['majorVersion'], $library['minorVersion'])] = $library;
    }

    // TODO: Should we remove libraries without files? Not really needed, but must be cleaned up some time, right?

    // Go trough libraries and insert dependencies. Missing deps. will just be ignored and not available. (I guess?!)
    $this->h5pF->lockDependencyStorage();
    foreach ($this->libraries as $library) {
      $this->h5pF->deleteLibraryDependencies($library['libraryId']);
      // This isn't optimal, but without it we would get duplicate warnings.
      // TODO: You might get PDOExceptions if two or more requests does this at the same time!!
      $types = array('preloaded', 'dynamic', 'editor');
      foreach ($types as $type) {
        if (isset($library[$type . 'Dependencies'])) {
          $this->h5pF->saveLibraryDependencies($library['libraryId'], $library[$type . 'Dependencies'], $type);
        }
      }
    }
    $this->h5pF->unlockDependencyStorage();
    // TODO: Deps must be inserted into h5p_nodes_libraries as well... ? But only if they are used?!
  }
private function findLibraries ( $ path ) { $ this -> libraries = array ( ) ; if ( is_dir ( $ path ) === FALSE ) { return ; } $ contents = scandir ( $ path ) ; for ( $ i = 0 , $ s = count ( $ contents ) ; $ i < $ s ; $ i ++ ) { if ( $ contents [ $ i ] { 0 } === '.' ) { continue ; // Skip hidden stuff. } $ libraryPath = $ path . '/' . $ contents [ $ i ] ; $ libraryJSON = $ this -> getFileContents ( $ libraryPath . '/library.json' ) ; if ( $ libraryJSON === NULL ) { continue ; // No JSON file, skip. } $ library = json_decode ( $ libraryJSON , TRUE ) ; if ( $ library === NULL ) { continue ; // Invalid JSON. } // TODO: Validate props? Not really needed, is it? this is a dev site. $ library [ 'libraryId' ] = $ this -> h5pF -> getLibraryId ( $ library [ 'machineName' ] , $ library [ 'majorVersion' ] , $ library [ 'minorVersion' ] ) ; // Convert metadataSettings values to boolean & json_encode it before saving $ library [ 'metadataSettings' ] = isset ( $ library [ 'metadataSettings' ] ) ? H5PMetadata :: boolifyAndEncodeSettings ( $ library [ 'metadataSettings' ] ) : NULL ; // Save/update library. $ this -> h5pF -> saveLibraryData ( $ library , $ library [ 'libraryId' ] === FALSE ) ; // Need to decode it again, since it is served from here. $ library [ 'metadataSettings' ] = json_decode ( $ library [ 'metadataSettings' ] ) ; $ library [ 'path' ] = 'development/' . $ contents [ $ i ] ; $ this -> libraries [ H5PDevelopment :: libraryToString ( $ library [ 'machineName' ] , $ library [ 'majorVersion' ] , $ library [ 'minorVersion' ] ) ] = $ library ; } // TODO: Should we remove libraries without files? Not really needed, but must be cleaned up some time, right? // Go trough libraries and insert dependencies. Missing deps. will just be ignored and not available. (I guess?!) $ this -> h5pF -> lockDependencyStorage ( ) ; foreach ( $ this -> libraries as $ library ) { $ this -> h5pF -> deleteLibraryDependencies ( $ library [ 'libraryId' ] ) ; // This isn't optimal, but without it we would get duplicate warnings. // TODO: You might get PDOExceptions if two or more requests does this at the same time!! $ types = array ( 'preloaded' , 'dynamic' , 'editor' ) ; foreach ( $ types as $ type ) { if ( isset ( $ library [ $ type . 'Dependencies' ] ) ) { $ this -> h5pF -> saveLibraryDependencies ( $ library [ 'libraryId' ] , $ library [ $ type . 'Dependencies' ] , $ type ) ; } } } $ this -> h5pF -> unlockDependencyStorage ( ) ; // TODO: Deps must be inserted into h5p_nodes_libraries as well... ? But only if they are used?! }
Scans development directory and find all libraries.

@param string $path Libraries development folder
Scans development directory and find all libraries .