node_edit_form.inc File Reference

(1.1.2.8 2008/07/29 10:34:25 sdboyer)


Detailed Description

Plugin to provide a node_edit_form context

Definition in file node_edit_form.inc.

Go to the source code of this file.

Functions

 panels_context_create_node_edit_form ($empty, $node=NULL, $conf=FALSE)
 panels_context_node_edit_form_settings_form ($conf, $external=FALSE)
 panels_context_node_edit_form_settings_form_validate ($form, $form_values)
 panels_node_edit_form_panels_contexts ()


Function Documentation

panels_context_create_node_edit_form ( empty,
node = NULL,
conf = FALSE 
)

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

Definition at line 28 of file node_edit_form.inc.

00028                                                                                    {
00029   $context = new panels_context(array('form', 'node_edit', 'node_form', 'node'));
00030   $context->plugin = 'node_edit_form';
00031 
00032   if ($empty) {
00033     return $context;
00034   }
00035 
00036   if ($conf) {
00037     // In this case, $node is actually our $conf array.
00038     $node = node_load($node['nid']);
00039   }
00040 
00041   if (!empty($node) && node_access('update', $node)) {
00042     // This is from node_edit_page cause Drupal still doesn't use fapi right.
00043     if ($_POST['op'] == t('Delete')) {
00044       // Note: we redirect from node/nid/edit to node/nid/delete to make the tabs disappear.
00045       if ($_REQUEST['destination']) {
00046         $destination = drupal_get_destination();
00047         unset($_REQUEST['destination']);
00048       }
00049       drupal_goto('node/'. $node->nid .'/delete', $destination);
00050     }
00051 
00052     $form = drupal_retrieve_form($node->type . '_node_form', $node);
00053     drupal_process_form($node->type . '_node_form', $form);
00054     // Fill in the 'node' portion of the context
00055     $context->data     = $node;
00056     $context->title    = $node->title;
00057     $context->argument = $node->nid;
00058 
00059     $context->form       = $form;
00060     $context->form_id    = $node->type . '_node_form';
00061     $context->form_title = $node->title;
00062     $context->node_type  = $node->type;
00063     return $context;
00064   }
00065 }

panels_context_node_edit_form_settings_form ( conf,
external = FALSE 
)

Definition at line 67 of file node_edit_form.inc.

00067                                                                                {
00068   if ($external) {
00069     $form['external'] = array(
00070       '#type' => 'checkbox',
00071       '#default_value' => $conf['external'],
00072       '#title' => t('Require this context from an external source (such as a containing panel page).'),
00073       '#description' => t('If selected, node selection (below) will be ignored.'),
00074     );
00075   }
00076 
00077   $form['node'] = array(
00078     '#prefix' => '<div class="no-float">',
00079     '#suffix' => '</div>',
00080     '#title' => t('Enter the title or NID of a post'),
00081     '#type' => 'textfield',
00082     '#maxlength' => 512,
00083     '#autocomplete_path' => 'panels/node/autocomplete',
00084     '#weight' => -10,
00085   );
00086 
00087   if (!empty($conf['nid'])) {
00088     $info = db_fetch_object(db_query("SELECT * FROM {node} WHERE nid = %d", $conf['nid']));
00089     if ($info) {
00090       $link = l("'$info->title' [node id: $info->nid]", "node/$info->nid", array('target' => '_blank', 'title' => t('Open in new window')));
00091       $form['node']['#description'] = t('Currently set to !link', array('!link' => $link));
00092     }
00093   }
00094 
00095   $form['nid'] = array(
00096     '#type' => 'value',
00097     '#value' => $conf['nid'],
00098   );
00099 
00100   $form['external'] = array(
00101     '#type' => 'value',
00102     '#value' => $external,
00103   );
00104 
00105   return $form;
00106 }

panels_context_node_edit_form_settings_form_validate ( form,
form_values 
)

Validate a node.

Definition at line 111 of file node_edit_form.inc.

References panels_nid_autocomplete().

00111                                                                                    {
00112   if (empty($form_values['external']) && empty($form_values['nid']) && empty($form_values['node'])) {
00113     form_error($form['node'], t('You must select a node.'));
00114     return;
00115   }
00116 
00117   if (empty($form_values['node'])) {
00118     return;
00119   }
00120 
00121   if ($nid = panels_nid_autocomplete($form_values['node'])) {
00122     form_set_value($form['nid'], $nid);
00123   }
00124   else {
00125     form_error($form['node'], t('Invalid node selected.'));
00126   }
00127 }

Here is the call graph for this function:

panels_node_edit_form_panels_contexts (  ) 

Definition at line 11 of file node_edit_form.inc.

00011                                                  {
00012   $args['node_edit_form'] = array(
00013     'title' => t("Node edit form"),
00014     'description' => t('A node edit form.'),
00015     'context' => 'panels_context_create_node_edit_form',
00016     'settings form' => 'panels_context_node_edit_form_settings_form',
00017     'settings form validate' => 'panels_context_node_edit_form_settings_form_validate',
00018     'keyword' => 'node_edit',
00019     'context name' => 'node_edit_form',
00020   );
00021   return $args;
00022 }


Generated on Sun Feb 5 05:00:16 2012 for Panels 2 by  doxygen 1.5.6