vendor/contao/core-bundle/src/Resources/contao/modules/ModuleNavigation.php line 53

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Contao.
  4.  *
  5.  * (c) Leo Feyer
  6.  *
  7.  * @license LGPL-3.0-or-later
  8.  */
  9. namespace Contao;
  10. /**
  11.  * Front end module "navigation".
  12.  */
  13. class ModuleNavigation extends Module
  14. {
  15.     /**
  16.      * Template
  17.      * @var string
  18.      */
  19.     protected $strTemplate 'mod_navigation';
  20.     /**
  21.      * Do not display the module if there are no menu items
  22.      *
  23.      * @return string
  24.      */
  25.     public function generate()
  26.     {
  27.         $request System::getContainer()->get('request_stack')->getCurrentRequest();
  28.         if ($request && System::getContainer()->get('contao.routing.scope_matcher')->isBackendRequest($request))
  29.         {
  30.             $objTemplate = new BackendTemplate('be_wildcard');
  31.             $objTemplate->wildcard '### ' $GLOBALS['TL_LANG']['FMD']['navigation'][0] . ' ###';
  32.             $objTemplate->title $this->headline;
  33.             $objTemplate->id $this->id;
  34.             $objTemplate->link $this->name;
  35.             $objTemplate->href StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', array('do'=>'themes''table'=>'tl_module''act'=>'edit''id'=>$this->id)));
  36.             return $objTemplate->parse();
  37.         }
  38.         $strBuffer parent::generate();
  39.         return $this->Template->items $strBuffer '';
  40.     }
  41.     /**
  42.      * Generate the module
  43.      */
  44.     protected function compile()
  45.     {
  46.         /** @var PageModel $objPage */
  47.         global $objPage;
  48.         // Set the trail and level
  49.         if ($this->defineRoot && $this->rootPage 0)
  50.         {
  51.             $trail = array($this->rootPage);
  52.             $level 0;
  53.         }
  54.         else
  55.         {
  56.             $trail $objPage->trail;
  57.             $level = ($this->levelOffset 0) ? $this->levelOffset 0;
  58.         }
  59.         $lang null;
  60.         $host null;
  61.         // Overwrite the domain and language if the reference page belongs to a different root page (see #3765)
  62.         if ($this->defineRoot && $this->rootPage && ($objRootPage PageModel::findWithDetails($this->rootPage)))
  63.         {
  64.             $lang $objRootPage->rootLanguage;
  65.             $host $objRootPage->domain;
  66.         }
  67.         $this->Template->request StringUtil::ampersand(Environment::get('indexFreeRequest'));
  68.         $this->Template->skipId 'skipNavigation' $this->id;
  69.         $this->Template->skipNavigation StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']);
  70.         $this->Template->items = isset($trail[$level]) ? $this->renderNavigation($trail[$level], 1$host$lang) : '';
  71.     }
  72. }
  73. class_alias(ModuleNavigation::class, 'ModuleNavigation');