Mercurial > defr > drupal > popups_reference
comparison popups_reference.module @ 10:108ced764a40 tip
Fix compatibility with CCK Multigroup
author | Franck Deroche <franck@defr.org> |
---|---|
date | Thu, 26 Mar 2009 14:59:27 +0100 |
parents | 571a89603e2b |
children |
comparison
equal
deleted
inserted
replaced
9:8ced981c0dc0 | 10:108ced764a40 |
---|---|
26 } | 26 } |
27 elseif (isset($form['type'])) { | 27 elseif (isset($form['type'])) { |
28 // Add the "Add New: Node Type" links. | 28 // Add the "Add New: Node Type" links. |
29 $node = $form['#node']; | 29 $node = $form['#node']; |
30 if ($form['type']['#value'] .'_node_form' == $form_id) { | 30 if ($form['type']['#value'] .'_node_form' == $form_id) { |
31 $fields = content_fields(); | 31 $form['#after_build'][] = 'popups_reference_after'; |
32 foreach ($form as $key => $item) { | 32 } |
33 if (is_array($item)) { | 33 } |
34 $type = $item['#type']; | 34 } |
35 if ($type == 'fieldset') { // Loop through all the subitems. | 35 |
36 foreach ($form[$key] as $subkey => $subitem) { | 36 function popups_reference_after($form, &$form_state) { |
37 popups_reference_alter_item($form[$key], $subkey, $subitem, $fields); | 37 $fields = content_fields(); |
38 } | 38 foreach ($form as $key => $item) { |
39 } | 39 if (element_child($key) && is_array($item)) { |
40 else { | 40 $type = $item['#type']; |
41 popups_reference_alter_item($form, $key, $item, $fields); | 41 if ($type == 'fieldset' || is_numeric($key)) { // Loop through all the subitems. |
42 } | 42 $form[$key] = popups_reference_after($form[$key], $form_state); |
43 } | 43 } |
44 | 44 else { |
45 popups_reference_alter_item($form, $key, $item, $fields); | |
45 } | 46 } |
46 } | 47 } |
47 } | 48 } |
49 return $form; | |
48 } | 50 } |
49 | 51 |
50 /** | 52 /** |
51 * Implementation of hook_nodeapi(). | 53 * Implementation of hook_nodeapi(). |
52 * Add cookies with node info when a new node is created. | 54 * Add cookies with node info when a new node is created. |
91 $wrapper_id = 'popups-reference-' . _popups_reference_counter(); | 93 $wrapper_id = 'popups-reference-' . _popups_reference_counter(); |
92 $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); | 94 $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); |
93 if ($links) { | 95 if ($links) { |
94 // Put the nodereference widget and links in an wrapper. | 96 // Put the nodereference widget and links in an wrapper. |
95 // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. | 97 // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. |
96 $form[$key]['#popups_reference_prefix'] = '<div id="'. $wrapper_id .'">'; | 98 $form[$key]['#prefix'] = '<div id="'. $wrapper_id .'">' . $form[$key]['#prefix']; |
97 $form[$key]['#popups_reference_suffix'] = '<div>Add New: ' . implode(', ', $links) .'</div></div>'; | 99 $form[$key]['#suffix'] = $form[$key]['#suffix'] . '<div>Add New: ' . implode(', ', $links) .'</div></div>'; |
98 $form[$key]['#after_build'][] = 'popups_reference_after_build'; | |
99 } | 100 } |
100 } | 101 } |
101 } | 102 } |
102 | 103 |
103 function popups_reference_after_build($form_element) { | 104 function popups_reference_after_build($form_element) { |