function oembedcore_providers in oEmbed 6.0
Returns all the registered providers, or the providers for a specific host.
@todo Make this more like drupal_match_path()
Parameters
string $host: Optional. Supply a hostname if you only want the provider patterns for a specific host.
Return value
array
1 call to oembedcore_providers()
- oembedcore_get_provider in ./
oembedcore.module - Returns the provider for a url.
File
- ./
oembedcore.module, line 183 - Core functionality for oEmbed
Code
function oembedcore_providers($url_host = NULL) {
static $providers;
if (!$providers) {
$cache_key = 'oembedcore:providers';
if (($cache = cache_get($cache_key)) && isset($cache->data)) {
$providers = $cache->data;
}
else {
$providers = array();
// oEmbed providers are local services that return content over callback
// function.
$modules = module_implements('oembedprovider');
foreach ($modules as $module) {
$ps = call_user_func($module . '_oembedprovider');
foreach ($ps as $pattern => $info) {
$host = _oembedcore_get_host($pattern);
$regex_pattern = '/' . str_replace('\\*', '(.*)', preg_quote($pattern, '/')) . '/i';
$providers[$host][$regex_pattern] = $info;
}
}
// oEmbed provider definitions are remote web services.
$provider_definitions = oembedcore_provider_load_all();
foreach ($provider_definitions as $provider_definition) {
if (empty($provider_definition->disabled)) {
$schemes = preg_split("/(\r\n?|\n)/", $provider_definition->scheme);
foreach ($schemes as $scheme) {
$host = _oembedcore_get_host($scheme);
$regex_pattern = '/' . str_replace('\\*', '.*', preg_quote($scheme, '/')) . '/i';
$providers[$host][$regex_pattern] = (array) $provider_definition;
}
}
}
drupal_alter('oembedprovider', $providers);
foreach ($providers as $host => &$patterns) {
uksort($patterns, '_oembedcore_specificity_compare');
}
cache_set($cache_key, $providers);
}
}
if ($url_host) {
return isset($providers[$url_host]) ? $providers[$url_host] : array();
}
return $providers;
}