wez Mon May 24 08:18:48 2004 EDT
Modified files:
/livedocs mkindex.php
Log:
Better id -> title handling.
http://cvs.php.net/diff.php/livedocs/mkindex.php?r1=1.33&r2=1.34&ty=u
Index: livedocs/mkindex.php
diff -u livedocs/mkindex.php:1.33 livedocs/mkindex.php:1.34
--- livedocs/mkindex.php:1.33 Sun May 23 04:58:01 2004
+++ livedocs/mkindex.php Mon May 24 08:18:48 2004
@@ -19,7 +19,7 @@
// | construct an index |
// +----------------------------------------------------------------------+
//
-// $Id: mkindex.php,v 1.33 2004/05/23 08:58:01 wez Exp $
+// $Id: mkindex.php,v 1.34 2004/05/24 12:18:48 wez Exp $
/* just to be on the safe side */
@@ -59,6 +59,7 @@
var $last_id = false;
var $cdata = null;
var $data = '';
+ var $title_depth = -1;
function DocBookXMLFileParser($filename, $rel, $parser) {
$this->fileid = $GLOBALS['fileid'];
@@ -86,28 +87,31 @@
}
function start_elem($parser, $name, $attrs) {
+ static $titles = array('TITLE', 'REFNAME');
+
// if there is an ID attribute, record it
if (isset($attrs['ID'])) {
$this->last_id = $attrs['ID'];
}
+ if ($this->last_id !== false && in_array($name, $titles)) {
+ $this->title_depth = 1;
+ }
}
function end_elem($parser, $name) {
- if ($this->last_id !== false) {
+ if ($this->last_id !== false && $this->title_depth &&
--$this->title_depth == 0) {
echo "\tAdded ID {$this->last_id}\n";
- $this->data .= "INSERT INTO idents VALUES ('" .
strtolower($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(str_replace('||amp||', '&', trim($this->cdata))) . "');";
$this->last_id = false;
+ $this->cdata = null;
}
}
function cdata($parser, $data) {
- if ($this->last_id !== false) {
- //small hack for '&'
- $data = str_replace('||amp||', '&', $data);
-
- $this->cdata = $data;
+ if ($this->title_depth) {
+ $this->cdata .= trim($data, "\r\n");
}
}