/[drupal]/contributions/modules/booktree/booktree.module
ViewVC logotype

Diff of /contributions/modules/booktree/booktree.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.11.2.5, Mon Aug 10 21:57:57 2009 UTC revision 1.11.2.6, Mon Sep 14 20:11:36 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: booktree.module,v 1.11.2.4 2009/07/04 16:40:15 uccio Exp $  // $Id: booktree.module,v 1.11.2.5 2009/08/10 21:57:57 uccio Exp $
3    
4    /**
5     * @file
6     * The booktree module fot drupal render a simple tree of books
7     *
8     */
9    
10    
11    
# Line 19  function booktree_perm() { Line 25  function booktree_perm() {
25    
26    
27  function booktree_menu() {  function booktree_menu() {
   
   
28    $items['booktree'] = array(    $items['booktree'] = array(
29        'title' => t('BookTree'),        'title' => t('BookTree'),
30        'description' => t('Book Index.'),        'description' => t('Book Index.'),
# Line 28  function booktree_menu() { Line 32  function booktree_menu() {
32        'access arguments' => array('access booktree'),        'access arguments' => array('access booktree'),
33        'type' => MENU_NORMAL_ITEM,        'type' => MENU_NORMAL_ITEM,
34        );        );
   
35    $items['admin/settings/booktree'] = array(    $items['admin/settings/booktree'] = array(
36        'title' => t('BookTree'),        'title' => t('BookTree'),
37        'description' => t('Manage the tree-view of book.'),        'description' => t('Manage the tree-view of book.'),
# Line 37  function booktree_menu() { Line 40  function booktree_menu() {
40        'access arguments' => array('access administration pages'),        'access arguments' => array('access administration pages'),
41        'type' => MENU_NORMAL_ITEM,        'type' => MENU_NORMAL_ITEM,
42        );        );
   
   
         //$stylesheet = drupal_get_path('module','booktree') .'/booktree.css';  
   //drupal_add_css($stylesheet);  
   
43    return $items;    return $items;
44  }  }
45    
# Line 107  function booktree_indice() { Line 105  function booktree_indice() {
105    }    }
106    
107  function booktree_mostra_figli( $mlid, $nid, $tit, $ricursione, $maxricursione, $trimval, $mlid_start) {  function booktree_mostra_figli( $mlid, $nid, $tit, $ricursione, $maxricursione, $trimval, $mlid_start) {
108    if ($ricursione<$maxricursione){    if ($ricursione<$maxricursione) {
109      $sql= "SELECT DISTINCT n.nid as nid, m.plid as plid, m.mlid as mlid,  n.title as title ,m.weight      $sql= "SELECT DISTINCT n.nid as nid, m.plid as plid, m.mlid as mlid,  n.title as title ,m.weight
110             FROM {book} as b             FROM {book} as b
111             inner join {menu_links} as m ON b.mlid = m.mlid             inner join {menu_links} as m ON b.mlid = m.mlid
# Line 118  function booktree_mostra_figli( $mlid, $ Line 116  function booktree_mostra_figli( $mlid, $
116      $children = db_query(db_rewrite_sql($sql), $mlid);      $children = db_query(db_rewrite_sql($sql), $mlid);
117      //Now hide a root book node      //Now hide a root book node
118      if ($mlid != $mlid_start) {      if ($mlid != $mlid_start) {
119        $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>";
120        }      }
121          $ricursione++;      $ricursione++;
122          while ($child = db_fetch_object($children)) {      while ($child = db_fetch_object($children)) {
123                                  $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);
124        }      }
125          //now write content only if necessary      //now write content only if necessary
126                  if (strlen($c) > 2){      if (strlen($c) > 2) {
127        $content .= "<ul class=\"booktree\">\n". $c ."</ul>\n";        $content .= "<ul class=\"booktree\">\n". $c ."</ul>\n";
128        }      }
129      return $content;      return $content;
130    }    }
131          else{    else {
132      return '';      return '';
133    }    }
134  }  }
135    
136    function booktree_render_tree($nid = NULL) {
137      if ($nid) {
138        drupal_add_css(drupal_get_path('module', 'booktree') .'/booktree.css', 'module', 'all', FALSE);
139        $maxricursione = variable_get('booktree_deep', 5)+2;
140        $node = node_load($nid);
141        return booktree_mostra_figli($node->book['mlid'], $node->nid, $node->title, 1, $maxricursione, 256, $node->book['mlid']);
142    
143      }
144    }

Legend:
Removed from v.1.11.2.5  
changed lines
  Added in v.1.11.2.6

  ViewVC Help
Powered by ViewVC 1.1.2