HFP-1943 Include metadata information in "rights of use" popup
Add copyright information of main content in popup Add copyright information of subcontent in popup HFP-1902 is intended to make the styling betterpull/52/head
parent
95d99d0ad3
commit
83e3c58ba3
63
js/h5p.js
63
js/h5p.js
|
@ -164,7 +164,7 @@ H5P.init = function (target) {
|
||||||
if (displayOptions.frame) {
|
if (displayOptions.frame) {
|
||||||
// Special handling of copyrights
|
// Special handling of copyrights
|
||||||
if (displayOptions.copyright) {
|
if (displayOptions.copyright) {
|
||||||
var copyrights = H5P.getCopyrights(instance, library.params, contentId);
|
var copyrights = H5P.getCopyrights(instance, library.params, library.metadata, contentId);
|
||||||
if (!copyrights) {
|
if (!copyrights) {
|
||||||
displayOptions.copyright = false;
|
displayOptions.copyright = false;
|
||||||
}
|
}
|
||||||
|
@ -976,11 +976,13 @@ H5P.Dialog = function (name, title, content, $element) {
|
||||||
* H5P instance to get copyright information for.
|
* H5P instance to get copyright information for.
|
||||||
* @param {Object} parameters
|
* @param {Object} parameters
|
||||||
* Parameters of the content instance.
|
* Parameters of the content instance.
|
||||||
|
* @param {Object} metadata
|
||||||
|
* Metadata of the content instance.
|
||||||
* @param {number} contentId
|
* @param {number} contentId
|
||||||
* Identifies the H5P content
|
* Identifies the H5P content
|
||||||
* @returns {string} Copyright information.
|
* @returns {string} Copyright information.
|
||||||
*/
|
*/
|
||||||
H5P.getCopyrights = function (instance, parameters, contentId) {
|
H5P.getCopyrights = function (instance, parameters, metadata, contentId) {
|
||||||
var copyrights;
|
var copyrights;
|
||||||
|
|
||||||
if (instance.getCopyrights !== undefined) {
|
if (instance.getCopyrights !== undefined) {
|
||||||
|
@ -999,6 +1001,11 @@ H5P.getCopyrights = function (instance, parameters, contentId) {
|
||||||
H5P.findCopyrights(copyrights, parameters, contentId);
|
H5P.findCopyrights(copyrights, parameters, contentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var metadataCopyrights = H5P.buildMetadataCopyrights(metadata, instance.libraryInfo.machineName);
|
||||||
|
if (metadataCopyrights !== undefined) {
|
||||||
|
copyrights.addMediaInFront(metadataCopyrights);
|
||||||
|
}
|
||||||
|
|
||||||
if (copyrights !== undefined) {
|
if (copyrights !== undefined) {
|
||||||
// Convert to string
|
// Convert to string
|
||||||
copyrights = copyrights.toString();
|
copyrights = copyrights.toString();
|
||||||
|
@ -1017,6 +1024,7 @@ H5P.getCopyrights = function (instance, parameters, contentId) {
|
||||||
* Used to insert thumbnails for images.
|
* Used to insert thumbnails for images.
|
||||||
*/
|
*/
|
||||||
H5P.findCopyrights = function (info, parameters, contentId) {
|
H5P.findCopyrights = function (info, parameters, contentId) {
|
||||||
|
var lastContentTypeName = undefined;
|
||||||
// Cycle through parameters
|
// Cycle through parameters
|
||||||
for (var field in parameters) {
|
for (var field in parameters) {
|
||||||
if (!parameters.hasOwnProperty(field)) {
|
if (!parameters.hasOwnProperty(field)) {
|
||||||
|
@ -1026,6 +1034,8 @@ H5P.findCopyrights = function (info, parameters, contentId) {
|
||||||
/**
|
/**
|
||||||
* @deprecated This hack should be removed after 2017-11-01
|
* @deprecated This hack should be removed after 2017-11-01
|
||||||
* The code that was using this was removed by HFP-574
|
* The code that was using this was removed by HFP-574
|
||||||
|
* This note was seen on 2018-04-04, and consultation with
|
||||||
|
* higher authorities lead to keeping the code for now ;-)
|
||||||
*/
|
*/
|
||||||
if (field === 'overrideSettings') {
|
if (field === 'overrideSettings') {
|
||||||
console.warn("The semantics field 'overrideSettings' is DEPRECATED and should not be used.");
|
console.warn("The semantics field 'overrideSettings' is DEPRECATED and should not be used.");
|
||||||
|
@ -1035,11 +1045,21 @@ H5P.findCopyrights = function (info, parameters, contentId) {
|
||||||
|
|
||||||
var value = parameters[field];
|
var value = parameters[field];
|
||||||
|
|
||||||
|
// TODO: Get the real name of the content type
|
||||||
|
lastContentTypeName = (value.library) ? value.library.split(' ')[0] : lastContentTypeName;
|
||||||
|
|
||||||
if (value instanceof Array) {
|
if (value instanceof Array) {
|
||||||
// Cycle through array
|
// Cycle through array
|
||||||
H5P.findCopyrights(info, value, contentId);
|
H5P.findCopyrights(info, value, contentId);
|
||||||
}
|
}
|
||||||
else if (value instanceof Object) {
|
else if (value instanceof Object) {
|
||||||
|
if (value.metadata) {
|
||||||
|
var metadataCopyrights = H5P.buildMetadataCopyrights(value.metadata, lastContentTypeName);
|
||||||
|
if (metadataCopyrights !== undefined) {
|
||||||
|
info.addMedia(metadataCopyrights);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if object is a file with copyrights
|
// Check if object is a file with copyrights
|
||||||
if (value.copyright === undefined ||
|
if (value.copyright === undefined ||
|
||||||
value.copyright.license === undefined ||
|
value.copyright.license === undefined ||
|
||||||
|
@ -1061,6 +1081,34 @@ H5P.findCopyrights = function (info, parameters, contentId) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
H5P.buildMetadataCopyrights = function (metadata, contentTypeName) {
|
||||||
|
if (metadata && metadata.license !== undefined && metadata.license !== 'U') {
|
||||||
|
var dataset = {
|
||||||
|
title: metadata.title,
|
||||||
|
author: (metadata.authors && metadata.authors.length > 0) ? metadata.authors.map(function(author) {return author.name + ' (' + author.role + ')';}).join(', ') : undefined,
|
||||||
|
source: metadata.source,
|
||||||
|
year: (metadata.yearFrom) ? (metadata.yearFrom + ((metadata.yearTo) ? '-' + metadata.yearTo: '')) : undefined,
|
||||||
|
license: metadata.license,
|
||||||
|
version: metadata.licenseVersion,
|
||||||
|
licenseExtras: metadata.licenseExtras,
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
if (contentTypeName && contentTypeName.indexOf('H5P.') === 0) {
|
||||||
|
contentTypeName = contentTypeName.substr(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new H5P.MediaCopyright(
|
||||||
|
dataset,
|
||||||
|
{type: 'Content type', licenseExtras: 'License extras', changes: 'Changelog'},
|
||||||
|
['type', 'title', 'license', 'author', 'year', 'source', 'licenseExtras', 'changes'],
|
||||||
|
{type: contentTypeName}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a dialog containing the embed code.
|
* Display a dialog containing the embed code.
|
||||||
*
|
*
|
||||||
|
@ -1180,6 +1228,17 @@ H5P.ContentCopyrights = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add sub content in front.
|
||||||
|
*
|
||||||
|
* @param {H5P.MediaCopyright} newMedia
|
||||||
|
*/
|
||||||
|
this.addMediaInFront = function (newMedia) {
|
||||||
|
if (newMedia !== undefined) {
|
||||||
|
media.unshift(newMedia);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add sub content.
|
* Add sub content.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue