Index: cck_blocks.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck_blocks/cck_blocks.module,v retrieving revision 1.2.2.5 diff -u -r1.2.2.5 cck_blocks.module --- cck_blocks.module 26 Oct 2009 20:14:07 -0000 1.2.2.5 +++ cck_blocks.module 27 Oct 2009 14:55:09 -0000 @@ -38,39 +38,67 @@ } } return $blocks; + + case 'configure': + // add token help, if token module is installed + if (module_exists('token')) { + $form = array(); + $form['view']['token_help'] = array( + '#title' => t('Replacement patterns'), + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'), + ); - case 'view': - $block = array(); + $form['view']['token_help']['help'] = array( + '#value' => theme('token_help', 'node'), + ); + + return $form; + } + + + case 'view': + $block = array(); - if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2) && $fields[$delta]) { - $nid = arg(1); - if (!isset($built_nodes[$nid])) { - // Build the node in the cck_blocks mode. This is based on node_build_content(). - $node = node_load($nid); - $node->build_mode = 'cck_blocks'; - - // Remove the delimiter (if any) that separates the teaser from the body. - $node->body = isset($node->body) ? str_replace('', '', $node->body) : ''; + if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2) && $fields[$delta]) { + $nid = arg(1); + if (!isset($built_nodes[$nid])) { + // Build the node in the cck_blocks mode. This is based on node_build_content(). + $node = node_load($nid); + $node->build_mode = 'cck_blocks'; + + // Remove the delimiter (if any) that separates the teaser from the body. + $node->body = isset($node->body) ? str_replace('', '', $node->body) : ''; - // The 'view' hook can be implemented to overwrite the default function - // to display nodes. - if (node_hook($node, 'view')) { - $node = node_invoke($node, 'view', $teaser, $page); - } - else { - $node = node_prepare($node, $teaser); - } + // The 'view' hook can be implemented to overwrite the default function + // to display nodes. + if (node_hook($node, 'view')) { + $node = node_invoke($node, 'view', $teaser, $page); + } + else { + $node = node_prepare($node, $teaser); + } - // Allow modules to make their own additions to the node. - node_invoke_nodeapi($node, 'view', $teaser, $page); - $built_nodes[$nid] = $node; - } + // Allow modules to make their own additions to the node. + node_invoke_nodeapi($node, 'view', $teaser, $page); + $built_nodes[$nid] = $node; + } - if (isset($built_nodes[$nid]->content[$delta])) { - $block['subject'] = $fields[$delta]['widget']['label'] ? $fields[$delta]['widget']['label'] : $delta; - $block['content'] = drupal_render($built_nodes[$nid]->content[$delta]); - } - } + if (isset($built_nodes[$nid]->content[$delta])) { + // evaluate tokens, if token module is installed + if (module_exists('token')) { + $result = db_query(db_rewrite_sql("SELECT title FROM {blocks} WHERE delta = '".$delta."' ")); + $object = db_fetch_object($result); + if($object->title){ + $block['title'] = token_replace($object->title,'node',$node); + } + } + $block['subject'] = t($fields[$delta]['widget']['label'] ? $fields[$delta]['widget']['label'] : $delta); + $block['content'] = drupal_render($built_nodes[$nid]->content[$delta]); + } + } } return $block;