Merge branch 'master' of github.com:h5p/h5p-php-library into HFP-574-remove-override-settings
commit
9ea6f277e1
168
h5p.classes.php
168
h5p.classes.php
|
@ -310,12 +310,14 @@ interface H5PFrameworkInterface {
|
|||
*
|
||||
* @param int $libraryId
|
||||
* Library identifier
|
||||
* @param boolean $skipContent
|
||||
* Flag to indicate if content usage should be skipped
|
||||
* @return array
|
||||
* Associative array containing:
|
||||
* - content: Number of content using the library
|
||||
* - libraries: Number of libraries depending on the library
|
||||
*/
|
||||
public function getLibraryUsage($libraryId);
|
||||
public function getLibraryUsage($libraryId, $skipContent = FALSE);
|
||||
|
||||
/**
|
||||
* Loads a library
|
||||
|
@ -2456,10 +2458,6 @@ class H5PCore {
|
|||
// Failed retrieving uuid
|
||||
if (!$registration) {
|
||||
$errorMessage = $this->h5pF->t('Site could not be registered with the hub. Please contact your site administrator.');
|
||||
H5PCore::ajaxError(
|
||||
$errorMessage,
|
||||
'SITE_REGISTRATION_FAILED'
|
||||
);
|
||||
$this->h5pF->setErrorMessage($errorMessage);
|
||||
$this->h5pF->setErrorMessage(
|
||||
$this->h5pF->t('The H5P Hub has been disabled until this problem can be resolved. You may still upload libraries through the "H5P Libraries" page.')
|
||||
|
@ -2506,7 +2504,7 @@ class H5PCore {
|
|||
|
||||
// No data received
|
||||
if (!$result || empty($result)) {
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Handle libraries metadata
|
||||
|
@ -2975,16 +2973,18 @@ class H5PCore {
|
|||
public static function returnBytes($val) {
|
||||
$val = trim($val);
|
||||
$last = strtolower($val[strlen($val) - 1]);
|
||||
$bytes = (int) $val;
|
||||
|
||||
switch ($last) {
|
||||
case 'g':
|
||||
$val *= 1024;
|
||||
$bytes *= 1024;
|
||||
case 'm':
|
||||
$val *= 1024;
|
||||
$bytes *= 1024;
|
||||
case 'k':
|
||||
$val *= 1024;
|
||||
$bytes *= 1024;
|
||||
}
|
||||
|
||||
return $val;
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3009,6 +3009,67 @@ class H5PCore {
|
|||
|
||||
return $can;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide localization for the Core JS
|
||||
* @return array
|
||||
*/
|
||||
public function getLocalization() {
|
||||
return array(
|
||||
'fullscreen' => $this->h5pF->t('Fullscreen'),
|
||||
'disableFullscreen' => $this->h5pF->t('Disable fullscreen'),
|
||||
'download' => $this->h5pF->t('Download'),
|
||||
'copyrights' => $this->h5pF->t('Rights of use'),
|
||||
'embed' => $this->h5pF->t('Embed'),
|
||||
'size' => $this->h5pF->t('Size'),
|
||||
'showAdvanced' => $this->h5pF->t('Show advanced'),
|
||||
'hideAdvanced' => $this->h5pF->t('Hide advanced'),
|
||||
'advancedHelp' => $this->h5pF->t('Include this script on your website if you want dynamic sizing of the embedded content:'),
|
||||
'copyrightInformation' => $this->h5pF->t('Rights of use'),
|
||||
'close' => $this->h5pF->t('Close'),
|
||||
'title' => $this->h5pF->t('Title'),
|
||||
'author' => $this->h5pF->t('Author'),
|
||||
'year' => $this->h5pF->t('Year'),
|
||||
'source' => $this->h5pF->t('Source'),
|
||||
'license' => $this->h5pF->t('License'),
|
||||
'thumbnail' => $this->h5pF->t('Thumbnail'),
|
||||
'noCopyrights' => $this->h5pF->t('No copyright information available for this content.'),
|
||||
'downloadDescription' => $this->h5pF->t('Download this content as a H5P file.'),
|
||||
'copyrightsDescription' => $this->h5pF->t('View copyright information for this content.'),
|
||||
'embedDescription' => $this->h5pF->t('View the embed code for this content.'),
|
||||
'h5pDescription' => $this->h5pF->t('Visit H5P.org to check out more cool content.'),
|
||||
'contentChanged' => $this->h5pF->t('This content has changed since you last used it.'),
|
||||
'startingOver' => $this->h5pF->t("You'll be starting over."),
|
||||
'by' => $this->h5pF->t('by'),
|
||||
'showMore' => $this->h5pF->t('Show more'),
|
||||
'showLess' => $this->h5pF->t('Show less'),
|
||||
'subLevel' => $this->h5pF->t('Sublevel'),
|
||||
'confirmDialogHeader' => $this->h5pF->t('Confirm action'),
|
||||
'confirmDialogBody' => $this->h5pF->t('Please confirm that you wish to proceed. This action is not reversible.'),
|
||||
'cancelLabel' => $this->h5pF->t('Cancel'),
|
||||
'confirmLabel' => $this->h5pF->t('Confirm'),
|
||||
'licenseU' => $this->h5pF->t('Undisclosed'),
|
||||
'licenseCCBY' => $this->h5pF->t('Attribution'),
|
||||
'licenseCCBYSA' => $this->h5pF->t('Attribution-ShareAlike'),
|
||||
'licenseCCBYND' => $this->h5pF->t('Attribution-NoDerivs'),
|
||||
'licenseCCBYNC' => $this->h5pF->t('Attribution-NonCommercial'),
|
||||
'licenseCCBYNCSA' => $this->h5pF->t('Attribution-NonCommercial-ShareAlike'),
|
||||
'licenseCCBYNCND' => $this->h5pF->t('Attribution-NonCommercial-NoDerivs'),
|
||||
'licenseCC40' => $this->h5pF->t('4.0 International'),
|
||||
'licenseCC30' => $this->h5pF->t('3.0 Unported'),
|
||||
'licenseCC25' => $this->h5pF->t('2.5 Generic'),
|
||||
'licenseCC20' => $this->h5pF->t('2.0 Generic'),
|
||||
'licenseCC10' => $this->h5pF->t('1.0 Generic'),
|
||||
'licenseGPL' => $this->h5pF->t('General Public License'),
|
||||
'licenseV3' => $this->h5pF->t('Version 3'),
|
||||
'licenseV2' => $this->h5pF->t('Version 2'),
|
||||
'licenseV1' => $this->h5pF->t('Version 1'),
|
||||
'licensePD' => $this->h5pF->t('Public Domain'),
|
||||
'licenseCC010' => $this->h5pF->t('CC0 1.0 Universal (CC0 1.0) Public Domain Dedication'),
|
||||
'licensePDM' => $this->h5pF->t('Public Domain Mark'),
|
||||
'licenseC' => $this->h5pF->t('Copyright')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3930,6 +3991,29 @@ class H5PContentValidator {
|
|||
static $semantics;
|
||||
|
||||
if ($semantics === NULL) {
|
||||
$cc_versions = array(
|
||||
(object) array(
|
||||
'value' => '4.0',
|
||||
'label' => $this->h5pF->t('4.0 International')
|
||||
),
|
||||
(object) array(
|
||||
'value' => '3.0',
|
||||
'label' => $this->h5pF->t('3.0 Unported')
|
||||
),
|
||||
(object) array(
|
||||
'value' => '2.5',
|
||||
'label' => $this->h5pF->t('2.5 Generic')
|
||||
),
|
||||
(object) array(
|
||||
'value' => '2.0',
|
||||
'label' => $this->h5pF->t('2.0 Generic')
|
||||
),
|
||||
(object) array(
|
||||
'value' => '1.0',
|
||||
'label' => $this->h5pF->t('1.0 Generic')
|
||||
)
|
||||
);
|
||||
|
||||
$semantics = (object) array(
|
||||
'name' => 'copyright',
|
||||
'type' => 'group',
|
||||
|
@ -3979,49 +4063,81 @@ class H5PContentValidator {
|
|||
),
|
||||
(object) array(
|
||||
'value' => 'CC BY',
|
||||
'label' => $this->h5pF->t('Attribution 4.0')
|
||||
'label' => $this->h5pF->t('Attribution'),
|
||||
'versions' => $cc_versions
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC BY-SA',
|
||||
'label' => $this->h5pF->t('Attribution-ShareAlike 4.0')
|
||||
'label' => $this->h5pF->t('Attribution-ShareAlike'),
|
||||
'versions' => $cc_versions
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC BY-ND',
|
||||
'label' => $this->h5pF->t('Attribution-NoDerivs 4.0')
|
||||
'label' => $this->h5pF->t('Attribution-NoDerivs'),
|
||||
'versions' => $cc_versions
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC BY-NC',
|
||||
'label' => $this->h5pF->t('Attribution-NonCommercial 4.0')
|
||||
'label' => $this->h5pF->t('Attribution-NonCommercial'),
|
||||
'versions' => $cc_versions
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC BY-NC-SA',
|
||||
'label' => $this->h5pF->t('Attribution-NonCommercial-ShareAlike 4.0')
|
||||
'label' => $this->h5pF->t('Attribution-NonCommercial-ShareAlike'),
|
||||
'versions' => $cc_versions
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC BY-NC-ND',
|
||||
'label' => $this->h5pF->t('Attribution-NonCommercial-NoDerivs 4.0')
|
||||
'label' => $this->h5pF->t('Attribution-NonCommercial-NoDerivs'),
|
||||
'versions' => $cc_versions
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'GNU GPL',
|
||||
'label' => $this->h5pF->t('General Public License v3')
|
||||
'label' => $this->h5pF->t('General Public License'),
|
||||
'versions' => array(
|
||||
(object) array(
|
||||
'value' => 'v3',
|
||||
'label' => $this->h5pF->t('Version 3')
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'v2',
|
||||
'label' => $this->h5pF->t('Version 2')
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'v1',
|
||||
'label' => $this->h5pF->t('Version 1')
|
||||
)
|
||||
)
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'PD',
|
||||
'label' => $this->h5pF->t('Public Domain')
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'ODC PDDL',
|
||||
'label' => $this->h5pF->t('Public Domain Dedication and Licence')
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC PDM',
|
||||
'label' => $this->h5pF->t('Public Domain Mark')
|
||||
'label' => $this->h5pF->t('Public Domain'),
|
||||
'versions' => array(
|
||||
(object) array(
|
||||
'value' => '-',
|
||||
'label' => '-'
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC0 1.0',
|
||||
'label' => $this->h5pF->t('CC0 1.0 Universal')
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'CC PDM',
|
||||
'label' => $this->h5pF->t('Public Domain Mark')
|
||||
)
|
||||
)
|
||||
),
|
||||
(object) array(
|
||||
'value' => 'C',
|
||||
'label' => $this->h5pF->t('Copyright')
|
||||
)
|
||||
)
|
||||
),
|
||||
(object) array(
|
||||
'name' => 'version',
|
||||
'type' => 'select',
|
||||
'label' => $this->h5pF->t('License Version'),
|
||||
'options' => array()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
166
js/h5p.js
166
js/h5p.js
|
@ -1234,16 +1234,65 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Get humanized value for field.
|
||||
* Get humanized value for the license field.
|
||||
*
|
||||
* @private
|
||||
* @param {string} fieldName
|
||||
* @param {string} value
|
||||
* @param {string} license
|
||||
* @param {string} [version]
|
||||
* @returns {string}
|
||||
*/
|
||||
var humanizeValue = function (fieldName, value) {
|
||||
if (fieldName === 'license') {
|
||||
return H5P.copyrightLicenses[value];
|
||||
var humanizeLicense = function (license, version) {
|
||||
var copyrightLicense = H5P.copyrightLicenses[license];
|
||||
|
||||
// Build license string
|
||||
var value = '';
|
||||
if (!(license === 'PD' && version)) {
|
||||
// Add license label
|
||||
value += (copyrightLicense.hasOwnProperty('label') ? copyrightLicense.label : copyrightLicense);
|
||||
}
|
||||
|
||||
// Check for version info
|
||||
var versionInfo;
|
||||
if (version && copyrightLicense.versions[version]) {
|
||||
versionInfo = copyrightLicense.versions[version];
|
||||
}
|
||||
|
||||
if (versionInfo) {
|
||||
// Add license version
|
||||
if (value) {
|
||||
value += ' ';
|
||||
}
|
||||
value += (versionInfo.hasOwnProperty('label') ? versionInfo.label : versionInfo);
|
||||
}
|
||||
|
||||
// Add link if specified
|
||||
var link;
|
||||
if (copyrightLicense.hasOwnProperty('link')) {
|
||||
link = copyrightLicense.link.replace(':version', copyrightLicense.linkVersions ? copyrightLicense.linkVersions[version] : version);
|
||||
}
|
||||
else if (versionInfo && copyrightLicense.hasOwnProperty('link')) {
|
||||
link = versionInfo.link
|
||||
}
|
||||
if (link) {
|
||||
value = '<a href="' + link + '" target="_blank">' + value + '</a>';
|
||||
}
|
||||
|
||||
// Generate parenthesis
|
||||
var parenthesis = '';
|
||||
if (license !== 'PD' && license !== 'C') {
|
||||
parenthesis += license;
|
||||
}
|
||||
if (version && version !== 'CC0 1.0') {
|
||||
if (parenthesis && license !== 'GNU GPL') {
|
||||
parenthesis += ' ';
|
||||
}
|
||||
parenthesis += version;
|
||||
}
|
||||
if (parenthesis) {
|
||||
value += ' (' + parenthesis + ')';
|
||||
}
|
||||
if (license === 'C') {
|
||||
value += ' ©';
|
||||
}
|
||||
|
||||
return value;
|
||||
|
@ -1265,7 +1314,11 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) {
|
|||
for (var i = 0; i < order.length; i++) {
|
||||
var fieldName = order[i];
|
||||
if (copyright[fieldName] !== undefined) {
|
||||
list.add(new H5P.Field(getLabel(fieldName), humanizeValue(fieldName, copyright[fieldName])));
|
||||
var humanValue = copyright[fieldName];
|
||||
if (fieldName === 'license') {
|
||||
humanValue = humanizeLicense(copyright.license, copyright.version);
|
||||
}
|
||||
list.add(new H5P.Field(getLabel(fieldName), humanValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1288,7 +1341,7 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) {
|
|||
this.undisclosed = function () {
|
||||
if (list.size() === 1) {
|
||||
var field = list.get(0);
|
||||
if (field.getLabel() === getLabel('license') && field.getValue() === humanizeValue('license', 'U')) {
|
||||
if (field.getLabel() === getLabel('license') && field.getValue() === humanizeLicense('U')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1320,26 +1373,6 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) {
|
|||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps copyright license codes to their human readable counterpart.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
H5P.copyrightLicenses = {
|
||||
'U': 'Undisclosed',
|
||||
'CC BY': '<a href="http://creativecommons.org/licenses/by/4.0/legalcode" target="_blank">Attribution 4.0</a>',
|
||||
'CC BY-SA': '<a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode" target="_blank">Attribution-ShareAlike 4.0</a>',
|
||||
'CC BY-ND': '<a href="https://creativecommons.org/licenses/by-nd/4.0/legalcode" target="_blank">Attribution-NoDerivs 4.0</a>',
|
||||
'CC BY-NC': '<a href="https://creativecommons.org/licenses/by-nc/4.0/legalcode" target="_blank">Attribution-NonCommercial 4.0</a>',
|
||||
'CC BY-NC-SA': '<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode" target="_blank">Attribution-NonCommercial-ShareAlike 4.0</a>',
|
||||
'CC BY-NC-ND': '<a href="https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode" target="_blank">Attribution-NonCommercial-NoDerivs 4.0</a>',
|
||||
'GNU GPL': '<a href="http://www.gnu.org/licenses/gpl-3.0-standalone.html" target="_blank">General Public License v3</a>',
|
||||
'PD': 'Public Domain',
|
||||
'ODC PDDL': '<a href="http://opendatacommons.org/licenses/pddl/1.0/" target="_blank">Public Domain Dedication and Licence</a>',
|
||||
'CC PDM': 'Public Domain Mark',
|
||||
'C': 'Copyright'
|
||||
};
|
||||
|
||||
/**
|
||||
* A simple and elegant class for creating thumbnails of images.
|
||||
*
|
||||
|
@ -1978,6 +2011,83 @@ H5P.createTitle = function (rawTitle, maxLength) {
|
|||
// Init H5P when page is fully loadded
|
||||
$(document).ready(function () {
|
||||
|
||||
var ccVersions = {
|
||||
'4.0': H5P.t('licenseCC40'),
|
||||
'3.0': H5P.t('licenseCC30'),
|
||||
'2.5': H5P.t('licenseCC25'),
|
||||
'2.0': H5P.t('licenseCC20'),
|
||||
'1.0': H5P.t('licenseCC10'),
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps copyright license codes to their human readable counterpart.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
H5P.copyrightLicenses = {
|
||||
'U': H5P.t('licenseU'),
|
||||
'CC BY': {
|
||||
label: H5P.t('licenseCCBY'),
|
||||
link: 'http://creativecommons.org/licenses/by/:version/legalcode',
|
||||
versions: ccVersions
|
||||
},
|
||||
'CC BY-SA': {
|
||||
label: H5P.t('licenseCCBYSA'),
|
||||
link: 'http://creativecommons.org/licenses/by-sa/:version/legalcode',
|
||||
versions: ccVersions
|
||||
},
|
||||
'CC BY-ND': {
|
||||
label: H5P.t('licenseCCBYND'),
|
||||
link: 'http://creativecommons.org/licenses/by-nd/:version/legalcode',
|
||||
versions: ccVersions
|
||||
},
|
||||
'CC BY-NC': {
|
||||
label: H5P.t('licenseCCBYNC'),
|
||||
link: 'http://creativecommons.org/licenses/by-nc/:version/legalcode',
|
||||
versions: ccVersions
|
||||
},
|
||||
'CC BY-NC-SA': {
|
||||
label: H5P.t('licenseCCBYNCSA'),
|
||||
link: 'http://creativecommons.org/licenses/by-nc-sa/:version/legalcode',
|
||||
versions: ccVersions
|
||||
},
|
||||
'CC BY-NC-ND': {
|
||||
label: H5P.t('licenseCCBYNCND'),
|
||||
link: 'http://creativecommons.org/licenses/by-nc-nd/:version/legalcode',
|
||||
versions: ccVersions
|
||||
},
|
||||
'GNU GPL': {
|
||||
label: H5P.t('licenseGPL'),
|
||||
link: 'http://www.gnu.org/licenses/gpl-:version-standalone.html',
|
||||
linkVersions: {
|
||||
'v3': '3.0',
|
||||
'v2': '2.0',
|
||||
'v1': '1.0'
|
||||
},
|
||||
versions: {
|
||||
'v3': H5P.t('licenseV3'),
|
||||
'v2': H5P.t('licenseV2'),
|
||||
'v1': H5P.t('licenseV1')
|
||||
}
|
||||
},
|
||||
'PD': {
|
||||
label: H5P.t('licensePD'),
|
||||
versions: {
|
||||
'CC0 1.0': {
|
||||
label: H5P.t('licenseCC010'),
|
||||
link: 'https://creativecommons.org/publicdomain/zero/1.0/'
|
||||
},
|
||||
'CC PDM': {
|
||||
label: H5P.t('licensePDM'),
|
||||
link: 'https://creativecommons.org/publicdomain/mark/1.0/'
|
||||
}
|
||||
}
|
||||
},
|
||||
'ODC PDDL': '<a href="http://opendatacommons.org/licenses/pddl/1.0/" target="_blank">Public Domain Dedication and Licence</a>',
|
||||
'CC PDM': H5P.t('licensePDM'),
|
||||
'C': H5P.t('licenseC'),
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates if H5P is embedded on an external page using iframe.
|
||||
* @member {boolean} H5P.externalEmbed
|
||||
|
|
Loading…
Reference in New Issue