function page_manager_get_handler_operations in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 page_manager/page_manager.admin.inc \page_manager_get_handler_operations()
Collect all the operations related to task handlers (variants) and build a menu.
1 call to page_manager_get_handler_operations()
- page_manager_get_operations in page_manager/
page_manager.admin.inc - Take the operations array from a task and expand it.
File
- page_manager/
page_manager.admin.inc, line 638 - Administrative functions for the page manager.
Code
function page_manager_get_handler_operations(&$page) {
ctools_include('export');
$group = array(
'type' => 'group',
'class' => 'operations-handlers',
'title' => t('Variants'),
);
$operations = array();
// If there is only one variant, let's not have it collapsible.
$collapsible = count($page->handler_info) != 1;
foreach ($page->handler_info as $id => $info) {
if ($info['changed'] & PAGE_MANAGER_CHANGED_DELETED) {
continue;
}
$handler = $page->handlers[$id];
$plugin = page_manager_get_task_handler($handler->handler);
$operations[$id] = array(
'type' => 'group',
'class' => 'operations-handlers-' . $id,
'title' => page_manager_get_handler_title($plugin, $handler, $page->task, $page->subtask_id),
'collapsible' => $collapsible,
'children' => array(),
);
$operations[$id]['children']['actions'] = array(
'type' => 'group',
'class' => 'operations-handlers-actions-' . $id,
'title' => t('Variant operations'),
'children' => array(),
'location' => $id,
);
// There needs to be a 'summary' item here for variants.
$operations[$id]['children']['summary'] = array(
'title' => t('Summary'),
'description' => t('Get a summary of the information about this variant.'),
'form info' => array(
'no buttons' => TRUE,
),
'form' => 'page_manager_handler_summary',
);
if ($plugin && isset($plugin['operations'])) {
$operations[$id]['children'] += $plugin['operations'];
}
$actions =& $operations[$id]['children']['actions']['children'];
$actions['clone'] = array(
'title' => t('Clone'),
'description' => t('Make an exact copy of this variant.'),
'form' => 'page_manager_handler_clone',
);
$actions['export'] = array(
'title' => t('Export'),
'description' => t('Export this variant into code to import into another page.'),
'form' => 'page_manager_handler_export',
);
if ($handler->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
$actions['delete'] = array(
'title' => t('Revert'),
'description' => t('Remove all changes to this variant and revert to the version in code.'),
'form' => 'page_manager_handler_delete',
'no update and save' => TRUE,
'form info' => array(
'finish text' => t('Revert'),
),
);
}
else {
if ($handler->export_type != EXPORT_IN_CODE) {
$actions['delete'] = array(
'title' => t('Delete'),
'description' => t('Remove this variant from the page completely.'),
'form' => 'page_manager_handler_delete',
'form info' => array(
'finish text' => t('Delete'),
'save text' => t('Delete and save'),
),
);
}
}
if (!empty($handler->disabled)) {
$actions['enable'] = array(
'title' => t('Enable'),
'description' => t('Activate this variant so that it will be in use in your system.'),
'form' => 'page_manager_handler_enable',
'silent' => TRUE,
'form info' => array(
'finish text' => t('Enable'),
'save text' => t('Enable and save'),
),
);
}
else {
$actions['disable'] = array(
'title' => t('Disable'),
'description' => t('De-activate this variant. The data will remain but the variant will not be in use on your system.'),
'form' => 'page_manager_handler_disable',
'silent' => TRUE,
'form info' => array(
'finish text' => t('Disable'),
'save text' => t('Disable and save'),
),
);
}
drupal_alter('page_manager_variant_operations', $operations[$id], $handler);
}
if (empty($operations)) {
$operations['empty'] = array(
'type' => 'text',
'title' => t('No variants'),
);
}
$group['children'] = $operations;
return $group;
}