Resolve conflicts

namespaces
Svein-Tore Griff With 2013-02-27 22:49:56 +01:00
commit 517f7e6e9d
2 changed files with 30 additions and 18 deletions

View File

@ -164,6 +164,7 @@ class H5PValidator {
'machineName' => '/^[\w0-9\-\.]{1,255}$/i', 'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
'majorVersion' => '/^[0-9]{1,5}$/', 'majorVersion' => '/^[0-9]{1,5}$/',
'minorVersion' => '/^[0-9]{1,5}$/', 'minorVersion' => '/^[0-9]{1,5}$/',
'defaultStyles' => 'boolean',
), ),
'mainLibrary' => '/^[$a-z_][0-9a-z_\.$]{1,254}$/i', 'mainLibrary' => '/^[$a-z_][0-9a-z_\.$]{1,254}$/i',
'embedTypes' => array('iframe', 'div'), 'embedTypes' => array('iframe', 'div'),
@ -178,6 +179,7 @@ class H5PValidator {
'machineName' => '/^[\w0-9\-\.]{1,255}$/i', 'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
'majorVersion' => '/^[0-9]{1,5}$/', 'majorVersion' => '/^[0-9]{1,5}$/',
'minorVersion' => '/^[0-9]{1,5}$/', 'minorVersion' => '/^[0-9]{1,5}$/',
'defaultStyles' => 'boolean',
), ),
'externalResources' => array( 'externalResources' => array(
'machineName' => '/^[\w0-9\-\.]{1,255}$/i', 'machineName' => '/^[\w0-9\-\.]{1,255}$/i',
@ -544,6 +546,13 @@ class H5PValidator {
$valid = TRUE; $valid = TRUE;
if (is_string($requirement)) { if (is_string($requirement)) {
if ($requirement == 'boolean') {
if (!is_bool($h5pData)) {
$this->h5pF->setErrorMessage($this->h5pF->t("Invalid data provided for %property in %library. Boolean expected.", array('%property' => $property_name, '%library' => $library_name)));
$valid = FALSE;
}
}
else {
// The requirement is a regexp, match it against the data // The requirement is a regexp, match it against the data
if (is_string($h5pData) || is_int($h5pData)) { if (is_string($h5pData) || is_int($h5pData)) {
if (preg_match($requirement, $h5pData) === 0) { if (preg_match($requirement, $h5pData) === 0) {
@ -556,6 +565,7 @@ class H5PValidator {
$valid = FALSE; $valid = FALSE;
} }
} }
}
elseif (is_array($requirement)) { elseif (is_array($requirement)) {
// We have sub requirements // We have sub requirements
if (is_array($h5pData)) { if (is_array($h5pData)) {
@ -725,6 +735,7 @@ class H5PStorage {
$librariesInUse[$preloadedDependency['machineName']] = array( $librariesInUse[$preloadedDependency['machineName']] = array(
'library' => $library, 'library' => $library,
'preloaded' => $dynamic ? 0 : 1, 'preloaded' => $dynamic ? 0 : 1,
'default_styles' => isset($preloadedDependency['defaultStyles']) && $preloadedDependency['defaultStyles'] ? 1 : 0,
); );
$this->getLibraryUsage($librariesInUse, $library, $dynamic); $this->getLibraryUsage($librariesInUse, $library, $dynamic);
} }

View File

@ -63,7 +63,7 @@ H5P.Coords = function(x, y, w, h) {
// function to call when finished. // function to call when finished.
// //
// TODO: Try to get rid of content path. // TODO: Try to get rid of content path.
H5P.playVideo = function ($target, params, cp, onEnded) { H5P.playVideo = function ($target, params, skipButtonText, cp, onEnded) {
var $ = H5P.jQuery; var $ = H5P.jQuery;
var width = 635, // TODO: These should come from some dimension setting. var width = 635, // TODO: These should come from some dimension setting.
@ -87,13 +87,14 @@ H5P.playVideo = function ($target, params, cp, onEnded) {
video.height = height; video.height = height;
if (video.canPlayType !== undefined) { if (video.canPlayType !== undefined) {
for (var key in params) { for (var i = 0; i < params.length; i++) {
var file = params[i];
// TODO: The files should probably be in their own group. // TODO: The files should probably be in their own group.
if (key.indexOf('video') === 0) { if (file.mime.indexOf('video') === 0) {
if (video.canPlayType(key)) { if (video.canPlayType(file.mime)) {
var source = document.createElement('source'); var source = document.createElement('source');
source.src = cp + params[key]; source.src = cp + file.path;
source.type = key; source.type = file.mime;
video.appendChild(source); video.appendChild(source);
willWork = willWork || true; willWork = willWork || true;
} }
@ -122,10 +123,10 @@ H5P.playVideo = function ($target, params, cp, onEnded) {
}, { }, {
buffering: true, buffering: true,
clip: { clip: {
url: window.location.protocol + '//' + window.location.host + cp + params['video/mp4'], url: window.location.protocol + '//' + window.location.host + cp + params[0].path,
autoPlay: true, autoPlay: true,
autoBuffering: true, autoBuffering: true,
onFinish: function (ev) { onFinish: function () {
onEnded(); onEnded();
}, },
onError: function () { onError: function () {
@ -144,8 +145,8 @@ H5P.playVideo = function ($target, params, cp, onEnded) {
return; return;
} }
if (params.skipButtonText) { if (skipButtonText) {
var $skipButton = $('<a class="button skip">' + params.skipButtonText + '</a>').click(function (ev) { var $skipButton = $('<a class="button skip">' + skipButtonText + '</a>').click(function (ev) {
if (fplayer !== undefined) { if (fplayer !== undefined) {
// Must stop this first. Errorama if we don't // Must stop this first. Errorama if we don't
fplayer.stop().close().unload(); fplayer.stop().close().unload();