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

class Pulse_Api_Core extends Core_Api_Abstract {

  public function themeConstants($themeColor = array(), $fonts = array()) {

    $settings = Engine_Api::_()->getApi('settings', 'core');
    
    $constant = array(
  		"themewidget_radius" => "".$settings->getSetting('themewidget.radius', 10)."px",
    );

    $themeColorsArray = array();
    if(engine_count($themeColor) > 0) {
      foreach($themeColor as $key => $value) {
        $themeColorsArray["".$key.""] = "".$value."";
      }
    } else {
      $themecustom = Engine_Api::_()->getDbTable('customthemes', 'pulse')->getThemeKey(array('theme_id'=> $settings->getSetting('pulse.theme.color', 1)));
      foreach($themecustom as $value) {
        $themeColorsArray["".$value['column_key'].""] = "".$value['value']."";
      }
    } 
    $constant = array_merge($constant, $themeColorsArray);

    //Fonts
    if(engine_count($fonts) > 0) { 
      $fontsArray = array();
      foreach($fonts as $key => $value) {
        $fontsArray["".$key.""] = "".$value."";
      }
    } else {
			$fontsArray = array(
        "pulse_body_fontfamily" => !empty($settings->getSetting('pulse.googlefonts', 0)) ? $settings->getSetting('pulse_googlebody_fontfamily') : ($settings->getSetting('pulse_body_fontfamily') ? $settings->getSetting('pulse_body_fontfamily') : "Default Font"),
        "pulse_heading_fontfamily" => !empty($settings->getSetting('pulse.googlefonts', 0)) ? $settings->getSetting('pulse_googleheading_fontfamily') : ($settings->getSetting('pulse_heading_fontfamily') ? $settings->getSetting('pulse_heading_fontfamily') : "Default Font"),
        "pulse_tab_fontfamily" => !empty($settings->getSetting('pulse.googlefonts', 0)) ? $settings->getSetting('pulse_googletab_fontfamily') : ($settings->getSetting('pulse_tab_fontfamily') ? $settings->getSetting('pulse_tab_fontfamily') : "Default Font"),
        "pulse_body_fontsize" => !empty($settings->getSetting('pulse.googlefonts', 0)) ? $settings->getSetting('pulse_googlebody_fontsize') : ($settings->getSetting('pulse_body_fontsize') ? $settings->getSetting('pulse_body_fontsize') : "0.875rem"),
        "pulse_heading_fontsize" => !empty($settings->getSetting('pulse.googlefonts', 0)) ? $settings->getSetting('pulse_googleheading_fontsize') : ($settings->getSetting('pulse_heading_fontsize') ? $settings->getSetting('pulse_heading_fontsize') : "1.0625rem"),
        "pulse_tab_fontsize" => !empty($settings->getSetting('pulse.googlefonts', 0)) ? $settings->getSetting('pulse_googletab_fontsize') : ($settings->getSetting('pulse_tab_fontsize') ? $settings->getSetting('pulse_tab_fontsize') : "0.875rem"),
      );
    }

    $constant = array_merge($constant, $fontsArray);

    return $constant;
  }
}
