Mercurial > defr > drupal > popups_reference
comparison popups_reference.module @ 9:8ced981c0dc0
Merge de la 1.0
| author | Franck Deroche <franck@defr.org> |
|---|---|
| date | Mon, 23 Mar 2009 12:44:22 +0100 |
| parents | 571a89603e2b |
| children | 108ced764a40 |
comparison
equal
deleted
inserted
replaced
| 8:ab667e3dc8ba | 9:8ced981c0dc0 |
|---|---|
| 91 $wrapper_id = 'popups-reference-' . _popups_reference_counter(); | 91 $wrapper_id = 'popups-reference-' . _popups_reference_counter(); |
| 92 $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); | 92 $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']); |
| 93 if ($links) { | 93 if ($links) { |
| 94 // Put the nodereference widget and links in an wrapper. | 94 // Put the nodereference widget and links in an wrapper. |
| 95 // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. | 95 // Makes it easy to find for Ahah targeting, and popups_reference behavior selecting. |
| 96 $form[$key]['#prefix'] = '<div id="'. $wrapper_id .'">'; | 96 $form[$key]['#popups_reference_prefix'] = '<div id="'. $wrapper_id .'">'; |
| 97 $form[$key]['#suffix'] = '<div>Add New: ' . implode(', ', $links) .'</div></div>'; | 97 $form[$key]['#popups_reference_suffix'] = '<div>Add New: ' . implode(', ', $links) .'</div></div>'; |
| 98 $form[$key]['#after_build'][] = 'popups_reference_after_build'; | |
| 98 } | 99 } |
| 99 } | 100 } |
| 101 } | |
| 102 | |
| 103 function popups_reference_after_build($form_element) { | |
| 104 $form_element['#prefix'] = $form_element['#popups_reference_prefix'] . $form_element['#prefix']; | |
| 105 $form_element['#suffix'] .= $form_element['#popups_reference_suffix']; | |
| 106 return $form_element; | |
| 100 } | 107 } |
| 101 | 108 |
| 102 /** | 109 /** |
| 103 * Generates 'Add new...' link | 110 * Generates 'Add new...' link |
| 104 * for each allowed content type | 111 * for each allowed content type |
| 112 function _popups_reference_links($field, $src_type, $wrapper_id, $widget_type) { | 119 function _popups_reference_links($field, $src_type, $wrapper_id, $widget_type) { |
| 113 if ($widget_type == 'nodereference_select' || $widget_type == 'nodereference_buttons') { | 120 if ($widget_type == 'nodereference_select' || $widget_type == 'nodereference_buttons') { |
| 114 // Target the wrapper for replacing. | 121 // Target the wrapper for replacing. |
| 115 popups_add_popups(array('a.'.$wrapper_id=>array('targetSelectors'=>array('#'.$wrapper_id)))); | 122 popups_add_popups(array('a.'.$wrapper_id=>array('targetSelectors'=>array('#'.$wrapper_id)))); |
| 116 } | 123 } |
| 117 else if ($widget_type == 'nodereference_autocomplete') { | 124 else if ($widget_type == 'nodereference_autocomplete' || $widget_type == 'noderef_view_autocomplete') { |
| 118 // Don't replace the autocomplete when done. | 125 // Don't replace the autocomplete when done. |
| 119 popups_add_popups(array('a.'.$wrapper_id=>array('noUpdate'=>TRUE))); | 126 popups_add_popups(array('a.'.$wrapper_id=>array('noUpdate'=>TRUE))); |
| 120 } | 127 } |
| 121 else { // Unsupported type. | 128 else { // Unsupported type. |
| 122 return; | 129 return; |
