<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Inspira_Widget_LandingPageHeaderController extends Engine_Content_Widget_Abstract
{
    public function indexAction()
    {
      $setting = Engine_Api::_()->getApi('settings', 'core');
      $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
      //widget options
      if($viewer->getIdentity())
      $options = $this->view->options = unserialize($setting->getSetting("inspira_headerloggedinoptions",'a:4:{i:0;s:6:"search";i:1;s:8:"miniMenu";i:2;s:8:"mainMenu";i:3;s:4:"logo";}'));
      else
      $options = $this->view->options = unserialize($setting->getSetting("inspira_headernonloggedinoptions",'a:4:{i:0;s:6:"search";i:1;s:8:"miniMenu";i:2;s:8:"mainMenu";i:3;s:4:"logo";}'));

      $this->view->accessibility_option = $setting->getSetting("accessibility_options");
      $this->view->logo = $setting->getSetting("landingpageinspira_logo") ? $setting->getSetting("landingpageinspira_logo") : $setting->getSetting("inspira_logo");

      // Main Menu
      $this->view->navigation = $navigation = Engine_Api::_()
      ->getApi('menus', 'core')
      ->getNavigation('core_main');

      
      $requireCheck = $setting->getSetting('core.general.portal', 1);
      if( !$requireCheck && !$viewer->getIdentity() ) {
        $navigation->removePage($navigation->findOneBy('route', 'user_general'));
      }
      $this->view->menuType = $menuType = $setting->getSetting('menuType', 'horizontal');
      $this->view->menuFromTheme = $this->_getParam('menuFromTheme', false);
      $this->view->submenu = $setting->getSetting("submenu",1);
			$this->view->menuCount = $setting->getSetting('landingpagemenuCount', 6) ? $setting->getSetting('landingpagemenuCount', 6) : '6';

			$require_check = Engine_Api::_()->getApi('settings', 'core')->core_general_portal;
			if(!$require_check) {
				if( $viewer->getIdentity()) {
					$this->view->search_check = true;
				}
				else{
					$this->view->search_check = false;
				}
			}
			else $this->view->search_check = true;        
    }
}
