View source
<?php
function page_manager_poll_page_manager_tasks() {
if (!module_exists('poll')) {
return;
}
return array(
'task type' => 'page',
'title' => t('All polls'),
'admin title' => t('All polls'),
'admin description' => t('When enabled, this overrides the default Drupal behavior for the polls at <em>/poll</em>. If no variant is selected, the default Drupal most recent polls will be shown.'),
'admin path' => 'poll',
'hook menu alter' => 'page_manager_poll_menu_alter',
'handler type' => 'context',
'disabled' => variable_get('page_manager_poll_disabled', TRUE),
'enable callback' => 'page_manager_poll_enable',
);
}
function page_manager_poll_menu_alter(&$items, $task) {
if (variable_get('page_manager_poll_disabled', TRUE)) {
return;
}
$callback = $items['poll']['page callback'];
if ($callback == 'poll_page' || variable_get('page_manager_override_anyway', FALSE)) {
$items['poll']['page callback'] = 'page_manager_poll';
$items['poll']['file path'] = $task['path'];
$items['poll']['file'] = $task['file'];
}
else {
variable_set('page_manager_poll_disabled', TRUE);
if (!empty($GLOBALS['page_manager_enabling_poll'])) {
drupal_set_message(t('Page manager module is unable to enable poll because some other module already has overridden with %callback.', array(
'%callback' => $callback,
)), 'warning');
}
return;
}
}
function page_manager_poll() {
$task = page_manager_get_task('poll');
ctools_include('context');
ctools_include('context-task-handler');
$output = ctools_context_handler_render($task, '', array(), array());
if ($output !== FALSE) {
return $output;
}
module_load_include('inc', 'poll', 'poll.pages');
$function = 'poll_page';
foreach (module_implements('page_manager_override') as $module) {
$call = $module . '_page_manager_override';
if (($rc = $call('poll')) && function_exists($rc)) {
$function = $rc;
break;
}
}
return $function();
}
function page_manager_poll_enable($cache, $status) {
variable_set('page_manager_poll_disabled', $status);
if (!$status) {
$GLOBALS['page_manager_enabling_poll'] = TRUE;
}
}