? refine_by_taxo_tagadelic_integration.patch Index: refine_by_taxo.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/refine_by_taxo/refine_by_taxo.module,v retrieving revision 1.4 diff -u -F^f -r1.4 refine_by_taxo.module --- refine_by_taxo.module 26 Aug 2006 13:12:56 -0000 1.4 +++ refine_by_taxo.module 26 Sep 2006 20:33:18 -0000 @@ -69,6 +69,22 @@ function refine_by_taxo_configure_blocks '#options' => _refine_by_taxo_options(), '#description' => t('The type of relation to refine trough.'), ); + + if (module_exist('tagadelic')) { + $form['render'] = array( + '#type' => 'radios', + '#title' => t('Rendered as:'), + '#default_value' => variable_get('refine_by_taxo_render_'. $delta, 'list'), + '#options' => array('list' => t('list'), 'tagcloud' => t('tagcloud')), + '#description' => t('The way to display the tags in the block.'), + ); + } + else { + $form['render'] = array( + '#value' => t('If you want to present terms as a weighted tagcloud, please install %tagadelic', array('%tagadelic' => l(t('tagadelic'), 'http://www.webschuur.com/modules/tagadelic'))), + ); + } + return $form; } @@ -79,6 +95,7 @@ function refine_by_taxo_save_blocks($del variable_set('refine_by_taxo_block_tags_'. $delta, $edit['terms']); variable_set('refine_by_taxo_block_title_'. $delta, $edit['title']); variable_set('refine_by_taxo_type_'. $delta, $edit['type']); + variable_set('refine_by_taxo_render_'. $delta, $edit['list']); } /** @@ -113,7 +130,12 @@ function refine_by_taxo_view_blocks($del break; } - $block['content'] = refine_by_taxo_build_body($terms, $op); + if (variable_get('refine_by_taxo_render_'. $delta, 'list') == 'list') { + $block['content'] = refine_by_taxo_build_list($terms, $op); + } + else { + $block['content'] = refine_by_taxo_build_cloud($terms, $op); + } $block['subject'] = variable_get('refine_by_taxo_block_title_'. $delta, t('refine with terms from %voc', array('%voc' => $voc->name))); return $block; } @@ -124,15 +146,13 @@ function refine_by_taxo_view_blocks($del /** * Returns a string ready for the body of a block */ -function refine_by_taxo_build_body($terms, $op) { - //placeholder for tagadelic integration - +function refine_by_taxo_build_list($terms, $op) { foreach ($terms as $term) { // BAH Drupal encodes teh paths, what a crap. // $items[] = l($term->name, refine_by_taxo_build_url($term->tid, $op)); $items[] = ''. $term->name .''; } - return theme('item_list', $items); + return count($items) ? theme('item_list', $items) : ''; } /** @@ -189,6 +209,7 @@ function refine_by_taxo_find_related_ter if ($conditions) { $sql = db_escape_string('SELECT tn.tid FROM {term_node} tn INNER JOIN {term_data} td ON td.tid = tn.tid WHERE' . $conditions); $result = db_query(db_rewrite_sql($sql)); + //This is where we should look for tagcloud-option and if set true where we should call the tagadelic APIS while ($i <= variable_get('refine_by_taxo_block_tags_'. $delta, 12) && ($tid = db_fetch_object($result))) { $terms[$tid->tid] = taxonomy_get_term($tid->tid); $i++; @@ -204,6 +225,8 @@ function refine_by_taxo_find_related_ter function refine_by_taxo_find_related_terms_by_relation($delta) { $tids = $terms = array(); $used_tids = refine_by_taxo_current_terms(FALSE); + //This is where we should look for tagcloud-option and if set true where we should call the tagadelic APIS. In this case, we also need a private SQL query here. + foreach ($used_tids as $used_tid) { array_merge($tids, taxonomy_get_related($tid)); } @@ -223,6 +246,7 @@ function refine_by_taxo_find_related_ter function refine_by_taxo_find_related_terms_by_hierarchy() { $tids = $terms = array(); $used_tids = refine_by_taxo_current_terms(FALSE); + //This is where we should look for tagcloud-option and if set true where we should call the tagadelic APIS. In this case, we also need a private SQL query here. foreach ($used_tids as $used_tid) { array_merge($tids, taxonomy_get_children($tid)); }