View source
<?php
function page_manager_contact_site_page_manager_tasks() {
if (!module_exists('contact')) {
return;
}
return array(
'task type' => 'page',
'title' => t('Site contact page'),
'admin title' => t('Site contact page'),
'admin description' => t('When enabled, this overrides the default Drupal behavior for the site contact page at <em>/contact</em>. If no variant is selected, the default Drupal contact form will be used.'),
'admin path' => 'contact',
'hook menu alter' => 'page_manager_contact_site_menu_alter',
'handler type' => 'context',
'disabled' => variable_get('page_manager_contact_site_disabled', TRUE),
'enable callback' => 'page_manager_contact_site_enable',
'access callback' => 'page_manager_contact_access_check',
);
}
function page_manager_contact_site_menu_alter(&$items, $task) {
if (variable_get('page_manager_contact_site_disabled', TRUE)) {
return;
}
$callback = $items['contact']['page callback'];
if ($callback == 'drupal_get_form') {
$callback = $items['contact']['page arguments'][0];
}
if ($callback == 'contact_site_form' || variable_get('page_manager_override_anyway', FALSE)) {
$items['contact']['page callback'] = 'page_manager_contact_site';
$items['contact']['file path'] = $task['path'];
$items['contact']['file'] = $task['file'];
}
else {
variable_set('page_manager_contact_site_disabled', TRUE);
if (!empty($GLOBALS['page_manager_enabling_contact_site'])) {
drupal_set_message(t('Page manager module is unable to enable contact because some other module already has overridden with %callback.', array(
'%callback' => $callback,
)), 'warning');
}
return;
}
}
function page_manager_contact_site() {
$task = page_manager_get_task('contact_site');
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', 'contact', 'contact.pages');
$function = 'contact_site_form';
foreach (module_implements('page_manager_override') as $module) {
$call = $module . '_page_manager_override';
if (($rc = $call('contact_site')) && function_exists($rc)) {
$function = $rc;
break;
}
}
if ($function == 'contact_site_form') {
return drupal_get_form($function);
}
return $function();
}
function page_manager_contact_site_enable($cache, $status) {
variable_set('page_manager_contact_site_disabled', $status);
if (!$status) {
$GLOBALS['page_manager_enabling_contact_site'] = TRUE;
}
}
function page_manager_contact_access_check($task, $subtask_id, $contexts) {
return user_access('access site-wide contact form');
}