Merge branch 'master' of github.com:h5p/h5p-php-library

namespaces
Frode Petterson 2014-08-22 12:00:56 +02:00
commit ffaad3b20b
4 changed files with 38 additions and 28 deletions

View File

@ -55,6 +55,13 @@ interface H5PFrameworkInterface {
* @return string Path to the last uploaded h5p * @return string Path to the last uploaded h5p
*/ */
public function getUploadedH5pPath(); 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 * Get id to an excisting library
@ -243,9 +250,9 @@ interface H5PFrameworkInterface {
/** /**
* Delete a library from database and file system * 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. * Load content.
@ -1325,7 +1332,7 @@ class H5PCore {
* @param array $content * @param array $content
* @return int Content ID * @return int Content ID
*/ */
public function saveContent($content, $contentMainId) { public function saveContent($content, $contentMainId = NULL) {
if (isset($content['id'])) { if (isset($content['id'])) {
$this->h5pF->updateContent($content, $contentMainId); $this->h5pF->updateContent($content, $contentMainId);
} }
@ -1333,7 +1340,10 @@ class H5PCore {
$content['id'] = $this->h5pF->insertContent($content, $contentMainId); $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']; return $content['id'];
} }
@ -1382,7 +1392,14 @@ class H5PCore {
* @return Object NULL on failure. * @return Object NULL on failure.
*/ */
public function filterParameters($content) { 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) { if ($params !== NULL) {
return $params; return $params;
} }

View File

@ -39,20 +39,6 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
$libraryInfo.append(H5PUtils.createLabeledField(title, value)); $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; return $libraryInfo;
}; };

View File

@ -38,7 +38,7 @@ var H5PLibraryList= H5PLibraryList || {};
var $libraryRow = H5PUtils.createTableRow([ var $libraryRow = H5PUtils.createTableRow([
library.title, library.title,
library.numContent, library.numContent,
library.numContentDependencies === -1 ? t.NA : library.numContentDependencies, library.numContentDependencies,
library.numLibraryDependencies, library.numLibraryDependencies,
'<div class="h5p-admin-buttons-wrapper">\ '<div class="h5p-admin-buttons-wrapper">\
<button class="h5p-admin-upgrade-library"></button>\ <button class="h5p-admin-upgrade-library"></button>\
@ -65,7 +65,7 @@ var H5PLibraryList= H5PLibraryList || {};
}); });
var $deleteButton = $('.h5p-admin-delete-library', $libraryRow); 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. // Disabled delete if content.
$deleteButton.attr('disabled', true); $deleteButton.attr('disabled', true);
} }

View File

@ -7,14 +7,20 @@ var H5PUtils = H5PUtils || {};
* @param {array} headers List of headers * @param {array} headers List of headers
*/ */
H5PUtils.createTable = function (headers) { H5PUtils.createTable = function (headers) {
var $table = $('<table class="h5p-admin-table"></table>'); var $table = $('<table class="h5p-admin-table' + (H5PIntegration.extraTableClasses !== undefined ? ' ' + H5PIntegration.extraTableClasses : '') + '"></table>');
if(headers) { if(headers) {
var $thead = $('<thead></thead>'); var $thead = $('<thead></thead>');
var $tr = $('<tr></tr>'); var $tr = $('<tr></tr>');
$.each(headers, function (index, value) { $.each(headers, function (index, value) {
$tr.append('<th>' + value + '</th>'); if (!(value instanceof Object)) {
value = {
text: value
};
}
$('<th/>', value).appendTo($tr);
}); });
$table.append($thead.append($tr)); $table.append($thead.append($tr));
@ -85,7 +91,7 @@ var H5PUtils = H5PUtils || {};
* @returns {$} * @returns {$}
*/ */
H5PUtils.getRebuildCache = function (notCached) { H5PUtils.getRebuildCache = function (notCached) {
var $container = $('<div class="h5p-admin-rebuild-cache"><p>' + notCached.message + '</p></div>'); var $container = $('<div class="h5p-admin-rebuild-cache"><p class="message">' + notCached.message + '</p><p class="progress">' + notCached.progress + '</p></div>');
var $button = $('<button>' + notCached.button + '</button>').appendTo($container).click(function () { var $button = $('<button>' + notCached.button + '</button>').appendTo($container).click(function () {
var $spinner = $('<div/>', {class: 'h5p-spinner'}).replaceAll($button); var $spinner = $('<div/>', {class: 'h5p-spinner'}).replaceAll($button);
var parts = ['|', '/', '-', '\\']; var parts = ['|', '/', '-', '\\'];
@ -96,7 +102,7 @@ var H5PUtils = H5PUtils || {};
if (current === parts.length) current = 0; if (current === parts.length) current = 0;
}, 100); }, 100);
var $counter = $container.find('.placeholder'); var $counter = $container.find('.progress');
var build = function () { var build = function () {
$.post(notCached.url, function (left) { $.post(notCached.url, function (left) {
if (left === '0') { if (left === '0') {
@ -105,8 +111,9 @@ var H5PUtils = H5PUtils || {};
location.reload(); location.reload();
} }
else { else {
var counter = $counter.text().split(' ', 2); var counter = $counter.text().split(' ');
$counter.text(left + ' ' + counter[1]); counter[0] = left;
$counter.text(counter.join(' '));
build(); build();
} }
}); });