<?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_Styling extends Engine_Form {

  public function init() {

    $description = "Here, you can manage the color schemes of your website. <br /><div class='tip'><span>Once you switch color schemes or make any changes to the new color schemes you added, please change the mode of your website from Production to Development. This has to be done everytime, and you can switch to production instantly or as soon you are done configuring the color scheme of your website.</span></div>";
    
    // Decorators
    $this->loadDefaultDecorators();
    $this->getDecorator('Description')->setOption('escape', false);
    $this->setTitle('Manage Color Schemes')
        ->setDescription($description);

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

    $contrast_mode = $settings->getSetting('contrast.mode', 'dark_mode');
    $theme_color = $settings->getSetting('inspira.theme.color', 1);

    $this->addElement('Radio', 'contrast_mode', array(
      'label' => 'Contrast Mode?',
      'description' => 'Choose the Contrast mode for the accessibility widget on your website. You can choose Dark Mode or Light Mode as per the default theme on your website.',
      'multiOptions' => array(
        'light_mode' => 'Light Mode',
        'dark_mode' => 'Dark Mode'
      ),
      'value'=>$contrast_mode
    ));

    $customThemes = Engine_Api::_()->getDbTable('customthemes', 'inspira')->getCustomThemes(array('all' => 1));
    foreach($customThemes as $customTheme) {
      if(engine_in_array($customTheme['theme_id'], array(1,2,3))) {
        $themeOptions[$customTheme['theme_id']] = '<img src="./application/modules/Inspira/externals/images/color-scheme/'.$customTheme['theme_id'].'.png" alt="" />';
      } else {
        $themeOptions[$customTheme['theme_id']] = '<img src="./application/modules/Inspira/externals/images/color-scheme/custom.png" alt="" /> <span class="custom_theme_name">'. $customTheme->name.'</span>';
      }
    }

    $this->addElement('Radio', 'theme_color', array(
      'label' => 'Color Schemes',
      'multiOptions' => $themeOptions,
      'onclick' => 'changeThemeColor(this.value, 1)',
      'escape' => false,
      'value' => $theme_color,
    ));

    $this->addElement('dummy', 'custom_themes', array(
      'decorators' => array(array('ViewScript', array(
        'viewScript' => 'application/modules/Inspira/views/scripts/custom_themes.tpl',
        'class' => 'form element',
      )))
    ));

    $themecustom = Engine_Api::_()->getDbTable('customthemes', 'inspira')->getThemeKey(array('theme_id'=>$theme_color, 'default' => 0));
    foreach($themecustom as $value) {
      ${$value['column_key']} = $value['value'];
    }

    $this->addElement('Dummy', 'header_settings', array(
        'label' => 'Header Styling Settings',
    ));
    $this->addElement('Text', "inspira_header_background_color", array(
        'label' => 'Header Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_header_background_color,
    ));

    $this->addElement('Text', "inspira_header_logo_color", array(
      'label' => 'Header Logo Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_header_logo_color,
  ));

    $this->addElement('Text', "inspira_mainmenu_background_color", array(
        'label' => 'Main Menu Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_mainmenu_background_color,
    ));

    $this->addElement('Text', "inspira_mainmenu_links_color", array(
        'label' => 'Main Menu Link Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_mainmenu_links_color,
    ));

    $this->addElement('Text', "inspira_mainmenu_links_hover_color", array(
        'label' => 'Main Menu Link Hover Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_mainmenu_links_hover_color,
    ));
    $this->addElement('Text', "inspira_mainmenu_links_hover_background_color", array(
        'label' => 'Main Menu Link Hover Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_mainmenu_links_hover_background_color,
    ));

    $this->addElement('Text', "inspira_minimenu_links_color", array(
        'label' => 'Mini Menu Link Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_minimenu_links_color,
    ));

    $this->addElement('Text', "inspira_minimenu_links_background_color", array(
      'label' => 'Mini Menu Link Background Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_minimenu_links_background_color,
  ));

    $this->addDisplayGroup(array('inspira_header_background_color', 'inspira_header_logo_color' , 'inspira_mainmenu_background_color', 'inspira_mainmenu_links_color', 'inspira_mainmenu_links_hover_color', 'inspira_mainmenu_links_hover_background_color', 'inspira_minimenu_links_color', 'inspira_minimenu_links_background_color'), 'header_settings_group', array('disableLoadDefaultDecorators' => true));
    $header_settings_group = $this->getDisplayGroup('header_settings_group');
    $header_settings_group->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'header_settings_group'))));

    $this->addElement('Dummy', 'footer_settings', array(
        'label' => 'Footer Styling Settings',
    ));
    $this->addElement('Text', "inspira_footer_background_color", array(
        'label' => 'Footer Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_footer_background_color,
    ));

    $this->addElement('Text', "inspira_footer_font_color", array(
        'label' => 'Footer Font Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_footer_font_color,
    ));

    $this->addElement('Text', "inspira_footer_links_color", array(
        'label' => 'Footer Link Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_footer_links_color,
    ));

    $this->addElement('Text', "inspira_footer_border_color", array(
        'label' => 'Footer Border Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_footer_border_color,
    ));
    $this->addDisplayGroup(array('inspira_footer_background_color', 'inspira_footer_font_color', 'inspira_footer_links_color', 'inspira_footer_border_color'), 'footer_settings_group', array('disableLoadDefaultDecorators' => true));
    $footer_settings_group = $this->getDisplayGroup('footer_settings_group');
    $footer_settings_group->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'footer_settings_group'))));

    $this->addElement('Dummy', 'body_settings', array(
        'label' => 'Body Styling Settings',
    ));
    $this->addElement('Text', "inspira_theme_color", array(
        'label' => 'Theme Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_theme_color,
    ));

    $this->addElement('Text', "inspira_body_background_color", array(
        'label' => 'Body Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_body_background_color,
    ));

    $this->addElement('Text', "inspira_font_color", array(
        'label' => 'Font Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_font_color,
    ));

    $this->addElement('Text', "inspira_font_color_light", array(
        'label' => 'Font Light Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_font_color_light,
    ));

    $this->addElement('Text', "inspira_links_color", array(
      'label' => 'Link Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_links_color,
    ));

    $this->addElement('Text', "inspira_links_hover_color", array(
        'label' => 'Link Hover Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_links_hover_color,
    ));

    $this->addElement('Text', "inspira_headline_color", array(
        'label' => 'Headline Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_headline_color,
    ));

    $this->addElement('Text', "inspira_border_color", array(
        'label' => 'Border Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_border_color,
    ));
    $this->addElement('Text', "inspira_box_background_color", array(
        'label' => 'Box Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_box_background_color,
    ));

    $this->addElement('Text', "inspira_box_background_alt_color", array(
      'label' => 'Box Alternate Background Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_box_background_alt_color,
  ));

    $this->addElement('Text', "inspira_form_label_color", array(
        'label' => 'Form Label Font Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_form_label_color,
    ));

    $this->addElement('Text', "inspira_input_background_color", array(
        'label' => 'Input Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_input_background_color,
    ));

    $this->addElement('Text', "inspira_input_font_color", array(
        'label' => 'Input Font Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_input_font_color,
    ));

    $this->addElement('Text', "inspira_input_border_color", array(
        'label' => 'Input Border Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_input_border_color,
    ));

    $this->addElement('Text', "inspira_button_background_color", array(
        'label' => 'Button Background Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_button_background_color,
    ));
    $this->addElement('Text', "inspira_button_background_color_hover", array(
        'label' => 'Button Background Hovor Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_button_background_color_hover,
    ));

    $this->addElement('Text', "inspira_button_font_color", array(
        'label' => 'Button Font Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_button_font_color,
    ));
    $this->addElement('Text', "inspira_button_font_color_hover", array(
      'label' => 'Button Font Hover Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_button_font_color_hover,
  ));
    $this->addElement('Text', "inspira_button_border_color", array(
        'label' => 'Button Border Color',
        'allowEmpty' => false,
        'required' => true,
        'class' => 'SEcolor',
        'value' => $inspira_button_border_color,
    ));


    $this->addElement('Text', "inspira_button_border_color_hover", array(
      'label' => 'Button Border Hover Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_button_border_color_hover,
    ));
    $this->addElement('Text', "inspira_secondary_button_background_color", array(
      'label' => 'Secondary Button Background Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_secondary_button_background_color,
    ));
    $this->addElement('Text', "inspira_secondary_button_background_color_hover", array(
      'label' => 'Secondary Button Background Hover Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_secondary_button_background_color_hover,
    ));
    $this->addElement('Text', "inspira_secondary_button_font_color", array(
      'label' => 'Secondary Button Font Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_secondary_button_font_color,
    ));
    $this->addElement('Text', "inspira_secondary_button_font_color_hover", array(
      'label' => 'Secondary Button Font Hover Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_secondary_button_font_color_hover,
    ));
    $this->addElement('Text', "inspira_secondary_button_border_color", array(
      'label' => 'Secondary Button Border Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_secondary_button_border_color,
    ));
    $this->addElement('Text', "inspira_secondary_button_border_color_hover", array(
      'label' => 'Secondary Button Border Hover Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_secondary_button_border_color_hover,
    ));


    $this->addElement('Text', "inspira_comments_background_color", array(
      'label' => 'Comments Background Color',
      'allowEmpty' => false,
      'required' => true,
      'class' => 'SEcolor',
      'value' => $inspira_comments_background_color,
    ));

    $this->addDisplayGroup(array('inspira_theme_color','inspira_body_background_color', 'inspira_font_color', 'inspira_font_color_light', 'inspira_links_color', 'inspira_links_hover_color','inspira_headline_color', 'inspira_border_color', 'inspira_box_background_color', 'inspira_box_background_alt_color', 'inspira_form_label_color', 'inspira_input_background_color', 'inspira_input_font_color', 'inspira_input_border_color', 'inspira_button_background_color', 'inspira_button_background_color_hover', 'inspira_button_font_color', 'inspira_button_font_color_hover', 'inspira_button_border_color', 'inspira_dashboard_list_background_color_hover', 'inspira_dashboard_list_border_color', 'inspira_dashboard_font_color', 'inspira_dashboard_link_color', 'inspira_button_border_color_hover', 'inspira_secondary_button_background_color', 'inspira_secondary_button_background_color_hover', 'inspira_secondary_button_font_color', 'inspira_secondary_button_font_color_hover', 'inspira_secondary_button_border_color', 'inspira_secondary_button_border_color_hover', 'inspira_comments_background_color'), 'body_settings_group', array('disableLoadDefaultDecorators' => true));
    $body_settings_group = $this->getDisplayGroup('body_settings_group');
    $body_settings_group->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'body_settings_group'))));

    $this->addElement('Button', 'save', array(
        'label' => 'Save Changes',
        'type' => 'submit',
        'ignore' => true,
        'decorators' => array('ViewHelper')
    ));
  }
}
