app/Modules/ModuleQuadrilaserHeader.php line 84

Open in your IDE?
  1. <?php
  2. namespace App\Modules;
  3. use Addictic\ContaoMultilangBundle\Controller\FrontendModule\LanguageSwitcherController;
  4. use Addictic\ContaoMultilangBundle\Multilang\EntityMultilang;
  5. use Addictic\ContaoMultilangBundle\Multilang\Multilang;
  6. use App\Classes\Commons;
  7. use App\Modules\ModuleQuadrilaser;
  8. use Contao\Config;
  9. use Contao\CoreBundle\ServiceAnnotation\FrontendModule;
  10. use Contao\FrontendTemplate;
  11. use Contao\Module;
  12. use Contao\ModuleCustomnav;
  13. use Contao\ModuleModel;
  14. use Contao\ModuleNavigation;
  15. use Contao\PageModel;
  16. use Contao\System;
  17. class ModuleQuadrilaserHeader extends Module
  18. {
  19.     protected $strTemplate 'mod_quadrilaser_header';
  20.     public function generate()
  21.     {
  22.         return parent::generate();
  23.     }
  24.     public function compile()
  25.     {
  26.         $objRootPage Commons::getRootPage();
  27.         // NAV
  28.         $pageIds $this->navPages unserialize($this->navPages) : [];
  29.         $secondaryPageIds $this->secondaryNavPages unserialize($this->secondaryNavPages) : [];
  30.         $firstLevelItems PageModel::findBy([
  31.             'id in ( ' implode(','$pageIds) . ' )',
  32.             'published = 1'
  33.         ], []);
  34.         foreach($firstLevelItems as &$item){
  35.             $item->children PageModel::findByPid($item->id);
  36.         }
  37.         $this->Template->navItems $firstLevelItems;
  38.         $this->Template->secondaryNavItems PageModel::findBy([
  39.             'id in ( ' implode(','$secondaryPageIds) . ' )',
  40.             'published = 1'
  41.         ], []);
  42.         $scanLandingPage  PageModel::findOneById($this->scanLandingPage);
  43.         $this->Template->scanLandingPage $scanLandingPage;
  44.         $this->Template->scanLandingPageLogo Commons::getImg($scanLandingPage->siteLogoMonoChrome);
  45.         // LOGO
  46.         $logo Commons::getLogo();
  47.         $this->Template->logoSRC $logo["path"];
  48.         $this->Template->logoAlt $logo["alt"] ?? 'Logo de Quadrilaser';
  49.         $this->Template->logoTitle $objRootPage->title;
  50.         $whiteLogo Commons::getLogoWhite();
  51.         $this->Template->logoWhiteSRC $whiteLogo["path"];
  52.         $homePage Commons::getHomePage();
  53.         $this->Template->logoLink $homePage->getFrontendUrl();
  54.         $contactPage PageModel::findOneById(Config::get('contactPage'));
  55.         $clientPage PageModel::findOneById(Config::get('clientPage'));
  56.         $contactPage EntityMultilang::getActiveLangVariant($contactPage);
  57.         $clientPage EntityMultilang::getActiveLangVariant($clientPage);
  58.         $this->Template->contactLink $contactPage->getFrontendUrl();
  59.         $this->Template->contactText $GLOBALS['TL_LANG']['quadrilaser']['contact'];
  60.         $this->Template->clientLink $clientPage->getFrontendUrl();
  61.         $this->Template->clientText $GLOBALS['TL_LANG']['quadrilaser']['client'];
  62.         System::getContainer()->get('contao.fragment._contao.frontend_module.language_switcher');
  63.         $template = new FrontendTemplate("mod_language_switcher");
  64.         $template->languages Multilang::getEnabledLanguages();
  65.         $template->activeLanguage Multilang::getActiveLanguage();
  66.         $template->switcherLayout "flag";
  67.         $this->Template->languageSwitcher $template->parse();
  68.     }
  69. }