diff --git a/insert_block.info b/insert_block.info index bd9be5a..ca32a0c 100644 --- a/insert_block.info +++ b/insert_block.info @@ -1,4 +1,6 @@ name = Insert Block description = "Inserts the contents of a block into into a node using [block:module=delta] tags" -version = "6.x-1.x-dev" -core = 6.x +core = 7.x + +files[] = insert_block.module +files[] = insert_block.install \ No newline at end of file diff --git a/insert_block.install b/insert_block.install index b6dc4a1..1a1b0ed 100644 --- a/insert_block.install +++ b/insert_block.install @@ -1,6 +1,4 @@ You may use [block:module=delta] tags to display the contents of block delta for module module. To discover module names and deltas, visit admin/build/block and hover over a block\'s configure link and look in your browser\'s status bar. The last "word" you see is the name of the module and the number following that is the delta. If you leave off the delta in an Insert Block tag, the default delta will be used.'); - } - 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()) { @@ -41,57 +28,57 @@ function insert_block_help($section = 'admin/help#insert_block', $args = array() } /** - * Implementation of hook_filter(). + * Implementation of hook_filter_info(). */ -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); - case 'no cache': - return TRUE; - } - break; - } +function insert_block_filter_info() { + $filters['insert_block'] = array( + 'title' => t('Insert blocks'), + 'description' => t('Inserts the contents of a block into a node using [block:module=delta] tags.'), + 'process callback' => '_insert_block', + 'settings callback' => '_insert_block_settings', + 'tips callback' => '_insert_block_tips', + 'cache' => FALSE, + ); + return $filters; } -function _insert_block_substitute_tags($text) { +function _insert_block($text, $filter, $format) { 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); + $block = module_invoke($module, 'block_view', $delta); - $repl[] = theme('insert_block_block', $block); + $repl[] = theme('insert_block_block', array('block' => $block)); } return str_replace($raw_tags, $repl, $text); } return $text; } +function _insert_block_settings($format) { + +} + +function _insert_block_tips($filter, $format, $long = FALSE) { + if ($long) { + return t('You may use [block:module=delta] tags to display the contents of block delta for module module. To discover module names and deltas, visit admin/build/block and hover over a block\'s configure link and look in your browser\'s status bar. The last "word" you see is the name of the module and the number following that is the delta. If you leave off the delta in an Insert Block tag, the default delta will be used.'); + } + 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->format", array('fragment' => 'filter-insert_block')))); + } +} + /** * Implementation of hook_theme(). */ function insert_block_theme() { $themes = array( 'insert_block_block' => array( - 'arguments' => array('block'), + 'variables' => array('block' => NULL), ), ); return $themes; @@ -105,13 +92,13 @@ function insert_block_theme() { * * @ingroup themeable */ -function theme_insert_block_block($block) { +function theme_insert_block_block($vars) { $content = ''; - if (!empty($block['subject'])) { - $content .= '

'. $block['subject'] .'

'; + if (!empty($vars['block']['subject'])) { + $content .= '

'. $vars['block']['subject'] .'

'; } - if (!empty($block['content'])) { - $content .= $block['content']; + if (!empty($vars['block']['content'])) { + $content .= $vars['block']['content']; } return $content; }