Merge branch 'without-pal' of github.com:h5p/h5p-php-library into without-pal
Conflicts: js/h5p-content-upgrade.jsd6
commit
245cf3c2a0
|
@ -153,14 +153,14 @@ class H5PDevelopment {
|
||||||
* @param int $minorVersion of the library.
|
* @param int $minorVersion of the library.
|
||||||
* @return string Translation
|
* @return string Translation
|
||||||
*/
|
*/
|
||||||
public function getLanguage($name, $majorVersion, $minorVersion) {
|
public function getLanguage($name, $majorVersion, $minorVersion, $language) {
|
||||||
$library = H5PDevelopment::libraryToString($name, $majorVersion, $minorVersion);
|
$library = H5PDevelopment::libraryToString($name, $majorVersion, $minorVersion);
|
||||||
|
|
||||||
if (isset($this->libraries[$library]) === FALSE) {
|
if (isset($this->libraries[$library]) === FALSE) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getFileContents($this->libraries[$library]['path'] . '/language/' . $this->language . '.json');
|
return $this->getFileContents($this->libraries[$library]['path'] . '/language/' . $language . '.json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,4 +175,3 @@ class H5PDevelopment {
|
||||||
return $name . ' ' . $majorVersion . '.' . $minorVersion;
|
return $name . ' ' . $majorVersion . '.' . $minorVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -292,47 +292,53 @@ interface H5PFrameworkInterface {
|
||||||
public function loadContentDependencies($id, $type = NULL);
|
public function loadContentDependencies($id, $type = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data from cache.
|
* Get stored setting.
|
||||||
*
|
*
|
||||||
* @param string $group
|
* @param string $name Identifier
|
||||||
* @param string $key
|
* @param string $default Optional
|
||||||
|
* @return mixed data
|
||||||
*/
|
*/
|
||||||
public function cacheGet($group, $key);
|
public function getOption($name, $default = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store data in cache.
|
* Stores the given setting.
|
||||||
|
* For example when did we last check h5p.org for updates to our libraries.
|
||||||
*
|
*
|
||||||
* @param string $group
|
* @param string $name Identifier
|
||||||
* @param string $key
|
* @param mixed $value Data
|
||||||
* @param mixed $data
|
|
||||||
*/
|
*/
|
||||||
public function cacheSet($group, $key, $data);
|
public function setOption($name, $value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete data from cache.
|
* This will set the filtered parameters for the given content.
|
||||||
*
|
*
|
||||||
* @param string $group
|
* @param int $content_id
|
||||||
* @param string $key
|
* @param string $parameters filtered
|
||||||
*/
|
*/
|
||||||
public function cacheDel($group, $key = NULL);
|
public function setFilteredParameters($content_id, $parameters = '');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will invalidate the cache for the content that uses the specified library.
|
* Will clear filtered params for all the content that uses the specified
|
||||||
* This means that the content dependencies has to be rebuilt, and the parameters refiltered.
|
* library. This means that the content dependencies will have to be rebuilt,
|
||||||
|
* and the parameters refiltered.
|
||||||
*
|
*
|
||||||
* @param int $library_id
|
* @param int $library_id
|
||||||
*/
|
*/
|
||||||
public function invalidateContentCache($library_id);
|
public function clearFilteredParameters($library_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get content without cache.
|
* Get number of contents that has to get their content dependencies rebuilt
|
||||||
|
* and parameters refiltered.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getNotCached();
|
public function getNumNotFiltered();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of contents using library as main library.
|
* Get number of contents using library as main library.
|
||||||
*
|
*
|
||||||
* @param int $library_id
|
* @param int $library_id
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getNumContent($library_id);
|
public function getNumContent($library_id);
|
||||||
}
|
}
|
||||||
|
@ -1103,7 +1109,7 @@ class H5PStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure libraries dependencies, parameter filtering and export files gets regenerated for all content who uses this library.
|
// Make sure libraries dependencies, parameter filtering and export files gets regenerated for all content who uses this library.
|
||||||
$this->h5pF->invalidateContentCache($library['libraryId']);
|
$this->h5pF->clearFilteredParameters($library['libraryId']);
|
||||||
|
|
||||||
$upgradedLibsCount++;
|
$upgradedLibsCount++;
|
||||||
}
|
}
|
||||||
|
@ -1403,11 +1409,6 @@ class H5PCore {
|
||||||
$content['id'] = $this->h5pF->insertContent($content, $contentMainId);
|
$content['id'] = $this->h5pF->insertContent($content, $contentMainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($content['filtered'])) {
|
|
||||||
// TODO: Add filtered to all impl. and remove
|
|
||||||
$this->h5pF->cacheDel('parameters', $content['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $content['id'];
|
return $content['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1455,16 +1456,8 @@ class H5PCore {
|
||||||
* @return Object NULL on failure.
|
* @return Object NULL on failure.
|
||||||
*/
|
*/
|
||||||
public function filterParameters($content) {
|
public function filterParameters($content) {
|
||||||
if (isset($content['filtered'])) {
|
if (isset($content['filtered']) && $content['filtered'] !== '') {
|
||||||
$params = ($content['filtered'] === '' ? NULL : $content['filtered']);
|
return $content['filtered'];
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO: Add filtered to all impl. and remove
|
|
||||||
$params = $this->h5pF->cacheGet('parameters', $content['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($params !== NULL) {
|
|
||||||
return $params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate and filter against main library semantics.
|
// Validate and filter against main library semantics.
|
||||||
|
@ -1491,7 +1484,7 @@ class H5PCore {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache.
|
// Cache.
|
||||||
$this->h5pF->cacheSet('parameters', $content['id'], $params);
|
$this->h5pF->setFilteredParameters($content['id'], $params);
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2410,7 +2403,7 @@ class H5PContentValidator {
|
||||||
if (!isset($this->libraries[$value->library])) {
|
if (!isset($this->libraries[$value->library])) {
|
||||||
$libspec = H5PCore::libraryFromString($value->library);
|
$libspec = H5PCore::libraryFromString($value->library);
|
||||||
$library = $this->h5pC->loadLibrary($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']);
|
$library = $this->h5pC->loadLibrary($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']);
|
||||||
$library['semantics'] = json_decode($library['semantics']);
|
$library['semantics'] = $this->h5pC->loadLibrarySemantics($libspec['machineName'], $libspec['majorVersion'], $libspec['minorVersion']);
|
||||||
$this->libraries[$value->library] = $library;
|
$this->libraries[$value->library] = $library;
|
||||||
|
|
||||||
// Find all dependencies for this library
|
// Find all dependencies for this library
|
||||||
|
|
|
@ -213,18 +213,28 @@ var H5PUpgrades = H5PUpgrades || {};
|
||||||
var current = 0; // Track progress
|
var current = 0; // Track progress
|
||||||
asyncSerial(parameters, function (id, params, next) {
|
asyncSerial(parameters, function (id, params, next) {
|
||||||
|
|
||||||
// Make params possible to work with
|
try {
|
||||||
params = JSON.parse(params);
|
// Make params possible to work with
|
||||||
|
params = JSON.parse(params);
|
||||||
|
if (!(params instanceof Object)) {
|
||||||
|
throw true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (event) {
|
||||||
|
return next(info.errorContent.replace('%id', id) + ' ' + info.errorParamsBroken);
|
||||||
|
}
|
||||||
|
|
||||||
// Upgrade this content.
|
// Upgrade this content.
|
||||||
self.upgrade(info.library.name, new Version(info.library.version), self.version, params, function (err, params) {
|
self.upgrade(info.library.name, new Version(info.library.version), self.version, params, function (err, params) {
|
||||||
if (!err) {
|
if (err) {
|
||||||
upgraded[id] = JSON.stringify(params);
|
return next(info.errorContent.replace('%id', id) + ' ' + err);
|
||||||
|
|
||||||
current++;
|
|
||||||
self.throbber.setProgress(Math.round((info.total - self.left + current) / (info.total / 100)) + ' %');
|
|
||||||
}
|
}
|
||||||
next(err);
|
|
||||||
|
upgraded[id] = JSON.stringify(params);
|
||||||
|
|
||||||
|
current++;
|
||||||
|
self.throbber.setProgress(Math.round((info.total - self.left + current) / (info.total / 100)) + ' %');
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
|
@ -375,14 +385,16 @@ var H5PUpgrades = H5PUpgrades || {};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We found an upgrade hook, run it
|
// We found an upgrade hook, run it
|
||||||
if (upgrade.contentUpgrade !== undefined && typeof upgrade.contentUpgrade === 'function') {
|
var unnecessaryWrapper = (upgrade.contentUpgrade !== undefined ? upgrade.contentUpgrade : upgrade);
|
||||||
upgrade.contentUpgrade(params, function (err, upgradedParams) {
|
|
||||||
|
try {
|
||||||
|
unnecessaryWrapper(params, function (err, upgradedParams) {
|
||||||
params = upgradedParams;
|
params = upgradedParams;
|
||||||
nextMinor(err);
|
nextMinor(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
catch (err) {
|
||||||
nextMinor(info.errorScript.replace('%lib', library.name + ' ' + newVersion));
|
next(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, nextMajor);
|
}, nextMajor);
|
||||||
|
|
|
@ -245,3 +245,6 @@ button.h5p-admin.disabled:hover {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
#h5p-admin-container .h5p-admin-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue