node_edit.inc File Reference

(1.1.2.7 2008/06/03 13:18:07 pancho)

Go to the source code of this file.

Functions

 panels_node_edit_choose_display ($conf, $context)
 panels_node_edit_context ($arg=NULL, $conf=NULL, $empty=FALSE)
 panels_node_edit_displays ($conf, $id)
 panels_node_edit_panels_arguments ()
 panels_node_edit_settings_form ($conf)
 panels_node_edit_settings_form_submit (&$values)


Function Documentation

panels_node_edit_choose_display ( conf,
context 
)

Based upon the settings and the context, choose which display to use.

Definition at line 145 of file node_edit.inc.

00145                                                           {
00146   if (empty($context->form)) {
00147     return;
00148   }
00149 
00150   if (!empty($conf['displays'][$context->node_type])) {
00151     return $context->node_type;
00152   }
00153 
00154   // Please note that 'default' is a special display.
00155   if (!empty($conf['own_default'])) {
00156     return 'default';
00157   }
00158 
00159   // Empty return says to use the default display.
00160   return;
00161 }

panels_node_edit_context ( arg = NULL,
conf = NULL,
empty = FALSE 
)

Discover if this argument gives us the node we crave.

Definition at line 28 of file node_edit.inc.

References panels_context_create(), and panels_context_create_empty().

00028                                                                              {
00029   // If unset it wants a generic, unfilled context.
00030   if ($empty) {
00031     return panels_context_create_empty('node_edit_form');
00032   }
00033 
00034   if (!is_numeric($arg)) {
00035     return FALSE;
00036   }
00037 
00038   $node = node_load($arg);
00039   if (!$node) {
00040     return FALSE;
00041   }
00042 
00043   if (array_filter($conf['types']) && empty($conf['types'][$node->type])) {
00044     return FALSE;
00045   }
00046 
00047   // This will perform a node_access check, so we don't have to.
00048   return panels_context_create('node_edit_form', $node);
00049 }

Here is the call graph for this function:

panels_node_edit_displays ( conf,
id 
)

What additional displays does this argument provide?

Definition at line 115 of file node_edit.inc.

00115                                                {
00116   $displays = array();
00117   if (!empty($conf['own_default'])) {
00118     $displays['default'] = array(
00119       'title' => t('Node edit form @id Default', array('@id' => $id)),
00120       'context' => 'node',
00121     );
00122   }
00123 
00124   if (is_array($conf['displays'])) {
00125     $options = array();
00126     foreach (node_get_types() as $type => $info) {
00127       $options[$type] = $info->name;
00128     }
00129     foreach (array_keys(array_filter($conf['displays'])) as $type) {
00130       $displays[$type] = array(
00131         'title' => t('Node edit form @id @type', array('@id' => $id, '@type' => $options[$type])),
00132         // Tell it to base the template for this display off of the default.
00133         'default' => 'default',
00134         'context' => 'node',
00135       );
00136     }
00137   }
00138 
00139   return $displays;
00140 }

panels_node_edit_panels_arguments (  ) 

Definition at line 10 of file node_edit.inc.

00010                                              {
00011   $args['node_edit'] = array(
00012     'title' => t("Node edit form"),
00013     // keyword to use for %substitution
00014     'keyword' => 'node',
00015     'description' => t('Displays the node edit form for a node.'),
00016     'context' => 'panels_node_edit_context',
00017     'settings form' => 'panels_node_edit_settings_form',
00018     'settings form submit' => 'panels_node_edit_settings_form_submit',
00019     'displays' => 'panels_node_edit_displays',
00020     'choose display' => 'panels_node_edit_choose_display',
00021   );
00022   return $args;
00023 }

panels_node_edit_settings_form ( conf  ) 

Settings form for the argument

Definition at line 54 of file node_edit.inc.

00054                                                {
00055   $options = array();
00056   foreach (node_get_types() as $type => $info) {
00057     $options[$type] = $info->name;
00058   }
00059   $form['types'] = array(
00060     '#title' => t('Node types'),
00061     '#type' => 'checkboxes',
00062     '#options' => $options,
00063     '#description' => t('You can restrict this argument to use the checked node types. Arguments from non-conforming node types will be ignored, and Panels will behave as if no argument were given. Leave all unchecked to impose no restriction.'),
00064     '#default_value' => $conf['types'],
00065     '#prefix' => '<div class="clear-block">',
00066     '#suffix' => '</div>',
00067   );
00068 
00069   $form['own_default'] = array(
00070     '#title' => t('Use different default display'),
00071     '#type' => 'checkbox',
00072     '#description' => t('If checked, when this argument is present it will use its own display rather than the default. Node types not selected in the "Own display" field will use this one.'),
00073     '#default_value' => $conf['own_default'],
00074   );
00075 
00076   $form['displays'] = array(
00077     '#title' => t('Own display'),
00078     '#type' => 'checkboxes',
00079     '#options' => $options,
00080     '#default_value' => $conf['displays'],
00081     '#description' => t('Each checked node type will get its own special display to layout its content. Only node types set above should be set here. Node types not set here will use the default display.'),
00082     '#prefix' => '<div class="clear-block">',
00083     '#suffix' => '</div>',
00084   );
00085 
00086   return $form;
00087 }

panels_node_edit_settings_form_submit ( &$  values  ) 

There appears to be a bit of a bug with the way we're handling forms; it causes 'checkboxes' to get invalid values added to them when empty. This takes care of that.

Definition at line 94 of file node_edit.inc.

00094                                                          {
00095   $types = node_get_types();
00096   if (!empty($values['types'])) {
00097     foreach ($values['types'] as $type => $value) {
00098       if (empty($types[$type])) {
00099         unset($values['types'][$type]);
00100       }
00101     }
00102   }
00103   if (!empty($values['displays'])) {
00104     foreach ($values['displays'] as $type => $value) {
00105       if (empty($types[$type])) {
00106         unset($values['displays'][$type]);
00107       }
00108     }
00109   }
00110 }


Generated on Thu Jul 29 05:00:15 2010 for Panels 2 by  doxygen 1.5.6