cvs: phd(PHD_0_2) / config.php package.xml /themes/pear pearbightml.php pearchm.php pearchunkedhtml.php peartheme.php pearweb.php
| From: | Rudy Nappée | Date: | Thu, 16 Oct 2008 15:43:46 +0000 |
| Subject: | cvs: phd(PHD_0_2) / config.php package.xml /themes/pear pearbightml.php pearchm.php pearchunkedhtml.php peartheme.php pearweb.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2246@lists.php.net to get a copy of this message | ||
loudi Thu Oct 16 15:43:46 2008 UTC
Added files: (Branch: PHD_0_2)
/phd/themes/pear pearbightml.php pearweb.php pearchm.php
pearchunkedhtml.php peartheme.php
Modified files:
/phd config.php package.xml
Log:
* Added Pear XHTML output in 0_2 branch
* Updated package.xml
http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45.2.13&r2=1.45.2.14&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45.2.13 phd/config.php:1.45.2.14 --- phd/config.php:1.45.2.13 Mon Oct 6 15:35:25 2008 +++ phd/config.php Thu Oct 16 15:43:46 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.45.2.13 2008/10/06 15:35:25 bjori Exp $ */ +/* $Id: config.php,v 1.45.2.14 2008/10/16 15:43:46 loudi Exp $ */ /* {{{ PhD error & message handler */ @@ -324,6 +324,7 @@ echo "Supported formats:\n"; echo "\txhtml\n"; echo "\tmanpage\n"; + echo "\tpdf:\n"; break; case "t": @@ -337,6 +338,10 @@ echo "\t\tchmsource\n"; echo "\t\tphpkdevelop\n"; echo "\t\thowto\n"; + echo "\t\tpearweb\n"; + echo "\t\tpearbightml\n"; + echo "\t\tpearchunkedhtml\n"; + echo "\t\tpearchm\n"; echo "\tmanpage:\n"; echo "\t\tphpfunctions\n"; echo "\tpdf:\n"; @@ -361,6 +366,10 @@ echo "\t\tchmsource\n"; echo "\t\tphpkdevelop\n"; echo "\t\thowto\n"; + echo "\t\tpearweb\n"; + echo "\t\tpearbightml\n"; + echo "\t\tpearchunkedhtml\n"; + echo "\t\tpearchm\n"; echo "\tmanpage:\n"; echo "\t\tphpfunctions\n"; echo "\tpdf:\n"; @@ -414,7 +423,8 @@ case "theme": /* Remove the default themes */ $OPTIONS["output_theme"]["xhtml"]["php"] = array(); - + $OPTIONS["output_theme"]["manpage"]["php"] = array(); + $OPTIONS["output_theme"]["xhtml"]["pear"] = array(); foreach((array)$v as $i => $val) { switch($val) { case "phpweb": @@ -438,6 +448,22 @@ $OPTIONS["output_theme"]["pdf"]["php"][] = $val; } break; + case "pear": + $OPTIONS["output_theme"]["xhtml"]["pear"] = array( + 'pearweb', + 'pearchunkedhtml', + 'pearbightml', + 'pearchm' + ); + break; + case "pearweb": + case "pearchunkedhtml": + case "pearbightml": + case "pearchm": + if (!in_array($val, $OPTIONS["output_theme"]["xhtml"]["pear"])) { + $OPTIONS["output_theme"]["xhtml"]["pear"][] = $val; + } + break; default: trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); } http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.74.2.18&r2=1.74.2.19&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.74.2.18 phd/package.xml:1.74.2.19 --- phd/package.xml:1.74.2.18 Tue Oct 7 07:04:49 2008 +++ phd/package.xml Thu Oct 16 15:43:46 2008 @@ -49,6 +49,7 @@ Fixed bug #46094 (and then from now on italic). (Hannes) Fixed a bug where it was only possible to pass one parameter to phd.bat (Kalle) Fixed a bug where it wasn't possible to have paths with spaces in when using phd.bat (Kalle) + Added PEAR XHTML output (Rudy) </notes> <contents> @@ -83,6 +84,12 @@ <file baseinstalldir="phd" name="themes/php/phpfunctions.php" role="php"/> <file baseinstalldir="phd" name="themes/php/phppdf.php" role="php"/> <file baseinstalldir="phd" name="themes/php/phpbigpdf.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearbightml.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearchm.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearchunkedhtml.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/peartheme.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearweb.php" role="php"/> + <file baseinstalldir="" name="build.php" role="script"> <tasks:replace from="@php_bin@" to="php_bin" type="pear-config"/> <tasks:replace from="@php_dir@" to="php_dir" type="pear-config"/> http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearbightml.php?view=markup&rev=1.1 Index: phd/themes/pear/pearbightml.php +++ phd/themes/pear/pearbightml.php <?php require_once $ROOT . '/themes/pear/peartheme.php'; class pearbightml extends peartheme { public function __construct(array $IDs, $ext = "html") { parent::__construct($IDs, $ext, false); $this->stream = fopen(PhDConfig::output_dir() . "pear_manual_{$this->lang}.html", "w"); self::header(); } public function appendData($data, $isChunk) { if($isChunk) { $data .= "<hr />"; } return fwrite($this->stream, $data); } public function __destruct() { self::footer(); fclose($this->stream); } public function header() { fwrite($this->stream, '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>PEAR Manual</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <div id="doc3"> <div id="body"> '); } public function footer() { fwrite($this->stream, "</div></div></body></html>"); } public function format_qandaset($open, $name, $attrs) { if ($open) { $this->cchunk["qandaentry"] = array(); $this->ostream = $this->stream; $this->stream = fopen("php://temp/maxmemory", "r+"); return ''; } $stream = $this->stream; $this->stream = $this->ostream; unset($this->ostream); rewind($stream); return parent::qandaset($stream); } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearweb.php?view=markup&rev=1.1 Index: phd/themes/pear/pearweb.php +++ phd/themes/pear/pearweb.php <?php require_once $ROOT . '/themes/pear/peartheme.php'; class pearweb extends peartheme { protected $streams = array(); protected $writeit = false; protected $outputdir = ''; public function __construct($IDs, $ext = "php", $chunked = true) { parent::__construct($IDs, $ext, $chunked); $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; if (!file_exists($this->outputdir) || is_file($this->outputdir)) { mkdir($this->outputdir) or die("Can't create the cache directory"); } else { if (file_exists($this->outputdir . "index.php")) { unlink($this->outputdir . "index.php"); } } } public function writeChunk($id, $stream) { rewind($stream); // Create random filename when the chunk doesn't have an ID if ($id === null) { $filename = tempnam($this->outputdir, 'phd'); $newfilename = $this->outputdir . basename($filename, '.tmp') . '.' . $this->ext; if(rename($filename, $newfilename)) { $filename = basename($filename, '.tmp'); } else { throw new Exception("Cannot rename $filename to $newfilename"); } trigger_error("Chunk without an ID found, TOC will NOT work. Wrote content to $newfilename.", E_USER_WARNING); } else { $filename = $id; } $filename .= '.' . $this->ext; file_put_contents($this->outputdir . $filename, $this->header($id)); file_put_contents($this->outputdir . $filename, $stream, FILE_APPEND); file_put_contents($this->outputdir . $filename, $this->footer($id), FILE_APPEND); v("Wrote %s", $this->outputdir . $filename, VERBOSE_CHUNK_WRITING); } public function appendData($data, $isChunk) { switch($isChunk) { case PhDReader::CLOSE_CHUNK: $id = $this->CURRENT_ID; $stream = array_pop($this->streams); $retval = fwrite($stream, $data); $this->writeChunk($id, $stream); fclose($stream); $this->CURRENT_ID = null; return $retval; break; case PhDReader::OPEN_CHUNK: $this->streams[] = fopen("php://temp/maxmemory", "r+"); default: $stream = end($this->streams); $retval = fwrite($stream, $data); return $retval; } } public function header($id) { $ext = "." . $this->ext; $parent = PhDHelper::getParent($id); if (!$parent || $parent == "ROOT") return '<?php sendManualHeaders("UTF-8","en"); setupNavigation(array( "home" => array("index.php", "PEAR Manual"), "prev" => array("#", ""), "next" => array("#", ""), "up" => array("#", ""), "toc" => array( array("#", "")))); manualHeader("PEAR Manual","index.php"); ?> '; // Fetch the siblings information $toc = array(); $siblings = PhDHelper::getChildren($parent); foreach($siblings as $sibling => $array) { $toc[] = array($sibling.$ext, empty($array["sdesc"]) ? $array["ldesc"] : $array["sdesc"]); } // Build the PEAR navigation table $nav = array( 'home' => array('index' . $ext, 'PEAR Manual'), 'prev' => $this->createPrev($id, $parent, $siblings), 'next' => $this->createNext($id, $parent, $siblings), 'up' => array($this->getFilename($parent).$ext, PhDHelper::getDescription($parent, true)), 'toc' => $toc ); return "<?php \n" . "sendManualHeaders(\"UTF-8\", {$this->lang});\n" . "setupNavigation(" . var_export($nav, true) . ");\n" . 'manualHeader("' . $this->getFilename($id).$ext . '", "' . PhDHelper::getDescription($id, true) . '");' . "\n" . "?>\n"; } public function footer($id) { $ext = $this->ext . "."; $parent = PhDHelper::getParent($id); return '<?php manualFooter("' . $this->getFilename($id).$ext . '", "' . PhDHelper::getDescription($id, true) . '"); ?>\n'; } protected function createPrev($id, $parent, $siblings) { $ext = '.' .$this->ext; if (!isset($siblings[$id])) { return array(null, null); } // Seek to $id while(list($tmp,) = each($siblings)) { if ($tmp == $id) { // Set the internal pointer back to $id prev($siblings); break; } } $tmp = prev($siblings); if ($tmp) { while (!empty($tmp["children"])) { $tmp = end($tmp["children"]); } return array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ? $tmp["ldesc"] : $tmp["sdesc"])); break; } return array(PhDHelper::getFilename($parent).$ext, PhDHelper::getDescription($parent, false)); } protected function createNext($id, $parent, $siblings) { $ext = '.' .$this->ext; $next = array(null, null); // {{{ Create the "next" link if (!empty($siblings[$id]["children"])) { $tmp = reset($siblings[$id]["children"]); return array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ? $tmp["ldesc"] : $tmp["sdesc"])); } do { if (!isset($siblings[$id])) { break; } // Seek to $id while(list($tmp,) = each($siblings)) { if ($tmp == $id) { break; } } $tmp = current($siblings); prev($siblings); // Reset the internal pointer to previous pos if ($tmp) { $next = array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ? $tmp["ldesc"] : $tmp["sdesc"])); break; } // We are the end element in this chapter $grandpa = PhDHelper::getParent($parent); if (!$grandpa || $grandpa == "ROOT") { // There is no next relative break; } $siblings = PhDHelper::getChildren($grandpa); $id = $parent; $parent = $grandpa; } while(true); return $next; } public function __destruct() { if (file_exists($this->outputdir . "guide.php") && !file_exists($this->outputdir . "index.php")) { copy($this->outputdir . "guide.php", $this->outputdir . "index.php"); } } public function format_qandaset($open, $name, $attrs) { if ($open) { $this->cchunk["qandaentry"] = array(); $this->appendData(null, PhDReader::OPEN_CHUNK); return ''; } $stream = array_pop($this->streams); rewind($stream); return parent::qandaset($stream); } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearchm.php?view=markup&rev=1.1 Index: phd/themes/pear/pearchm.php +++ phd/themes/pear/pearchm.php <?php require_once $ROOT . '/themes/pear/pearchunkedhtml.php'; class pearchm extends pearchunkedhtml { const DEFAULT_FONT = "Arial,10,0"; const DEFAULT_TITLE = "PEAR Manual"; // Array to manual code -> HTML Help Code conversion // Code list: http://www.helpware.net/htmlhelp/hh_info.htm // Charset list: http://www.microsoft.com/globaldev/nlsweb/default.asp // Language code: http://www.unicode.org/unicode/onlinedat/languages.html // MIME preferred charset list: http://www.iana.org/assignments/character-sets // Font list: http://www.microsoft.com/office/ork/xp/three/inte03.htm private $LANGUAGES = array( "hk" => array( "langcode" => "0xc04 Hong Kong Cantonese", "preferred_charset" => "CP950", "mime_charset_name" => "Big5", "preferred_font" => "MingLiu,10,0" ), "tw" => array( "langcode" => "0x404 Traditional Chinese", "preferred_charset" => "CP950", "mime_charset_name" => "Big5", "preferred_font" => "MingLiu,10,0" ), "cs" => array( "langcode" => "0x405 Czech", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT, ), "da" => array( "langcode" => "0x406 Danish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, ), "de" => array( "langcode" => "0x407 German (Germany)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "PEAR Handbuch", ), "el" => array( "langcode" => "0x408 Greek", "preferred_charset" => "Windows-1253", "mime_charset_name" => "Windows-1253", "preferred_font" => self::DEFAULT_FONT ), "en" => array( "langcode" => "0x809 English (United Kingdom)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "PEAR Manual", ), "es" => array( "langcode" => "0xc0a Spanish (International Sort)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "fr" => array( "langcode" => "0x40c French (France)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "Manuel PHP" ), "fi" => array( "langcode" => "0x40b Finnish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "he" => array( "langcode" => "0x40d Hebrew", "preferred_charset" => "Windows-1255", "mime_charset_name" => "Windows-1255", "preferred_font" => self::DEFAULT_FONT ), "hu" => array( "langcode" => "0x40e Hungarian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "it" => array( "langcode" => "0x410 Italian (Italy)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "Manuale PEAR", ), "ja" => array( "langcode" => "0x411 Japanese", "preferred_charset" => "CP932", "mime_charset_name" => "csWindows31J", "preferred_font" => "MS PGothic,10,0" ), "kr" => array( "langcode" => "0x412 Korean", "preferred_charset" => "CP949", "mime_charset_name" => "EUC-KR", "preferred_font" => "Gulim,10,0" ), "nl" => array( "langcode" => "0x413 Dutch (Netherlands)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "no" => array( "langcode" => "0x414 Norwegian (Bokmal)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "pl" => array( "langcode" => "0x415 Polish", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "pt_BR" => array( "langcode" => "0x416 Portuguese (Brazil)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "Manual do PEAR", ), "ro" => array( "langcode" => "0x418 Romanian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "ru" => array( "langcode" => "0x419 Russian", "preferred_charset" => "Windows-1251", "mime_charset_name" => "Windows-1251", "preferred_font" => self::DEFAULT_FONT ), "sk" => array( "langcode" => "0x41b Slovak", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "sl" => array( "langcode" => "0x424 Slovenian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "sv" => array( "langcode" => "0x41d Swedish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "zh" => array( "langcode" => "0x804 Simplified Chinese", "preferred_charset" => "CP936", "mime_charset_name" => "gb2312", "preferred_font" => "simsun,10,0" ) ); // HTML Help Workshop project file protected $hhpStream; // CHM Table of contents protected $hhcStream; protected $currentTocDepth = 0; protected $lastContent = null; protected $toc; // CHM Index Map protected $hhkStream; // Project files Output directory protected $chmdir; public function __construct(array $IDs, $ext = "html", $dir = "chm") { parent::__construct($IDs, $ext); $this->chmdir = PhDConfig::output_dir() . $dir . DIRECTORY_SEPARATOR; if(!file_exists($this->chmdir) || is_file($this->chmdir)) mkdir($this->chmdir) or die("Can't create the CHM project directory"); $this->outputdir = PhDConfig::output_dir() . $dir . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory"); $lang = PhDConfig::language(); $this->hhpStream = fopen($this->chmdir . "pear_manual_{$lang}.hhp", "w"); $this->hhcStream = fopen($this->chmdir . "pear_manual_{$lang}.hhc", "w"); $this->hhkStream = fopen($this->chmdir . "pear_manual_{$lang}.hhk", "w"); foreach(array("reset-fonts", "style", "manual") as $name) file_put_contents($this->outputdir . "$name.css", $this->fetchStylesheet($name)); self::headerChm(); } public function __destruct() { self::footerChm(); fclose($this->hhpStream); fclose($this->hhcStream); fclose($this->hhkStream); parent::__destruct(); } protected function appendChm($name, $ref, $isChunk, $hasChild) { switch ($isChunk) { case PhDReader::OPEN_CHUNK : $this->currentTocDepth++; fwrite($this->hhpStream, "{$ref}\n"); fwrite($this->hhcStream, "{$this->offset(1)}<li><object type=\"text/sitemap\">\n" . "{$this->offset(3)}<param name=\"Name\" value=\"" . htmlentities($name) . "\">\n" . "{$this->offset(3)}<param name=\"Local\" value=\"{$ref}\">\n" . "{$this->offset(2)}</object>\n"); if ($hasChild) fwrite($this->hhcStream, "{$this->offset(2)}<ul>\n"); fwrite($this->hhkStream, " <li><object type=\"text/sitemap\">\n" . " <param name=\"Local\" value=\"{$ref}\">\n" . " <param name=\"Name\" value=\"" . htmlentities($name) . "\">\n" . " </object>\n </li>\n"); break; case PhDReader::CLOSE_CHUNK : if ($hasChild) { fwrite($this->hhcStream, "{$this->offset(2)}</ul>\n"); } $this->currentTocDepth--; break; } } protected function headerChm() { $lang = PhDConfig::language(); fwrite($this->hhpStream, '[OPTIONS] Compatibility=1.1 or later Compiled file=pear_manual_' . $lang . '.chm Contents file=pear_manual_' . $lang . '.hhc Index file=pear_manual_' . $lang . '.hhk Default Window=doc Default topic=res\guide.html Display compile progress=Yes Full-text search=Yes Language=' . $this->LANGUAGES[$lang]["langcode"] . ' Title=' . ($this->LANGUAGES[$lang]["title"] ? $this->LANGUAGES[$lang]["title"] : self::DEFAULT_TITLE) . ' Default Font=' . ($this->LANGUAGES[$lang]["preferred_font"] ? $this->LANGUAGES[$lang]["preferred_font"] : self::DEFAULT_FONT). ' [WINDOWS] doc="' . ($this->LANGUAGES[$lang]["title"] ? $this->LANGUAGES[$lang]["title"] : self::DEFAULT_TITLE) . '","pear_manual_' . $lang . '.hhc","pear_manual_' . $lang . '.hhk","res\guide.html","res\guide.html",,,,,0x23520,,0x386e,,,,,,,,0 [FILES] res\reset-fonts.css res\style.css res\manual.css '); fwrite($this->hhcStream, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <meta name="generator" content="PhD"> <!-- Sitemap 1.0 --> </head> <body> <object type="text/site properties"> <param name="Window Styles" value="0x800227"> </object> <ul> '); fwrite($this->hhkStream, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <meta name="generator" content="PhD"> <!-- Sitemap 1.0 --> </head> <body> <object type="text/site properties"> <param name="Window Styles" value="0x800227"> </object> <ul> '); } protected function footerChm() { fwrite($this->hhcStream, " </ul>\n" . " </body>\n" . "</html>\n"); fwrite($this->hhkStream, " </ul>\n" . " </body>\n" . "</html>\n"); } public function appendData($data, $isChunk) { if ($this->lastContent) $this->appendChm($this->lastContent["name"], $this->lastContent["reference"], $isChunk, $this->lastContent["hasChild"]); $this->lastContent = null; return parent::appendData($data, $isChunk); } public function format_chunk($open, $name, $attrs, $props) { $this->collectContent($attrs); return parent::format_chunk($open, $name, $attrs, $props); } public function format_container_chunk($open, $name, $attrs, $props) { $this->collectContent($attrs); return parent::format_container_chunk($open, $name, $attrs, $props); } public function format_root_chunk($open, $name, $attrs, $props) { $this->collectContent($attrs); return parent::format_root_chunk($open, $name, $attrs, $props); } public function header($id) { $header = parent::header($id); // Add CSS link to <head> $header = ereg_replace('( *)</head>','\\1 <link media="all" rel="stylesheet" type="text/css" href="reset-fonts.css"/> <link media="all" rel="stylesheet" type="text/css" href="style.css"/> <link media="all" rel="stylesheet" href="manual.css"/> \\1</head>', $header); return $header; } private function collectContent($attrs) { if (isset($attrs[PhDReader::XMLNS_XML]["id"])) { $id = $attrs[PhDReader::XMLNS_XML]["id"]; $this->lastContent = array( "name" => PhDHelper::getDescription($id), "reference" => "res\\" . (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext, "hasChild" => (count(PhDHelper::getChildren($id)) > 0) ); } } private function fetchStylesheet($name) { $stylesheet = file_get_contents("http://pear.php.net/css/$name.css"); if ($stylesheet) return $stylesheet; else { v("Stylesheet $name not fetched. Uses default rendering style.", E_USER_WARNING); return ""; } } private function offset($offset) { $spaces = ""; for ($i = 0; $i < $offset + 2 * $this->currentTocDepth; $i++) $spaces .= " "; return $spaces; } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearchunkedhtml.php?view=markup&rev=1.1 Index: phd/themes/pear/pearchunkedhtml.php +++ phd/themes/pear/pearchunkedhtml.php <?php require_once $ROOT . '/themes/pear/pearweb.php'; class pearchunkedhtml extends pearweb { private $nav = ""; public function __construct(array $IDs, $ext = "html") { parent::__construct($IDs, $ext, true); $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory"); elseif (file_exists($this->outputdir . 'index.html')) unlink($this->outputdir . 'index.html'); // preserve back-compat } public function header($id) { $title = PhDHelper::getDescription($id, true); $parent = PhDHelper::getParent($id); $next = $prev = $up = array(null, null); if ($parent && $parent != "ROOT") { $siblings = PhDHelper::getChildren($parent); $prev = pearweb::createPrev($id, $parent, $siblings); $next = pearweb::createNext($id, $parent, $siblings); $up = array($parent.".html", PhDHelper::getDescription($parent, false)); } $header = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>' . $title . '</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="generator" content="PhD" /> <link rel="start" href="guide.html" title="PEAR Manual" /> '; if ($up[0]) $header .= ' <link rel="up" href="'.$up[0].'" title="'.$up[1].'" /> '; if ($prev[0]) $header .= ' <link rel="prev" href="'.$prev[0].'" title="'.$prev[1].'" /> '; if ($next[0]) $header .= ' <link rel="next" href="'.$next[0].'" title="'.$next[1].'" /> '; $header .= ' </head> <body> '; $nav = <<< NAV <table style="background-color: #E0E0E0; width: 100%; font-size: 75%; white-space: nowrap; border-collapse:collapse; border-spacing:0pt;" align="center"> <tbody> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> <tr valign="top"> <td align="left" style="padding: 0px 10px;"> <a href="{$prev[0]}">{$prev[1]}</a> </td> <td align="right" style="padding: 0px 10px;"> <a href="{$next[0]}">{$next[1]}</a> </td> </tr> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> <tr valign="top"> <td colspan="2" align="center"><a href="{$up[0]}">{$up[1]}</a></td> </tr> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> <tr valign="top"> <td colspan="2" align="center"><a href="guide.html">PEAR Manual</a></td> </tr> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> </tbody> </table> NAV; $header .= $nav . "<hr /><div id=\"doc3\"><div id=\"body\">"; $this->nav = $nav; return $header; } public function footer($id) { $nav = $this->nav; $this->nav = ""; return "<hr /></div></div>$nav</body></html>\n"; } public function __destruct() { if (file_exists($this->outputdir . "guide.html") && !file_exists($this->outputdir . 'index.html')) { copy($this->outputdir . "guide.html", $this->outputdir . "index.html"); } } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?view=markup&rev=1.1 Index: phd/themes/pear/peartheme.php +++ phd/themes/pear/peartheme.php <?php abstract class peartheme extends PhDTheme { protected $elementmap = array( 'acronym' => 'span', 'article' => 'format_container_chunk', 'answer' => 'format_answer', 'appendix' => 'format_container_chunk', 'author' => 'format_suppressed_tags', 'authorgroup' => 'format_editedby', 'bibliography' => array( /* DEFAULT */ false, 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'book' => 'format_root_chunk', 'callout' => 'format_callout', 'calloutlist' => 'format_calloutlist', 'copyright' => 'format_copyright', 'coref' => 'format_suppressed_tags', 'chapter' => 'format_container_chunk', 'classname' => 'b', 'colophon' => 'format_chunk', 'constant' => 'b', 'emphasis' => 'format_emphasis', 'entry' => 'format_entry', 'filename' => array( /* DEFAULT */ 'tt', 'titleabbrev' => 'format_suppressed_tags', ), 'firstname' => 'format_suppressed_tags', 'funcdef' => 'format_funcdef', 'funcprototype' => 'format_funcprototype', 'funcsynopsisinfo' => 'format_programlisting', 'funcsynopsis' => 'div', 'function' => 'b', 'editor' => 'div', 'email' => 'tt', 'glossary' => array( /* DEFAULT */ false, 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'glossentry' => 'format_suppressed_tags', 'glossdef' => 'format_glossdef', 'glosslist' => 'dl', 'glossterm' => 'format_glossterm', 'guimenu' => 'format_guimenu', 'holder' => 'format_holder', 'important' => 'format_admonition', 'info' => array( /* DEFAULT */ false, 'chapter' => 'format_comment', 'refsynopsisdiv' => 'format_comment', ), 'index' => array( /* DEFAULT */ false, 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'informalexample' => 'div', 'informaltable' => 'format_table', 'itemizedlist' => 'ul', 'legalnotice' => 'format_chunk', 'link' => 'format_link', 'listitem' => array( /* DEFAULT */ false, 'varlistentry' => 'dd', 'itemizedlist' => 'li', ), 'literal' => 'tt', 'literallayout' => 'p', 'menuchoice' => 'format_suppressed_tags', 'methodname' => 'tt', 'note' => 'format_admonition', 'para' => array( /* DEFAULT */ false, 'warning' => 'format_warning_para', 'important' => 'format_suppressed_tags', ), 'paramdef' => 'format_paramdef', 'parameter' => array( /* DEFAULT */ false, 'paramdef' => 'format_suppressed_tags', ), 'part' => 'format_container_chunk', 'preface' => 'format_container_chunk', 'programlisting' => 'format_programlisting', 'prompt' => 'tt', 'pubdate' => 'p', 'qandaentry' => 'format_qandaentry', 'qandaset' => 'format_qandaset', 'question' => 'format_question', 'replaceable' => 'format_replaceable', 'refentry' => 'format_chunk', 'reference' => 'format_container_chunk', 'refname' => 'h1', 'refnamediv' => 'format_suppressed_tags', 'refpurpose' => 'format_refpurpose', 'refsynopsisdiv' => 'format_refsynopsisdiv', 'row' => 'tr', 'screen' => 'format_screen', 'sect1' => 'format_chunk', 'sect2' => 'format_chunk', 'sect3' => 'format_chunk', 'sect4' => 'format_chunk', 'sect5' => 'format_chunk', 'section' => 'format_container_chunk', 'set' => 'format_root_chunk', 'setindex' => 'format_chunk', 'simpara' => array( /* DEFAULT */ false, 'entry' => 'p', 'listitem' => 'p', 'warning' => 'format_warning_para', ), 'subtitle' => 'format_subtitle', 'surname' => 'format_suppressed_tags', 'synopsis' => 'format_programlisting', 'table' => 'format_table', 'title' => array( /* DEFAULT */ false, 'article' => 'format_container_chunk_title', 'appendix' => 'format_container_chunk_title', 'chapter' => 'format_container_chunk_title', //'example' => 'format_example_title', 'part' => 'format_container_chunk_title', 'preface' => 'format_container_chunk_title', 'info' => array( /* DEFAULT */ false, 'article' => 'format_container_chunk_title', 'appendix' => 'format_container_chunk_title', 'chapter' => 'format_container_chunk_title', //'example' => 'format_example_title', 'part' => 'format_container_chunk_title', ), 'refsect1' => 'h2', 'refsect2' => 'h3', 'refsect3' => 'h4', 'section' => array( /* DEFAULT */ 'format_container_chunk_title', 'section' => array( /* DEFAULT */ 'h2', 'section' => array( /* DEFAULT */ 'h3', 'section' => array( /* DEFAULT */ 'h4', 'section' => 'h5' ))) ), 'table' => 'format_table_title', 'warning' => 'format_warning_title', ), 'tbody' => 'tbody', 'term' => 'dt', 'uri' => 'format_uri', 'userinput' => 'format_userinput', 'variablelist' => 'div', 'varlistentry' => 'dl', 'varname' => 'tt', 'warning' => 'format_warning', 'xref' => 'format_link', ); protected $textmap = array( 'classname' => array( /* DEFAULT */ false, 'refname' => 'format_refname_classname_text', ), 'filename' => array( /* DEFAULT */ false, 'titleabbrev' => 'format_suppressed_text', ), 'function' => array( /* DEFAULT */ 'format_function_text', 'funcdef' => false, 'refname' => 'format_refname_function_text', ), 'programlisting' => 'format_programlisting_text', 'refname' => 'format_refname_text', 'year' => 'format_year', ); public $role = false; protected $chunked = true; protected $lang = "en"; protected $CURRENT_ID = ""; /* Current Chunk settings */ protected $cchunk = array(); /* Default Chunk settings */ protected $dchunk = array( "fieldsynopsis" => array( "modifier" => "public", ), "container_chunk" => null, "qandaentry" => array( ), "examples" => 0, "verinfo" => false, "refname" => array(), ); public function __construct(array $IDs, $ext = "php", $chunked = true) { parent::__construct($IDs, $ext); $this->ext = $ext; $this->chunked = $chunked; } public function format_chunk($open, $name, $attrs, $props) { if (isset($attrs[PhDReader::XMLNS_XML]["id"])) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; } if ($props["isChunk"]) { $this->cchunk = $this->dchunk; } if (isset($props["lang"])) { $this->lang = $props["lang"]; } if ($name == "refentry") { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { $this->cchunk["verinfo"] = !($attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "noversion"); } else { $this->cchunk["verinfo"] = true; } } if ($name == "legalnotice") { if ($open) { return '<div class="' . $name . '" ' . ($id ? "id=\"{$id}\"" : "") . '">'; } return "</div>\n"; } return false; } public function format_container_chunk($open, $name, $attrs, $props) { if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return "<div class=\"{$name}\">"; $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { if ($props["isChunk"]) { $this->cchunk = $this->dchunk; } $chunks = PhDHelper::getChildren($id); if (count($chunks)) { $content = "<div class=\"TOC\">\n <dl>\n <dt><b>" . $this->autogen("toc", $props["lang"]) . "</b></dt>\n"; foreach($chunks as $chunkid => $junk) { $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); if ($long && $short && $long != $short) { $desc = $short. '</a> -- ' .$long; } else { $desc = ($long ? $long : $short). '</a>'; } if ($this->chunked) { $content .= " <dt><a href=\"{$chunkid}.{$this->ext}\">" . $desc . "</dt>\n"; } else { $content .= " <dt><a href=\"#{$chunkid}\">" . $this->format->TEXT(PhDHelper::getDescription($chunkid, false)) . "</a></dt>\n"; } } $content .= " </dl>\n</div>\n"; $this->cchunk["container_chunk"] = $content; } return "<div class=\"{$name}\" id=\"{$id}\">"; } return "</div>\n"; } public function format_root_chunk($open, $name, $attrs, $props) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { return "<div class=\"{$name}\">"; } $chunks = PhDHelper::getChildren($id); $content = '<p><b>' . $this->autogen("toc", $props["lang"]) . '</b></p><ul class="chunklist chunklist_'.$name.'">'; foreach($chunks as $chunkid => $junk) { $href = $this->chunked ? $chunkid .'.'. $this->ext : "#$chunkid"; $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a>'; $children = PhDHelper::getChildren($chunkid); if (count($children)) { $content .= '<ul class="chunklist chunklist_'.$name.' chunklist_children">'; foreach(PhDHelper::getChildren($chunkid) as $childid => $junk) { $href = $this->chunked ? $childid .'.'. $this->ext : "#$childid"; $long = $this->format->TEXT(PhDHelper::getDescription($childid, true)); $short = $this->format->TEXT(PhDHelper::getDescription($childid, false)); $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a></li>'; } $content .="</ul>"; } $content .= "</li>"; } $content .= "</ul>"; return $content; } public function format_link($open, $name, $attrs, $props) { if ($open) { $content = $fragment = ""; $class = $name; if(isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) { $linkto = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"]; $id = $href = PhDHelper::getFilename($linkto); if ($id != $linkto) { $fragment = "#$linkto"; } if ($this->chunked) { $href .= ".".$this->ext; } } elseif(isset($attrs[PhDReader::XMLNS_XLINK]["href"])) { $href = $attrs[PhDReader::XMLNS_XLINK]["href"]; $class .= " external"; } if ($name == "xref") { if ($this->chunked) { $link = $href; } else { $link = "#"; if (isset($linkto)) { $link .= $linkto; } else { $link .= $href; } } return '<a href="' .$link. '" class="' .$class. '">' .($content.PhDHelper::getDescription($id, false)). '</a>'; } elseif ($props["empty"]) { if ($this->chunked) { $link = ""; } else { $link = "#"; } return '<a href="' .$link.$href.$fragment. '" class="' .$class. '">' .$content.$href.$fragment. '</a>'; } else { if ($this->chunked) { $link = $href.$fragment; } elseif(isset($linkto)) { if ($fragment) { $link = $fragment; } else { $link = "#$href"; } } else { $link = $href; } return '<a href="' .$link. '" class="' .$class. '">' .$content; } } return "</a>"; } public function format_container_chunk_title($open, $name, $attrs) { if ($open) { return "<h1>"; } $ret = ""; if ($this->cchunk["container_chunk"]) { $ret = $this->cchunk["container_chunk"]; $this->cchunk["container_chunk"] = null; } return "</h1>\n" .$ret; } public function transformFromMap($open, $tag, $name, $attrs, $props) { if ($open) { $idstr = ""; if (isset($attrs[PhDReader::XMLNS_XML]["id"])) { $id = $attrs[PhDReader::XMLNS_XML]["id"]; $idstr = ' id="' .$id. '" name="' .$id. '"'; } return '<' .$tag. ' class="' .$name. '"' . $idstr. '>' . ($props["empty"] ? "</{$tag}>" : ""); } return '</' .$tag. '>'; } public function format_programlisting($open, $name, $attrs) { if ($open) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { $this->role = $attrs[PhDReader::XMLNS_DOCBOOK]["role"]; } else { $this->role = "default"; } return '<table class="EXAMPLE-CODE" bgcolor="#eeeeee" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><pre class="'. ($this->role ? $this->role : 'programlisting') .'">'; } $this->role = false; return "</pre></td></tr></table>\n"; } public function format_programlisting_text($value, $tag) { switch($this->role) { case "php": if ( strrpos($value, "<?php") || strrpos($value, "?>") ) return highlight_string(trim($value), 1); else return highlight_string("<?php\n" . trim($value) . "\n?>", 1); break; default: return htmlspecialchars($value, ENT_QUOTES, "UTF-8"); } } public function format_screen($open, $name, $attrs) { if ($open) { return '<table class="EXAMPLE-CODE" bgcolor="#eeeeee" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><pre class="screen">'; } return "</pre></td></tr></table>\n"; } public function CDATA($str) { if (!$this->role) return str_replace(array("\n", " "), array("<br/>", " "), htmlspecialchars($str, ENT_QUOTES, "UTF-8")); switch($this->role) { case "php": if ( strrpos($str, "<?php") || strrpos($str, "?>") ) return (highlight_string(trim($str), 1)); else return (highlight_string("<?php\n" . trim($str) . "\n?>", 1)); break; default: return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } } public function format_suppressed_tags($open, $name, $attrs) { /* Ignore it */ return ""; } public function format_suppressed_text($value, $tag) { /* Suppress any content */ return ""; } public function format_subtitle($open, $name, $attrs) { if ($open) return '<p><font color="red">'; return '</font></p>'; } public function format_editedby($open, $name, $attrs, $props) { if ($open) return "<h2 class=\"EDITEDBY\">" . $this->autogen("editedby", $props["lang"]) . "</h2>"; } public function format_copyright($open, $name, $attrs) { if ($open) { if ($this->chunked) { return '<p class="'.$name.'"><a href="copyright.' . $this->ext . '">Copyright</a> © '; } else { return '<p class="'.$name.'"><a href="#copyright">Copyright</a> © '; } } return '</p>'; } public function format_comment($open, $name, $attrs) { if ($open) { return '<!-- '; } return '-->'; } public function format_holder($open, $name, $attrs, $props) { if ($open) return $this->autogen("by", $props["lang"]) . " "; } public function format_year($value) { return $value . ", "; } public function format_admonition($open, $name, $attrs, $props) { if ($open) { return '<p><div class="' . $name . '"><blockquote class="' . $name . '"><p><b>'.$this->autogen($name, $props["lang"]). ': </b>'; } return "</p></blockquote></div></p>"; } public function format_table($open, $name, $attrs, $props) { if ($open) { return '<p><div class="'.$name.'"><table border="1" class="CALSTABLE">'; } return "</table></div></p>"; } public function format_entry($open, $name, $attrs, $props) { if ($open) { return '<td align="left" valign="middle">'; } return "</td>"; } public function format_table_title($open, $name, $attrs, $props) { if ($props["empty"]) return ""; if ($open) { return '<p><b>'; } return '</b></p>'; } public function format_userinput($open, $name, $attrs, $props) { if ($open) { return '<tt class="'.$name.'"><b>'; } return "</b></tt>"; } function format_replaceable($open, $name, $attrs, $props) { if ($open) { return '<tt class="'.$name.'"><i>'; } return "</i></tt>"; } public function format_warning($open, $name, $attrs, $props) { if ($open) { return '<div class="warning"><table class="warning" border="1" width="100%"><tbody>'; } return "</td></tr></tbody></table></div>"; } public function format_warning_title($open, $name, $attrs, $props) { if ($open) { return '<tr><td align="center"><b>'; } return "</b></td></tr>"; } public function format_warning_para($open, $name, $attrs, $props) { if ($open) { if (!$props["sibling"]) return '<tr align="center"><td><b>' . $this->autogen("warning", $props["lang"]) . "</b></td></tr>" . '<tr><td align="left"><p>'; return '<tr><td align="left"><p>'; } return "</p></td></tr>"; } public function format_refname_function_text($value) { $this->cchunk["refname"][] = '<b class="function">' . $this->format->TEXT($value . '()') . '</b>'; return false; } public function format_refname_classname_text($value) { $this->cchunk["refname"][] = '<b class="classname">' . $this->format->TEXT($value) . '</b>'; return false; } public function format_refpurpose($open, $tag, $attrs) { if ($open) { $refnames = implode(' ', $this->cchunk["refname"]); return '<div class="refnamediv">'. $refnames. ' -- '; } return "</div>\n"; } public function format_refname_text($value, $tag) { $this->cchunk["refname"][] = $this->format->TEXT($value); return false; } public function format_function_text($value) { return $this->format->TEXT($value."()"); } public function format_paramdef($open, $name, $attrs, $props) { if ($open && $props["sibling"] == 'paramdef') return ' , '; return false; } public function format_funcdef($open, $name, $attrs, $props) { if (!$open) return ' ( '; return false; } public function format_funcprototype($open, $name, $attrs, $props) { if ($open) { return "<p><code class=$name>"; } else return ")</code></p>"; } public function format_uri($open, $name, $attrs, $props) { if ($open) { return '<font color="red">'; } else return "</font>"; } public function format_refsynopsisdiv($open, $name, $attrs, $props) { if ($open) { return '<h2 class="refsynopsisdiv">Synopsis</h2><p>'; } return '</p>'; } public function format_guimenu($open, $name, $attrs, $props) { if ($open) { if ($props["sibling"]) return '-><span class="guimenu"><i>'; return '<span class="guimenu"><i>'; } return '</i></span>'; } /* FIXME: This function is a crazy performance killer */ public function qandaset($stream) { $xml = stream_get_contents($stream); $old = libxml_use_internal_errors(true); $doc = new DOMDocument("1.0", "UTF-8"); $doc->preserveWhitespace = false; $doc->loadXML(html_entity_decode(str_replace("&", "&amp;", "<div>$xml</div>"), ENT_QUOTES, "UTF-8")); if ($err = libxml_get_errors()) { print_r($err); libxml_clear_errors(); } fclose($stream); libxml_use_internal_errors($old); $xpath = new DOMXPath($doc); $nlist = $xpath->query("//div/dl/dt/strong"); $ret = '<div class="qandaset"><ol class="qandaset_questions">'; $i = 0; foreach($nlist as $node) { $ret .= '<li><a href="#' .($this->cchunk["qandaentry"][$i++]). '">' .($node->textContent). '</a></li>'; } return $ret.'</ol>'.$xml.'</div>'; } public function format_qandaentry($open, $name, $attrs) { if ($open) { $this->cchunk["qandaentry"][] = $this->CURRENT_ID . ".entry" . count($this->cchunk["qandaentry"]); return '<dl>'; } return '</dl>'; } public function format_answer($open, $name, $attrs) { if ($open) { return '<dd><a name="' .end($this->cchunk["qandaentry"]).'"></a>'; } return "</dd>"; } public function format_question($open, $name, $attrs) { if ($open) { return '<dt><strong>'; } return '</strong></dt>'; } public function format_emphasis($open, $name, $attrs) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) && $attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "bold") $role = "b"; else $role = "i"; if ($open) { return '<' . $role . ' class="' . $name . '">'; } return "</{$role}>"; } public function format_glossterm($open, $name, $attrs) { if ($open) { return '<dt><b>'; } return "</b></dt>"; } public function format_glossdef($open, $name, $attrs) { if ($open) { return '<dd><p>'; } return "</p></dd>"; } public function format_calloutlist($open, $name, $attrs) { if ($open) { $this->cchunk["callouts"] = 0; return '<table>'; } return '</table>'; } public function format_callout($open, $name, $attrs) { if ($open) { return '<tr><td><a href="#'.$attrs[PhDReader::XMLNS_DOCBOOK]["arearefs"].'">(' .++$this->cchunk["callouts"]. ')</a></td><td>'; } return "</td></tr>\n"; } }
http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45.2.13&r2=1.45.2.14&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45.2.13 phd/config.php:1.45.2.14 --- phd/config.php:1.45.2.13 Mon Oct 6 15:35:25 2008 +++ phd/config.php Thu Oct 16 15:43:46 2008 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.45.2.13 2008/10/06 15:35:25 bjori Exp $ */ +/* $Id: config.php,v 1.45.2.14 2008/10/16 15:43:46 loudi Exp $ */ /* {{{ PhD error & message handler */ @@ -324,6 +324,7 @@ echo "Supported formats:\n"; echo "\txhtml\n"; echo "\tmanpage\n"; + echo "\tpdf:\n"; break; case "t": @@ -337,6 +338,10 @@ echo "\t\tchmsource\n"; echo "\t\tphpkdevelop\n"; echo "\t\thowto\n"; + echo "\t\tpearweb\n"; + echo "\t\tpearbightml\n"; + echo "\t\tpearchunkedhtml\n"; + echo "\t\tpearchm\n"; echo "\tmanpage:\n"; echo "\t\tphpfunctions\n"; echo "\tpdf:\n"; @@ -361,6 +366,10 @@ echo "\t\tchmsource\n"; echo "\t\tphpkdevelop\n"; echo "\t\thowto\n"; + echo "\t\tpearweb\n"; + echo "\t\tpearbightml\n"; + echo "\t\tpearchunkedhtml\n"; + echo "\t\tpearchm\n"; echo "\tmanpage:\n"; echo "\t\tphpfunctions\n"; echo "\tpdf:\n"; @@ -414,7 +423,8 @@ case "theme": /* Remove the default themes */ $OPTIONS["output_theme"]["xhtml"]["php"] = array(); - + $OPTIONS["output_theme"]["manpage"]["php"] = array(); + $OPTIONS["output_theme"]["xhtml"]["pear"] = array(); foreach((array)$v as $i => $val) { switch($val) { case "phpweb": @@ -438,6 +448,22 @@ $OPTIONS["output_theme"]["pdf"]["php"][] = $val; } break; + case "pear": + $OPTIONS["output_theme"]["xhtml"]["pear"] = array( + 'pearweb', + 'pearchunkedhtml', + 'pearbightml', + 'pearchm' + ); + break; + case "pearweb": + case "pearchunkedhtml": + case "pearbightml": + case "pearchm": + if (!in_array($val, $OPTIONS["output_theme"]["xhtml"]["pear"])) { + $OPTIONS["output_theme"]["xhtml"]["pear"][] = $val; + } + break; default: trigger_error(sprintf("Unknown theme '%s'", $val), E_USER_ERROR); } http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.74.2.18&r2=1.74.2.19&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.74.2.18 phd/package.xml:1.74.2.19 --- phd/package.xml:1.74.2.18 Tue Oct 7 07:04:49 2008 +++ phd/package.xml Thu Oct 16 15:43:46 2008 @@ -49,6 +49,7 @@ Fixed bug #46094 (and then from now on italic). (Hannes) Fixed a bug where it was only possible to pass one parameter to phd.bat (Kalle) Fixed a bug where it wasn't possible to have paths with spaces in when using phd.bat (Kalle) + Added PEAR XHTML output (Rudy) </notes> <contents> @@ -83,6 +84,12 @@ <file baseinstalldir="phd" name="themes/php/phpfunctions.php" role="php"/> <file baseinstalldir="phd" name="themes/php/phppdf.php" role="php"/> <file baseinstalldir="phd" name="themes/php/phpbigpdf.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearbightml.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearchm.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearchunkedhtml.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/peartheme.php" role="php"/> + <file baseinstalldir="phd" name="themes/pear/pearweb.php" role="php"/> + <file baseinstalldir="" name="build.php" role="script"> <tasks:replace from="@php_bin@" to="php_bin" type="pear-config"/> <tasks:replace from="@php_dir@" to="php_dir" type="pear-config"/> http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearbightml.php?view=markup&rev=1.1 Index: phd/themes/pear/pearbightml.php +++ phd/themes/pear/pearbightml.php <?php require_once $ROOT . '/themes/pear/peartheme.php'; class pearbightml extends peartheme { public function __construct(array $IDs, $ext = "html") { parent::__construct($IDs, $ext, false); $this->stream = fopen(PhDConfig::output_dir() . "pear_manual_{$this->lang}.html", "w"); self::header(); } public function appendData($data, $isChunk) { if($isChunk) { $data .= "<hr />"; } return fwrite($this->stream, $data); } public function __destruct() { self::footer(); fclose($this->stream); } public function header() { fwrite($this->stream, '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>PEAR Manual</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <div id="doc3"> <div id="body"> '); } public function footer() { fwrite($this->stream, "</div></div></body></html>"); } public function format_qandaset($open, $name, $attrs) { if ($open) { $this->cchunk["qandaentry"] = array(); $this->ostream = $this->stream; $this->stream = fopen("php://temp/maxmemory", "r+"); return ''; } $stream = $this->stream; $this->stream = $this->ostream; unset($this->ostream); rewind($stream); return parent::qandaset($stream); } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearweb.php?view=markup&rev=1.1 Index: phd/themes/pear/pearweb.php +++ phd/themes/pear/pearweb.php <?php require_once $ROOT . '/themes/pear/peartheme.php'; class pearweb extends peartheme { protected $streams = array(); protected $writeit = false; protected $outputdir = ''; public function __construct($IDs, $ext = "php", $chunked = true) { parent::__construct($IDs, $ext, $chunked); $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; if (!file_exists($this->outputdir) || is_file($this->outputdir)) { mkdir($this->outputdir) or die("Can't create the cache directory"); } else { if (file_exists($this->outputdir . "index.php")) { unlink($this->outputdir . "index.php"); } } } public function writeChunk($id, $stream) { rewind($stream); // Create random filename when the chunk doesn't have an ID if ($id === null) { $filename = tempnam($this->outputdir, 'phd'); $newfilename = $this->outputdir . basename($filename, '.tmp') . '.' . $this->ext; if(rename($filename, $newfilename)) { $filename = basename($filename, '.tmp'); } else { throw new Exception("Cannot rename $filename to $newfilename"); } trigger_error("Chunk without an ID found, TOC will NOT work. Wrote content to $newfilename.", E_USER_WARNING); } else { $filename = $id; } $filename .= '.' . $this->ext; file_put_contents($this->outputdir . $filename, $this->header($id)); file_put_contents($this->outputdir . $filename, $stream, FILE_APPEND); file_put_contents($this->outputdir . $filename, $this->footer($id), FILE_APPEND); v("Wrote %s", $this->outputdir . $filename, VERBOSE_CHUNK_WRITING); } public function appendData($data, $isChunk) { switch($isChunk) { case PhDReader::CLOSE_CHUNK: $id = $this->CURRENT_ID; $stream = array_pop($this->streams); $retval = fwrite($stream, $data); $this->writeChunk($id, $stream); fclose($stream); $this->CURRENT_ID = null; return $retval; break; case PhDReader::OPEN_CHUNK: $this->streams[] = fopen("php://temp/maxmemory", "r+"); default: $stream = end($this->streams); $retval = fwrite($stream, $data); return $retval; } } public function header($id) { $ext = "." . $this->ext; $parent = PhDHelper::getParent($id); if (!$parent || $parent == "ROOT") return '<?php sendManualHeaders("UTF-8","en"); setupNavigation(array( "home" => array("index.php", "PEAR Manual"), "prev" => array("#", ""), "next" => array("#", ""), "up" => array("#", ""), "toc" => array( array("#", "")))); manualHeader("PEAR Manual","index.php"); ?> '; // Fetch the siblings information $toc = array(); $siblings = PhDHelper::getChildren($parent); foreach($siblings as $sibling => $array) { $toc[] = array($sibling.$ext, empty($array["sdesc"]) ? $array["ldesc"] : $array["sdesc"]); } // Build the PEAR navigation table $nav = array( 'home' => array('index' . $ext, 'PEAR Manual'), 'prev' => $this->createPrev($id, $parent, $siblings), 'next' => $this->createNext($id, $parent, $siblings), 'up' => array($this->getFilename($parent).$ext, PhDHelper::getDescription($parent, true)), 'toc' => $toc ); return "<?php \n" . "sendManualHeaders(\"UTF-8\", {$this->lang});\n" . "setupNavigation(" . var_export($nav, true) . ");\n" . 'manualHeader("' . $this->getFilename($id).$ext . '", "' . PhDHelper::getDescription($id, true) . '");' . "\n" . "?>\n"; } public function footer($id) { $ext = $this->ext . "."; $parent = PhDHelper::getParent($id); return '<?php manualFooter("' . $this->getFilename($id).$ext . '", "' . PhDHelper::getDescription($id, true) . '"); ?>\n'; } protected function createPrev($id, $parent, $siblings) { $ext = '.' .$this->ext; if (!isset($siblings[$id])) { return array(null, null); } // Seek to $id while(list($tmp,) = each($siblings)) { if ($tmp == $id) { // Set the internal pointer back to $id prev($siblings); break; } } $tmp = prev($siblings); if ($tmp) { while (!empty($tmp["children"])) { $tmp = end($tmp["children"]); } return array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ? $tmp["ldesc"] : $tmp["sdesc"])); break; } return array(PhDHelper::getFilename($parent).$ext, PhDHelper::getDescription($parent, false)); } protected function createNext($id, $parent, $siblings) { $ext = '.' .$this->ext; $next = array(null, null); // {{{ Create the "next" link if (!empty($siblings[$id]["children"])) { $tmp = reset($siblings[$id]["children"]); return array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ? $tmp["ldesc"] : $tmp["sdesc"])); } do { if (!isset($siblings[$id])) { break; } // Seek to $id while(list($tmp,) = each($siblings)) { if ($tmp == $id) { break; } } $tmp = current($siblings); prev($siblings); // Reset the internal pointer to previous pos if ($tmp) { $next = array($tmp["filename"].$ext, (empty($tmp["sdesc"]) ? $tmp["ldesc"] : $tmp["sdesc"])); break; } // We are the end element in this chapter $grandpa = PhDHelper::getParent($parent); if (!$grandpa || $grandpa == "ROOT") { // There is no next relative break; } $siblings = PhDHelper::getChildren($grandpa); $id = $parent; $parent = $grandpa; } while(true); return $next; } public function __destruct() { if (file_exists($this->outputdir . "guide.php") && !file_exists($this->outputdir . "index.php")) { copy($this->outputdir . "guide.php", $this->outputdir . "index.php"); } } public function format_qandaset($open, $name, $attrs) { if ($open) { $this->cchunk["qandaentry"] = array(); $this->appendData(null, PhDReader::OPEN_CHUNK); return ''; } $stream = array_pop($this->streams); rewind($stream); return parent::qandaset($stream); } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearchm.php?view=markup&rev=1.1 Index: phd/themes/pear/pearchm.php +++ phd/themes/pear/pearchm.php <?php require_once $ROOT . '/themes/pear/pearchunkedhtml.php'; class pearchm extends pearchunkedhtml { const DEFAULT_FONT = "Arial,10,0"; const DEFAULT_TITLE = "PEAR Manual"; // Array to manual code -> HTML Help Code conversion // Code list: http://www.helpware.net/htmlhelp/hh_info.htm // Charset list: http://www.microsoft.com/globaldev/nlsweb/default.asp // Language code: http://www.unicode.org/unicode/onlinedat/languages.html // MIME preferred charset list: http://www.iana.org/assignments/character-sets // Font list: http://www.microsoft.com/office/ork/xp/three/inte03.htm private $LANGUAGES = array( "hk" => array( "langcode" => "0xc04 Hong Kong Cantonese", "preferred_charset" => "CP950", "mime_charset_name" => "Big5", "preferred_font" => "MingLiu,10,0" ), "tw" => array( "langcode" => "0x404 Traditional Chinese", "preferred_charset" => "CP950", "mime_charset_name" => "Big5", "preferred_font" => "MingLiu,10,0" ), "cs" => array( "langcode" => "0x405 Czech", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT, ), "da" => array( "langcode" => "0x406 Danish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, ), "de" => array( "langcode" => "0x407 German (Germany)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "PEAR Handbuch", ), "el" => array( "langcode" => "0x408 Greek", "preferred_charset" => "Windows-1253", "mime_charset_name" => "Windows-1253", "preferred_font" => self::DEFAULT_FONT ), "en" => array( "langcode" => "0x809 English (United Kingdom)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "PEAR Manual", ), "es" => array( "langcode" => "0xc0a Spanish (International Sort)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "fr" => array( "langcode" => "0x40c French (France)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "Manuel PHP" ), "fi" => array( "langcode" => "0x40b Finnish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "he" => array( "langcode" => "0x40d Hebrew", "preferred_charset" => "Windows-1255", "mime_charset_name" => "Windows-1255", "preferred_font" => self::DEFAULT_FONT ), "hu" => array( "langcode" => "0x40e Hungarian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "it" => array( "langcode" => "0x410 Italian (Italy)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "Manuale PEAR", ), "ja" => array( "langcode" => "0x411 Japanese", "preferred_charset" => "CP932", "mime_charset_name" => "csWindows31J", "preferred_font" => "MS PGothic,10,0" ), "kr" => array( "langcode" => "0x412 Korean", "preferred_charset" => "CP949", "mime_charset_name" => "EUC-KR", "preferred_font" => "Gulim,10,0" ), "nl" => array( "langcode" => "0x413 Dutch (Netherlands)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "no" => array( "langcode" => "0x414 Norwegian (Bokmal)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "pl" => array( "langcode" => "0x415 Polish", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "pt_BR" => array( "langcode" => "0x416 Portuguese (Brazil)", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT, "title" => "Manual do PEAR", ), "ro" => array( "langcode" => "0x418 Romanian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "ru" => array( "langcode" => "0x419 Russian", "preferred_charset" => "Windows-1251", "mime_charset_name" => "Windows-1251", "preferred_font" => self::DEFAULT_FONT ), "sk" => array( "langcode" => "0x41b Slovak", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "sl" => array( "langcode" => "0x424 Slovenian", "preferred_charset" => "Windows-1250", "mime_charset_name" => "Windows-1250", "preferred_font" => self::DEFAULT_FONT ), "sv" => array( "langcode" => "0x41d Swedish", "preferred_charset" => "Windows-1252", "mime_charset_name" => "Windows-1252", "preferred_font" => self::DEFAULT_FONT ), "zh" => array( "langcode" => "0x804 Simplified Chinese", "preferred_charset" => "CP936", "mime_charset_name" => "gb2312", "preferred_font" => "simsun,10,0" ) ); // HTML Help Workshop project file protected $hhpStream; // CHM Table of contents protected $hhcStream; protected $currentTocDepth = 0; protected $lastContent = null; protected $toc; // CHM Index Map protected $hhkStream; // Project files Output directory protected $chmdir; public function __construct(array $IDs, $ext = "html", $dir = "chm") { parent::__construct($IDs, $ext); $this->chmdir = PhDConfig::output_dir() . $dir . DIRECTORY_SEPARATOR; if(!file_exists($this->chmdir) || is_file($this->chmdir)) mkdir($this->chmdir) or die("Can't create the CHM project directory"); $this->outputdir = PhDConfig::output_dir() . $dir . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory"); $lang = PhDConfig::language(); $this->hhpStream = fopen($this->chmdir . "pear_manual_{$lang}.hhp", "w"); $this->hhcStream = fopen($this->chmdir . "pear_manual_{$lang}.hhc", "w"); $this->hhkStream = fopen($this->chmdir . "pear_manual_{$lang}.hhk", "w"); foreach(array("reset-fonts", "style", "manual") as $name) file_put_contents($this->outputdir . "$name.css", $this->fetchStylesheet($name)); self::headerChm(); } public function __destruct() { self::footerChm(); fclose($this->hhpStream); fclose($this->hhcStream); fclose($this->hhkStream); parent::__destruct(); } protected function appendChm($name, $ref, $isChunk, $hasChild) { switch ($isChunk) { case PhDReader::OPEN_CHUNK : $this->currentTocDepth++; fwrite($this->hhpStream, "{$ref}\n"); fwrite($this->hhcStream, "{$this->offset(1)}<li><object type=\"text/sitemap\">\n" . "{$this->offset(3)}<param name=\"Name\" value=\"" . htmlentities($name) . "\">\n" . "{$this->offset(3)}<param name=\"Local\" value=\"{$ref}\">\n" . "{$this->offset(2)}</object>\n"); if ($hasChild) fwrite($this->hhcStream, "{$this->offset(2)}<ul>\n"); fwrite($this->hhkStream, " <li><object type=\"text/sitemap\">\n" . " <param name=\"Local\" value=\"{$ref}\">\n" . " <param name=\"Name\" value=\"" . htmlentities($name) . "\">\n" . " </object>\n </li>\n"); break; case PhDReader::CLOSE_CHUNK : if ($hasChild) { fwrite($this->hhcStream, "{$this->offset(2)}</ul>\n"); } $this->currentTocDepth--; break; } } protected function headerChm() { $lang = PhDConfig::language(); fwrite($this->hhpStream, '[OPTIONS] Compatibility=1.1 or later Compiled file=pear_manual_' . $lang . '.chm Contents file=pear_manual_' . $lang . '.hhc Index file=pear_manual_' . $lang . '.hhk Default Window=doc Default topic=res\guide.html Display compile progress=Yes Full-text search=Yes Language=' . $this->LANGUAGES[$lang]["langcode"] . ' Title=' . ($this->LANGUAGES[$lang]["title"] ? $this->LANGUAGES[$lang]["title"] : self::DEFAULT_TITLE) . ' Default Font=' . ($this->LANGUAGES[$lang]["preferred_font"] ? $this->LANGUAGES[$lang]["preferred_font"] : self::DEFAULT_FONT). ' [WINDOWS] doc="' . ($this->LANGUAGES[$lang]["title"] ? $this->LANGUAGES[$lang]["title"] : self::DEFAULT_TITLE) . '","pear_manual_' . $lang . '.hhc","pear_manual_' . $lang . '.hhk","res\guide.html","res\guide.html",,,,,0x23520,,0x386e,,,,,,,,0 [FILES] res\reset-fonts.css res\style.css res\manual.css '); fwrite($this->hhcStream, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <meta name="generator" content="PhD"> <!-- Sitemap 1.0 --> </head> <body> <object type="text/site properties"> <param name="Window Styles" value="0x800227"> </object> <ul> '); fwrite($this->hhkStream, '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <meta name="generator" content="PhD"> <!-- Sitemap 1.0 --> </head> <body> <object type="text/site properties"> <param name="Window Styles" value="0x800227"> </object> <ul> '); } protected function footerChm() { fwrite($this->hhcStream, " </ul>\n" . " </body>\n" . "</html>\n"); fwrite($this->hhkStream, " </ul>\n" . " </body>\n" . "</html>\n"); } public function appendData($data, $isChunk) { if ($this->lastContent) $this->appendChm($this->lastContent["name"], $this->lastContent["reference"], $isChunk, $this->lastContent["hasChild"]); $this->lastContent = null; return parent::appendData($data, $isChunk); } public function format_chunk($open, $name, $attrs, $props) { $this->collectContent($attrs); return parent::format_chunk($open, $name, $attrs, $props); } public function format_container_chunk($open, $name, $attrs, $props) { $this->collectContent($attrs); return parent::format_container_chunk($open, $name, $attrs, $props); } public function format_root_chunk($open, $name, $attrs, $props) { $this->collectContent($attrs); return parent::format_root_chunk($open, $name, $attrs, $props); } public function header($id) { $header = parent::header($id); // Add CSS link to <head> $header = ereg_replace('( *)</head>','\\1 <link media="all" rel="stylesheet" type="text/css" href="reset-fonts.css"/> <link media="all" rel="stylesheet" type="text/css" href="style.css"/> <link media="all" rel="stylesheet" href="manual.css"/> \\1</head>', $header); return $header; } private function collectContent($attrs) { if (isset($attrs[PhDReader::XMLNS_XML]["id"])) { $id = $attrs[PhDReader::XMLNS_XML]["id"]; $this->lastContent = array( "name" => PhDHelper::getDescription($id), "reference" => "res\\" . (PhDHelper::getFilename($id) ? PhDHelper::getFilename($id) : $id) . "." . $this->ext, "hasChild" => (count(PhDHelper::getChildren($id)) > 0) ); } } private function fetchStylesheet($name) { $stylesheet = file_get_contents("http://pear.php.net/css/$name.css"); if ($stylesheet) return $stylesheet; else { v("Stylesheet $name not fetched. Uses default rendering style.", E_USER_WARNING); return ""; } } private function offset($offset) { $spaces = ""; for ($i = 0; $i < $offset + 2 * $this->currentTocDepth; $i++) $spaces .= " "; return $spaces; } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearchunkedhtml.php?view=markup&rev=1.1 Index: phd/themes/pear/pearchunkedhtml.php +++ phd/themes/pear/pearchunkedhtml.php <?php require_once $ROOT . '/themes/pear/pearweb.php'; class pearchunkedhtml extends pearweb { private $nav = ""; public function __construct(array $IDs, $ext = "html") { parent::__construct($IDs, $ext, true); $this->outputdir = PhDConfig::output_dir() . $this->ext . DIRECTORY_SEPARATOR; if(!file_exists($this->outputdir) || is_file($this->outputdir)) mkdir($this->outputdir) or die("Can't create the cache directory"); elseif (file_exists($this->outputdir . 'index.html')) unlink($this->outputdir . 'index.html'); // preserve back-compat } public function header($id) { $title = PhDHelper::getDescription($id, true); $parent = PhDHelper::getParent($id); $next = $prev = $up = array(null, null); if ($parent && $parent != "ROOT") { $siblings = PhDHelper::getChildren($parent); $prev = pearweb::createPrev($id, $parent, $siblings); $next = pearweb::createNext($id, $parent, $siblings); $up = array($parent.".html", PhDHelper::getDescription($parent, false)); } $header = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>' . $title . '</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta name="generator" content="PhD" /> <link rel="start" href="guide.html" title="PEAR Manual" /> '; if ($up[0]) $header .= ' <link rel="up" href="'.$up[0].'" title="'.$up[1].'" /> '; if ($prev[0]) $header .= ' <link rel="prev" href="'.$prev[0].'" title="'.$prev[1].'" /> '; if ($next[0]) $header .= ' <link rel="next" href="'.$next[0].'" title="'.$next[1].'" /> '; $header .= ' </head> <body> '; $nav = <<< NAV <table style="background-color: #E0E0E0; width: 100%; font-size: 75%; white-space: nowrap; border-collapse:collapse; border-spacing:0pt;" align="center"> <tbody> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> <tr valign="top"> <td align="left" style="padding: 0px 10px;"> <a href="{$prev[0]}">{$prev[1]}</a> </td> <td align="right" style="padding: 0px 10px;"> <a href="{$next[0]}">{$next[1]}</a> </td> </tr> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> <tr valign="top"> <td colspan="2" align="center"><a href="{$up[0]}">{$up[1]}</a></td> </tr> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> <tr valign="top"> <td colspan="2" align="center"><a href="guide.html">PEAR Manual</a></td> </tr> <tr valign="top"> <td colspan="2" height="1"><hr style="height: 1px; margin: 0px;"></td> </tr> </tbody> </table> NAV; $header .= $nav . "<hr /><div id=\"doc3\"><div id=\"body\">"; $this->nav = $nav; return $header; } public function footer($id) { $nav = $this->nav; $this->nav = ""; return "<hr /></div></div>$nav</body></html>\n"; } public function __destruct() { if (file_exists($this->outputdir . "guide.html") && !file_exists($this->outputdir . 'index.html')) { copy($this->outputdir . "guide.html", $this->outputdir . "index.html"); } } } http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?view=markup&rev=1.1 Index: phd/themes/pear/peartheme.php +++ phd/themes/pear/peartheme.php <?php abstract class peartheme extends PhDTheme { protected $elementmap = array( 'acronym' => 'span', 'article' => 'format_container_chunk', 'answer' => 'format_answer', 'appendix' => 'format_container_chunk', 'author' => 'format_suppressed_tags', 'authorgroup' => 'format_editedby', 'bibliography' => array( /* DEFAULT */ false, 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'book' => 'format_root_chunk', 'callout' => 'format_callout', 'calloutlist' => 'format_calloutlist', 'copyright' => 'format_copyright', 'coref' => 'format_suppressed_tags', 'chapter' => 'format_container_chunk', 'classname' => 'b', 'colophon' => 'format_chunk', 'constant' => 'b', 'emphasis' => 'format_emphasis', 'entry' => 'format_entry', 'filename' => array( /* DEFAULT */ 'tt', 'titleabbrev' => 'format_suppressed_tags', ), 'firstname' => 'format_suppressed_tags', 'funcdef' => 'format_funcdef', 'funcprototype' => 'format_funcprototype', 'funcsynopsisinfo' => 'format_programlisting', 'funcsynopsis' => 'div', 'function' => 'b', 'editor' => 'div', 'email' => 'tt', 'glossary' => array( /* DEFAULT */ false, 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'glossentry' => 'format_suppressed_tags', 'glossdef' => 'format_glossdef', 'glosslist' => 'dl', 'glossterm' => 'format_glossterm', 'guimenu' => 'format_guimenu', 'holder' => 'format_holder', 'important' => 'format_admonition', 'info' => array( /* DEFAULT */ false, 'chapter' => 'format_comment', 'refsynopsisdiv' => 'format_comment', ), 'index' => array( /* DEFAULT */ false, 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'informalexample' => 'div', 'informaltable' => 'format_table', 'itemizedlist' => 'ul', 'legalnotice' => 'format_chunk', 'link' => 'format_link', 'listitem' => array( /* DEFAULT */ false, 'varlistentry' => 'dd', 'itemizedlist' => 'li', ), 'literal' => 'tt', 'literallayout' => 'p', 'menuchoice' => 'format_suppressed_tags', 'methodname' => 'tt', 'note' => 'format_admonition', 'para' => array( /* DEFAULT */ false, 'warning' => 'format_warning_para', 'important' => 'format_suppressed_tags', ), 'paramdef' => 'format_paramdef', 'parameter' => array( /* DEFAULT */ false, 'paramdef' => 'format_suppressed_tags', ), 'part' => 'format_container_chunk', 'preface' => 'format_container_chunk', 'programlisting' => 'format_programlisting', 'prompt' => 'tt', 'pubdate' => 'p', 'qandaentry' => 'format_qandaentry', 'qandaset' => 'format_qandaset', 'question' => 'format_question', 'replaceable' => 'format_replaceable', 'refentry' => 'format_chunk', 'reference' => 'format_container_chunk', 'refname' => 'h1', 'refnamediv' => 'format_suppressed_tags', 'refpurpose' => 'format_refpurpose', 'refsynopsisdiv' => 'format_refsynopsisdiv', 'row' => 'tr', 'screen' => 'format_screen', 'sect1' => 'format_chunk', 'sect2' => 'format_chunk', 'sect3' => 'format_chunk', 'sect4' => 'format_chunk', 'sect5' => 'format_chunk', 'section' => 'format_container_chunk', 'set' => 'format_root_chunk', 'setindex' => 'format_chunk', 'simpara' => array( /* DEFAULT */ false, 'entry' => 'p', 'listitem' => 'p', 'warning' => 'format_warning_para', ), 'subtitle' => 'format_subtitle', 'surname' => 'format_suppressed_tags', 'synopsis' => 'format_programlisting', 'table' => 'format_table', 'title' => array( /* DEFAULT */ false, 'article' => 'format_container_chunk_title', 'appendix' => 'format_container_chunk_title', 'chapter' => 'format_container_chunk_title', //'example' => 'format_example_title', 'part' => 'format_container_chunk_title', 'preface' => 'format_container_chunk_title', 'info' => array( /* DEFAULT */ false, 'article' => 'format_container_chunk_title', 'appendix' => 'format_container_chunk_title', 'chapter' => 'format_container_chunk_title', //'example' => 'format_example_title', 'part' => 'format_container_chunk_title', ), 'refsect1' => 'h2', 'refsect2' => 'h3', 'refsect3' => 'h4', 'section' => array( /* DEFAULT */ 'format_container_chunk_title', 'section' => array( /* DEFAULT */ 'h2', 'section' => array( /* DEFAULT */ 'h3', 'section' => array( /* DEFAULT */ 'h4', 'section' => 'h5' ))) ), 'table' => 'format_table_title', 'warning' => 'format_warning_title', ), 'tbody' => 'tbody', 'term' => 'dt', 'uri' => 'format_uri', 'userinput' => 'format_userinput', 'variablelist' => 'div', 'varlistentry' => 'dl', 'varname' => 'tt', 'warning' => 'format_warning', 'xref' => 'format_link', ); protected $textmap = array( 'classname' => array( /* DEFAULT */ false, 'refname' => 'format_refname_classname_text', ), 'filename' => array( /* DEFAULT */ false, 'titleabbrev' => 'format_suppressed_text', ), 'function' => array( /* DEFAULT */ 'format_function_text', 'funcdef' => false, 'refname' => 'format_refname_function_text', ), 'programlisting' => 'format_programlisting_text', 'refname' => 'format_refname_text', 'year' => 'format_year', ); public $role = false; protected $chunked = true; protected $lang = "en"; protected $CURRENT_ID = ""; /* Current Chunk settings */ protected $cchunk = array(); /* Default Chunk settings */ protected $dchunk = array( "fieldsynopsis" => array( "modifier" => "public", ), "container_chunk" => null, "qandaentry" => array( ), "examples" => 0, "verinfo" => false, "refname" => array(), ); public function __construct(array $IDs, $ext = "php", $chunked = true) { parent::__construct($IDs, $ext); $this->ext = $ext; $this->chunked = $chunked; } public function format_chunk($open, $name, $attrs, $props) { if (isset($attrs[PhDReader::XMLNS_XML]["id"])) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; } if ($props["isChunk"]) { $this->cchunk = $this->dchunk; } if (isset($props["lang"])) { $this->lang = $props["lang"]; } if ($name == "refentry") { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { $this->cchunk["verinfo"] = !($attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "noversion"); } else { $this->cchunk["verinfo"] = true; } } if ($name == "legalnotice") { if ($open) { return '<div class="' . $name . '" ' . ($id ? "id=\"{$id}\"" : "") . '">'; } return "</div>\n"; } return false; } public function format_container_chunk($open, $name, $attrs, $props) { if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) return "<div class=\"{$name}\">"; $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { if ($props["isChunk"]) { $this->cchunk = $this->dchunk; } $chunks = PhDHelper::getChildren($id); if (count($chunks)) { $content = "<div class=\"TOC\">\n <dl>\n <dt><b>" . $this->autogen("toc", $props["lang"]) . "</b></dt>\n"; foreach($chunks as $chunkid => $junk) { $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); if ($long && $short && $long != $short) { $desc = $short. '</a> -- ' .$long; } else { $desc = ($long ? $long : $short). '</a>'; } if ($this->chunked) { $content .= " <dt><a href=\"{$chunkid}.{$this->ext}\">" . $desc . "</dt>\n"; } else { $content .= " <dt><a href=\"#{$chunkid}\">" . $this->format->TEXT(PhDHelper::getDescription($chunkid, false)) . "</a></dt>\n"; } } $content .= " </dl>\n</div>\n"; $this->cchunk["container_chunk"] = $content; } return "<div class=\"{$name}\" id=\"{$id}\">"; } return "</div>\n"; } public function format_root_chunk($open, $name, $attrs, $props) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { return "<div class=\"{$name}\">"; } $chunks = PhDHelper::getChildren($id); $content = '<p><b>' . $this->autogen("toc", $props["lang"]) . '</b></p><ul class="chunklist chunklist_'.$name.'">'; foreach($chunks as $chunkid => $junk) { $href = $this->chunked ? $chunkid .'.'. $this->ext : "#$chunkid"; $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a>'; $children = PhDHelper::getChildren($chunkid); if (count($children)) { $content .= '<ul class="chunklist chunklist_'.$name.' chunklist_children">'; foreach(PhDHelper::getChildren($chunkid) as $childid => $junk) { $href = $this->chunked ? $childid .'.'. $this->ext : "#$childid"; $long = $this->format->TEXT(PhDHelper::getDescription($childid, true)); $short = $this->format->TEXT(PhDHelper::getDescription($childid, false)); $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a></li>'; } $content .="</ul>"; } $content .= "</li>"; } $content .= "</ul>"; return $content; } public function format_link($open, $name, $attrs, $props) { if ($open) { $content = $fragment = ""; $class = $name; if(isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) { $linkto = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"]; $id = $href = PhDHelper::getFilename($linkto); if ($id != $linkto) { $fragment = "#$linkto"; } if ($this->chunked) { $href .= ".".$this->ext; } } elseif(isset($attrs[PhDReader::XMLNS_XLINK]["href"])) { $href = $attrs[PhDReader::XMLNS_XLINK]["href"]; $class .= " external"; } if ($name == "xref") { if ($this->chunked) { $link = $href; } else { $link = "#"; if (isset($linkto)) { $link .= $linkto; } else { $link .= $href; } } return '<a href="' .$link. '" class="' .$class. '">' .($content.PhDHelper::getDescription($id, false)). '</a>'; } elseif ($props["empty"]) { if ($this->chunked) { $link = ""; } else { $link = "#"; } return '<a href="' .$link.$href.$fragment. '" class="' .$class. '">' .$content.$href.$fragment. '</a>'; } else { if ($this->chunked) { $link = $href.$fragment; } elseif(isset($linkto)) { if ($fragment) { $link = $fragment; } else { $link = "#$href"; } } else { $link = $href; } return '<a href="' .$link. '" class="' .$class. '">' .$content; } } return "</a>"; } public function format_container_chunk_title($open, $name, $attrs) { if ($open) { return "<h1>"; } $ret = ""; if ($this->cchunk["container_chunk"]) { $ret = $this->cchunk["container_chunk"]; $this->cchunk["container_chunk"] = null; } return "</h1>\n" .$ret; } public function transformFromMap($open, $tag, $name, $attrs, $props) { if ($open) { $idstr = ""; if (isset($attrs[PhDReader::XMLNS_XML]["id"])) { $id = $attrs[PhDReader::XMLNS_XML]["id"]; $idstr = ' id="' .$id. '" name="' .$id. '"'; } return '<' .$tag. ' class="' .$name. '"' . $idstr. '>' . ($props["empty"] ? "</{$tag}>" : ""); } return '</' .$tag. '>'; } public function format_programlisting($open, $name, $attrs) { if ($open) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { $this->role = $attrs[PhDReader::XMLNS_DOCBOOK]["role"]; } else { $this->role = "default"; } return '<table class="EXAMPLE-CODE" bgcolor="#eeeeee" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><pre class="'. ($this->role ? $this->role : 'programlisting') .'">'; } $this->role = false; return "</pre></td></tr></table>\n"; } public function format_programlisting_text($value, $tag) { switch($this->role) { case "php": if ( strrpos($value, "<?php") || strrpos($value, "?>") ) return highlight_string(trim($value), 1); else return highlight_string("<?php\n" . trim($value) . "\n?>", 1); break; default: return htmlspecialchars($value, ENT_QUOTES, "UTF-8"); } } public function format_screen($open, $name, $attrs) { if ($open) { return '<table class="EXAMPLE-CODE" bgcolor="#eeeeee" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><pre class="screen">'; } return "</pre></td></tr></table>\n"; } public function CDATA($str) { if (!$this->role) return str_replace(array("\n", " "), array("<br/>", " "), htmlspecialchars($str, ENT_QUOTES, "UTF-8")); switch($this->role) { case "php": if ( strrpos($str, "<?php") || strrpos($str, "?>") ) return (highlight_string(trim($str), 1)); else return (highlight_string("<?php\n" . trim($str) . "\n?>", 1)); break; default: return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } } public function format_suppressed_tags($open, $name, $attrs) { /* Ignore it */ return ""; } public function format_suppressed_text($value, $tag) { /* Suppress any content */ return ""; } public function format_subtitle($open, $name, $attrs) { if ($open) return '<p><font color="red">'; return '</font></p>'; } public function format_editedby($open, $name, $attrs, $props) { if ($open) return "<h2 class=\"EDITEDBY\">" . $this->autogen("editedby", $props["lang"]) . "</h2>"; } public function format_copyright($open, $name, $attrs) { if ($open) { if ($this->chunked) { return '<p class="'.$name.'"><a href="copyright.' . $this->ext . '">Copyright</a> © '; } else { return '<p class="'.$name.'"><a href="#copyright">Copyright</a> © '; } } return '</p>'; } public function format_comment($open, $name, $attrs) { if ($open) { return '<!-- '; } return '-->'; } public function format_holder($open, $name, $attrs, $props) { if ($open) return $this->autogen("by", $props["lang"]) . " "; } public function format_year($value) { return $value . ", "; } public function format_admonition($open, $name, $attrs, $props) { if ($open) { return '<p><div class="' . $name . '"><blockquote class="' . $name . '"><p><b>'.$this->autogen($name, $props["lang"]). ': </b>'; } return "</p></blockquote></div></p>"; } public function format_table($open, $name, $attrs, $props) { if ($open) { return '<p><div class="'.$name.'"><table border="1" class="CALSTABLE">'; } return "</table></div></p>"; } public function format_entry($open, $name, $attrs, $props) { if ($open) { return '<td align="left" valign="middle">'; } return "</td>"; } public function format_table_title($open, $name, $attrs, $props) { if ($props["empty"]) return ""; if ($open) { return '<p><b>'; } return '</b></p>'; } public function format_userinput($open, $name, $attrs, $props) { if ($open) { return '<tt class="'.$name.'"><b>'; } return "</b></tt>"; } function format_replaceable($open, $name, $attrs, $props) { if ($open) { return '<tt class="'.$name.'"><i>'; } return "</i></tt>"; } public function format_warning($open, $name, $attrs, $props) { if ($open) { return '<div class="warning"><table class="warning" border="1" width="100%"><tbody>'; } return "</td></tr></tbody></table></div>"; } public function format_warning_title($open, $name, $attrs, $props) { if ($open) { return '<tr><td align="center"><b>'; } return "</b></td></tr>"; } public function format_warning_para($open, $name, $attrs, $props) { if ($open) { if (!$props["sibling"]) return '<tr align="center"><td><b>' . $this->autogen("warning", $props["lang"]) . "</b></td></tr>" . '<tr><td align="left"><p>'; return '<tr><td align="left"><p>'; } return "</p></td></tr>"; } public function format_refname_function_text($value) { $this->cchunk["refname"][] = '<b class="function">' . $this->format->TEXT($value . '()') . '</b>'; return false; } public function format_refname_classname_text($value) { $this->cchunk["refname"][] = '<b class="classname">' . $this->format->TEXT($value) . '</b>'; return false; } public function format_refpurpose($open, $tag, $attrs) { if ($open) { $refnames = implode(' ', $this->cchunk["refname"]); return '<div class="refnamediv">'. $refnames. ' -- '; } return "</div>\n"; } public function format_refname_text($value, $tag) { $this->cchunk["refname"][] = $this->format->TEXT($value); return false; } public function format_function_text($value) { return $this->format->TEXT($value."()"); } public function format_paramdef($open, $name, $attrs, $props) { if ($open && $props["sibling"] == 'paramdef') return ' , '; return false; } public function format_funcdef($open, $name, $attrs, $props) { if (!$open) return ' ( '; return false; } public function format_funcprototype($open, $name, $attrs, $props) { if ($open) { return "<p><code class=$name>"; } else return ")</code></p>"; } public function format_uri($open, $name, $attrs, $props) { if ($open) { return '<font color="red">'; } else return "</font>"; } public function format_refsynopsisdiv($open, $name, $attrs, $props) { if ($open) { return '<h2 class="refsynopsisdiv">Synopsis</h2><p>'; } return '</p>'; } public function format_guimenu($open, $name, $attrs, $props) { if ($open) { if ($props["sibling"]) return '-><span class="guimenu"><i>'; return '<span class="guimenu"><i>'; } return '</i></span>'; } /* FIXME: This function is a crazy performance killer */ public function qandaset($stream) { $xml = stream_get_contents($stream); $old = libxml_use_internal_errors(true); $doc = new DOMDocument("1.0", "UTF-8"); $doc->preserveWhitespace = false; $doc->loadXML(html_entity_decode(str_replace("&", "&amp;", "<div>$xml</div>"), ENT_QUOTES, "UTF-8")); if ($err = libxml_get_errors()) { print_r($err); libxml_clear_errors(); } fclose($stream); libxml_use_internal_errors($old); $xpath = new DOMXPath($doc); $nlist = $xpath->query("//div/dl/dt/strong"); $ret = '<div class="qandaset"><ol class="qandaset_questions">'; $i = 0; foreach($nlist as $node) { $ret .= '<li><a href="#' .($this->cchunk["qandaentry"][$i++]). '">' .($node->textContent). '</a></li>'; } return $ret.'</ol>'.$xml.'</div>'; } public function format_qandaentry($open, $name, $attrs) { if ($open) { $this->cchunk["qandaentry"][] = $this->CURRENT_ID . ".entry" . count($this->cchunk["qandaentry"]); return '<dl>'; } return '</dl>'; } public function format_answer($open, $name, $attrs) { if ($open) { return '<dd><a name="' .end($this->cchunk["qandaentry"]).'"></a>'; } return "</dd>"; } public function format_question($open, $name, $attrs) { if ($open) { return '<dt><strong>'; } return '</strong></dt>'; } public function format_emphasis($open, $name, $attrs) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) && $attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "bold") $role = "b"; else $role = "i"; if ($open) { return '<' . $role . ' class="' . $name . '">'; } return "</{$role}>"; } public function format_glossterm($open, $name, $attrs) { if ($open) { return '<dt><b>'; } return "</b></dt>"; } public function format_glossdef($open, $name, $attrs) { if ($open) { return '<dd><p>'; } return "</p></dd>"; } public function format_calloutlist($open, $name, $attrs) { if ($open) { $this->cchunk["callouts"] = 0; return '<table>'; } return '</table>'; } public function format_callout($open, $name, $attrs) { if ($open) { return '<tr><td><a href="#'.$attrs[PhDReader::XMLNS_DOCBOOK]["arearefs"].'">(' .++$this->cchunk["callouts"]. ')</a></td><td>'; } return "</td></tr>\n"; } }