bjori Tue Aug 7 20:10:09 2007 UTC
Modified files: /phd build.php /phd/themes phpweb.php Log: Add version info http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.6&r2=1.7&diff_format=u Index: phd/build.php diff -u phd/build.php:1.6 phd/build.php:1.7 --- phd/build.php:1.6 Sun Aug 5 17:47:49 2007 +++ phd/build.php Tue Aug 7 20:10:09 2007 @@ -1,6 +1,6 @@ #!/home/bjori/.apps/bin/php <?php -/* $Id: build.php,v 1.6 2007/08/05 17:47:49 bjori Exp $ */ +/* $Id: build.php,v 1.7 2007/08/07 20:10:09 bjori Exp $ */ function err($no, $str, $file, $line) { global $notify; @@ -41,7 +41,7 @@ } $reader = new PhDReader("/home/bjori/php/doc/.manual.xml"); -$format = new phpweb($reader, $IDs, $IDMap); +$format = new phpweb($reader, $IDs, $IDMap, "/home/bjori/php/doc/phpbook/phpbook-xsl/version.xml"); $map = $format->getMap(); http://cvs.php.net/viewvc.cgi/phd/themes/phpweb.php?r1=1.1&r2=1.2&diff_format=u Index: phd/themes/phpweb.php diff -u phd/themes/phpweb.php:1.1 phd/themes/phpweb.php:1.2 --- phd/themes/phpweb.php:1.1 Sun Aug 5 14:49:55 2007 +++ phd/themes/phpweb.php Tue Aug 7 20:10:09 2007 @@ -1,11 +1,59 @@ <?php -/* $Id: phpweb.php,v 1.1 2007/08/05 14:49:55 bjori Exp $ */ +/* $Id: phpweb.php,v 1.2 2007/08/07 20:10:09 bjori Exp $ */ class phpweb extends PHPPhDFormat { protected $streams = array(); protected $writeit = false; - protected $CURRENT_ID = ""; + protected $CURRENT_ID = ""; + private $versions = array(); + public function __construct(PhDReader $reader, array $IDs, array $IDMap, $filename, $ext = "php") { + parent::__construct($reader, $IDs, $IDMap, $ext); + $r = new XMLReader; + if (!$r->open($filename)) { + throw new Exception; + } + $versions = array(); + while($r->read()) { + if ( + $r->moveToAttribute("name") + && ($funcname = str_replace( + array("::", "->", "__", "_", '$'), + array("-", "-", "-", "-", ""), + $r->value)) + && $r->moveToAttribute("from") + && ($from = $r->value) + ) { + $versions[strtolower($funcname)] = $from; + $r->moveToElement(); + } + } + $r->close(); + $this->versions = $versions; + } + public function versionInfo($funcname) { + $funcname = str_replace( + array("::", "->", "__", "_", '$'), + array("-", "-", "-", "-", ""), + strtolower($funcname)); + return isset($this->versions[$funcname]) ? $this->versions[$funcname] : "No version information available, might be only in CVS"; + } + public function format_refnamediv($open, $root) { + while ($child = PhDFormat::getNextChild($root)) { + $name = $child["name"]; + switch($name) { + case "refname": + $refname = $this->readContent($name); + break; + case "refpurpose": + $refpurpose = $this->readContent($name); + break; + } + } + $ver = $this->versionInfo($refname); + + return sprintf('<div class="refnamediv"><h1 class="refname">%s</h1><p class="verinfo">(%s)</p><p class="refpurpose">%1$s â %s</p></div>', $refname, $ver, $refpurpose); + } public function writeChunk($id, $stream) { rewind($stream); file_put_contents("cache/$id.php", $this->header($id));