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

Contents of /contributions/modules/ssi/ssi.module

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


Revision 1.3 - (show annotations) (download) (as text)
Mon Aug 4 07:15:27 2008 UTC (15 months, 3 weeks ago) by deciphered
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +66 -8 lines
File MIME type: text/x-php
Added three new output types.
1 <?php
2 // $Id: ssi.module,v 1.2 2008/08/03 06:27:39 deciphered Exp $
3
4 /**
5 * @file
6 * Allows Drupal content to be accessed externally via SSI
7 */
8
9 /**
10 * Implementation of hook_perm().
11 */
12 function ssi_perm() {
13 return array('view ssi');
14 }
15
16 /**
17 * Implementation of hook_menu().
18 */
19 function ssi_menu() {
20 $items = array();
21
22 $items['ssi/block'] = array(
23 'title' => 'SSI Block',
24 'page callback' => 'ssi_display_blocks',
25 'page arguments' => array('block'),
26 'access arguments' => array('view ssi'),
27 'type' => MENU_CALLBACK
28 );
29
30 $items['ssi/region'] = array(
31 'title' => 'SSI Region',
32 'page callback' => 'ssi_display_blocks',
33 'page arguments' => array('region'),
34 'access arguments' => array('view ssi'),
35 'type' => MENU_CALLBACK
36 );
37
38 $items['ssi/node/%'] = array(
39 'title' => 'SSI Node',
40 'page callback' => 'ssi_display_node',
41 'page arguments' => array(2),
42 'access arguments' => array('view ssi'),
43 'type' => MENU_CALLBACK
44 );
45
46 $items['ssi/node/%/teaser'] = array(
47 'title' => 'SSI Node - Teaser',
48 'page callback' => 'ssi_display_node',
49 'page arguments' => array(2, TRUE),
50 'access arguments' => array('view ssi'),
51 'type' => MENU_CALLBACK
52 );
53
54 return $items;
55 }
56
57 /**
58 * Output Blocks for SSI
59 */
60 function ssi_display_blocks($type) {
61 $output = '';
62
63 if ($type == 'block' && arg(2) && arg(3)) {
64 $blocks[arg(2) .'_'. arg(3)] = (object) module_invoke(arg(2), 'block', 'view', arg(3));
65 }
66 else if ($type == 'region' && arg(2)) {
67 init_theme();
68 $blocks = block_list(arg(2));
69 }
70
71 if (count($blocks) >= 1) {
72 foreach ($blocks as $block) {
73 if ($block->content) {
74 $output .= theme('block', $block);
75 }
76 }
77 }
78
79 print $output;
80 exit;
81 }
82
83 /**
84 * Output Node for SSI
85 */
86 function ssi_display_node($nid, $teaser = FALSE) {
87 $output = '';
88
89 if (is_numeric($nid)) {
90 $node = node_load($nid);
91 // TODO: Add support for CCK Fields
92
93 $page = ($teaser == FALSE) ? 1 : 0;
94
95 $output = theme('node', $node, $teaser, $page);
96 }
97
98 print $output;
99 exit;
100 }

  ViewVC Help
Powered by ViewVC 1.1.2