Plugin: H5P: Add installer checks and translations - refs #2667

pull/3417/head
Yannick Warnier 5 years ago
parent c35cb2379c
commit a761c90ce9
  1. 28
      plugin/h5p/node_process.php
  2. 44
      plugin/h5p/resources/css/H5P.css
  3. 2
      plugin/h5p/resources/js/h5p_extras.js

@ -64,13 +64,24 @@ if ($id > 0) {
$h5pDestination = 'cache-h5p/launch/'.$fieldId;
//mkdir($dest_h5p);
$installH5P = true;
if (!file_exists('cache-h5p/launch/img/dialogcard.jpg')) {
$installH5P = false;
}
if (!file_exists( 'cache-h5p/launch/images/dialogcard.jpg')) {
$installH5P = false;
}
if (!file_exists($h5pSource)) {
$installH5P = false;
} else {
copyr($h5pSource, $h5pDestination);
}
$contentSource = 'cache-h5p/launch/'.$fieldId.'/content/content.json';
$contentFlx = file_get_contents($contentSource);
if ($nodeType == 'dialogcard' || $nodeType == 'memory') {
if (($nodeType == 'dialogcard' || $nodeType == 'memory') && $installH5P) {
if (controlSourceCards($termA)) {
$baseFlx = getSourceCards($termA, $nodeType);
}
@ -98,7 +109,7 @@ if ($id > 0) {
$contentFlx = str_replace("\"@base_cards@\"", $baseFlx, $contentFlx);
}
if ($nodeType == 'guesstheanswer') {
if ($nodeType == 'guesstheanswer' && $installH5P) {
$extractImgData = "images/dialogcard.jpg";
$pathParts = pathinfo($termB);
$fileN = $pathParts['filename'];
@ -138,6 +149,10 @@ if ($id > 0) {
$contentFlx = str_replace("\"You got :num out of :total points\"",
"\"Votre score :num out sur :total points\"", $contentFlx);
$contentFlx = str_replace("\"Show solution\"", "\"Voir la solution\"", $contentFlx);
$contentFlx = str_replace("\"Match found.\"", "\"Correspondance trouvée.\"", $contentFlx);
$contentFlx = str_replace("\"Reset\"", "\"Recommencer\"", $contentFlx);
$contentFlx = str_replace("\"Close\"", "\"Fermer\"", $contentFlx);
$contentFlx = str_replace("\"Time spent\"", "\"Temps\"", $contentFlx);
} elseif ($interfaceLanguage == 'es') {
$contentFlx = str_replace("\"solution label\"", "\"Ver la solución\"", $contentFlx);
$contentFlx = str_replace("\"Turn\"", "\"Girar\"", $contentFlx);
@ -149,6 +164,10 @@ if ($id > 0) {
$contentFlx = str_replace("\"You got :num out of :total points\"",
"\"Su nota es de :num sobre :total puntos\"", $contentFlx);
$contentFlx = str_replace("\"Show solution\"", "\"Ver la solución\"", $contentFlx);
$contentFlx = str_replace("\"Match found.\"", "\"Coincidencia encontrada.\"", $contentFlx);
$contentFlx = str_replace("\"Reset\"", "\"Reiniciar\"", $contentFlx);
$contentFlx = str_replace("\"Close\"", "\"Cerrar\"", $contentFlx);
$contentFlx = str_replace("\"Time spent\"", "\"El tiempo pasado\"", $contentFlx);
}
$fp = fopen($contentSource, 'w');
@ -180,6 +199,10 @@ $contentForm .= '<a href="list.php" class="btn btn-primary">';
$contentForm .= '<em class="fa"></em>'.get_lang('Close').'</a>';
$contentForm .= '</p>';
if ($installH5P == false) {
$contentForm = Display::return_message(get_lang('FolderDoesntExistsInFileSystem'), 'error');
}
$tpl = new Template("H5P");
$tpl->assign('form', $contentForm);
$content = $tpl->fetch('/h5p/view/view.tpl');
@ -262,3 +285,4 @@ function getSourceCards($termData, $nodeType)
return $baseFlx;
}

@ -116,3 +116,47 @@
border : solid 2px rgb(224, 73, 35);
border-radius : 50%;
}
/* header cell in data table in tools */
.data_table {
margin-bottom: 18px;
width: 100%;
border: 1px solid #DDDDDD;
}
.data_table td {
font-size: 12px;
}
.data_table th, .data_table td {
border-top: 1px solid #DDDDDD;
line-height: 18px;
padding: 10px;
}
.data_table th {
padding: 8px 10px;
font-weight: normal;
background-color: #EEEEEE;
border-bottom: 1px solid #DDDDDD;
color: #333;
}
.data_table th a {
color: #333;
}
.data_table_no_border {
border-collapse: collapse;
border-spacing: 0;
font-size: 12px;
margin-bottom: 15px;
margin-top: 8px;
text-align: left;
width: 100%;
}
.data_table_no_border td {
line-height: normal;
padding: 6px;
text-align: left;
vertical-align: middle;
}
.data_table tr.row_odd {
background-color: #F9F9F9;
}

@ -66,6 +66,8 @@ function insertExtrasObjectsH5p(){
if($("#extrasobjectH5p").length==0){
$("body").append('<div id="extrasobjectH5p" >'+inExtrasObjectsH5p()+'</div>');
showEditH5pLoad();
}else{
loadDataH5Pbase();
}
}

Loading…
Cancel
Save