2014-03-31 16:10:39 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Code for the Farm Crop feature.
|
|
|
|
*/
|
|
|
|
|
|
|
|
include_once 'farm_crop.features.inc';
|
2014-11-19 19:27:27 +01:00
|
|
|
|
2014-11-26 22:55:20 +01:00
|
|
|
/**
|
2015-03-13 01:01:33 +01:00
|
|
|
* Implements hook_farm_admin_actions().
|
2014-11-26 22:55:20 +01:00
|
|
|
*/
|
2015-03-13 01:01:33 +01:00
|
|
|
function farm_crop_farm_admin_actions() {
|
2014-11-26 22:55:20 +01:00
|
|
|
|
|
|
|
// Define actions.
|
|
|
|
$actions = array(
|
|
|
|
'crop' => array(
|
|
|
|
'title' => t('Add a crop'),
|
|
|
|
'href' => 'admin/structure/taxonomy/farm_crops/add',
|
2015-03-13 01:01:33 +01:00
|
|
|
'paths' => array(
|
|
|
|
'farm/crops',
|
|
|
|
),
|
2014-11-26 22:55:20 +01:00
|
|
|
),
|
2014-12-01 01:30:00 +01:00
|
|
|
'harvest' => array(
|
|
|
|
'title' => t('Add a harvest'),
|
|
|
|
'href' => 'log/add/farm_harvest',
|
2015-03-13 01:01:33 +01:00
|
|
|
'paths' => array(
|
|
|
|
'farm/asset/%/harvests',
|
|
|
|
'farm/crops/harvests',
|
|
|
|
),
|
|
|
|
'assets' => array(
|
|
|
|
'planting'
|
|
|
|
),
|
2014-12-01 01:30:00 +01:00
|
|
|
),
|
2014-12-01 01:30:19 +01:00
|
|
|
'input' => array(
|
|
|
|
'title' => t('Add an input'),
|
|
|
|
'href' => 'log/add/farm_input',
|
2015-03-13 01:01:33 +01:00
|
|
|
'paths' => array(
|
|
|
|
'farm/area/%/inputs',
|
|
|
|
'farm/asset/%/inputs',
|
|
|
|
'farm/crops/inputs',
|
|
|
|
'taxonomy/term/%',
|
|
|
|
),
|
|
|
|
'assets' => array(
|
|
|
|
'planting'
|
|
|
|
),
|
2014-12-01 01:30:19 +01:00
|
|
|
),
|
2014-11-26 22:55:20 +01:00
|
|
|
'planting' => array(
|
|
|
|
'title' => t('Add a planting'),
|
|
|
|
'href' => 'farm/asset/add/planting',
|
2015-03-13 01:01:33 +01:00
|
|
|
'paths' => array(
|
|
|
|
'farm/area/%/plantings',
|
|
|
|
'farm/crop/%/plantings',
|
|
|
|
'farm/crops',
|
|
|
|
'farm/crops/plantings',
|
|
|
|
),
|
2014-11-26 22:55:20 +01:00
|
|
|
),
|
|
|
|
'seeding' => array(
|
2014-12-01 01:30:00 +01:00
|
|
|
'title' => t('Add a seeding'),
|
2014-11-26 22:55:20 +01:00
|
|
|
'href' => 'log/add/farm_seeding',
|
2015-03-13 01:01:33 +01:00
|
|
|
'paths' => array(
|
|
|
|
'farm/asset/%/seedings',
|
|
|
|
'farm/crops/seedings',
|
|
|
|
),
|
|
|
|
'assets' => array(
|
|
|
|
'planting'
|
|
|
|
),
|
2014-11-26 22:55:20 +01:00
|
|
|
),
|
|
|
|
'transplanting' => array(
|
2014-12-01 01:30:00 +01:00
|
|
|
'title' => t('Add a transplanting'),
|
2014-11-26 22:55:20 +01:00
|
|
|
'href' => 'log/add/farm_transplanting',
|
2015-03-13 01:01:33 +01:00
|
|
|
'paths' => array(
|
|
|
|
'farm/asset/%/transplantings',
|
|
|
|
'farm/crops/transplantings',
|
|
|
|
),
|
|
|
|
'assets' => array(
|
|
|
|
'planting'
|
|
|
|
),
|
2014-11-26 22:55:20 +01:00
|
|
|
),
|
|
|
|
);
|
2015-03-13 01:01:33 +01:00
|
|
|
return $actions;
|
2014-11-26 22:55:20 +01:00
|
|
|
}
|
|
|
|
|
2014-11-19 19:27:27 +01:00
|
|
|
/**
|
|
|
|
* Implements hook_form_alter().
|
|
|
|
*/
|
|
|
|
function farm_crop_form_alter(&$form, &$form_state, $form_id) {
|
|
|
|
|
|
|
|
// If this is a log form with a planting reference field...
|
|
|
|
if ($form_id == 'log_form' && !empty($form['field_farm_planting'])) {
|
|
|
|
|
|
|
|
// Alter the form with the farm_log helper function.
|
2014-12-01 03:51:25 +01:00
|
|
|
farm_log_form_prepopulate_asset($form, 'field_farm_planting');
|
2014-11-19 19:27:27 +01:00
|
|
|
}
|
2014-12-01 02:09:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_farm_area_links().
|
|
|
|
*/
|
|
|
|
function farm_crop_farm_area_links($id) {
|
|
|
|
return array(
|
2014-12-01 15:03:54 +01:00
|
|
|
array(
|
|
|
|
'title' => t('Inputs'),
|
|
|
|
'href' => 'farm/area/' . $id . '/inputs',
|
|
|
|
'weight' => 10,
|
|
|
|
),
|
2014-12-01 20:19:06 +01:00
|
|
|
array(
|
|
|
|
'title' => t('Plantings'),
|
|
|
|
'href' => 'farm/area/' . $id . '/plantings',
|
|
|
|
),
|
2014-12-01 02:09:58 +01:00
|
|
|
);
|
|
|
|
}
|