Plugin to provide an argument handler for a Node add form
Plugin to provide an argument handler for a Node edit form
Definition in file nid.inc.
Go to the source code of this file.
Functions | |
| panels_nid_choose_display ($conf, $context) | |
| panels_nid_context ($arg=NULL, $conf=NULL, $empty=FALSE) | |
| panels_nid_displays ($conf, $id) | |
| panels_nid_panels_arguments () | |
| panels_nid_settings_form ($conf) | |
| panels_nid_settings_form_submit (&$values) | |
| panels_nid_choose_display | ( | $ | conf, | |
| $ | context | |||
| ) |
Based upon the settings and the context, choose which display to use.
Definition at line 145 of file nid.inc.
00145 { 00146 if (empty($context->data)) { 00147 return; 00148 } 00149 00150 if (!empty($conf['displays'][$context->data->type])) { 00151 return $context->data->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_nid_context | ( | $ | arg = NULL, |
|
| $ | conf = NULL, |
|||
| $ | empty = FALSE | |||
| ) |
Discover if this argument gives us the node we crave.
Definition at line 28 of file nid.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', $conf); 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 return panels_context_create('node', $node, $conf); 00048 }
| panels_nid_displays | ( | $ | conf, | |
| $ | id | |||
| ) |
What additional displays does this argument provide?
Definition at line 115 of file nid.inc.
00115 { 00116 $displays = array(); 00117 if (!empty($conf['own_default'])) { 00118 $displays['default'] = array( 00119 'title' => t('Node ID @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 ID @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_nid_panels_arguments | ( | ) |
Definition at line 10 of file nid.inc.
00010 { 00011 $args['nid'] = array( 00012 'title' => t("Node ID"), 00013 // keyword to use for %substitution 00014 'keyword' => 'node', 00015 'description' => t('Restricts the argument to a node id.'), 00016 'context' => 'panels_nid_context', 00017 'settings form' => 'panels_nid_settings_form', 00018 'settings form submit' => 'panels_nid_settings_form_submit', 00019 'displays' => 'panels_nid_displays', 00020 'choose display' => 'panels_nid_choose_display', 00021 ); 00022 return $args; 00023 }
| panels_nid_settings_form | ( | $ | conf | ) |
Settings form for the argument
Definition at line 53 of file nid.inc.
00053 { 00054 $options = array(); 00055 foreach (node_get_types() as $type => $info) { 00056 $options[$type] = $info->name; 00057 } 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_nid_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 nid.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 }
1.5.6