You are here

public function EntityWorkflowUIController::overviewForm in Workflow 7.2

Builds the entity overview form.

Overrides EntityDefaultUIController::overviewForm

File

workflow_admin_ui/includes/Entity/EntityWorkflowUIController.php, line 78
Contains workflow_admin_ui\includes\Entity\EntityWorkflowUIController.

Class

EntityWorkflowUIController
@file Contains workflow_admin_ui\includes\Entity\EntityWorkflowUIController.

Code

public function overviewForm($form, &$form_state) {

  // Add table and pager.
  $form = parent::overviewForm($form, $form_state);

  // Allow modules to insert their own action links to the 'table', like cleanup module.
  $top_actions = module_invoke_all('workflow_operations', 'top_actions', NULL);

  // Allow modules to insert their own workflow operations.
  foreach ($form['table']['#rows'] as &$row) {
    $url = $row[0]['data']['#url'];
    $workflow = $url['options']['entity'];
    foreach ($actions = module_invoke_all('workflow_operations', 'workflow', $workflow) as $action) {
      $action['attributes'] = isset($action['attributes']) ? $action['attributes'] : array();
      $row[] = l(strtolower($action['title']), $action['href'], $action['attributes']);
    }
  }

  // @todo: add these top actions next to the core 'Add workflow' action.
  $top_actions_args = array(
    'links' => $top_actions,
    'attributes' => array(
      'class' => array(
        'inline',
        'action-links',
      ),
    ),
  );
  $form['action-links'] = array(
    '#type' => 'markup',
    '#markup' => theme('links', $top_actions_args),
    '#weight' => -1,
  );
  if (module_exists('workflownode')) {

    // Append the type_map form, changing the form by reference.
    // The 'type_map' form is only valid for Workflow Node API.
    module_load_include('inc', 'workflow_admin_ui', 'workflow_admin_ui.page.type_map');
    workflow_admin_ui_type_map_form($form);
  }

  // Add a submit button. The submit functions are added in the sub-forms.
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 100,
  );
  return $form;
}