// Only display this block when the user is browsing a book:
if(arg(0)=='book'&&arg(1)=='view'&&$nid=arg(2)){
$page=db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid"));
$path=book_location($page);
$path[]=$page;
foreach($pathas$key=>$node){
$expand[]=$node->nid;
}
$title=$path[0]->title;
$table=book_tree($expand[0],5,$expand);
}
if($op=='list'){
$block[0]['info']=t('Book navigation');
}
else{
$block['subject']=$title;
$block['content']=$table;
}
return$block;
}
functionbook_load($node){
global$user;
...
...
@@ -286,6 +314,8 @@ function book_revision_load($page, $conditions = array()) {
** Return the path (call stack) to a certain book page.
*/
functionbook_location($node,$nodes=array()){
// TODO: eliminate the recursion
$parent=db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d",$node->parent));
if($parent->title){
$nodes=book_location($parent,$nodes);
...
...
@@ -295,6 +325,8 @@ function book_location($node, $nodes = array()) {
}
functionbook_location_down($node,$nodes=array()){
// TODO: eliminate the recursion
$last_direct_child=db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight DESC, n.title DESC",$node->nid));
if($last_direct_child){
array_push($nodes,$last_direct_child);
...
...
@@ -484,32 +516,29 @@ function book_navigation($node) {
$node->breadcrumb="";// Overwrite the trail with a book trail.
$result=db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = '1' AND n.moderate = '0' ORDER BY b.weight, n.title");
// Only display this block when the user is browsing a book:
if(arg(0)=='book'&&arg(1)=='view'&&$nid=arg(2)){
$page=db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid"));
$path=book_location($page);
$path[]=$page;
foreach($pathas$key=>$node){
$expand[]=$node->nid;
}
$title=$path[0]->title;
$table=book_tree($expand[0],5,$expand);
}
if($op=='list'){
$block[0]['info']=t('Book navigation');
}
else{
$block['subject']=$title;
$block['content']=$table;
}
return$block;
}
functionbook_load($node){
global$user;
...
...
@@ -286,6 +314,8 @@ function book_revision_load($page, $conditions = array()) {
** Return the path (call stack) to a certain book page.
*/
functionbook_location($node,$nodes=array()){
// TODO: eliminate the recursion
$parent=db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.nid = %d",$node->parent));
if($parent->title){
$nodes=book_location($parent,$nodes);
...
...
@@ -295,6 +325,8 @@ function book_location($node, $nodes = array()) {
}
functionbook_location_down($node,$nodes=array()){
// TODO: eliminate the recursion
$last_direct_child=db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight DESC, n.title DESC",$node->nid));
if($last_direct_child){
array_push($nodes,$last_direct_child);
...
...
@@ -484,32 +516,29 @@ function book_navigation($node) {
$node->breadcrumb="";// Overwrite the trail with a book trail.
$result=db_query("SELECT n.nid, n.title, b.parent FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = '1' AND n.moderate = '0' ORDER BY b.weight, n.title");