Révision fc3d89c3
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc | ||
---|---|---|
12 | 12 |
* |
13 | 13 |
* @TODO check for security probably pass text through filter_xss |
14 | 14 |
*/ |
15 |
function media_wysiwyg_filter($text) { |
|
16 |
$text = preg_replace_callback(MEDIA_WYSIWYG_TOKEN_REGEX, 'media_wysiwyg_token_to_markup', $text); |
|
17 |
return $text; |
|
15 |
function media_wysiwyg_filter($text, $filter, $format, $langcode, $cache, $cache_id) { |
|
16 |
$replacements = array(); |
|
17 |
$patterns = array(); |
|
18 |
$rendered_text = $text; |
|
19 |
$count = 1; |
|
20 |
preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $text, $matches); |
|
21 |
if (!empty($matches[0])) { |
|
22 |
foreach ($matches[0] as $match) { |
|
23 |
$replacement = media_wysiwyg_token_to_markup(array($match), FALSE, $langcode); |
|
24 |
$rendered_text = str_replace($match, $replacement, $rendered_text, $count); |
|
25 |
} |
|
26 |
} |
|
27 |
return $rendered_text; |
|
18 | 28 |
} |
19 | 29 |
|
20 | 30 |
/** |
... | ... | |
55 | 65 |
* @see media_wysiwyg_get_file_without_label() |
56 | 66 |
* @see hook_media_wysiwyg_token_to_markup_alter() |
57 | 67 |
*/ |
58 |
function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { |
|
68 |
function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NULL) {
|
|
59 | 69 |
static $recursion_stop; |
60 | 70 |
$settings = array(); |
61 | 71 |
$match = str_replace("[[", "", $match); |
... | ... | |
156 | 166 |
} |
157 | 167 |
} |
158 | 168 |
} |
169 |
foreach (array('title', 'alt') as $field_type) { |
|
170 |
if (isset($settings['attributes'][$field_type])) { |
|
171 |
$settings['attributes'][$field_type] = decode_entities($settings['attributes'][$field_type]); |
|
172 |
} |
|
173 |
} |
|
159 | 174 |
} |
160 | 175 |
} |
161 | 176 |
catch (Exception $e) { |
... | ... | |
180 | 195 |
// that an inline macro can be generated when the WYSIWYG is detached. |
181 | 196 |
// The WYSIWYG plugin is expecting this information in the |
182 | 197 |
// Drupal.settings.mediaDataMap variable. |
183 |
$element = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings); |
|
198 |
$element = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings, $langcode);
|
|
184 | 199 |
$data = array( |
185 | 200 |
'type' => 'media', |
186 | 201 |
'fid' => $file->fid, |
... | ... | |
199 | 214 |
if (variable_get('media_wysiwyg_default_render', 'file_entity') == 'file_entity') { |
200 | 215 |
$element['content'] = file_view($file, $tag_info['view_mode']); |
201 | 216 |
} |
202 |
$element['content']['file'] = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings); |
|
217 |
$element['content']['file'] = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings, $langcode);
|
|
203 | 218 |
// Overwrite or set the file #alt attribute if it has been set in this |
204 | 219 |
// instance. |
205 | 220 |
if (!empty($element['content']['file']['#attributes']['alt'])) { |
... | ... | |
212 | 227 |
} |
213 | 228 |
// For sites using the legacy field_attach rendering method, attach fields. |
214 | 229 |
if (variable_get('media_wysiwyg_default_render', 'file_entity') == 'field_attach') { |
215 |
field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode']); |
|
216 |
entity_prepare_view('file', array($file->fid => $file)); |
|
217 |
$element['content'] += field_attach_view('file', $file, $tag_info['view_mode']); |
|
230 |
field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode'], $langcode);
|
|
231 |
entity_prepare_view('file', array($file->fid => $file), $langcode);
|
|
232 |
$element['content'] += field_attach_view('file', $file, $tag_info['view_mode'], $langcode);
|
|
218 | 233 |
} |
219 | 234 |
if (count(element_children($element['content'])) > 1) { |
220 | 235 |
// Add surrounding divs to group them together. |
... | ... | |
234 | 249 |
$element['#pre_render'][] = 'media_wysiwyg_pre_render_cached_filter'; |
235 | 250 |
} |
236 | 251 |
} |
237 |
drupal_alter('media_wysiwyg_token_to_markup', $element, $tag_info, $settings); |
|
252 |
drupal_alter('media_wysiwyg_token_to_markup', $element, $tag_info, $settings, $langcode);
|
|
238 | 253 |
$output = drupal_render($element); |
239 | 254 |
unset($recursion_stop[$file->fid]); |
240 | 255 |
return $output; |
... | ... | |
261 | 276 |
|
262 | 277 |
// The value should be set at the deepest level. |
263 | 278 |
// Fields that use rich-text markup will be urlencoded. |
264 |
$ref = urldecode($field_value);
|
|
279 |
$ref = decode_entities($field_value);
|
|
265 | 280 |
} |
266 | 281 |
} |
267 | 282 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules