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

class Pulse_Widget_LandingPageMainController extends Engine_Content_Widget_Abstract {

  public function indexAction() {

    $menuApi = Engine_Api::_()->getApi('menus', 'core');
    $this->getElement()->removeDecorator('Title');
    $this->view->allParams = $this->_getAllParams();

    //Footer Links
    $this->view->footernavigation = $menuApi->getNavigation('core_footer');
    // Do not show if logged in
    if( Engine_Api::_()->user()->getViewer()->getIdentity() ) {
      $this->setNoRender();
      return;
    }
    $this->view->image = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.general.landingimage', '');

    // Display form
    $form = $this->view->form = new User_Form_Login(array(
      'mode' => 'column',
			'sociallinks' => false,
    ));
    $form->setTitle(null)->setDescription(null);

    // Facebook login
    if( 'none' == Engine_Api::_()->getApi('settings', 'core')->core_facebook_enable ) {
      $form->removeElement('facebook');
    }
    
    // Check for recaptcha - it's too fat
    $this->view->noForm = false;
    if( ($captcha = $form->getElement('captcha')) instanceof Zend_Form_Element_Captcha && 
        $captcha->getCaptcha() instanceof Zend_Captcha_ReCaptcha ) {
      $this->view->noForm = true;
      $emailFieldName = $form->getEmailElementFieldName();
      $form->removeElement($emailFieldName);
      $form->removeElement('password');
      $form->removeElement('captcha');
      $form->removeElement('submit');
      $form->removeElement('remember');
//      $form->removeElement('facebook');
//      $form->removeElement('twitter');
      $form->removeDisplayGroup('buttons');
    }

    //Languages
    $this->view->languageNameList = Engine_Api::_()->getApi('languages', 'core')->getLanguages();

    $this->view->logo = Engine_Api::_()->getApi('settings', 'core')->getSetting("pulse_logo");
    $this->view->logocontrast = Engine_Api::_()->getApi('settings', 'core')->getSetting("pulse_logocontrast");
		$this->view->contrast_mode = Engine_Api::_()->getApi('settings', 'core')->getSetting('contrast.mode', 'dark_mode');
    $this->view->accessibility_option = Engine_Api::_()->getApi('settings', 'core')->getSetting("accessibility_options");

  }
  public function getCacheKey()
  {
    return false;
  }
}
