]> _ Git - cubist_cms-back.git/commitdiff
wip #2922 @0:15
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Sep 2019 09:17:57 +0000 (11:17 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Sep 2019 09:17:57 +0000 (11:17 +0200)
src/app/Magic/Menu/Item.php
src/app/Magic/Menu/PageItem.php

index de029a2914f0562a3b8551ee669bd38eee37119e..92b6009b12fe7649164127b1174feff929d198e8 100644 (file)
@@ -49,6 +49,25 @@ class Item
      */
     protected $_type = '';
 
+    /**
+     * @var bool
+     */
+    protected $_menu_desktop = true;
+
+    /**
+     * @var bool
+     */
+    protected $_menu_desktop_children = true;
+
+    /**
+     * @var bool
+     */
+    protected $_menu_mobile = true;
+    /**
+     * @var bool
+     */
+    protected $_menu_mobile_children = true;
+
 
     /**
      * @var array
@@ -460,4 +479,86 @@ class Item
     {
         $this->_urlAliases = $urlAliases;
     }
+
+    /**
+     * @param bool $menu_desktop
+     */
+    public function setMenuDesktop(bool $menu_desktop): void
+    {
+        $this->_menu_desktop = $menu_desktop;
+    }
+
+    /**
+     * @param bool $menu_desktop_children
+     */
+    public function setMenuDesktopChildren(bool $menu_desktop_children): void
+    {
+        $this->_menu_desktop_children = $menu_desktop_children;
+    }
+
+    /**
+     * @param bool $menu_mobile
+     */
+    public function setMenuMobile(bool $menu_mobile): void
+    {
+        $this->_menu_mobile = $menu_mobile;
+    }
+
+    /**
+     * @param bool $menu_mobile_children
+     */
+    public function setMenuMobileChildren(bool $menu_mobile_children): void
+    {
+        $this->_menu_mobile_children = $menu_mobile_children;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isMenuDesktop(): bool
+    {
+        return $this->_menu_desktop;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isMenuDesktopChildren(): bool
+    {
+        return $this->isMenuDesktop() && $this->_menu_desktop_children;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isMenuMobile(): bool
+    {
+        return $this->_menu_mobile;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isMenuMobileChildren(): bool
+    {
+        return $this->isMenuMobile() && $this->_menu_mobile_children;
+    }
+
+    public function hideInAllMenus()
+    {
+        $this->_allMenus(false);
+    }
+
+    public function showInAllMenus()
+    {
+        $this->_allMenus(true);
+    }
+
+    protected function _allMenus(bool $val)
+    {
+        $this->setMenuDesktop($val);
+        $this->setMenuMobile($val);
+        $this->setMenuDesktopChildren($val);
+        $this->setMenuMobileChildren($val);
+    }
 }
index 9ec85c72af06c4cdbf24eb12d8e6685d37e331e3..4f491f5791647ff2f41d0c80d7495cfe6f121b15 100644 (file)
@@ -43,6 +43,14 @@ class PageItem extends Item
         $this->setName($entity->name ?? get_class($entity) . '_' . $entity->id);
         $this->setSlug($entity->slug);
         $this->setTitle($entity->title);
+
+        $this->setMenuDesktop($entity->menu_desktop != 'no');
+        $this->setMenuDesktopChildren($entity->menu_desktop == 'children');
+
+        $mobile = $entity->menu_mobile == 'desktop' ? $entity->menu_desktop : $entity->menu_mobile;
+        $this->setMenuMobile($mobile != 'no');
+        $this->setMenuMobileChildren($mobile == 'children');
+
         $dbaliases = $entity->getPageData()->url_alias;
         if (is_array($dbaliases)) {
             $aliases = [];
@@ -57,7 +65,7 @@ class PageItem extends Item
     {
         if ($this->getPage() instanceof CMSPage) {
             $template = $this->getPage()->getUsedTemplate();
-            if(null!==$template) {
+            if (null !== $template) {
                 $template->setMenuChildren($this);
             }
         }
@@ -112,7 +120,7 @@ class PageItem extends Item
     public function isVirtual()
     {
         if (null === $this->_isVirtual) {
-            if ($this->getPage() instanceof CMSPage && null!==$this->getPage()->getUsedTemplate()) {
+            if ($this->getPage() instanceof CMSPage && null !== $this->getPage()->getUsedTemplate()) {
                 $this->_isVirtual = $this->getPage()->getUsedTemplate()->isVirtual();
             } else {
                 $this->_isVirtual = false;