mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Add asset, log, and plan types to entity view pages so it's clear what you're looking at.
This commit is contained in:
parent
a0928554f4
commit
06bc4a24bc
3 changed files with 38 additions and 0 deletions
|
@ -324,6 +324,15 @@ function farm_asset_entity_view($entity, $type, $view_mode, $langcode) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Add the asset type.
|
||||
$asset_types = farm_asset_type_get_names();
|
||||
if (!empty($asset_types[$entity->type])) {
|
||||
$entity->content['type'] = array(
|
||||
'#markup' => '<div><strong>Asset type:</strong> ' . $asset_types[$entity->type] . '</div>',
|
||||
'#weight' => -101,
|
||||
);
|
||||
}
|
||||
|
||||
// If the asset is archived, display a message and the archived date.
|
||||
if (!empty($entity->archived)) {
|
||||
drupal_set_message(t('This asset is archived. Archived assets should not be edited or deleted unless they contain information that is incorrect.'), 'warning');
|
||||
|
|
|
@ -7,6 +7,26 @@
|
|||
// Include Features code.
|
||||
include_once 'farm_log.features.inc';
|
||||
|
||||
/**
|
||||
* Implements hook_entity_view().
|
||||
*/
|
||||
function farm_log_entity_view($entity, $type, $view_mode, $langcode) {
|
||||
|
||||
// If the entity is not a log, bail.
|
||||
if ($type != 'log') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the log type.
|
||||
$log_types = log_type_get_names();
|
||||
if (!empty($log_types[$entity->type])) {
|
||||
$entity->content['type'] = array(
|
||||
'#markup' => '<div><strong>Log type:</strong> ' . $log_types[$entity->type] . '</div>',
|
||||
'#weight' => -101,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*/
|
||||
|
|
|
@ -302,6 +302,15 @@ function farm_plan_entity_view($entity, $type, $view_mode, $langcode) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Add the plan type.
|
||||
$plan_types = farm_plan_type_get_names();
|
||||
if (!empty($plan_types[$entity->type])) {
|
||||
$entity->content['type'] = array(
|
||||
'#markup' => '<div><strong>Plan type:</strong> ' . $plan_types[$entity->type] . '</div>',
|
||||
'#weight' => -101,
|
||||
);
|
||||
}
|
||||
|
||||
// Add the plan's "active" status.
|
||||
if ($entity->active) {
|
||||
$status = 'Yes';
|
||||
|
|
Loading…
Reference in a new issue