76 lines
1.5 KiB
Plaintext
76 lines
1.5 KiB
Plaintext
<?php
|
|
/**
|
|
* @file
|
|
* Code for the Farm Soil Test feature.
|
|
*/
|
|
|
|
include_once 'farm_soil_test.features.inc';
|
|
|
|
/**
|
|
* Implements hook_farm_ui_entities().
|
|
*/
|
|
function farm_soil_test_farm_ui_entities() {
|
|
return array(
|
|
'log' => array(
|
|
'farm_soil_test' => array(
|
|
'label' => t('Soil test'),
|
|
'label_plural' => t('Soil tests'),
|
|
'view' => 'farm_log_soil_tests',
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_ui_actions().
|
|
*/
|
|
function farm_soil_test_farm_ui_actions() {
|
|
|
|
// Define farm area actions.
|
|
$actions = array(
|
|
'soil_test' => array(
|
|
'title' => t('Add a soil test'),
|
|
'href' => 'log/add/farm_soil_test',
|
|
'paths' => array(
|
|
'taxonomy/term/%',
|
|
),
|
|
),
|
|
);
|
|
return $actions;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_taxonomy_term_view_views().
|
|
*/
|
|
function farm_soil_test_farm_taxonomy_term_view_views($term) {
|
|
|
|
// If the term is not an area, bail.
|
|
if ($term->vocabulary_machine_name != 'farm_areas') {
|
|
return array();
|
|
}
|
|
|
|
// Return a list of Views to include on Areas.
|
|
return array(
|
|
'farm_log_soil_tests',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_area_links().
|
|
*/
|
|
function farm_soil_test_farm_area_links($id) {
|
|
$links = array();
|
|
|
|
// Add link to soil tests.
|
|
$view = views_get_view('farm_log_soil_tests');
|
|
$view->preview('default', array($id));
|
|
if ($view->total_rows > 0) {
|
|
$links[] = array(
|
|
'title' => t('Soil tests') . ': ' . $view->total_rows,
|
|
'href' => 'farm/logs/soil-tests/' . $id,
|
|
);
|
|
}
|
|
|
|
return $links;
|
|
}
|