node_add_form.inc
Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 function panels_node_add_form_panels_contexts() {
00012 $args['node_add_form'] = array(
00013 'title' => t("Node add form"),
00014 'description' => t('A node add form.'),
00015 'context' => 'panels_context_create_node_add_form',
00016 'settings form' => 'panels_context_node_add_form_settings_form',
00017 'keyword' => 'node_add',
00018 'context name' => 'node_add_form',
00019 );
00020 return $args;
00021 }
00022
00023
00024
00025
00026
00027 function panels_context_create_node_add_form($empty, $data = NULL, $conf = FALSE) {
00028 $context = new panels_context(array('form', 'node_add', 'node_form'));
00029 $context->plugin = 'node_add_form';
00030
00031 if ($empty) {
00032 return $context;
00033 }
00034
00035 if ($conf) {
00036 $data = $data['type'];
00037 }
00038
00039 if (!empty($data)) {
00040 $types = node_get_types();
00041 $type = str_replace('-', '_', $data);
00042
00043
00044 if (isset($types[$type]) && node_access('create', $type)) {
00045
00046 global $user;
00047 $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type);
00048
00049 $form = drupal_retrieve_form($type . '_node_form', $node);
00050 drupal_process_form($type . '_node_form', $form);
00051
00052 $context->data = $type;
00053 $context->title = $types[$type]->name;
00054 $context->argument = $type;
00055
00056
00057
00058 $context->form = $form;
00059 $context->form_id = $type . '_node_form';
00060 $context->form_title = t('Submit @name', array('@name' => $types[$type]->name));
00061 $context->node_type = $type;
00062 return $context;
00063 }
00064 }
00065 }
00066
00067 function panels_context_node_add_form_settings_form($conf, $external = FALSE) {
00068 if ($external) {
00069 $options[0] = t('External source');
00070 }
00071
00072 foreach (node_get_types() as $type => $info) {
00073 $options[$type] = $info->name;
00074 }
00075
00076 $form['type'] = array(
00077 '#title' => t('Node type'),
00078 '#type' => 'select',
00079 '#options' => $options,
00080 '#default_value' => $conf['type'],
00081 '#description' => t('Select the node type for this form.'),
00082 );
00083
00084 if ($external) {
00085 $form['type']['#description'] .= ' ' . t('Select external to require this from an external source (such as a containing panel page).');
00086 }
00087
00088 return $form;
00089 }
00090