iliaa           Wed Feb  9 15:03:44 2005 EDT

  Modified files:              
    /livedocs   livedoc_funcs.php 
  Log:
  Fixed bug #30204
  
  
http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.20&r2=1.21&ty=u
Index: livedocs/livedoc_funcs.php
diff -u livedocs/livedoc_funcs.php:1.20 livedocs/livedoc_funcs.php:1.21
--- livedocs/livedoc_funcs.php:1.20     Wed Feb  9 14:47:38 2005
+++ livedocs/livedoc_funcs.php  Wed Feb  9 15:03:43 2005
@@ -11,13 +11,35 @@
 include LIVEDOC_SOURCE . '/handlers.php';
 include LIVEDOC_SOURCE . '/themes/' . THEME_NAME . '/html_format.php';
 
+/* if THEME_NAME/html_format.php doesn't redefine these */
+if (!defined('NAV_TRUNCATE')) {
+       define('NAV_TRUNCATE', 25);
+}
+if (!defined('NAV_SPACE')) {
+       define('NAV_SPACE', ' ');
+}
+if (!defined('NAV_START')) {
+       define('NAV_START', '<table class="nav" border="0" cellpadding="0" 
cellspacing="0" width="150">');
+}
+if (!defined('NAV_END')) {
+       define('NAV_END', "</table>\n");
+}
+if (!defined('NAV_CHILDREN_EMBEDED')) {
+       define('NAV_CHILDREN_EMBEDED', false);
+}
+if (!function_exists('nav_item')) {
+       function nav_item($data, $class ) {
+               return "<tr><td class='$class'>$data</td></tr>\n";
+       }
+}
+
 /*****************************************************************************
  * Helper functions for navigation
  */
 function do_nav($idx, $fb_idx, $lang, $current_page, &$nav, &$children) 
 {
        $children = array();
-       $nav = "<table class='nav' border='0' cellpadding='0' cellspacing='0' 
width='150'>";
+       $nav = NAV_START;
 
        /* Get the fileinfo for the reference */
        $tr = sqlite_array_query($idx, "SELECT title, filename, idents.fileid, 
files.dirid from idents left join files where id='$current_page' and 
idents.fileid=files.fileid", SQLITE_NUM);
@@ -33,37 +55,53 @@
        /* Get parent ID and child IDs */
        /* - first we get the first three parts of the path */
        $last_item = 'manual';
+       $head_class = 'header home';
        if (($r = sqlite_single_query($idx, "SELECT path FROM toc WHERE 
docbook_id = '$current_page' LIMIT 1"))) {
                $path = explode(",", $r);
                foreach ($path as $item) {
-                       $nav .= do_nav_line($item, 'up', $current_page, $lang, 
$dummy);
+                       $nav .= do_nav_line($item, $head_class, $current_page, 
$lang, $dummy);
                        $last_item = $item;
+                       $head_class = 'header up';
                }
        } else {
                $nav .= do_nav_line('manual', 'up', $current_page, $lang, 
$dummy);
        }
 
+       $after_child_class = '';
        /* With $last_item we're going to show all brothers */
        $r = (array) sqlite_single_query($idx, "SELECT docbook_id FROM toc 
WHERE parent_docbook_id = '$last_item' ORDER BY id");
        foreach ($r as $val) {
-               $nav .= do_nav_line($val, 'down', $current_page, $lang, $dummy);
+               $nav .= do_nav_line($val, 'down'.$after_child_class, 
$current_page, $lang, $dummy);
+               $after_child_class = '';
+
+               /* Include the children here */ 
+               if (NAV_CHILDREN_EMBEDED && $current_page == $val) {
+                       do_nav_children($idx, $val, $lang, $current_page, $nav, 
$children);
+               }
+
        }
 
        /* And finally all children, but only if $current_page != $last_item
         * because showing the same thing twice makes no sense */
-       if ($current_page != $last_item && $current_page != 'manual') {
-               $r = (array) sqlite_single_query($idx, "SELECT docbook_id FROM 
toc WHERE parent_docbook_id = '$current_page' ORDER BY id");
-               foreach ($r as $val) {
-                       $nav .= do_nav_line($val, 'downdown', $current_page, 
$lang, $title);
-                       $children[$val] = $title;
-               }
+       if ( !NAV_CHILDREN_EMBEDED && $current_page != $last_item) {
+               do_nav_children($idx, $val, $lang, $current_page, $nav, 
$children);
        }
 
-       $nav .= "</table>\n";
+
+       $nav .= NAV_END;
        return $tr[0];
 
 }
 
+function do_nav_children($idx, $parent, $lang, $current_page, &$nav, 
&$children)  {
+       if ($current_page != 'manual' ) {
+               $rsub = (array) sqlite_single_query($idx, "SELECT docbook_id 
FROM toc WHERE parent_docbook_id = '$current_page' ORDER BY id");
+               foreach ($rsub as $valsub) {
+                       $nav .= do_nav_line($valsub, 'downdown', $current_page, 
$lang, $title);
+                       $children[$parent] = $title;
+               }
+       }
+}
 
 function generate_url_for_id($lang, $ref) 
 {
@@ -124,9 +162,9 @@
 
        $title = lookup_title($item);
        $fulltitle = $title;
-       if (isset($title{25})) {
+       if (NAV_TRUNCATE && isset($title{NAV_TRUNCATE}) ) {
                $ftitle = " title='$title'";
-               $title = substr($title, 0, 22). '...';
+               $title = substr($title, 0, NAV_TRUNCATE-3). '...';
        } else {
                $ftitle = "";
                if (!$title) {
@@ -137,16 +175,22 @@
        
        if ($item == $current_page) {
                $current_page_title = $title;
+               $class .= ' active'; 
                $title = "<b>$title</b>";
        }
-       $title = str_replace(' ', '&nbsp;', $title);
+       if (NAV_SPACE != ' ') {
+               $title = str_replace(' ', NAV_SPACE, $title);
+       }
+
 
        if ($nolink) {
-               return "<tr><td class='$class'>$title</td></tr>\n";
+               $navitem = $title;
        } else {
                $url = generate_url_for_id($lang, $item);
-               return "<tr><td class='$class'><a $ftitle class='$class' 
href='$url'>$title</a></td></tr>\n";
+               $navitem = "<a $ftitle class='$class' href='$url'>$title</a>";
        }
+
+       return nav_item($navitem, $class);
 }
 
 /*****************************************************************************

Reply via email to