/[drupal]/contributions/modules/inline/inline.node.inc
ViewVC logotype

Contents of /contributions/modules/inline/inline.node.inc

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


Revision 1.4 - (show annotations) (download) (as text)
Wed Aug 12 05:54:36 2009 UTC (3 months, 2 weeks ago) by sun
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +10 -17 lines
File MIME type: text/x-php
#172613 by sun: Changed handling and passing of $macro object to implementations.
1 <?php
2 // $Id: inline.node.inc,v 1.3 2009/08/12 05:27:35 sun Exp $
3
4 /**
5 * @file
6 * Allows to embed nodes into content.
7 */
8
9 /**
10 * Implementation of hook_TAGNAME_inline().
11 *
12 * @param $op
13 * The current operation performed.
14 * @param $macro
15 * An inline macro object containing user supplied values, passed by reference.
16 */
17 function inline_node_inline($op, &$macro) {
18 switch ($op) {
19 case 'args':
20 // Return an array of available/required tag arguments.
21 $args = array(
22 'nid' => array(
23 '#title' => t('Node id'),
24 '#description' => t('A node id to embed.'),
25 '#type' => 'int',
26 '#default_value' => 0,
27 ),
28 );
29 return $args;
30
31 case 'prepare':
32 // Load a node object if valid nid is given.
33 if (!empty($macro->params['nid'])) {
34 $node = node_load($macro->params['nid']);
35 if (node_access('view', $node)) {
36 $macro->node['node'] = $node;
37 }
38 }
39 return;
40
41 case 'render':
42 // Return a rendered representation to replace a tag.
43 if (!isset($macro->node['node'])) {
44 return;
45 }
46 $node = node_build_content($macro->node['node'], FALSE, TRUE);
47 return drupal_render($node->content);
48 }
49 }
50

  ViewVC Help
Powered by ViewVC 1.1.2