[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/ctools/page_manager/plugins/tasks/ -> contact_site.inc (source)

   1  <?php
   2  // $Id: contact_site.inc,v 1.1.2.2 2010/01/29 21:21:31 merlinofchaos Exp $
   3  
   4  /**
   5   * Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
   6   * more information.
   7   */
   8  function page_manager_contact_site_page_manager_tasks() {
   9    if (!module_exists('contact')) {
  10      return;
  11    }
  12  
  13    return array(
  14      // This is a 'page' task and will fall under the page admin UI
  15      'task type' => 'page',
  16  
  17      'title' => t('Site contact page'),
  18      'admin title' => t('Site contact page'),
  19      '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.'),
  20      'admin path' => 'contact',
  21  
  22      // Menu hooks so that we can alter the node/%node menu entry to point to us.
  23      'hook menu alter' => 'page_manager_contact_site_menu_alter',
  24  
  25      // This is task uses 'context' handlers and must implement these to give the
  26      // handler data it needs.
  27      'handler type' => 'context',
  28  
  29      // Allow this to be enabled or disabled:
  30      'disabled' => variable_get('page_manager_contact_site_disabled', TRUE),
  31      'enable callback' => 'page_manager_contact_site_enable',
  32    );
  33  }
  34  
  35  /**
  36   * Callback defined by page_manager_contact_site_page_manager_tasks().
  37   *
  38   * Alter the node edit input so that node edit comes to us rather than the
  39   * normal node edit process.
  40   */
  41  function page_manager_contact_site_menu_alter(&$items, $task) {
  42    if (variable_get('page_manager_contact_site_disabled', TRUE)) {
  43      return;
  44    }
  45  
  46    $callback = $items['contact']['page callback'];
  47    // Override the node edit handler for our purpose.
  48    if ($callback == 'contact_site_page' || variable_get('page_manager_override_anyway', FALSE)) {
  49      $items['contact']['page callback'] = 'page_manager_contact_site';
  50      $items['contact']['file path'] = $task['path'];
  51      $items['contact']['file'] = $task['file'];
  52    }
  53    else {
  54      variable_set('page_manager_contact_site_disabled', TRUE);
  55      if (!empty($GLOBALS['page_manager_enabling_contact_site'])) {
  56        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');
  57      }
  58      return;
  59    }
  60  
  61  }
  62  
  63  /**
  64   * Entry point for our overridden node edit.
  65   *
  66   * This function asks its assigned handlers who, if anyone, would like
  67   * to run with it. If no one does, it passes through to Drupal core's
  68   * node edit, which is node_page_edit().
  69   */
  70  function page_manager_contact_site() {
  71    // Load my task plugin
  72    $task = page_manager_get_task('contact_site');
  73  
  74    ctools_include('context');
  75    ctools_include('context-task-handler');
  76    $output = ctools_context_handler_render($task, '', array(), array());
  77    if ($output !== FALSE) {
  78      return $output;
  79    }
  80  
  81    module_load_include('inc', 'contact', 'contact.pages');
  82    $function = 'contact_site_page';
  83    foreach (module_implements('page_manager_override') as $module) {
  84      $call = $module . '_page_manager_override';
  85      if (($rc = $call('contact_site')) && function_exists($rc)) {
  86        $function = $rc;
  87        break;
  88      }
  89    }
  90  
  91    // Otherwise, fall back.
  92    return $function();
  93  }
  94  
  95  /**
  96   * Callback to enable/disable the page from the UI.
  97   */
  98  function page_manager_contact_site_enable($cache, $status) {
  99    variable_set('page_manager_contact_site_disabled', $status);
 100    // Set a global flag so that the menu routine knows it needs
 101    // to set a message if enabling cannot be done.
 102    if (!$status) {
 103      $GLOBALS['page_manager_enabling_contact_site'] = TRUE;
 104    }
 105  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7