Skip to content
Snippets Groups Projects
Commit a55d46f2 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-148] Remove some code from [gh-124] that was mistakenly pushed to staging

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@873 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent d55d26b3
No related branches found
No related tags found
No related merge requests found
......@@ -882,54 +882,6 @@ function unl_still_alive()
echo '200 Still Alive';
}
/**
* Implementation of hook_filter_info().
*/
function unl_filter_info() {
return array(
'unl_embed' => array(
'title' => 'UNL Node Embed',
'description' => "Allow a node's body to be embedded into another node by using tags.",
'process callback' => 'unl_filter_embed_process',
'cache' => FALSE,
),
);
}
/**
* Implementation of hook_filter_FILTER_process pseudo-hook
*
* Replace any instances of [[node:X]] in the $text with the content of node X's body.
*/
function unl_filter_embed_process($text, $filter, $format, $langcode, $cache, $cache_id) {
static $processed_hashes = array();
$text_hash = hash('sha256', $text);
if (in_array($text_hash, array_keys($processed_hashes))) {
// Possible recursion detected, return the cache result.
return $processed_hashes[$text_hash];
}
// In case of recursion, set the cached result to this until we have the real result.
$processed_hashes[$text_hash] = 'Error: Cannot embed a node in itself..';
$matches = NULL;
preg_match_all('/\[\[node:([0-9]+)\]\]/', $text, $matches);
$node_ids = $matches[1];
$nodes = entity_load('node', $node_ids);
$replace_array = array();
foreach ($node_ids as $node_id) {
$content = node_view($nodes[$node_id]);
$replace_array["[[node:$node_id]]"] = PHP_EOL . "<!-- Node $node_id start -->" . PHP_EOL
. render($content['body'])
. PHP_EOL . "<!-- Node $node_id end -->" . PHP_EOL;
}
$text = strtr($text, $replace_array);
// Set the cached result to the real result.
$processed_hashes[$text_hash] = $text;
return $text;
}
/**
* Custom function to return the current admin theme for use with hook_menu_alter().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment