Merge remote-tracking branch 'origin/master'

pull/5209/head
Angel Fernando Quiroz Campos 9 months ago
commit cf0b6be489
  1. 4
      public/main/lp/lp_list.php
  2. 53
      src/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php
  3. 24
      src/CoreBundle/Resources/views/LearnPath/list.html.twig

@ -205,7 +205,7 @@ foreach ($categories as $category) {
$flat_list = $list->get_flat_list(); $flat_list = $list->get_flat_list();
// Hiding categories with out LPs (only for student) // Hiding categories without LPs (only for student)
if (empty($flat_list) && !$is_allowed_to_edit) { if (empty($flat_list) && !$is_allowed_to_edit) {
continue; continue;
} }
@ -714,7 +714,9 @@ foreach ($categories as $category) {
"lp_controller.php?$cidReq&action=move_lp_down&lp_id=$id&category_id=$categoryId", "lp_controller.php?$cidReq&action=move_lp_down&lp_id=$id&category_id=$categoryId",
['title' => htmlentities(get_lang('Move down'))] ['title' => htmlentities(get_lang('Move down'))]
); );
$dsp_order .= Display::getMdiIcon('arrow-up-bold', 'ch-tool-icon-disabled', '', 22, get_lang('Move up'));
} elseif ($current == $max - 1 && 1 != $max) { } elseif ($current == $max - 1 && 1 != $max) {
$dsp_order .= Display::getMdiIcon('arrow-down-bold', 'ch-tool-icon-disabled', '', 22, get_lang('Move down'));
$dsp_order .= Display::url( $dsp_order .= Display::url(
Display::getMdiIcon('arrow-up-bold', 'ch-tool-icon', '', 22), Display::getMdiIcon('arrow-up-bold', 'ch-tool-icon', '', 22),
"lp_controller.php?$cidReq&action=move_lp_up&lp_id=$id&category_id=$categoryId", "lp_controller.php?$cidReq&action=move_lp_up&lp_id=$id&category_id=$categoryId",

@ -191,13 +191,10 @@ class Basic extends Toolbar
$config['file_picker_callback'] = '[browser]'; $config['file_picker_callback'] = '[browser]';
$iso = api_get_language_isocode(); $iso = api_get_language_isocode();
$url = api_get_path(WEB_PATH); $languageConfig = $this->getLanguageConfig($iso);
// Language list: https://www.tiny.cloud/get-tiny/language-packages/ // Merge the language configuration
if ('en_US' !== $iso) { $config = array_merge($config, $languageConfig);
$config['language'] = $iso;
$config['language_url'] = "$url/libs/editor/langs/$iso.js";
}
/*if (isset($this->config)) { /*if (isset($this->config)) {
$this->config = array_merge($config, $this->config); $this->config = array_merge($config, $this->config);
@ -301,4 +298,48 @@ class Basic extends Toolbar
['Toolbarswitch', 'Source'], ['Toolbarswitch', 'Source'],
]; ];
} }
/**
* Determines the appropriate language configuration for the editor.
* Tries to load a specific language file based on the ISO code. If not found, it attempts to load a general language file.
* Falls back to English if neither specific nor general language files are available.
*/
private function getLanguageConfig(string $iso): array
{
$url = api_get_path(WEB_PATH);
$sysUrl = api_get_path(SYS_PATH);
$defaultLang = 'en';
$defaultLangFile = "libs/editor/langs/{$defaultLang}.js";
$specificLangFile = "libs/editor/langs/{$iso}.js";
$generalLangFile = null;
// Default configuration set to English
$config = [
'language' => $defaultLang,
'language_url' => $defaultLangFile,
];
if ('en_US' !== $iso) {
// Check for a specific variant of the language (e.g., de_german2)
if (str_contains($iso, '_')) {
// Extract the general language code (e.g., de)
list($generalLangCode, ) = explode('_', $iso, 2);
$generalLangFile = "libs/editor/langs/{$generalLangCode}.js";
}
// Attempt to load the specific language file
if (file_exists($sysUrl.$specificLangFile)) {
$config['language'] = $iso;
$config['language_url'] = $url.$specificLangFile;
}
// Fallback to the general language file if specific is not available
elseif ($generalLangFile !== null && file_exists($sysUrl.$generalLangFile)) {
$config['language'] = $generalLangCode;
$config['language_url'] = $url.$generalLangFile;
}
}
return $config;
}
} }

@ -48,23 +48,23 @@
{% if loop.index0 == 1 %} {% if loop.index0 == 1 %}
<a href="#"> <a href="#">
<i class="mdi-arrow-up-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-up-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move up"|trans }}"></i>
</a> </a>
{% else %} {% else %}
<a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_up_category&id=' ~ lp_data.category.iid }}" <a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_up_category&id=' ~ lp_data.category.iid }}"
title="{{ "Move"|trans }}"> title="{{ "Move up"|trans }}">
<i class="mdi-arrow-up-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-up-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move up"|trans }}"></i>
</a> </a>
{% endif %} {% endif %}
{% if (data|length - 1) == loop.index0 %} {% if (data|length - 1) == loop.index0 %}
<a href="#"> <a href="#">
<i class="mdi-arrow-down-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-down-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move down"|trans }}"></i>
</a> </a>
{% else %} {% else %}
<a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_down_category&id=' ~ lp_data.category.iid }}" <a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_down_category&id=' ~ lp_data.category.iid }}"
title="{{ "Move"|trans }}"> title="{{ "Move down"|trans }}">
<i class="mdi-arrow-down-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-down-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move down"|trans }}"></i>
</a> </a>
{% endif %} {% endif %}
{% endif %} {% endif %}
@ -363,23 +363,23 @@
{% if loop.index0 == 1 %} {% if loop.index0 == 1 %}
<a href="#"> <a href="#">
<i class="mdi-arrow-up-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-up-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move up"|trans }}"></i>
</a> </a>
{% else %} {% else %}
<a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_up_category&id=' ~ lp_data.category.iid }}" <a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_up_category&id=' ~ lp_data.category.iid }}"
title="{{ "Move"|trans }}"> title="{{ "Move up"|trans }}">
<i class="mdi-arrow-up-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-up-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move up"|trans }}"></i>
</a> </a>
{% endif %} {% endif %}
{% if (data|length - 1) == loop.index0 %} {% if (data|length - 1) == loop.index0 %}
<a href="#"> <a href="#">
<i class="mdi-arrow-down-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-down-bold mdi ch-tool-icon-disabled" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move down"|trans }}"></i>
</a> </a>
{% else %} {% else %}
<a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_down_category&id=' ~ lp_data.category.iid }}" <a href="{{ 'lp_controller.php?' ~ course_url_params ~ '&action=move_down_category&id=' ~ lp_data.category.iid }}"
title="{{ "Move"|trans }}"> title="{{ "Move down"|trans }}">
<i class="mdi-arrow-down-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move"|trans }}"></i> <i class="mdi-arrow-down-bold mdi ch-tool-icon" style="font-size: 22px; width: 22px; height: 22px;" aria-hidden="true" title="{{ "Move down"|trans }}"></i>
</a> </a>
{% endif %} {% endif %}
{% endif %} {% endif %}

Loading…
Cancel
Save