You are here

function emailpanels_contactemail in Panels Extras 6

Entry point for our overridden cck email generated contact form page.

This function asks its assigned handlers who, if anyone, would like to run with it. If no one does, it passes through to CCK email field, which is email_mail_page().

1 string reference to 'emailpanels_contactemail'
emailpanels_contactemail_menu_alter in emailpanels/plugins/tasks/contactemail.inc
Callback defined by emailpanels_contactemail_page_manager_tasks().

File

emailpanels/plugins/tasks/contactemail.inc, line 72
Provides additional page manager tasks CCK Email Contact form for panels use

Code

function emailpanels_contactemail($nid, $field_name) {

  // Load my task plugin
  $task = page_manager_get_task('contactemail');
  ctools_include('context');
  ctools_include('context-task-handler');

  // @todo add ability to accept the node and field name context; well maybe just the node context
  // Load the node into a context.
  $contexts = ctools_context_handler_get_task_contexts($task, '', array(
    $nid,
  ));
  $output = ctools_context_handler_render($task, '', $contexts, array(
    'nid' => $nid,
    'field_name' => $field_name,
  ));
  if ($output !== FALSE) {
    return $output;
  }

  // fallback to the default email contact form page handler
  // assume the cck email module is on.
  $function = 'email_mail_page';
  foreach (module_implements('page_manager_override') as $module) {
    $call = $module . '_page_manager_override';
    if (($rc = $call('contactemail')) && function_exists($rc)) {
      $function = $rc;
      break;
    }
  }

  // Otherwise, fall back.
  return $function($nid, $field_name);
}