You are here

function kml_admin_settings in KML 5

Same name and namespace in other branches
  1. 6 kml.module \kml_admin_settings()

Form for settings page

1 string reference to 'kml_admin_settings'
kml_menu in ./kml.module
Implementation of hook_menu().

File

./kml.module, line 249
KML Module

Code

function kml_admin_settings() {
  $form['individual_nodes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Node display'),
    '#description' => t('You can add a KML link to the bottom of location-enabled nodes using these options.'),
  );
  $form['individual_nodes']['kml_nodelink'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add KML link to footer of each full node that has coordinates'),
    '#default_value' => variable_get('kml_nodelink', 1),
  );
  $form['individual_nodes']['kml_nodelink_teaser'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add KML link to footer of each node teaser that has coordinates'),
    '#default_value' => variable_get('kml_nodelink_teaser', 0),
  );
  $form['multiple_nodes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Node ordering'),
    '#description' => t('Choose the order in which multiple nodes are sent in KML feeds. Google Earth should display them in this order, allowing a user to fly through them.'),
  );
  $sort_modes = array(
    'n.created' => 'Time created',
    'n.changed' => 'Time changed',
    'u.name' => 'Author',
    'n.title' => 'Title',
  );
  $sort_orders = array(
    'asc' => 'Ascending',
    'desc' => 'Descending',
  );
  $form['multiple_nodes']['kml_sortmode'] = array(
    '#type' => 'radios',
    '#title' => t('Sort mode'),
    '#default_value' => variable_get('kml_sortmode', 'n.created'),
    '#options' => $sort_modes,
    '#description' => t('Note that this will not affect KML feeds defined through views module.'),
  );
  $form['multiple_nodes']['kml_sortorder'] = array(
    '#type' => 'radios',
    '#title' => t('Sort order'),
    '#default_value' => variable_get('kml_sortorder', 'asc'),
    '#options' => $sort_orders,
  );
  $form['time_information'] = array(
    '#type' => 'fieldset',
    '#title' => t('Time information'),
    '#description' => t('Choose the type of time information to include in the KML feeds. This will allow users to filter the information by time in Google Earth.'),
  );
  $time_types = array(
    'created' => 'Time created',
    'changed' => 'Time changed',
    'none' => 'None',
  );
  $form['time_information']['kml_timetype'] = array(
    '#type' => 'radios',
    '#title' => t('Timestamp'),
    '#default_value' => variable_get('kml_timetype', 'created'),
    '#options' => $time_types,
  );
  $form['style'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display style'),
    '#description' => t('Customise how nodes will be displayed in Google Earth.'),
  );
  $form['style']['kml_sitelogo_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Site logo'),
    '#default_value' => variable_get('kml_sitelogo_url', ''),
    '#description' => t("Add the URL to an image to include a logo in the top left of the Google Earth screen."),
    '#length' => 40,
  );
  $form['style']['kml_altitude'] = array(
    '#type' => 'textfield',
    '#title' => t('Node altitude (meters)'),
    '#default_value' => variable_get('kml_altitude', 0),
    '#description' => t("This will extrude a node from the earth by the specified distance. A line will join the icon to the position on earth. It is useful if you don't want to obscure an area with its own icon."),
    '#size' => '2',
  );
  $form['style']['kml_extrude'] = array(
    '#type' => 'checkbox',
    '#title' => t('Extrude nodes'),
    '#default_value' => variable_get('kml_extrude', 0),
    '#description' => t("This will draw a line joining the icon to the position on earth if an altitude is set above."),
  );
  $content_types = node_get_types('names');
  foreach ($content_types as $name => $title) {
    $form['style']['placemarks'][$name] = array(
      '#type' => 'fieldset',
      '#title' => t('Google Earth Highlight placemark url for ') . $title,
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['style']['placemarks'][$name]['kml_highlightplacemark_url_' . $name] = array(
      '#type' => 'textfield',
      '#title' => t('Google Earth Highlight placemark url'),
      '#default_value' => variable_get('kml_highlightplacemark_url_' . $name, 'http://maps.google.com/mapfiles/kml/paddle/red-stars.png'),
      '#description' => t("Add the URL to an image to use as Google Earth highlight placemark."),
      '#length' => 40,
    );
    $form['style']['placemarks'][$name]['kml_normalplacemark_url_' . $name] = array(
      '#type' => 'textfield',
      '#title' => t('Google Earth normal placemark url'),
      '#default_value' => variable_get('kml_normalplacemark_url_' . $name, 'http://maps.google.com/mapfiles/kml/paddle/wht-blank.png'),
      '#description' => t("Add the URL to an image to use as Google Earth normal placemark."),
      '#length' => 40,
    );
  }
  $form['network_links'] = array(
    '#type' => 'fieldset',
    '#title' => t('Network links'),
    '#description' => t('Network links are simply a pointer to the current version of the KML feed. A user need only download a Network link once, and have the data within it automatically refresh to the latest data from this Drupal site.'),
  );
  $use_networklinks = array(
    1 => 'Yes',
    0 => 'No',
  );
  $form['network_links']['kml_usenetworklinks'] = array(
    '#type' => 'radios',
    '#title' => t('Use network links?'),
    '#default_value' => variable_get('kml_usenetworklinks', 1),
    '#description' => t('Plain feeds are good if the user does not need the information to stay up-to-date. Note that you may have problems when using network links on a site which requires users to log in, and you will require a module such as securesite to provide a standard HTTP Auth login option for any KML feeds.'),
    '#options' => $use_networklinks,
  );
  $refresh_modes = array(
    'never' => 'Never',
    'onStop' => 'onStop',
    'onRequest' => 'onRequest',
  );
  $form['network_links']['kml_refreshmode'] = array(
    '#type' => 'radios',
    '#title' => t('Refresh mode'),
    '#default_value' => variable_get('kml_refreshmode', 'onStop'),
    '#description' => t('When information should be requested from the server.'),
    '#options' => $refresh_modes,
  );
  $form['network_links']['kml_refreshtime'] = array(
    '#type' => 'textfield',
    '#title' => t('Refresh delay'),
    '#default_value' => variable_get('kml_refreshtime', 60),
    '#description' => t("The number of seconds to wait before refreshing the Network Link after the view in Google Earth has stopped moving. Requires 'onStop' to be selected above."),
    '#maxlength' => '3',
    '#size' => '2',
  );
  $form['file_format'] = array(
    '#type' => 'fieldset',
    '#title' => t('File format'),
    '#description' => t('Specify the settings to be used for the KML files produced.'),
  );

  //$kmz_disabled = 0; // TODO: add KMZ file support - http://drupal.org/node/289832
  $kmz_disabled = 1;
  $kmz_note = t('<em><a href="http://drupal.org/node/289832">KMZ support</a> is not yet available.</em>');
  $form['file_format']['kml_usekmz'] = array(
    '#type' => 'checkbox',
    '#title' => t('Compress KML into KMZ?'),
    '#default_value' => variable_get('kml_usekmz', 0),
    '#description' => t('By letting the module compress your KML files into KMZ format you will save a lot on bandwidth and your users will be able to download your data quicker.') . ' ' . $kmz_note,
    '#disabled' => $kmz_disabled,
  );

  // TODO: allow for token module support in here so sites can create dynamic filenames
  $form['file_format']['kml_filename'] = array(
    '#type' => 'textfield',
    '#title' => t('KML filename'),
    '#default_value' => variable_get('kml_filename', 'nodes'),
    '#description' => t('Filename to use for KML feeds. Note that .kml or .kmz will be appended to the above string, so do not include that yourself.'),
  );
  $form['file_format']['kml_networklinkfilename'] = array(
    '#type' => 'textfield',
    '#title' => t('Network Link filename'),
    '#default_value' => variable_get('kml_networklinkfilename', 'networklink'),
    '#description' => t('Filename to use for KML network links. Note that .kml or .kmz will be appended to the above string, so do not include that yourself.'),
  );
  return system_settings_form($form);
}