Revert "Merge branch 'master' of b.amendor.com:h5p"
This reverts commit 87c44d7d041fbc7b74eee20f70db17bf053bc1e4, reversing changes made to fc545475b1dc2d699e76392bb8b3ae4ce01a8e1c.namespaces
parent
18d3798ec1
commit
d790299326
|
@ -58,7 +58,7 @@ interface H5PFrameworkInterface {
|
||||||
/**
|
/**
|
||||||
* Get id to an excisting library
|
* Get id to an excisting library
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $machineName
|
||||||
* The librarys machine name
|
* The librarys machine name
|
||||||
* @param int $majorVersion
|
* @param int $majorVersion
|
||||||
* The librarys major version
|
* The librarys major version
|
||||||
|
@ -67,7 +67,7 @@ interface H5PFrameworkInterface {
|
||||||
* @return int
|
* @return int
|
||||||
* The id of the specified library or FALSE
|
* The id of the specified library or FALSE
|
||||||
*/
|
*/
|
||||||
public function getLibraryId($name, $majorVersion, $minorVersion);
|
public function getLibraryId($machineName, $majorVersion, $minorVersion);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the library a patched version of an excisting library?
|
* Is the library a patched version of an excisting library?
|
||||||
|
@ -142,14 +142,14 @@ interface H5PFrameworkInterface {
|
||||||
/**
|
/**
|
||||||
* Loads a library
|
* Loads a library
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $machineName
|
||||||
* @param int $majorVersion
|
* @param int $majorVersion
|
||||||
* @param int $minorVersion
|
* @param int $minorVersion
|
||||||
* @return array|FALSE
|
* @return array|FALSE
|
||||||
* Array representing the library with dependency descriptions
|
* Array representing the library with dependency descriptions
|
||||||
* FALSE if the library doesn't exist
|
* FALSE if the library doesn't exist
|
||||||
*/
|
*/
|
||||||
public function loadLibrary($name, $majorVersion, $minorVersion);
|
public function loadLibrary($machineName, $majorVersion, $minorVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
class H5PValidator {
|
class H5PValidator {
|
||||||
|
@ -161,11 +161,11 @@ class H5PValidator {
|
||||||
'title' => '/^.{1,255}$/',
|
'title' => '/^.{1,255}$/',
|
||||||
'language' => '/^[a-z]{1,5}$/',
|
'language' => '/^[a-z]{1,5}$/',
|
||||||
'preloadedDependencies' => array(
|
'preloadedDependencies' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'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}$/',
|
||||||
),
|
),
|
||||||
'library_name' => '/^[a-z0-9\-]{1,255}$/',
|
'mainLibrary' => '/^[$a-z_][0-9a-z_\.$]{1,254}$/i',
|
||||||
'embedTypes' => array('iframe', 'div'),
|
'embedTypes' => array('iframe', 'div'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -175,20 +175,19 @@ 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)$/',
|
'license' => '/^(cc-by|cc-by-sa|cc-by-nd|cc-by-nc|cc-by-nc-sa|cc-by-nc-nd|pd|cr|MIT)$/',
|
||||||
'dynamicDependencies' => array(
|
'dynamicDependencies' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'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}$/',
|
||||||
),
|
),
|
||||||
'externalResources' => array(
|
'externalResources' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'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}$/',
|
||||||
'url' => '/^http:\/\/[a-z_\-\.0-9]+\.[a-z]{2, 10}$/i',
|
'url' => '/^http:\/\/[a-z_\-\.0-9]+\.[a-z]{2, 10}$/i',
|
||||||
'type' => '/^(css|js)$/',
|
'type' => '/^(css|js)$/',
|
||||||
),
|
),
|
||||||
'width' => '/^[0-9]{1,4}$/',
|
'w' => '/^[0-9]{1,4}$/',
|
||||||
'height' => '/^[0-9]{1,4}$/',
|
'h' => '/^[0-9]{1,4}$/',
|
||||||
'fullscreen' => 'boolean',
|
|
||||||
'metaKeywords' => '/^.{1,}$/',
|
'metaKeywords' => '/^.{1,}$/',
|
||||||
'metaDescription' => '/^.{1,}$/k',
|
'metaDescription' => '/^.{1,}$/k',
|
||||||
);
|
);
|
||||||
|
@ -199,8 +198,7 @@ class H5PValidator {
|
||||||
'majorVersion' => '/^[0-9]{1,5}$/',
|
'majorVersion' => '/^[0-9]{1,5}$/',
|
||||||
'minorVersion' => '/^[0-9]{1,5}$/',
|
'minorVersion' => '/^[0-9]{1,5}$/',
|
||||||
'patchVersion' => '/^[0-9]{1,5}$/',
|
'patchVersion' => '/^[0-9]{1,5}$/',
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
||||||
'class' => '/^[a-z0-9\.]{1,255}$/i',
|
|
||||||
'runnable' => '/^(0|1)$/',
|
'runnable' => '/^(0|1)$/',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -209,22 +207,22 @@ class H5PValidator {
|
||||||
'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,}$/',
|
||||||
'dynamicDependencies' => array(
|
'dynamicDependencies' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'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}$/',
|
||||||
),
|
),
|
||||||
'preloadedDependencies' => array(
|
'preloadedDependencies' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'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}$/',
|
||||||
),
|
),
|
||||||
'editorDependencies' => array(
|
'editorDependencies' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'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}$/',
|
||||||
),
|
),
|
||||||
'externalResources' => array(
|
'externalResources' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'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}$/',
|
||||||
'url' => '/^http:\/\/[a-z_\-\.0-9]+\.[a-z]{2, 10}$/i',
|
'url' => '/^http:\/\/[a-z_\-\.0-9]+\.[a-z]{2, 10}$/i',
|
||||||
|
@ -237,11 +235,10 @@ class H5PValidator {
|
||||||
'path' => '/^((\\\|\/)?[a-z_\-\s0-9]+)+\.css$/i',
|
'path' => '/^((\\\|\/)?[a-z_\-\s0-9]+)+\.css$/i',
|
||||||
),
|
),
|
||||||
'dropLibraryCss' => array(
|
'dropLibraryCss' => array(
|
||||||
'name' => '/^[a-z0-9\-]{1,255}$/',
|
'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
|
||||||
),
|
),
|
||||||
'width' => '/^[0-9]{1,4}$/',
|
'w' => '/^[0-9]{1,4}$/',
|
||||||
'height' => '/^[0-9]{1,4}$/',
|
'h' => '/^[0-9]{1,4}$/',
|
||||||
'fullscreen' => 'boolean',
|
|
||||||
'embedTypes' => array('iframe', 'div'),
|
'embedTypes' => array('iframe', 'div'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -396,8 +393,8 @@ class H5PValidator {
|
||||||
$libraries['mainH5pData'] = $mainH5pData;
|
$libraries['mainH5pData'] = $mainH5pData;
|
||||||
$missingLibraries = $this->getMissingLibraries($libraries);
|
$missingLibraries = $this->getMissingLibraries($libraries);
|
||||||
foreach ($missingLibraries as $missing) {
|
foreach ($missingLibraries as $missing) {
|
||||||
if ($this->h5pF->getLibraryId($missing['name'], $missing['majorVersion'], $missing['minorVersion'])) {
|
if ($this->h5pF->getLibraryId($missing['machineName'], $missing['majorVersion'], $missing['minorVersion'])) {
|
||||||
unset($missingLibraries[$missing['name']]);
|
unset($missingLibraries[$missing['machineName']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$valid = empty($missingLibraries) && $valid;
|
$valid = empty($missingLibraries) && $valid;
|
||||||
|
@ -412,10 +409,10 @@ class H5PValidator {
|
||||||
* Use the dependency declarations to find any missing libraries
|
* Use the dependency declarations to find any missing libraries
|
||||||
*
|
*
|
||||||
* @param array $libraries
|
* @param array $libraries
|
||||||
* A multidimensional array of libraries keyed with name first and majorVersion second
|
* A multidimensional array of libraries keyed with machineName first and majorVersion second
|
||||||
* @return array
|
* @return array
|
||||||
* A list of libraries that are missing keyed with name and holds objects with
|
* A list of libraries that are missing keyed with machineName and holds objects with
|
||||||
* name, majorVersion and minorVersion properties
|
* machineName, majorVersion and minorVersion properties
|
||||||
*/
|
*/
|
||||||
private function getMissingLibraries($libraries) {
|
private function getMissingLibraries($libraries) {
|
||||||
$missing = array();
|
$missing = array();
|
||||||
|
@ -438,23 +435,23 @@ class H5PValidator {
|
||||||
* the provided list of libraries
|
* the provided list of libraries
|
||||||
*
|
*
|
||||||
* @param array $dependencies
|
* @param array $dependencies
|
||||||
* A list of objects with name, majorVersion and minorVersion properties
|
* A list of objects with machineName, majorVersion and minorVersion properties
|
||||||
* @param array $libraries
|
* @param array $libraries
|
||||||
* An array of libraries keyed with name
|
* An array of libraries keyed with machineName
|
||||||
* @return
|
* @return
|
||||||
* A list of libraries that are missing keyed with name and holds objects with
|
* A list of libraries that are missing keyed with machineName and holds objects with
|
||||||
* name, majorVersion and minorVersion properties
|
* machineName, majorVersion and minorVersion properties
|
||||||
*/
|
*/
|
||||||
private function getMissingDependencies($dependencies, $libraries) {
|
private function getMissingDependencies($dependencies, $libraries) {
|
||||||
$missing = array();
|
$missing = array();
|
||||||
foreach ($dependencies as $dependency) {
|
foreach ($dependencies as $dependency) {
|
||||||
if (isset($libraries[$dependency['name']])) {
|
if (isset($libraries[$dependency['machineName']])) {
|
||||||
if (!$this->h5pC->isSameVersion($libraries[$dependency['name']], $dependency)) {
|
if (!$this->h5pC->isSameVersion($libraries[$dependency['machineName']], $dependency)) {
|
||||||
$missing[$dependency['name']] = $dependency;
|
$missing[$dependency['machineName']] = $dependency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$missing[$dependency['name']] = $dependency;
|
$missing[$dependency['machineName']] = $dependency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $missing;
|
return $missing;
|
||||||
|
@ -736,8 +733,8 @@ class H5PStorage {
|
||||||
public function getLibraryUsage(&$librariesInUse, $jsonData, $dynamic = FALSE) {
|
public function getLibraryUsage(&$librariesInUse, $jsonData, $dynamic = FALSE) {
|
||||||
if (isset($jsonData['preloadedDependencies'])) {
|
if (isset($jsonData['preloadedDependencies'])) {
|
||||||
foreach ($jsonData['preloadedDependencies'] as $preloadedDependency) {
|
foreach ($jsonData['preloadedDependencies'] as $preloadedDependency) {
|
||||||
$library = $this->h5pF->loadLibrary($preloadedDependency['name'], $preloadedDependency['majorVersion'], $preloadedDependency['minorVersion']);
|
$library = $this->h5pF->loadLibrary($preloadedDependency['machineName'], $preloadedDependency['majorVersion'], $preloadedDependency['minorVersion']);
|
||||||
$librariesInUse[$preloadedDependency['name']] = array(
|
$librariesInUse[$preloadedDependency['machineName']] = array(
|
||||||
'library' => $library,
|
'library' => $library,
|
||||||
'preloaded' => $dynamic ? 0 : 1,
|
'preloaded' => $dynamic ? 0 : 1,
|
||||||
);
|
);
|
||||||
|
@ -746,9 +743,9 @@ class H5PStorage {
|
||||||
}
|
}
|
||||||
if (isset($jsonData['dynamicDependencies'])) {
|
if (isset($jsonData['dynamicDependencies'])) {
|
||||||
foreach ($jsonData['dynamicDependencies'] as $dynamicDependency) {
|
foreach ($jsonData['dynamicDependencies'] as $dynamicDependency) {
|
||||||
if (!isset($librariesInUse[$dynamicDependency['name']])) {
|
if (!isset($librariesInUse[$dynamicDependency['machineName']])) {
|
||||||
$library = $this->h5pF->loadLibrary($dynamicDependency['name'], $dynamicDependency['majorVersion'], $dynamicDependency['minorVersion']);
|
$library = $this->h5pF->loadLibrary($dynamicDependency['machineName'], $dynamicDependency['majorVersion'], $dynamicDependency['minorVersion']);
|
||||||
$librariesInUse[$dynamicDependency['name']] = array(
|
$librariesInUse[$dynamicDependency['machineName']] = array(
|
||||||
'library' => $library,
|
'library' => $library,
|
||||||
'preloaded' => 0,
|
'preloaded' => 0,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue