Merge branch 'master' of github.com:h5p/h5p-php-library
commit
cb2acb21c8
|
@ -84,11 +84,14 @@ class H5PDevelopment {
|
||||||
|
|
||||||
// TODO: Validate props? Not really needed, is it? this is a dev site.
|
// TODO: Validate props? Not really needed, is it? this is a dev site.
|
||||||
|
|
||||||
// Save/update library.
|
|
||||||
$library['libraryId'] = $this->h5pF->getLibraryId($library['machineName'], $library['majorVersion'], $library['minorVersion']);
|
$library['libraryId'] = $this->h5pF->getLibraryId($library['machineName'], $library['majorVersion'], $library['minorVersion']);
|
||||||
if (!isset($library['metadata'])) {
|
|
||||||
$library['metadata'] = 1;
|
// Convert metadataSettings values to boolean & json_encode it before saving
|
||||||
}
|
$library['metadataSettings'] = isset($library['metadataSettings']) ?
|
||||||
|
H5PMetadata::boolifyAndEncodeSettings($library['metadataSettings']) :
|
||||||
|
NULL;
|
||||||
|
|
||||||
|
// Save/update library.
|
||||||
$this->h5pF->saveLibraryData($library, $library['libraryId'] === FALSE);
|
$this->h5pF->saveLibraryData($library, $library['libraryId'] === FALSE);
|
||||||
|
|
||||||
$library['path'] = 'development/' . $contents[$i];
|
$library['path'] = 'development/' . $contents[$i];
|
||||||
|
|
|
@ -114,4 +114,24 @@ abstract class H5PMetadata {
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metadataSettings field in libraryJson uses 1 for true and 0 for false.
|
||||||
|
* Here we are converting these to booleans, and also doing JSON encoding.
|
||||||
|
* This is invoked before the library data is beeing inserted/updated to DB.
|
||||||
|
*
|
||||||
|
* @param array $metadataSettings
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function boolifyAndEncodeSettings($metadataSettings) {
|
||||||
|
// Convert metadataSettings values to boolean
|
||||||
|
if (isset($metadataSettings['disable'])) {
|
||||||
|
$metadataSettings['disable'] = $metadataSettings['disable'] === 1;
|
||||||
|
}
|
||||||
|
if (isset($metadataSettings['disable'])) {
|
||||||
|
$metadataSettings['disableExtraTitleField'] = $metadataSettings['disableExtraTitleField'] === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($metadataSettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,9 @@ interface H5PFrameworkInterface {
|
||||||
* - minorVersion: The library's minorVersion
|
* - minorVersion: The library's minorVersion
|
||||||
* - patchVersion: The library's patchVersion
|
* - patchVersion: The library's patchVersion
|
||||||
* - runnable: 1 if the library is a content type, 0 otherwise
|
* - runnable: 1 if the library is a content type, 0 otherwise
|
||||||
* - metadata: 1 if the library should support setting metadata (copyright etc)
|
* - metadataSettings: Associative array containing:
|
||||||
|
* - disable: 1 if the library should not support setting metadata (copyright etc)
|
||||||
|
* - disableExtraTitleField: 1 if the library don't need the extra title field
|
||||||
* - fullscreen(optional): 1 if the library supports fullscreen, 0 otherwise
|
* - fullscreen(optional): 1 if the library supports fullscreen, 0 otherwise
|
||||||
* - embedTypes(optional): list of supported embed types
|
* - embedTypes(optional): list of supported embed types
|
||||||
* - preloadedJs(optional): list of associative arrays containing:
|
* - preloadedJs(optional): list of associative arrays containing:
|
||||||
|
@ -681,7 +683,10 @@ class H5PValidator {
|
||||||
'author' => '/^.{1,255}$/',
|
'author' => '/^.{1,255}$/',
|
||||||
'license' => '/^(cc-by|cc-by-sa|cc-by-nd|cc-by-nc|cc-by-nc-sa|cc-by-nc-nd|pd|cr|MIT|GPL1|GPL2|GPL3|MPL|MPL2)$/',
|
'license' => '/^(cc-by|cc-by-sa|cc-by-nd|cc-by-nc|cc-by-nc-sa|cc-by-nc-nd|pd|cr|MIT|GPL1|GPL2|GPL3|MPL|MPL2)$/',
|
||||||
'description' => '/^.{1,}$/',
|
'description' => '/^.{1,}$/',
|
||||||
'metadata' => '/^(0|1)$/',
|
'metadataSettings' => array(
|
||||||
|
'disable' => '/^(0|1)$/',
|
||||||
|
'disableExtraTitleField' => '/^(0|1)$/'
|
||||||
|
),
|
||||||
'dynamicDependencies' => array(
|
'dynamicDependencies' => array(
|
||||||
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
||||||
'majorVersion' => '/^[0-9]{1,5}$/',
|
'majorVersion' => '/^[0-9]{1,5}$/',
|
||||||
|
@ -1440,10 +1445,11 @@ class H5PStorage {
|
||||||
// Indicate that the dependencies of this library should be saved.
|
// Indicate that the dependencies of this library should be saved.
|
||||||
$library['saveDependencies'] = TRUE;
|
$library['saveDependencies'] = TRUE;
|
||||||
|
|
||||||
// Save library meta data
|
// Convert metadataSettings values to boolean & json_encode it before saving
|
||||||
if (!isset($library['metadata'])) {
|
$library['metadataSettings'] = isset($library['metadataSettings']) ?
|
||||||
$library['metadata'] = 1;
|
H5PMetadata::boolifyAndEncodeSettings($library['metadataSettings']) :
|
||||||
}
|
NULL;
|
||||||
|
|
||||||
$this->h5pF->saveLibraryData($library, $new);
|
$this->h5pF->saveLibraryData($library, $new);
|
||||||
|
|
||||||
// Save library folder
|
// Save library folder
|
||||||
|
|
Loading…
Reference in New Issue