diff --git a/insert_block.module b/insert_block.module index 9d18351..10f119d 100644 --- a/insert_block.module +++ b/insert_block.module @@ -71,47 +71,28 @@ function insert_block_filter($op, $delta = 0, $format = -1, $text = '') { function _insert_block_substitute_tags($text) { if (preg_match_all("/\[block:([^=\\]]+)=?([^\\]]*)?\]/i", $text, $match)) { + $raw_tags = $repl = array(); 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); + $block = (object) module_invoke($module, 'block', 'view', $delta); + if (isset($block->content)) { + init_theme(); + global $theme_key; + $title = db_result(db_query_range("SELECT b.title FROM {blocks} b WHERE b.theme = '%s' AND b.module = '%s' AND b.delta = '%s'", $theme_key, $module, $delta, 0, 1)); + if ($title) { + $block->subject = $title == '' ? '' : check_plain($title); + } + $block->module = $module; + $block->delta = $delta; + $block->region = 'insert_block'; - $repl[] = theme('insert_block_block', $block); + $raw_tags[] = $match[0][$key]; + $repl[] = theme('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 (!empty($block['subject'])) { - $content .= '

'. $block['subject'] .'

'; - } - if (!empty($block['content'])) { - $content .= $block['content']; - } - return $content; -} +} \ No newline at end of file