/[drupal]/contributions/modules/composite/composite.block.inc
ViewVC logotype

Contents of /contributions/modules/composite/composite.block.inc

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


Revision 1.1 - (show annotations) (download) (as text)
Tue Oct 14 01:03:56 2008 UTC (13 months, 2 weeks ago) by bengtan
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA1, HEAD
Branch point for: DRUPAL-6--1
File MIME type: text/x-php
Initial import.
1 <?php
2 // $Id$
3
4 function composite_composite_block_api(&$reference, $op, $a3 = NULL, $a4 = NULL) {
5 switch ($op) {
6 // Derive additional fields
7 case 'load':
8 list($reference['module'], $reference['delta']) = explode('-', $reference['id'], 2);
9 break;
10
11 // Generate and insert an informative human-readable string into ['info']
12 case 'info':
13 $blocks = module_invoke($reference['module'], 'block', 'list');
14 $reference['info'] = check_plain($blocks[$reference['delta']]['info']);
15 break;
16
17 // Return a rendering of the reference item
18 case 'view':
19 $block = new StdClass();
20 $block->module = $reference['module'];
21 $block->delta = $reference['delta'];
22 $array = module_invoke($block->module, 'block', 'view', $block->delta);
23 if (isset($array) && is_array($array)) {
24 foreach ($array as $k => $v) {
25 $block->$k = $v;
26 }
27 }
28 if ($block->content) {
29 return theme('block', $block);
30 }
31 break;
32
33 }
34 }
35
36 /**
37 * Generates and returns a keyed array of potential composite references
38 * so composite.module can create a meaningful local task.
39 */
40 function composite_composite_block_potentials($node) {
41 // Build a list of blocks
42 // Note: Instead of using code in blocks.module, we generate our own
43 // since we want this list to be theme-independent
44 $block_list = array();
45 foreach (module_implements('block') as $module) {
46 $module_blocks = module_invoke($module, 'block', 'list');
47 foreach ($module_blocks as $delta => $block) {
48 $block_list[$module . '-' . $delta] = $block['info'];
49 }
50 }
51 asort($block_list);
52 return $block_list;
53 }

  ViewVC Help
Powered by ViewVC 1.1.2