function _page_manager_get_operation_content
Fetch the content for an operation, after it's been discovered from arguments.
This system runs through the CTools form wizard. Each operation specifies a form or set of forms that it may use. Operations may also specify wrappers and can set their own next/finish handlers so that they can make additional things happen at the end.
1 call to _page_manager_get_operation_content()
- page_manager_get_operation_content in page_manager/
page_manager.admin.inc - Fetch the content for an operation.
File
-
page_manager/
page_manager.admin.inc, line 854
Code
function _page_manager_get_operation_content($js, &$page, $active, $operation, $titles = array(), $args = array()) {
if (isset($operation['form'])) {
$form_info = array(
'id' => 'page_manager_page',
'finish text' => t('Update'),
'show trail' => FALSE,
'show back' => FALSE,
'show return' => FALSE,
'show cancel' => FALSE,
'next callback' => 'page_manager_edit_page_next',
'finish callback' => 'page_manager_edit_page_finish',
// Items specific to the 'edit' routines that will get moved over:
'path' => page_manager_edit_url($page->task_name, $active) . "/%step",
// wrapper function to add an extra finish button.
'wrapper' => 'page_manager_operation_wrapper',
);
// If $operation['form'] is simply a string, then it is the function
// name of the form.
if (!is_array($operation['form'])) {
$form_info['order'] = array(
'form' => $operation['title'],
);
$form_info['forms'] = array(
'form' => array(
'form id' => $operation['form'],
),
);
if (isset($operation['wrapper'])) {
$form_info['forms']['form']['wrapper'] = $operation['wrapper'];
}
}
else {
$form_info['order'] = $operation['form']['order'];
$form_info['forms'] = $operation['form']['forms'];
}
// Allow the operation to override any form info settings:
if (isset($operation['form info'])) {
foreach ($operation['form info'] as $key => $setting) {
$form_info[$key] = $setting;
}
}
if (!empty($page->subtask['operations include'])) {
// Quickly load any files necessary to display the forms.
$page->subtask['operations include']['function'] = 'nop';
ctools_plugin_get_function($page->subtask, 'operations include');
}
$step = array_shift($args);
// If step is unset, go with the basic step.
if (!isset($step)) {
$step = current(array_keys($form_info['order']));
}
// If it is locked, hide the buttonzzz!
if ($page->locked && empty($operation['even locked'])) {
$form_info['no buttons'] = TRUE;
}
ctools_include('wizard');
$form_state = array(
'page' => $page,
'type' => 'edit',
'ajax' => $js && (!isset($operation['ajax']) || !empty($operation['ajax'])),
'rerender' => TRUE,
'trail' => $active,
'task_name' => $page->task_name,
'task_id' => $page->task_id,
'task' => $page->task,
'subtask_id' => $page->subtask_id,
'subtask' => $page->subtask,
'operation' => $operation,
);
if ($active && $active[0] == 'handlers' && isset($form_state['page']->handlers[$form_state['trail'][1]])) {
$form_state['handler_id'] = $form_state['trail'][1];
$form_state['handler'] =& $form_state['page']->handlers[$form_state['handler_id']];
}
if ($active && $active[0] == 'actions' && $active[1] == 'configure' && isset($form_state['page']->new_handler)) {
$form_state['handler_id'] = $form_state['page']->new_handler->name;
$form_state['handler'] =& $form_state['page']->new_handler;
}
$built_form = ctools_wizard_multistep_form($form_info, $step, $form_state);
$output = drupal_render($built_form);
$title = empty($form_state['title']) ? $operation['title'] : $form_state['title'];
$titles[] = $title;
$title = implode(' » ', array_filter($titles));
// If there are messages for the form, render them.
if ($messages = theme('status_messages')) {
$output = $messages . $output;
}
$description = isset($operation['admin description']) ? $operation['admin description'] : (isset($operation['description']) ? $operation['description'] : '');
$return = array(
'title' => $title,
'content' => $output,
'description' => $description,
);
// Append any extra content, used for the preview which is submitted then
// rendered.
if (isset($form_state['content'])) {
$return['content'] .= $form_state['content'];
}
// If the form wanted us to go somewhere else next, pass that along.
if (isset($form_state['new trail'])) {
$return['new trail'] = $form_state['new trail'];
}
}
else {
$return = array(
'title' => t('Error'),
'content' => t('This operation trail does not exist.'),
);
}
$return['active'] = $active;
return $return;
}