You are here

function theme_workflow_admin_ui_edit_form in Workflow 6

Same name and namespace in other branches
  1. 6.2 workflow_admin_ui/workflow_admin_ui.module \theme_workflow_admin_ui_edit_form()
  2. 7 workflow_admin_ui/workflow_admin_ui.pages.inc \theme_workflow_admin_ui_edit_form()

Theme the workflow editing form.

See also

workflow_edit_form()

File

workflow_admin_ui/workflow_admin_ui.module, line 357
Provides administrative UI for workflow. Why it's own module? Lower code footprint and better performance. Additional creadit to gcassie ( http://drupal.org/user/80260 ) for the initial push to split UI out of core workflow. We're moving…

Code

function theme_workflow_admin_ui_edit_form($form) {
  $output = drupal_render($form['wf_name']);
  $wid = $form['wid']['#value'];
  $states = workflow_get_states($wid);
  drupal_set_title(t('Edit workflow %name', array(
    '%name' => workflow_get_name($wid),
  )));
  if ($states) {
    $roles = workflow_get_roles();
    $header = array(
      array(
        'data' => t('From / To ') . ' ' . WORKFLOW_ARROW,
      ),
    );
    $rows = array();
    foreach ($states as $state_id => $name) {

      // Don't allow transition TO (creation).
      if ($name != t('(creation)')) {
        $header[] = array(
          'data' => check_plain(t($name)),
        );
      }
      $row = array(
        array(
          'data' => check_plain(t($name)),
        ),
      );
      foreach ($states as $nested_state_id => $nested_name) {
        if ($nested_name == t('(creation)')) {

          // Don't allow transition TO (creation).
          continue;
        }
        if ($nested_state_id != $state_id) {

          // Need to render checkboxes for transition from $state to $nested_state.
          $from = $state_id;
          $to = $nested_state_id;
          $cell = '';
          foreach ($roles as $rid => $role_name) {
            $cell .= drupal_render($form['transitions'][$from][$to][$rid]);
          }
          $row[] = array(
            'data' => $cell,
          );
        }
        else {
          $row[] = array(
            'data' => '',
          );
        }
      }
      $rows[] = $row;
    }
    $output .= theme('table', $header, $rows);
  }
  else {
    $output = t('There are no states defined for this workflow.');
  }
  $output .= drupal_render($form);
  return $output;
}