<?php


?>
<?php if($this->navigation || $this->quickcreate) { ?>
		<a class="header_minimenu_icon" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
			<i class="fi fi-rr-apps"></i>
		</a>
	<?php
		$menuClass = '';
		if(engine_in_array('mainMenu',$this->options) && !empty($this->navigation) && !empty($this->quickcreate) && $this->viewer->getIdentity()) {
			$menuClass = 'both_menu';
		} elseif(engine_in_array('mainMenu',$this->options) && !empty($this->navigation)) {
			$menuClass = 'only_dashboardmenu';
		} elseif(!empty($this->quickcreate)) {
			$menuClass = 'only_createmenu';
		}
	?>
	<div id="pulse_header_mainmenu_dropdown" class="dropdown-menu pulse_header_mainmenu_dropdown dropdown-menu-end <?php echo $menuClass; ?>">
		<div class="pulse_header_mainmenu_dropdown_inner">
			<div class="pulse_header_mainmenu_dropdown_header">
				<h2 class="pulse_header_mainmenu_dropdown_heading"><?php echo $this->translate("Menu"); ?></h2>
			</div>
			<div class="pulse_header_mainmenu_dropdown_body">
				<?php if(engine_in_array('mainMenu',$this->options) && !empty($this->navigation)) { ?>
					<div class="pulse_header_mainmenu">
						<div class="pulse_header_mainmenu_input">
							<i class="fa-solid fa-magnifying-glass"></i>
							<input type="text" placeholder="<?php echo $this->translate('Search'); ?>" class="dashboard_search_input">
						</div>
						<div class="pulse_header_mainmenu_item_container">
							<?php foreach( $this->navigation as $link ): ?>
								<?php 
									$explodedString = explode(' ', $link->class);
									$menuName = end($explodedString); 
									$moduleName = str_replace('core_main_', '', $menuName);
									if(strpos($moduleName, 'custom_') !== 0){
										$moduleName = $moduleName.'_main';
									}
								?>
								<div class="pulse_header_mainmenu_item <?php echo $link->get('active') ? 'active' : '' ?>">
									<a href='<?php echo $link->getHref() ?>' class="pulse_header_mainmenu_item_link <?php echo $link->getClass() ? ' ' . $link->getClass() : ''  ?>" <?php if( $link->get('target') ): ?> target='<?php echo $link->get('target') ?>' <?php endif; ?> >
										<div class="pulse_header_mainmenu_item_icon">
											<?php if (isset($link->file_id) && !empty($link->file_id)): ?>
												<?php $photo = Engine_Api::_()->storage()->get($link->file_id, '');
												if ($photo) {
													$photo = $photo->map(); ?>		
													<img src="<?php echo $photo; ?>" alt="<?php echo $this->translate($link->getlabel()) ?>" height="40" width="40" />
												<?php } else { ?>
													 <i class="<?php echo $link->get('icon') ? $link->get('icon') : 'fa fa-star' ?>"></i>
												<?php } ?>
											<?php else: ?>
												 <i class="<?php echo $link->get('icon') ? $link->get('icon') : 'fa fa-star' ?>"></i>
											<?php endif; ?>
										</div>
										<div class="pulse_header_mainmenu_item_content">
											<h4><?php echo $this->translate($link->getlabel()) ?></h4>
											<?php if (isset($link->description) && !empty($link->description)) { ?>
												<p class="_text"><?php echo $this->translate($link->description) ?></p>
											<?php } ?>
										</div>
									</a>
								</div>
							<?php endforeach; ?>
							<div class="dashboard_no_result" style="display:none; text-align:center; padding:15px;">
								<?php echo $this->translate("No results found"); ?>
							</div>
						</div>
					</div>
				<?php } ?>
				<?php if(!empty($this->quickcreate) && engine_count($this->quickcreate) > 0 && $this->viewer->getIdentity()) { ?>
					<div class="createmenu_dropdown">
						<div class="createmenu_head">
							<h2 class="createmenu_dropdown_heading"><?php echo $this->translate("Create"); ?></h2>
						</div>
						<?php foreach ($this->quickcreate as $link): ?>
							<?php 
								$explodedString = explode(' ', $link->class);
								$menuName = end($explodedString); 
								$moduleName = str_replace('core_main_', '', $menuName);
								if(strpos($moduleName, 'custom_') !== 0){
									$moduleName = $moduleName.'_main';
								}
							?>
							<div class="createmenu_body">
								<a href='<?php echo $link->getHref() ?>' class="createmenu_dropdown_item"
									<?php if( $link->get('target') ): ?> target='<?php echo $link->get('target') ?>' <?php endif; ?> >
									<div class="createmenu_dropdown_item_image">
										<i class="<?php echo $link->get('icon') ? $link->get('icon') : 'fa fa-star' ?>"></i>
									</div>
									<div class="createmenu_dropdown_item_content">
										<p><?php echo $this->translate($link->getlabel()) ?></p>
									</div>
								</a>
							</div>
						<?php endforeach; ?>
					</div>
				<?php } ?>
			</div>
		</div>
	</div>
<?php } ?>