function workflow_admin_ui_type_map_form in Workflow 7
Same name and namespace in other branches
- 7.2 workflow_admin_ui/workflow_admin_ui.page.type_map.inc \workflow_admin_ui_type_map_form()
Form builder. Allow administrator to map workflows to content types and determine placement.
1 string reference to 'workflow_admin_ui_type_map_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 912 - 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_type_map_form($form) {
$form = array();
// Allow modules to insert their own action links.
$links = module_invoke_all('workflow_operations', 'top_actions', NULL);
$links_args = array(
'links' => $links,
'attributes' => array(
'class' => array(
'inline',
'action-links',
),
),
);
$form['action-links'] = array(
'#type' => 'markup',
'#markup' => theme('links', $links_args),
);
// Create list of all Workflow types. Include an initial empty value.
// Validate each workflow, and generate a message if not complete.
$workflows[0] = t('None');
foreach (Workflow::getWorkflows() as $workflow) {
if ($isValid = $workflow
->validate()) {
$workflows[$workflow->wid] = $workflow
->label();
}
}
if (count($workflows) == 1) {
drupal_set_message(t('You must create at least one workflow before content can be assigned to a workflow.'));
return $form;
}
$type_map = workflow_get_workflow_type_map();
$form['#tree'] = TRUE;
$form['help'] = array(
'#type' => 'item',
'#title' => '<h3>' . t('Content Type Mapping') . '</h3>',
'#markup' => t('Each content type may have a separate workflow. The form for changing workflow state can be ' . 'displayed when editing a node, editing a comment for a node, or both.'),
);
$placement_options = array(
'node' => t('Post'),
'comment' => t('Comment'),
);
foreach (node_type_get_names() as $type => $name) {
$form[$type]['workflow'] = array(
'#type' => 'select',
'#options' => $workflows,
'#default_value' => isset($type_map[$type]) ? $type_map[$type] : 0,
);
$form[$type]['placement'] = array(
'#type' => 'checkboxes',
'#options' => $placement_options,
'#default_value' => variable_get('workflow_' . $type, array()),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save workflow mapping'),
'#weight' => 100,
);
return $form;
}