| 1 |
<?php |
<?php |
| 2 |
// $Id: booktree.module,v 1.5.2.2 2009/07/04 16:09:16 uccio Exp $ |
// $Id: booktree.module,v 1.5.2.3 2009/07/04 16:54:00 uccio Exp $ |
| 3 |
|
|
| 4 |
|
|
| 5 |
function booktree_help($section) { |
function booktree_help($section) { |
| 102 |
drupal_set_title(check_plain($node->title)); |
drupal_set_title(check_plain($node->title)); |
| 103 |
$content = '<p>'. check_markup($node->body, $node->format, FALSE) .'</p>'; |
$content = '<p>'. check_markup($node->body, $node->format, FALSE) .'</p>'; |
| 104 |
$ricursione=1; |
$ricursione=1; |
| 105 |
$content .= booktree_mostra_figli($node->nid,$node->title,$ricursione,$maxricursione,$trimval,$booktree_start); |
$content .= _booktree_mostra_figli($node->nid,$node->title,$ricursione,$maxricursione,$trimval,$booktree_start); |
| 106 |
print theme('page', $content); |
print theme('page', $content); |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
} |
} |
| 111 |
|
|
| 112 |
|
function booktree_render_tree($nid = NULL) { |
| 113 |
|
if ($nid) { |
| 114 |
|
drupal_add_css(drupal_get_path('module', 'booktree') .'/booktree.css', 'module', 'all', FALSE); |
| 115 |
|
$maxricursione = variable_get('booktree_deep', 5)+2; |
| 116 |
|
$node = node_load($nid); |
| 117 |
|
return _booktree_mostra_figli($node->nid, $node->title, 1, $maxricursione, 256, $node->nid); |
| 118 |
|
|
| 119 |
|
} |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
|
| 123 |
function booktree_mostra_figli( $nid,$tit,$ricursione,$maxricursione,$trimval,$booktree_start ) { |
function _booktree_mostra_figli( $nid,$tit,$ricursione,$maxricursione,$trimval,$booktree_start ) { |
| 124 |
if ($ricursione<$maxricursione) |
if ($ricursione<$maxricursione) |
| 125 |
{ |
{ |
| 126 |
$sql = 'SELECT distinct n.nid, b.weight, n.title |
$sql = 'SELECT distinct n.nid, b.weight, n.title |
| 130 |
ORDER BY b.weight, n.title'; |
ORDER BY b.weight, n.title'; |
| 131 |
$children = db_query(db_rewrite_sql($sql), $nid); |
$children = db_query(db_rewrite_sql($sql), $nid); |
| 132 |
if ($nid != $booktree_start) { |
if ($nid != $booktree_start) { |
| 133 |
$content .= "<li class=\"booktree\">" . l(truncate_utf8($tit, $trimval, TRUE, TRUE),'node/'.$nid , $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE ) ."</li>"; |
$content .= "<li class=\"booktree tree-level-". ($ricursione - 1) ."\">" . l(truncate_utf8($tit, $trimval, TRUE, TRUE), 'node/'. $nid , $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE ) ."</li>"; |
| 134 |
} |
} |
| 135 |
$content .="<ul class=\"booktree\">\n"; |
$content .="<ul class=\"booktree\">\n"; |
| 136 |
$ricursione++; |
$ricursione++; |
| 137 |
while ($child = db_fetch_object($children)) { |
while ($child = db_fetch_object($children)) { |
| 138 |
$content .= booktree_mostra_figli($child->nid,$child->title,$ricursione,$maxricursione,$trimval,$booktree_start);} |
$content .= _booktree_mostra_figli($child->nid,$child->title,$ricursione,$maxricursione,$trimval,$booktree_start);} |
| 139 |
$content .="</ul>\n"; |
$content .="</ul>\n"; |
| 140 |
return $content;} |
return $content;} |
| 141 |
else { |
else { |
| 142 |
return ''; |
return ''; |