From 04edd738552cc4ee0391824459eb4ced16e54351 Mon Sep 17 00:00:00 2001 From: Thomas Horn Sivertsen Date: Fri, 19 Jan 2018 14:56:07 +0100 Subject: [PATCH] HFP-1806 Formatting code + adding comments. --- h5p-default-storage.class.php | 21 +++++++++++++-------- h5p.classes.php | 16 ++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index ba41eb9..a06c47c 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -451,15 +451,20 @@ class H5PDefaultStorage implements \H5PFileStorage { 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) { - $filePath = implode(DIRECTORY_SEPARATOR, [ - $this->path, - 'libraries', - $name, - 'presave.js', - ]); - - return file_exists($filePath); + $filePath = implode(DIRECTORY_SEPARATOR, [ + $this->path, + 'libraries', + $name, + 'presave.js', + ]); + return file_exists($filePath); } /** diff --git a/h5p.classes.php b/h5p.classes.php index a978516..80399d9 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2119,7 +2119,7 @@ class H5PCore { $this->getDependencyAssets($dependency, 'preloadedJs', $files['scripts'], $prefix); $this->getDependencyAssets($dependency, 'preloadedCss', $files['styles'], $prefix); if( $this->fs->hasPresave($libraryName) ){ - $this->addPresaveFile($files, $dependency, $prefix); + $this->addPresaveFile($files, $dependency, $prefix); } } @@ -2134,13 +2134,13 @@ class H5PCore { return $files; } - public function addPresaveFile(&$assets, $library, $prefix = ''){ - $this->getDependencyAssets([ - '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); - } + public function addPresaveFile(&$assets, $library, $prefix = ''){ + $this->getDependencyAssets([ + '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