farmOS/modules/farm/farm_log/farm_log_input/farm_log_input.module

64 lines
1.2 KiB
Plaintext

<?php
/**
* @file
* Code for the Farm Log: Input feature.
*/
// Include Features code.
include_once 'farm_log_input.features.inc';
/**
* Implements hook_farm_ui_entities().
*/
function farm_log_input_farm_ui_entities() {
return array(
'log' => array(
'farm_input' => array(
'label' => t('Input'),
'label_plural' => t('Inputs'),
'view' => 'farm_log_input',
'areas' => TRUE,
),
),
);
}
/**
* Implements hook_farm_taxonomy_term_view_views().
*/
function farm_log_input_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(
array(
'name' => 'farm_log_input',
'arg' => 2,
),
);
}
/**
* Implements hook_farm_area_links().
*/
function farm_log_input_farm_area_links($id) {
$links = array();
// Add link to inputs.
$view = views_get_view('farm_log_input');
$view->preview('default', array('all', $id));
if ($view->total_rows > 0) {
$links[] = array(
'title' => t('Inputs') . ': ' . $view->total_rows,
'href' => 'farm/logs/inputs/all/' . $id,
'weight' => 10,
);
}
return $links;
}