Projet

Général

Profil

Révision 2b3c8cc1

Ajouté par Assos Assos il y a presque 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media/modules/media_internet/media_internet.module
61 61
}
62 62

  
63 63
/**
64
 * Gets the list of providers.
64
 * Gets the list of Internet media providers.
65 65
 *
66
 * A "Provider" is a bit of meta-data like a title and a logo and a class which
67
 * can handle saving remote files.  Each provider is able to parse an embed code or URL
68
 * and store it as a file object in file_managed.
66
 * Each 'Provider' has a title and a class which can handle saving remote files.
67
 * Providers are each given a turn at parsing a user-submitted URL or embed code
68
 * and, if they recognize that it belongs to a service or protocol they support,
69
 * they store a representation of it as a file object in file_managed.
70
 *
71
 * @return array
72
 *   An associative array of provider information keyed by provider name.
69 73
 */
70 74
function media_internet_get_providers() {
71 75
  $providers = &drupal_static(__FUNCTION__);
72 76

  
73 77
  if (!isset($providers)) {
74
    $cid = 'media:internet:providers';
75
    if ($cache = cache_get($cid)) {
76
      $providers = $cache->data;
77
    }
78
    else {
79
      $providers = array();
80
      foreach (module_implements('media_internet_providers') as $module) {
81
        foreach (module_invoke($module, 'media_internet_providers') as $key => $provider) {
82
          // Store the module here too for convinience.
83
          $providers[$key] = $provider;
84
          $providers[$key]['module'] = $module;
85
          if (!isset($providers[$key]['weight'])) {
86
            $providers[$key]['weight'] = 0;
87
          }
78
    foreach (module_implements('media_internet_providers') as $module) {
79
      foreach (module_invoke($module, 'media_internet_providers') as $class => $info) {
80
        $providers[$class] = $info;
81

  
82
        // Store the name of the module which declared the provider.
83
        $providers[$class]['module'] = $module;
84

  
85
        // Assign a default value to providers which don't specify a weight.
86
        if (!isset($providers[$class]['weight'])) {
87
          $providers[$class]['weight'] = 0;
88 88
        }
89 89
      }
90
      uasort($providers, 'drupal_sort_weight');
91
      cache_set($cid, $providers);
92 90
    }
91

  
92
    // Allow modules to alter the list of providers.
93
    drupal_alter('media_internet_providers', $providers);
94

  
95
    // Sort the providers by weight.
96
    uasort($providers, 'drupal_sort_weight');
93 97
  }
94 98

  
95 99
  return $providers;
......
201 205
      $form['embed_code']['#title'] = t('File URL or media resource');
202 206
      $form['embed_code']['#description'] = t('Enter a URL to a file or media resource. Many media providers also support identifying media via the embed code used to embed the media into external websites.');
203 207

  
204
      $form['embed_code']['#description'] = theme('media_internet_embed_help', array('description' => $form['embed_code']['#description'], 'supported_providers' => implode(' ', $providers)));
208
      $form['embed_code']['#description'] = theme('media_internet_embed_help', array('description' => $form['embed_code']['#description'], 'supported_providers' => implode(', ', $providers)));
205 209
    }
206 210

  
207 211
    $form['#validators'] = array();

Formats disponibles : Unified diff