function workflow_admin_ui_workflow_operations in Workflow 7
Implements hook_workflow_operations(). Might as well eat our own cooking.
File
- workflow_admin_ui/
workflow_admin_ui.module, line 168 - 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_workflow_operations($op, $workflow = NULL, $state = NULL) {
switch ($op) {
case 'top_actions':
// Build a link to each workflow.
$alt = t('Add a new workflow');
$actions = array(
'add-workflow' => array(
'title' => t('Add workflow'),
// @TODO: It might be more sane to go to the "settings" page.
'href' => 'admin/config/workflow/workflow/add',
'attributes' => array(
'alt' => $alt,
'title' => $alt,
),
),
);
foreach (Workflow::getWorkflows() as $workflow) {
$name = $workflow
->getName();
$wid = $workflow->wid;
$alt = t('Work with @wf', array(
'@wf' => $name,
));
$actions[drupal_html_class($name)] = array(
'title' => $workflow
->label(),
'href' => "admin/config/workflow/workflow/{$wid}",
'attributes' => array(
'alt' => $alt,
'title' => $alt,
),
);
}
return $actions;
case 'workflow':
$name = $workflow
->getName();
$wid = $workflow->wid;
$actions = array(
'workflow_settings' => array(
'title' => t('Settings'),
'href' => "admin/config/workflow/workflow/edit/{$wid}",
'attributes' => array(
'alt' => t('Edit the @wf settings', array(
'@wf' => $name,
)),
),
),
'workflow_transitions' => array(
'title' => t('Transitions'),
'href' => "admin/config/workflow/workflow/transitions/{$wid}",
'attributes' => array(
'alt' => t('Edit the @wf transitions', array(
'@wf' => $name,
)),
),
),
'workflow_permission_summary' => array(
'title' => t('Summary'),
'href' => "admin/config/workflow/workflow/perm_summary/{$wid}",
'attributes' => array(
'alt' => t('See a summary of the @wf transitions', array(
'@wf' => $name,
)),
),
),
'workflow_overview_delete' => array(
'title' => t('Delete'),
'href' => "admin/config/workflow/workflow/delete/{$wid}",
'attributes' => array(
'alt' => t('Delete the @wf workflow', array(
'@wf' => $name,
)),
),
),
);
foreach ($actions as $name => $link) {
$actions[$name]['attributes']['title'] = $actions[$name]['attributes']['alt'];
}
return $actions;
}
}