comparison dnd.module @ 4:c2eb995212bf

TONS of fixes in this commit.
author David Eads <eads@chicagotech.org>
date Thu, 19 Feb 2009 12:33:19 -0600
parents 5df0783706f7
children ea5d7834d0dc
comparison
equal deleted inserted replaced
3:5df0783706f7 4:c2eb995212bf
75 * callback should be smart about attachment and detachment 75 * callback should be smart about attachment and detachment
76 */ 76 */
77 function dnd_process_textarea($element, $form_state) { 77 function dnd_process_textarea($element, $form_state) {
78 if ($element['#dnd-enabled']) { 78 if ($element['#dnd-enabled']) {
79 79
80 drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd.js'); 80 drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd.js', 'footer');
81 drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd-library.js'); 81 drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd-library.js', 'footer');
82 82
83 $settings = array(); 83 $settings = array();
84 84
85 // We take a string or an 85 // We take a string or an
86 if (is_string($element['#dnd-settings'])) { 86 if (is_string($element['#dnd-settings'])) {
124 $request = drupal_http_request($settings['url']); 124 $request = drupal_http_request($settings['url']);
125 125
126 // We must remove some Drupal escaping 126 // We must remove some Drupal escaping
127 $json = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $request->data), TRUE); 127 $json = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $request->data), TRUE);
128 128
129 foreach ($json['library'] as $id=>$item) { 129 // Generate an array of editor representations to add
130 $editor_representations[$id] = filter_xss_admin($item['editor']); 130 foreach ($json['editor_representations'] as $editor_id=>$editor_item) {
131 $library_representations[$id] = filter_xss_admin($item['library']); 131 $editor_representations[$editor_id] = filter_xss_admin($editor_item);
132 } 132 }
133 133
134 // Store editor representations in Drupal setting
135 drupal_add_js(array('dndEditorRepresentations' => $editor_representations,), 'setting');
136
134 $variables['library_id'] = $settings['library_id']; 137 $variables['library_id'] = $settings['library_id'];
135 $variables['header'] = filter_xss_admin($json['header']); 138 $variables['header'] = filter_xss_admin($json['header']);
136 $variables['items'] = $library_representations; 139 $variables['library'] = filter_xss_admin($json['library']);
137 $variables['footer'] = filter_xss_admin($json['footer']); 140 $variables['footer'] = filter_xss_admin($json['footer']);
138
139 // Store editor representations in Drupal setting
140 drupal_add_js(array(
141 'dndEditorRepresentations' => $editor_representations,
142 ), 'setting');
143 } 141 }