| 1 |
<?php |
<?php |
| 2 |
// $Id: booktree.module,v 1.11.2.3 2009/07/04 16:18:16 uccio Exp $ |
// $Id: booktree.module,v 1.11.2.4 2009/07/04 16:40:15 uccio Exp $ |
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 94 |
} |
} |
| 95 |
else { |
else { |
| 96 |
$booktree_start = variable_get('booktree_start', 1); |
$booktree_start = variable_get('booktree_start', 1); |
| 97 |
$maxricursione=variable_get('booktree_deep', 5)+2; |
$maxricursione = variable_get('booktree_deep', 5)+2; |
| 98 |
$trimval=variable_get('booktree_trim', 35); |
$trimval = variable_get('booktree_trim', 35); |
| 99 |
} |
} |
| 100 |
|
|
| 101 |
$node = node_load(array('nid' => $booktree_start)); |
$node = node_load(array('nid' => $booktree_start)); |
| 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->book['mlid'],$node->nid,$node->title,$ricursione,$maxricursione,$trimval,$node->book['mlid']); |
$content .= booktree_mostra_figli($node->book['mlid'], $node->nid, $node->title, $ricursione, $maxricursione, $trimval, $node->book['mlid']); |
| 106 |
return $content; |
return $content; |
| 107 |
} |
} |
| 108 |
|
|
| 109 |
function booktree_mostra_figli( $mlid,$nid,$tit,$ricursione,$maxricursione,$trimval,$mlid_start) { |
function booktree_mostra_figli( $mlid, $nid, $tit, $ricursione, $maxricursione, $trimval, $mlid_start) { |
| 110 |
if ($ricursione<$maxricursione){ |
if ($ricursione<$maxricursione){ |
| 111 |
$sql= "SELECT DISTINCT n.nid as nid, m.plid as plid, m.mlid as mlid, n.title as title |
$sql= "SELECT DISTINCT n.nid as nid, m.plid as plid, m.mlid as mlid, n.title as title ,m.weight |
| 112 |
FROM {book} as b |
FROM {book} as b |
| 113 |
inner join {menu_links} as m ON b.mlid = m.mlid |
inner join {menu_links} as m ON b.mlid = m.mlid |
| 114 |
inner join {node} as n ON n.nid = b.nid |
inner join {node} as n ON n.nid = b.nid |
| 118 |
$children = db_query(db_rewrite_sql($sql), $mlid); |
$children = db_query(db_rewrite_sql($sql), $mlid); |
| 119 |
//Now hide a root book node |
//Now hide a root book node |
| 120 |
if ($mlid != $mlid_start) { |
if ($mlid != $mlid_start) { |
| 121 |
$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\">". l(truncate_utf8($tit, $trimval, TRUE, TRUE), 'node/'. $nid , $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE ) ."</li>"; |
| 122 |
} |
} |
| 123 |
$ricursione++; |
$ricursione++; |
| 124 |
while ($child = db_fetch_object($children)) { |
while ($child = db_fetch_object($children)) { |
| 125 |
$c .= booktree_mostra_figli($child->mlid,$child->nid,$child->title,$ricursione,$maxricursione,$trimval,$mlid_start); |
$c .= booktree_mostra_figli($child->mlid, $child->nid, $child->title, $ricursione, $maxricursione, $trimval, $mlid_start); |
| 126 |
} |
} |
| 127 |
//now write content only if necessary |
//now write content only if necessary |
| 128 |
if (strlen($c) > 2){ |
if (strlen($c) > 2){ |
| 129 |
$content .= "<ul class=\"booktree\">\n". $c. "</ul>\n"; |
$content .= "<ul class=\"booktree\">\n". $c ."</ul>\n"; |
| 130 |
} |
} |
| 131 |
return $content; |
return $content; |
| 132 |
} |
} |
| 133 |
else{ |
else{ |
| 134 |
return ''; |
return ''; |
| 135 |
} |
} |
| 136 |
} |
} |