Go to the source code of this file.
Functions | |
| panels_node_add_choose_display ($conf, $context) | |
| panels_node_add_context ($arg=NULL, $conf=NULL, $empty=FALSE) | |
| panels_node_add_displays ($conf, $id) | |
| panels_node_add_panels_arguments () | |
| panels_node_add_settings_form ($conf) | |
| panels_node_add_settings_form_submit (&$values) | |
| panels_node_add_choose_display | ( | $ | conf, | |
| $ | context | |||
| ) |
Based upon the settings and the context, choose which display to use.
Definition at line 105 of file node_add.inc.
00105 { 00106 if (empty($context->form)) { 00107 return; 00108 } 00109 00110 if (!empty($conf['displays'][$context->node_type])) { 00111 return $context->node_type; 00112 } 00113 00114 // Please note that 'default' is a special display. 00115 if (!empty($conf['own_default'])) { 00116 return 'default'; 00117 } 00118 00119 // Empty return says to use the default display. 00120 return; 00121 }
| panels_node_add_context | ( | $ | arg = NULL, |
|
| $ | conf = NULL, |
|||
| $ | empty = FALSE | |||
| ) |
Discover if this argument gives us the node we crave.
Definition at line 28 of file node_add.inc.
References panels_context_create(), and panels_context_create_empty().
00028 { 00029 // If unset it wants a generic, unfilled context. 00030 if (!isset($arg)) { 00031 return panels_context_create_empty('node_add_form'); 00032 } 00033 00034 if (array_filter($conf['types']) && empty($conf['types'][$arg])) { 00035 return FALSE; 00036 } 00037 00038 return panels_context_create('node_add_form', $arg); 00039 }
| panels_node_add_displays | ( | $ | conf, | |
| $ | id | |||
| ) |
What additional displays does this argument provide?
Definition at line 126 of file node_add.inc.
00126 { 00127 $displays = array(); 00128 if (!empty($conf['own_default'])) { 00129 $displays['default'] = array( 00130 'title' => t('Node add form @id Default', array('@id' => $id)), 00131 'context' => 'node', 00132 ); 00133 } 00134 00135 if (is_array($conf['displays'])) { 00136 $options = array(); 00137 foreach (node_get_types() as $type => $info) { 00138 $options[$type] = $info->name; 00139 } 00140 foreach (array_keys(array_filter($conf['displays'])) as $type) { 00141 if (!empty($options[$type])) { 00142 $displays[$type] = array( 00143 'title' => t('Node add form @id @type', array('@id' => $id, '@type' => $options[$type])), 00144 // Tell it to base the template for this display off of the default. 00145 'default' => 'default', 00146 'context' => 'node', 00147 ); 00148 } 00149 } 00150 } 00151 00152 return $displays; 00153 }
| panels_node_add_panels_arguments | ( | ) |
Definition at line 10 of file node_add.inc.
00010 { 00011 $args['node_add'] = array( 00012 'title' => t("Node add form"), 00013 // keyword to use for %substitution 00014 'keyword' => 'node_type', 00015 'description' => t('Displays the node add form for a content type.'), 00016 'context' => 'panels_node_add_context', 00017 'settings form' => 'panels_node_add_settings_form', 00018 'settings form submit' => 'panels_node_add_settings_form_submit', 00019 'displays' => 'panels_node_add_displays', 00020 'choose display' => 'panels_node_add_choose_display', 00021 ); 00022 return $args; 00023 }
| panels_node_add_settings_form | ( | $ | conf | ) |
Settings form for the argument
Definition at line 44 of file node_add.inc.
00044 { 00045 $options = array(); 00046 foreach (node_get_types() as $type => $info) { 00047 $options[$type] = $info->name; 00048 } 00049 $form['types'] = array( 00050 '#title' => t('Node types'), 00051 '#type' => 'checkboxes', 00052 '#options' => $options, 00053 '#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.'), 00054 '#default_value' => $conf['types'], 00055 '#prefix' => '<div class="clear-block">', 00056 '#suffix' => '</div>', 00057 ); 00058 00059 $form['own_default'] = array( 00060 '#title' => t('Use different default display'), 00061 '#type' => 'checkbox', 00062 '#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.'), 00063 '#default_value' => $conf['own_default'], 00064 ); 00065 00066 $form['displays'] = array( 00067 '#title' => t('Own display'), 00068 '#type' => 'checkboxes', 00069 '#options' => $options, 00070 '#default_value' => $conf['displays'], 00071 '#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.'), 00072 '#prefix' => '<div class="clear-block">', 00073 '#suffix' => '</div>', 00074 ); 00075 00076 return $form; 00077 }
| panels_node_add_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 84 of file node_add.inc.
00084 { 00085 $types = node_get_types(); 00086 if (!empty($values['types'])) { 00087 foreach ($values['types'] as $type => $value) { 00088 if (empty($types[$type])) { 00089 unset($values['types'][$type]); 00090 } 00091 } 00092 } 00093 if (!empty($values['displays'])) { 00094 foreach ($values['displays'] as $type => $value) { 00095 if (empty($types[$type])) { 00096 unset($values['displays'][$type]); 00097 } 00098 } 00099 } 00100 }
1.5.6