Fixes for defaultStyles, adds boolean requirement parsing too
parent
4a41265a23
commit
027a32baf1
|
@ -164,7 +164,7 @@ class H5PValidator {
|
||||||
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
||||||
'majorVersion' => '/^[0-9]{1,5}$/',
|
'majorVersion' => '/^[0-9]{1,5}$/',
|
||||||
'minorVersion' => '/^[0-9]{1,5}$/',
|
'minorVersion' => '/^[0-9]{1,5}$/',
|
||||||
'defaultStyles' => '/^(true|false)$/',
|
'defaultStyles' => 'boolean',
|
||||||
),
|
),
|
||||||
'mainLibrary' => '/^[$a-z_][0-9a-z_\.$]{1,254}$/i',
|
'mainLibrary' => '/^[$a-z_][0-9a-z_\.$]{1,254}$/i',
|
||||||
'embedTypes' => array('iframe', 'div'),
|
'embedTypes' => array('iframe', 'div'),
|
||||||
|
@ -179,7 +179,7 @@ class H5PValidator {
|
||||||
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
||||||
'majorVersion' => '/^[0-9]{1,5}$/',
|
'majorVersion' => '/^[0-9]{1,5}$/',
|
||||||
'minorVersion' => '/^[0-9]{1,5}$/',
|
'minorVersion' => '/^[0-9]{1,5}$/',
|
||||||
'defaultStyles' => '/^(true|false)$/',
|
'defaultStyles' => 'boolean',
|
||||||
),
|
),
|
||||||
'externalResources' => array(
|
'externalResources' => array(
|
||||||
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
||||||
|
@ -546,6 +546,13 @@ class H5PValidator {
|
||||||
$valid = TRUE;
|
$valid = TRUE;
|
||||||
|
|
||||||
if (is_string($requirement)) {
|
if (is_string($requirement)) {
|
||||||
|
if ($requirement == 'boolean') {
|
||||||
|
if (!is_bool($h5pData)) {
|
||||||
|
$this->h5pF->setErrorMessage($this->h5pF->t("Invalid data provided for %property in %library. Boolean expected.", array('%property' => $property_name, '%library' => $library_name)));
|
||||||
|
$valid = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
// The requirement is a regexp, match it against the data
|
// The requirement is a regexp, match it against the data
|
||||||
if (is_string($h5pData) || is_int($h5pData)) {
|
if (is_string($h5pData) || is_int($h5pData)) {
|
||||||
if (preg_match($requirement, $h5pData) === 0) {
|
if (preg_match($requirement, $h5pData) === 0) {
|
||||||
|
@ -558,6 +565,7 @@ class H5PValidator {
|
||||||
$valid = FALSE;
|
$valid = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
elseif (is_array($requirement)) {
|
elseif (is_array($requirement)) {
|
||||||
// We have sub requirements
|
// We have sub requirements
|
||||||
if (is_array($h5pData)) {
|
if (is_array($h5pData)) {
|
||||||
|
@ -715,6 +723,7 @@ class H5PStorage {
|
||||||
$librariesInUse[$preloadedDependency['machineName']] = array(
|
$librariesInUse[$preloadedDependency['machineName']] = array(
|
||||||
'library' => $library,
|
'library' => $library,
|
||||||
'preloaded' => $dynamic ? 0 : 1,
|
'preloaded' => $dynamic ? 0 : 1,
|
||||||
|
'default_styles' => $preloadedDependency['defaultStyles'] ? 1 : 0,
|
||||||
);
|
);
|
||||||
$this->getLibraryUsage($librariesInUse, $library, $dynamic);
|
$this->getLibraryUsage($librariesInUse, $library, $dynamic);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue