| 1 |
<?php |
<?php |
| 2 |
// $Id: taxonomy_block.module,v 1.23 2009/06/24 11:49:39 thenicespider Exp $ |
// $Id: taxonomy_block.module,v 1.24 2009/06/26 09:02:02 thenicespider Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 61 |
{ |
{ |
| 62 |
$vid = variable_get('taxonomy_block_settings_vid',1); |
$vid = variable_get('taxonomy_block_settings_vid',1); |
| 63 |
$node_count = variable_get('taxonomy_block_settings_node_count',0); |
$node_count = variable_get('taxonomy_block_settings_node_count',0); |
| 64 |
$num_term = 20; |
$num_term = variable_get('taxonomy_block_settings_max_term',0); |
| 65 |
|
|
| 66 |
switch($delta) { |
switch($delta) { |
| 67 |
case 0: |
case 0: |
| 72 |
|
|
| 73 |
//Check database |
//Check database |
| 74 |
|
|
| 75 |
$sql = " SELECT td.tid, td.name, th.parent from {term_data} td " |
if ($num_term == 0) { |
| 76 |
|
$sql = " SELECT td.tid, td.name, th.parent from {term_data} td " |
| 77 |
." INNER JOIN {term_hierarchy} th ON th.tid=td.tid " |
." INNER JOIN {term_hierarchy} th ON th.tid=td.tid " |
| 78 |
." WHERE vid='%d' AND th.parent=0 ORDER BY name ASC LIMIT %d"; |
." WHERE vid='%d' AND th.parent=0 ORDER BY name ASC"; |
| 79 |
|
} else { |
| 80 |
|
$sql = " SELECT td.tid, td.name, th.parent from {term_data} td " |
| 81 |
|
." INNER JOIN {term_hierarchy} th ON th.tid=td.tid " |
| 82 |
|
." WHERE vid='%d' AND th.parent=0 ORDER BY name ASC LIMIT %d"; |
| 83 |
|
} |
| 84 |
|
|
| 85 |
$term_parents = db_query($sql, $vid, $num_term ); |
$term_parents = db_query($sql, $vid, $num_term ); |
| 86 |
|
|
| 87 |
|
|
| 109 |
$count_child = db_result($count_childs); |
$count_child = db_result($count_childs); |
| 110 |
|
|
| 111 |
if ($count_child) { |
if ($count_child) { |
| 112 |
$sql_term_childs = " SELECT td.tid, td.name from {term_data} td " |
if ($num_term == 0) { |
| 113 |
." INNER JOIN {term_hierarchy} th ON th.tid=td.tid " |
$sql_term_childs = " SELECT td.tid, td.name from {term_data} td " |
| 114 |
." WHERE vid='%d' AND th.parent='%d' ORDER BY name ASC LIMIT %d"; |
." INNER JOIN {term_hierarchy} th ON th.tid=td.tid " |
| 115 |
|
." WHERE vid='%d' AND th.parent='%d' ORDER BY name ASC"; |
| 116 |
|
} else { |
| 117 |
|
$sql_term_childs = " SELECT td.tid, td.name from {term_data} td " |
| 118 |
|
." INNER JOIN {term_hierarchy} th ON th.tid=td.tid " |
| 119 |
|
." WHERE vid='%d' AND th.parent='%d' ORDER BY name ASC LIMIT %d"; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
$term_childs = db_query($sql_term_childs, $vid, $tid_parent, $num_term ); |
$term_childs = db_query($sql_term_childs, $vid, $tid_parent, $num_term ); |
| 123 |
$output .= '<ul>'; |
$output .= '<ul>'; |
| 124 |
while ($term_child = db_fetch_object($term_childs)) { |
while ($term_child = db_fetch_object($term_childs)) { |