84 lines
1.7 KiB
Plaintext
84 lines
1.7 KiB
Plaintext
<?php
|
|
/**
|
|
* @file
|
|
* Code for the Farm Log: Activity feature.
|
|
*/
|
|
|
|
// Include Features code.
|
|
include_once 'farm_log_activity.features.inc';
|
|
|
|
/**
|
|
* Implements hook_farm_ui_entities().
|
|
*/
|
|
function farm_log_activity_farm_ui_entities() {
|
|
return array(
|
|
'log' => array(
|
|
'farm_activity' => array(
|
|
'label' => t('Activity'),
|
|
'label_plural' => t('Activities'),
|
|
'view' => 'farm_log_activity',
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_ui_actions().
|
|
*/
|
|
function farm_log_activity_farm_ui_actions() {
|
|
|
|
// Define farm area actions.
|
|
$actions = array(
|
|
'activity' => array(
|
|
'title' => t('Add an activity'),
|
|
'href' => 'log/add/farm_activity',
|
|
'assets' => array(
|
|
'all',
|
|
),
|
|
'paths' => array(
|
|
'taxonomy/term/%',
|
|
),
|
|
),
|
|
);
|
|
return $actions;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_taxonomy_term_view_views().
|
|
*/
|
|
function farm_log_activity_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_activity',
|
|
'arg' => 2,
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_farm_area_links().
|
|
*/
|
|
function farm_log_activity_farm_area_links($id) {
|
|
$links = array();
|
|
|
|
// Add link to activities.
|
|
$view = views_get_view('farm_log_activity');
|
|
$view->preview('default', array('all', $id));
|
|
if ($view->total_rows > 0) {
|
|
$links[] = array(
|
|
'title' => t('Activities') . ': ' . $view->total_rows,
|
|
'href' => 'farm/logs/activities/all/' . $id,
|
|
'weight' => -100,
|
|
);
|
|
}
|
|
|
|
return $links;
|
|
}
|