<? include(TAO_TPL_PATH . 'layout_header.tpl') ?>
<header class="dark-bar clearfix" style="direction:ltr;">
	<nav>
		<div class="rgt">
			<a href="<?=BASE_URL?>"><img src="<?=TAO_LOGO?>" alt="ptech-logo" id="tao-main-logo"/></a>
		</div>
		<div class="plain rgt main-menu-wrapper">
		<ul class="plain rgt main-menu" >		
			<?$first = true;foreach(get_data('extensions') as $extension):?>
				<?php if ($extension['enabled']): ?>
					<li <?php if (get_data('shownExtension') == $extension['extension']): ?>class="active"<?php endif ?>>
						
						<a href="<?=_url('index', null, null, array('structure' => $extension['id'], 'ext' => $extension['extension']))?>" title="<?=__($extension['description'])?>"><span class="fa <?=$extension['extension']?>"></span><?=__($extension['name'])?></a>
					</li>
				<?php endif; ?>
			<?endforeach?>
		</ul>
		</div>
		<div class="more-button" onclick="toggleFullMenu();"><a href="javascript:void(0);" title="<?=__('More')?>" ><i id="more-menu-button" class="fas fa-angle-double-down"></i></a></div>
		
		<div class="settings-menu lft">
			<ul class="padding_0 clearfix">
				
				<!-- top boxes section -->
				<?php
					$topboxService = tao_models_classes_topbox_TopBoxService::singleton();
					$topboxes = $topboxService->getAllActiveTopBoxes();
					$user = tao_models_classes_UserService::singleton()->getCurrentUser();
					
					foreach ($topboxes as $topbox) {
						$topBoxImplementation = $topboxService->getTopBoxImplementation($topbox);
						if ($topBoxImplementation->checkUser($user) == true) {
						?>
							<?=$topBoxImplementation->getContent()?>
						<?php
						}
					}
				?>
				<!-- User Settings-->
                <li class="dropdown" >
                            <a class="nav-link dropdown-toggle waves-effect waves-dark mydropbtn" style="padding-left:20px;padding-right:20px;" href="<?=_url('index', 'Main', 'tao', array('structure' => 'user_pt_settings', 'ext' => 'ptBasic'))?>#Notifications">
                                <span class="fa-stack fa-5x <?php if(get_data('notification_count') > 0){ ?> has-badge" data-count="<?=get_data('notification_count')?>"<?php } else { echo '"';} ?>>
                                  <i class="fa fa-bell fa-lg fa-inverse"></i>
                                </span>
                            </a>
                </li>
				<li class="dropdown">
				  <div class="li-user_settings userLabelDD mydropbtn" onclick="toggleUserMenu()"><span class="fa fa-chevron-down"></span><span class="username"> <i class="fa fa-lg fa-user-circle" aria-hidden="true"></i> </span></div>     
				  <div id="myDropdown" class="dropdown-content">
                      <div style="text-align:center;line-height:2em;background: #fff;" ><span class="username" style="font-weight:700;color: #266d9c;"><?php $userLabel = get_data('userLabel');
				  $userLabel = strlen($userLabel) > 22 ?   mb_substr($userLabel, 0, 22, 'UTF-8'). "..." :  $userLabel; echo $userLabel;
				  ?></span></a></div>
					<?php if (tao_helpers_funcACL_funcACL::hasAccess('tao', 'UserSettings', null)){?>
					<div ><a id="user_settings" href="<?=_url('index', 'Main', 'tao', array('structure' => 'user_pt_settings', 'ext' => 'ptBasic'))?>" ><span class="fa fa-user"></span><span class="username"> <?=__('My Settings')?></span></a></div>
					<?php } ?>
					<!-- Files Managment-->
					<?php if (tao_helpers_funcACL_funcACL::hasAccess('filemanager', 'Browser', null)){ ?>
						<div  class="li-media"><a id="media" href="#" ><span class="fa fa-file-alt"></span><span> <?=__('Media Management')?></span></a></div> 
						<?php } ?>
						<!-- Users Managment-->
						<?php if (tao_helpers_funcACL_funcACL::hasAccess('tao', 'Users', null)){ ?>
						<div  class="li-users"><a id="users" href="<?=_url('index', 'Main', 'tao', array('structure' => 'users', 'ext' => 'tao'))?>" ><span class="fa fa-users"></span><span> <?=__('User Management')?></span></a></div>
						<?php } ?>
						<!-- System Settings -->
						<?php if (tao_helpers_funcACL_funcACL::hasAccess('tao', 'Settings', null) && tao_helpers_SysAdmin::isSysAdmin()){ ?>
							<div  class="li-settings"><a id="settings" href="<?=_url('index', 'Main', 'tao', array('structure' => 'settings', 'ext' => 'tao'))?>" ><span class="fa fa-cogs"></span><span> <?=__('System Settings')?></span></a></div>
						<?php } ?>
						<!-- Logout-->
						<div  class="li-logout"><a id="logout" href="<?=_url('logout', 'Main', 'tao')?>" ><span class="fa fa-sign-out-alt fa-w-16 fa-flip-horizontal" ></span><span> <?= __('Log Out') ?></span></a></div>
				  </div>
				</li>
				
			</ul>
		</div>
			
            <div class="breaker"></div>
	</nav>
</header>


<? if(get_data('sections')):?>

	<script type='text/javascript'>
		var shownExtension	= '<?=$shownExtension?>';
		var shownStructure = '<?=$shownStructure?>';
	</script>
	<div id="tabs">
		<ul>
		<?foreach(get_data('sections') as $section):?>
			<li><a id="<?=$section['id']?>" href="<?=ROOT_URL . substr($section['url'], 1) ?>" title="<?=$section['name']?>"><?=__($section['name'])?></a></li>
		<?endforeach?>
		</ul>

		<div id="sections-aside">
			<div id="section-trees"></div>
			<div id="section-actions"></div>
		</div>
		<div class="clearfix"></div>
		<div id="section-meta"></div>
	</div>
	
<?else:?>

	<?include('main/home.tpl');?>

<?endif?>
		</div>
<? include 'layout_footer.tpl' ?>
	<script type="text/javascript">
        function toggleUserMenu() {
          $('#myDropdown').toggle();
		}
</script>	
	</body>
</html>