Merge branch 'without-pal' of github.com:h5p/h5p-php-library into user-results

Conflicts:
	js/h5p-content-upgrade.js
	styles/h5p-admin.css
d6
Frode Petterson 2014-10-16 16:11:12 +02:00
commit e6125f5c61
4 changed files with 239 additions and 232 deletions

View File

@ -153,14 +153,14 @@ class H5PDevelopment {
* @param int $minorVersion of the library.
* @return string Translation
*/
public function getLanguage($name, $majorVersion, $minorVersion) {
public function getLanguage($name, $majorVersion, $minorVersion, $language) {
$library = H5PDevelopment::libraryToString($name, $majorVersion, $minorVersion);
if (isset($this->libraries[$library]) === FALSE) {
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;
}
}

View File

@ -292,47 +292,53 @@ interface H5PFrameworkInterface {
public function loadContentDependencies($id, $type = NULL);
/**
* Get data from cache.
* Get stored setting.
*
* @param string $group
* @param string $key
* @param string $name Identifier
* @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 $key
* @param mixed $data
* @param string $name Identifier
* @param mixed $value 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 string $key
* @param int $content_id
* @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.
* This means that the content dependencies has to be rebuilt, and the parameters refiltered.
* Will clear filtered params for all the content that uses the specified
* library. This means that the content dependencies will have to be rebuilt,
* and the parameters refiltered.
*
* @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.
*
* @param int $library_id
* @return int
*/
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.
$this->h5pF->invalidateContentCache($library['libraryId']);
$this->h5pF->clearFilteredParameters($library['libraryId']);
$upgradedLibsCount++;
}
@ -1403,11 +1409,6 @@ class H5PCore {
$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'];
}
@ -1455,16 +1456,8 @@ class H5PCore {
* @return Object NULL on failure.
*/
public function filterParameters($content) {
if (isset($content['filtered'])) {
$params = ($content['filtered'] === '' ? NULL : $content['filtered']);
}
else {
// TODO: Add filtered to all impl. and remove
$params = $this->h5pF->cacheGet('parameters', $content['id']);
}
if ($params !== NULL) {
return $params;
if (isset($content['filtered']) && $content['filtered'] !== '') {
return $content['filtered'];
}
// Validate and filter against main library semantics.
@ -1491,7 +1484,7 @@ class H5PCore {
}
// Cache.
$this->h5pF->cacheSet('parameters', $content['id'], $params);
$this->h5pF->setFilteredParameters($content['id'], $params);
return $params;
}
@ -2410,7 +2403,7 @@ class H5PContentValidator {
if (!isset($this->libraries[$value->library])) {
$libspec = H5PCore::libraryFromString($value->library);
$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;
// Find all dependencies for this library

View File

@ -213,18 +213,28 @@ var H5PUpgrades = H5PUpgrades || {};
var current = 0; // Track progress
asyncSerial(parameters, function (id, params, next) {
try {
// 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.
self.upgrade(info.library.name, new Version(info.library.version), self.version, params, function (err, params) {
if (!err) {
if (err) {
return next(info.errorContent.replace('%id', id) + ' ' + err);
}
upgraded[id] = JSON.stringify(params);
current++;
self.throbber.setProgress(Math.round((info.total - self.left + current) / (info.total / 100)) + ' %');
}
next(err);
next();
});
}, function (err) {
@ -375,14 +385,16 @@ var H5PUpgrades = H5PUpgrades || {};
}
else {
// We found an upgrade hook, run it
if (upgrade.contentUpgrade !== undefined && typeof upgrade.contentUpgrade === 'function') {
upgrade.contentUpgrade(params, function (err, upgradedParams) {
var unnecessaryWrapper = (upgrade.contentUpgrade !== undefined ? upgrade.contentUpgrade : upgrade);
try {
unnecessaryWrapper(params, function (err, upgradedParams) {
params = upgradedParams;
nextMinor(err);
});
}
else {
nextMinor(info.errorScript.replace('%lib', library.name + ' ' + newVersion));
catch (err) {
next(err);
}
}
}, nextMajor);

View File

@ -246,6 +246,9 @@ button.h5p-admin.disabled:hover {
font-size: 1.5em;
font-weight: bold;
}
#h5p-admin-container .h5p-admin-center {
text-align: center;
}
.h5p-pagination {
text-align: center;
}