You are here

function taxonomy_block_i18n_block in Taxonomy Block 6

Implementation of hook_block().

File

./taxonomy_block.module, line 52
The taxonomy_block_i18n module used for displaying Site Counter.

Code

function taxonomy_block_i18n_block($op = 'list', $delta = 0) {
  if ($op == 'list') {
    $blocks[0]['info'] = 'Taxonomy Block i18n';
    return $blocks;
  }
  if ($op == 'view') {
    $vid = variable_get('taxonomy_block_i18n_settings_vid', 1);
    $node_count = variable_get('taxonomy_block_i18n_settings_node_count', 0);
    $num_term = 20;
    switch ($delta) {
      case 0:
        $block['subject'] = 'Taxonomy Block i18n';
        $output = '';

        //Check database
        $sql = " SELECT td.tid, td.name, th.parent  from {term_data} td " . " INNER JOIN {term_hierarchy} th ON th.tid=td.tid " . " WHERE vid='%d' AND th.parent=0 ORDER BY name ASC LIMIT %d";
        $term_parents = db_query($sql, $vid, $num_term);
        $output .= '<ul class="menu">';
        while ($term_parent = db_fetch_object($term_parents)) {
          $tid_parent = $term_parent->tid;
          $name_parent = $term_parent->name;
          $output .= "<li>";
          $output .= l(tt("taxonomy:term:{$tid_parent}:name", $name_parent), "taxonomy/term/{$tid_parent}");
          if ($node_count) {
            $count = db_result(db_query("SELECT COUNT(nid) FROM {term_node} WHERE tid = %d", $tid_parent));
            $output .= " ({$count})";
          }
          $output .= "</li>";
          $sql_count_childs = " SELECT count(td.tid) from {term_data} td " . " INNER JOIN {term_hierarchy} th ON th.tid=td.tid " . " WHERE td.vid='%d' AND th.parent='%d'";
          $count_childs = db_query($sql_count_childs, $vid, $tid_parent);
          $count_child = db_result($count_childs);
          if ($count_child) {
            $sql_term_childs = " SELECT td.tid, td.name from {term_data} td " . " INNER JOIN {term_hierarchy} th ON th.tid=td.tid " . " WHERE vid='%d' AND th.parent='%d' ORDER BY name ASC LIMIT %d";
            $term_childs = db_query($sql_term_childs, $vid, $tid_parent, $num_term);
            $output .= "<ul>";
            while ($term_child = db_fetch_object($term_childs)) {
              $tid_child = $term_child->tid;
              $name_child = $term_child->name;
              $output .= "<li>";
              $output .= l(tt("taxonomy:term:{$tid_child}:name", $name_child), "taxonomy/term/{$tid_child}");
              $output .= "</li>";
            }
            $output .= "</ul>";
          }
        }
        $output .= "</ul>";

        //if(count($items)) {

        //  return theme('item_list',$items);

        //}
        $block['content'] = $output;
        break;
    }
    return $block;
  }
}