Skip to content
Snippets Groups Projects
Commit e006e7b3 authored by AlexisWilke's avatar AlexisWilke
Browse files

The InsertNode project files (I'd like to rename it, but that could cause

some mayhem...)
parents
No related branches found
No related tags found
No related merge requests found
; $ Id: $
name = Insert node
description = A filter to include content from one node in another
package = "Input filters"
dependencies[] = filter
<?php
// $Id$
// Author: Mark Burton
// Conversion to D6: Alexis Wilke
function _insert_node_replacer($matches) {
if (is_numeric($matches[1])) {
$nid = $matches[1];
}
else {
$path = explode("/", drupal_get_normal_path(rtrim(ltrim($matches[1], "/"), "/")));
if ($path && ($path[0] == 'node') && is_numeric($path[1])) {
$nid = $path[1];
}
else {
return "<em>". t("Can't find !s to include!", array("!s" => $matches[1])) ."</em>";
}
}
$node = node_load(array('nid' => $nid));
if ($nid && node_access('view', $node)) {
switch ($matches[2]) {
case 'body':
return $node->body;
case 'teaser':
return $node->teaser;
case 'link':
return l($node->title, "node/$node->nid");
case 'collapsible':
return theme('fieldset', array(
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => $node->title,
'#value' => $node->body));
case 'collapsed':
return theme('fieldset', array(
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => $node->title,
'#value' => $node->body));
default:
return theme('node', $node);
}
}
return '';
}
function insert_node_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'list':
return array(0 => t('Include/link node by ID or path'));
case 'description':
return t('Include/link node by ID or path');
case 'prepare':
return $text;
case "process":
return preg_replace_callback('/\[node:([^\s\]]+)(?:\s+(body|teaser|link|collapsible|collapsed))?\]/', '_insert_node_replacer', $text);
}
}
function insert_node_filter_tips($delta, $format, $long = false) {
return t('[node:123] - insert full text (themed by theme(\'node\'))<br/>'
. '[node:123 body] - insert node\'s body<br/>'
. '[node:123 teaser] - insert node\'s teaser<br/>'
. '[node:123 link] - insert title as a link to node<br/>'
. '[node:123 collapsible] - insert collapsible node\'s body (in a frame that can be collapsed)<br/>'
. '[node:123 collapsed] - insert collapsed node\'s body (in a collapsed frame)');
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment