141 lines
3.4 KiB
Plaintext
141 lines
3.4 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',
|
|
'asset_view_arg' => 2,
|
|
),
|
|
'farm_animal_types' => array(
|
|
'label' => t('Type'),
|
|
'label_plural' => t('Types'),
|
|
'view' => 'farm_animal_types',
|
|
'farm_asset' => 'animal',
|
|
'asset_view_arg' => 3,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 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_log_categories().
|
|
*/
|
|
function farm_livestock_farm_log_categories() {
|
|
|
|
// Provide an "Animals" log category.
|
|
return array('Animals');
|
|
}
|
|
|
|
/**
|
|
* Implements hook_feeds_importer_default_alter().
|
|
*/
|
|
function farm_livestock_feeds_importer_default_alter($importers) {
|
|
|
|
// Add extra field mappings to animals.
|
|
$name = 'farm_asset_animal';
|
|
if (!empty($importers[$name])) {
|
|
$mappings = array(
|
|
array(
|
|
'source' => 'Nicknames',
|
|
'target' => 'field_farm_animal_nicknames',
|
|
'unique' => FALSE,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Date of birth',
|
|
'target' => 'field_farm_date:start',
|
|
'unique' => FALSE,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Species/breed',
|
|
'target' => 'field_farm_animal_type',
|
|
'term_search' => '0',
|
|
'autocreate' => 1,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Group',
|
|
'target' => 'field_farm_animal_group',
|
|
'term_search' => '0',
|
|
'autocreate' => 1,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Sex',
|
|
'target' => 'field_farm_animal_sex',
|
|
'unique' => FALSE,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Castrated',
|
|
'target' => 'field_farm_animal_castrated',
|
|
'unique' => FALSE,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Tag ID',
|
|
'target' => 'field_farm_animal_tag:field_farm_animal_tag_id',
|
|
'unique' => FALSE,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Tag type',
|
|
'target' => 'field_farm_animal_tag:field_farm_animal_tag_type',
|
|
'unique' => FALSE,
|
|
'language' => 'und',
|
|
),
|
|
array(
|
|
'source' => 'Tag location',
|
|
'target' => 'field_farm_animal_tag:field_farm_animal_tag_location',
|
|
'unique' => FALSE,
|
|
'language' => 'und',
|
|
),
|
|
);
|
|
$importer_mappings =& $importers[$name]->config['processor']['config']['mappings'];
|
|
$importer_mappings = array_merge($importer_mappings, $mappings);
|
|
}
|
|
}
|