[block:module=delta] tags to display the contents of block delta for module module.', array("@insert_block_help" => url("filter/tips/$format", array('fragment' => 'filter-insert_block')))); } else { return t('You may use [block:module=delta] tags to display the contents of block delta for module module.', array("@insert_block_help" => url("filter/tips/$format", array('fragment' => 'filter-insert_block')))); } } /** * Implementation of hook_help(). */ function insert_block_help($section = 'admin/help#insert_block', $args = array()) { $output = ''; switch ($section) { case 'admin/help#insert_block': return t('

Inserts the contents of a block into into a node using [block:module=delta] tags.

You may use [block:module=delta] tags to display the contents of block delta for module module.

', array("@insert_block_help" => url("filter/tips/$format", NULL, 'filter-insert_block'))); } } /** * Implementation of hook_filter(). */ function insert_block_filter($op, $delta = 0, $format = -1, $text = '') { // The "list" operation provides the module an opportunity to declare both how // many filters it defines and a human-readable name for each filter. Note that // the returned name should be passed through t() for translation. if ($op == 'list') { return array( 0 => t('insert block filter')); } // go ahead and set this up for multiple filters, though I doubt we'll use it switch ($delta) { case 0: switch ($op) { case 'description': return t('Inserts the contents of a block into a node using [block:module=delta] tags.'); case 'prepare': return $text; case 'process': return _insert_block_substitute_tags($text); } break; } } function _insert_block_substitute_tags($text) { if (preg_match_all("/\[block:([^=\\]]+)=?([^\\]]*)?\]/i", $text, $match)) { foreach ($match[2] as $key => $value) { $raw_tags[] = $match[0][$key]; $module = $match[1][$key]; $delta = $match[2][$key]; $block = module_invoke($module, 'block', 'view', $delta); $repl[] = theme('insert_block_block', $block); } return str_replace($raw_tags, $repl, $text); } return $text; } /** * Implementation of hook_theme(). */ function insert_block_theme() { $themes = array( 'insert_block_block' => array( 'arguments' => array('block'), ), ); return $themes; } /** * Format an included block. * * Gets passed the block array to be formatted. By default it includes * the block subject, if any, and the block's content. * * @ingroup themeable */ function theme_insert_block_block($block) { $content = ''; if ($block['subject']) { $content .= '

' . $block['subject'] . '

'; } if ($block['content']) { $content .= $block['content']; } return $content; }