<?php
namespace App\Modules;
use Addictic\ContaoMultilangBundle\Controller\FrontendModule\LanguageSwitcherController;
use Addictic\ContaoMultilangBundle\Multilang\EntityMultilang;
use Addictic\ContaoMultilangBundle\Multilang\Multilang;
use App\Classes\Commons;
use App\Modules\ModuleQuadrilaser;
use Contao\Config;
use Contao\CoreBundle\ServiceAnnotation\FrontendModule;
use Contao\FrontendTemplate;
use Contao\Module;
use Contao\ModuleCustomnav;
use Contao\ModuleModel;
use Contao\ModuleNavigation;
use Contao\PageModel;
use Contao\System;
class ModuleQuadrilaserHeader extends Module
{
protected $strTemplate = 'mod_quadrilaser_header';
public function generate()
{
return parent::generate();
}
public function compile()
{
$objRootPage = Commons::getRootPage();
// NAV
$pageIds = $this->navPages ? unserialize($this->navPages) : [];
$secondaryPageIds = $this->secondaryNavPages ? unserialize($this->secondaryNavPages) : [];
$firstLevelItems = PageModel::findBy([
'id in ( ' . implode(',', $pageIds) . ' )',
'published = 1'
], []);
foreach($firstLevelItems as &$item){
$item->children = PageModel::findByPid($item->id);
}
$this->Template->navItems = $firstLevelItems;
$this->Template->secondaryNavItems = PageModel::findBy([
'id in ( ' . implode(',', $secondaryPageIds) . ' )',
'published = 1'
], []);
$scanLandingPage = PageModel::findOneById($this->scanLandingPage);
$this->Template->scanLandingPage = $scanLandingPage;
$this->Template->scanLandingPageLogo = Commons::getImg($scanLandingPage->siteLogoMonoChrome);
// LOGO
$logo = Commons::getLogo();
$this->Template->logoSRC = $logo["path"];
$this->Template->logoAlt = $logo["alt"] ?? 'Logo de Quadrilaser';
$this->Template->logoTitle = $objRootPage->title;
$whiteLogo = Commons::getLogoWhite();
$this->Template->logoWhiteSRC = $whiteLogo["path"];
$homePage = Commons::getHomePage();
$this->Template->logoLink = $homePage->getFrontendUrl();
$contactPage = PageModel::findOneById(Config::get('contactPage'));
$clientPage = PageModel::findOneById(Config::get('clientPage'));
$contactPage = EntityMultilang::getActiveLangVariant($contactPage);
$clientPage = EntityMultilang::getActiveLangVariant($clientPage);
$this->Template->contactLink = $contactPage->getFrontendUrl();
$this->Template->contactText = $GLOBALS['TL_LANG']['quadrilaser']['contact'];
$this->Template->clientLink = $clientPage->getFrontendUrl();
$this->Template->clientText = $GLOBALS['TL_LANG']['quadrilaser']['client'];
System::getContainer()->get('contao.fragment._contao.frontend_module.language_switcher');
$template = new FrontendTemplate("mod_language_switcher");
$template->languages = Multilang::getEnabledLanguages();
$template->activeLanguage = Multilang::getActiveLanguage();
$template->switcherLayout = "flag";
$this->Template->languageSwitcher = $template->parse();
}
}