oembedprovider.module in oEmbed 6.0
Module for providing content as defined in the oEmbed specification
File
oembedprovider.moduleView source
<?php
/**
* @file
* Module for providing content as defined in the oEmbed specification
*/
/**
* Implementation of hook_menu().
*/
function oembedprovider_menu() {
$menu = array();
$handler = array(
'type' => MENU_CALLBACK,
'file' => 'oembedprovider.inc',
'page callback' => '_oembedprovider_handle_request',
'page arguments' => array(
2,
),
'access arguments' => array(
'access content',
),
);
$menu['oembed/endpoint'] = $menu['oembed/endpoint/%'] = $handler;
return $menu;
}
/**
* Implementation of hook_theme().
*/
function oembedprovider_theme() {
$themes = array();
$themes['oembed_node'] = array(
'arguments' => array(
'node' => NULL,
),
);
return $themes;
}
/**
* The default provider to handle nodes
*
* @param string $url
* @param array $matches
*/
function oembedprovider_node_provider($provider, $url, $matches) {
module_load_include('inc', 'oembedprovider');
return _oembedprovider_node_provider($provider, $url, $matches);
}
/**
* Default theme implementation for oembed_node. We just mirror the node_view function
* and pass everything on to the node template.
*
* @param object $node
* @return string
* The html representation of the node
*/
function theme_oembed_node($node) {
$node = node_build_content($node, TRUE, FALSE);
// Set the proper node part, then unset unused $node part so that a bad
// theme can not open a security hole.
$content = drupal_render($node->content);
$node->teaser = $content;
unset($node->body);
// Allow modules to modify the fully-built node.
node_invoke_nodeapi($node, 'alter', TRUE, FALSE);
return theme('node', $node, TRUE, FALSE);
}
/**
* Implementation of hook_oembedprovider().
*
* @return array
*/
function oembedprovider_oembedprovider() {
$base_url = url('', array(
'absolute' => TRUE,
)) . 'node/*';
return array(
$base_url => array(
'callback' => 'oembedprovider_node_provider',
),
);
}
/**
* Returns all the registered response formats
*
* @return array
*/
function oembedprovider_formats() {
static $formats;
if (!$formats) {
$cache_key = 'oembedprovider:formats';
if (!$reset && ($cache = cache_get($cache_key)) && isset($cache->data)) {
$formats = $cache->data;
}
else {
$formats = array(
'json' => array(
'mime' => 'text/javascript',
'callback' => '_oembedprovider_formats_json',
),
'xml' => array(
'mime' => 'text/xml',
'callback' => '_oembedprovider_formats_xml',
),
);
drupal_alter('oembedprovider_formats', $formats);
cache_set($cache_key, $formats);
}
}
return $formats;
}
/**
* Implementation of hook_oembedprovider_formats_alter().
*/
function oembedprovider_oembedprovider_formats_alter(&$formats) {
$formats['jsonp'] = array(
'mime' => 'text/javascript',
'callback' => '_oembedprovider_formats_jsonp',
);
}
Functions
Name | Description |
---|---|
oembedprovider_formats | Returns all the registered response formats |
oembedprovider_menu | Implementation of hook_menu(). |
oembedprovider_node_provider | The default provider to handle nodes |
oembedprovider_oembedprovider | Implementation of hook_oembedprovider(). |
oembedprovider_oembedprovider_formats_alter | Implementation of hook_oembedprovider_formats_alter(). |
oembedprovider_theme | Implementation of hook_theme(). |
theme_oembed_node | Default theme implementation for oembed_node. We just mirror the node_view function and pass everything on to the node template. |