Hi Wez,

Today you have commited my patch, but it was modified. Check ref.spl or
ref.tidy and you will see that are broken, because you missed some parts of
my patch.

Attached is the patch to solve that issues (the parts that weren't commited)
and also a bugfix for the PCRE page.

Nuno
Index: BUGS
===================================================================
RCS file: /repository/livedocs/BUGS,v
retrieving revision 1.6
diff -u -r1.6 BUGS
--- BUGS        1 May 2004 10:08:22 -0000       1.6
+++ BUGS        23 May 2004 10:45:12 -0000
@@ -4,10 +4,6 @@
  - The reserved constants and the missing stuff section are not working,
    the later would be better left out from the livedocs output.
 
- - The ref.pcre page does not link properly to the pattern modifiers and
-   pattern syntax docs (it thinks that those are functions but this is
-   not true at all)
-
  - Table spans don't work. Check nl_langinfo() function for an example
    
 $Revision: 1.6 $
Index: livedoc.php
===================================================================
RCS file: /repository/livedocs/livedoc.php,v
retrieving revision 1.103
diff -u -r1.103 livedoc.php
--- livedoc.php 7 May 2004 13:32:58 -0000       1.103
+++ livedoc.php 23 May 2004 10:45:12 -0000
@@ -127,7 +127,7 @@
 }
 
 /* Checks if translated file is updated */
-if ($lang != 'en' && isset($lang_rev)) {
+if ($lang != FALLBACK_LANG && isset($lang_rev) && $lang_rev > 0) {
 
        /* get english file revision */
        $data = @file_get_contents(FALLBACK_BASE . $filename);
@@ -349,6 +349,19 @@
                        $entities['&' . $r[0] . ';'] = $r[1];
                }
 
+               /* If language!=English and entity was not found */
+               if($GLOBALS['lang'] != FALLBACK_LANG) {
+                       foreach($entities_to_find as $ent) {
+                               if(!isset($entities['&' . $ent . ';'])) {
+                                       $q = sqlite_single_query($GLOBALS['fb_idx'], 
"SELECT value FROM ents WHERE entid='$ent'");
+                                       if (!$q) {
+                                               break;
+                                       }
+                                       $entities['&' . $ent . ';'] = $q;
+                               }
+                       }
+               }
+
                /* substitute */
                $data = strtr($data, $entities);
 
@@ -395,6 +408,7 @@
        $data = preg_replace('@<!--\s+.*\s-->@Usm', '', $data);
 
        /* Replace entities */
+       $data = str_replace($search, $replace, $data);
        $data = bind_entities($data);
 
        /* catch any undefined entities */
@@ -413,8 +427,6 @@
                $data = preg_replace('/&([a-zA-Z0-9-]+)\.([a-zA-Z0-9.-]+);/sm', 
'<phpdoc_include ref="\\1.\\2"/>', $data);
        }
 
-       $data = str_replace($search, $replace, $data);
-
        $page = new DocBookToHTML($data);
 
 
@@ -504,32 +516,36 @@
  * and generate a link to its node using its title */
 function make_function_link($ref) 
 {
-       $parts = explode('.', $ref);
-
-       $stag = 'function';
-       $etag = 'function';
-
-       if (count($parts) == 4) {
-               $id = 'function.' . $parts[3];
-               $func_name = lookup_title($id);
-       } elseif ($parts[3] == 'class' && count($parts) == 5) {
-               $id = 'class.' . $parts[4];
-               $func_name = strtr($parts[4], array('-'=>'_'));
-               $stag = "xref linkend=\"$id\"";
-               $etag = "xref";
-       } else {
-               /* some weird node type we don't understand */
-               $id = $ref;
-               $func_name = 'Unknown ??';
-       }
-       
-       if($parts[3] == 'class') {
-               $title = ' - ' . lookup_title($id) . ' class';
-       } else {
-               $title = ' - ' . bind_entities(sqlite_single_query($GLOBALS['idx'], 
"SELECT descr from toc where docbook_id='$id'"));
-       }
-
-       return "<div class=\"function_link\"><$stag>$func_name</$etag>$title</div>";
+       $parts = explode('.', $ref);
+ 
+       $stag = 'function';
+       $etag = 'function';
+ 
+       if (count($parts) == 5 && $parts[3] == 'class') {
+               $id = 'class.' . $parts[4];
+               $stag = "xref linkend=\"$id\"";
+               $etag = 'xref';
+               $name = strtoupper($parts[4]);
+               $title = "$name class";
+       } else {
+               $id = 'function.' . strtolower($parts[3]);
+               $q = sqlite_array_query($GLOBALS['idx'], "SELECT title,descr from toc 
where docbook_id='$id'", SQLITE_NUM);
+
+               if($q) {
+                       $name = $q[0][0];
+                       $title = $q[0][1];
+               } else {
+                       $name = $id;
+                       $title = '???';
+               }
+ 
+               /* Fetch english description */
+               if($GLOBALS['lang'] != FALLBACK_LANG && $name == $title) {
+                       $title = sqlite_single_query($GLOBALS['fb_idx'], "SELECT descr 
from toc where docbook_id='$id'");
+               }
+       }
+ 
+       return "<div class=\"function_link\"><$stag>$name</$etag> - " . 
bind_entities($title) . '</div>';
 }
 
 function make_xref($ref) 
@@ -576,6 +592,16 @@
 
 function handle_include($node) 
 {
+       if (substr_count($node->attributes['ref'], '.') == 3) {
+
+               $id = substr($node->attributes['ref'], 
strpos($node->attributes['ref'], '.')+1);
+
+               $caption = lookup_title($id);
+               $url = generate_url_for_id($GLOBALS['lang'], $id);
+
+               return '<div class="div"><a class="link" 
href="'.$url.'">'.$caption.'</a></div>';
+       }
+
        $filename = BASE . strtr($node->attributes['ref'], '.', '/') . '.xml';
        $fallback_filename = FALLBACK_BASE . strtr($node->attributes['ref'], '.', '/') 
. '.xml';
 
Index: style_mapping.php
===================================================================
RCS file: /repository/livedocs/style_mapping.php,v
retrieving revision 1.15
diff -u -r1.15 style_mapping.php
--- style_mapping.php   23 May 2004 08:58:01 -0000      1.15
+++ style_mapping.php   23 May 2004 10:45:13 -0000
@@ -261,9 +261,14 @@
                $dest = $node->attributes['class'] . '.method.' . $itemid;
        } else {
                $class = 'function';
-               $dest = 'function.' . $itemid;
+
+               if($current_page == 'ref.dom' || substr($current_page, 0, 13) == 
'function.dom-') {
+                       $dest = 'function.dom-' . $itemid;
+               } else {
+                       $dest = 'function.' . $itemid;
+               }
        }
-       
+
        if ($current_page == $dest) {
                return sprintf('<span class="%s"%s>%s()</span>', $class, LTR, 
$node->content);
        }
@@ -275,14 +280,16 @@
         * include/require) don't have versinfo ;-)
         */
 
-       $q = sqlite_single_query($idx, "SELECT versinfo FROM funcs where funcname='" . 
sqlite_escape_string($node->content) . "'");
-       if ($q && LATEST_VERSION == $q) {
-               $image = '<img src="' . WEBBASE . 'themes/' . THEME_NAME . '/vers' .
-                       LATEST_VERSION_NO . '.png" alt="' .
-                       bind_entities('&livedocs.new-in-vers-' .  LATEST_VERSION_NO . 
';') .
-                       '" width="15" height="15"/> ';
-       } else {
-               $image = '';
+       $image = '';
+
+       if(BUILD_TYPE == 'phpdoc') {
+               $q = sqlite_single_query($idx, "SELECT versinfo FROM funcs where 
funcname='" . sqlite_escape_string($node->content) . "'");
+               if (!$q || LATEST_VERSION == $q) {
+                       $image = '<img src="' . WEBBASE . 'themes/' . THEME_NAME . 
'/vers' .
+                               LATEST_VERSION_NO . '.png" alt="' .
+                               bind_entities('&livedocs.new-in-vers-' .  
LATEST_VERSION_NO . ';') .
+                               '" width="15" height="15"/> ';
+               }
        }
 
        $url = generate_url_for_id($lang, $dest);
@@ -299,9 +306,13 @@
 {
        global $lang;
 
-       $link = strtr($matches[1], array('_' => '-'));
-       $link = WEBBASE . (FORCE_DYNAMIC ? "?l=$lang&q=function.$link" : 
"$lang/function.$link.html");
-       return '<a class="phpfunc" href="' . $link . '">' . $matches[1] . '</a>(';
+       $link = 'function.' . strtr($matches[1], array('_' => '-'));
+       
+       if ($link == $GLOBALS['current_page'])
+               return $matches[0];
+
+       $link = WEBBASE . (FORCE_DYNAMIC ? "?l=$lang&q=$link" : "$lang/$link.html");
+       return '<a class="phpfunc" href="' . $link . '">' . $matches[1] . 
'</a></span>' . $matches[3];
 }
 
 function format_listing($node) 

Reply via email to