From a59640672dc5ff0030bc688eaacfa8a544ed9f72 Mon Sep 17 00:00:00 2001 From: Thomas Horn Sivertsen Date: Thu, 7 Jun 2018 12:43:12 +0200 Subject: [PATCH] HFP-1806 - fixed PhpDoc - only load presave.js when editing a H5P - moved loading logic from core to editor - removed unused code --- h5p-default-storage.class.php | 3 ++- h5p-file-storage.interface.php | 4 +++- h5p.classes.php | 23 ----------------------- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index 9766e47..d6d13ea 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -454,7 +454,8 @@ class H5PDefaultStorage implements \H5PFileStorage { /** * Check if the file presave.js exists in the root of the library * - * @param string $name + * @param string $libraryFolder + * @param string $developmentPath * @return bool */ public function hasPresave($libraryFolder, $developmentPath = null) { diff --git a/h5p-file-storage.interface.php b/h5p-file-storage.interface.php index 976605e..4dbdbc6 100644 --- a/h5p-file-storage.interface.php +++ b/h5p-file-storage.interface.php @@ -194,7 +194,9 @@ interface H5PFileStorage { /** * 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); } diff --git a/h5p.classes.php b/h5p.classes.php index efac783..650895c 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2118,9 +2118,6 @@ class H5PCore { $dependency['version'] = "?ver={$dependency['majorVersion']}.{$dependency['minorVersion']}.{$dependency['patchVersion']}"; $this->getDependencyAssets($dependency, 'preloadedJs', $files['scripts'], $prefix); $this->getDependencyAssets($dependency, 'preloadedCss', $files['styles'], $prefix); - if( $this->hasPresave($libraryName) ){ - $this->addPresaveFile($files, $dependency, $prefix); - } } if ($this->aggregateAssets) { @@ -2134,26 +2131,6 @@ class H5PCore { 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) { // Build hash of dependencies $toHash = array();