diff -rupN taxonomy_dhtml_old//taxonomy_dhtml.admin.inc taxonomy_dhtml/taxonomy_dhtml.admin.inc --- taxonomy_dhtml_old//taxonomy_dhtml.admin.inc 2008-12-13 08:54:10.000000000 +1100 +++ taxonomy_dhtml.admin.inc 2009-03-16 12:02:37.000000000 +1100 @@ -23,6 +23,14 @@ function taxonomy_dhtml_admin() { $form[$vocabulary->vid]['noi'] = array('#type' => 'textfield', '#size' => 3, '#maxlength' => 3, '#default_value' => (is_null($vocabulary->noi) ? 25 : $vocabulary->noi)); $form[$vocabulary->vid]['exposeBlock'] = array('#type' => 'checkbox', '#default_value' => is_null($vocabulary->expblock) ? FALSE : $vocabulary->expblock); $form[$vocabulary->vid]['depth'] = array('#type' => 'select', '#default_value' => is_null($vocabulary->depth) ? 0 : $vocabulary->depth, '#options' => array('0' => t('None'), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => 'All')); + // If the taxonomy_redirect module is available make the option a checkbox. Otherwise make it hidden. + // This makes sure that if the form is saved when taxonomy_redirect is not enabled the value in the taxonomy_redirect field isn't lost + if (module_exists('taxonomy_redirect')) { + $form[$vocabulary->vid]['taxonomy_redirect'] = array('#type' => 'checkbox', '#default_value' => is_null($vocabulary->taxonomy_redirect) ? FALSE : $vocabulary->taxonomy_redirect); + } + else { + $form[$vocabulary->vid]['taxonomy_redirect'] = array('#type' => 'hidden', '#value' => is_null($vocabulary->taxonomy_redirect) ? FALSE : $vocabulary->taxonomy_redirect); + } } $form['submit'] = array('#type' => 'submit', '#value' => t('Save')); @@ -46,6 +54,7 @@ function theme_taxonomy_dhtml_admin($for $row[] = drupal_render($vocabulary['noi']); $row[] = drupal_render($vocabulary['depth']); $row[] = drupal_render($vocabulary['exposeBlock']); + $row[] = drupal_render($vocabulary['taxonomy_redirect']); $rows[] = array('data' => $row, 'class' => 'draggable'); } } @@ -53,7 +62,12 @@ function theme_taxonomy_dhtml_admin($for $rows[] = array(array('data' => t('No vocabularies available.'), 'colspan' => '3')); } - $header = array(t('Name'), t('Number of items to display'), t('Depth'), t('Expose Block')); + if (module_exists('taxonomy_redirect')) { + $header = array(t('Name'), t('Number of items to display'), t('Depth'), t('Expose Block'), t('Use taxonomy redirect')); + } + else { + $header = array(t('Name'), t('Number of items to display'), t('Depth'), t('Expose Block')); + } return theme('table', $header, $rows, array('id' => 'taxonomy')) . drupal_render($form); } @@ -67,7 +81,7 @@ function taxonomy_dhtml_admin_submit($fo foreach (array_keys($form_state['values']) as $ak) { if (is_array($form_state['values'][$ak])) { db_query("DELETE FROM {taxonomy_dhtml} WHERE vid=%d", $ak); - db_query("INSERT INTO {taxonomy_dhtml} (vid, noi, depth, expblock) VALUES (%d, %d, %d, %d)", $ak, $form_state['values'][$ak]['noi'], $form_state['values'][$ak]['depth'], $form_state['values'][$ak]['exposeBlock']); + db_query("INSERT INTO {taxonomy_dhtml} (vid, noi, depth, expblock, taxonomy_redirect) VALUES (%d, %d, %d, %d, %d)", $ak, $form_state['values'][$ak]['noi'], $form_state['values'][$ak]['depth'], $form_state['values'][$ak]['exposeBlock'], $form_state['values'][$ak]['taxonomy_redirect']); } } cache_clear_all(); diff -rupN taxonomy_dhtml_old//taxonomy_dhtml.install taxonomy_dhtml/taxonomy_dhtml.install --- taxonomy_dhtml_old//taxonomy_dhtml.install 2008-12-13 08:54:10.000000000 +1100 +++ taxonomy_dhtml.install 2009-03-16 11:09:00.000000000 +1100 @@ -28,6 +28,12 @@ function taxonomy_dhtml_update_6100() { return $ret; } +function taxonomy_dhtml_update_6101() { + $ret = array(); + db_add_field($ret, 'taxonomy_dhtml', 'taxonomy_redirect', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => t('Whether or not to use taxonomy redirect for the menu links.'), 'default' => 0)); + return $ret; +} + /** * Implementation of hook_schema(). */ @@ -63,6 +69,13 @@ function taxonomy_dhtml_schema() { 'description' => t('Boolean to indicate if we are making this available on the block page.'), 'default' => 0, ), + 'taxonomy_redirect' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'description' => t('Whether or not to use taxonomy redirect for the menu links.'), + 'default' => 0, + ), ), ); diff -rupN taxonomy_dhtml_old//taxonomy_dhtml.module taxonomy_dhtml/taxonomy_dhtml.module --- taxonomy_dhtml_old//taxonomy_dhtml.module 2008-12-13 08:54:10.000000000 +1100 +++ taxonomy_dhtml.module 2009-03-16 12:03:19.000000000 +1100 @@ -58,15 +58,21 @@ function taxonomy_dhtml_vocab_vert($voca * The depth at which we are processing. We stop recursion if this is zero. */ function taxonomy_dhtml_process_term($term, $depth) { + $dhtml_vocab = taxonomy_dhtml_get_vocabulary($term->vid); + $use_taxonomy_redirect = FALSE; + if (module_exists('taxonomy_redirect') && $dhtml_vocab) { + $use_taxonomy_redirect = TRUE; + } + switch ($depth) { case 0: - $url = "taxonomy/term/$term->tid"; + $url = $use_taxonomy_redirect ? taxonomy_term_path($term) : "taxonomy/term/$term->tid"; break; case 10: - $url = "taxonomy/term/$term->tid/all"; + $url = $use_taxonomy_redirect ? taxonomy_term_path($term) : "taxonomy/term/$term->tid/all"; break; default: - $url = "taxonomy/term/$term->tid/$depth"; + $url = $use_taxonomy_redirect ? taxonomy_term_path($term) : "taxonomy/term/$term->tid/$depth"; } $count = taxonomy_dhtml_term_count_nodes($term, $depth); @@ -113,6 +119,7 @@ function taxonomy_dhtml_help($path, $arg case 'admin/settings/taxonomy_dhtml': $output = '

'; $output .= "This module provides a DHTML representation of this site's taxonomy. ". l("Blocks", "admin/build/block"). " are also provided for each vocabulary."; + $output .= (module_exists('taxonomy_redirect')) ? " Check the 'Use taxonomy redirect' checkbox if you would like ". l("Taxonomy Redirect", "admin/build/taxonomy_redirect"). " to override the links in your menu." : ""; return $output; } } @@ -141,10 +148,10 @@ function taxonomy_dhtml_get_noi($vid) { */ function taxonomy_dhtml_get_vocabularies($exposed = FALSE) { if ($exposed) { - $result = db_query(db_rewrite_sql('SELECT v.*, t.noi, t.depth, t.expblock FROM {vocabulary} v LEFT JOIN {taxonomy_dhtml} t ON v.vid = t.vid WHERE t.expblock=1 AND t.noi>0 ORDER BY v.weight, v.name', 'v', 'vid')); + $result = db_query(db_rewrite_sql('SELECT v.*, t.noi, t.depth, t.expblock, t.taxonomy_redirect FROM {vocabulary} v LEFT JOIN {taxonomy_dhtml} t ON v.vid = t.vid WHERE t.expblock = 1 AND t.noi > 0 ORDER BY v.weight, v.name', 'v', 'vid')); } else { - $result = db_query(db_rewrite_sql('SELECT v.*, t.noi, t.depth, t.expblock FROM {vocabulary} v LEFT JOIN {taxonomy_dhtml} t ON v.vid = t.vid ORDER BY v.weight, v.name', 'v', 'vid')); + $result = db_query(db_rewrite_sql('SELECT v.*, t.noi, t.depth, t.expblock, t.taxonomy_redirect FROM {vocabulary} v LEFT JOIN {taxonomy_dhtml} t ON v.vid = t.vid ORDER BY v.weight, v.name', 'v', 'vid')); } $vocabularies = array(); @@ -157,6 +164,23 @@ function taxonomy_dhtml_get_vocabularies } /** + * Retrieve a taxonomy_dhtml vocabulary object. + * + * @param vid + * The vocabulary ID of the taxonomy_dhtml vacabulary object you want to retrieve. + * + * @return + * A taxonomy_dhtml vocabulary object or FALSE if there wasn't one that matched the given vid. + */ +function taxonomy_dhtml_get_vocabulary($vid) { + $result = db_query("SELECT * FROM {taxonomy_dhtml} v WHERE v.vid = '%s'", $vid); + + $vocab = db_fetch_object($result); + + return $vocab; +} + +/** * Retrieve term count recursively * Rewrite of taxonomy_term_count_nodes to allow us to eliminate children from the count. *