You are here

function getlocations_leaflet_awesome_marker_get in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_leaflet/getlocations_leaflet.module \getlocations_leaflet_awesome_marker_get()

Function

Return value

Returns

3 calls to getlocations_leaflet_awesome_marker_get()
getlocations_leaflet_entity_type_map in modules/getlocations_leaflet/getlocations_leaflet.module
Function
getlocations_leaflet_field_formatter_view in modules/getlocations_leaflet/getlocations_leaflet.module
Implements hook_field_formatter_view(). Build a renderable array for a field value.
template_preprocess_getlocations_leaflet_view_map in modules/getlocations_leaflet/views/getlocations_leaflet.views.inc
Preprocess function for getlocations_leaflet_view_map.tpl

File

modules/getlocations_leaflet/getlocations_leaflet.module, line 5116
getlocations_leaflet.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_leaflet_awesome_marker_get($defaults, $prefix = '') {
  if (!empty($prefix)) {
    $prefix .= '_marker_';
  }
  $awesome_icon_type = isset($defaults[$prefix . 'awesome_icon_type']) && $defaults[$prefix . 'awesome_icon_type'] ? $defaults[$prefix . 'awesome_icon_type'] : $defaults['awesome_icon_type'];
  if ($awesome_icon_type == 'i') {

    // icon only
    $icon = isset($defaults[$prefix . 'awesome_icon']) ? $defaults[$prefix . 'awesome_icon'] : $defaults['awesome_icon'];
    $selector = isset($defaults[$prefix . 'awesome_icon_color_selector']) ? $defaults[$prefix . 'awesome_icon_color_selector'] : $defaults['awesome_icon_color_selector'];
    $iconcolor = $defaults[$prefix . 'awesome_icon_color'] ? $defaults[$prefix . 'awesome_icon_color'] : $selector;
    $spin = isset($defaults[$prefix . 'awesome_icon_spin']) ? $defaults[$prefix . 'awesome_icon_spin'] : $defaults['awesome_icon_spin'];
    $flip = isset($defaults[$prefix . 'awesome_icon_flip']) ? $defaults[$prefix . 'awesome_icon_flip'] : $defaults['awesome_icon_flip'];
    $iconsize = isset($defaults[$prefix . 'awesome_icon_size']) ? $defaults[$prefix . 'awesome_icon_size'] : $defaults['awesome_icon_size'];
    $html = isset($defaults[$prefix . 'awesome_icon_html']) ? $defaults[$prefix . 'awesome_icon_html'] : $defaults['awesome_icon_html'];
    $classname = isset($defaults[$prefix . 'awesome_icon_class']) ? $defaults[$prefix . 'awesome_icon_class'] : $defaults['awesome_icon_class'];
    $px = 12;
    if ($iconsize == 'fa-lg') {
      $px = 16;
    }
    elseif ($iconsize == 'fa-2x') {
      $px = 24;
    }
    elseif ($iconsize == 'fa-3x') {
      $px = 36;
    }
    elseif ($iconsize == 'fa-4x') {
      $px = 48;
    }
    elseif ($iconsize == 'fa-5x') {
      $px = 60;
    }
    $style = '';
    $class = array();
    $class[] = 'fa';
    $class[] = $icon;
    if ($iconsize) {
      $class[] = $iconsize;
    }
    if ($spin) {
      $class[] = $spin;
    }
    if ($flip) {
      $class[] = $flip;
    }
    if ($iconcolor == 'black' || $iconcolor == 'white') {
      $class[] = 'fa-' . $iconcolor;
    }
    else {
      $style = 'style="color:' . $iconcolor . '"';
    }
    $classes = implode(' ', $class);
    if (empty($html)) {
      $html = '<i class="' . $classes . '" ' . $style . '></i>';
    }
    $vicon = array(
      'px' => $px,
      'html' => $html,
      'classname' => $classname,
    );
  }
  elseif ($awesome_icon_type == 'm') {

    // marker only, do it by providing a nonexistent icon
    $markercolor = isset($defaults[$prefix . 'awesome_marker_color']) ? $defaults[$prefix . 'awesome_marker_color'] : $defaults['awesome_marker_color'];
    $selector = isset($defaults[$prefix . 'awesome_icon_color_selector']) ? $defaults[$prefix . 'awesome_icon_color_selector'] : $defaults['awesome_icon_color_selector'];
    $iconcolor = $defaults[$prefix . 'awesome_icon_color'] ? $defaults[$prefix . 'awesome_icon_color'] : $selector;
    $html = isset($defaults[$prefix . 'awesome_icon_html']) ? $defaults[$prefix . 'awesome_icon_html'] : $defaults['awesome_icon_html'];
    $vicon = array(
      'icon' => 'fa-xxx',
      'markerColor' => $markercolor,
      'prefix' => 'fa',
      'spin' => FALSE,
      'html' => $html,
      'iconColor' => $iconcolor,
    );
  }
  else {

    // both
    $icon = isset($defaults[$prefix . 'awesome_icon']) ? $defaults[$prefix . 'awesome_icon'] : $defaults['awesome_icon'];
    $markercolor = isset($defaults[$prefix . 'awesome_marker_color']) ? $defaults[$prefix . 'awesome_marker_color'] : $defaults['awesome_marker_color'];
    $selector = isset($defaults[$prefix . 'awesome_icon_color_selector']) ? $defaults[$prefix . 'awesome_icon_color_selector'] : $defaults['awesome_icon_color_selector'];
    $iconcolor = isset($defaults[$prefix . 'awesome_icon_color']) && $defaults[$prefix . 'awesome_icon_color'] ? $defaults[$prefix . 'awesome_icon_color'] : $selector;
    $spin = isset($defaults[$prefix . 'awesome_icon_spin']) ? $defaults[$prefix . 'awesome_icon_spin'] : $defaults['awesome_icon_spin'];

    #$flip = (isset($defaults[$prefix . 'awesome_icon_flip']) ? $defaults[$prefix . 'awesome_icon_flip'] : $defaults['awesome_icon_flip']);
    $vicon = array(
      'icon' => $icon,
      'markerColor' => $markercolor,
      'iconColor' => $iconcolor,
      'prefix' => 'fa',
      'spin' => $spin,
    );
  }
  return array(
    'data' => $vicon,
    'type' => $awesome_icon_type,
  );
}