Formatting code + adding comments.
pull/50/head
Thomas Horn Sivertsen 2018-01-19 14:56:07 +01:00
parent 1b079d36f1
commit 04edd73855
2 changed files with 21 additions and 16 deletions

View File

@ -451,15 +451,20 @@ class H5PDefaultStorage implements \H5PFileStorage {
return self::dirReady($this->path); return self::dirReady($this->path);
} }
/**
* Check if the file presave.js exists in the root of the library
*
* @param string $name
* @return bool
*/
public function hasPresave($name) { public function hasPresave($name) {
$filePath = implode(DIRECTORY_SEPARATOR, [ $filePath = implode(DIRECTORY_SEPARATOR, [
$this->path, $this->path,
'libraries', 'libraries',
$name, $name,
'presave.js', 'presave.js',
]); ]);
return file_exists($filePath);
return file_exists($filePath);
} }
/** /**

View File

@ -2119,7 +2119,7 @@ class H5PCore {
$this->getDependencyAssets($dependency, 'preloadedJs', $files['scripts'], $prefix); $this->getDependencyAssets($dependency, 'preloadedJs', $files['scripts'], $prefix);
$this->getDependencyAssets($dependency, 'preloadedCss', $files['styles'], $prefix); $this->getDependencyAssets($dependency, 'preloadedCss', $files['styles'], $prefix);
if( $this->fs->hasPresave($libraryName) ){ if( $this->fs->hasPresave($libraryName) ){
$this->addPresaveFile($files, $dependency, $prefix); $this->addPresaveFile($files, $dependency, $prefix);
} }
} }
@ -2134,13 +2134,13 @@ class H5PCore {
return $files; return $files;
} }
public function addPresaveFile(&$assets, $library, $prefix = ''){ public function addPresaveFile(&$assets, $library, $prefix = ''){
$this->getDependencyAssets([ $this->getDependencyAssets([
'path' => 'libraries' . DIRECTORY_SEPARATOR . self::libraryToString($library, true), 'path' => 'libraries' . DIRECTORY_SEPARATOR . self::libraryToString($library, true),
'version' => array_key_exists('version', $library) ? $library['version'] : "?ver={$library['majorVersion']}.{$library['minorVersion']}.{$library['patchVersion']}", 'version' => array_key_exists('version', $library) ? $library['version'] : "?ver={$library['majorVersion']}.{$library['minorVersion']}.{$library['patchVersion']}",
'presaveJs' => ['presave.js'] 'presaveJs' => ['presave.js']
], 'presaveJs', $assets['scripts'], $prefix); ], 'presaveJs', $assets['scripts'], $prefix);
} }
private static function getDependenciesHash(&$dependencies) { private static function getDependenciesHash(&$dependencies) {
// Build hash of dependencies // Build hash of dependencies