Loading modules/media_wysiwyg/includes/media_wysiwyg.filter.inc +20 −10 Changes for modules/media_wysiwyg/includes/media_wysiwyg.filter.inc: 20 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -12,9 +12,19 @@ define('MEDIA_WYSIWYG_TOKEN_REGEX', '/\[\[.*?\]\]/s'); * * @TODO check for security probably pass text through filter_xss */ function media_wysiwyg_filter($text) { $text = preg_replace_callback(MEDIA_WYSIWYG_TOKEN_REGEX, 'media_wysiwyg_token_to_markup', $text); return $text; function media_wysiwyg_filter($text, $filter, $format, $langcode, $cache, $cache_id) { $replacements = array(); $patterns = array(); $rendered_text = $text; $count = 1; preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $text, $matches); if (!empty($matches[0])) { foreach ($matches[0] as $match) { $replacement = media_wysiwyg_token_to_markup(array($match), FALSE, $langcode); $rendered_text = str_replace($match, $replacement, $rendered_text, $count); } } return $rendered_text; } /** Loading Loading @@ -55,7 +65,7 @@ function media_wysiwyg_parse_css_declarations($declarations) { * @see media_wysiwyg_get_file_without_label() * @see hook_media_wysiwyg_token_to_markup_alter() */ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NULL) { static $recursion_stop; $settings = array(); $match = str_replace("[[", "", $match); Loading Loading @@ -180,7 +190,7 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { // that an inline macro can be generated when the WYSIWYG is detached. // The WYSIWYG plugin is expecting this information in the // Drupal.settings.mediaDataMap variable. $element = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings); $element = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings, $langcode); $data = array( 'type' => 'media', 'fid' => $file->fid, Loading @@ -199,7 +209,7 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { if (variable_get('media_wysiwyg_default_render', 'file_entity') == 'file_entity') { $element['content'] = file_view($file, $tag_info['view_mode']); } $element['content']['file'] = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings); $element['content']['file'] = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings, $langcode); // Overwrite or set the file #alt attribute if it has been set in this // instance. if (!empty($element['content']['file']['#attributes']['alt'])) { Loading @@ -212,9 +222,9 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { } // For sites using the legacy field_attach rendering method, attach fields. if (variable_get('media_wysiwyg_default_render', 'file_entity') == 'field_attach') { field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode']); entity_prepare_view('file', array($file->fid => $file)); $element['content'] += field_attach_view('file', $file, $tag_info['view_mode']); field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode'], $langcode); entity_prepare_view('file', array($file->fid => $file), $langcode); $element['content'] += field_attach_view('file', $file, $tag_info['view_mode'], $langcode); } if (count(element_children($element['content'])) > 1) { // Add surrounding divs to group them together. Loading @@ -234,7 +244,7 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { $element['#pre_render'][] = 'media_wysiwyg_pre_render_cached_filter'; } } drupal_alter('media_wysiwyg_token_to_markup', $element, $tag_info, $settings); drupal_alter('media_wysiwyg_token_to_markup', $element, $tag_info, $settings, $langcode); $output = drupal_render($element); unset($recursion_stop[$file->fid]); return $output; Loading modules/media_wysiwyg/media_wysiwyg.module +10 −2 Changes for modules/media_wysiwyg/media_wysiwyg.module: 10 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -288,10 +288,18 @@ function _media_wysiwyg_wysiwyg_allowed_attributes_default() { * * Optional custom settings can override how the file is displayed. */ function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = array()) { function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = array(), $langcode = NULL) { $file->override = $settings; $element = file_view_file($file, $view_mode); $element = file_view_file($file, $view_mode, $langcode); // Field Translation Support. if (field_has_translation_handler('file')) { if ($field_items = field_get_items('file', $file, 'field_file_image_alt_text', $langcode)) { $value = field_view_value('file', $file, 'field_file_image_alt_text', $field_items[0], array(), $langcode); $element['#alt'] = isset($value['#markup']) ? $value['#markup'] : ''; } } // The formatter invoked by file_view_file() can use $file->override to // customize the returned render array to match the requested settings. To Loading Loading
modules/media_wysiwyg/includes/media_wysiwyg.filter.inc +20 −10 Changes for modules/media_wysiwyg/includes/media_wysiwyg.filter.inc: 20 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -12,9 +12,19 @@ define('MEDIA_WYSIWYG_TOKEN_REGEX', '/\[\[.*?\]\]/s'); * * @TODO check for security probably pass text through filter_xss */ function media_wysiwyg_filter($text) { $text = preg_replace_callback(MEDIA_WYSIWYG_TOKEN_REGEX, 'media_wysiwyg_token_to_markup', $text); return $text; function media_wysiwyg_filter($text, $filter, $format, $langcode, $cache, $cache_id) { $replacements = array(); $patterns = array(); $rendered_text = $text; $count = 1; preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $text, $matches); if (!empty($matches[0])) { foreach ($matches[0] as $match) { $replacement = media_wysiwyg_token_to_markup(array($match), FALSE, $langcode); $rendered_text = str_replace($match, $replacement, $rendered_text, $count); } } return $rendered_text; } /** Loading Loading @@ -55,7 +65,7 @@ function media_wysiwyg_parse_css_declarations($declarations) { * @see media_wysiwyg_get_file_without_label() * @see hook_media_wysiwyg_token_to_markup_alter() */ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NULL) { static $recursion_stop; $settings = array(); $match = str_replace("[[", "", $match); Loading Loading @@ -180,7 +190,7 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { // that an inline macro can be generated when the WYSIWYG is detached. // The WYSIWYG plugin is expecting this information in the // Drupal.settings.mediaDataMap variable. $element = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings); $element = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings, $langcode); $data = array( 'type' => 'media', 'fid' => $file->fid, Loading @@ -199,7 +209,7 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { if (variable_get('media_wysiwyg_default_render', 'file_entity') == 'file_entity') { $element['content'] = file_view($file, $tag_info['view_mode']); } $element['content']['file'] = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings); $element['content']['file'] = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings, $langcode); // Overwrite or set the file #alt attribute if it has been set in this // instance. if (!empty($element['content']['file']['#attributes']['alt'])) { Loading @@ -212,9 +222,9 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { } // For sites using the legacy field_attach rendering method, attach fields. if (variable_get('media_wysiwyg_default_render', 'file_entity') == 'field_attach') { field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode']); entity_prepare_view('file', array($file->fid => $file)); $element['content'] += field_attach_view('file', $file, $tag_info['view_mode']); field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode'], $langcode); entity_prepare_view('file', array($file->fid => $file), $langcode); $element['content'] += field_attach_view('file', $file, $tag_info['view_mode'], $langcode); } if (count(element_children($element['content'])) > 1) { // Add surrounding divs to group them together. Loading @@ -234,7 +244,7 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE) { $element['#pre_render'][] = 'media_wysiwyg_pre_render_cached_filter'; } } drupal_alter('media_wysiwyg_token_to_markup', $element, $tag_info, $settings); drupal_alter('media_wysiwyg_token_to_markup', $element, $tag_info, $settings, $langcode); $output = drupal_render($element); unset($recursion_stop[$file->fid]); return $output; Loading
modules/media_wysiwyg/media_wysiwyg.module +10 −2 Changes for modules/media_wysiwyg/media_wysiwyg.module: 10 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -288,10 +288,18 @@ function _media_wysiwyg_wysiwyg_allowed_attributes_default() { * * Optional custom settings can override how the file is displayed. */ function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = array()) { function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = array(), $langcode = NULL) { $file->override = $settings; $element = file_view_file($file, $view_mode); $element = file_view_file($file, $view_mode, $langcode); // Field Translation Support. if (field_has_translation_handler('file')) { if ($field_items = field_get_items('file', $file, 'field_file_image_alt_text', $langcode)) { $value = field_view_value('file', $file, 'field_file_image_alt_text', $field_items[0], array(), $langcode); $element['#alt'] = isset($value['#markup']) ? $value['#markup'] : ''; } } // The formatter invoked by file_view_file() can use $file->override to // customize the returned render array to match the requested settings. To Loading