- fixed PhpDoc
- only load presave.js when editing a H5P
- moved loading logic from core to editor
- removed unused code
pull/50/head
Thomas Horn Sivertsen 2018-06-07 12:43:12 +02:00
parent 615bac7c08
commit a59640672d
3 changed files with 5 additions and 25 deletions

View File

@ -454,7 +454,8 @@ class H5PDefaultStorage implements \H5PFileStorage {
/** /**
* Check if the file presave.js exists in the root of the library * Check if the file presave.js exists in the root of the library
* *
* @param string $name * @param string $libraryFolder
* @param string $developmentPath
* @return bool * @return bool
*/ */
public function hasPresave($libraryFolder, $developmentPath = null) { public function hasPresave($libraryFolder, $developmentPath = null) {

View File

@ -194,7 +194,9 @@ interface H5PFileStorage {
/** /**
* Check if the library has a presave.js in the root folder * Check if the library has a presave.js in the root folder
* *
* @return string|null Path if presave.js found * @param string $libraryName
* @param string $developmentPath
* @return bool
*/ */
public function hasPresave($libraryName, $developmentPath = null); public function hasPresave($libraryName, $developmentPath = null);
} }

View File

@ -2118,9 +2118,6 @@ class H5PCore {
$dependency['version'] = "?ver={$dependency['majorVersion']}.{$dependency['minorVersion']}.{$dependency['patchVersion']}"; $dependency['version'] = "?ver={$dependency['majorVersion']}.{$dependency['minorVersion']}.{$dependency['patchVersion']}";
$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->hasPresave($libraryName) ){
$this->addPresaveFile($files, $dependency, $prefix);
}
} }
if ($this->aggregateAssets) { if ($this->aggregateAssets) {
@ -2134,26 +2131,6 @@ class H5PCore {
return $files; return $files;
} }
public function hasPresave($libraryName)
{
if( isset($this->h5pD) ){
extract(H5PCore::libraryFromString($libraryName));
$library = $this->h5pD->getLibrary($machineName, $majorVersion, $minorVersion);
if( !is_null($library)){
return $this->fs->hasPresave($libraryName, $library['path']);
}
}
return $this->fs->hasPresave($libraryName);
}
public function addPresaveFile(&$assets, $library, $prefix = ''){
$this->getDependencyAssets([
'path' => array_key_exists('path', $library) ? $library['path'] : 'libraries' . DIRECTORY_SEPARATOR . self::libraryToString($library, true),
'version' => array_key_exists('version', $library) ? $library['version'] : "?ver={$library['majorVersion']}.{$library['minorVersion']}.{$library['patchVersion']}",
'presaveJs' => ['presave.js']
], 'presaveJs', $assets['scripts'], $prefix);
}
private static function getDependenciesHash(&$dependencies) { private static function getDependenciesHash(&$dependencies) {
// Build hash of dependencies // Build hash of dependencies
$toHash = array(); $toHash = array();