comparison dnd.module @ 7:e6378dbabe45

Added conditional logic to prevent choking on missing json data.
author David Eads <eads@chicagotech.org>
date Thu, 19 Feb 2009 14:10:13 -0500
parents ea5d7834d0dc
children b9cd179a30a8 a5b2b9fa2a1a
comparison
equal deleted inserted replaced
6:ea5d7834d0dc 7:e6378dbabe45
118 118
119 // Handle both relative and absolute urls 119 // Handle both relative and absolute urls
120 if (!isset($url['scheme'])) { 120 if (!isset($url['scheme'])) {
121 $settings['url'] = $base_url .'/'. $settings['url']; 121 $settings['url'] = $base_url .'/'. $settings['url'];
122 } 122 }
123 dpm($settings);
124 123
125 $request = drupal_http_request($settings['url']); 124 $request = drupal_http_request($settings['url']);
126 125
127 // We must remove some Drupal escaping 126 // We must remove some Drupal escaping
128 $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);
129 128
130 // Generate an array of editor representations to add 129 // Generate an array of editor representations to add
131 foreach ($json['editor_representations'] as $editor_id=>$editor_item) { 130 if (is_array($json['editor_representations'])) {
132 $editor_representations[$editor_id] = filter_xss_admin($editor_item); 131 foreach ($json['editor_representations'] as $editor_id=>$editor_item) {
132 $editor_representations[$editor_id] = filter_xss_admin($editor_item);
133 }
133 } 134 }
134 135
135 // Store editor representations in Drupal setting 136 // Store editor representations in Drupal setting
136 drupal_add_js(array('dndEditorRepresentations' => $editor_representations,), 'setting'); 137 drupal_add_js(array('dndEditorRepresentations' => $editor_representations,), 'setting');
137 138