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

class Pulse_Form_Admin_Settings_Fonts extends Engine_Form {

  public function init() {

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

    $this->setTitle('Manage Fonts')
        ->setDescription('Here, you can configure the font settings for this theme on your website. You can also choose to enable the Google Fonts.');
            
    $googleFontArray = Engine_Api::_()->core()->getGoogleFonts('fontfamily');

    $this->addElement('Select', 'pulse_googlefonts', array(
      'label' => 'Choose Fonts',
      'description' => 'Choose from below the Fonts which you want to enable in this theme.',
      'multiOptions' => array(
        '0' => 'Web Safe Font Combinations',
        '1' => 'Google Fonts',
      ),
      'onchange' => "usegooglefont(this.value)",
      'value' => $settings->getSetting('pulse.googlefonts', 0),
    ));
    
    $font_array = array(
      'Default Font' => 'Default Font',
      'Georgia, serif' => 'Georgia, serif',
      '"Palatino Linotype", "Book Antiqua", Palatino, serif' => '"Palatino Linotype", "Book Antiqua", Palatino, serif',
      '"Times New Roman", Times, serif' => '"Times New Roman", Times, serif',
      'Arial, Helvetica, sans-serif' => 'Arial, Helvetica, sans-serif',
      '"Arial Black", Gadget, sans-serif' => '"Arial Black", Gadget, sans-serif',
      '"Comic Sans MS", cursive, sans-serif' => '"Comic Sans MS", cursive, sans-serif',
      'Impact, Charcoal, sans-serif' => 'Impact, Charcoal, sans-serif',
      '"Lucida Sans Unicode", "Lucida Grande", sans-serif' => '"Lucida Sans Unicode", "Lucida Grande", sans-serif',
      'Tahoma, Geneva, sans-serif' => 'Tahoma, Geneva, sans-serif',
      '"Trebuchet MS", Helvetica, sans-serif' => '"Trebuchet MS", Helvetica, sans-serif',
      'Verdana, Geneva, sans-serif' => 'Verdana, Geneva, sans-serif',
      '"Courier New", Courier, monospace' => '"Courier New", Courier, monospace',
      '"Lucida Console", Monaco, monospace' => '"Lucida Console", Monaco, monospace',
    );
    
    //Body Settings
    $this->addElement('Select', 'pulse_body_fontfamily', array(
      'label' => 'Body - Font Family',
      'description' => "Choose font family for the text under Body Styling.",
      'multiOptions' => $font_array,
      'value' => $settings->getSetting('pulse_body_fontfamily'),
    ));
    $this->getElement('pulse_body_fontfamily')->getDecorator('Description')->setOptions(array('placement' => 'PREPEND', 'escape' => false));

    $this->addElement('Text', 'pulse_body_fontsize', array(
      'label' => 'Body - Font Size',
      'description' => 'Enter the font size for the text under Body Styling.',
      'allowEmpty' => false,
      'required' => true,
      'value' => $settings->getSetting('pulse_body_fontsize', '0.875rem'),
    ));
    $this->getElement('pulse_body_fontsize')->getDecorator('Description')->setOption('escape',false); 
    
    $this->addDisplayGroup(array('pulse_body_fontfamily', 'pulse_body_fontsize'), 'pulse_bodygrp', array('disableLoadDefaultDecorators' => true));
    $pulse_bodygrp = $this->getDisplayGroup('pulse_bodygrp');
    $pulse_bodygrp->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'pulse_bodygrp'))));

    //Google Font work
    $this->addElement('Select', 'pulse_googlebody_fontfamily', array(
      'label' => 'Body - Font Family',
      'description' => "Choose font family for the text under Body Styling.",
      'multiOptions' => $googleFontArray,
      'value' => $settings->getSetting('pulse_googlebody_fontfamily'),
    ));
    $this->getElement('pulse_googlebody_fontfamily')->getDecorator('Description')->setOptions(array('placement' => 'PREPEND', 'escape' => false));
    
    $this->addElement('Text', 'pulse_googlebody_fontsize', array(
      'label' => 'Body - Font Size',
      'description' => 'Enter the font size for the text under Body Styling.',
      'allowEmpty' => false,
      'required' => true,
      'value' => $settings->getSetting('pulse_googlebody_fontsize','0.875rem'),
    ));
    $this->getElement('pulse_googlebody_fontsize')->getDecorator('Description')->setOption('escape',false); 
    
    $this->addDisplayGroup(array('pulse_googlebody_fontfamily', 'pulse_googlebody_fontsize'), 'pulse_googlebodygrp', array('disableLoadDefaultDecorators' => true));
    $pulse_googlebodygrp = $this->getDisplayGroup('pulse_googlebodygrp');
    $pulse_googlebodygrp->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'pulse_googlebodygrp'))));
    

    //Heading Settings
    $this->addElement('Select', 'pulse_heading_fontfamily', array(
      'label' => 'Heading - Font Family',
      'description' => "Choose font family for the text under Heading Styling.",
      'multiOptions' => $font_array,
      'value' => $settings->getSetting('pulse_heading_fontfamily'),
    ));
    $this->getElement('pulse_heading_fontfamily')->getDecorator('Description')->setOptions(array('placement' => 'PREPEND', 'escape' => false));

    $this->addElement('Text', 'pulse_heading_fontsize', array(
      'label' => 'Heading - Font Size',
      'description' => 'Enter the font size for the text under Heading Styling.',
      'allowEmpty' => false,
      'required' => true,
      'value' => $settings->getSetting('pulse_heading_fontsize', '1.0625rem'),
    ));
    $this->getElement('pulse_heading_fontsize')->getDecorator('Description')->setOption('escape',false); 
    
    $this->addDisplayGroup(array('pulse_heading_fontfamily', 'pulse_heading_fontsize'), 'pulse_headinggrp', array('disableLoadDefaultDecorators' => true));
    $pulse_headinggrp = $this->getDisplayGroup('pulse_headinggrp');
    $pulse_headinggrp->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'pulse_headinggrp'))));
    
    
    //Google Font work
    $this->addElement('Select', 'pulse_googleheading_fontfamily', array(
      'label' => 'Heading - Font Family',
      'description' => "Choose font family for the text under Heading Styling.",
      'multiOptions' => $googleFontArray,
      'value' => $settings->getSetting('pulse_googleheading_fontfamily'),
    ));
    $this->getElement('pulse_googleheading_fontfamily')->getDecorator('Description')->setOptions(array('placement' => 'PREPEND', 'escape' => false));
    
    $this->addElement('Text', 'pulse_googleheading_fontsize', array(
      'label' => 'Heading - Font Size',
      'description' => 'Enter the font size for the text under Heading Styling.',
      'allowEmpty' => false,
      'required' => true,
      'value' => $settings->getSetting('pulse_googleheading_fontsize', '1.0625rem'),
    ));
    $this->getElement('pulse_googleheading_fontsize')->getDecorator('Description')->setOption('escape',false); 
    
    $this->addDisplayGroup(array('pulse_googleheading_fontfamily', 'pulse_googleheading_fontsize'), 'pulse_googleheadinggrp', array('disableLoadDefaultDecorators' => true));
    $pulse_googleheadinggrp = $this->getDisplayGroup('pulse_googleheadinggrp');
    $pulse_googleheadinggrp->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'pulse_googleheadinggrp'))));    

    //Tab Settings
    $this->addElement('Select', 'pulse_tab_fontfamily', array(
      'label' => 'Tab - Font Family',
      'description' => "Choose font family for the text under Tab Styling.",
      'multiOptions' => $font_array,
      'value' => $settings->getSetting('pulse_tab_fontfamily'),
    ));
    $this->getElement('pulse_tab_fontfamily')->getDecorator('Description')->setOptions(array('placement' => 'PREPEND', 'escape' => false));

    $this->addElement('Text', 'pulse_tab_fontsize', array(
      'label' => 'Tab - Font Size',
      'description' => 'Enter the font size for the text under Tab Styling.',
      'allowEmpty' => false,
      'required' => true,
      'value' => $settings->getSetting('pulse_tab_fontsize', '0.875rem'),
    ));
    $this->getElement('pulse_tab_fontsize')->getDecorator('Description')->setOption('escape',false); 
    
    $this->addDisplayGroup(array('pulse_tab_fontfamily', 'pulse_tab_fontsize'), 'pulse_tabgrp', array('disableLoadDefaultDecorators' => true));
    $pulse_tabgrp = $this->getDisplayGroup('pulse_tabgrp');
    $pulse_tabgrp->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'pulse_tabgrp'))));
    
    
    //Google Font work
    $this->addElement('Select', 'pulse_googletab_fontfamily', array(
      'label' => 'Tab - Font Family',
      'description' => "Choose font family for the text under Tab Styling.",
      'multiOptions' => $googleFontArray,
      'value' => $settings->getSetting('pulse_googletab_fontfamily'),
    ));
    $this->getElement('pulse_googletab_fontfamily')->getDecorator('Description')->setOptions(array('placement' => 'PREPEND', 'escape' => false));
    
    $this->addElement('Text', 'pulse_googletab_fontsize', array(
      'label' => 'Tab - Font Size',
      'description' => 'Enter the font size for the text under Tab Styling.',
      'allowEmpty' => false,
      'required' => true,
      'value' => $settings->getSetting('pulse_googletab_fontsize', '0.875rem'),
    ));
    $this->getElement('pulse_googletab_fontsize')->getDecorator('Description')->setOption('escape',false); 
    
    $this->addDisplayGroup(array('pulse_googletab_fontfamily', 'pulse_googletab_fontsize'), 'pulse_googletabgrp', array('disableLoadDefaultDecorators' => true));
    $pulse_googletabgrp = $this->getDisplayGroup('pulse_googletabgrp');
    $pulse_googletabgrp->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'id' => 'pulse_googletabgrp'))));

    
    // Add submit button
    $this->addElement('Button', 'submit', array(
        'label' => 'Save Changes',
        'type' => 'submit',
        'ignore' => true
    ));
  }
}
