function workflow_admin_ui_overview_form in Workflow 7
Menu callback. Create the main workflow page, which gives an overview of workflows and workflow states. Replaced by http://drupal.org/node/1367530.
1 string reference to 'workflow_admin_ui_overview_form'
- workflow_admin_ui_menu in workflow_admin_ui/
workflow_admin_ui.module - Implements hook_menu().
File
- workflow_admin_ui/
workflow_admin_ui.pages.inc, line 614 - Provides administrative UI for workflow. Why it's own module? Lower code footprint and better performance. Additional credit to gcassie ( http://drupal.org/user/80260 ) for the initial push to split UI out of core workflow. We're moving…
Code
function workflow_admin_ui_overview_form($form, $form_state, $workflow) {
// Let's add some breadcrumbs.
$bc = array(
l(t('Home'), '<front>'),
);
$bc[] = l(t('Configuration'), 'admin/config');
$bc[] = l(t('Workflow'), 'admin/config/workflow');
$bc[] = l(t('Workflow'), 'admin/config/workflow/workflow');
drupal_set_breadcrumb($bc);
drupal_set_title(t('Workflow: ') . $workflow
->label());
$form = array();
$form['#tree'] = TRUE;
$form['workflow'] = array(
'#type' => 'value',
'#value' => $workflow,
);
// Allow modules to insert their own workflow operations.
$links = module_invoke_all('workflow_operations', 'workflow', $workflow);
$links_args = array(
'links' => $links,
'attributes' => array(
'class' => array(
'inline',
'action-links',
),
),
);
$form['action-links'] = array(
'#type' => 'markup',
'#markup' => theme('links', $links_args),
);
// Build select options for reassigning states.
// We put a blank state first for validation.
$state_list = array(
'' => ' ',
);
$state_list += $workflow
->getOptions();
// Is this the last state available?
$form['#last_mohican'] = count($state_list) == 2;
// Get the state objects as array ($sid => WorkflowState)
$states = $workflow
->getStates($all = TRUE);
// Dummy object for new state item.
$dummy = WorkflowState::create($name = '', $wid = $workflow->wid);
$dummy->weight = 99;
$states[$dummy->sid] = $dummy;
// Although the index is 0, the state is appended at the end of the list.
foreach ($states as $state) {
// Allow modules to insert state operations.
$state_links = module_invoke_all('workflow_operations', 'state', $workflow, $state);
$form['states'][$state->sid] = array(
'state' => array(
'#type' => 'textfield',
'#size' => 30,
'#maxlength' => 255,
'#default_value' => $state
->label(),
),
'weight' => array(
'#type' => 'weight',
'#delta' => 20,
'#default_value' => $state->weight,
'#title-display' => 'invisible',
'#attributes' => array(
'class' => array(
'state-weight',
),
),
),
'status' => array(
'#type' => 'checkbox',
'#default_value' => $state
->isActive(),
),
// Save the original status for the validation handler.
'orig_status' => array(
'#type' => 'value',
'#value' => $state
->isActive(),
),
'reassign' => array(
'#type' => 'select',
'#options' => $state_list,
),
'count' => array(
'#type' => 'value',
'#value' => count(workflow_get_workflow_node_by_sid($state->sid)),
),
'ops' => array(
'#type' => 'markup',
'#markup' => theme('links', array(
'links' => $state_links,
)),
),
'sysid' => array(
'#type' => 'value',
'#value' => $state
->isCreationState(),
),
);
// Don't let the creation state change weight or status or name.
if ($state
->isCreationState()) {
$form['states'][$state->sid]['weight']['#value'] = -50;
$form['states'][$state->sid]['sysid']['#value'] = 1;
$form['states'][$state->sid]['state']['#disabled'] = TRUE;
$form['states'][$state->sid]['status']['#disabled'] = TRUE;
$form['states'][$state->sid]['reassign']['#disabled'] = TRUE;
}
}
$form['instructions'] = array(
'#type' => 'markup',
'#markup' => '<p>' . t('You may enter a new state name in the empty space.
Check the "Active" box to make it effective. You may also drag it to the appropriate position.') . '</p>' . '<p>' . t('A state not marked as active will not be shown as available in the workflow settings.') . '</p>' . '<p>' . t('If you wish to inactivate a state that has content (i.e. count is not zero),
then you need to select a state to which to reassign that content.') . '</p>',
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Changes'),
);
return $form;
}