Learning path: Add script to translate html and bootstrap links - refs BT#19044

pull/3997/head
Christian 4 years ago
parent 638a25648f
commit 6f80eb0276
  1. 41
      assets/js/translatehtml.js
  2. 3
      public/main/lp/lp_controller.php
  3. 8
      src/CoreBundle/Controller/ResourceController.php
  4. 2
      src/CoreBundle/Settings/CourseSettingsSchema.php
  5. 1
      src/CoreBundle/Settings/SettingsManager.php

@ -7,17 +7,46 @@ document.addEventListener('DOMContentLoaded', function () {
window.config['editor.translate_html'] &&
'true' === window.config['editor.translate_html']
) {
const isoCode = window.user.locale;
var isoCode = window.user.locale;
const translateElement = document.querySelector('.mce-translatehtml');
if (translateElement) {
document.querySelectorAll('.mce-translatehtml').forEach(function (el) {
el.style.display = 'none';
});
const selectedLang = document.querySelectorAll('[lang="' + isoCode + '"]');
selectedLang.forEach(function (userLang) {
userLang.classList.remove('hidden')
userLang.style.display = 'block';
});
if (selectedLang.length > 0) {
selectedLang.forEach(function (userLang) {
userLang.classList.remove('hidden')
userLang.style.display = 'block';
});
}
} else {
// it checks content from old version
const langs = document.querySelectorAll('span[lang]');
if (langs.length > 0) {
// it hides all contents with lang
langs.forEach(function (el) {
el.style.display = 'none';
});
// To show only the content by user language.
if (isoCode == 'pl_PL') {
isoCode = 'pl';
}
if (isoCode == 'fr_FR') {
isoCode = 'fr';
}
if (isoCode == 'en_US') {
isoCode = 'en';
}
const selectedLang = document.querySelectorAll('span[lang="' + isoCode + '"]');
if (selectedLang.length > 0) {
selectedLang.forEach(function (userLang) {
userLang.classList.remove('hidden')
userLang.style.display = 'block';
});
}
}
}
}
});
});

@ -523,6 +523,7 @@ switch ($action) {
$audio = $_FILES['mp3'];
}
$previous = isset($_POST['previous']) ? $_POST['previous'] : '';
$description = isset($_POST['description']) ? $_POST['description'] : '';
$prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : '';
$maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : '';
@ -531,7 +532,7 @@ switch ($action) {
$oLP->edit_item(
$_REQUEST['id'],
$_POST['parent'],
$_POST['previous'],
$previous,
$post_title,
$description,
$prerequisites,

@ -521,7 +521,13 @@ class ResourceController extends AbstractResourceController implements CourseCon
$content = str_replace('</head>', $js.'</head>', $content);
}
}
if ('true' === $this->getSettingsManager()->getSetting('course.enable_bootstrap_in_documents_html')) {
// It adds the bootstrap and awesome css
$links = '<link href="'.api_get_path(WEB_PATH).'libs/bootstrap/bootstrap.min.css" rel="stylesheet">';
$links .= '<link href="'.api_get_path(WEB_PATH).'libs/bootstrap/font-awesome.min.css" rel="stylesheet">';
// Insert inside the head tag.
$content = str_replace('</head>', $links.'</head>', $content);
}
$response->setContent($content);
/*$contents = $this->renderView('@ChamiloCore/Resource/view_html.twig', [
'category' => '...',

@ -83,6 +83,7 @@ class CourseSettingsSchema extends AbstractSettingsSchema
'lp_show_reduced_report' => 'false',
'course_creation_splash_screen' => 'true',
'block_registered_users_access_to_open_course_contents' => 'false',
'enable_bootstrap_in_documents_html' => 'false',
// @todo
]
)
@ -222,6 +223,7 @@ class CourseSettingsSchema extends AbstractSettingsSchema
->add('lp_show_reduced_report', YesNoType::class)
->add('course_creation_splash_screen', YesNoType::class)
->add('block_registered_users_access_to_open_course_contents', YesNoType::class)
->add('enable_bootstrap_in_documents_html', YesNoType::class)
;
}
}

@ -861,6 +861,7 @@ class SettingsManager implements SettingsManagerInterface
'gradebook_show_percentage_in_reports' => 'gradebook',
'course_creation_splash_screen' => 'Course',
'translate_html' => 'Editor',
'enable_bootstrap_in_documents_html' => 'Course',
];
}

Loading…
Cancel
Save