HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/NVonken/mijneigenlied.com/wwwroot/Core/Page Elements/menu.element.php
<?php
	
	
	class Element_Menu
	{
		var $_tpl;
		public $elementName = 'Menu';
		
		public static function Settings()
		{
			return array(	"Pageable" 		=> false,
							"DisplayName" 	=> "Menu",
							"Version" 		=> 1.0,
							"Filename"		=> "menu.element.php");
		}
		
		public function __construct()
		{
			General::Load("Menu");
		}
		
		public function Run()
		{
			$this->_tpl = new tpl();
			$menus = Menu::SelectAllByParent(null, ACTIVE_LANGUAGE, ACTIVE_HATCH_ID);
			return $this->_generateMenuStructure($menus);
		}
		
		private function _generateMenuStructure($menus, $level = 0)
		{
			$menuList = "";
			foreach($menus as $menu)
			{
				$subs = Menu::SelectAllByParent($menu->Id, ACTIVE_LANGUAGE, ACTIVE_HATCH_ID);
				if($subs != null){
					 $this->_tpl->assign("subItems",$this->_generateMenuStructure($subs, ($level + 1)));		
				}
				else
				{
					$this->_tpl->assign("subItems","");
				}
				if($menu->PageId > 0)
				{
                    $this->_tpl->assign("active", defined("GET_1") && strtolower(GET_1) == strtolower($menu->_otherFields["PageSlug"]) ? "active" : "");
					$this->_tpl->assign("menuUrl", BASE_URL."/".strtolower($menu->_otherFields["PageSlug"]).".html");
				}
				else
				{
					$this->_tpl->assign("menuUrl", $menu->Url);
				}
				
				$this->_tpl->assign("menuTarget", $menu->Target);
				$this->_tpl->assign("menuTitle", $menu->Title);

                $menuList .= $this->_tpl->parse("Menu/item");
						
			}
			$this->_tpl->assign("items", $menuList);
			return $this->_tpl->parse("Menu/container");
		}
	}
	
?>