| 1 |
<?php |
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_block(). |
* Implementation of hook_block(). |
| 7 |
function related_terms_block($op = 'list', $delta = 0, $edit = array()) { |
function related_terms_block($op = 'list', $delta = 0, $edit = array()) { |
| 8 |
|
|
| 9 |
$blocks = array( |
$blocks = array( |
| 10 |
array('info' => t('Related terms')) |
array( |
| 11 |
|
'info' => t('Related terms'), |
| 12 |
|
'cache' => BLOCK_CACHE_PER_PAGE |
| 13 |
|
) |
| 14 |
); |
); |
| 15 |
|
|
| 16 |
switch ($op) { |
switch ($op) { |
| 92 |
} |
} |
| 93 |
} |
} |
| 94 |
|
|
| 95 |
function theme_related_terms_block($terms) { |
/** |
| 96 |
|
* Implementation of hook_theme(). |
| 97 |
|
*/ |
| 98 |
|
function related_terms_theme($existing, $type, $theme, $path) { |
| 99 |
|
return array( |
| 100 |
|
'related_terms_block' => array( |
| 101 |
|
'arguments' => array('terms' => array()) |
| 102 |
|
), |
| 103 |
|
); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
function theme_related_terms_block($terms = array()) { |
| 107 |
$output = ''; |
$output = ''; |
| 108 |
foreach($terms as $term) { |
foreach($terms as $term) { |
| 109 |
$output .= sprintf( |
$output .= sprintf( |
| 120 |
|
|
| 121 |
// $sort can be name, shuffle, frequence |
// $sort can be name, shuffle, frequence |
| 122 |
function related_terms_get_related_terms($tid, $limit = 0, $sort = 'name', $vids = array()) { |
function related_terms_get_related_terms($tid, $limit = 0, $sort = 'name', $vids = array()) { |
| 123 |
|
|
| 124 |
$restrict_vids = ''; |
$restrict_vids = ''; |
| 125 |
if(count($vids) > 0) { |
if(count($vids) > 0) { |
| 126 |
$restrict_vids = ' AND td2.vid IN (' . implode(',',$vids) . ') '; |
$restrict_vids = ' AND td2.vid IN (' . implode(',',$vids) . ') '; |