Merge branch 'master' of github.com:h5p/h5p-php-library
commit
acd3aa2dba
BIN
fonts/h5p.woff
BIN
fonts/h5p.woff
Binary file not shown.
|
@ -14,7 +14,7 @@ interface H5PFrameworkInterface {
|
|||
* - h5pVersion: The version of the H5P plugin/module
|
||||
*/
|
||||
public function getPlatformInfo();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetches a file from a remote server using HTTP GET
|
||||
|
@ -1487,8 +1487,6 @@ Class H5PExport {
|
|||
// Build h5p.json
|
||||
$h5pJson = array (
|
||||
'title' => $content['title'],
|
||||
// TODO - stop using 'und', this is not the preferred way.
|
||||
// Either remove language from the json if not existing, or use "language": null
|
||||
'language' => (isset($content['language']) && strlen(trim($content['language'])) !== 0) ? $content['language'] : 'und',
|
||||
'mainLibrary' => $content['library']['name'],
|
||||
'embedTypes' => $embedTypes,
|
||||
|
@ -1519,28 +1517,52 @@ Class H5PExport {
|
|||
$results = print_r(json_encode($h5pJson), true);
|
||||
file_put_contents($tempPath . DIRECTORY_SEPARATOR . 'h5p.json', $results);
|
||||
|
||||
// Get a complete file list from our tmp dir
|
||||
$files = array();
|
||||
self::populateFileList($tempPath, $files);
|
||||
|
||||
// Create new zip instance.
|
||||
$zip = new ZipArchive();
|
||||
$zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
|
||||
|
||||
// Get all files and folders in $tempPath
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tempPath . DIRECTORY_SEPARATOR));
|
||||
// Add files to zip
|
||||
foreach ($iterator as $key => $value) {
|
||||
$test = '.';
|
||||
// Do not add the folders '.' and '..' to the zip. This will make zip invalid.
|
||||
if (substr_compare($key, $test, -strlen($test), strlen($test)) !== 0) {
|
||||
// Get files path in $tempPath
|
||||
$filePath = explode($tempPath . DIRECTORY_SEPARATOR, $key);
|
||||
// Add files to the zip with the intended file-structure
|
||||
$zip->addFile($key, $filePath[1]);
|
||||
}
|
||||
// Add all the files from the tmp dir.
|
||||
foreach ($files as $file) {
|
||||
// Please note that the zip format has no concept of folders, we must
|
||||
// use forward slashes to separate our directories.
|
||||
$zip->addFile($file->absolutePath, $file->relativePath);
|
||||
}
|
||||
|
||||
// Close zip and remove temp dir
|
||||
$zip->close();
|
||||
H5PCore::deleteFileTree($tempPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive function the will add the files of the given directory to the
|
||||
* given files list. All files are objects with an absolute path and
|
||||
* a relative path. The relative path is forward slashes only! Great for
|
||||
* use in zip files and URLs.
|
||||
*
|
||||
* @param string $dir path
|
||||
* @param array $files list
|
||||
* @param string $relative prefix. Optional
|
||||
*/
|
||||
private static function populateFileList($dir, &$files, $relative = '') {
|
||||
$strip = strlen($dir) + 1;
|
||||
foreach (glob($dir . DIRECTORY_SEPARATOR . '*') as $file) {
|
||||
$rel = $relative . substr($file, $strip);
|
||||
if (is_dir($file)) {
|
||||
self::populateFileList($file, $files, $rel . '/');
|
||||
}
|
||||
else {
|
||||
$files[] = (object) array(
|
||||
'absolutePath' => $file,
|
||||
'relativePath' => $rel
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete .h5p file
|
||||
*
|
||||
|
@ -1717,8 +1739,6 @@ class H5PCore {
|
|||
// Recreate export file
|
||||
$exporter = new H5PExport($this->h5pF, $this);
|
||||
$exporter->createExportFile($content);
|
||||
|
||||
// TODO: Should we rather create the file once first accessed, like imagecache?
|
||||
}
|
||||
|
||||
// Cache.
|
||||
|
@ -2223,8 +2243,6 @@ class H5PCore {
|
|||
/**
|
||||
* Helper function for creating markup for the unsupported libraries list
|
||||
*
|
||||
* TODO: Make help text translatable
|
||||
*
|
||||
* @return string Html
|
||||
* */
|
||||
public function createMarkupForUnsupportedLibraryList($libraries) {
|
||||
|
@ -2325,7 +2343,6 @@ class H5PContentValidator {
|
|||
|
||||
// Keep track of the libraries we load to avoid loading it multiple times.
|
||||
$this->libraries = array();
|
||||
// TODO: Should this possible be done in core's loadLibrary? This might be done multiple places.
|
||||
|
||||
// Keep track of all dependencies for the given content.
|
||||
$this->dependencies = array();
|
||||
|
|
|
@ -32,8 +32,9 @@ var H5PDataView = (function ($) {
|
|||
* search in column 2.
|
||||
* @param {Function} loaded
|
||||
* Callback for when data has been loaded.
|
||||
* @param {Object} order
|
||||
*/
|
||||
function H5PDataView(container, source, headers, l10n, classes, filters, loaded) {
|
||||
function H5PDataView(container, source, headers, l10n, classes, filters, loaded, order) {
|
||||
var self = this;
|
||||
|
||||
self.$container = $(container).addClass('h5p-data-view').html('');
|
||||
|
@ -44,6 +45,7 @@ var H5PDataView = (function ($) {
|
|||
self.classes = (classes === undefined ? {} : classes);
|
||||
self.filters = (filters === undefined ? [] : filters);
|
||||
self.loaded = loaded;
|
||||
self.order = order;
|
||||
|
||||
self.limit = 20;
|
||||
self.offset = 0;
|
||||
|
@ -68,8 +70,8 @@ var H5PDataView = (function ($) {
|
|||
url += (url.indexOf('?') === -1 ? '?' : '&') + 'offset=' + self.offset + '&limit=' + self.limit;
|
||||
|
||||
// Add sorting
|
||||
if (self.sortBy !== undefined && self.sortDir !== undefined) {
|
||||
url += '&sortBy=' + self.sortBy + '&sortDir=' + self.sortDir;
|
||||
if (self.order !== undefined) {
|
||||
url += '&sortBy=' + self.order.by + '&sortDir=' + self.order.dir;
|
||||
}
|
||||
|
||||
// Add filters
|
||||
|
@ -144,12 +146,11 @@ var H5PDataView = (function ($) {
|
|||
|
||||
// Create new table
|
||||
self.table = new H5PUtils.Table(self.classes, self.headers);
|
||||
self.table.setHeaders(self.headers, function (col, dir) {
|
||||
// Sorting column or direction has changed callback.
|
||||
self.sortBy = col;
|
||||
self.sortDir = dir;
|
||||
self.table.setHeaders(self.headers, function (order) {
|
||||
// Sorting column or direction has changed.
|
||||
self.order = order;
|
||||
self.loadData();
|
||||
});
|
||||
}, self.order);
|
||||
self.table.appendTo(self.$container);
|
||||
}
|
||||
|
||||
|
|
|
@ -182,18 +182,30 @@ var H5PUtils = H5PUtils || {};
|
|||
if (sortByCol !== undefined && col.sortable === true) {
|
||||
// Make sortable
|
||||
options.role = 'button';
|
||||
options.tabIndex = 1;
|
||||
options.tabIndex = 0;
|
||||
|
||||
// This is the first sortable column, use as default sort
|
||||
if (sortCol === undefined) {
|
||||
sortCol = id;
|
||||
sortDir = 0;
|
||||
}
|
||||
|
||||
// This is the sort column
|
||||
if (sortCol === id) {
|
||||
options['class'] = 'h5p-sort';
|
||||
if (sortDir === 1) {
|
||||
options['class'] += ' h5p-reverse';
|
||||
}
|
||||
}
|
||||
|
||||
options.on.click = function () {
|
||||
sort($th, id);
|
||||
};
|
||||
options.on.keypress = function (event) {
|
||||
if ((event.charCode || event.keyCode) === 32) { // Space
|
||||
sort($th, id);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +244,10 @@ var H5PUtils = H5PUtils || {};
|
|||
sortDir = 0;
|
||||
}
|
||||
|
||||
sortByCol(sortCol, sortDir);
|
||||
sortByCol({
|
||||
by: sortCol,
|
||||
dir: sortDir
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -244,11 +259,17 @@ var H5PUtils = H5PUtils || {};
|
|||
* "text" and "sortable". E.g.
|
||||
* [{text: 'Col 1', sortable: true}, 'Col 2', 'Col 3']
|
||||
* @param {Function} sort Callback which is runned when sorting changes
|
||||
* @param {Object} [order]
|
||||
*/
|
||||
this.setHeaders = function (cols, sort) {
|
||||
this.setHeaders = function (cols, sort, order) {
|
||||
numCols = cols.length;
|
||||
sortByCol = sort;
|
||||
|
||||
if (order) {
|
||||
sortCol = order.by;
|
||||
sortDir = order.dir;
|
||||
}
|
||||
|
||||
// Create new head
|
||||
var $newThead = $('<thead/>');
|
||||
var $tr = $('<tr/>').appendTo($newThead);
|
||||
|
|
|
@ -33,8 +33,6 @@ else if (document.documentElement.msRequestFullscreen) {
|
|||
// Keep track of when the H5Ps where started
|
||||
H5P.opened = {};
|
||||
|
||||
H5P.canHasFullScreen = (H5P.isFramed && H5P.externalEmbed !== false) ? (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) : true;
|
||||
|
||||
/**
|
||||
* Initialize H5P content.
|
||||
* Scans for ".h5p-content" in the document and initializes H5P instances where found.
|
||||
|
@ -45,6 +43,11 @@ H5P.init = function (target) {
|
|||
H5P.$body = H5P.jQuery(document.body);
|
||||
}
|
||||
|
||||
// Determine if we can use full screen
|
||||
if (H5P.canHasFullScreen === undefined) {
|
||||
H5P.canHasFullScreen = (H5P.isFramed && H5P.externalEmbed !== false) ? (document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled) : true;
|
||||
}
|
||||
|
||||
// H5Ps added in normal DIV.
|
||||
var $containers = H5P.jQuery('.h5p-content:not(.h5p-initialized)', target).each(function () {
|
||||
var $element = H5P.jQuery(this).addClass('h5p-initialized');
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue