diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index 38af307..26e3e01 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -451,6 +451,19 @@ class H5PDefaultStorage implements \H5PFileStorage { return self::dirReady($this->path); } + /** + * Check if the file presave.js exists in the root of the library + * + * @param string $libraryFolder + * @param string $developmentPath + * @return bool + */ + public function hasPresave($libraryFolder, $developmentPath = null) { + $path = is_null($developmentPath) ? 'libraries' . DIRECTORY_SEPARATOR . $libraryFolder : $developmentPath; + $filePath = realpath($this->path . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . 'presave.js'); + return file_exists($filePath); + } + /** * Recursive function for copying directories. * diff --git a/h5p-file-storage.interface.php b/h5p-file-storage.interface.php index 394210b..4dbdbc6 100644 --- a/h5p-file-storage.interface.php +++ b/h5p-file-storage.interface.php @@ -190,4 +190,13 @@ interface H5PFileStorage { * @return bool True if server has the proper write access */ public function hasWriteAccess(); + + /** + * Check if the library has a presave.js in the root folder + * + * @param string $libraryName + * @param string $developmentPath + * @return bool + */ + public function hasPresave($libraryName, $developmentPath = null); }