Rename init to main_library and remove init from libraries, add schema to db
parent
905afe7dde
commit
a5acd003d0
|
@ -122,7 +122,7 @@ class h5pValidator {
|
||||||
'majorVersion' => '/^[0-9]{1,5}$/',
|
'majorVersion' => '/^[0-9]{1,5}$/',
|
||||||
'minorVersion' => '/^[0-9]{1,5}$/',
|
'minorVersion' => '/^[0-9]{1,5}$/',
|
||||||
),
|
),
|
||||||
// 'init' => '/^[$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'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -160,7 +160,6 @@ class h5pValidator {
|
||||||
);
|
);
|
||||||
|
|
||||||
private $libraryOptional = array(
|
private $libraryOptional = array(
|
||||||
// 'init' => '/^[$a-z_][0-9a-z_\.$]{1,254}$/i',
|
|
||||||
'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)$/',
|
'license' => '/^(cc-by|cc-by-sa|cc-by-nd|cc-by-nc|cc-by-nc-sa|cc-by-nc-nd|pd|cr|MIT)$/',
|
||||||
'description' => '/^.{1,}$/',
|
'description' => '/^.{1,}$/',
|
||||||
|
@ -300,17 +299,17 @@ class h5pValidator {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate json if a schema file is provided
|
// validate json if a semantics file is provided
|
||||||
$schemaPath = $file_path . DIRECTORY_SEPARATOR . 'schema.json';
|
$semanticsPath = $file_path . DIRECTORY_SEPARATOR . 'semantics.json';
|
||||||
if (file_exists($schemaPath)) {
|
if (file_exists($semanticsPath)) {
|
||||||
$schema = $this->getJsonData($schemaPath);
|
$semantics = $this->getJsonData($semanticsPath, TRUE);
|
||||||
if ($schema === FALSE) {
|
if ($semantics === FALSE) {
|
||||||
$this->h5pF->setErrorMessage($this->h5pF->t('Invalid schema.json file has been included in the library %name', array('%name' => $file)));
|
$this->h5pF->setErrorMessage($this->h5pF->t('Invalid semantics.json file has been included in the library %name', array('%name' => $file)));
|
||||||
$valid = FALSE;
|
$valid = FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$h5pData->schema = $schema;
|
$h5pData['semantics'] = $semantics;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +559,7 @@ class h5pValidator {
|
||||||
return $valid;
|
return $valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getJsonData($file_path) {
|
private function getJsonData($file_path, $return_as_string = FALSE) {
|
||||||
$json = file_get_contents($file_path);
|
$json = file_get_contents($file_path);
|
||||||
if (!$json) {
|
if (!$json) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -569,7 +568,7 @@ class h5pValidator {
|
||||||
if (!$jsonData) {
|
if (!$jsonData) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return $jsonData;
|
return $return_as_string ? $json : $jsonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function arrayCopy(array $array) {
|
private function arrayCopy(array $array) {
|
||||||
|
|
Loading…
Reference in New Issue