You are here

function oembed_provider_process in oEmbed 8

Same name and namespace in other branches
  1. 7 oembed.oembed.inc \oembed_provider_process()
  2. 7.0 oembed.oembed.inc \oembed_provider_process()

File

./oembed.oembed.inc, line 29

Code

function oembed_provider_process(&$plugin, $info) {

  // For plugins which provide children based on the URL, a scheme callback allows a
  // map to be used to generate a regular expression for the whole plugin and each
  // child. Probably the plugin properties 'scheme callback' and 'scheme' are mutually
  // exclusive.
  $function = ctools_plugin_get_function($plugin, 'scheme callback');
  if ($function) {
    $schemes = array();
    $plugin['scheme map'] = $function();
    foreach ($plugin['scheme map'] as $id => $scheme) {
      if (is_array($scheme)) {
        $scheme = implode("\n", $scheme);
      }
      $schemes[] = $scheme;
      $plugin['scheme map'][$id] = oembed_scheme_to_regex($scheme, $plugin['capture subpatterns']);
    }
    uasort($plugin['scheme map'], '_oembed_specificity_compare');
  }
  else {
    if (is_array($plugin['scheme'])) {
      $schemes = $plugin['scheme'];
    }
    else {
      $schemes = array(
        $plugin['scheme'],
      );
    }
  }
  if (!empty($schemes)) {
    $plugin['scheme'] = implode("\n", $schemes);
    $plugin['scheme'] = oembed_scheme_to_regex($plugin['scheme'], $plugin['capture subpatterns']);
    if (empty($plugin['weight'])) {
      $plugin['weight'] = strlen($plugin['scheme']);
    }
  }
}