Imported changes from Drupal 6.x.

namespaces
Frode Petterson 2014-04-13 15:52:12 +02:00
parent c77b6ee19e
commit 9e01bbfb81
4 changed files with 75 additions and 47 deletions

View File

@ -399,12 +399,20 @@ class H5PValidator {
// Extract and then remove the package file.
$zip = new ZipArchive;
// Only allow files with the .h5p extension:
if (strtolower(substr($tmpPath, -3)) !== 'h5p') {
$this->h5pF->setErrorMessage($this->h5pF->t('The file you uploaded is not a valid HTML5 Package (It does not have the .h5p file extension)'));
H5PCore::deleteFileTree($tmpDir);
return;
}
if ($zip->open($tmpPath) === true) {
$zip->extractTo($tmpDir);
$zip->close();
}
else {
$this->h5pF->setErrorMessage($this->h5pF->t('The file you uploaded is not a valid HTML5 Package.'));
$this->h5pF->setErrorMessage($this->h5pF->t('The file you uploaded is not a valid HTML5 Package (We are unable to unzip it)'));
H5PCore::deleteFileTree($tmpDir);
return;
}
@ -430,7 +438,7 @@ class H5PValidator {
$mainH5pData = $this->getJsonData($filePath);
if ($mainH5pData === FALSE) {
$valid = FALSE;
$this->h5pF->setErrorMessage($this->h5pF->t('Could not find or parse the main h5p.json file'));
$this->h5pF->setErrorMessage($this->h5pF->t('Could not parse the main h5p.json file'));
}
else {
$validH5p = $this->isValidH5pData($mainH5pData, $file, $this->h5pRequired, $this->h5pOptional);
@ -439,7 +447,7 @@ class H5PValidator {
}
else {
$valid = FALSE;
$this->h5pF->setErrorMessage($this->h5pF->t('Could not find or parse the main h5p.json file'));
$this->h5pF->setErrorMessage($this->h5pF->t('The main h5p.json file is not valid'));
}
}
}
@ -485,8 +493,15 @@ class H5PValidator {
$libraryH5PData = $this->getLibraryData($file, $filePath, $tmpDir);
/* library's directory name and machineName in library.json must match */
if($libraryH5PData['machineName'] !== $file) {
$this->h5pF->setErrorMessage($this->h5pF->t('Library directory name must match machineName in library.json. (Directory: %directoryName , machineName: %machineName)', array('%directoryName' => $file, '%machineName' => $libraryH5PData['machineName'])));
$valid = FALSE;
continue;
}
if ($libraryH5PData) {
$libraries[$file] = $libraryH5PData;
$libraries[$libraryH5PData['machineName']] = $libraryH5PData;
}
else {
$valid = FALSE;
@ -1997,7 +2012,7 @@ class H5PContentValidator {
*/
public function validateLibrary(&$value, $semantics) {
// Check if provided library is within allowed options
if (in_array($value->library, $semantics->options)) {
if (isset($value->library) && in_array($value->library, $semantics->options)) {
if (isset($this->semanticsCache[$value->library])) {
$librarySemantics = $this->semanticsCache[$value->library];
}

View File

@ -117,7 +117,11 @@ var H5P = H5P || (function () {
embedCode: content.embedCode
};
},
i18n: content.i18n
i18n: content.i18n,
showH5PIconInActionBar: function () {
// Always show H5P-icon when embedding
return true;
}
};
};
@ -168,7 +172,7 @@ var H5P = H5P || (function () {
$classes.addClass('h5p-semi-fullscreen');
iframe.style.position = 'fixed';
var $disable = $element.prepend('<a href="#" class="h5p-disable-fullscreen">Disable fullscreen</a>').children(':first');
var $disable = $element.prepend('<a href="#" class="h5p-disable-fullscreen" title="Disable fullscreen"></a>').children(':first');
var keyup, disableSemiFullscreen = function () {
$disable.remove();
$body.unbind('keyup', keyup);

View File

@ -51,7 +51,7 @@ H5P.init = function () {
// Check if we should add and display a fullscreen button for this H5P.
if (contentData.fullScreen == 1) {
H5P.jQuery('<div class="h5p-content-controls"><div role="button" tabindex="1" class="h5p-enable-fullscreen">' + H5P.t('fullscreen') + '</div></div>').insertBefore($container).children().click(function () {
H5P.jQuery('<div class="h5p-content-controls"><div role="button" tabindex="1" class="h5p-enable-fullscreen" title="' + H5P.t('fullscreen') + '"></div></div>').prependTo($container).children().click(function () {
H5P.fullScreen($container, instance);
});
};
@ -75,7 +75,9 @@ H5P.init = function () {
H5P.openEmbedDialog($actions, contentData.embedCode);
});
}
if (H5PIntegration.showH5PIconInActionBar()) {
H5P.jQuery('<li><a class="h5p-link" href="http://h5p.org" target="_blank" title="' + H5P.t('h5pDescription') + '"></a></li>').appendTo($actions);
}
$actions.insertAfter($container);
if (H5P.isFramed) {
@ -207,7 +209,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) {
$classes.addClass('h5p-semi-fullscreen');
H5P.isFullscreen = true;
var $disable = $container.prepend('<a href="#" class="h5p-disable-fullscreen">Disable fullscreen</a>').children(':first');
var $disable = $container.prepend('<a href="#" class="h5p-disable-fullscreen" title="Disable fullscreen"></a>').children(':first');
var keyup, disableSemiFullscreen = function () {
$disable.remove();
$body.unbind('keyup', keyup);

View File

@ -33,6 +33,10 @@ html.h5p-iframe, html.h5p-iframe > body {
background: #fefefe;
font-size: 16px;
line-height: 1.5em;
border: 1px solid #EEE;
border-bottom: none;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
html.h5p-iframe .h5p-content {
width: 100%;
@ -49,15 +53,17 @@ html.h5p-iframe .h5p-content {
z-index: 101;
width: 100%;
height: 100%;
background-color: #FFF;
}
.h5p-content-controls {
margin: 0;
text-align: right;
position: relative;
position: absolute;
right: 0;
top: 0;
z-index: 3;
}
.h5p-iframe > .h5p-fullscreen .h5p-content-controls {
.h5p-fullscreen .h5p-content-controls {
display: none;
}
@ -67,49 +73,44 @@ html.h5p-iframe .h5p-content {
.h5p-enable-fullscreen:before, .h5p-disable-fullscreen:before {
font-family: H5PFontAwesome4;
margin-right: 10px;
content: "\f0b2";
font-size: 1.2em;
font-size: 25px;
}
.h5p-enable-fullscreen:before {
content: "\f065";
}
.h5p-disable-fullscreen:before {
content: "\f066";
}
.h5p-enable-fullscreen, .h5p-disable-fullscreen {
display: inline-block;
line-height: 1.25em;
padding: 6px 12px;
border: 0.2em solid #fff;
border-radius: 0.4em;
margin: 1em 1.2em;
line-height: 25px;
width: 25px;
height: 25px;
padding: 6px 6px;
cursor: pointer;
color: #fff;
box-shadow: 0 0 0.5em #999;
font-size: 12px;
color: #EEE;
background: rgb(0,0,0);
background: rgba(0,0,0,0.3);
text-decoration: none;
font-family: Verdana, Arial, sans-serif;
background: rgb(100,152,254); /* Old browsers */
background: -moz-linear-gradient(top, rgba(100,152,254,1) 0%, rgba(4,104,206,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(100,152,254,1)), color-stop(100%,rgba(4,104,206,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(100,152,254,1) 0%,rgba(4,104,206,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(100,152,254,1) 0%,rgba(4,104,206,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(100,152,254,1) 0%,rgba(4,104,206,1) 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6498fe', endColorstr='#0468ce',GradientType=0 ); /* IE6-9 */
text-align: center;
}
.h5p-disable-fullscreen {
position: absolute;
right: 0;
top: 0;
right: 10px;
top: 10px;
z-index: 201;
background: rgb(0,0,0);
background: rgba(0,0,0,0.7);
}
.h5p-enable-fullscreen:hover, .h5p-disable-fullscreen:hover {
text-decoration: none;
background: rgba(0,0,0,0.5);
}
background: rgb(4,104,206); /* Old browsers */
background: -moz-linear-gradient(top, rgba(4,104,206,1) 0%, rgba(100,152,254,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(4,104,206,1)), color-stop(100%,rgba(100,152,254,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(4,104,206,1) 0%,rgba(100,152,254,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(4,104,206,1) 0%,rgba(100,152,254,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(4,104,206,1) 0%,rgba(100,152,254,1) 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0468ce', endColorstr='#6498fe',GradientType=0 ); /* IE6-9 */
.h5p-semi-fullscreen .h5p-content-controls {
display: none;
}
div.h5p-fullscreen {
@ -179,14 +180,20 @@ div.h5p-fullscreen {
cursor: pointer;
}
.h5p-actions {
.h5p-content ul.h5p-actions {
box-sizing: border-box;
-moz-box-sizing: border-box;
overflow: hidden;
list-style: none;
padding: 4px;
margin: 0.25em 0;
position: relative;
z-index: 2;
padding: 0px 10px;
margin: 0;
height: 25px;
font-size: 12px;
background: #FAFAFA;
border-top: 1px solid #EEE;
border-bottom: 1px solid #EEE;
clear: both;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.h5p-fullscreen .h5p-actions, .h5p-semi-fullscreen .h5p-actions {
display: none;