Compare commits

...

12 Commits
master ... d6

Author SHA1 Message Date
Frode Petterson 419aed308a Merged in url fixes. 2015-04-20 13:53:38 +02:00
Frode Petterson 8ed7e39ddf Merge branch 'no-url-fopen' into d6 2015-03-23 10:00:05 +01:00
Frode Petterson 9672986112 Merge branch 'settings' into d6
Conflicts:
	h5p.classes.php
	js/h5p.js
2015-03-20 13:52:57 +01:00
Frode Petterson 2b1c894307 Merge branch 'master' into settings
Conflicts:
	h5p.classes.php
2015-02-19 15:50:04 +01:00
Frode Petterson 9fc5f82b2f Fixed empty frame. 2015-02-12 11:52:55 +01:00
Frode Petterson fb77a4d20d bugfix. 2015-02-10 16:40:23 +01:00
Frode Petterson c764d13b32 Moved display options helpers into core. 2015-02-10 16:29:16 +01:00
Frode Petterson 3c712193b3 Merge branch 'master' into settings
Conflicts:
	styles/h5p.css
2015-02-09 15:25:09 +01:00
Frode Petterson 21674d31ac Merge branch 'master' into settings
Conflicts:
	js/h5p.js
2015-02-04 09:32:03 +01:00
Frode Petterson 0d874e11f8 Merge branch 'whitelist' into settings 2014-10-28 10:05:38 +01:00
Frode Petterson 6c38bfe38c Merge branch 'whitelist' into settings 2014-10-23 15:31:34 +02:00
Frode Petterson 2636ddc393 Make it easy to disable generic content features. 2014-10-23 14:02:34 +02:00
5 changed files with 141 additions and 24 deletions

View File

@ -9,7 +9,7 @@ class H5PDevelopment {
const MODE_CONTENT = 1; const MODE_CONTENT = 1;
const MODE_LIBRARY = 2; const MODE_LIBRARY = 2;
private $h5pF, $libraries, $language; private $h5pF, $libraries, $language, $filesPath;
/** /**
* Constructor. * Constructor.
@ -23,6 +23,7 @@ class H5PDevelopment {
public function __construct($H5PFramework, $filesPath, $language, $libraries = NULL) { public function __construct($H5PFramework, $filesPath, $language, $libraries = NULL) {
$this->h5pF = $H5PFramework; $this->h5pF = $H5PFramework;
$this->language = $language; $this->language = $language;
$this->filesPath = $filesPath;
if ($libraries !== NULL) { if ($libraries !== NULL) {
$this->libraries = $libraries; $this->libraries = $libraries;
} }
@ -86,7 +87,7 @@ class H5PDevelopment {
$library['libraryId'] = $this->h5pF->getLibraryId($library['machineName'], $library['majorVersion'], $library['minorVersion']); $library['libraryId'] = $this->h5pF->getLibraryId($library['machineName'], $library['majorVersion'], $library['minorVersion']);
$this->h5pF->saveLibraryData($library, $library['libraryId'] === FALSE); $this->h5pF->saveLibraryData($library, $library['libraryId'] === FALSE);
$library['path'] = $libraryPath; $library['path'] = 'development/' . $contents[$i];
$this->libraries[H5PDevelopment::libraryToString($library['machineName'], $library['majorVersion'], $library['minorVersion'])] = $library; $this->libraries[H5PDevelopment::libraryToString($library['machineName'], $library['majorVersion'], $library['minorVersion'])] = $library;
} }
@ -144,7 +145,7 @@ class H5PDevelopment {
return NULL; return NULL;
} }
return $this->getFileContents($this->libraries[$library]['path'] . '/semantics.json'); return $this->getFileContents($this->filesPath . $this->libraries[$library]['path'] . '/semantics.json');
} }
/** /**
@ -162,7 +163,7 @@ class H5PDevelopment {
return NULL; return NULL;
} }
return $this->getFileContents($this->libraries[$library]['path'] . '/language/' . $language . '.json'); return $this->getFileContents($this->filesPath . $this->libraries[$library]['path'] . '/language/' . $language . '.json');
} }
/** /**

View File

@ -15,7 +15,6 @@ interface H5PFrameworkInterface {
*/ */
public function getPlatformInfo(); public function getPlatformInfo();
/** /**
* Fetches a file from a remote server using HTTP GET * Fetches a file from a remote server using HTTP GET
* *
@ -1494,7 +1493,7 @@ Class H5PExport {
$library = $dependency['library']; $library = $dependency['library'];
// Copy library to h5p // Copy library to h5p
$source = isset($library['path']) ? $library['path'] : $h5pDir . 'libraries' . DIRECTORY_SEPARATOR . H5PCore::libraryToString($library, TRUE); $source = $h5pDir . (isset($library['path']) ? $library['path'] : 'libraries' . DIRECTORY_SEPARATOR . H5PCore::libraryToString($library, TRUE));
$destination = $tempPath . DIRECTORY_SEPARATOR . $library['machineName']; $destination = $tempPath . DIRECTORY_SEPARATOR . $library['machineName'];
$this->h5pC->copyFileTree($source, $destination); $this->h5pC->copyFileTree($source, $destination);
@ -1602,6 +1601,22 @@ class H5PCore {
private $exportEnabled; private $exportEnabled;
// Disable flags
const DISABLE_NONE = 0;
const DISABLE_FRAME = 1;
const DISABLE_DOWNLOAD = 2;
const DISABLE_EMBED = 4;
const DISABLE_COPYRIGHT = 8;
const DISABLE_ABOUT = 16;
// Map flags to string
public static $disable = array(
self::DISABLE_FRAME => 'frame',
self::DISABLE_DOWNLOAD => 'download',
self::DISABLE_EMBED => 'embed',
self::DISABLE_COPYRIGHT => 'copyright'
);
/** /**
* Constructor for the H5PCore * Constructor for the H5PCore
* *
@ -1622,7 +1637,7 @@ class H5PCore {
$this->development_mode = $development_mode; $this->development_mode = $development_mode;
if ($development_mode & H5PDevelopment::MODE_LIBRARY) { if ($development_mode & H5PDevelopment::MODE_LIBRARY) {
$this->h5pD = new H5PDevelopment($this->h5pF, $path, $language); $this->h5pD = new H5PDevelopment($this->h5pF, $path . '/', $language);
} }
} }
@ -1768,7 +1783,7 @@ class H5PCore {
foreach ($dependency[$type] as $file) { foreach ($dependency[$type] as $file) {
$assets[] = (object) array( $assets[] = (object) array(
'path' => $prefix . $dependency['path'] . '/' . trim(is_array($file) ? $file['path'] : $file), 'path' => $prefix . '/' . $dependency['path'] . '/' . trim(is_array($file) ? $file['path'] : $file),
'version' => $dependency['version'] 'version' => $dependency['version']
); );
} }
@ -1816,7 +1831,7 @@ class H5PCore {
); );
foreach ($dependencies as $dependency) { foreach ($dependencies as $dependency) {
if (isset($dependency['path']) === FALSE) { if (isset($dependency['path']) === FALSE) {
$dependency['path'] = '/libraries/' . H5PCore::libraryToString($dependency, TRUE); $dependency['path'] = 'libraries/' . H5PCore::libraryToString($dependency, TRUE);
$dependency['preloadedJs'] = explode(',', $dependency['preloadedJs']); $dependency['preloadedJs'] = explode(',', $dependency['preloadedJs']);
$dependency['preloadedCss'] = explode(',', $dependency['preloadedCss']); $dependency['preloadedCss'] = explode(',', $dependency['preloadedCss']);
} }
@ -2271,11 +2286,59 @@ class H5PCore {
} }
} }
if($platformInfo['uuid'] === '' && isset($json->uuid)) { if($platformInfo['uuid'] === '' && isset($json->uuid)) {
$this->h5pF->setOption('h5p_site_uuid', $json->uuid); $this->h5pF->setOption('site_uuid', $json->uuid);
} }
} }
} }
public function getGlobalDisable() {
$disable = self::DISABLE_NONE;
// Allow global settings to override and disable options
if (!$this->h5pF->getOption('frame', TRUE)) {
$disable |= self::DISABLE_FRAME;
}
else {
if (!$this->h5pF->getOption('export', TRUE)) {
$disable |= self::DISABLE_DOWNLOAD;
}
if (!$this->h5pF->getOption('embed', TRUE)) {
$disable |= self::DISABLE_EMBED;
}
if (!$this->h5pF->getOption('copyright', TRUE)) {
$disable |= self::DISABLE_COPYRIGHT;
}
if (!$this->h5pF->getOption('icon', TRUE)) {
$disable |= self::DISABLE_ABOUT;
}
}
return $disable;
}
/**
* Determine disable state from sources.
*
* @param array $sources
* @return int
*/
public static function getDisable(&$sources) {
$disable = H5PCore::DISABLE_NONE;
if (!$sources['frame']) {
$disable |= H5PCore::DISABLE_FRAME;
}
if (!$sources['download']) {
$disable |= H5PCore::DISABLE_DOWNLOAD;
}
if (!$sources['copyright']) {
$disable |= H5PCore::DISABLE_COPYRIGHT;
}
if (!$sources['embed']) {
$disable |= H5PCore::DISABLE_EMBED;
}
return $disable;
}
// Cache for getting library ids // Cache for getting library ids
private $libraryIdMap = array(); private $libraryIdMap = array();

19
js/disable.js Normal file
View File

@ -0,0 +1,19 @@
(function ($) {
$(document).ready(function () {
var $inputs = $('.h5p-action-bar-settings input');
var $frame = $inputs.filter('input[name="frame"], input[name="h5p_frame"]');
var $others = $inputs.filter(':not(input[name="frame"], input[name="h5p_frame"])');
var toggle = function () {
if ($frame.is(':checked')) {
$others.attr('disabled', false);
}
else {
$others.attr('disabled', true);
}
};
$frame.change(toggle);
toggle();
});
})(jQuery);

View File

@ -30,7 +30,29 @@ else if (document.documentElement.msRequestFullscreen) {
H5P.fullScreenBrowserPrefix = 'ms'; H5P.fullScreenBrowserPrefix = 'ms';
} }
// Keep track of when the H5Ps where started /** @const {Number} */
H5P.DISABLE_NONE = 0;
/** @const {Number} */
H5P.DISABLE_FRAME = 1;
/** @const {Number} */
H5P.DISABLE_DOWNLOAD = 2;
/** @const {Number} */
H5P.DISABLE_EMBED = 4;
/** @const {Number} */
H5P.DISABLE_COPYRIGHT = 8;
/** @const {Number} */
H5P.DISABLE_ABOUT = 16;
/**
* Keep track of when the H5Ps where started.
*
* @type {Array}
*/
H5P.opened = {}; H5P.opened = {};
/** /**
@ -72,21 +94,23 @@ H5P.init = function (target) {
}); });
} }
// Create action bar
var $actions = H5P.jQuery('<ul class="h5p-actions"></ul>'); var $actions = H5P.jQuery('<ul class="h5p-actions"></ul>');
if (contentData.exportUrl !== '') {
// Display export button if (!(contentData.disable & H5P.DISABLE_DOWNLOAD)) {
// Add export button
H5P.jQuery('<li class="h5p-button h5p-export" role="button" tabindex="1" title="' + H5P.t('downloadDescription') + '">' + H5P.t('download') + '</li>').appendTo($actions).click(function () { H5P.jQuery('<li class="h5p-button h5p-export" role="button" tabindex="1" title="' + H5P.t('downloadDescription') + '">' + H5P.t('download') + '</li>').appendTo($actions).click(function () {
window.location.href = contentData.exportUrl; window.location.href = contentData.exportUrl;
}); });
} }
if (!(contentData.disable & H5P.DISABLE_COPYRIGHT) && instance.getCopyrights !== undefined) {
// Display copyrights button // Add copyrights button
H5P.jQuery('<li class="h5p-button h5p-copyrights" role="button" tabindex="1" title="' + H5P.t('copyrightsDescription') + '">' + H5P.t('copyrights') + '</li>').appendTo($actions).click(function () { H5P.jQuery('<li class="h5p-button h5p-copyrights" role="button" tabindex="1" title="' + H5P.t('copyrightsDescription') + '">' + H5P.t('copyrights') + '</li>').appendTo($actions).click(function () {
H5P.openCopyrightsDialog($actions, instance, library.params, contentId); H5P.openCopyrightsDialog($actions, instance, library.params, contentId);
}); });
}
if (contentData.embedCode !== undefined) { if (!(contentData.disable & H5P.DISABLE_EMBED)) {
// Display embed button // Add embed button
H5P.jQuery('<li class="h5p-button h5p-embed" role="button" tabindex="1" title="' + H5P.t('embedDescription') + '">' + H5P.t('embed') + '</li>').appendTo($actions).click(function () { H5P.jQuery('<li class="h5p-button h5p-embed" role="button" tabindex="1" title="' + H5P.t('embedDescription') + '">' + H5P.t('embed') + '</li>').appendTo($actions).click(function () {
H5P.openEmbedDialog($actions, contentData.embedCode, contentData.resizeCode, { H5P.openEmbedDialog($actions, contentData.embedCode, contentData.resizeCode, {
width: $container.width(), width: $container.width(),
@ -94,10 +118,18 @@ H5P.init = function (target) {
}); });
}); });
} }
if (contentData.showH5PIconInActionBar) { if (!(contentData.disable & H5P.DISABLE_ABOUT)) {
// Add about H5P button icon
H5P.jQuery('<li><a class="h5p-link" href="http://h5p.org" target="_blank" title="' + H5P.t('h5pDescription') + '"></a></li>').appendTo($actions); H5P.jQuery('<li><a class="h5p-link" href="http://h5p.org" target="_blank" title="' + H5P.t('h5pDescription') + '"></a></li>').appendTo($actions);
} }
$actions.insertAfter($container);
// Insert action bar if it has any content
if ($actions.children().length) {
$actions.insertAfter($container);
}
else {
$element.addClass('h5p-no-frame');
}
// Keep track of when we started // Keep track of when we started
H5P.opened[contentId] = new Date(); H5P.opened[contentId] = new Date();

View File

@ -36,7 +36,9 @@ html.h5p-iframe .h5p-content {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.h5p-fullscreen .h5p-content, .h5p-semi-fullscreen .h5p-content { .h5p-content.h5p-no-frame,
.h5p-fullscreen .h5p-content,
.h5p-semi-fullscreen .h5p-content {
border: 0; border: 0;
} }
.h5p-container { .h5p-container {