svn: /phd/trunk/phpdotnet/phd/ Format.php Index.php

From: Date: Sun, 16 Aug 2009 05:57:49 +0000
Subject: svn: /phd/trunk/phpdotnet/phd/ Format.php Index.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4692@lists.php.net to get a copy of this message
moacir Sun, 16 Aug 2009 05:57:49 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=287356 Log: Storing all xml:ids in the indexer (no more broken links), New field in the SQLite DB: chunk - to inform if an id is a chunk or not (also this field allows to register the chunk elements using SQL updates) Changed paths: U phd/trunk/phpdotnet/phd/Format.php U phd/trunk/phpdotnet/phd/Index.php Modified: phd/trunk/phpdotnet/phd/Format.php =================================================================== --- phd/trunk/phpdotnet/phd/Format.php 2009-08-16 03:53:07 UTC (rev 287355) +++ phd/trunk/phpdotnet/phd/Format.php 2009-08-16 05:57:49 UTC (rev 287356) @@ -65,19 +65,19 @@ } public function sortIDs() { - $this->sqlite->createAggregate("indexes", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 8); + $this->sqlite->createAggregate("indexes", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 9); $this->sqlite->createAggregate("childrens", array($this, "SQLiteChildrens"), array($this, "SQLiteFinal"), 2); $this->sqlite->createAggregate("refname", array($this, "SQLiteRefname"), array($this, "SQLiteFinal"), 2); $this->sqlite->createAggregate("varname", array($this, "SQLiteVarname"), array($this, "SQLiteFinal"), 2); $this->sqlite->createAggregate("classname", array($this, "SQLiteClassname"), array($this, "SQLiteFinal"), 2); - $this->sqlite->query('SELECT indexes(docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) FROM ids'); - $this->sqlite->query('SELECT childrens(docbook_id, parent_id) FROM ids'); + $this->sqlite->query('SELECT indexes(docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next, chunk) FROM ids'); + $this->sqlite->query('SELECT childrens(docbook_id, parent_id) FROM ids WHERE chunk != 0'); $this->sqlite->query('SELECT refname(docbook_id, sdesc) FROM ids WHERE element=\'refentry\''); $this->sqlite->query('SELECT varname(docbook_id, sdesc) FROM ids WHERE element=\'phpdoc:varentry\''); $this->sqlite->query('SELECT classname(docbook_id, sdesc) FROM ids WHERE element=\'phpdoc:exceptionref\' OR element=\'phpdoc:classref\''); } - public function SQLiteIndex(&$context, $index, $id, $filename, $parent, $sdesc, $ldesc, $element, $previous, $next) { + public function SQLiteIndex(&$context, $index, $id, $filename, $parent, $sdesc, $ldesc, $element, $previous, $next, $chunk) { $this->indexes[$id] = array( "docbook_id" => $id, "filename" => $filename, @@ -86,7 +86,8 @@ "ldesc" => $ldesc, "element" => $element, "previous" => $previous, - "next" => $next + "next" => $next, + "chunk" => $chunk, ); } @@ -302,7 +303,11 @@ return null; } return $this->childrens[$id]; + } + final public function isChunkID($id) { + return isset($this->indexes[$id]["chunk"]) ? $this->indexes[$id]["chunk"] : false; } + /* }}} */ /* {{{ Table helper functions */ Modified: phd/trunk/phpdotnet/phd/Index.php =================================================================== --- phd/trunk/phpdotnet/phd/Index.php 2009-08-16 03:53:07 UTC (rev 287355) +++ phd/trunk/phpdotnet/phd/Index.php 2009-08-16 05:57:49 UTC (rev 287356) @@ -133,7 +133,8 @@ ldesc TEXT, element TEXT, previous TEXT, - next TEXT + next TEXT, + chunk INTEGER ); CREATE TABLE indexing ( time INTEGER PRIMARY KEY @@ -167,17 +168,20 @@ return $this->mytextmap; } public function UNDEF($open, $name, $attrs, $props) { - /*if ($open) { + if ($open) { if(isset($attrs[Reader::XMLNS_XML]["id"])) { $id = $attrs[Reader::XMLNS_XML]["id"]; - $this->storeInfo($name, $id, $this->currentchunk); + $this->storeInfo($name, $id, $this->currentchunk, false); + if ($props["empty"]) { + $this->appendID(); + } } return false; } if(isset($attrs[Reader::XMLNS_XML]["id"])) { $this->appendID(); - }*/ + } return false; } protected function storeInfo($elm, $id, $filename, $isChunk = true) { @@ -190,7 +194,8 @@ "ldesc" => "", "element" => $elm, "children" => array(), - "previous" => $this->previousId + "previous" => $isChunk ? $this->previousId : "", + "chunk" => $isChunk, ); // Append "next" to the previously inserted row if ($isChunk) { @@ -199,21 +204,16 @@ $this->db->escapeString($id), $this->db->escapeString($this->previousId) ); - //echo "resquete UPDATE ids SET next = '".$this->db->escapeString($id)."' WHERE docbook_id = '".$this->db->escapeString($this->previousId)."';\n"; $this->previousId = $id; } } - public function appendID($isChunk = true) { + public function appendID() { static $rand = 0; $lastChunkId = array_pop($this->ids); $parentid = end($this->ids); $this->currentid = $parentid; - if (!$isChunk) { - return false; - } - $lastChunk = $this->nfo[$lastChunkId]; if (is_array($lastChunk["sdesc"])) { $array = true; @@ -224,26 +224,28 @@ } $this->commit .= sprintf( - "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '');\n", + "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next, chunk) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '', %d);\n", $this->db->escapeString($lastChunkId), $this->db->escapeString($lastChunk["filename"]), $this->db->escapeString($this->currentchunk), $this->db->escapeString($sdesc), $this->db->escapeString($lastChunk["ldesc"]), $this->db->escapeString($lastChunk["element"]), - $this->db->escapeString($lastChunk["previous"]) + $this->db->escapeString($lastChunk["previous"]), + $this->db->escapeString($lastChunk["chunk"]) ); if ($array === true && !empty($a["sdesc"])) { foreach($lastChunk["sdesc"] as $sdesc) { ++$rand; $this->commit .= sprintf( - "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) VALUES('%s', '%s', '', '%s', '%s', '%s', '%s', '');\n", + "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next, chunk) VALUES('%s', '%s', '', '%s', '%s', '%s', '%s', '', %d);\n", "phdgen-" . $rand, $this->db->escapeString($lastChunk["filename"]), $this->db->escapeString($sdesc), $this->db->escapeString($lastChunk["ldesc"]), $this->db->escapeString($lastChunk["element"]), - $this->db->escapeString($lastChunk["previous"]) + $this->db->escapeString($lastChunk["previous"]), + $this->db->escapeString($lastChunk["chunk"]) ); } }

« previous php.doc.cvs (#4692) next »