Merge branch 'without-pal'

Conflicts:
	h5p.classes.php
	js/h5p-library-list.js
namespaces
Frode Petterson 2014-10-23 15:18:03 +02:00
commit 2737f3c721
10 changed files with 366 additions and 360 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

@ -394,10 +394,10 @@ interface H5PFrameworkInterface {
/**
* Delete a library from database and file system
*
* @param int $libraryId
* Library identifier
* @param stdClass $library
* Library object with id, name, major version and minor version.
*/
public function deleteLibrary($libraryId);
public function deleteLibrary($library);
/**
* Load content.
@ -444,57 +444,58 @@ interface H5PFrameworkInterface {
public function loadContentDependencies($id, $type = NULL);
/**
* Get data from cache.
* Get stored setting.
*
* @param string $group
* Identifier for the cache group
* @param string $key
* Unique identifier within the group
* @param string $name
* Identifier for the setting
* @param string $default
* Optional default value if settings is not set
* @return mixed
* Whatever has been stored in the cache. NULL if the entry doesn't exist
* Whatever has been stored as the setting
*/
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
* The cache group where the data should be stored
* @param string $key
* A unique key identifying where the data should be stored
* @param mixed $data
* The data you want to cache
* @param string $name
* Identifier for the setting
* @param mixed $value Data
* Whatever we want to store as the setting
*/
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
* Identifier for the cache group
* @param string $key
* Unique identifier within the group
* @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 $libraryId
* @param int $library_id
*/
public function invalidateContentCache($libraryId);
public function clearFilteredParameters($library_id);
/**
* Get number of content that hasn't been cached
* 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 $libraryId
* Identifier for a library
* @return int
*/
public function getNumContent($libraryId);
}
@ -1265,7 +1266,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++;
}
@ -1567,11 +1568,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'];
}
@ -1619,16 +1615,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.
@ -1655,7 +1643,7 @@ class H5PCore {
}
// Cache.
$this->h5pF->cacheSet('parameters', $content['id'], $params);
$this->h5pF->setFilteredParameters($content['id'], $params);
return $params;
}
@ -2598,7 +2586,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

@ -1,3 +1,4 @@
/*jshint -W083 */
var H5PUpgrades = H5PUpgrades || {};
(function ($) {
@ -212,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) {
@ -374,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

@ -1,3 +1,5 @@
/*jshint multistr: true */
/**
*
*/
@ -130,8 +132,8 @@ var H5P = H5P || (function () {
if (document.documentElement.requestFullScreen) {
fullScreenBrowserPrefix = '';
}
else if (document.documentElement.webkitRequestFullScreen
&& navigator.userAgent.indexOf('Android') === -1 // Skip Android
else if (document.documentElement.webkitRequestFullScreen &&
navigator.userAgent.indexOf('Android') === -1 // Skip Android
) {
safariBrowser = navigator.userAgent.match(/Version\/(\d)/);
safariBrowser = (safariBrowser === null ? 0 : parseInt(safariBrowser[1]));

View File

@ -257,7 +257,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.updatePager();
};
var inputTimer = undefined;
var inputTimer;
$('input', H5PLibraryDetails.$search).on('change keypress paste input', function () {
// Here we start the filtering
// We wait at least 500 ms after last input to perform search

View File

@ -1,4 +1,5 @@
var H5PLibraryList= H5PLibraryList || {};
/*jshint multistr: true */
var H5PLibraryList = H5PLibraryList || {};
(function ($) {

View File

@ -1,3 +1,4 @@
/*jshint multistr: true */
// TODO: Should we split up the generic parts needed by the editor(and others), and the parts needed to "run" H5Ps?
var H5P = H5P || {};
@ -11,9 +12,7 @@ H5P.$window = H5P.jQuery(window);
if (document.documentElement.requestFullScreen) {
H5P.fullScreenBrowserPrefix = '';
}
else if (document.documentElement.webkitRequestFullScreen
&& navigator.userAgent.indexOf('Android') === -1 // Skip Android
) {
else if (document.documentElement.webkitRequestFullScreen) {
H5P.safariBrowser = navigator.userAgent.match(/Version\/(\d)/);
H5P.safariBrowser = (H5P.safariBrowser === null ? 0 : parseInt(H5P.safariBrowser[1]));
@ -62,7 +61,7 @@ H5P.init = function () {
H5P.jQuery('<div class="h5p-content-controls"><div role="button" tabindex="1" class="h5p-enable-fullscreen" title="' + H5P.t('fullscreen') + '"></div></div>').prependTo($container).children().click(function () {
H5P.fullScreen($container, instance);
});
};
}
var $actions = H5P.jQuery('<ul class="h5p-actions"></ul>');
if (contentData.exportUrl !== '') {
@ -290,7 +289,7 @@ H5P.getPath = function (path, contentId) {
if (contentId !== undefined) {
prefix = H5PIntegration.getContentPath(contentId);
}
else if (window['H5PEditor'] !== undefined) {
else if (window.H5PEditor !== undefined) {
prefix = H5PEditor.filesPath;
}
else {
@ -344,9 +343,10 @@ H5P.classFromName = function (name) {
* @return {Object} Instance.
*/
H5P.newRunnable = function (library, contentId, $attachTo, skipResize) {
var nameSplit, versionSplit;
try {
var nameSplit = library.library.split(' ', 2);
var versionSplit = nameSplit[1].split('.', 2);
nameSplit = library.library.split(' ', 2);
versionSplit = nameSplit[1].split('.', 2);
}
catch (err) {
return H5P.error('Invalid library string: ' + library.library);
@ -358,12 +358,13 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize) {
}
// Find constructor function
var constructor;
try {
nameSplit = nameSplit[0].split('.');
var constructor = window;
constructor = window;
for (var i = 0; i < nameSplit.length; i++) {
constructor = constructor[nameSplit[i]];
};
}
if (typeof constructor !== 'function') {
throw null;
}
@ -565,7 +566,7 @@ H5P.ContentCopyrights = function () {
}
// Add sub content rights
for (var i = 0; i < content.length; i++) {
for (i = 0; i < content.length; i++) {
html += content[i];
}

1
js/jquery.js vendored

File diff suppressed because one or more lines are too long

View File

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