function ctools_context_create_node_add_form

cis7 node_add_form.inc ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE)
cle7 node_add_form.inc ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE)
elmsmedia7 node_add_form.inc ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE)
icor7 node_add_form.inc ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE)
meedjum_blog7 node_add_form.inc ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE)
mooc7 node_add_form.inc ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE)

It's important to remember that $conf is optional here, because contexts are not always created from the UI.

1 string reference to 'ctools_context_create_node_add_form'
node_add_form.inc in sites/all/modules/ulmus/ctools/plugins/contexts/node_add_form.inc
Plugin to provide a node_add_form context

File

sites/all/modules/ulmus/ctools/plugins/contexts/node_add_form.inc, line 33
Plugin to provide a node_add_form context

Code

function ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE) {
  static $creating = FALSE;
  $context = new ctools_context(array('form', 'node_add', 'node_form', 'node', 'entity:node'));
  $context->plugin = 'node_add_form';

  if ($empty || ($creating)) {
    return $context;
  }
  $creating = TRUE;

  if ($conf && (isset($data['types']) || isset($data['type']))) {
    // Holdover from typo'd config.
    $data = isset($data['types']) ? $data['types'] : $data['type'];
  }

  if (!empty($data)) {
    $types = node_type_get_types();
    $type = str_replace('-', '_', $data);

    // Validate the node type exists.
    if (isset($types[$type]) && node_access('create', $type)) {
      // Initialize settings:
      global $user;
      $node = (object) array(
        'uid' => $user->uid,
        'name' => (isset($user->name) ? $user->name : ''),
        'type' => $type,
        'language' => LANGUAGE_NONE,
      );

      $form_id = $type . '_node_form';

      $form_state = array(
        'want form' => TRUE,
        'build_info' => array(
          'args' => array($node),
        ),
      );

      // Use module_load_include so that caches and stuff can know to load this.
      form_load_include($form_state, 'inc', 'node', 'node.pages');

      $form = drupal_build_form($form_id, $form_state);

      // In a form, $data is the object being edited.
      $context->data = $node;
      $context->title = $types[$type]->name;
      $context->argument = $type;

      // These are specific pieces of data to this form.
      // All forms should place the form here.
      $context->form = $form;
      $context->form_id = $form_id;
      $context->form_title = t('Submit @name', array('@name' => $types[$type]->name));
      $context->node_type = $type;
      $context->restrictions['type'] = array($type);
      $context->restrictions['form'] = array('form');

      $creating = FALSE;
      return $context;
    }
  }
  $creating = FALSE;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.