diff --git a/h5p.classes.php b/h5p.classes.php index 77130c3..7bf5cab 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -55,6 +55,13 @@ interface H5PFrameworkInterface { * @return string Path to the last uploaded h5p */ public function getUploadedH5pPath(); + + /** + * Get the list of the current installed libraries + * + * @return array Associative array containg one item per machine name. This item contains an array of libraries. + */ + public function loadLibraries(); /** * Get id to an excisting library @@ -243,9 +250,9 @@ interface H5PFrameworkInterface { /** * Delete a library from database and file system * - * @param int $libraryId Library Id + * @param mixed $library Library */ - public function deleteLibrary($libraryId); + public function deleteLibrary($library); /** * Load content. @@ -1325,7 +1332,7 @@ class H5PCore { * @param array $content * @return int Content ID */ - public function saveContent($content, $contentMainId) { + public function saveContent($content, $contentMainId = NULL) { if (isset($content['id'])) { $this->h5pF->updateContent($content, $contentMainId); } @@ -1333,7 +1340,10 @@ class H5PCore { $content['id'] = $this->h5pF->insertContent($content, $contentMainId); } - $this->h5pF->cacheDel('parameters', $content['id']); + if (!isset($content['filtered'])) { + // TODO: Add filtered to all impl. and remove + $this->h5pF->cacheDel('parameters', $content['id']); + } return $content['id']; } @@ -1382,7 +1392,14 @@ class H5PCore { * @return Object NULL on failure. */ public function filterParameters($content) { - $params = $this->h5pF->cacheGet('parameters', $content['id']); + 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; } diff --git a/js/h5p-library-details.js b/js/h5p-library-details.js index e274d22..73a996f 100644 --- a/js/h5p-library-details.js +++ b/js/h5p-library-details.js @@ -39,20 +39,6 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; $libraryInfo.append(H5PUtils.createLabeledField(title, value)); }); - var count; - if (H5PLibraryDetails.library.notCached !== undefined) { - count = H5PIntegration.i18n.H5P.NA; - } - else if (H5PLibraryDetails.library.content === undefined) { - count = 0; - } - else { - count = H5PLibraryDetails.library.content.length; - } - - // List counter: - $libraryInfo.append(H5PUtils.createLabeledField(H5PLibraryDetails.library.translations.contentCount, count)); - return $libraryInfo; }; diff --git a/js/h5p-library-list.js b/js/h5p-library-list.js index cfadf0d..aeba889 100644 --- a/js/h5p-library-list.js +++ b/js/h5p-library-list.js @@ -38,7 +38,7 @@ var H5PLibraryList= H5PLibraryList || {}; var $libraryRow = H5PUtils.createTableRow([ library.title, library.numContent, - library.numContentDependencies === -1 ? t.NA : library.numContentDependencies, + library.numContentDependencies, library.numLibraryDependencies, '
\ \ @@ -65,7 +65,7 @@ var H5PLibraryList= H5PLibraryList || {}; }); var $deleteButton = $('.h5p-admin-delete-library', $libraryRow); - if (library.numContent !== 0 || library.numContentDependencies !== 0 || library.numLibraryDependencies !== 0) { + if (library.numContent !== '0' || library.numContentDependencies !== '' || library.numLibraryDependencies !== '') { // Disabled delete if content. $deleteButton.attr('disabled', true); } diff --git a/js/h5p-utils.js b/js/h5p-utils.js index d8faf68..3004c95 100644 --- a/js/h5p-utils.js +++ b/js/h5p-utils.js @@ -7,14 +7,20 @@ var H5PUtils = H5PUtils || {}; * @param {array} headers List of headers */ H5PUtils.createTable = function (headers) { - var $table = $('
'); - + var $table = $('
'); + if(headers) { var $thead = $(''); var $tr = $(''); $.each(headers, function (index, value) { - $tr.append('' + value + ''); + if (!(value instanceof Object)) { + value = { + text: value + }; + } + + $('', value).appendTo($tr); }); $table.append($thead.append($tr)); @@ -85,7 +91,7 @@ var H5PUtils = H5PUtils || {}; * @returns {$} */ H5PUtils.getRebuildCache = function (notCached) { - var $container = $('

' + notCached.message + '

'); + var $container = $('

' + notCached.message + '

' + notCached.progress + '

'); var $button = $('').appendTo($container).click(function () { var $spinner = $('
', {class: 'h5p-spinner'}).replaceAll($button); var parts = ['|', '/', '-', '\\']; @@ -96,7 +102,7 @@ var H5PUtils = H5PUtils || {}; if (current === parts.length) current = 0; }, 100); - var $counter = $container.find('.placeholder'); + var $counter = $container.find('.progress'); var build = function () { $.post(notCached.url, function (left) { if (left === '0') { @@ -105,8 +111,9 @@ var H5PUtils = H5PUtils || {}; location.reload(); } else { - var counter = $counter.text().split(' ', 2); - $counter.text(left + ' ' + counter[1]); + var counter = $counter.text().split(' '); + counter[0] = left; + $counter.text(counter.join(' ')); build(); } });