Projet

Général

Profil

Révision b0d73b57

Ajouté par Assos Assos il y a presque 9 ans

Revert media to 2.0-alpha4

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 Internet media providers.
64
 * Gets the list of providers.
65 65
 *
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.
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.
73 69
 */
74 70
function media_internet_get_providers() {
75 71
  $providers = &drupal_static(__FUNCTION__);
76 72

  
77 73
  if (!isset($providers)) {
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;
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
          }
88 88
        }
89 89
      }
90
      uasort($providers, 'drupal_sort_weight');
91
      cache_set($cid, $providers);
90 92
    }
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');
97 93
  }
98 94

  
99 95
  return $providers;
......
205 201
      $form['embed_code']['#title'] = t('File URL or media resource');
206 202
      $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.');
207 203

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

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

Formats disponibles : Unified diff