Projet

Général

Profil

Révision 1e39edcb

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
5 5
 * Functions related to the WYSIWYG editor and the media input filter.
6 6
 */
7 7

  
8
define('MEDIA_WYSIWYG_TOKEN_REGEX', '/\[\[\{"fid".*?\]\]/s');
8
define('MEDIA_WYSIWYG_TOKEN_REGEX', '/\[\[.*?\]\]/s');
9 9

  
10 10
/**
11 11
 * Filter callback for media markup filter.
......
215 215

  
216 216
  if ($wysiwyg) {
217 217
    $settings['wysiwyg'] = $wysiwyg;
218

  
219
    // Render file in WYSIWYG using appropriate view mode.
220
    $view_mode = db_query('SELECT view_mode FROM {media_view_mode_wysiwyg} WHERE type = :type', array(
221
      ':type' => $file->type,
222
    ))
223
      ->fetchField();
224
    if (empty($view_mode)) {
225
      $view_mode = $tag_info['view_mode'];
226
    }
227

  
218 228
    // If sending markup to a WYSIWYG, we need to pass the file information so
219 229
    // that an inline macro can be generated when the WYSIWYG is detached.
220 230
    // The WYSIWYG plugin is expecting this information in the
221 231
    // Drupal.settings.mediaDataMap variable.
222
    $element = media_wysiwyg_get_file_without_label($file, $tag_info['view_mode'], $settings, $langcode);
232
    $element = media_wysiwyg_get_file_without_label($file, $view_mode, $settings, $langcode);
223 233
    $data = array(
224 234
      'type' => 'media',
225 235
      'fid'  => $file->fid,
......
257 267
    }
258 268
    if (count(element_children($element['content'])) > 1) {
259 269
      // Add surrounding divs to group them together.
260
      // We dont want divs when there are no additional fields to allow files
270
      // We don't want divs when there are no additional fields to allow files
261 271
      // to display inline with text, without breaking p tags.
262 272
      $element['content']['#type'] = 'container';
263 273
      $element['content']['#attributes']['class'] = array(
264 274
        'media',
265 275
        'media-element-container',
266
        'media-' . $element['content']['file']['#view_mode']
276
        'media-' . $element['content']['file']['#view_mode'],
267 277
      );
268 278
    }
269 279

  
......
351 361
  // between function calls. Since media_process_form is multiple times
352 362
  // with same form, this function is also called multiple times.
353 363
  static $tagmap = array();
354
  preg_match_all(MEDIA_WYSIWYG_TOKEN_REGEX, $text, $matches, PREG_SET_ORDER);
364
  preg_match_all("/\[\[.*?\]\]/s", $text, $matches, PREG_SET_ORDER);
355 365
  foreach ($matches as $match) {
356 366
    // We see if tagContent is already in $tagMap, if not we add it
357 367
    // to $tagmap.  If we return an empty array, we break embeddings of the same
......
415 425
  }
416 426

  
417 427
  $view_modes = $enabled_view_modes[$file->type];
428
  media_wysiwyg_wysiwyg_allowed_view_modes_restrict($view_modes, $file);
418 429
  drupal_alter('media_wysiwyg_allowed_view_modes', $view_modes, $file);
419 430
  // Invoke the deprecated/misspelled alter hook as well.
420 431
  drupal_alter('media_wysiwyg_wysiwyg_allowed_view_modes', $view_modes, $file);
421 432
  return $view_modes;
422 433
}
423

  
434
/**
435
 * Do not show restricted view modes.
436
 */
437
function media_wysiwyg_wysiwyg_allowed_view_modes_restrict(&$view_modes, &$file) {
438
  $restricted_view_modes = db_query('SELECT display FROM {media_restrict_wysiwyg} WHERE type = :type', array(':type' => $file->type))->fetchCol();
439
  foreach ($restricted_view_modes as $restricted_view_mode) {
440
    if (array_key_exists($restricted_view_mode, $view_modes)) {
441
      unset($view_modes[$restricted_view_mode]);
442
    }
443
  }
444
}
424 445
/**
425 446
 * #pre_render callback: Modify the element if the render cache is filtered.
426 447
 */

Formats disponibles : Unified diff