You are here

function farm_ui_farm_area_details in farmOS 7

Implements hook_farm_area_details().

File

modules/farm/farm_ui/farm_ui.farm_area.inc, line 9

Code

function farm_ui_farm_area_details($id) {

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

  // Add links to lists of assets and logs in the area.
  $entity_types = array(
    'farm_asset' => array(
      'label' => t('Assets'),
      'weight' => -50,
    ),
    'log' => array(
      'label' => t('Logs'),
      'weight' => -40,
    ),
  );
  foreach ($entity_types as $type => $info) {

    // Get area links for the entity type.
    $area_links = farm_ui_area_links($id, $type);

    // If there are none, skip it.
    if (empty($area_links)) {
      continue;
    }

    // Create variables for an item list.
    $variables = array(
      'items' => $area_links,
      'attributes' => array(),
    );

    // Render the links as markup with a title.
    $output[$type . '_links'] = array(
      '#type' => 'markup',
      '#markup' => '<strong>' . $info['label'] . '</strong>' . theme('item_list', $variables),
      '#weight' => $info['weight'],
    );
  }

  // Return the render array.
  return $output;
}