cvs: phd(PHD_ENTERPRISE) /formats php.php xhtml.php /include PhDFormat.class.php PhDIndex.class.php
| From: | Rudy Nappée | Date: | Sun, 03 Aug 2008 22:06:40 +0000 |
| Subject: | cvs: phd(PHD_ENTERPRISE) /formats php.php xhtml.php /include PhDFormat.class.php PhDIndex.class.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-1982@lists.php.net to get a copy of this message | ||
loudi Sun Aug 3 22:06:40 2008 UTC
Modified files: (Branch: PHD_ENTERPRISE)
/phd/formats xhtml.php php.php
/phd/include PhDIndex.class.php PhDFormat.class.php
Log:
* now handles phpdoc:exception element
* now Previous/Next/Parent links works fine (in chunked-xhtml headers)
* fixed bug #45143 (TOC now contain all sections)
* added navigation bar in xhtml output (please revert if unwanted, it's a mistaking of the
#44735 request)
http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.68.2.7&r2=1.68.2.8&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.68.2.7 phd/formats/xhtml.php:1.68.2.8 --- phd/formats/xhtml.php:1.68.2.7 Fri Aug 1 18:57:52 2008 +++ phd/formats/xhtml.php Sun Aug 3 22:06:39 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.68.2.7 2008/08/01 18:57:52 bjori Exp $ */ +/* $Id: xhtml.php,v 1.68.2.8 2008/08/03 22:06:39 loudi Exp $ */ class PhDXHTMLFormat extends PhDFormat { private $simpleName = "XHTML"; private $myelementmap = array( /* {{{ */ @@ -97,6 +97,7 @@ 'errortype' => 'span', 'errorcode' => 'span', 'example' => 'div', + 'phpdoc:exception' => 'format_exception_chunk', 'formalpara' => 'p', 'fieldsynopsis' => array( /* DEFAULT */ 'format_fieldsynopsis', @@ -157,7 +158,7 @@ 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface', ), 'interfacename' => 'span', - 'option' => 'span', + 'option' => 'span', 'orderedlist' => 'ol', 'para' => array( /* DEFAULT */ 'p', @@ -438,29 +439,20 @@ $lang = $this->CURRENT_LANG; $prev = $next = $parent = array("href" => null, "desc" => null); - /* {{{ FIXME: This is a complete fuckup */ - $ok = false; - $count = count($this->CHILDRENS)-1; - foreach($this->CHILDRENS as $row => $data) { - if ($data["filename"] === $id) { - if ($row != 0) { - $prev = array("href" => $this->CHILDRENS[$row-1]["filename"]. '.' .$this->ext, "desc" => $this->CHILDRENS[$row-1]["ldesc"] ?: $this->CHILDRENS[$row-1]["sdesc"]); - } - if ($row != $count) { - $next = array("href" => $this->CHILDRENS[$row+1]["filename"]. '.' .$this->ext, "desc" => $this->CHILDRENS[$row+1]["ldesc"] ?: $this->CHILDRENS[$row+1]["sdesc"]); - } - $ok = true; - break; - } - } - if (!$ok) { - //var_dump($id, $this->CHILDRENS); - //echo "\n\n"; + + if ($parentId = $this->getParent($id)) { + $parent = array("href" => $this->getFilename($parentId) . '.' .$this->ext, + "desc" => $this->getLongDescription($parentId)); + } + if ($prevId = PhDFormat::getPrevious($id)) { + $prev = array("href" => PhDFormat::getFilename($prevId) . '.' .$this->ext, + "desc" => $this->getLongDescription($prevId)); + } + if ($nextId = PhDFormat::getNext($id)) { + $next = array("href" => PhDFormat::getFilename($nextId) . '.' .$this->ext, + "desc" => $this->getLongDescription($nextId)); } - - $parent = $this->getParentInfo($id); - /* }}} */ - + $navBar = $this->createNavBar($id); return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> @@ -470,16 +462,22 @@ <title>PHP: '.$title.'</title> </head> <body> -<div style="text-align: center;"> - <div class="prev" style="float: left;"><a href="' .$prev["href"]. '">' .$prev["desc"]. '</a></div> - <div class="next" style="float: right;"><a href="' .$next["href"]. '">' .$next["desc"] .'</a></div> - <div class="up"><a href="' .$parent["href"]. '">' .$parent["desc"]. '</a></div> - <div class="home"><a href="index.html">PHP Manual</a></div> -</div> +<table width="100%"> + <tr valign="top"> + <td style="font-size: smaller;" width="15%"> +'.$navBar.' + </td> + <td width="85%"> + <div style="text-align: center;"> + '.($prevId ? '<div class="prev" style="text-align: left; float: left;"><a href="' .$prev["href"]. '">' .$prev["desc"]. '</a></div>' : '') .' + '.($nextId ? '<div class="next" style="text-align: right; float: right;"><a href="' .$next["href"]. '">' .$next["desc"].'</a></div>' : '') .' + '.($parentId ? '<div class="up"><a href="' .$parent["href"]. '">' .$parent["desc"]. '</a></div>' : '') .' + <div class="home"><a href="index.html">PHP Manual</a></div> + </div><hr/> '; } public function footer($id) { - return "\n</body>\n</html>\n"; + return "\n </td>\n </tr>\n</table>\n</body>\n</html>\n"; } public function writeChunk($id, $fp) { $filename = $this->outputdir . $id . '.' .$this->ext; @@ -530,10 +528,6 @@ return $retval; } - public function getParentInfo($for) { - $parentId = $this->getParent($for); - return array("href" => $this->getFilename($parentId), "desc" => $this->getLongDescription($parentId)); - } protected function createTOC(SQLite3Result $result) { $toc = '<ol>'; $desc = $title = ""; @@ -558,6 +552,62 @@ return $toc; } + protected function createNavBar($id) { + $navBar = '<style type="text/css"> +#leftbar { + float: left; + width: 186px; + padding: 5px; + font-size: smaller; +} +ul.toc { + margin: 0px 5px 5px 5px; + padding: 0px; +} +ul.toc li { + font-size: 85%; + margin: 1px 0 1px 1px; + padding: 1px 0 1px 11px; + list-style-type: none; + background-repeat: no-repeat; + background-position: center left; +} +ul.toc li.header { + font-size: 115%; + padding: 5px 0px 5px 11px; + border-bottom: 1px solid #cccccc; + margin-bottom: 5px; +} +ul.toc li.active { + font-weight: bold; +} +ul.toc li a { + text-decoration: none; +} +ul.toc li a:hover { + text-decoration: underline; +} +</style> + <ul class="toc"> + <li class="header home"><a href="index.'.$this->ext.'">PHP Manual</a></li> +'; + $currentId = $id; + while (($currentId = $this->getParent($currentId)) && $currentId != "index") { + $desc = ""; + $link = $this->createLink($currentId, $desc); + $navBar .= " <li class=\"header up\"><a href=\"$link\">$desc</a></li>\n"; + } + $parent = $this->getParent($id); + $childrens = $this->sqlite->query("SELECT docbook_id FROM ids WHERE parent_id='$parent'"); + while ($child = $childrens->fetchArray(SQLITE3_ASSOC)) { + $desc = ""; + $link = $this->createLink($child["docbook_id"], $desc); + $active = ($id === $child["docbook_id"]); + $navBar .= " <li" .($active ? " class=\"active\"" : ""). "><a href=\"$link\">$desc</a></li>\n"; + } + return $navBar . " </ul>\n"; + } + public function CDATA($str) { switch($this->role) { case "php": @@ -597,7 +647,7 @@ $this->registerTextMap(static::getDefaultTextMap()); } break; - + case PhDRender::INIT: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); $this->outputdir = $tmp = PhDConfig::output_dir() . strtolower($this->getFormatName()) . '/'; @@ -721,7 +771,7 @@ case "othername": if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { - /* We maight want to add support for other roles */ + /* We might want to add support for other roles */ switch($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) { case "nickname": $class = " nickname"; @@ -757,7 +807,7 @@ $toc = ""; if (!NO_SQLITE && !in_array($id, $this->TOC_WRITTEN)) { - $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id' AND filename=docbook_id"); + $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id'"); $toc = $this->createTOC($result); } return $toc."</div>"; @@ -769,7 +819,7 @@ $id = $this->CURRENT_CHUNK; if (!NO_SQLITE) { - $this->CHILDRENS = $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id' AND filename=docbook_id"); + $this->CHILDRENS = $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id'"); $toc = $this->createTOC($result); } else { $this->CHILDRENS = array(); @@ -811,6 +861,9 @@ $this->notify(PhDRender::CHUNK, PhDRender::CLOSE); return $toc . '</div>'; } + public function format_exception_chunk($open, $name, $attrs, $props) { + return $this->format_container_chunk_below($open, "reference", $attrs, $props); + } public function format_section_chunk($open, $name, $attrs, $props) { static $a = array(); if ($open) { @@ -936,13 +989,13 @@ } return "</div>"; } - + public function format_classsynopsis_ooclass_classname_text($value, $tag) { $this->cchunk["classsynopsis"]["classname"] = $value; return $this->TEXT($value); } - - + + public function format_fieldsynopsis($open, $name, $attrs) { $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"]; if ($open) { @@ -1434,7 +1487,7 @@ } /* - * "colspan" is *not* an standard prop, only used to overwrite the + * "colspan" is *not* an standard prop, only used to overwrite the * colspan for <footnote>s in tables */ if (isset($props["colspan"])) { @@ -1495,14 +1548,14 @@ } return '</a></li>'; } - + public function format_citation($open, $name, $attrs, $props) { if ($open) { return '[<span class="citation">'; } return '</span>]'; } - + public function format_email_text($value) { return '<<a href="mailto:' . $value . '">' . $value . '</a>>'; } http://cvs.php.net/viewvc.cgi/phd/formats/php.php?r1=1.4.2.6&r2=1.4.2.7&diff_format=u Index: phd/formats/php.php diff -u phd/formats/php.php:1.4.2.6 phd/formats/php.php:1.4.2.7 --- phd/formats/php.php:1.4.2.6 Fri Aug 1 18:57:52 2008 +++ phd/formats/php.php Sun Aug 3 22:06:39 2008 @@ -145,11 +145,9 @@ } protected function lookupRefname($for) { - return isset($this->refs[$for]) ? $this->refs[$for] : null; - return NO_SQLITE; - $rsl = $this->sqlite->query("SELECT filename, ldesc, sdesc FROM ids WHERE sdesc='$for' AND element='refentry'")->fetchArray(SQLITE3_ASSOC); - if (isset($rsl[0])) { - return $rsl[0]["filename"]; + $result = $this->sqlite->query("SELECT filename, ldesc, sdesc FROM ids WHERE sdesc='$for' AND element='refentry'")->fetchArray(SQLITE3_ASSOC); + if (is_array($result)) { + return $result["filename"]; } return false; } http://cvs.php.net/viewvc.cgi/phd/include/PhDIndex.class.php?r1=1.2.2.7&r2=1.2.2.8&diff_format=u Index: phd/include/PhDIndex.class.php diff -u phd/include/PhDIndex.class.php:1.2.2.7 phd/include/PhDIndex.class.php:1.2.2.8 --- phd/include/PhDIndex.class.php:1.2.2.7 Fri Aug 1 18:57:52 2008 +++ phd/include/PhDIndex.class.php Sun Aug 3 22:06:40 2008 @@ -27,6 +27,7 @@ 'legalnotice' => 'format_legalnotice_chunk', 'part' => 'format_container_chunk', + 'phpdoc:exception' => 'format_container_chunk', 'preface' => 'format_chunk', 'refentry' => 'format_chunk', 'reference' => 'format_container_chunk', @@ -63,6 +64,7 @@ private $mytextmap = array( ); private $chunks = array(); + private $previousId = ""; public function transformFromMap($open, $tag, $name, $attrs, $props) { } @@ -117,7 +119,9 @@ parent_id TEXT, sdesc TEXT, ldesc TEXT, - element TEXT + element TEXT, + previous TEXT, + next TEXT ); CREATE TABLE indexing ( time INTEGER PRIMARY KEY @@ -147,24 +151,22 @@ return $this->mytextmap; } public function UNDEF($open, $name, $attrs, $props) { - if ($open) { - if(!isset($attrs[PhDReader::XMLNS_XML]["id"])) { - return false; + /*if ($open) { + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $id = $attrs[PhDReader::XMLNS_XML]["id"]; + $this->storeInfo($name, $id, $this->currentchunk); } - $id = $attrs[PhDReader::XMLNS_XML]["id"]; - $this->storeInfo($name, $id, $this->currentchunk); - return false; } - if(!isset($attrs[PhDReader::XMLNS_XML]["id"])) { - return false; - } - - $this->appendID(); + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $this->appendID(); + }*/ return false; } - protected function storeInfo($elm, $id, $filename) { + protected function storeInfo($elm, $id, $filename, $isChunk = true) { + $this->ids[] = $id; + $this->currentid = $id; $this->nfo[$id] = array( "parent" => "", "filename" => $filename, @@ -172,63 +174,82 @@ "ldesc" => "", "element" => $elm, "children" => array(), + "previous" => $this->previousId ); - $this->ids[] = $id; - $this->currentid = $id; + // Append "next" to the previously inserted row + if ($isChunk) { + $this->commitAfter .= sprintf( + "UPDATE ids SET next = '%s' WHERE docbook_id = '%s';\n", + $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() { + public function appendID($isChunk = true) { static $rand = 0; - $lastchunkid = array_pop($this->ids); + $lastChunkId = array_pop($this->ids); $parentid = end($this->ids); $this->currentid = $parentid; - $a = $this->nfo[$lastchunkid]; - if (is_array($a["sdesc"])) { + $lastChunk = $this->nfo[$lastChunkId]; + if (is_array($lastChunk["sdesc"])) { $array = true; - $sdesc = array_shift($a["sdesc"]); + $sdesc = array_shift($lastChunk["sdesc"]); } else { $array = false; - $sdesc = $a["sdesc"]; + $sdesc = $lastChunk["sdesc"]; } $this->commit .= sprintf( - "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element) VALUES('%s', '%s', '%s', '%s', '%s', '%s');\n", - $this->db->escapeString($lastchunkid), - $this->db->escapeString($a["filename"]), + "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '');\n", + $this->db->escapeString($lastChunkId), + $this->db->escapeString($lastChunk["filename"]), $this->db->escapeString($this->currentchunk), $this->db->escapeString($sdesc), - $this->db->escapeString($a["ldesc"]), - $this->db->escapeString($a["element"]) + $this->db->escapeString($lastChunk["ldesc"]), + $this->db->escapeString($lastChunk["element"]), + $this->db->escapeString($lastChunk["previous"]) ); if ($array === true && !empty($a["sdesc"])) { - foreach($a["sdesc"] as $sdesc) { + foreach($lastChunk["sdesc"] as $sdesc) { ++$rand; $this->commit .= sprintf( - "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element) VALUES('%s', '%s', '', '%s', '%s', '%s');\n", - "phdgen-" . $rand, - $this->db->escapeString($a["filename"]), + "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) VALUES('%s', '%s', '', '%s', '%s', '%s', '%s', '');\n", + "phdgen-" . $rand, + $this->db->escapeString($lastChunk["filename"]), $this->db->escapeString($sdesc), - $this->db->escapeString($a["ldesc"]), - $this->db->escapeString($a["element"]) + $this->db->escapeString($lastChunk["ldesc"]), + $this->db->escapeString($lastChunk["element"]), + $this->db->escapeString($lastChunk["previous"]) ); } } } public function format_section_chunk($open, $name, $attrs, $props) { - static $a = array(); + static $sectionChunks = array(); if ($open) { - $a[] = $props["sibling"]; + $sectionChunks[] = $props["sibling"]; if ($props["sibling"] === $name) { return $this->format_chunk($open, $name, $attrs, $props); } + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $id = $attrs[PhDReader::XMLNS_XML]["id"]; + return $this->storeInfo($name, $id, $this->currentchunk, false); + } return $this->UNDEF($open, $name, $attrs, $props); } - $x = array_pop($a); + $x = array_pop($sectionChunks); if ($x == $name) { return $this->format_chunk($open, $name, $attrs, $props); } - $a[] = $x; + $sectionChunks[] = $x; + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $id = $attrs[PhDReader::XMLNS_XML]["id"]; + return $this->appendID(false); + } return $this->UNDEF($open, $name, $attrs, $props); } public function format_container_chunk($open, $name, $attrs, $props) { @@ -289,7 +310,8 @@ public function commit() { if (isset($this->commit) && $this->commit) { var_dump($this->db->exec('BEGIN TRANSACTION; '.$this->commit.' COMMIT')); - $this->commit = null; + var_dump($this->db->exec('BEGIN TRANSACTION; '.$this->commitAfter.' COMMIT')); + $this->commit = $this->commitAfter = null; } } } http://cvs.php.net/viewvc.cgi/phd/include/PhDFormat.class.php?r1=1.10.6.7&r2=1.10.6.8&diff_format=u Index: phd/include/PhDFormat.class.php diff -u phd/include/PhDFormat.class.php:1.10.6.7 phd/include/PhDFormat.class.php:1.10.6.8 --- phd/include/PhDFormat.class.php:1.10.6.7 Fri Aug 1 18:57:52 2008 +++ phd/include/PhDFormat.class.php Sun Aug 3 22:06:40 2008 @@ -27,17 +27,19 @@ abstract public function update($event, $value = null); public function sortIDs() { - $this->sqlite->createAggregate("idx", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 6); - $this->sqlite->query('SELECT idx(docbook_id, filename, parent_id, sdesc, ldesc, element) FROM ids'); + $this->sqlite->createAggregate("idx", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 8); + $this->sqlite->query('SELECT idx(docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) FROM ids'); } - public function SQLiteIndex(&$context, $index, $id, $filename, $parent, $sdesc, $ldesc, $element) { + public function SQLiteIndex(&$context, $index, $id, $filename, $parent, $sdesc, $ldesc, $element, $previous, $next) { $this->idx[$id] = array( "docbook_id" => $id, "filename" => $filename, "parent_id" => $parent, "sdesc" => $sdesc, "ldesc" => $ldesc, - "element" => $element + "element" => $element, + "previous" => $previous, + "next" => $next ); if ($element == "refentry") { $this->refs[$sdesc] = $id; @@ -128,6 +130,22 @@ } return $row["filename"]; } + final public function getPrevious($id) { + $row = $this->sqlite->query($q = "SELECT previous FROM ids WHERE docbook_id='$id'")->fetchArray(SQLITE3_ASSOC); + if (!is_array($row)) { + var_dump($q); + return false; + } + return $row["previous"]; + } + final public function getNext($id) { + $row = $this->sqlite->query($q = "SELECT next FROM ids WHERE docbook_id='$id'")->fetchArray(SQLITE3_ASSOC); + if (!is_array($row)) { + var_dump($q); + return false; + } + return $row["next"]; + } final public function getParent($id) { $row = $this->sqlite->query($q = "SELECT parent_id FROM ids WHERE docbook_id='$id'")->fetchArray(SQLITE3_ASSOC); if (!is_array($row)) {
http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.68.2.7&r2=1.68.2.8&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.68.2.7 phd/formats/xhtml.php:1.68.2.8 --- phd/formats/xhtml.php:1.68.2.7 Fri Aug 1 18:57:52 2008 +++ phd/formats/xhtml.php Sun Aug 3 22:06:39 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.68.2.7 2008/08/01 18:57:52 bjori Exp $ */ +/* $Id: xhtml.php,v 1.68.2.8 2008/08/03 22:06:39 loudi Exp $ */ class PhDXHTMLFormat extends PhDFormat { private $simpleName = "XHTML"; private $myelementmap = array( /* {{{ */ @@ -97,6 +97,7 @@ 'errortype' => 'span', 'errorcode' => 'span', 'example' => 'div', + 'phpdoc:exception' => 'format_exception_chunk', 'formalpara' => 'p', 'fieldsynopsis' => array( /* DEFAULT */ 'format_fieldsynopsis', @@ -157,7 +158,7 @@ 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface', ), 'interfacename' => 'span', - 'option' => 'span', + 'option' => 'span', 'orderedlist' => 'ol', 'para' => array( /* DEFAULT */ 'p', @@ -438,29 +439,20 @@ $lang = $this->CURRENT_LANG; $prev = $next = $parent = array("href" => null, "desc" => null); - /* {{{ FIXME: This is a complete fuckup */ - $ok = false; - $count = count($this->CHILDRENS)-1; - foreach($this->CHILDRENS as $row => $data) { - if ($data["filename"] === $id) { - if ($row != 0) { - $prev = array("href" => $this->CHILDRENS[$row-1]["filename"]. '.' .$this->ext, "desc" => $this->CHILDRENS[$row-1]["ldesc"] ?: $this->CHILDRENS[$row-1]["sdesc"]); - } - if ($row != $count) { - $next = array("href" => $this->CHILDRENS[$row+1]["filename"]. '.' .$this->ext, "desc" => $this->CHILDRENS[$row+1]["ldesc"] ?: $this->CHILDRENS[$row+1]["sdesc"]); - } - $ok = true; - break; - } - } - if (!$ok) { - //var_dump($id, $this->CHILDRENS); - //echo "\n\n"; + + if ($parentId = $this->getParent($id)) { + $parent = array("href" => $this->getFilename($parentId) . '.' .$this->ext, + "desc" => $this->getLongDescription($parentId)); + } + if ($prevId = PhDFormat::getPrevious($id)) { + $prev = array("href" => PhDFormat::getFilename($prevId) . '.' .$this->ext, + "desc" => $this->getLongDescription($prevId)); + } + if ($nextId = PhDFormat::getNext($id)) { + $next = array("href" => PhDFormat::getFilename($nextId) . '.' .$this->ext, + "desc" => $this->getLongDescription($nextId)); } - - $parent = $this->getParentInfo($id); - /* }}} */ - + $navBar = $this->createNavBar($id); return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> @@ -470,16 +462,22 @@ <title>PHP: '.$title.'</title> </head> <body> -<div style="text-align: center;"> - <div class="prev" style="float: left;"><a href="' .$prev["href"]. '">' .$prev["desc"]. '</a></div> - <div class="next" style="float: right;"><a href="' .$next["href"]. '">' .$next["desc"] .'</a></div> - <div class="up"><a href="' .$parent["href"]. '">' .$parent["desc"]. '</a></div> - <div class="home"><a href="index.html">PHP Manual</a></div> -</div> +<table width="100%"> + <tr valign="top"> + <td style="font-size: smaller;" width="15%"> +'.$navBar.' + </td> + <td width="85%"> + <div style="text-align: center;"> + '.($prevId ? '<div class="prev" style="text-align: left; float: left;"><a href="' .$prev["href"]. '">' .$prev["desc"]. '</a></div>' : '') .' + '.($nextId ? '<div class="next" style="text-align: right; float: right;"><a href="' .$next["href"]. '">' .$next["desc"].'</a></div>' : '') .' + '.($parentId ? '<div class="up"><a href="' .$parent["href"]. '">' .$parent["desc"]. '</a></div>' : '') .' + <div class="home"><a href="index.html">PHP Manual</a></div> + </div><hr/> '; } public function footer($id) { - return "\n</body>\n</html>\n"; + return "\n </td>\n </tr>\n</table>\n</body>\n</html>\n"; } public function writeChunk($id, $fp) { $filename = $this->outputdir . $id . '.' .$this->ext; @@ -530,10 +528,6 @@ return $retval; } - public function getParentInfo($for) { - $parentId = $this->getParent($for); - return array("href" => $this->getFilename($parentId), "desc" => $this->getLongDescription($parentId)); - } protected function createTOC(SQLite3Result $result) { $toc = '<ol>'; $desc = $title = ""; @@ -558,6 +552,62 @@ return $toc; } + protected function createNavBar($id) { + $navBar = '<style type="text/css"> +#leftbar { + float: left; + width: 186px; + padding: 5px; + font-size: smaller; +} +ul.toc { + margin: 0px 5px 5px 5px; + padding: 0px; +} +ul.toc li { + font-size: 85%; + margin: 1px 0 1px 1px; + padding: 1px 0 1px 11px; + list-style-type: none; + background-repeat: no-repeat; + background-position: center left; +} +ul.toc li.header { + font-size: 115%; + padding: 5px 0px 5px 11px; + border-bottom: 1px solid #cccccc; + margin-bottom: 5px; +} +ul.toc li.active { + font-weight: bold; +} +ul.toc li a { + text-decoration: none; +} +ul.toc li a:hover { + text-decoration: underline; +} +</style> + <ul class="toc"> + <li class="header home"><a href="index.'.$this->ext.'">PHP Manual</a></li> +'; + $currentId = $id; + while (($currentId = $this->getParent($currentId)) && $currentId != "index") { + $desc = ""; + $link = $this->createLink($currentId, $desc); + $navBar .= " <li class=\"header up\"><a href=\"$link\">$desc</a></li>\n"; + } + $parent = $this->getParent($id); + $childrens = $this->sqlite->query("SELECT docbook_id FROM ids WHERE parent_id='$parent'"); + while ($child = $childrens->fetchArray(SQLITE3_ASSOC)) { + $desc = ""; + $link = $this->createLink($child["docbook_id"], $desc); + $active = ($id === $child["docbook_id"]); + $navBar .= " <li" .($active ? " class=\"active\"" : ""). "><a href=\"$link\">$desc</a></li>\n"; + } + return $navBar . " </ul>\n"; + } + public function CDATA($str) { switch($this->role) { case "php": @@ -597,7 +647,7 @@ $this->registerTextMap(static::getDefaultTextMap()); } break; - + case PhDRender::INIT: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); $this->outputdir = $tmp = PhDConfig::output_dir() . strtolower($this->getFormatName()) . '/'; @@ -721,7 +771,7 @@ case "othername": if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { - /* We maight want to add support for other roles */ + /* We might want to add support for other roles */ switch($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) { case "nickname": $class = " nickname"; @@ -757,7 +807,7 @@ $toc = ""; if (!NO_SQLITE && !in_array($id, $this->TOC_WRITTEN)) { - $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id' AND filename=docbook_id"); + $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id'"); $toc = $this->createTOC($result); } return $toc."</div>"; @@ -769,7 +819,7 @@ $id = $this->CURRENT_CHUNK; if (!NO_SQLITE) { - $this->CHILDRENS = $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id' AND filename=docbook_id"); + $this->CHILDRENS = $result = $this->sqlite->query("SELECT docbook_id, filename, sdesc, ldesc FROM ids WHERE parent_id='$id'"); $toc = $this->createTOC($result); } else { $this->CHILDRENS = array(); @@ -811,6 +861,9 @@ $this->notify(PhDRender::CHUNK, PhDRender::CLOSE); return $toc . '</div>'; } + public function format_exception_chunk($open, $name, $attrs, $props) { + return $this->format_container_chunk_below($open, "reference", $attrs, $props); + } public function format_section_chunk($open, $name, $attrs, $props) { static $a = array(); if ($open) { @@ -936,13 +989,13 @@ } return "</div>"; } - + public function format_classsynopsis_ooclass_classname_text($value, $tag) { $this->cchunk["classsynopsis"]["classname"] = $value; return $this->TEXT($value); } - - + + public function format_fieldsynopsis($open, $name, $attrs) { $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"]; if ($open) { @@ -1434,7 +1487,7 @@ } /* - * "colspan" is *not* an standard prop, only used to overwrite the + * "colspan" is *not* an standard prop, only used to overwrite the * colspan for <footnote>s in tables */ if (isset($props["colspan"])) { @@ -1495,14 +1548,14 @@ } return '</a></li>'; } - + public function format_citation($open, $name, $attrs, $props) { if ($open) { return '[<span class="citation">'; } return '</span>]'; } - + public function format_email_text($value) { return '<<a href="mailto:' . $value . '">' . $value . '</a>>'; } http://cvs.php.net/viewvc.cgi/phd/formats/php.php?r1=1.4.2.6&r2=1.4.2.7&diff_format=u Index: phd/formats/php.php diff -u phd/formats/php.php:1.4.2.6 phd/formats/php.php:1.4.2.7 --- phd/formats/php.php:1.4.2.6 Fri Aug 1 18:57:52 2008 +++ phd/formats/php.php Sun Aug 3 22:06:39 2008 @@ -145,11 +145,9 @@ } protected function lookupRefname($for) { - return isset($this->refs[$for]) ? $this->refs[$for] : null; - return NO_SQLITE; - $rsl = $this->sqlite->query("SELECT filename, ldesc, sdesc FROM ids WHERE sdesc='$for' AND element='refentry'")->fetchArray(SQLITE3_ASSOC); - if (isset($rsl[0])) { - return $rsl[0]["filename"]; + $result = $this->sqlite->query("SELECT filename, ldesc, sdesc FROM ids WHERE sdesc='$for' AND element='refentry'")->fetchArray(SQLITE3_ASSOC); + if (is_array($result)) { + return $result["filename"]; } return false; } http://cvs.php.net/viewvc.cgi/phd/include/PhDIndex.class.php?r1=1.2.2.7&r2=1.2.2.8&diff_format=u Index: phd/include/PhDIndex.class.php diff -u phd/include/PhDIndex.class.php:1.2.2.7 phd/include/PhDIndex.class.php:1.2.2.8 --- phd/include/PhDIndex.class.php:1.2.2.7 Fri Aug 1 18:57:52 2008 +++ phd/include/PhDIndex.class.php Sun Aug 3 22:06:40 2008 @@ -27,6 +27,7 @@ 'legalnotice' => 'format_legalnotice_chunk', 'part' => 'format_container_chunk', + 'phpdoc:exception' => 'format_container_chunk', 'preface' => 'format_chunk', 'refentry' => 'format_chunk', 'reference' => 'format_container_chunk', @@ -63,6 +64,7 @@ private $mytextmap = array( ); private $chunks = array(); + private $previousId = ""; public function transformFromMap($open, $tag, $name, $attrs, $props) { } @@ -117,7 +119,9 @@ parent_id TEXT, sdesc TEXT, ldesc TEXT, - element TEXT + element TEXT, + previous TEXT, + next TEXT ); CREATE TABLE indexing ( time INTEGER PRIMARY KEY @@ -147,24 +151,22 @@ return $this->mytextmap; } public function UNDEF($open, $name, $attrs, $props) { - if ($open) { - if(!isset($attrs[PhDReader::XMLNS_XML]["id"])) { - return false; + /*if ($open) { + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $id = $attrs[PhDReader::XMLNS_XML]["id"]; + $this->storeInfo($name, $id, $this->currentchunk); } - $id = $attrs[PhDReader::XMLNS_XML]["id"]; - $this->storeInfo($name, $id, $this->currentchunk); - return false; } - if(!isset($attrs[PhDReader::XMLNS_XML]["id"])) { - return false; - } - - $this->appendID(); + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $this->appendID(); + }*/ return false; } - protected function storeInfo($elm, $id, $filename) { + protected function storeInfo($elm, $id, $filename, $isChunk = true) { + $this->ids[] = $id; + $this->currentid = $id; $this->nfo[$id] = array( "parent" => "", "filename" => $filename, @@ -172,63 +174,82 @@ "ldesc" => "", "element" => $elm, "children" => array(), + "previous" => $this->previousId ); - $this->ids[] = $id; - $this->currentid = $id; + // Append "next" to the previously inserted row + if ($isChunk) { + $this->commitAfter .= sprintf( + "UPDATE ids SET next = '%s' WHERE docbook_id = '%s';\n", + $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() { + public function appendID($isChunk = true) { static $rand = 0; - $lastchunkid = array_pop($this->ids); + $lastChunkId = array_pop($this->ids); $parentid = end($this->ids); $this->currentid = $parentid; - $a = $this->nfo[$lastchunkid]; - if (is_array($a["sdesc"])) { + $lastChunk = $this->nfo[$lastChunkId]; + if (is_array($lastChunk["sdesc"])) { $array = true; - $sdesc = array_shift($a["sdesc"]); + $sdesc = array_shift($lastChunk["sdesc"]); } else { $array = false; - $sdesc = $a["sdesc"]; + $sdesc = $lastChunk["sdesc"]; } $this->commit .= sprintf( - "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element) VALUES('%s', '%s', '%s', '%s', '%s', '%s');\n", - $this->db->escapeString($lastchunkid), - $this->db->escapeString($a["filename"]), + "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '');\n", + $this->db->escapeString($lastChunkId), + $this->db->escapeString($lastChunk["filename"]), $this->db->escapeString($this->currentchunk), $this->db->escapeString($sdesc), - $this->db->escapeString($a["ldesc"]), - $this->db->escapeString($a["element"]) + $this->db->escapeString($lastChunk["ldesc"]), + $this->db->escapeString($lastChunk["element"]), + $this->db->escapeString($lastChunk["previous"]) ); if ($array === true && !empty($a["sdesc"])) { - foreach($a["sdesc"] as $sdesc) { + foreach($lastChunk["sdesc"] as $sdesc) { ++$rand; $this->commit .= sprintf( - "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element) VALUES('%s', '%s', '', '%s', '%s', '%s');\n", - "phdgen-" . $rand, - $this->db->escapeString($a["filename"]), + "INSERT INTO ids (docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) VALUES('%s', '%s', '', '%s', '%s', '%s', '%s', '');\n", + "phdgen-" . $rand, + $this->db->escapeString($lastChunk["filename"]), $this->db->escapeString($sdesc), - $this->db->escapeString($a["ldesc"]), - $this->db->escapeString($a["element"]) + $this->db->escapeString($lastChunk["ldesc"]), + $this->db->escapeString($lastChunk["element"]), + $this->db->escapeString($lastChunk["previous"]) ); } } } public function format_section_chunk($open, $name, $attrs, $props) { - static $a = array(); + static $sectionChunks = array(); if ($open) { - $a[] = $props["sibling"]; + $sectionChunks[] = $props["sibling"]; if ($props["sibling"] === $name) { return $this->format_chunk($open, $name, $attrs, $props); } + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $id = $attrs[PhDReader::XMLNS_XML]["id"]; + return $this->storeInfo($name, $id, $this->currentchunk, false); + } return $this->UNDEF($open, $name, $attrs, $props); } - $x = array_pop($a); + $x = array_pop($sectionChunks); if ($x == $name) { return $this->format_chunk($open, $name, $attrs, $props); } - $a[] = $x; + $sectionChunks[] = $x; + if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { + $id = $attrs[PhDReader::XMLNS_XML]["id"]; + return $this->appendID(false); + } return $this->UNDEF($open, $name, $attrs, $props); } public function format_container_chunk($open, $name, $attrs, $props) { @@ -289,7 +310,8 @@ public function commit() { if (isset($this->commit) && $this->commit) { var_dump($this->db->exec('BEGIN TRANSACTION; '.$this->commit.' COMMIT')); - $this->commit = null; + var_dump($this->db->exec('BEGIN TRANSACTION; '.$this->commitAfter.' COMMIT')); + $this->commit = $this->commitAfter = null; } } } http://cvs.php.net/viewvc.cgi/phd/include/PhDFormat.class.php?r1=1.10.6.7&r2=1.10.6.8&diff_format=u Index: phd/include/PhDFormat.class.php diff -u phd/include/PhDFormat.class.php:1.10.6.7 phd/include/PhDFormat.class.php:1.10.6.8 --- phd/include/PhDFormat.class.php:1.10.6.7 Fri Aug 1 18:57:52 2008 +++ phd/include/PhDFormat.class.php Sun Aug 3 22:06:40 2008 @@ -27,17 +27,19 @@ abstract public function update($event, $value = null); public function sortIDs() { - $this->sqlite->createAggregate("idx", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 6); - $this->sqlite->query('SELECT idx(docbook_id, filename, parent_id, sdesc, ldesc, element) FROM ids'); + $this->sqlite->createAggregate("idx", array($this, "SQLiteIndex"), array($this, "SQLiteFinal"), 8); + $this->sqlite->query('SELECT idx(docbook_id, filename, parent_id, sdesc, ldesc, element, previous, next) FROM ids'); } - public function SQLiteIndex(&$context, $index, $id, $filename, $parent, $sdesc, $ldesc, $element) { + public function SQLiteIndex(&$context, $index, $id, $filename, $parent, $sdesc, $ldesc, $element, $previous, $next) { $this->idx[$id] = array( "docbook_id" => $id, "filename" => $filename, "parent_id" => $parent, "sdesc" => $sdesc, "ldesc" => $ldesc, - "element" => $element + "element" => $element, + "previous" => $previous, + "next" => $next ); if ($element == "refentry") { $this->refs[$sdesc] = $id; @@ -128,6 +130,22 @@ } return $row["filename"]; } + final public function getPrevious($id) { + $row = $this->sqlite->query($q = "SELECT previous FROM ids WHERE docbook_id='$id'")->fetchArray(SQLITE3_ASSOC); + if (!is_array($row)) { + var_dump($q); + return false; + } + return $row["previous"]; + } + final public function getNext($id) { + $row = $this->sqlite->query($q = "SELECT next FROM ids WHERE docbook_id='$id'")->fetchArray(SQLITE3_ASSOC); + if (!is_array($row)) { + var_dump($q); + return false; + } + return $row["next"]; + } final public function getParent($id) { $row = $this->sqlite->query($q = "SELECT parent_id FROM ids WHERE docbook_id='$id'")->fetchArray(SQLITE3_ASSOC); if (!is_array($row)) {