taxonomy_block.module in Taxonomy Block 6
Same filename and directory in other branches
The taxonomy_block_i18n module used for displaying Site Counter.
File
taxonomy_block.moduleView source
<?php
/**
* @file
* The taxonomy_block_i18n module used for displaying Site Counter.
*/
/**
* Implementation of hook_help().
*/
function taxonomy_block_i18n_help($section) {
switch ($section) {
case 'admin/help#taxonomy_block_i18n':
$output = "The taxonomy_block_i18n module used for displaying taxonomy in a block with 18n/multi-languages support";
return $output;
case 'admin/modules#description':
return 'The taxonomy_block_i18n module used for displaying taxonomy in a block with 18n/multi-languages support';
}
}
/**
* Implementation of hook_perm
*/
function taxonomy_block_i18n_perm() {
return array(
'access taxonomy_block_i18n',
'administer taxonomy_block_i18n',
);
}
/**
* Menu callback. Prints a listing of active nodes on the site.
*/
function taxonomy_block_i18n_menu() {
$items = array();
$items['admin/settings/taxonomy_block_i18n'] = array(
'title' => 'Taxonomy Block i18n',
'description' => 'Show taxonomy in block with i18n support',
'access arguments' => array(
'administer taxonomy_block_i18n',
),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'taxonomy_block_i18n_admin_settings',
),
'type' => MENU_NORMAL_ITEM,
'file' => 'taxonomy_block_i18n.settings.inc',
);
return $items;
}
/**
* Implementation of hook_block().
*
*/
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;
}
}
Functions
Name![]() |
Description |
---|---|
taxonomy_block_i18n_block | Implementation of hook_block(). |
taxonomy_block_i18n_help | Implementation of hook_help(). |
taxonomy_block_i18n_menu | Menu callback. Prints a listing of active nodes on the site. |
taxonomy_block_i18n_perm | Implementation of hook_perm |