You are here

function farm_map_build in farmOS 7

Build a map render array.

Parameters

string $map_name: The machine name of the map.

bool $fieldset: Whether or not to wrap the map in a fieldset.

string $title: Whether or not to wrap the map in a fieldset.

bool $collapsed: Whether or not to collapse the fieldset by default.

Return value

array Returns a Drupal render array.

4 calls to farm_map_build()
farm_area_generate_page_build in modules/farm/farm_area/farm_area_generate/farm_area_generate.module
Implements hook_page_build().
farm_area_page_build in modules/farm/farm_area/farm_area.module
Implements hook_page_build().
farm_map_block_view in modules/farm/farm_map/farm_map.block.inc
Implements hook_block_view().
farm_plan_map_entity_view_alter in modules/farm/farm_plan/farm_plan_map/farm_plan_map.module
Implements hook_entity_view_alter().

File

modules/farm/farm_map/farm_map.module, line 196

Code

function farm_map_build($map_name, $fieldset = FALSE, $title = '', $collapsed = FALSE) {

  // Build the map.
  $build = array(
    '#type' => 'farm_map',
    '#map_name' => $map_name,
  );

  // Wrap the map in a fieldset, if desired.
  if (!empty($fieldset)) {

    // Create the fieldset.
    $build = array(
      '#type' => 'fieldset',
      '#title' => $title,
      '#collapsible' => TRUE,
      '#collapsed' => $collapsed,
      'farm_map' => $build,
    );

    // Add 'collapsible' and 'collapsed' classes. This is necessary when
    // rendering the fieldset outside of a form.
    // See: https://www.drupal.org/node/1099132
    drupal_add_library('system', 'drupal.collapse');
    $build['#attributes']['class'][] = 'collapsible';
    $build['#attributes']['class'][] = 'collapsed';
  }

  // Return the build.
  return $build;
}