Here is one more patch for livedocs.
It address the following issues:
 * Fetch english entities if other's languages aren't avaliable;
 * Small bug in load_xml_doc(): replace pre-defined entites before
bind_entities();
 * Re-writen make_function_link(): there was a problem because of DOM
extension;
 * Fix problems of UpPeRcAsE IDs: turn everything lowercase when building;
 * Implemented forgotten &livedocs.published; entity.

Nuno
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 8 May 2004 11:19:42 -0000
@@ -349,6 +349,19 @@
                        $entities['&' . $r[0] . ';'] = $r[1];
                }
 
+               /* If language!=English and entity was not found */
+               if($GLOBALS['lang'] != 'en') {
+                       foreach($entities_to_find as $ent) {
+                               if(!isset($entities['&' . $ent . ';'])) {
+                                       $q = sqlite_array_query($GLOBALS['fb_idx'], 
"SELECT entid,value from ents where entid='$ent'", SQLITE_NUM);
+                                       if (!$q) {
+                                               break;
+                                       }
+                                       $entities['&' . $q[0][0] . ';'] = $q[0][1];
+                               }
+                       }
+               }
+
                /* 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);
 
 
@@ -505,31 +517,35 @@
 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) {
+       if (count($parts) == 5 && $parts[3] == 'class') {
                $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';
+               $etag = 'xref';
+               $name = strtoupper($parts[4]);
+               $title = "$name class";
        } else {
-               $title = ' - ' . bind_entities(sqlite_single_query($GLOBALS['idx'], 
"SELECT descr from toc where docbook_id='$id'"));
+               $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'] != 'en' && $name == $title) {
+                       $title = sqlite_single_query($GLOBALS['fb_idx'], "SELECT descr 
from toc where docbook_id='$id'", SQLITE_NUM);
+               }
+
        }
 
-       return "<div class=\"function_link\"><$stag>$func_name</$etag>$title</div>";
+       return "<div class=\"function_link\"><$stag>$name</$etag> - " . 
bind_entities($title) . '</div>';
 }
 
 function make_xref($ref) 
Index: mk_phpdoc.php
===================================================================
RCS file: /repository/livedocs/mk_phpdoc.php,v
retrieving revision 1.8
diff -u -r1.8 mk_phpdoc.php
--- mk_phpdoc.php       1 May 2004 09:46:46 -0000       1.8
+++ mk_phpdoc.php       8 May 2004 11:19:42 -0000
@@ -46,7 +46,7 @@
                                                if ($f == 'configure.xml' || $f == 
'constants.xml' || $f == 'ini.xml' || $f == 'reference.xml') {
                                                        $docbook_id = 'ref.' . 
basename($path);
                                                } else {
-                                                       $docbook_id = 'function.' . 
substr($f, 0, -4);
+                                                       $docbook_id = 'function.' . 
strtolower(substr($f, 0, -4));
                                                }
                                                break;
                                        case 'language' :
Index: mkindex.php
===================================================================
RCS file: /repository/livedocs/mkindex.php,v
retrieving revision 1.32
diff -u -r1.32 mkindex.php
--- mkindex.php 27 Apr 2004 14:43:28 -0000      1.32
+++ mkindex.php 8 May 2004 11:19:43 -0000
@@ -96,7 +96,7 @@
                if ($this->last_id !== false) {
                        echo "\tAdded ID {$this->last_id}\n";
 
-                       $this->data .= "INSERT INTO idents VALUES ('{$this->last_id}', 
{$this->fileid}, '" . sqlite_escape_string(trim($this->cdata)) . "');";
+                       $this->data .= "INSERT INTO idents VALUES ('". 
strtolower($this->last_id) . "', {$this->fileid}, '" . 
sqlite_escape_string(trim($this->cdata)) . "');";
 
                        $this->last_id = false;
                }
Index: mktoc.php
===================================================================
RCS file: /repository/livedocs/mktoc.php,v
retrieving revision 1.8
diff -u -r1.8 mktoc.php
--- mktoc.php   16 Feb 2004 17:54:59 -0000      1.8
+++ mktoc.php   8 May 2004 11:19:43 -0000
@@ -68,7 +68,7 @@
                array_push($this->id_stack, $this->last_id);
                array_push($this->docbook_id_stack, $docbook_id);
 
-               echo "INSERT INTO toc VALUES ({$this->last_id}, {$level}, 
{$parent_id}, '{$docbook_id}', '{$docbook_parent_id}', '{$path}', '{$title}', 
'{$title}');\n";
+               echo "INSERT INTO toc VALUES ({$this->last_id}, {$level}, 
{$parent_id}, '".strtolower($docbook_id)."', '{$docbook_parent_id}', '{$path}', 
'{$title}', '{$title}');\n";
                $this->last_id++;
        }
 
Index: style_mapping.php
===================================================================
RCS file: /repository/livedocs/style_mapping.php,v
retrieving revision 1.13
diff -u -r1.13 style_mapping.php
--- style_mapping.php   8 May 2004 09:20:43 -0000       1.13
+++ style_mapping.php   8 May 2004 11:19:43 -0000
@@ -204,7 +204,7 @@
 
 function format_pubdate($node) 
 {
-       return sprintf('<div class="%s">Published on: %s</div>', $node->tagname, 
$node->content);
+       return sprintf('<div class="%s">' . bind_entities('&livedocs.published;') . 
'</div>', $node->tagname, $node->content);
 }
 
 function format_ulink($node) 
@@ -248,7 +248,7 @@
                        '->' => '-');
 
        $itemid = strtr($node->content, $replace);
-       $itemid = strtr($itemid, array('---' => '-'));
+       $itemid = strtolower(strtr($itemid, array('---' => '-')));
 
        $class = 'function';
        if (isset($node->attributes['class'])) {

Reply via email to