Commit 2f4de741 authored by paalj's avatar paalj

HFP-2378 Fix empty metadata fields displayed as 'null'

parent 725c4354
......@@ -5,8 +5,8 @@
"homepage": "http://drupal.org/project/h5p",
"license": "GPL-2.0+",
"require": {
"h5p/h5p-core": "dev-master",
"h5p/h5p-editor": "dev-master"
"h5p/h5p-core": "dev-release",
"h5p/h5p-editor": "dev-release"
},
"minimum-stability": "RC"
}
......@@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "b576d27c600fa0f1e8b6dfbdd423b7ec",
"content-hash": "ec2c3f58a79a6493a73307e6350d64d3",
"packages": [
{
"name": "h5p/h5p-core",
"version": "dev-master",
"version": "dev-release",
"source": {
"type": "git",
"url": "https://github.com/h5p/h5p-php-library.git",
"reference": "c4e52f4f29f3824dd69fbddeeb524ff1dade32aa"
"reference": "715fa6f80311adf605898fcf2dfed690b6cc8c4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/h5p/h5p-php-library/zipball/c4e52f4f29f3824dd69fbddeeb524ff1dade32aa",
"reference": "c4e52f4f29f3824dd69fbddeeb524ff1dade32aa",
"url": "https://api.github.com/repos/h5p/h5p-php-library/zipball/715fa6f80311adf605898fcf2dfed690b6cc8c4e",
"reference": "715fa6f80311adf605898fcf2dfed690b6cc8c4e",
"shasum": ""
},
"require": {
......@@ -61,20 +61,20 @@
"interactive",
"quiz"
],
"time": "2018-10-17T11:53:38+00:00"
"time": "2018-11-01T13:42:12+00:00"
},
{
"name": "h5p/h5p-editor",
"version": "dev-master",
"version": "dev-release",
"source": {
"type": "git",
"url": "https://github.com/h5p/h5p-editor-php-library.git",
"reference": "00c2caa82328621e2366e3e7eca75766de1adea4"
"reference": "2d91b3a5f991fe59412b674d6ed1279758f6f912"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/h5p/h5p-editor-php-library/zipball/00c2caa82328621e2366e3e7eca75766de1adea4",
"reference": "00c2caa82328621e2366e3e7eca75766de1adea4",
"url": "https://api.github.com/repos/h5p/h5p-editor-php-library/zipball/2d91b3a5f991fe59412b674d6ed1279758f6f912",
"reference": "2d91b3a5f991fe59412b674d6ed1279758f6f912",
"shasum": ""
},
"require": {
......@@ -118,7 +118,7 @@
"interactive",
"quiz"
],
"time": "2018-10-16T13:53:58+00:00"
"time": "2018-11-01T13:40:43+00:00"
}
],
"packages-dev": [],
......
......@@ -107,7 +107,7 @@ class H5PContentUpgrade extends ControllerBase {
foreach ($params as $id => $param) {
$upgraded = json_decode($param);
$fields = array_merge(\H5PMetadata::toDBArray($upgraded->metadata, false), array(
$fields = array_merge(\H5PMetadata::toDBArray($upgraded->metadata, false, false), array(
'library_id' => $to_library->id,
'parameters' => json_encode($upgraded->params),
'filtered_parameters' => '',
......
[
{
"name": "h5p/h5p-core",
"version": "dev-master",
"version_normalized": "9999999-dev",
"version": "dev-release",
"version_normalized": "dev-release",
"source": {
"type": "git",
"url": "https://github.com/h5p/h5p-php-library.git",
"reference": "c4e52f4f29f3824dd69fbddeeb524ff1dade32aa"
"reference": "715fa6f80311adf605898fcf2dfed690b6cc8c4e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/h5p/h5p-php-library/zipball/c4e52f4f29f3824dd69fbddeeb524ff1dade32aa",
"reference": "c4e52f4f29f3824dd69fbddeeb524ff1dade32aa",
"url": "https://api.github.com/repos/h5p/h5p-php-library/zipball/715fa6f80311adf605898fcf2dfed690b6cc8c4e",
"reference": "715fa6f80311adf605898fcf2dfed690b6cc8c4e",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2018-10-17T11:53:38+00:00",
"time": "2018-11-01T13:42:12+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
......@@ -60,23 +60,23 @@
},
{
"name": "h5p/h5p-editor",
"version": "dev-master",
"version_normalized": "9999999-dev",
"version": "dev-release",
"version_normalized": "dev-release",
"source": {
"type": "git",
"url": "https://github.com/h5p/h5p-editor-php-library.git",
"reference": "00c2caa82328621e2366e3e7eca75766de1adea4"
"reference": "2d91b3a5f991fe59412b674d6ed1279758f6f912"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/h5p/h5p-editor-php-library/zipball/00c2caa82328621e2366e3e7eca75766de1adea4",
"reference": "00c2caa82328621e2366e3e7eca75766de1adea4",
"url": "https://api.github.com/repos/h5p/h5p-editor-php-library/zipball/2d91b3a5f991fe59412b674d6ed1279758f6f912",
"reference": "2d91b3a5f991fe59412b674d6ed1279758f6f912",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2018-10-16T13:53:58+00:00",
"time": "2018-11-01T13:40:43+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
......
......@@ -64,15 +64,16 @@ abstract class H5PMetadata {
',"authorComments":' . (isset($content->author_comments) ? json_encode($content->author_comments) : 'null') . '}';
}
/**
* Make the metadata into an associative array keyed by the property names
* @param mixed $metadata Array or object containing metadata
* @param bool $include_title
* @param bool $include_missing For metadata fields not being set, skip 'em.
* Relevant for content upgrade
* @param array $types
* @return array
*/
public static function toDBArray($metadata, $include_title = true, &$types = array()) {
public static function toDBArray($metadata, $include_title = true, $include_missing = true, &$types = array()) {
$fields = array();
if (!is_array($metadata)) {
......@@ -81,35 +82,43 @@ abstract class H5PMetadata {
foreach (self::$fields as $key => $config) {
// Ignore title?
if ($key === 'title' && !$include_title) {
continue;
}
if (isset($metadata[$key])) {
$value = $metadata[$key];
$db_field_name = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $key));
switch ($config['type']) {
case 'text':
if (strlen($value) > $config['maxLength']) {
$value = mb_substr($value, 0, $config['maxLength']);
}
$types[] = '%s';
break;
case 'int':
$value = ($value !== null) ? intval($value): null;
$types[] = '%d';
break;
case 'json':
$value = json_encode($value);
$types[] = '%s';
break;
}
$fields[$db_field_name] = $value;
$exists = array_key_exists($key, $metadata);
// Don't include missing fields
if (!$include_missing && !exists) {
continue;
}
$value = $exists ? $metadata[$key] : null;
// lowerCamelCase to snake_case
$db_field_name = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $key));
switch ($config['type']) {
case 'text':
if ($value !== null && strlen($value) > $config['maxLength']) {
$value = mb_substr($value, 0, $config['maxLength']);
}
$types[] = '%s';
break;
case 'int':
$value = ($value !== null) ? intval($value) : null;
$types[] = '%d';
break;
case 'json':
$value = ($value !== null) ? json_encode($value) : null;
$types[] = '%s';
break;
}
$fields[$db_field_name] = $value;
}
return $fields;
......
......@@ -1647,7 +1647,7 @@ Class H5PExport {
);
foreach(array('authors', 'source', 'license', 'licenseVersion', 'licenseExtras' ,'yearFrom', 'yearTo', 'changes', 'authorComments') as $field) {
if (isset($content['metadata'][$field])) {
if (isset($content['metadata'][$field]) && $content['metadata'][$field] !== '') {
if (($field !== 'authors' && $field !== 'changes') || (count($content['metadata'][$field]) > 0)) {
$h5pJson[$field] = json_decode(json_encode($content['metadata'][$field], TRUE));
}
......@@ -2000,6 +2000,10 @@ class H5PCore {
return $content['filtered'];
}
if (!(isset($content['library']) && isset($content['params']))) {
return NULL;
}
// Validate and filter against main library semantics.
$validator = new H5PContentValidator($this->h5pF, $this);
$params = (object) array(
......
......@@ -351,7 +351,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
*
* @param {number|null} minHeight
*/
this.setViewPortMinimumHeight = function(minHeight) {
this.setViewPortMinimumHeight = function (minHeight) {
var container = document.querySelector('.h5p-container') || document.body;
container.style.minHeight = (typeof minHeight === 'number') ? (minHeight + 'px') : minHeight;
};
......
......@@ -11,7 +11,7 @@
* @class
* @augments H5P.EventDispatcher
*/
H5P.ContentType = function (isRootLibrary, library) {
H5P.ContentType = function (isRootLibrary) {
function ContentType() {}
......
......@@ -127,10 +127,10 @@ H5P.ContentUpgradeProcess = (function (Version) {
}, {metadata: metadata});
}
catch (err) {
if (console && console.log) {
console.log("Error", err.stack);
console.log("Error", err.name);
console.log("Error", err.message);
if (console && console.error) {
console.error("Error", err.stack);
console.error("Error", err.name);
console.error("Error", err.message);
}
next(err);
}
......
/* global importScripts */
var H5P = H5P || {};
importScripts('h5p-version.js', 'h5p-content-upgrade-process.js');
......
/*jshint -W083 */
/* global H5PAdminIntegration H5PUtils */
(function ($, Version) {
var info, $container, librariesCache = {}, scriptsCache = {};
......
/* global H5PUtils */
var H5PDataView = (function ($) {
/**
......@@ -198,7 +199,6 @@ var H5PDataView = (function ($) {
* @param number col ID of column
*/
H5PDataView.prototype.createFacets = function (input, col) {
var self = this;
var facets = '';
if (input instanceof Array) {
......
......@@ -10,7 +10,7 @@ var H5P = window.H5P = window.H5P || {};
* @param {boolean} [extras.bubbles]
* @param {boolean} [extras.external]
*/
H5P.Event = function(type, data, extras) {
H5P.Event = function (type, data, extras) {
this.type = type;
this.data = data;
var bubbles = false;
......@@ -34,7 +34,7 @@ H5P.Event = function(type, data, extras) {
/**
* Prevent this event from bubbling up to parent
*/
this.preventBubbling = function() {
this.preventBubbling = function () {
bubbles = false;
};
......@@ -44,7 +44,7 @@ H5P.Event = function(type, data, extras) {
* @returns {boolean}
* true if bubbling false otherwise
*/
this.getBubbles = function() {
this.getBubbles = function () {
return bubbles;
};
......@@ -54,7 +54,7 @@ H5P.Event = function(type, data, extras) {
* @returns {boolean}
* true if external and not already scheduled, otherwise false
*/
this.scheduleForExternal = function() {
this.scheduleForExternal = function () {
if (external && !scheduledForExternal) {
scheduledForExternal = true;
return true;
......
var H5PLibraryDetails= H5PLibraryDetails || {};
/* global H5PAdminIntegration H5PUtils */
var H5PLibraryDetails = H5PLibraryDetails || {};
(function ($) {
......@@ -68,7 +69,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
*/
H5PLibraryDetails.createContentTable = function () {
// Remove it if it exists:
if(H5PLibraryDetails.$contentTable) {
if (H5PLibraryDetails.$contentTable) {
H5PLibraryDetails.$contentTable.remove();
}
......@@ -77,10 +78,10 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
var i = (H5PLibraryDetails.currentPage*H5PLibraryDetails.PAGER_SIZE);
var lastIndex = (i+H5PLibraryDetails.PAGER_SIZE);
if(lastIndex > H5PLibraryDetails.currentContent.length) {
if (lastIndex > H5PLibraryDetails.currentContent.length) {
lastIndex = H5PLibraryDetails.currentContent.length;
}
for(; i<lastIndex; i++) {
for (; i<lastIndex; i++) {
var content = H5PLibraryDetails.currentContent[i];
H5PLibraryDetails.$contentTable.append(H5PUtils.createTableRow(['<a href="' + content.url + '">' + content.title + '</a>']));
}
......@@ -97,7 +98,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.$next = $('<button type="button" class="next h5p-admin">></button>');
H5PLibraryDetails.$previous.on('click', function () {
if(H5PLibraryDetails.$previous.hasClass('disabled')) {
if (H5PLibraryDetails.$previous.hasClass('disabled')) {
return;
}
......@@ -107,7 +108,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
});
H5PLibraryDetails.$next.on('click', function () {
if(H5PLibraryDetails.$next.hasClass('disabled')) {
if (H5PLibraryDetails.$next.hasClass('disabled')) {
return;
}
......@@ -127,7 +128,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.$pagerInfo.hide();
// User has updated the pageNumber
var pageNumerUpdated = function() {
var pageNumerUpdated = function () {
var newPageNum = $gotoInput.val()-1;
var intRegex = /^\d+$/;
......@@ -135,7 +136,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'});
// Check if input value is valid, and that it has actually changed
if(!(intRegex.test(newPageNum) && newPageNum >= 0 && newPageNum < H5PLibraryDetails.getNumPages() && newPageNum != H5PLibraryDetails.currentPage)) {
if (!(intRegex.test(newPageNum) && newPageNum >= 0 && newPageNum < H5PLibraryDetails.getNumPages() && newPageNum != H5PLibraryDetails.currentPage)) {
return;
}
......@@ -185,7 +186,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.updatePager = function () {
H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'});
if(H5PLibraryDetails.getNumPages() > 0) {
if (H5PLibraryDetails.getNumPages() > 0) {
var message = H5PUtils.translateReplace(H5PLibraryDetails.library.translations.pageXOfY, {
'$x': (H5PLibraryDetails.currentPage+1),
'$y': H5PLibraryDetails.getNumPages()
......@@ -211,7 +212,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
var searchString = $('.h5p-content-search > input').val();
// If search string same as previous, just do nothing
if(H5PLibraryDetails.currentFilter === searchString) {
if (H5PLibraryDetails.currentFilter === searchString) {
return;
}
......@@ -219,7 +220,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
// If empty search, use the complete list
H5PLibraryDetails.currentContent = H5PLibraryDetails.library.content;
}
else if(H5PLibraryDetails.filterCache[searchString]) {
else if (H5PLibraryDetails.filterCache[searchString]) {
// If search is cached, no need to filter
H5PLibraryDetails.currentContent = H5PLibraryDetails.filterCache[searchString];
}
......@@ -227,10 +228,10 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
var listToFilter = H5PLibraryDetails.library.content;
// Check if we can filter the already filtered results (for performance)
if(searchString.length > 1 && H5PLibraryDetails.currentFilter === searchString.substr(0, H5PLibraryDetails.currentFilter.length)) {
if (searchString.length > 1 && H5PLibraryDetails.currentFilter === searchString.substr(0, H5PLibraryDetails.currentFilter.length)) {
listToFilter = H5PLibraryDetails.currentContent;
}
H5PLibraryDetails.currentContent = $.grep(listToFilter, function(content) {
H5PLibraryDetails.currentContent = $.grep(listToFilter, function (content) {
return content.title && content.title.match(new RegExp(searchString, 'i'));
});
}
......@@ -256,7 +257,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
$('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
if(inputTimer) {
if (inputTimer) {
clearTimeout(inputTimer);
}
......
/*jshint multistr: true */
/* global H5PAdminIntegration H5PUtils */
var H5PLibraryList = H5PLibraryList || {};
(function ($) {
......@@ -25,7 +25,7 @@ var H5PLibraryList = H5PLibraryList || {};
*/
H5PLibraryList.createLibraryList = function (libraries) {
var t = H5PAdminIntegration.l10n;
if(libraries.listData === undefined || libraries.listData.length === 0) {
if (libraries.listData === undefined || libraries.listData.length === 0) {
return $('<div>' + t.NA + '</div>');
}
......
......@@ -21,7 +21,7 @@
iframe.style.width = '100%';
// Tell iframe that it needs to resize when our window resizes
var resize = function (event) {
var resize = function () {
if (iframe.contentWindow) {
// Limit resize calls to avoid flickering
respond('resize');
......@@ -64,7 +64,7 @@
* @param {Object} data Payload
* @param {Function} respond Send a response to the iframe
*/
actionHandlers.resize = function (iframe, data, respond) {
actionHandlers.resize = function (iframe, data) {
// Resize iframe so all content is visible. Use scrollHeight to make sure we get everything
iframe.style.height = data.scrollHeight + 'px';
};
......
/* global H5PAdminIntegration*/
var H5PUtils = H5PUtils || {};
(function ($) {
......@@ -9,7 +10,7 @@ var H5PUtils = H5PUtils || {};
H5PUtils.createTable = function (headers) {
var $table = $('<table class="h5p-admin-table' + (H5PAdminIntegration.extraTableClasses !== undefined ? ' ' + H5PAdminIntegration.extraTableClasses : '') + '"></table>');
if(headers) {
if (headers) {
var $thead = $('<thead></thead>');
var $tr = $('<tr></tr>');
......@@ -44,7 +45,7 @@ var H5PUtils = H5PUtils || {};
};
}
$('<td/>', value).appendTo($tr);
$('<td/>', value).appendTo($tr);
});
return $tr;
......
......@@ -217,7 +217,7 @@ H5P.XAPIEvent.prototype.setActor = function () {
* @returns {number}
* The max score, or null if not defined
*/
H5P.XAPIEvent.prototype.getMaxScore = function() {
H5P.XAPIEvent.prototype.getMaxScore = function () {
return this.getVerifiedStatementValue(['result', 'score', 'max']);
};
......@@ -227,7 +227,7 @@ H5P.XAPIEvent.prototype.getMaxScore = function() {
* @returns {number}
* The score, or null if not defined
*/
H5P.XAPIEvent.prototype.getScore = function() {
H5P.XAPIEvent.prototype.getScore = function () {
return this.getVerifiedStatementValue(['result', 'score', 'raw']);
};
......@@ -256,7 +256,7 @@ H5P.XAPIEvent.prototype.getContentXAPIId = function (instance) {
H5P.XAPIEvent.prototype.isFromChild = function () {
var parentId = this.getVerifiedStatementValue(['context', 'contextActivities', 'parent', 0, 'id']);
return !parentId || parentId.indexOf('subContentId') === -1;
}
};
/**
* Figure out if a property exists in the statement and return it
......@@ -267,7 +267,7 @@ H5P.XAPIEvent.prototype.isFromChild = function () {
* @returns {*}
* The value of the property if it is set, null otherwise.
*/
H5P.XAPIEvent.prototype.getVerifiedStatementValue = function(keys) {
H5P.XAPIEvent.prototype.getVerifiedStatementValue = function (keys) {
var val = this.data.statement;
for (var i = 0; i < keys.length; i++) {
if (val[keys[i]] === undefined) {
......
......@@ -92,7 +92,7 @@ H5P.EventDispatcher.prototype.triggerXAPIScored = function (score, maxScore, ver
this.trigger(event);
};
H5P.EventDispatcher.prototype.setActivityStarted = function() {
H5P.EventDispatcher.prototype.setActivityStarted = function () {
if (this.activityStartTime === undefined) {
// Don't trigger xAPI events in the editor
if (this.contentId !== undefined &&
......
......@@ -89,7 +89,7 @@ H5P.init = function (target) {
}
// H5Ps added in normal DIV.
var $containers = H5P.jQuery('.h5p-content:not(.h5p-initialized)', target).each(function () {
H5P.jQuery('.h5p-content:not(.h5p-initialized)', target).each(function () {
var $element = H5P.jQuery(this).addClass('h5p-initialized');
var $container = H5P.jQuery('<div class="h5p-container"></div>').appendTo($element);
var contentId = $element.data('content-id');
......@@ -301,7 +301,7 @@ H5P.init = function (target) {
});
// When resize has been prepared tell parent window to resize
H5P.communicator.on('resizePrepared', function (data) {
H5P.communicator.on('resizePrepared', function () {
H5P.communicator.send('resize', {
scrollHeight: document.body.scrollHeight
});
......@@ -494,7 +494,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
}
var $container = $element;
var $classes, $iframe;
var $classes, $iframe, $body;
if (body === undefined) {
$body = H5P.$body;
}
......@@ -1089,7 +1089,7 @@ H5P.findCopyrights = function (info, parameters, contentId, extras) {
}
}
function buildFromMetadata (data, name, contentId) {
function buildFromMetadata(data, name, contentId) {
if (data.metadata) {
const metadataCopyrights = H5P.buildMetadataCopyrights(data.metadata, name);
if (metadataCopyrights !== undefined) {
......@@ -1105,12 +1105,12 @@ H5P.findCopyrights = function (info, parameters, contentId, extras) {
}
};
H5P.buildMetadataCopyrights = function (metadata, contentTypeName) {
H5P.buildMetadataCopyrights = function (metadata) {
if (metadata && metadata.license !== undefined && metadata.license !== 'U') {
var dataset = {
contentType: metadata.contentType,
title: metadata.title,
author: (metadata.authors && metadata.authors.length > 0) ? metadata.authors.map(function(author) {
author: (metadata.authors && metadata.authors.length > 0) ? metadata.authors.map(function (author) {
return (author.role) ? author.name + ' (' + author.role + ')' : author.name;
}).join(', ') : undefined,
source: metadata.source,
......@@ -1118,7 +1118,7 @@ H5P.buildMetadataCopyrights = function (metadata, contentTypeName) {
license: metadata.license,
version: metadata.licenseVersion,
licenseExtras: metadata.licenseExtras,
changes: (metadata.changes && metadata.changes.length > 0) ? metadata.changes.map(function(change) {
changes: (metadata.changes && metadata.changes.length > 0) ? metadata.changes.map(function (change) {
return change.log + (change.author ? ', ' + change.author : '') + (change.date ? ', ' + change.date : '');
}).join(' / ') : undefined
};
......@@ -1181,10 +1181,10 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
updateEmbed();
// Select text and expand textareas
$dialog.find('.h5p-embed-code-container').each(function(index, value) {
H5P.jQuery(this).css('height', this.scrollHeight + 'px').focus(function() {
H5P.jQuery(this).select();
});
$dialog.find('.h5p-embed-code-container').each(function () {
H5P.jQuery(this).css('height', this.scrollHeight + 'px').focus(function () {
H5P.jQuery(this).select();
});
});
$dialog.find('.h5p-embed-code-container').eq(0).select();
positionInner();
......@@ -1201,7 +1201,7 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
$expander.addClass('h5p-open').text(H5P.t('hideAdvanced'));
$content.show();
}
$dialog.find('.h5p-embed-code-container').each(function(index, value) {
$dialog.find('.h5p-embed-code-container').each(function () {
H5P.jQuery(this).css('height', this.scrollHeight + 'px');
});
positionInner();
......@@ -1418,7 +1418,7 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) {
for (var i = 0; i < order.length; i++) {
var fieldName = order[i];
if (copyright[fieldName] !== undefined) {
if (copyright[fieldName] !== undefined && copyright[fieldName] !== '') {
var humanValue = copyright[fieldName];
if (fieldName === 'license') {
humanValue = humanizeLicense(copyright.license, copyright.version);
......@@ -1614,7 +1614,8 @@ H5P.Coords = function (x, y, w, h) {
this.y = x.y;
this.w = x.w;
this.h = x.h;
} else {
}
else {
if (x !== undefined) {
this.x = x;
}
......@@ -1870,7 +1871,7 @@ H5P.on = function (instance, eventType, handler) {
* @returns {string} UUID
*/
H5P.createUUID = function () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(char) {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
var random = Math.random()*16|0, newChar = char === 'x' ? random : (random&0x3|0x8);
return newChar.toString(16);
});
......@@ -2098,7 +2099,7 @@ H5P.createTitle = function (rawTitle, maxLength) {
}
preloadedData[options.subContentId][dataId] = data;
contentUserDataAjax(contentId, dataId, options.subContentId, function (error, data) {
contentUserDataAjax(contentId, dataId, options.subContentId, function (error) {
if (options.errorCallback && error) {
options.errorCallback(error);
}
......
......@@ -165,10 +165,11 @@ H5PEditor.language.core = {
metadataSharingAndLicensingInfo: 'Metadata (sharing and licensing info)',
fillInTheFieldsBelow: 'Fill in the fields below',
saveMetadata: 'Save metadata',
addAuthor: 'Add author',
addAuthor: 'Save author',
confirmRemoveAuthor: 'Are you sure you would like to remove this author?',
addNewChange: 'Add new change',
confirmDeleteChangeLog: 'Are you sure you would like to delete this change log entry?',
changelogDescription: 'Some licenses require that changes made to the original work, or derivatives are logged and displayed. You may log your changes here for licensing reasons or just to allow yourself and others to keep track of the changes made to this content.',
logThisChange: 'Log this change',
newChangeHasBeenLogged: 'New change has been logged',
loggedChanges: 'Logged changes',
......@@ -179,11 +180,14 @@ H5PEditor.language.core = {
copyButton: 'Copy',
copiedButton: 'Copied',
pasteButton: 'Paste',
pasteContent: 'Paste Content',
confirmPasteContent: 'By doing this you will replace the current content with the content from your clipboard. Are you sure you wish to continue?',
pasteAndReplaceButton: 'Paste & Replace',
pasteContent: 'Replace Content',
confirmPasteContent: 'By doing this you will replace the current content with the content from your clipboard. The current content will be lost. Are you sure you wish to continue?',
confirmPasteButtonText: 'Replace content',
copyToClipboard: 'Copy H5P content to the clipboard',
copiedToClipboard: 'Content is copied to the clipboard',
pasteFromClipboard: 'Paste H5P content from the clipboard',