You are here

function farm_flags_farm_area_details in farmOS 7

Implements hook_farm_area_details().

File

modules/farm/farm_area/farm_area.farm_area.inc, line 45
Farm Area hooks implemented by the Farm Area module.

Code

function farm_flags_farm_area_details($id) {

  // Start a render array.
  $output = array();

  // Load the area.
  $area = taxonomy_term_load($id);

  // If the area didn't load, bail.
  if (empty($area)) {
    return $output;
  }

  // Load and display any flags on the area.
  $all_flags = farm_flags_list();
  $area_flags = farm_flags_load($area);
  foreach ($area_flags as $key => $flag) {
    if (!empty($all_flags[$flag])) {
      $area_flags[$key] = farm_flags_wrap($all_flags[$flag], $flag);
    }
  }

  // If there are no flags, bail.
  if (empty($area_flags)) {
    return $output;
  }

  // Add the list of flags to the area details.
  $output[] = array(
    '#type' => 'markup',
    '#markup' => implode(' ', $area_flags),
    '#weight' => -101,
  );

  // Return the output.
  return $output;
}