From 42fbb6ab1f0dec5b83273d1b0e6be079769fd2ed Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 11 Feb 2015 14:40:01 +0100 Subject: [PATCH] Reverse direction of dependency loading. The libraries used last in the parameters are now loaded first, e.g. summary is now loaded before iv! --- h5p.classes.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index ae7d2f5..f0ca139 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1307,7 +1307,7 @@ class H5PStorage { // Find out which libraries are used by this package/content $librariesInUse = array(); $nextWeight = $this->h5pC->findLibraryDependencies($librariesInUse, $this->h5pC->mainJsonData); - + // Save content if ($content === NULL) { $content = array(); @@ -1841,7 +1841,7 @@ class H5PCore { * @param array $library To find all dependencies for. * @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 + * @param bool $editor Used interally to force all preloaded sub dependencies * of an editor dependecy to be editor dependencies. */ public function findLibraryDependencies(&$dependencies, $library, $nextWeight = 1, $editor = FALSE) { @@ -2633,18 +2633,6 @@ class H5PContentValidator { $library = $this->h5pC->loadLibrary($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']); $library['semantics'] = $this->h5pC->loadLibrarySemantics($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']); $this->libraries[$value->library] = $library; - - // Find all dependencies for this library - $depkey = 'preloaded-' . $libspec['machineName']; - if (!isset($this->dependencies[$depkey])) { - $this->dependencies[$depkey] = array( - 'library' => $library, - 'type' => 'preloaded' - ); - - $this->nextWeight = $this->h5pC->findLibraryDependencies($this->dependencies, $library, $this->nextWeight); - $this->dependencies[$depkey]['weight'] = $this->nextWeight++; - } } else { $library = $this->libraries[$value->library]; @@ -2659,6 +2647,18 @@ class H5PContentValidator { $validkeys = array_merge($validkeys, $semantics->extraAttributes); } $this->filterParams($value, $validkeys); + + // Find all dependencies for this library + $depkey = 'preloaded-' . $library['machineName']; + if (!isset($this->dependencies[$depkey])) { + $this->dependencies[$depkey] = array( + 'library' => $library, + 'type' => 'preloaded' + ); + + $this->nextWeight = $this->h5pC->findLibraryDependencies($this->dependencies, $library, $this->nextWeight); + $this->dependencies[$depkey]['weight'] = $this->nextWeight++; + } } /**