farmOS/modules/farm/farm_livestock/farm_livestock.module

123 lines
2.7 KiB
Plaintext

<?php
/**
* @file
* Code for the Farm Livestock feature.
*/
include_once 'farm_livestock.features.inc';
/**
* Implements hook_farm_ui_entities().
*/
function farm_livestock_farm_ui_entities() {
return array(
'farm_asset' => array(
'animal' => array(
'label' => t('Animal'),
'label_plural' => t('Animals'),
'view' => 'farm_animals',
),
),
'log' => array(
'farm_medical' => array(
'label' => t('Medical record'),
'label_plural' => t('Medical records'),
'view' => 'farm_log_medical',
'farm_asset' => 'animal',
'weight' => 20,
),
),
'taxonomy_term' => array(
'farm_animal_groups' => array(
'label' => t('Group'),
'label_plural' => t('Groups'),
'view' => 'farm_animal_groups',
'farm_asset' => 'animal',
),
'farm_animal_types' => array(
'label' => t('Type'),
'label_plural' => t('Types'),
'view' => 'farm_animal_types',
'farm_asset' => 'animal',
),
),
);
}
/**
* Implements hook_farm_area_type_info().
*/
function farm_livestock_farm_area_type_info() {
return array(
'paddock' => array(
'label' => t('Paddock'),
'style' => 'farm_map_style_dark_green',
'weight' => 5,
),
);
}
/**
* Implements hook_farm_ui_entity_views().
*/
function farm_livestock_farm_ui_entity_views($entity_type, $bundle, $entity) {
$views = array();
// Return a list of Views to include on Animals.
if ($entity_type == 'farm_asset' && $bundle == 'animal') {
$views[] = array(
'name' => 'farm_log_movement',
'weight' => 100,
);
$views[] = array(
'name' => 'farm_asset_children',
'display' => 'page',
'title' => t('Children'),
'weight' => 110,
);
}
// If the entity is a taxonomy_term...
elseif ($entity_type == 'taxonomy_term') {
switch ($entity->vocabulary_machine_name) {
// Farm areas:
case 'farm_areas':
$views[] = array(
'name' => 'farm_animals',
'weight' => -10,
);
break;
// Farm animal groups:
case 'farm_animal_groups':
$views[] = array(
'name' => 'farm_animals',
'arg' => 2,
'always' => TRUE,
);
break;
// Farm animal types:
case 'farm_animal_types':
$views[] = array(
'name' => 'farm_animals',
'arg' => 3,
'always' => TRUE,
);
break;
}
}
return $views;
}
/**
* Implements hook_farm_log_categories().
*/
function farm_livestock_farm_log_categories() {
// Provide an "Animals" log category.
return array('Animals');
}