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

class Pulse_Widget_MobileMenuController extends Engine_Content_Widget_Abstract {

  public function indexAction() {
  
		if(!Engine_Api::_()->core()->isMobile())
			return $this->setNoRender();

    $setting = Engine_Api::_()->getApi('settings', 'core');
    $menuApi = Engine_Api::_()->getApi('menus', 'core');
    $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();

    if($viewer->getIdentity()) {
      $this->view->options = unserialize($setting->getSetting("pulse.headerloggedinoptions",'a:4:{i:0;s:6:"search";i:1;s:8:"miniMenu";i:2;s:8:"mainMenu";i:3;s:4:"logo";}'));
    } else {
      $this->view->options = unserialize($setting->getSetting("pulse.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("pulse_logo");
    $this->view->logocontrast = $setting->getSetting("pulse_logocontrast");
    
    // Main Menu
    $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_main');

		// Main Menu
    $this->view->quickcreate = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_main_quickcreate');
    
    
    $requireCheck = $setting->getSetting('core.general.portal', 1);
    if( !$requireCheck && !$viewer->getIdentity() ) {
      $navigation->removePage($navigation->findOneBy('route', 'user_general'));
    }

    $this->view->menuCount = $setting->getSetting('menu.count', 5);
    $this->view->submenu = $setting->getSetting("submenu",0);
    $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;

		//Mini menu
    $request = Zend_Controller_Front::getInstance()->getRequest();
    $this->view->notificationOnly = $request->getParam('notificationOnly', false);
    $this->view->updateSettings = 120000;
    $this->view->showIcons = 1;
    $this->view->message_count = Engine_Api::_()->messages()->getUnreadMessageCount($viewer);
    $this->view->requestCount = Engine_Api::_()->getDbTable('notifications', 'activity')->hasFriendNotifications($viewer);
    $this->view->currencies = Engine_Api::_()->getDbTable('currencies', 'payment')->getCurrencies(array('enabled' => 1, 'change_rate' => 1));
    $this->view->contrast_mode = $setting->getSetting('contrast.mode', 'dark_mode');
    $this->view->accessibility = $setting->getSetting("accessibility.options",1);
    
    $this->view->core_minimenuquick = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_minimenuquick');
    //Languages
    $this->view->languageNameList = Engine_Api::_()->getApi('languages', 'core')->getLanguages();
    //Location
    if(Engine_Api::_()->getApi('settings', 'core')->getSetting('enableglocation', 0) == 1) {
      $this->view->cookiedata = Engine_Api::_()->getApi('location', 'core')->getUserLocationBasedCookieData();
    }

		//Help & Support menu for Mobile
		$this->view->helpsupportMobile = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_helpsupport_mobile');
  }
}
