farmOS/modules/farm/farm_log/farm_log_observation/farm_log_observation.module

66 lines
1.4 KiB
Plaintext

<?php
/**
* @file
* Code for the Farm Log: Observation feature.
*/
// Include Features code.
include_once 'farm_log_observation.features.inc';
/**
* Implements hook_farm_ui_entities().
*/
function farm_log_observation_farm_ui_entities() {
return array(
'log' => array(
'farm_observation' => array(
'label' => t('Observation'),
'label_plural' => t('Observations'),
'view' => 'farm_log_observation',
'areas' => TRUE,
),
),
);
}
/**
* Implements hook_farm_taxonomy_term_view_views().
*/
function farm_log_observation_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(
// Observations in this area.
array(
'name' => 'farm_log_observation',
'arg' => 2,
),
);
}
/**
* Implements hook_farm_area_links().
*/
function farm_log_observation_farm_area_links($id) {
$links = array();
// Add link to observations.
$view = views_get_view('farm_log_observation');
$view->preview('default', array('all', $id));
if ($view->total_rows > 0) {
$links[] = array(
'title' => t('Observations') . ': ' . $view->total_rows,
'href' => 'farm/logs/observations/all/' . $id,
'weight' => -100,
);
}
return $links;
}