You are here

function media_internet_get_providers in D7 Media 7

Same name and namespace in other branches
  1. 7.4 modules/media_internet/media_internet.module \media_internet_get_providers()
  2. 7.2 modules/media_internet/media_internet.module \media_internet_get_providers()
  3. 7.3 modules/media_internet/media_internet.module \media_internet_get_providers()

Gets the list of providers.

A "Provider" is a bit of meta-data like a title and a logo and a class which can handle saving remote files. Each provider is able to parse an embed code or URL and store it as a file object in file_managed.

2 calls to media_internet_get_providers()
media_internet_add in modules/media_internet/media_internet.module
Provides a form for adding media items from 3rd party sources.
media_internet_get_provider in modules/media_internet/media_internet.module
Finds the appropriate provider for a given URL or embed_string

File

modules/media_internet/media_internet.module, line 188

Code

function media_internet_get_providers() {
  $providers =& drupal_static(__FUNCTION__);
  if (!isset($providers)) {
    $cid = 'media:internet:providers';
    if ($cache = cache_get($cid)) {
      $providers = $cache->data;
    }
    else {
      $providers = array();
      foreach (module_implements('media_internet_providers') as $module) {
        foreach (module_invoke($module, 'media_internet_providers') as $key => $provider) {

          // Store the module here too for convinience.
          $providers[$key] = $provider;
          $providers[$key]['module'] = $module;
          if (!isset($providers[$key]['weight'])) {
            $providers[$key]['weight'] = 0;
          }
        }
      }
      uasort($providers, 'drupal_sort_weight');
      cache_set($cid, $providers);
    }
  }
  return $providers;
}