Remove "lunetics/locale-bundle", fix lang switcher and listeners

pull/2528/head
jmontoyaa 7 years ago
parent 000f93c6ac
commit 2da1d004c1
  1. 1
      assets/js/main.js
  2. 3
      composer.json
  3. 1
      config/bundles.php
  4. 7
      config/packages/lunetics_locale.yaml
  5. 1
      config/services.yaml
  6. 15
      src/CoreBundle/EventListener/LegacyListener.php
  7. 3
      src/CoreBundle/EventListener/LegacyLoginListener.php
  8. 11
      src/CoreBundle/EventListener/LocaleListener.php
  9. 2
      src/CoreBundle/Resources/config/services.yml
  10. 95
      src/ThemeBundle/Resources/views/Layout/base-layout.html.twig
  11. 2
      src/ThemeBundle/Resources/views/Sidebar/left_menu.html.twig
  12. 22
      src/ThemeBundle/Resources/views/Sidebar/login.html.twig
  13. 4
      src/ThemeBundle/Resources/views/Sidebar/menu_knp.html.twig

@ -27,6 +27,7 @@ require("timeago");
require("select2/dist/css/select2.css");
require('bootstrap-select/dist/js/bootstrap-select.js');
require('bootstrap-select/dist/css/bootstrap-select.css');
require('flag-icon-css/css/flag-icon.css');
// doesn't work with webpack added directly in /public/libs folder
/*

@ -127,7 +127,7 @@
"emojione/emojione": "1.3.0",
"zendframework/zend-config": "~3.0",
"zendframework/zend-config": "~3.2",
"zendframework/zend-feed": "~2.9",
"zendframework/zend-filter": "~2.7",
"zendframework/zend-http": "~2.7",
@ -156,7 +156,6 @@
"kigkonsult/icalcreator": "2.24",
"essence/essence": "~3.0",
"paragonie/random-lib": "2.0.0",
"lunetics/locale-bundle": "^2.6",
"hwi/oauth-bundle": "~0.6",
"php-http/guzzle6-adapter": "^1.1",
"php-http/httplug-bundle": "^1.8",

@ -57,7 +57,6 @@ return [
Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle::class => ['all' => true],
Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
Sylius\Bundle\SettingsBundle\SyliusSettingsBundle::class => ['all' => true],
Lunetics\LocaleBundle\LuneticsLocaleBundle::class => ['all' => true],
Http\HttplugBundle\HttplugBundle::class => ['all' => true],
Oneup\FlysystemBundle\OneupFlysystemBundle::class => ['all' => true],
Sonata\CacheBundle\SonataCacheBundle::class => ['all' => true],

@ -1,7 +0,0 @@
lunetics_locale:
guessing_order:
- session
- query
- router
#- browser
allowed_locales: '%locales%'

@ -4,7 +4,6 @@ parameters:
password_encryption: '%env(APP_ENCRYPT_METHOD)%'
secret: '%env(APP_SECRET)%'
locale: '%env(APP_LOCALE)%'
locales: ['%env(APP_LOCALE)%']
url_append: '%env(APP_URL_APPEND)%'
installed: '%env(APP_INSTALLED)%'
twig:

@ -43,11 +43,10 @@ class LegacyListener
$container->get('router')->getRouteCollection()->add('legacy_index', $route);*/
}
$context = $container->get('router.request_context');
/*$context = $container->get('router.request_context');
$context->setBaseUrl('/');
$container->get('router.default')->setContext($context);
$container->get('router.default')->setContext($context);*/
//var_dump($container->get('router.default')->generate('home'));
// Setting container
Container::setContainer($container);
Container::setLegacyServices($container);
@ -116,6 +115,15 @@ class LegacyListener
$extraHeader = trim(api_get_setting('header_extra_content'));
$container->get('twig')->addGlobal('header_extra_content', $extraHeader);
$languages = api_get_languages();
$languageList = [];
foreach ($languages as $isoCode => $language) {
$languageList[languageToCountryIsoCode($isoCode)] = $language;
}
$container->get('twig')->addGlobal('current_locale_iso',languageToCountryIsoCode($request->getLocale()));
$container->get('twig')->addGlobal('available_locales', $languages);
}
// We set cid_reset = true if we enter inside a main/admin url
@ -125,7 +133,6 @@ class LegacyListener
} else {
$session->set('cid_reset', false);
}
$session->set('access_url_id', $urlId);
}

@ -52,7 +52,6 @@ class LegacyLoginListener implements EventSubscriberInterface
$container = $this->container;
$token = $this->tokenStorage->getToken();
$session = $request->getSession();
if ($token) {
$isGranted = $container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY');
if ($isGranted) {
@ -78,9 +77,7 @@ class LegacyLoginListener implements EventSubscriberInterface
$locale = isset($languages[$user->getLanguage()]) ? $languages[$user->getLanguage()] : '';
if ($user && !empty($locale)) {
$user->setLocale($locale);
//$request->getSession()->set('_locale_user', $locale);
// if no explicit locale has been set on this request, use one from the session
$request->getSession()->set('_locale', $locale);
$request->setLocale($locale);

@ -47,13 +47,14 @@ class LocaleListener implements EventSubscriberInterface
return;
}
$request = $event->getRequest();
$container = $this->container;
$installed = $container->get('kernel')->isInstalled();
if (!$installed) {
return;
}
$request = $event->getRequest();
$courseCode = $request->get('course');
// Detect if the course was set with a cidReq:
@ -74,8 +75,6 @@ class LocaleListener implements EventSubscriberInterface
if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->set('_locale', $locale);
} else {
$locale = $this->defaultLocale;
// 1. Check platform locale
/** @var SettingsManager $settings */
$settings = $this->container->get('chamilo.settings.manager');
@ -101,6 +100,12 @@ class LocaleListener implements EventSubscriberInterface
}
}
// 4. force locale if it was selected from the URL
$localeFromUrl = $request->get('_locale');
if (!empty($localeFromUrl)) {
$locale = $localeFromUrl;
}
// if no explicit locale has been set on this request, use one from the session
$request->setLocale($locale);
$request->getSession()->set('_locale', $locale);

@ -157,7 +157,7 @@ services:
class: Chamilo\CoreBundle\EventListener\LocaleListener
arguments: ['%kernel.default_locale%', '@service_container']
tags:
- {name: kernel.event_subscriber}
- {name: kernel.event_subscriber, priority: 9}
# User locale listener
chamilo_core.listener.user_locale_listener:

@ -179,62 +179,61 @@
</div>
</section>
<section id="menu-bar">
{# menu #}
{% block menu %}
<nav class="navbar navbar-default">
<div class="container">
<div class="collapse navbar-collapse">
{{ mopa_bootstrap_menu('ChamiloCoreBundle:NavBuilder:leftMenu', {'automenu': 'navbar', 'stacked' : false}) }}
{% if app.user is not null and is_granted('IS_AUTHENTICATED_FULLY') %}
<div class="navbar-custom-menu">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<img class="img-circle" src="{{ asset(app.user.avatarOrAnonymous(32)) }}"
alt="{{ app.user.completeName }}" />
<span class="caret"></span>
</a>
{# menu #}
{% block menu %}
<nav class="navbar navbar-default">
<div class="container">
<div class="collapse navbar-collapse">
{{ mopa_bootstrap_menu('ChamiloCoreBundle:NavBuilder:leftMenu', {'automenu': 'navbar', 'stacked' : false}) }}
<ul class="dropdown-menu" role="menu">
<li class="user-header">
<div class="text-center">
<img class="img-circle" src="{{ asset(app.user.avatarOrAnonymous(64)) }}" alt="{{ app.user.completeName }}" />
<p class="name">
<a href="{{ url('legacy_main', { 'name' : 'social/home.php' })}}">
{{ app.user.completeName }}
</a>
</p>
<p><i class="fa fa-envelope-o" aria-hidden="true"></i> {{ app.user.email }}</p>
</div>
</li>
<li role="separator" class="divider"></li>
<li class="user-body">
<a title="{{ "Inbox"|trans }}" href="{{ url('legacy_main', { 'name' : 'messages/inbox.php' }) }}">
<em class="fa fa-envelope" aria-hidden="true"></em> {{ "Inbox"|get_lang }}
</a>
<a title="{{ "MyCertificates"|trans }}" href="{{ url('legacy_main', { 'name' : 'gradebook/my_certificates.php' }) }}">
<em class="fa fa-graduation-cap" aria-hidden="true"></em> {{ "MyCertificates"|get_lang }}
</a>
<a id="logout_button" title="{{ "Logout"|trans }}" href="{{ path('legacy_main', { 'name' : '../public/logout'}) }}" >
<em class="fa fa-sign-out"></em> {{ "Logout"|trans }}
</a>
</li>
</ul>
</li>
</ul>
</div>
{% endif %}
{% if app.user is not null and is_granted('IS_AUTHENTICATED_FULLY') %}
<div class="navbar-custom-menu">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<img class="img-circle" src="{{ asset(app.user.avatarOrAnonymous(32)) }}"
alt="{{ app.user.completeName }}" />
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li class="user-header">
<div class="text-center">
<img class="img-circle" src="{{ asset(app.user.avatarOrAnonymous(64)) }}" alt="{{ app.user.completeName }}" />
<p class="name">
<a href="{{ url('legacy_main', { 'name' : 'social/home.php' })}}">
{{ app.user.completeName }}
</a>
</p>
<p><i class="fa fa-envelope-o" aria-hidden="true"></i> {{ app.user.email }}</p>
</div>
</li>
<li role="separator" class="divider"></li>
<li class="user-body">
<a title="{{ "Inbox"|trans }}" href="{{ url('legacy_main', { 'name' : 'messages/inbox.php' }) }}">
<em class="fa fa-envelope" aria-hidden="true"></em> {{ "Inbox"|get_lang }}
</a>
<a title="{{ "MyCertificates"|trans }}" href="{{ url('legacy_main', { 'name' : 'gradebook/my_certificates.php' }) }}">
<em class="fa fa-graduation-cap" aria-hidden="true"></em> {{ "MyCertificates"|get_lang }}
</a>
<a id="logout_button" title="{{ "Logout"|trans }}" href="{{ path('legacy_main', { 'name' : '../public/logout'}) }}" >
<em class="fa fa-sign-out"></em> {{ "Logout"|trans }}
</a>
</li>
</ul>
</li>
</ul>
</div>
{% endif %}
</div>
</nav>
{#{% include "@template_style/layout/menu.html.twig" %}#}
</div>
</nav>
{#{% include "@template_style/layout/menu.html.twig" %}#}
{% endblock %}
</section>
</header>
<div id="top_main_content" class="container">
{#{{ locale_switcher() }}#}
{# course navigation links/shortcuts need to be activated by the admin #}
{#{% include "@template_style/layout/course_navigation.html.twig" %}#}
{#{% endif %}#}

@ -38,10 +38,8 @@
</div>
{% endif %}
{% endif %}
{{ macro.panel(
'Help' | trans,
mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:helpMenu', {'automenu': 'pills', 'stacked':true})
) }}
{% endautoescape %}

@ -1,5 +1,23 @@
{{ locale_switcher(null, null, 'ChamiloCoreBundle:Admin:switcher_links.html.twig') }}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="flag-icon flag-icon-{{ current_locale_iso }}"></span>
{{ current_locale_iso }}
<span class="caret">
</span>
</button>
<ul class="dropdown-menu" role="menu">
{% autoescape false %}
{% for index, locale in available_locales %}
<li>
<a href="{{ app.request.attributes.get('_route') }}?_locale={{ index }}">
<span class="flag-icon flag-icon-{{ index }}"></span>
{{ locale }}
</a>
</li>
{% endfor %}
{% endautoescape %}
</ul>
</div>
<form class="form-horizontal" action="{{ path("fos_user_security_check") }}" method="post" name="formLogin" id="formLogin">
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
<fieldset>

@ -16,9 +16,7 @@
mopa_bootstrap_menu('ChamiloCoreBundle:CourseMenuBuilder:skillsMenu', {'automenu': 'pills', 'stacked':true})) }}
{% else %}
{{ locale_switcher(null, null, 'ChamiloCoreBundle:Admin:switcher_links.html.twig') }}
<div class="user-panel">
<div class="user-panel">switcher
</div>
<form action="{{ path("fos_user_security_check") }}" method="post" role="form" class="sidebar-form">
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>

Loading…
Cancel
Save