Skip to content
Code-Schnipsel Gruppen Projekte
SlideOut.php 2,55 KiB
Newer Older
  • Learn to ignore specific revisions
  • Henning Leutz's avatar
    Henning Leutz committed
    <?php
    
    /**
     * This file contains \QUI\Menu\SlideOut
     */
    
    namespace QUI\Menu;
    
    use QUI;
    
    /**
     * Class SlideOut
     * Creates an slideout menu
     *
     * @package QUI\Menu
     * @author  www.pcsg.de (Henning Leutz)
     */
    class SlideOut extends QUI\Control
    {
    
        public function __construct(array $attributes = [])
    
                'showHomeLink' => true,
                'menuId' => false, // if set independent menu template will be used
                'showFirstLevelIcons' => false, // current it works only for independent menu
    
                'showLevel' => 1
    
    Henning Leutz's avatar
    Henning Leutz committed
        /**
         * @return string
         * @throws QUI\Exception
         */
    
        public function getBody(): string
    
    Henning Leutz's avatar
    Henning Leutz committed
        {
            $Engine = QUI::getTemplateManager()->getEngine();
    
    
            $collapseMobileSubmenu = $this->getAttribute('collapseMobileSubmenu');
    
            $showLevel = $this->getAttribute('showLevel');
    
                'this' => $this,
                'Project' => $this->getProject(),
                'jsControl' => 'package/quiqqer/menu/bin/SlideOut',
    
                'showHomeLink' => $this->getAttribute('showHomeLink')
            ];
    
            if ($this->getAttribute('menuId')) {
                $IndependentMenu = Independent\Handler::getMenu($this->getAttribute('menuId'));
    
    
                $template = dirname(__FILE__) . '/Menu.Independent.html';
                $params['FileMenu'] = dirname(__FILE__) . '/Menu.Children.Independent.html';
                $params['IndependentMenu'] = $IndependentMenu;
                $params['Site'] = $this->getSite();
    
                $params['collapseMobileSubmenu'] = $collapseMobileSubmenu;
    
                $params['showLevel'] = $showLevel;
                $params['showFirstLevelIcons'] = $this->getAttribute('showFirstLevelIcons');
    
                $template = dirname(__FILE__) . '/Menu.html';
    
                $params['collapseMobileSubmenu'] = $collapseMobileSubmenu;
    
                $params['showLevel'] = $showLevel;
                $params['FileMenu'] = dirname(__FILE__) . '/Menu.Children.html';
                $params['Site'] = $this->getSite();
    
    Henning Leutz's avatar
    Henning Leutz committed
    
    
            return $Engine->fetch($template);
    
    Henning Leutz's avatar
    Henning Leutz committed
        }
    
        /**
         * Return the current site
         *
    
         * @return QUI\Interfaces\Projects\Site
    
    Henning Leutz's avatar
    Henning Leutz committed
         */
    
        protected function getSite(): QUI\Interfaces\Projects\Site
    
    Henning Leutz's avatar
    Henning Leutz committed
        {
            if ($this->getAttribute('Site')) {
                return $this->getAttribute('Site');
            }
    
            return QUI::getRewrite()->getSite();
        }
    }