diff -rup directory/directory.module directory_new/directory.module --- directory/directory.module 2008-07-16 16:08:25.000000000 +1000 +++ directory.module 2011-01-21 14:13:51.000000000 +1100 @@ -237,17 +237,68 @@ function directory_theme($existing, $typ 'arguments' => array('limit' => NULL, 'element' => 0, 'format' => '%d through %d of %d.'), ), 'directory_home_vocabulary' => array( - 'arguments' => array('vid' => NULL, 'collapse' => TRUE), + 'arguments' => array('vid' => NULL, 'collapse' => TRUE, 'display_title' => TRUE), ), 'directory_resource' => array( 'arguments' => array('tid' => NULL, 'filter' => NULL, 'fid' => NULL), ), 'directory_taxonomy_subterms' => array( - 'arguments' => array('tid' => NULL), + 'arguments' => array('tid' => NULL, 'display_title' => TRUE), ), ); } +/** + * Implemenation of hook_block(). + */ +function directory_block($op = 'list', $delta = 0, $edit = array()) { + if ($op == 'list') { + // Make a directory block for each vocabulary. + $vocabularies = taxonomy_get_vocabularies(); + foreach ($vocabularies AS $vid => $vocabulary) { + $blocks['vocab_dir_' . $vocabulary->vid] = array( + 'info' => t('Directory: Vocabulary directory: @vocab', array('@vocab' => $vocabulary->name)), + 'cache' => BLOCK_CACHE_GLOBAL, + ); + } + + $blocks['subterms'] = array( + 'info' => t('Directory: Taxonomy subterms'), + 'cache' => BLOCK_CACHE_PER_PAGE, + ); + + return $blocks; + } + else if ($op == 'view') { + // We only want to do a generic vocab delta instead of one for each vocab. + $delta_check = (substr($delta, 0, 10) == 'vocab_dir_') ? substr($delta, 0, 10) : $delta; + + switch ($delta_check) { + case 'vocab_dir_': + $block = array(); + $vid = substr($delta, 10); + $vocab = taxonomy_vocabulary_load($vid); + if ($vocab) { + $block = array( + 'subject' => t('Directory for @vocab', array('@vocab' => $vocab->name)), + 'content' => theme_directory_home_vocabulary($vocab->vid, FALSE, FALSE), + ); + } + break; + case 'subterms': + $block = array(); + if (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(2)) { + $block = array( + 'subject' => t('Subterms'), + 'content' => theme('directory_taxonomy_subterms', arg(2), FALSE), + ); + } + break; + } + return $block; + } +} + /******************************************************************** * Module Specific :: Public Functions * ******************************************************************/ @@ -298,6 +349,8 @@ function directory_page() { * * @param $vid * integer: the vocabulary ID. + * @param $display_title + * Boolean for whether or not to add a title to the list. * * @param $collapse * boolean: say if the vocabulary should follow the collapsed setting. @@ -307,7 +360,7 @@ function directory_page() { * @return $output * formatted html. */ -function theme_directory_home_vocabulary($vid, $collapse = TRUE) { +function theme_directory_home_vocabulary($vid, $collapse = TRUE, $display_title = TRUE) { static $js_added; $vocabulary = taxonomy_vocabulary_load($vid); $terms = taxonomy_get_children(0, $vid); @@ -330,8 +383,8 @@ function theme_directory_home_vocabulary } $output = '