You are here

function gmap_plugin_style_gmap::options_form in GMap Module 6

Same name and namespace in other branches
  1. 6.2 gmap_plugin_style_gmap.inc \gmap_plugin_style_gmap::options_form()
  2. 7.2 gmap_plugin_style_gmap.inc \gmap_plugin_style_gmap::options_form()
  3. 7 gmap_plugin_style_gmap.inc \gmap_plugin_style_gmap::options_form()

Render the given style.

File

./gmap_plugin_style_gmap.inc, line 256
GMap style plugin.

Class

gmap_plugin_style_gmap
Style plugin to render a map.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $field_options = array();
  $fields = $this->display->handler
    ->get_handlers('field');
  foreach ($fields as $id => $handler) {
    $field_options[$id] = $handler
      ->ui_name(FALSE);
  }
  $argument_options = array();
  $arguments = $this->display->handler
    ->get_handlers('argument');
  foreach ($arguments as $id => $handler) {
    $argument_options[$id] = $handler
      ->ui_name(FALSE);
  }
  $form['macro'] = array(
    '#type' => 'textarea',
    '#title' => t('Macro'),
    '#rows' => 3,
    '#default_value' => $this->options['macro'],
  );
  $form['datasource'] = array(
    '#type' => 'select',
    '#title' => t('Data Source'),
    '#options' => array(
      'location' => t('Location.module'),
      'fields' => t('Choose latitude and longitude fields'),
    ),
    '#default_value' => $this->options['datasource'],
    '#multiple' => FALSE,
  );
  $form['latfield'] = array(
    '#title' => t('Latitude field'),
    '#description' => t('Format must be degrees decimal.'),
    '#type' => 'select',
    '#options' => $field_options,
    '#default_value' => $this->options['latfield'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-datasource' => array(
        'fields',
      ),
    ),
  );
  $form['lonfield'] = array(
    '#title' => t('Longitude field'),
    '#description' => t('Format must be degrees decimal.'),
    '#type' => 'select',
    '#options' => $field_options,
    '#default_value' => $this->options['lonfield'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-datasource' => array(
        'fields',
      ),
    ),
  );
  $form['markers'] = array(
    '#type' => 'select',
    '#title' => t('Marker handling'),
    // @@@ Detect view type automatically?
    '#options' => array(
      'nodetype' => t('By content type (for node views)'),
      'taxonomy' => t('By term (for node views)'),
      'userrole' => t('By user role (for user views)'),
      'field' => t('Use marker field'),
      'static' => t('Use single marker type'),
    ),
    '#default_value' => $this->options['markers'],
  );
  $form['markerfield'] = array(
    '#type' => 'select',
    '#title' => t('Marker field'),
    '#description' => t('You can use a views field to set the <em>markername</em> property of the markers.'),
    '#options' => $field_options,
    '#default_value' => $this->options['markerfield'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-markers' => array(
        'field',
      ),
    ),
  );
  $form['enablermt'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable GMap RMT for markers'),
    '#description' => t('You can pull the bodies of the markers from a callback instead of defining them inline. This is a performance feature for advanced users.'),
    '#default_value' => $this->options['enablermt'],
  );
  $form['rmtfield'] = array(
    '#type' => 'select',
    '#title' => t('RMT field'),
    '#description' => t('You can use a views field to define the "tail" of the path called back.'),
    '#options' => $field_options,
    '#default_value' => $this->options['rmtfield'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-enablermt' => array(
        TRUE,
      ),
    ),
  );
  $form['rmtcallback'] = array(
    '#type' => 'textfield',
    '#title' => t('RMT callback path'),
    '#description' => t('Define the base path to the callback here. The value of the rmt field will be appended.'),
    '#default_value' => $this->options['rmtcallback'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-enablermt' => array(
        TRUE,
      ),
    ),
  );

  // Hide the taxonomy handling if gmap_taxonomy.module isn't installed.
  if (!module_exists('gmap_taxonomy')) {
    unset($form['markers']['#options']['taxonomy']);
  }
  $form['markertype'] = array(
    '#type' => 'gmap_markerchooser',
    '#title' => t('Marker / fallback marker to use'),
    '#default_value' => $this->options['markertype'],
  );
  $form['center_on_nodearg'] = array(
    '#type' => 'checkbox',
    '#title' => t('Center on node argument'),
    '#default_value' => $this->options['center_on_nodearg'],
    '#description' => $this->view->base_table == 'node' ? t('Note: The view must contain an argument whose value is a node ID.') : t('Note: The view must contain an argument whose value is a node ID.') . '<br />' . t("The view must contain 'Node: nid' as one of its fields because the view type is not 'Node'."),
  );
  $form['center_on_nodearg_arg'] = array(
    '#title' => t('Argument'),
    '#description' => empty($argument_options) ? t("The value of the selected argument must be a number that matches a node ID.  Use the 'Global: Null' argument if you don't want to also restrict results to that node ID.  You must have added arguments to the view to use this option.") : t("The selected argument must be a number that matches a node ID.  Use the 'Global: Null' argument if you don't want to also restrict results to that node ID."),
    '#type' => 'select',
    '#options' => $argument_options,
    '#default_value' => $this->options['center_on_nodearg_arg'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-center-on-nodearg' => array(
        TRUE,
      ),
    ),
  );
  $form['highlight_nodearg'] = array(
    '#type' => 'checkbox',
    '#title' => t('Highlight marker for node argument'),
    '#default_value' => $this->options['highlight_nodearg'],
    '#description' => $this->view->base_table == 'node' ? t('Note: The view must contain an argument whose value is a node ID.') : t('Note: The view must contain an argument whose value is a node ID.') . '<br />' . t("The view must contain 'Node: nid' as one of its fields because the view type is not 'Node'."),
  );
  $form['highlight_nodearg_arg'] = array(
    '#title' => t('Argument'),
    '#description' => empty($argument_options) ? t("The value of the selected argument must be a number that matches a node ID.  Use the 'Global: Null' argument if you don't want to also restrict results to that node ID.  You must have added arguments to the view to use this option.") : t("The value of the selected argument must be a number that matches a node ID.  Use the 'Global: Null' argument if you don't want to also restrict results to that node ID."),
    '#type' => 'select',
    '#options' => $argument_options,
    '#default_value' => $this->options['highlight_nodearg_arg'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-highlight-nodearg' => array(
        TRUE,
      ),
    ),
  );
  $form['highlight_nodearg_color'] = array(
    '#title' => t('Highlight color'),
    '#description' => t("A 6 digit hex color value to use for the highlight. Include preceding hash. Example #FF0000"),
    '#type' => 'textfield',
    '#size' => 7,
    '#maxlength' => 7,
    '#default_value' => $this->options['highlight_nodearg_color'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-highlight-nodearg' => array(
        TRUE,
      ),
    ),
  );
  $form['tooltipenabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display a tooltip when hovering over markers'),
    '#default_value' => $this->options['tooltipenabled'],
  );
  $form['tooltipfield'] = array(
    '#title' => t('Tooltip field'),
    '#description' => empty($field_options) ? t("The field's format must be text.  You must be using the fields row style and have added fields to the view to use this option.") : t("The field's format must be text."),
    '#type' => 'select',
    '#options' => $field_options,
    '#default_value' => $this->options['tooltipfield'],
    '#process' => array(
      'views_process_dependency',
    ),
    '#dependency' => array(
      'edit-style-options-tooltipenabled' => array(
        TRUE,
      ),
    ),
  );
}