You are here

function state_flow_iib_entity_item in State Machine 7.2

Implements hook_iib_page_item()

Return value

array

File

modules/state_flow/state_flow.iib.inc, line 8

Code

function state_flow_iib_entity_item($entity, $entity_type, $view_mode) {
  $output = $events = array();
  switch ($entity_type) {
    case 'node':
      if (is_object($entity) && $view_mode == 'full') {
        $state_flow = state_flow_load_state_machine($entity);
        $state = $state_flow
          ->get_current_state();
        $output[] = t('Revision Status: @state', array(
          '@state' => $state,
        ));
        $all_events = $state_flow
          ->get_available_events();
        foreach ($all_events as $event_machine_name => $event) {
          if (state_flow_access($entity, $event_machine_name)) {
            $events[$event_machine_name] = $event
              ->get_option('label');
          }
        }
        if (!empty($events)) {
          $iib_state_form = drupal_get_form('state_flow_iib_entity_state_form', $events, $entity, $state_flow);
          $output[] = drupal_render($iib_state_form);
        }
      }
      break;
  }
  if (!empty($output)) {
    $items['center'] = array(
      '#weight' => -10,
      '#prefix' => '<div class="state-flow-iib">',
      '#markup' => implode("\n", $output),
      '#suffix' => '</div>',
    );
    return $items;
  }
}