/[drupal]/contributions/modules/taxonomy_block/taxonomy_block.module
ViewVC logotype

Diff of /contributions/modules/taxonomy_block/taxonomy_block.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.25, Fri Aug 14 02:56:43 2009 UTC revision 1.26, Wed Nov 11 09:25:16 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: taxonomy_block.module,v 1.24 2009/06/26 09:02:02 thenicespider Exp $  // $Id: taxonomy_block.module,v 1.25 2009/08/14 02:56:43 thenicespider Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 63  function taxonomy_block_block($op = 'lis Line 63  function taxonomy_block_block($op = 'lis
63      $node_count = variable_get('taxonomy_block_settings_node_count',0);      $node_count = variable_get('taxonomy_block_settings_node_count',0);
64      $num_term   = variable_get('taxonomy_block_settings_max_term',0);      $num_term   = variable_get('taxonomy_block_settings_max_term',0);
65    
66        $order_by   = variable_get('taxonomy_block_settings_order_by', 0)==0 ? 'name' : 'weight';
67        $order_type = variable_get('taxonomy_block_settings_order_type', 0)==0 ? 'ASC' : 'DESC';
68    
69    
70      switch($delta) {      switch($delta) {
71        case 0:        case 0:
72          $block['subject'] = 'Taxonomy Block';          $block['subject'] = t('Taxonomy Block');
73    
74          $output  = '';          $output  = '';
75    
# Line 75  function taxonomy_block_block($op = 'lis Line 79  function taxonomy_block_block($op = 'lis
79        if ($num_term == 0) {        if ($num_term == 0) {
80          $sql = " SELECT td.tid, td.name, th.parent  from {term_data} td "          $sql = " SELECT td.tid, td.name, th.parent  from {term_data} td "
81              ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "              ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "
82              ." WHERE vid='%d' AND th.parent=0 ORDER BY name ASC";              ." WHERE vid='%d' AND th.parent=0 ORDER BY %s %s";
83        } else {        } else {
84          $sql = " SELECT td.tid, td.name, th.parent  from {term_data} td "          $sql = " SELECT td.tid, td.name, th.parent  from {term_data} td "
85              ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "              ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "
86              ." WHERE vid='%d' AND th.parent=0 ORDER BY name ASC LIMIT %d";              ." WHERE vid='%d' AND th.parent=0 ORDER BY %s %s LIMIT %d";
87        }        }
88    
89        $term_parents = db_query($sql, $vid, $num_term );        $term_parents = db_query($sql, $vid, $order_by, $order_type, $num_term );
90    
   
91        $output .= '<ul class="menu">';        $output .= '<ul class="menu">';
92        while ($term_parent = db_fetch_object($term_parents)) {        while ($term_parent = db_fetch_object($term_parents)) {
93          $tid_parent = $term_parent->tid;          $tid_parent = $term_parent->tid;
94          $name_parent= $term_parent->name;          $name_parent= $term_parent->name;
95    
96          $output .= '<li>';          $output .= '<li>';
97            $term_parent = taxonomy_get_term($tid_parent);
98    
99          if (module_exists("i18n")) {          if (module_exists("i18n")) {
100            $output .= l(tt("taxonomy:term:$tid_parent:name", $name_parent), "taxonomy/term/$tid_parent");            $output .= l(tt("taxonomy:term:$tid_parent:name", $name_parent), taxonomy_term_path($term_parent));
101          } else {          } else {
102            $output .= l(t($name_parent), "taxonomy/term/$tid_parent");            //$output .= l(t($name_parent), "taxonomy/term/$tid_parent");
103              $output .= l(t($name_parent), taxonomy_term_path($term_parent));
104          }          }
105          if ($node_count) {          if ($node_count) {
106            $total_parent = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $tid_parent));            $total_parent = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $tid_parent));
# Line 105  function taxonomy_block_block($op = 'lis Line 111  function taxonomy_block_block($op = 'lis
111          $sql_count_childs = " SELECT count(td.tid) from {term_data} td "          $sql_count_childs = " SELECT count(td.tid) from {term_data} td "
112                             ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "                             ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "
113                             ." WHERE td.vid='%d' AND th.parent='%d'";                             ." WHERE td.vid='%d' AND th.parent='%d'";
114          $count_childs = db_query($sql_count_childs, $vid, $tid_parent);          $count_child = db_result(db_query($sql_count_childs, $vid, $tid_parent));
         $count_child  = db_result($count_childs);  
115    
116          if ($count_child) {          if ($count_child) {
117            if ($num_term == 0) {            if ($num_term == 0) {
118              $sql_term_childs = " SELECT td.tid, td.name from {term_data} td "              $sql_term_childs = " SELECT td.tid, td.name from {term_data} td "
119                                ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "                                ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "
120                                ." WHERE vid='%d' AND th.parent='%d' ORDER BY name ASC";                                ." WHERE vid='%d' AND th.parent='%d' ORDER BY %s %s";
121            } else {            } else {
122              $sql_term_childs = " SELECT td.tid, td.name from {term_data} td "              $sql_term_childs = " SELECT td.tid, td.name from {term_data} td "
123                                ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "                                ." INNER JOIN {term_hierarchy} th ON th.tid=td.tid "
124                                ." WHERE vid='%d' AND th.parent='%d' ORDER BY name ASC LIMIT %d";                                ." WHERE vid='%d' AND th.parent='%d' ORDER BY %s %s LIMIT %d";
125            }            }
126    
127            $term_childs = db_query($sql_term_childs, $vid, $tid_parent, $num_term );            $term_childs = db_query($sql_term_childs, $vid, $tid_parent, $order_by, $order_type, $num_term );
128            $output .= '<ul>';            $output .= '<ul>';
129            while ($term_child = db_fetch_object($term_childs)) {            while ($term_child = db_fetch_object($term_childs)) {
130              $tid_child = $term_child->tid;              $tid_child = $term_child->tid;
131              $name_child = $term_child->name;              $name_child = $term_child->name;
132    
133              $output .= '<li>';              $output .= '<li>';
134                $term_child = taxonomy_get_term($tid_child);
135    
136              if (module_exists("i18n")) {              if (module_exists("i18n")) {
137                $output .= l(tt("taxonomy:term:$tid_child:name", $name_child), "taxonomy/term/$tid_child");                $output .= l(tt("taxonomy:term:$tid_child:name", $name_child), taxonomy_term_path($term_child));
138              } else {              } else {
139                $output .= l(t($name_child), "taxonomy/term/$tid_child");                $output .= l(t($name_child), taxonomy_term_path($term_child));
140              }              }
141              if ($node_count) {              if ($node_count) {
142                $total_child = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $tid_child));                $total_child = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $tid_child));

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.2