mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
65 lines
1.4 KiB
Plaintext
65 lines
1.4 KiB
Plaintext
<?php
|
|
/**
|
|
* @file
|
|
* Code for the Farm Area feature.
|
|
*/
|
|
|
|
include_once 'farm_area.features.inc';
|
|
|
|
/**
|
|
* Implements hook_menu_local_tasks_alter().
|
|
*/
|
|
function farm_area_menu_local_tasks_alter(&$data, $router_item, $root_path) {
|
|
|
|
// Define actions.
|
|
$actions = array(
|
|
'area' => array(
|
|
'title' => t('Add an area'),
|
|
'href' => t('admin/structure/taxonomy/farm_areas/add'),
|
|
),
|
|
);
|
|
|
|
// Define actions for various paths.
|
|
$path_actions = array(
|
|
'admin/farm' => $actions['area'],
|
|
'admin/farm/areas' => $actions['area'],
|
|
);
|
|
|
|
// Add actions depending on the root path.
|
|
if (array_key_exists($root_path, $path_actions)) {
|
|
$output = array(
|
|
'#theme' => 'menu_local_action',
|
|
'#link' => array(
|
|
'title' => $path_actions[$root_path]['title'],
|
|
'href' => $path_actions[$root_path]['href'],
|
|
'localized_options' => array(
|
|
'query' => array(
|
|
'destination' => $root_path,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
// Add the action output.
|
|
$data['actions']['output'][] = $output;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Generate area links.
|
|
*
|
|
* @param $id
|
|
* The area id.
|
|
*
|
|
* @return string
|
|
* Returns a string of links.
|
|
*/
|
|
function farm_area_get_links($id) {
|
|
|
|
// Call out to modules that want to provide links.
|
|
$links = module_invoke_all('farm_area_links', check_plain($id));
|
|
|
|
// Return the links.
|
|
return $links;
|
|
} |