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

class Inspira_Form_Admin_Settings_Global extends Engine_Form {

  public function init() {

    $settings = Engine_Api::_()->getApi('settings', 'core');

    $this->addElement('Radio', 'inspira_changelanding', array(
      'label' => 'Set Landing Page of Inspira Theme',
      'description' => 'Do you want to set the Landing Page from this theme and replace the current Landing page with one of the landing page design from this theme? (If you choose Yes and save changes, then later you can manually make changes in the Landing page from Layout Editor. Back up page of your current landing page will get created with the name "Backup - Landing Page".)',
      'onclick' => 'confirmChangeLandingPage(this.value)',
      'multiOptions' => array(
        '1' => 'Yes, Landing Page Design 1',
        '2' => 'Yes, Landing Page Design 2',
        '0' => 'No',
      ),
      'value' => Engine_Api::_()->getDbTable('settings', 'core')->getDbSettings('inspira.changelanding') ? Engine_Api::_()->getDbTable('settings', 'core')->getDbSettings('inspira.changelanding'): 0,
    ));

    $this->addElement('MultiCheckbox', 'inspira_headerloggedinoptions', array(
      'label' => 'Header Options for Logged in Members',
      'description' => 'Choose from the below options to be available in the header to logged in members on your website.',
      'multiOptions' => array(
          'search' => 'Search',
          'miniMenu' => 'Mini Menu',
          'mainMenu' =>'Main Menu',
          'logo' =>'Logo',
      ),
      'value' => unserialize($settings->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";}')),
    ));

    $this->addElement('MultiCheckbox', 'inspira_headernonloggedinoptions', array(
      'label' => 'Header Options for Non-Logged in Members',
      'description' => 'Choose from the below options to be available in the header to non-logged in members on your website.',
      'multiOptions' => array(
          'search' => 'Search',
          'miniMenu' => 'Mini Menu',
          'mainMenu' =>'Main Menu',
          'logo' =>'Logo',
      ),
      'value' => unserialize($settings->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";}')),
    ));

    // Get available files
    $logoOptions = array('' => 'Text-only (No logo)');

    $files = Engine_Api::_()->getDbTable('files', 'core')->getFiles(array('fetchAll' => 1, 'extension' => array('gif', 'jpg', 'jpeg', 'png', 'webp', 'svg')));
    foreach( $files as $file ) {
      $logoOptions[$file->storage_path] = $file->name;
    }

    $this->addElement('Select', 'inspira_logo', array(
      'label' => 'Header Logo',
      'multiOptions' => $logoOptions,
      'value'=>$settings->getSetting("inspira_logo",''),
			'attribs' => array(
				'class' => 'preview-select-image'
			),
    ));
    $this->addElement('Select', 'inspira_logocontrast', array(
      'label' => 'Header Logo for Contrast Mode',
      'multiOptions' => $logoOptions,
      'value'=>$settings->getSetting("inspira.logocontrast",''),
			'attribs' => array(
				'class' => 'preview-select-image'
			),
    ));

    $this->addElement('Select', 'menuType', array(
      'label' => 'Menu Position',
      'description'=> 'Choose position of this menu below.',
      'multiOptions' => array(
        'horizontal' => 'Horizontal',
        'vertical' => 'Vertical',
      ),
      'onchange' => 'hideShowSettings(this.value);',
      'value'=>$settings->getSetting("menuType",'horizontal'),
    ));
    $this->addElement('Text', 'menuCount', array(
      'label' => 'Menu Item Count',
      'description' => 'Enter the number of menu items after which you want to show "More+" in this widget. The remaining menu items will be shown under More+ dropdown. Enter "0", if you want to show all menu items in this widget and do not want to show "More+"',
      'value'=>$settings->getSetting("menuCount",7)
    ));
    $this->addElement('Select', 'submenu', array(
      'label' => 'Show Sub Menus',
      'description'=> 'Do you want to show sub menus?',
      'multiOptions' => array('1'=>'Yes','0'=>'No'),
      'value'=>$settings->getSetting("submenu",1)
    ));
    $this->addElement('Select', 'accessibility_options', array(
      'label' => 'Show Accessibility Options',
      'multiOptions' => array('1'=>'Yes','0'=>'No'),
      'value'=>$settings->getSetting("accessibility_options",1)
    ));

    $landingpagelogoOptions  = array('' => '');
    $files = Engine_Api::_()->getDbTable('files', 'core')->getFiles(array('fetchAll' => 1, 'extension' => array('gif', 'jpg', 'jpeg', 'png', 'webp', 'svg')));
    foreach( $files as $file ) {
      $landingpagelogoOptions[$file->storage_path] = $file->name;
    }
    
    $this->addElement('Select', 'landingpageinspira_logo', array(
      'label' => 'Landing Page Header Logo',
      'multiOptions' => $landingpagelogoOptions,
      'value'=>$settings->getSetting("landingpageinspira_logo",''),
      'description' => 'We recommend a dimension of 200x200 for the logo if using Landing Page Design 2.'
    ));
    $this->addElement('Text', 'landingpagemenuCount', array(
      'label' => 'Landing Page Menu Item Count',
      'description' => 'Enter the number of menu items after which you want to show "More+" in this widget. The remaining menu items will be shown under More+ dropdown. Enter "0", if you want to show all menu items in this widget and do not want to show "More+"',
      'value'=>$settings->getSetting("landingpagemenuCount", 4)
    ));
    
    $this->addElement('Button', 'submit', array(
      'label' => 'Save Changes',
      'type' => 'submit',
      'ignore' => true
    ));
  }
}
