farmOS/modules/farm/farm_soil/farm_soil_test/farm_soil_test.module

60 lines
1.2 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',
'farm_asset' => 'none',
'areas' => TRUE,
),
),
);
}
/**
* 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;
}