<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<header class="inspira_header <?php if(empty($this->viewer->getIdentity())){ ?>inspira_header_guest<?php } ?> <?php if($this->menuType == 'horizontal') { echo "inspira_header_horizontal";} ?>">
	<div class="inspira_header_container">
  	<div class="header-top">
     <?php if(engine_in_array('mainMenu',$this->options)){ ?>
        <div class="navigation_button">
          <button type="button" class="toggle_button"><i class="fas fa-bars"></i></button>
        </div>
      <?php } ?>
    	<div class="header_logo">
      	<?php if(engine_in_array('logo',$this->options)){ ?>
          <div class="header_logo_normal">
            <?php echo $this->content()->renderWidget("core.menu-logo",array("logo"=>$this->logo)); ?>
          </div>
          <?php if($this->accessibility_option){ ?>
            <div class="header_logo_contrast">
              <?php echo $this->content()->renderWidget("core.menu-logo",array("logo"=>$this->logocontrast)); ?>
            </div> 
          <?php } ?>
         <?php } ?>
      </div>
      <?php if(!empty($this->search_check)) { ?>
				<div class="header_search">
					<?php if(engine_in_array('search',$this->options)){ ?>
						<i class="fas fa-search"></i>
						<?php echo $this->content()->renderWidget("core.search-mini"); ?>
					<?php } ?>      
				</div>
      <?php } ?>
      <?php if(engine_in_array('miniMenu',$this->options)){ ?>
				<div class="header_menu_mini">
					<?php if(!empty($this->search_check) && engine_in_array('search',$this->options)){ ?>
            <div class="search_button">
              <a href="javascript:void(0)">  
                <i class="fa fa-search" aria-hidden="true"></i>
              </a>
            </div>
					<?php } ?>
					<?php echo $this->content()->renderWidget("core.menu-mini"); ?>
				</div>
      <?php } ?>
   </div> 
	</div>
  <?php if($this->menuType == 'horizontal') { ?>
        <div class="inspira_main_menu">
          <div class="inspira_main_menu_container">
            <?php if(engine_in_array('mainMenu',$this->options)){ ?>
							<?php $countMenu = 0; ?>
              <ul class="navigation navigation_horizontal">
                <?php foreach( $this->navigation as $link ): ?>
                  <?php if( $countMenu < $this->menuCount ): ?>
                    <?php 
                      $explodedString = explode(' ', $link->class);
                      $menuName = end($explodedString); 
                      $moduleName = str_replace('core_main_', '', $menuName);
                      if(strpos($moduleName, 'custom_') !== 0){
                        $moduleName = $moduleName.'_main';
                      }
                    ?>
                    <?php $subMenus = Engine_Api::_()->getApi('menus', 'core')->getNavigation($moduleName); 
                      $menuSubArray = $subMenus->toArray();
                    ?>
                    <li class="<?php echo $link->get('active') ? 'active' : '' ?>">
                      <a href='<?php echo $link->getHref() ?>' class="<?php echo $link->getClass() ? ' ' . $link->getClass() : ''  ?>"
                        <?php if( $link->get('target') ): ?> target='<?php echo $link->get('target') ?>' <?php endif; ?> >
                      
                        <span><?php echo $this->translate($link->getlabel()) ?></span>
                        <?php if(count($menuSubArray) > 0 && $this->submenu): ?>
                            <i class="fa fa-angle-down"></i>
                        <?php endif; ?>
                      </a>
                      <?php if(count($menuSubArray) > 0 && $this->submenu): ?>
                        <ul class="main_menu_submenu">
                          <?php 
                          $counter = 0; 
                          foreach( $subMenus as $subMenu): 
                          $active = isset($menuSubArray[$counter]['active']) ? $menuSubArray[$counter]['active'] : 0;
                          ?>
                            <li class="clearfix <?php echo ($active) ? 'selected_sub_main_menu' : '' ?>">
                              <a href="<?php echo $subMenu->getHref(); ?>" <?php if( $subMenu->get('target') ): ?> target='<?php echo $subMenu->get('target') ?>' <?php endif; ?> class="<?php echo $subMenu->getClass(); ?>">
                                <i class="menu_icon <?php echo $subMenu->get('icon') ? $subMenu->get('icon') : 'fa fa-star' ?>"></i><span><?php echo $this->translate($subMenu->getLabel()); ?></span>
                              </a>
                            </li>
                          <?php 
                          $counter++;
                          endforeach; ?>
                        </ul>
                      <?php endif; ?>
                    </li>
                  <?php else:?>
                    <?php break;?>
                  <?php endif;?>
                  <?php $countMenu++;?>
                <?php endforeach; ?>
                <?php if (count($this->navigation) > $this->menuCount):?>
                  <?php $countMenu = 0; ?>
                  <li class="more_tab">
                    <a href="javascript:void(0);">
                      <span><?php echo $this->translate("More") ?></span>
                      <i class="fa fa-angle-down"></i>
                    </a>
                    <ul class="main_menu_submenu">
                      <?php foreach( $this->navigation as  $link ): ?>
                        <?php if ($countMenu >= $this->menuCount): ?>
                          <?php 
                            $explodedString = explode(' ', $link->class);
                            $menuName = end($explodedString); 
                            $moduleName = str_replace('core_main_', '', $menuName);
                            if(strpos($moduleName, 'custom_') !== 0){
                              $moduleName = $moduleName.'_main';
                            }
                          ?>
                          <?php 
                            $subMenus = Engine_Api::_()->getApi('menus', 'core')->getNavigation($moduleName);
                            $menuSubArray = $subMenus->toArray();
                          ?>
                          <li class="<?php echo $link->get('active') ? 'active' : '' ?>">
                            <a href='<?php echo $link->getHref() ?>' class="<?php echo $link->getClass() ? ' ' . $link->getClass() : ''  ?>"
                              <?php if( $link->get('target') ): ?> target='<?php echo $link->get('target') ?>' <?php endif; ?> >
                              <span><?php echo $this->translate($link->getlabel()) ?></span>
                            </a>
                          </li>
                        <?php endif;?>
                        <?php $countMenu++;?>
                      <?php endforeach; ?>
                    </ul>
                  </li>
                <?php endif;?>
              </ul>
              <?php include APPLICATION_PATH . '/application/modules/Inspira/widgets/header/_verticalmenu.tpl'; ?>
            <?php } ?>
          </div>
        </div>
      <?php } ?>


  <?php if($this->menuType == 'vertical') { ?> 
      <?php include APPLICATION_PATH . '/application/modules/Inspira/widgets/header/_verticalmenu.tpl'; ?>
   <?php } ?>
 </header>

<script type="text/javascript">

   // Search Toggle
   var removeClass = true;
   scriptJquery(".search_button").click(function () {
   scriptJquery(".header_search").toggleClass('active');
      removeClass = false;
   });
   
   scriptJquery(".header_search").click(function() {
    removeClass = false;
   });
   
   scriptJquery("html").click(function () {
    if (removeClass) {
        scriptJquery(".header_search").removeClass('active');
    }
    removeClass = true;
   });
</script>
