From: Vincent Vanwaelscappel Date: Fri, 6 Sep 2019 09:17:57 +0000 (+0200) Subject: wip #2922 @0:15 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=16338e2b9ab7a7e823d64d02a6160e57624d88ed;p=cubist_cms-back.git wip #2922 @0:15 --- diff --git a/src/app/Magic/Menu/Item.php b/src/app/Magic/Menu/Item.php index de029a2..92b6009 100644 --- a/src/app/Magic/Menu/Item.php +++ b/src/app/Magic/Menu/Item.php @@ -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); + } } diff --git a/src/app/Magic/Menu/PageItem.php b/src/app/Magic/Menu/PageItem.php index 9ec85c7..4f491f5 100644 --- a/src/app/Magic/Menu/PageItem.php +++ b/src/app/Magic/Menu/PageItem.php @@ -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;