/[drupal]/contributions/modules/InsertNode/InsertNode.module
ViewVC logotype

Contents of /contributions/modules/InsertNode/InsertNode.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Fri Oct 23 11:21:59 2009 UTC (4 weeks, 5 days ago) by markfoodyburton
Branch: MAIN
CVS Tags: DRUPAL-5--1-2, HEAD
Changes since 1.2: +5 -5 lines
File MIME type: text/x-php
added check_html to ensure rendering is done right
1 <?php
2 // $Id: InsertNode.module,v 1.2 2008/03/04 14:54:35 markfoodyburton Exp $
3 // Author: Mark Burton
4
5
6 function _InsertNode_replacer($matches) {
7 if (is_numeric($matches[1])) {
8 $nid=$matches[1];
9 } else {
10 $path=explode("/",drupal_get_normal_path(rtrim(ltrim($matches[1],"/"),"/")));
11 if ($path && ($path[0]=='node') && is_numeric($path[1])) {
12 $nid=$path[1];
13 } else {
14 return "<em>".t("Can't find @s to include!</em>",array("@s"=>$matches[1]))."</em>";
15 }
16 }
17
18 $node=node_load(array('nid'=>$nid));
19 if ($nid && node_access('view',$node)) {
20 switch ($matches[2]) {
21 case 'body':
22 return check_markup($node->body, $node->format, FALSE);
23 case 'teaser':
24 return check_markup($node->teaser, $node->format, FALSE);
25 case 'link':
26 return l($node->title, "node/$node->nid");
27 case 'collapsed':
28 return theme('fieldset', array('#collapsible'=>true, '#collapsed'=>true, '#title'=>$node->title, '#value'=>$node->body));
29 default:
30 return node_view($node);
31 }
32 } else {
33 return '';
34 }
35
36 }
37
38
39 function InsertNode_filter($op, $delta = 0, $format = -1, $text = '') {
40 switch ($op) {
41 case 'list':
42 return array(0 => t('Include/link node by ID or path'));
43 case 'description':
44 return t('Include/link node by ID or path (Keep last in filter order)');
45 case 'prepare':
46 return $text;
47 case "process":
48 $text = preg_replace_callback('/\[node:([^\s\]]+)(?:\s+(body|link|collapsed|teaser))?\]/', '_InsertNode_replacer', $text);
49 return $text;
50 default:
51 return $text;
52 }
53 }
54
55
56 function InsertNode_filter_tips($delta, $format, $long = false) {
57 // if ($long) {
58 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 link to node<br> [node:123 collapsed] - insert collapsed node\'s body');
59 }
60
61 ?>

  ViewVC Help
Powered by ViewVC 1.1.2