From d1bbed49fceb0dfb6c24495c0ec49cc8a0bbe78b Mon Sep 17 00:00:00 2001 From: thomasmars Date: Mon, 22 May 2017 12:57:43 +0200 Subject: [PATCH 1/8] Don't assume fetchLibrariesMetadata is AJAX HFP-1103 --- h5p.classes.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 2661a43..95f1778 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2456,10 +2456,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 +2502,7 @@ class H5PCore { // No data received if (!$result || empty($result)) { - return; + return FALSE; } // Handle libraries metadata From 0ce7d66c3a053706842668745bb1205b8cab847f Mon Sep 17 00:00:00 2001 From: thomasmars Date: Thu, 25 May 2017 13:52:50 +0200 Subject: [PATCH 2/8] Cast bytes to int before multiplying it. Removes warning in PHP 7.0+ --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 95f1778..6a0799c 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2969,7 +2969,7 @@ class H5PCore { * @return int|string */ public static function returnBytes($val) { - $val = trim($val); + $val = (int) trim($val); $last = strtolower($val[strlen($val) - 1]); switch ($last) { case 'g': From fa31c56dce89abb6d2ee00e37c219d02671ae47c Mon Sep 17 00:00:00 2001 From: thomasmars Date: Mon, 29 May 2017 11:18:12 +0200 Subject: [PATCH 3/8] Fixed returnBytes function return correct amount of bytes --- h5p.classes.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 6a0799c..d39393d 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2969,18 +2969,20 @@ class H5PCore { * @return int|string */ public static function returnBytes($val) { - $val = (int) trim($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; } /** From 42e0c99fd31625115bc89f7c105c7e8d167515b0 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 30 May 2017 14:12:22 +0200 Subject: [PATCH 4/8] Add version info to license HFP-1079 --- h5p.classes.php | 87 ++++++++++++++++++++----- js/h5p.js | 170 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 214 insertions(+), 43 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index d39393d..61f6be2 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3928,6 +3928,29 @@ class H5PContentValidator { static $semantics; if ($semantics === NULL) { + $cc_versions = array( + (object) array( + 'value' => '4.0', + 'label' => '4.0 International' + ), + (object) array( + 'value' => '3.0', + 'label' => '3.0 Unported' + ), + (object) array( + 'value' => '2.5', + 'label' => '2.5 Generic' + ), + (object) array( + 'value' => '2.0', + 'label' => '2.0 Generic' + ), + (object) array( + 'value' => '1.0', + 'label' => '1.0 Generic' + ) + ); + $semantics = (object) array( 'name' => 'copyright', 'type' => 'group', @@ -3977,49 +4000,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' => 'Version 3' + ), + (object) array( + 'value' => 'v2', + 'label' => 'Version 2' + ), + (object) array( + 'value' => 'v1', + 'label' => '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' => 'CC0 1.0 Universal' + ), + (object) array( + 'value' => 'CC PDM', + 'label' => '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() ) ) ); diff --git a/js/h5p.js b/js/h5p.js index 36e2709..25119ef 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1245,16 +1245,68 @@ 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]; + if (copyrightLicense.label === undefined) { + return copyrightLicense; + } + + // Build license string + var value = ''; + if (!(license === 'PD' && version)) { + // Add license label + value += (copyrightLicense.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.label ? versionInfo.label : versionInfo); + } + + // Add link if specified + var link; + if (copyrightLicense.link) { + link = copyrightLicense.link.replace(':version', copyrightLicense.linkVersions ? copyrightLicense.linkVersions[version] : version); + } + else if (versionInfo && versionInfo.link) { + link = versionInfo.link + } + if (link) { + value = '' + value + ''; + } + + // 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; @@ -1276,7 +1328,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)); } } } @@ -1299,7 +1355,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; } } @@ -1331,25 +1387,85 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { }; }; -/** - * Maps copyright license codes to their human readable counterpart. - * - * @type {Object} - */ -H5P.copyrightLicenses = { - 'U': 'Undisclosed', - 'CC BY': 'Attribution 4.0', - 'CC BY-SA': 'Attribution-ShareAlike 4.0', - 'CC BY-ND': 'Attribution-NoDerivs 4.0', - 'CC BY-NC': 'Attribution-NonCommercial 4.0', - 'CC BY-NC-SA': 'Attribution-NonCommercial-ShareAlike 4.0', - 'CC BY-NC-ND': 'Attribution-NonCommercial-NoDerivs 4.0', - 'GNU GPL': 'General Public License v3', - 'PD': 'Public Domain', - 'ODC PDDL': 'Public Domain Dedication and Licence', - 'CC PDM': 'Public Domain Mark', - 'C': 'Copyright' -}; +(function () { + var ccVersions = { + '4.0': '4.0 International', + '3.0': '3.0 Unported', + '2.5': '2.5 Generic', + '2.0': '2.0 Generic', + '1.0': '1.0 Generic' + }; + + /** + * Maps copyright license codes to their human readable counterpart. + * + * @type {Object} + */ + H5P.copyrightLicenses = { + 'U': 'Undisclosed', + 'CC BY': { + label: 'Attribution', + link: 'http://creativecommons.org/licenses/by/:version/legalcode', + versions: ccVersions + }, + 'CC BY-SA': { + label: 'Attribution-ShareAlike', + link: 'http://creativecommons.org/licenses/by-sa/:version/legalcode', + versions: ccVersions + }, + 'CC BY-ND': { + label: 'Attribution-NoDerivs', + link: 'http://creativecommons.org/licenses/by-nd/:version/legalcode', + versions: ccVersions + }, + 'CC BY-NC': { + label: 'Attribution-NonCommercial', + link: 'http://creativecommons.org/licenses/by-nc/:version/legalcode', + versions: ccVersions + }, + 'CC BY-NC-SA': { + label: 'Attribution-NonCommercial-ShareAlike', + link: 'http://creativecommons.org/licenses/by-nc-sa/:version/legalcode', + versions: ccVersions + }, + 'CC BY-NC-ND': { + label: 'Attribution-NonCommercial-NoDerivs', + link: 'http://creativecommons.org/licenses/by-nc-nd/:version/legalcode', + versions: ccVersions + }, + 'GNU GPL': { + label: 'General Public License', + link: 'http://www.gnu.org/licenses/gpl-:version-standalone.html', + linkVersions: { + 'v3': '3.0', + 'v2': '2.0', + 'v1': '1.0' + }, + versions: { + 'v3': 'Version 3', + 'v2': 'Version 2', + 'v1': 'Version 1' + } + }, + 'PD': { + label: 'Public Domain', + versions: { + 'CC0 1.0': { + label: 'CC0 1.0 Universal (CC0 1.0) Public Domain Dedication', + link: 'https://creativecommons.org/publicdomain/zero/1.0/' + }, + 'CC PDM': { + label: 'Public Domain Mark', + link: 'https://creativecommons.org/publicdomain/mark/1.0/' + } + } + }, + 'ODC PDDL': 'Public Domain Dedication and Licence', + 'CC PDM': 'Public Domain Mark', + 'C': 'Copyright' + }; + +})(); /** * A simple and elegant class for creating thumbnails of images. From 59fd08594f5c2c86570073fa8b5c7567e4dfa9ad Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 30 May 2017 15:23:25 +0200 Subject: [PATCH 5/8] Support localized licenses HFP-1079 --- h5p.classes.php | 81 +++++++++++++++++++++++++++++++++++++++++++------ js/h5p.js | 42 ++++++++++++------------- 2 files changed, 92 insertions(+), 31 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 61f6be2..d325e3d 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3007,6 +3007,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'), + 'licensePDM' => $this->h5pF->t('Public Domain Mark'), + 'licenseC' => $this->h5pF->t('Copyright') + ); + } } /** @@ -3931,23 +3992,23 @@ class H5PContentValidator { $cc_versions = array( (object) array( 'value' => '4.0', - 'label' => '4.0 International' + 'label' => $this->h5pF->t('4.0 International') ), (object) array( 'value' => '3.0', - 'label' => '3.0 Unported' + 'label' => $this->h5pF->t('3.0 Unported') ), (object) array( 'value' => '2.5', - 'label' => '2.5 Generic' + 'label' => $this->h5pF->t('2.5 Generic') ), (object) array( 'value' => '2.0', - 'label' => '2.0 Generic' + 'label' => $this->h5pF->t('2.0 Generic') ), (object) array( 'value' => '1.0', - 'label' => '1.0 Generic' + 'label' => $this->h5pF->t('1.0 Generic') ) ); @@ -4034,15 +4095,15 @@ class H5PContentValidator { 'versions' => array( (object) array( 'value' => 'v3', - 'label' => 'Version 3' + 'label' => $this->h5pF->t('Version 3') ), (object) array( 'value' => 'v2', - 'label' => 'Version 2' + 'label' => $this->h5pF->t('Version 2') ), (object) array( 'value' => 'v1', - 'label' => 'Version 1' + 'label' => $this->h5pF->t('Version 1') ) ) ), @@ -4056,11 +4117,11 @@ class H5PContentValidator { ), (object) array( 'value' => 'CC0 1.0', - 'label' => 'CC0 1.0 Universal' + 'label' => $this->h5pF->t('CC0 1.0 Universal') ), (object) array( 'value' => 'CC PDM', - 'label' => 'Public Domain Mark' + 'label' => $this->h5pF->t('Public Domain Mark') ) ) ), diff --git a/js/h5p.js b/js/h5p.js index 25119ef..22b5de5 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1389,11 +1389,11 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { (function () { var ccVersions = { - '4.0': '4.0 International', - '3.0': '3.0 Unported', - '2.5': '2.5 Generic', - '2.0': '2.0 Generic', - '1.0': '1.0 Generic' + '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'), }; /** @@ -1402,39 +1402,39 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { * @type {Object} */ H5P.copyrightLicenses = { - 'U': 'Undisclosed', + 'U': H5P.t('licenseU'), 'CC BY': { - label: 'Attribution', + label: H5P.t('licenseCCBY'), link: 'http://creativecommons.org/licenses/by/:version/legalcode', versions: ccVersions }, 'CC BY-SA': { - label: 'Attribution-ShareAlike', + label: H5P.t('licenseCCBYSA'), link: 'http://creativecommons.org/licenses/by-sa/:version/legalcode', versions: ccVersions }, 'CC BY-ND': { - label: 'Attribution-NoDerivs', + label: H5P.t('licenseCCBYND'), link: 'http://creativecommons.org/licenses/by-nd/:version/legalcode', versions: ccVersions }, 'CC BY-NC': { - label: 'Attribution-NonCommercial', + label: H5P.t('licenseCCBYNC'), link: 'http://creativecommons.org/licenses/by-nc/:version/legalcode', versions: ccVersions }, 'CC BY-NC-SA': { - label: 'Attribution-NonCommercial-ShareAlike', + label: H5P.t('licenseCCBYNCSA'), link: 'http://creativecommons.org/licenses/by-nc-sa/:version/legalcode', versions: ccVersions }, 'CC BY-NC-ND': { - label: 'Attribution-NonCommercial-NoDerivs', + label: H5P.t('licenseCCBYNCND'), link: 'http://creativecommons.org/licenses/by-nc-nd/:version/legalcode', versions: ccVersions }, 'GNU GPL': { - label: 'General Public License', + label: H5P.t('licenseGPL'), link: 'http://www.gnu.org/licenses/gpl-:version-standalone.html', linkVersions: { 'v3': '3.0', @@ -1442,27 +1442,27 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { 'v1': '1.0' }, versions: { - 'v3': 'Version 3', - 'v2': 'Version 2', - 'v1': 'Version 1' + 'v3': H5P.t('licenseV3'), + 'v2': H5P.t('licenseV2'), + 'v1': H5P.t('licenseV1') } }, 'PD': { - label: 'Public Domain', + label: H5P.t('licensePD'), versions: { 'CC0 1.0': { - label: 'CC0 1.0 Universal (CC0 1.0) Public Domain Dedication', + label: H5P.t('licenseCC010'), link: 'https://creativecommons.org/publicdomain/zero/1.0/' }, 'CC PDM': { - label: 'Public Domain Mark', + label: H5P.t('licensePDM'), link: 'https://creativecommons.org/publicdomain/mark/1.0/' } } }, 'ODC PDDL': 'Public Domain Dedication and Licence', - 'CC PDM': 'Public Domain Mark', - 'C': 'Copyright' + 'CC PDM': H5P.t('licensePDM'), + 'C': H5P.t('licenseC'), }; })(); From 9adc92d3c4d7bd68017edb7221e1ebf2940178c1 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 30 May 2017 15:43:26 +0200 Subject: [PATCH 6/8] Move license definition for localization to work HFP-1079 --- h5p.classes.php | 2 +- js/h5p.js | 157 ++++++++++++++++++++++++------------------------ 2 files changed, 78 insertions(+), 81 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index d325e3d..1715071 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3063,7 +3063,7 @@ class H5PCore { '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'), + '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') ); diff --git a/js/h5p.js b/js/h5p.js index 22b5de5..1b460c4 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1387,86 +1387,6 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { }; }; -(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': 'Public Domain Dedication and Licence', - 'CC PDM': H5P.t('licensePDM'), - 'C': H5P.t('licenseC'), - }; - -})(); - /** * A simple and elegant class for creating thumbnails of images. * @@ -2105,6 +2025,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': 'Public Domain Dedication and Licence', + 'CC PDM': H5P.t('licensePDM'), + 'C': H5P.t('licenseC'), + }; + /** * Indicates if H5P is embedded on an external page using iframe. * @member {boolean} H5P.externalEmbed From aaa08613554c4e86740567264db2aa1141947e10 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Wed, 31 May 2017 09:33:10 +0200 Subject: [PATCH 7/8] Fix copyright not being display processes correctly HFP-1079 --- js/h5p.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index 1b460c4..9c0846b 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1254,15 +1254,12 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { */ var humanizeLicense = function (license, version) { var copyrightLicense = H5P.copyrightLicenses[license]; - if (copyrightLicense.label === undefined) { - return copyrightLicense; - } // Build license string var value = ''; if (!(license === 'PD' && version)) { // Add license label - value += (copyrightLicense.label ? copyrightLicense.label : copyrightLicense); + value += (copyrightLicense.hasOwnProperty('label') ? copyrightLicense.label : copyrightLicense); } // Check for version info @@ -1276,15 +1273,15 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { if (value) { value += ' '; } - value += (versionInfo.label ? versionInfo.label : versionInfo); + value += (versionInfo.hasOwnProperty('label') ? versionInfo.label : versionInfo); } // Add link if specified var link; - if (copyrightLicense.link) { + if (copyrightLicense.hasOwnProperty('link')) { link = copyrightLicense.link.replace(':version', copyrightLicense.linkVersions ? copyrightLicense.linkVersions[version] : version); } - else if (versionInfo && versionInfo.link) { + else if (versionInfo && copyrightLicense.hasOwnProperty('link')) { link = versionInfo.link } if (link) { From 46d772cb511cf4fc6deaaf398d52aed8031b986f Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Wed, 31 May 2017 11:17:28 +0200 Subject: [PATCH 8/8] Added missing parameter in getLibraryUsage [HFP-1067] --- h5p.classes.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 1715071..32aeb38 100644 --- a/h5p.classes.php +++ b/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