You are here

function theme_getlocations_leaflet_settings_form in Get Locations 7

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

Function

Return value

Returns

File

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

Code

function theme_getlocations_leaflet_settings_form($variables) {
  $form = $variables['form'];
  $output = '';
  $form['getlocations_leaflet_defaults']['returnlink_page_link']['#prefix'] = '<div id="wrap-page-link">';
  $form['getlocations_leaflet_defaults']['returnlink_page_link']['#suffix'] = '</div>';
  if (isset($form['getlocations_leaflet_defaults']['returnlink_user_link'])) {
    $form['getlocations_leaflet_defaults']['returnlink_user_link']['#prefix'] = '<div id="wrap-user-link">';
    $form['getlocations_leaflet_defaults']['returnlink_user_link']['#suffix'] = '</div>';
  }
  if (isset($form['getlocations_leaflet_defaults']['returnlink_term_link'])) {
    $form['getlocations_leaflet_defaults']['returnlink_term_link']['#prefix'] = '<div id="wrap-term-link">';
    $form['getlocations_leaflet_defaults']['returnlink_term_link']['#suffix'] = '</div>';
  }
  if (isset($form['getlocations_leaflet_defaults']['returnlink_comment_link'])) {
    $form['getlocations_leaflet_defaults']['returnlink_comment_link']['#prefix'] = '<div id="wrap-comment-link">';
    $form['getlocations_leaflet_defaults']['returnlink_comment_link']['#suffix'] = '</div>';
  }

  // mapbox
  if (module_exists('getlocations_mapbox')) {
    $mapnum = $form['getlocations_leaflet_mapbox']['mapnum']['#value'];
    unset($form['getlocations_leaflet_mapbox']['mapnum']);
    for ($ct = 0; $ct < $mapnum; $ct++) {
      $form['getlocations_leaflet_mapbox']['mapbox_info'][$ct]['label']['#prefix'] = '<fieldset class="getlocations_fieldset form-wrapper"><legend><span class="fieldset-legend">' . t('MapBox map @n', array(
        '@n' => $ct + 1,
      )) . '</span></legend><div class="fieldset-wrapper">';
      $form['getlocations_leaflet_mapbox']['mapbox_info'][$ct]['type']['#suffix'] = '</div></fieldset>';
    }
  }

  // preview leaflet
  if (isset($form['getlocations_leaflet_preview']['preview_map']['#markup'])) {
    $links = array();
    $nodezoom = FALSE;
    $iconlist = array();
    $getlocations_leaflet_defaults = getlocations_leaflet_defaults();
    $map_settings = getlocations_leaflet_map_get_info('Getlocations OSM');
    $map_settings = getlocations_leaflet_get_map_layers($map_settings);
    if (!empty($getlocations_leaflet_defaults['baselayers'])) {
      $map_layers = array();
      foreach ($getlocations_leaflet_defaults['baselayers'] as $k => $v) {
        if (isset($map_settings['map_layers'][$k]) && $getlocations_leaflet_defaults['baselayers'][$k]) {
          $map_layers[$k] = $map_settings['map_layers'][$k];
        }
      }
      if (!empty($map_layers)) {
        $map_settings['map_layers'] = $map_layers;
      }
    }
    $ll = explode(',', $getlocations_leaflet_defaults['latlong']);
    $map_settings['map_opts']['center'] = array(
      $ll[0],
      $ll[1],
    );
    $map_settings['map_opts']['zoom'] = $getlocations_leaflet_defaults['zoom'];
    $mapid = getlocations_setup_map('', FALSE, FALSE, TRUE);
    $latlons = array();
    $minmaxes = array();
    $map_settings['map_settings']['dragging'] = TRUE;

    // add in some more
    $map_settings = getlocations_leaflet_map_settings_do($map_settings, $getlocations_leaflet_defaults, $latlons, $mapid);
    $map_settings['map_settings']['nodezoom'] = $nodezoom ? $nodezoom : $getlocations_leaflet_defaults['nodezoom'];
    $map_settings['map_settings']['minmaxes'] = empty($minmaxes) ? FALSE : implode(',', $minmaxes);
    $map_settings['icons'] = $iconlist;
    $map_settings['datanum'] = 0;
    $map_settings['latlons'] = $latlons;
    $map_settings['extcontrol'] = 'preview_map';
    $preview_map = theme('getlocations_leaflet_map', array(
      'width' => $getlocations_leaflet_defaults['width'],
      'height' => $getlocations_leaflet_defaults['height'],
      'map_settings' => $map_settings,
      'mapid' => $mapid,
      'links' => $links,
    ));
    $form['getlocations_leaflet_preview']['preview_map']['#markup'] = '<div id="getlocations_leaflet_preview_map">' . $preview_map . '</div>';
  }
  $output .= drupal_render_children($form);
  return $output;
}