Add ordering of libraries
parent
06ba81c2ab
commit
ae6329595b
|
@ -1305,8 +1305,8 @@ class H5PStorage {
|
|||
|
||||
// Find out which libraries are used by this package/content
|
||||
$librariesInUse = array();
|
||||
$this->h5pC->findLibraryDependencies($librariesInUse, $this->h5pC->mainJsonData);
|
||||
|
||||
$nextWeight = $this->h5pC->findLibraryDependencies($librariesInUse, $this->h5pC->mainJsonData);
|
||||
|
||||
// Save content
|
||||
if ($content === NULL) {
|
||||
$content = array();
|
||||
|
@ -1836,9 +1836,12 @@ class H5PCore {
|
|||
*
|
||||
* @param array $librariesUsed Flat list of all dependencies.
|
||||
* @param array $library To find all dependencies for.
|
||||
* @param bool $editor Used interally to force all preloaded sub dependencies of an editor dependecy to be editor dependencies.
|
||||
* @param int $nextWeight An integer determining the order of the libraries
|
||||
* when they are loaded
|
||||
* @param bool $editor Used interally to force all preloaded sub dependencies
|
||||
* of an editor dependecy to be editor dependencies.
|
||||
*/
|
||||
public function findLibraryDependencies(&$dependencies, $library, $editor = FALSE) {
|
||||
public function findLibraryDependencies(&$dependencies, $library, $nextWeight = 1, $editor = FALSE) {
|
||||
foreach (array('dynamic', 'preloaded', 'editor') as $type) {
|
||||
$property = $type . 'Dependencies';
|
||||
if (!isset($library[$property])) {
|
||||
|
@ -1862,7 +1865,8 @@ class H5PCore {
|
|||
'library' => $dependencyLibrary,
|
||||
'type' => $type
|
||||
);
|
||||
$this->findLibraryDependencies($dependencies, $dependencyLibrary, $type === 'editor');
|
||||
$nextWeight = $this->findLibraryDependencies($dependencies, $dependencyLibrary, $nextWeight, $type === 'editor');
|
||||
$dependencies[$dependencyKey]['weight'] = $nextWeight++;
|
||||
}
|
||||
else {
|
||||
// This site is missing a dependency!
|
||||
|
@ -1870,6 +1874,7 @@ class H5PCore {
|
|||
}
|
||||
}
|
||||
}
|
||||
return $nextWeight;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2220,8 +2225,7 @@ class H5PCore {
|
|||
class H5PContentValidator {
|
||||
public $h5pF;
|
||||
public $h5pC;
|
||||
private $typeMap;
|
||||
private $libraries, $dependencies;
|
||||
private $typeMap, $libraries, $dependencies, $nextWeight;
|
||||
|
||||
/**
|
||||
* Constructor for the H5PContentValidator
|
||||
|
@ -2247,6 +2251,7 @@ class H5PContentValidator {
|
|||
'select' => 'validateSelect',
|
||||
'library' => 'validateLibrary',
|
||||
);
|
||||
$this->nextWeight = 1;
|
||||
|
||||
// Keep track of the libraries we load to avoid loading it multiple times.
|
||||
$this->libraries = array();
|
||||
|
@ -2634,7 +2639,8 @@ class H5PContentValidator {
|
|||
'type' => 'preloaded'
|
||||
);
|
||||
|
||||
$this->h5pC->findLibraryDependencies($this->dependencies, $library);
|
||||
$this->nextWeight = $this->h5pC->findLibraryDependencies($this->dependencies, $library, $this->nextWeight);
|
||||
$this->dependencies[$depkey]['weight'] = $this->nextWeight++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in New Issue