diff --git a/.gitignore b/.gitignore index b25c15b..9577d19 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +vendor *~ + diff --git a/composer.json b/composer.json index 5f423f9..fac6c53 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,34 @@ { - "name": "h5p/h5p-php-library", + "name": "h5p/h5p-core", + "type": "library", + "description": "H5P Core functionality in PHP", + "keywords": ["h5p","hvp","interactive","content","quiz"], + "homepage": "https://h5p.org", "license": "GPL-3.0", + "authors": [ + { + "name": "Svein-Tore Griff With", + "email": "with@joubel.com", + "homepage": "http://joubel.com", + "role": "CEO" + }, + { + "name": "Frode Petterson", + "email": "frode.petterson@joubel.com", + "homepage": "http://joubel.com", + "role": "Developer" + } + ], + "require": { + "php": ">=5.3.0" + }, "autoload": { "files": [ - "h5p-development.class.php", - "h5p.classes.php" + "h5p.classes.php", + "h5p-development.class.php", + "h5p-file-storage.interface.php", + "h5p-default-storage.class.php", + "h5p-event-base.class.php" ] } -} \ No newline at end of file +} diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index 88a4776..25ae287 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -132,11 +132,18 @@ class H5PDefaultStorage implements \H5PFileStorage { * Path on file system to temporary export file. * @param string $filename * Name of export file. + * @throws Exception Unable to save the file */ public function saveExport($source, $filename) { $this->deleteExport($filename); - self::dirReady("{$this->path}/exports"); - copy($source, "{$this->path}/exports/{$filename}"); + + if (!self::dirReady("{$this->path}/exports")) { + throw new Exception("Unable to create directory for H5P export file."); + } + + if (!copy($source, "{$this->path}/exports/{$filename}")) { + throw new Exception("Unable to save H5P export file."); + } } /** diff --git a/h5p.classes.php b/h5p.classes.php index c1892cd..4d7223b 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -553,6 +553,11 @@ interface H5PFrameworkInterface { * return int */ public function getLibraryContentCount(); + + /** + * Will trigger after the export file is created. + */ + public function afterExportCreated(); } /** @@ -1595,9 +1600,11 @@ Class H5PExport { } catch (Exception $e) { $this->h5pF->setErrorMessage($this->h5pF->t($e->getMessage())); + return false; } unlink($tmpFile); + $this->h5pF->afterExportCreated(); return true; } @@ -1669,7 +1676,7 @@ class H5PCore { public static $coreApi = array( 'majorVersion' => 1, - 'minorVersion' => 9 + 'minorVersion' => 10 ); public static $styles = array( 'styles/h5p.css',