var/cache/test/twig/2e/2e8805ae1ba933c0f999b7a67a847c9c.php line 43

Open in your IDE?
  1. <?php
  2. use Twig\Environment;
  3. use Twig\Error\LoaderError;
  4. use Twig\Error\RuntimeError;
  5. use Twig\Extension\SandboxExtension;
  6. use Twig\Markup;
  7. use Twig\Sandbox\SecurityError;
  8. use Twig\Sandbox\SecurityNotAllowedTagError;
  9. use Twig\Sandbox\SecurityNotAllowedFilterError;
  10. use Twig\Sandbox\SecurityNotAllowedFunctionError;
  11. use Twig\Source;
  12. use Twig\Template;
  13. /* @ui2022/translate_widget.html.twig */
  14. class __TwigTemplate_d7e60a44a84a287f52abf827860d08ea extends \Twig\Template
  15. {
  16.     private $source;
  17.     private $macros = [];
  18.     public function __construct(Environment $env)
  19.     {
  20.         parent::__construct($env);
  21.         $this->source $this->getSourceContext();
  22.         $this->parent false;
  23.         $this->blocks = [
  24.         ];
  25.     }
  26.     protected function doDisplay(array $context, array $blocks = [])
  27.     {
  28.         $macros $this->macros;
  29.         $__internal_5a27a8ba21ca79b61932376b2fa922d2 $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  30.         $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template""@ui2022/translate_widget.html.twig"));
  31.         $__internal_6f47bbe9983af81f1e7450e9a3e3768f $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  32.         $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template""@ui2022/translate_widget.html.twig"));
  33.         // line 1
  34.         $context["translationLanguages"] = ((twig_get_attribute($this->env$this->source, ($context["_args"] ?? null), "languages", [], "any"truetruefalse1)) ? (_twig_default_filter(twig_get_attribute($this->env$this->source, ($context["_args"] ?? null), "languages", [], "any"falsefalsefalse1), twig_get_attribute($this->env$this->source, (isset($context["cms"]) || array_key_exists("cms"$context) ? $context["cms"] : (function () { throw new RuntimeError('Variable "cms" does not exist.'1$this->source); })()), "translationLanguages", [], "any"falsefalsefalse1))) : (twig_get_attribute($this->env$this->source, (isset($context["cms"]) || array_key_exists("cms"$context) ? $context["cms"] : (function () { throw new RuntimeError('Variable "cms" does not exist.'1$this->source); })()), "translationLanguages", [], "any"falsefalsefalse1)));
  35.         // line 2
  36.         $context["userEffectiveLanguage"] = twig_get_attribute($this->env$this->source, (isset($context["cms"]) || array_key_exists("cms"$context) ? $context["cms"] : (function () { throw new RuntimeError('Variable "cms" does not exist.'2$this->source); })()), "userEffectiveLanguage", [], "any"falsefalsefalse2);
  37.         // line 3
  38.         echo "
  39. ";
  40.         // line 4
  41.         if ( !twig_test_empty((isset($context["translationLanguages"]) || array_key_exists("translationLanguages"$context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.'4$this->source); })()))) {
  42.             // line 5
  43.             echo "    ";
  44.             $context["defaultLanguage"] = twig_constant("App\\Util\\Locales::ISO6391__ENGLISH");
  45.             // line 6
  46.             echo "    ";
  47.             $context["defaultLanguageHumanReadable"] = twig_get_attribute($this->env$this->sourcetwig_constant("App\\Util\\Locales::ISO6391_HUMAN_READABLE"), (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage"$context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.'6$this->source); })()), [], "array"falsefalsefalse6);
  48.             // line 7
  49.             echo "    ";
  50.             $context["translationLanguages"] = twig_array_merge([(isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage"$context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.'7$this->source); })()) => (isset($context["defaultLanguageHumanReadable"]) || array_key_exists("defaultLanguageHumanReadable"$context) ? $context["defaultLanguageHumanReadable"] : (function () { throw new RuntimeError('Variable "defaultLanguageHumanReadable" does not exist.'7$this->source); })())], (isset($context["translationLanguages"]) || array_key_exists("translationLanguages"$context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.'7$this->source); })()));
  51.             // line 8
  52.             echo "
  53.     ";
  54.             // line 9
  55.             $this->extensions['App\Twig\Extension\DomExtension']->dom_scripts_($context"head", [=> "https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"]);
  56.             // line 12
  57.             echo "
  58.     <div class=\"col-auto mp__head-right\">
  59.         <div id=\"language-switcher\" class=\"dropdown dropdown-lang notranslate\">
  60.             <a class=\"select-lang dropdown-toggle\" href=\"#\" role=\"button\" data-toggle=\"dropdown\"
  61.                aria-expanded=\"false\">";
  62.             // line 16
  63.             echo twig_escape_filter($this->envtwig_get_attribute($this->env$this->source, (isset($context["translationLanguages"]) || array_key_exists("translationLanguages"$context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.'16$this->source); })()), (isset($context["userEffectiveLanguage"]) || array_key_exists("userEffectiveLanguage"$context) ? $context["userEffectiveLanguage"] : (function () { throw new RuntimeError('Variable "userEffectiveLanguage" does not exist.'16$this->source); })()), [], "array"falsefalsefalse16), "html"nulltrue);
  64.             echo "</a>
  65.             <div class=\"dropdown-menu\" aria-labelledby=\"select-language\">
  66.                 ";
  67.             // line 19
  68.             $context['_parent'] = $context;
  69.             $context['_seq'] = twig_ensure_traversable((isset($context["translationLanguages"]) || array_key_exists("translationLanguages"$context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.'19$this->source); })()));
  70.             foreach ($context['_seq'] as $context["lang"] => $context["name"]) {
  71.                 // line 20
  72.                 echo "                    <a class=\"dropdown-item";
  73.                 if (((isset($context["userEffectiveLanguage"]) || array_key_exists("userEffectiveLanguage"$context) ? $context["userEffectiveLanguage"] : (function () { throw new RuntimeError('Variable "userEffectiveLanguage" does not exist.'20$this->source); })()) === $context["lang"])) {
  74.                     echo " d-none";
  75.                 }
  76.                 echo "\"
  77.                        href=\"#\" data-href=\"";
  78.                 // line 21
  79.                 echo twig_escape_filter($this->env$this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("app.notifications.portal.language.set", ["language" => $context["lang"]]), "html"nulltrue);
  80.                 echo "\"
  81.                        data-lang=\"";
  82.                 // line 22
  83.                 echo twig_escape_filter($this->env$context["lang"], "html"nulltrue);
  84.                 echo "\">";
  85.                 echo twig_escape_filter($this->env$context["name"], "html"nulltrue);
  86.                 echo "</a>
  87.                 ";
  88.             }
  89.             $_parent $context['_parent'];
  90.             unset($context['_seq'], $context['_iterated'], $context['lang'], $context['name'], $context['_parent'], $context['loop']);
  91.             $context array_intersect_key($context$_parent) + $_parent;
  92.             // line 24
  93.             echo "            </div>
  94.         </div>
  95.     </div>
  96.     <script type=\"text/javascript\">
  97.         (function (window, document, \$, undefined) {
  98.             \$(function () {
  99.                 \$('#language-switcher .dropdown-menu').on('click', 'a.dropdown-item', function (e) {
  100.                     e.preventDefault();
  101.                     var lang = \$(this).attr('data-lang');
  102.                     \$('#language-switcher .select-lang').text(\$(this).text());
  103.                     \$('#language-switcher .dropdown-menu .dropdown-item').each(function (index, elem) {
  104.                         \$(elem).toggleClass(
  105.                             'd-none',
  106.                             (\$(elem).attr('data-lang') === lang)
  107.                         );
  108.                     });
  109.                     ";
  110.             // line 44
  111.             if (twig_get_attribute($this->env$this->source, (isset($context["app"]) || array_key_exists("app"$context) ? $context["app"] : (function () { throw new RuntimeError('Variable "app" does not exist.'44$this->source); })()), "user", [], "any"falsefalsefalse44)) {
  112.                 // line 45
  113.                 echo "                    \$.ajax({
  114.                         url: \$(this).attr('data-href'),
  115.                         method: 'GET',
  116.                     });
  117.                     ";
  118.             }
  119.             // line 50
  120.             echo "
  121.                     if (lang === '";
  122.             // line 51
  123.             echo twig_escape_filter($this->env, (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage"$context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.'51$this->source); })()), "html"nulltrue);
  124.             echo "') {
  125.                         dismissGoogleTranslate();
  126.                         \$('#language-switcher .select-lang').text('";
  127.             // line 53
  128.             echo twig_escape_filter($this->env, (isset($context["defaultLanguageHumanReadable"]) || array_key_exists("defaultLanguageHumanReadable"$context) ? $context["defaultLanguageHumanReadable"] : (function () { throw new RuntimeError('Variable "defaultLanguageHumanReadable" does not exist.'53$this->source); })()), "html"nulltrue);
  129.             echo "');
  130.                     } else {
  131.                         triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
  132.                     }
  133.                 });
  134.             });
  135.         })(window, document, jQuery);
  136.         function googleTranslateElementInit() {
  137.             new google.translate.TranslateElement({
  138.                 pageLanguage: '";
  139.             // line 65
  140.             echo twig_escape_filter($this->env, (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage"$context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.'65$this->source); })()), "html"nulltrue);
  141.             echo "',
  142.                 includedLanguages: '";
  143.             // line 66
  144.             echo twig_escape_filter($this->envtwig_join_filter(twig_get_array_keys_filter((isset($context["translationLanguages"]) || array_key_exists("translationLanguages"$context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.'66$this->source); })())), ","), "html"nulltrue);
  145.             echo "',
  146.                 layout: google.translate.TranslateElement.InlineLayout.simple,
  147.             }, 'google_translate_element');
  148.             // set cookie
  149.             var lang = '";
  150.             // line 72
  151.             echo twig_escape_filter($this->env, (isset($context["userEffectiveLanguage"]) || array_key_exists("userEffectiveLanguage"$context) ? $context["userEffectiveLanguage"] : (function () { throw new RuntimeError('Variable "userEffectiveLanguage" does not exist.'72$this->source); })()), "html"nulltrue);
  152.             echo "';
  153.             var intervalId = setInterval(function(){
  154.                 if (\$('.goog-te-combo').length > 0){ // Check if element has been found
  155.                     if (lang !== '";
  156.             // line 75
  157.             echo twig_escape_filter($this->env, (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage"$context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.'75$this->source); })()), "html"nulltrue);
  158.             echo "' && \$('.goog-te-combo').val() !== lang) {
  159.                         triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
  160.                     }
  161.                     clearInterval(intervalId);
  162.                 }
  163.             }, 1000);
  164.         }
  165.         // fire google change event, set cookie
  166.         function triggerLangChangeEvent(element, eventName, lang) {
  167.             \$('.goog-te-combo').val(lang);
  168.             var event;
  169.             if (document.createEvent) {
  170.                 event = document.createEvent('HTMLEvents');
  171.                 event.initEvent(eventName, true, true);
  172.                 element.dispatchEvent(event);
  173.             } else {
  174.                 event = document.createEventObject();
  175.                 event.eventType = eventName;
  176.                 element.fireEvent('on' + event.eventType, event);
  177.             }
  178.         }
  179.         // back to default language
  180.         function dismissGoogleTranslate() {
  181.             // find `iframe` element with GoogleTranslate select and buttons
  182.             var iframe = document.getElementsByClassName('goog-te-banner-frame')[0]
  183.                 || document.getElementById(':1.container');
  184.             if (!iframe) return;
  185.             // search all buttons from the retrieved iframe
  186.             var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
  187.             var restore_el = innerDoc.getElementsByTagName(\"button\");
  188.             // fire `click` event on the `restore` button, that `Shows the origin`
  189.             for (var i = 0; i < restore_el.length; i++) {
  190.                 if (restore_el[i].id.indexOf(\"restore\") >= 0) {
  191.                     restore_el[i].click();
  192.                     return;
  193.                 }
  194.             }
  195.         }
  196.     </script>
  197.     <div class=\"google-translate d-none\" id=\"google_translate_element\"></div>
  198.     <style>
  199.         body {
  200.             position: static !important;
  201.             top: 0 !important;
  202.         }
  203.         .skiptranslate {
  204.             display: none !important;
  205.         }
  206.     </style>
  207. ";
  208.         }
  209.         
  210.         $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  211.         
  212.         $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  213.     }
  214.     public function getTemplateName()
  215.     {
  216.         return "@ui2022/translate_widget.html.twig";
  217.     }
  218.     public function isTraitable()
  219.     {
  220.         return false;
  221.     }
  222.     public function getDebugInfo()
  223.     {
  224.         return array (  176 => 75,  170 => 72,  161 => 66,  157 => 65,  142 => 53,  137 => 51,  134 => 50,  127 => 45,  125 => 44,  103 => 24,  93 => 22,  89 => 21,  82 => 20,  78 => 19,  72 => 16,  66 => 12,  64 => 9,  61 => 8,  58 => 7,  55 => 6,  52 => 5,  50 => 4,  47 => 3,  45 => 2,  43 => 1,);
  225.     }
  226.     public function getSourceContext()
  227.     {
  228.         return new Source("{% set translationLanguages = _args.languages|default(cms.translationLanguages) %}
  229. {% set userEffectiveLanguage = cms.userEffectiveLanguage %}
  230. {% if translationLanguages is not empty %}
  231.     {% set defaultLanguage = constant('App\\\\Util\\\\Locales::ISO6391__ENGLISH') %}
  232.     {% set defaultLanguageHumanReadable = (constant('App\\\\Util\\\\Locales::ISO6391_HUMAN_READABLE'))[defaultLanguage] %}
  233.     {% set translationLanguages  = {(defaultLanguage): defaultLanguageHumanReadable}|merge(translationLanguages) %}
  234.     {% do dom_scripts_head([
  235.         'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit',
  236.     ]) %}
  237.     <div class=\"col-auto mp__head-right\">
  238.         <div id=\"language-switcher\" class=\"dropdown dropdown-lang notranslate\">
  239.             <a class=\"select-lang dropdown-toggle\" href=\"#\" role=\"button\" data-toggle=\"dropdown\"
  240.                aria-expanded=\"false\">{{ translationLanguages[userEffectiveLanguage] }}</a>
  241.             <div class=\"dropdown-menu\" aria-labelledby=\"select-language\">
  242.                 {% for lang, name in translationLanguages %}
  243.                     <a class=\"dropdown-item{% if userEffectiveLanguage is same as(lang) %} d-none{% endif %}\"
  244.                        href=\"#\" data-href=\"{{ path('app.notifications.portal.language.set', {language: lang}) }}\"
  245.                        data-lang=\"{{ lang }}\">{{ name }}</a>
  246.                 {% endfor %}
  247.             </div>
  248.         </div>
  249.     </div>
  250.     <script type=\"text/javascript\">
  251.         (function (window, document, \$, undefined) {
  252.             \$(function () {
  253.                 \$('#language-switcher .dropdown-menu').on('click', 'a.dropdown-item', function (e) {
  254.                     e.preventDefault();
  255.                     var lang = \$(this).attr('data-lang');
  256.                     \$('#language-switcher .select-lang').text(\$(this).text());
  257.                     \$('#language-switcher .dropdown-menu .dropdown-item').each(function (index, elem) {
  258.                         \$(elem).toggleClass(
  259.                             'd-none',
  260.                             (\$(elem).attr('data-lang') === lang)
  261.                         );
  262.                     });
  263.                     {% if app.user %}
  264.                     \$.ajax({
  265.                         url: \$(this).attr('data-href'),
  266.                         method: 'GET',
  267.                     });
  268.                     {% endif %}
  269.                     if (lang === '{{ defaultLanguage }}') {
  270.                         dismissGoogleTranslate();
  271.                         \$('#language-switcher .select-lang').text('{{ defaultLanguageHumanReadable }}');
  272.                     } else {
  273.                         triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
  274.                     }
  275.                 });
  276.             });
  277.         })(window, document, jQuery);
  278.         function googleTranslateElementInit() {
  279.             new google.translate.TranslateElement({
  280.                 pageLanguage: '{{ defaultLanguage }}',
  281.                 includedLanguages: '{{ translationLanguages|keys|join(',') }}',
  282.                 layout: google.translate.TranslateElement.InlineLayout.simple,
  283.             }, 'google_translate_element');
  284.             // set cookie
  285.             var lang = '{{ userEffectiveLanguage }}';
  286.             var intervalId = setInterval(function(){
  287.                 if (\$('.goog-te-combo').length > 0){ // Check if element has been found
  288.                     if (lang !== '{{ defaultLanguage }}' && \$('.goog-te-combo').val() !== lang) {
  289.                         triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
  290.                     }
  291.                     clearInterval(intervalId);
  292.                 }
  293.             }, 1000);
  294.         }
  295.         // fire google change event, set cookie
  296.         function triggerLangChangeEvent(element, eventName, lang) {
  297.             \$('.goog-te-combo').val(lang);
  298.             var event;
  299.             if (document.createEvent) {
  300.                 event = document.createEvent('HTMLEvents');
  301.                 event.initEvent(eventName, true, true);
  302.                 element.dispatchEvent(event);
  303.             } else {
  304.                 event = document.createEventObject();
  305.                 event.eventType = eventName;
  306.                 element.fireEvent('on' + event.eventType, event);
  307.             }
  308.         }
  309.         // back to default language
  310.         function dismissGoogleTranslate() {
  311.             // find `iframe` element with GoogleTranslate select and buttons
  312.             var iframe = document.getElementsByClassName('goog-te-banner-frame')[0]
  313.                 || document.getElementById(':1.container');
  314.             if (!iframe) return;
  315.             // search all buttons from the retrieved iframe
  316.             var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
  317.             var restore_el = innerDoc.getElementsByTagName(\"button\");
  318.             // fire `click` event on the `restore` button, that `Shows the origin`
  319.             for (var i = 0; i < restore_el.length; i++) {
  320.                 if (restore_el[i].id.indexOf(\"restore\") >= 0) {
  321.                     restore_el[i].click();
  322.                     return;
  323.                 }
  324.             }
  325.         }
  326.     </script>
  327.     <div class=\"google-translate d-none\" id=\"google_translate_element\"></div>
  328.     <style>
  329.         body {
  330.             position: static !important;
  331.             top: 0 !important;
  332.         }
  333.         .skiptranslate {
  334.             display: none !important;
  335.         }
  336.     </style>
  337. {% endif %}
  338. ""@ui2022/translate_widget.html.twig""/var/www/campussuite/ui2022/translate_widget.html.twig");
  339.     }
  340. }