You are here

function beautytips_manager_define_beautytips_styles in BeautyTips 8

Same name and namespace in other branches
  1. 7.2 beautytips_manager.module \beautytips_manager_define_beautytips_styles()

Implements hook_define_beautytips_styles().

File

beautytips_manager/beautytips_manager.module, line 306
Code related to defining and displaying custom beautytips and styles.

Code

function beautytips_manager_define_beautytips_styles() {
  $styles = [];
  $custom_styles = beautytips_manager_get_custom_styles();
  $style_map = beautytips_manager_style_mapping();
  $style_options = array_flip($style_map['options']);
  $css_style_options = array_flip($style_map['css_options']);
  if (count($custom_styles)) {
    foreach ($custom_styles as $style) {
      $options = [];
      foreach ($style as $key => $value) {
        if (isset($style_options[$key])) {
          if ($key == 'shadow') {
            if ($value != 'default') {
              $options['shadow'] = $value == 'shadow' ? TRUE : FALSE;
            }
          }
          else {
            if (!is_null($value) && $value != '') {

              // Add the setting and make sure integers stay as integers.
              $options[$style_options[$key]] = ctype_digit($value) || is_int($value) ? (int) $value : Html::escape($value);
            }
          }
        }
        else {
          if (isset($css_style_options[$key])) {
            if (!is_null($value) && $value != '') {
              $options['cssStyles'][$css_style_options[$key]] = Html::escape($value);
            }
          }
        }
      }
      $styles[$style->name] = $options;
    }
  }
  return $styles;
}