cvs: phd /phpdotnet/phd Config.php /phpdotnet/phd/Format/Abstract XHTML.php /phpdotnet/phd/Package/Default BigXHTML.php ChunkedXHTML.php Factory.php
PHP.php XHTML.php
| From: | Moacir de Oliveira Miranda Júnior | Date: | Mon, 22 Jun 2009 02:31:42 +0000 |
| Subject: | cvs: phd /phpdotnet/phd Config.php /phpdotnet/phd/Format/Abstract XHTML.php /phpdotnet/phd/Package/Default BigXHTML.php ChunkedXHTML.php Factory.php PHP.php XHTML.php |
||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4194@lists.php.net to get a copy of this message | ||
moacir Mon Jun 22 02:31:42 2009 UTC
Added files:
/phd/phpdotnet/phd/Package/Default ChunkedXHTML.php BigXHTML.php
PHP.php
Modified files:
/phd/phpdotnet/phd/Format/Abstract XHTML.php
/phd/phpdotnet/phd/Package/Default Factory.php XHTML.php
/phd/phpdotnet/phd Config.php
Log:
Default package added
http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Format/Abstract/XHTML.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Format/Abstract/XHTML.php diff -u phd/phpdotnet/phd/Format/Abstract/XHTML.php:1.2 phd/phpdotnet/phd/Format/Abstract/XHTML.php:1.3 --- phd/phpdotnet/phd/Format/Abstract/XHTML.php:1.2 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Format/Abstract/XHTML.php Mon Jun 22 02:31:42 2009 @@ -1,17 +1,24 @@ <?php namespace phpdotnet\phd; -abstract class Format_Abstract_XHTML extends Format -{ +abstract class Format_Abstract_XHTML extends Format { private $formatname = "XHTML"; protected $title; - protected $flags; protected $ext = "html"; - protected $fp = array(); - protected $outputdir = __DIR__; + protected $outputdir; + protected $fp; + public $role = false; + + /* XHTMLPhDFormat */ + protected $openPara = 0; + protected $escapedPara = array(); + + /* PhDThemeXhtml */ + protected $chunked = true; + protected $mediamanager = null; + protected $lang = 'en'; - public $role = false; /* Current Chunk variables */ protected $cchunk = array(); /* Default Chunk variables */ @@ -49,11 +56,9 @@ public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); + $this->postConstruct(); } - public abstract function header($id); - public abstract function footer($id); - public function transformFromMap($open, $tag, $name, $attrs, $props) { if ($open) { $idstr = ""; @@ -64,151 +69,105 @@ return '<' .$tag. ' class="' .$name. '"' . $idstr . ($props["empty"] ? '/' : "") . '>'; } return '</' .$tag. '>'; - } - - public function appendData($data) { - if ($this->appendToBuffer) { - $this->buffer .= $data; - return; - } elseif ($this->flags & Render::CLOSE) { - $fp = array_pop($this->fp); - fwrite($fp, $data); - $this->writeChunk($this->CURRENT_CHUNK, $fp); - fclose($fp); - - $this->flags ^= Render::CLOSE; - } elseif ($this->flags & Render::OPEN) { - $this->fp[] = $fp = fopen("php://temp/maxmemory", "r+"); - fwrite($fp, $data); - - $this->flags ^= Render::OPEN; - } else { - $fp = end($this->fp); - fwrite($fp, $data); - } - } - - public function writeChunk($id, $fp) { - $filename = $this->outputdir . $id . '.' .$this->ext; - - rewind($fp); - file_put_contents($filename, $this->header($id)); - file_put_contents($filename, $fp, FILE_APPEND); - file_put_contents($filename, $this->footer($id), FILE_APPEND); - } + } - public function close() { - foreach ($this->fp as $fp) { - fclose($fp); - } + public function TEXT($str) { + return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } - public function createLink($for, &$desc = null, $type = Format::SDESC) { - $retval = null; - if (isset($this->indexes[$for])) { - $rsl = $this->indexes[$for]; - $retval = $rsl["filename"] . "." . $this->ext . '#' . $rsl["docbook_id"]; - $desc = $rsl["sdesc"] ?: $rsl["ldesc"]; + public function UNDEF($open, $name, $attrs, $props) { + if ($open) { + trigger_error("No mapper found for '{$name}'", E_USER_WARNING); } - return $retval; - } - - public function TEXT($str) { - return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } - public function CDATA($str) { + public function CDATA($str) { switch($this->role) { - case "php": - return '<div class="phpcode">' .(highlight_string(trim($str), 1)). '</div>'; - break; + case '': + return '<div class="cdata"><pre>' + . htmlspecialchars($str, ENT_QUOTES, "UTF-8") + . '</pre></div>'; default: - return '<div class="cdata"><pre>' .(htmlspecialchars($str, ENT_QUOTES, "UTF-8")). '</pre></div>'; + return '<div class="' . $this->role . 'code">' + . $this->highlight(trim($str), $this->role, 'xhtml') + . '</div>'; } } - public function UNDEF($open, $name, $attrs, $props) { - if ($open) { - trigger_error("No mapper found for '{$name}'", E_USER_WARNING); - } + public function getChunkInfo() { + return $this->cchunk; } - protected function createTOC($id, $lang) { - if (!$this->getChildrens($id)) { - return ""; - } - $toc = '<h2>' . $this->autogen('toc', $lang) . '</h2><ol>'; - foreach ($this->getChildrens($id) as $child) { - $isLDesc = null; - $isSDesc = null; - $long = $this->parse($this->getLongDescription($child, $isLDesc)); - $short = $this->getShortDescription($child, $isSDesc); - $link = $this->createLink($child); - - $list = ""; - if ($this->cchunk["name"] === "book" || $this->cchunk["name"] === "set") { - if ($this->getChildrens($child)) { - $list = "<ol>"; - foreach ($this->getChildrens($child) as $subChild) { - $isSubLDesc = null; - $isSubSDesc = null; - $subLong = $this->parse($this->getLongDescription($subChild, $isLDesc)); - $subShort = $this->getShortDescription($subChild, $isSubSDesc); - - $href = $this->createLink($subChild); - if ($isSubLDesc && $isSubSDesc) { - $list .= '<li><a href="' . $href . '">' . $subShort . '</a> â ' . $subLong . "</li>\n"; - } else { - $list .= '<li><a href="' . $href . '">' . ($subLong ?: $subShort) . '</a>' . "</li>\n"; - } - } - $list .="</ol>"; - } - } - if ($isLDesc && $isSDesc) { - $toc .= '<li><a href="' . $link . '">' . $short . '</a> â ' . $long . $list . "</li>\n"; - } else { - $toc .= '<li><a href="' . $link . '">' . ($long ?: $short) . '</a>' . $list . "</li>\n"; - } + /* Functions from PhDThemeXhtml */ + + /** + * Called after the constructor finished. + * This is needed since themes set their outputdir and outputfile + * in the constructor. That file/dir is used for mediamanager. + * That means we cannot instantiate and complete the manager in our + * constructor centrally. + * + * Each theme needs its own media manager, since the manager contains + * the output path. + * + * @return void + */ + public function postConstruct() { + $this->mediamanager = new MediaManager(Config::xml_root()); + $outputdir = Config::output_dir(); + if (isset($outputdir) && $outputdir) { + $this->mediamanager->output_dir = $outputdir; + } else { + $this->mediamanager->output_dir = $outputfile . '-data/'; + $this->mediamanager->relative_ref_path = basename($this->mediamanager->output_dir) . '/'; } - $toc .= "</ol>\n"; - return $toc; } - public function update($event, $val = null) { - switch($event) { - case Render::CHUNK: - $this->flags = $val; - break; + /* Functions from XHTMLPhDFormat */ - case Render::STANDALONE: - if ($val) { - $this->registerElementMap(static::getDefaultElementMap()); - $this->registerTextMap(static::getDefaultTextMap()); - } - break; + /** + * Closes a para tag when we are already in a paragraph. + * + * @return string HTML code + * + * @see $openPara + * @see restorePara() + */ + public function escapePara() { + if (!$this->openPara) { + return ''; + } - case Render::INIT: - $this->outputdir = $tmp = Config::output_dir() . strtolower($this->getFormatName()) . '/'; - if (file_exists($tmp)) { - if (!is_dir($tmp)) { - v("Output directory is a file?", E_USER_ERROR); - } - } else { - if (!mkdir($tmp)) { - v("Can't create output directory", E_USER_ERROR); - } - } - break; - case Render::VERBOSE: - v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); - break; + if (!isset($this->escapedPara[$this->openPara])) { + $this->escapedPara[$this->openPara] = 1; + return '</p>'; + } else { + ++$this->escapedPara[$this->openPara]; + return ''; } } - public function getChunkInfo() { - return $this->cchunk; + /** + * Opens a para tag again when we escaped one before. + * + * @return string HTML code + * + * @see $openPara + * @see escapePara() + */ + public function restorePara() { + if (!$this->openPara || !isset($this->escapedPara[$this->openPara])) { + return ''; + } + + if ($this->escapedPara[$this->openPara] == 1) { + unset($this->escapedPara[$this->openPara]); + return '<p>'; + } else { + --$this->escapedPara[$this->openPara]; + return ''; + } } } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/Factory.php?r1=1.3&r2=1.4&diff_format=u Index: phd/phpdotnet/phd/Package/Default/Factory.php diff -u phd/phpdotnet/phd/Package/Default/Factory.php:1.3 phd/phpdotnet/phd/Package/Default/Factory.php:1.4 --- phd/phpdotnet/phd/Package/Default/Factory.php:1.3 Sat Jun 20 06:55:42 2009 +++ phd/phpdotnet/phd/Package/Default/Factory.php Mon Jun 22 02:31:42 2009 @@ -1,20 +1,19 @@ <?php namespace phpdotnet\phd; -class Package_Default_Factory extends Format_Factory -{ +class Package_Default_Factory extends Format_Factory { public function createXhtmlFormat() { - return new Package_Default_XHTML(); + return new Package_Default_ChunkedXHTML(); } -/* + public function createBigXhtmlFormat() { - return new DefaultBigXHTMLFormat(); + return new Package_Default_BigXHTML(); } - + public function createPHPFormat() { - return new DefaultPHPFormat(); + return new Package_Default_PHP(); } -*/ + } ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/XHTML.php?r1=1.3&r2=1.4&diff_format=u Index: phd/phpdotnet/phd/Package/Default/XHTML.php diff -u phd/phpdotnet/phd/Package/Default/XHTML.php:1.3 phd/phpdotnet/phd/Package/Default/XHTML.php:1.4 --- phd/phpdotnet/phd/Package/Default/XHTML.php:1.3 Sat Jun 20 06:55:42 2009 +++ phd/phpdotnet/phd/Package/Default/XHTML.php Mon Jun 22 02:31:42 2009 @@ -1,9 +1,7 @@ <?php namespace phpdotnet\phd; -class Package_Default_XHTML extends Format_Abstract_XHTML -{ - private $formatname = "XHTML"; +abstract class Package_Default_XHTML extends Format_Abstract_XHTML { private $myelementmap = array( /* {{{ */ 'abstract' => 'div', /* Docbook-xsl prints "abstract"... */ 'abbrev' => 'abbr', @@ -99,7 +97,6 @@ 'errortype' => 'span', 'errorcode' => 'span', 'example' => 'div', - 'phpdoc:exception' => 'format_exception_chunk', 'formalpara' => 'p', 'fieldsynopsis' => array( /* DEFAULT */ 'format_fieldsynopsis', @@ -305,6 +302,7 @@ 'titleabbrev' => 'format_suppressed_tags', 'type' => 'span', 'userinput' => 'format_userinput', + 'uri' => 'tt', 'variablelist' => 'format_variablelist', 'varlistentry' => 'format_varlistentry', 'varname' => array( @@ -324,13 +322,24 @@ ), 'questions' => 'ol', // From the PhD namespace 'answer' => 'dd', + + //phpdoc: implement in the PHP Package + 'phpdoc:classref' => 'format_suppressed_tags', + 'phpdoc:exception' => 'format_suppressed_tags', + 'phpdoc:exceptionref' => 'format_suppressed_tags', + 'phpdoc:varentry' => 'format_suppressed_tags', + + //phd + 'phd:toc' => 'format_phd_toc', + ); /* }}} */ + private $mytextmap = array( 'segtitle' => 'format_segtitle_text', 'affiliation' => 'format_suppressed_text', 'contrib' => 'format_suppressed_text', 'shortaffil' => 'format_suppressed_text', - 'titleabbrev' => 'format_suppressed_text', + 'programlisting' => 'format_programlisting_text', 'alt' => 'format_alt_text', 'modifier' => array( @@ -358,10 +367,10 @@ ), 'literal' => 'format_literal_text', 'email' => 'format_email_text', - + 'titleabbrev' => 'format_suppressed_text', ); - protected $title = "PhD Default Xhtml"; + //protected $flags; public function __construct() { parent::__construct(); @@ -375,116 +384,59 @@ return $this->mytextmap; } - public function header($id) { - $title = $this->getLongDescription($id); - $lang = $this->CURRENT_LANG; - - $prev = $next = $parent = array("href" => null, "desc" => null); - - if ($parentId = $this->getParent($id)) { - $parent = array("href" => $this->getFilename($parentId) . '.' .$this->ext, - "desc" => $this->getShortDescription($parentId)); - } - if ($prevId = Format::getPrevious($id)) { - $prev = array("href" => Format::getFilename($prevId) . '.' .$this->ext, - "desc" => $this->getShortDescription($prevId)); - } - if ($nextId = Format::getNext($id)) { - $next = array("href" => Format::getFilename($nextId) . '.' .$this->ext, - "desc" => $this->getShortDescription($nextId)); - } - $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"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .$lang. '" lang="' .$lang. '"> -<head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> - <title>'.$this->title.': '.$title.'</title> -</head> -<body> -<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">'.$this->title.'</a></div> - </div><hr/> -'; - } - - public function footer($id) { - return "\n </td>\n </tr>\n</table>\n</body>\n</html>\n"; - } - - 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.'">'.$this->title.'</a></li> -'; - // Fetch ancestors of the current node - $ancestors = array(); - $currentId = $id; - while (($currentId = $this->getParent($currentId)) && $currentId != "index") { - $desc = ""; - $link = $this->createLink($currentId, $desc); - $ancestors[] = array("desc" => $desc, "link" => $link); + protected function createTOC($id, $lang) { + if (!$this->getChildrens($id)) { + return ""; } - // Show them from the root to the closest parent - foreach (array_reverse($ancestors) as $ancestor) { - $navBar .= " <li class=\"header up\"><a href=\"{$ancestor["link"]}\">{$ancestor["desc"]}</a></li>\n"; - } - // Fetch siblings of the current node - $parent = $this->getParent($id); - foreach ($this->getChildrens($parent) as $child) { - $desc = ""; - $link = $this->createLink($child, $desc); - $active = ($id === $child); - $navBar .= " <li" .($active ? " class=\"active\"" : ""). "><a href=\"$link\">$desc</a></li>\n"; + $toc = '<strong>' . $this->autogen('toc', $lang) . '</strong><ul>'; + foreach ($this->getChildrens($id) as $child) { + $isLDesc = null; + $isSDesc = null; + $long = $this->parse($this->getLongDescription($child, $isLDesc)); + $short = $this->getShortDescription($child, $isSDesc); + $link = $this->createLink($child); + + $list = ""; + if ($this->cchunk["name"] === "book" || $this->cchunk["name"] === "set") { + if ($this->getChildrens($child)) { + $list = "<ul>"; + foreach ($this->getChildrens($child) as $subChild) { + $isSubLDesc = null; + $isSubSDesc = null; + $subLong = $this->parse($this->getLongDescription($subChild, $isLDesc)); + $subShort = $this->getShortDescription($subChild, $isSubSDesc); + + $href = $this->createLink($subChild); + if ($isSubLDesc && $isSubSDesc) { + $list .= '<li><a href="' . $href . '">' . $subShort . '</a> â ' . $subLong . "</li>\n"; + } else { + $list .= '<li><a href="' . $href . '">' . ($subLong ?: $subShort) . '</a>' . "</li>\n"; + } + } + $list .="</ul>"; + } + } + if ($isLDesc && $isSDesc) { + $toc .= '<li><a href="' . $link . '">' . $short . '</a> â ' . $long . $list . "</li>\n"; + } else { + $toc .= '<li><a href="' . $link . '">' . ($long ?: $short) . '</a>' . $list . "</li>\n"; + } + } + $toc .= "</ul>\n"; + return $toc; + } + + public function createLink($for, &$desc = null, $type = Format::SDESC) { + $retval = null; + if (isset($this->indexes[$for])) { + $rsl = $this->indexes[$for]; + $retval = $rsl["filename"] . "." . $this->ext . '#' . $rsl["docbook_id"]; + $desc = $rsl["sdesc"] ?: $rsl["ldesc"]; } - return $navBar . " </ul>\n"; + return $retval; } - + /* Functions format_* */ public function format_suppressed_tags($open, $name, $attrs, $props) { /* Ignore it */ @@ -566,18 +518,21 @@ } return '</div>'; } + public function format_author($open, $name, $attrs, $props) { if ($open) { return '<div class="' .$name. ' vcard">'; } return "</div>"; } + public function format_personname($open, $name, $attrs, $props) { if ($open) { return '<span class="' .$name. ' fn">'; } return "</span>"; } + public function format_name($open, $name, $attrs) { if ($open) { $class = ""; @@ -1324,10 +1279,10 @@ public function format_qandaset($open, $name, $attrs, $props) { if ($open) { $node = $this->getReader()->expand(); - $doc = new DOMDocument; + $doc = new \DOMDocument; $doc->appendChild($node); - $xp = new DOMXPath($doc); + $xp = new \DOMXPath($doc); $xp->registerNamespace("db", Reader::XMLNS_DOCBOOK); $questions = $xp->query("//db:qandaentry/db:question"); @@ -1379,5 +1334,4 @@ return '<<a href="mailto:' . $value . '">' . $value . '</a>>'; } - } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Config.php?r1=1.62&r2=1.63&diff_format=u Index: phd/phpdotnet/phd/Config.php diff -u phd/phpdotnet/phd/Config.php:1.62 phd/phpdotnet/phd/Config.php:1.63 --- phd/phpdotnet/phd/Config.php:1.62 Mon Jun 22 01:22:52 2009 +++ phd/phpdotnet/phd/Config.php Mon Jun 22 02:31:42 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: Config.php,v 1.62 2009/06/22 01:22:52 moacir Exp $ */ +/* $Id: Config.php,v 1.63 2009/06/22 02:31:42 moacir Exp $ */ define("PHD_VERSION", "phd-from-cvs"); @@ -39,7 +39,7 @@ 'phd_info_output' => NULL, 'phd_info_color' => false, 'highlighter' => "phpdotnet\\phd\\Highlighter", - 'package' => 'PHP', + 'package' => 'Default', ); public static function init(array $a) { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/ChunkedXHTML.php?view=markup&rev=1.1 Index: phd/phpdotnet/phd/Package/Default/ChunkedXHTML.php +++ phd/phpdotnet/phd/Package/Default/ChunkedXHTML.php <?php namespace phpdotnet\phd; class Package_Default_ChunkedXHTML extends Package_Default_XHTML { protected $formatname = "Chunked-XHTML"; protected $title = "Index"; public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); $this->chunked = true; } public function __destruct() { $this->close(); } public function appendData($data) { if ($this->appendToBuffer) { $this->buffer .= $data; return; } elseif ($this->flags & Render::CLOSE) { $fp = array_pop($this->fp); fwrite($fp, $data); $this->writeChunk($this->CURRENT_CHUNK, $fp); fclose($fp); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { $this->fp[] = $fp = fopen("php://temp/maxmemory", "r+"); fwrite($fp, $data); $this->flags ^= Render::OPEN; } else { $fp = end($this->fp); fwrite($fp, $data); } } public function writeChunk($id, $fp) { $filename = $this->outputdir . $id . '.' .$this->ext; rewind($fp); file_put_contents($filename, $this->header($id)); file_put_contents($filename, $fp, FILE_APPEND); file_put_contents($filename, $this->footer($id), FILE_APPEND); } public function close() { foreach ($this->fp as $fp) { fclose($fp); } } public function update($event, $val = null) { switch($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: $this->outputdir = $tmp = Config::output_dir() . strtolower($this->getFormatName()) . '/'; if (file_exists($tmp)) { if (!is_dir($tmp)) { v("Output directory is a file?", E_USER_ERROR); } } else { if (!mkdir($tmp)) { v("Can't create output directory", E_USER_ERROR); } } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } } public function header($id) { $title = $this->getLongDescription($id); $lang = Config::language(); $prev = $next = $parent = array("href" => null, "desc" => null); if ($parentId = $this->getParent($id)) { $parent = array("href" => $this->getFilename($parentId) . '.' .$this->ext, "desc" => $this->getShortDescription($parentId)); } if ($prevId = Format::getPrevious($id)) { $prev = array("href" => Format::getFilename($prevId) . '.' .$this->ext, "desc" => $this->getShortDescription($prevId)); } if ($nextId = Format::getNext($id)) { $next = array("href" => Format::getFilename($nextId) . '.' .$this->ext, "desc" => $this->getShortDescription($nextId)); } $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"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .$lang. '" lang="' .$lang. '"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>'.$this->title.': '.$title.'</title> </head> <body> <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">'.$this->title.'</a></div> </div><hr/> '; } public function footer($id) { return "\n </td>\n </tr>\n</table>\n</body>\n</html>\n"; } 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.'">'.$this->title.'</a></li> '; // Fetch ancestors of the current node $ancestors = array(); $currentId = $id; while (($currentId = $this->getParent($currentId)) && $currentId != "index") { $desc = ""; $link = $this->createLink($currentId, $desc); $ancestors[] = array("desc" => $desc, "link" => $link); } // Show them from the root to the closest parent foreach (array_reverse($ancestors) as $ancestor) { $navBar .= " <li class=\"header up\"><a href=\"{$ancestor["link"]}\">{$ancestor["desc"]}</a></li>\n"; } // Fetch siblings of the current node $parent = $this->getParent($id); foreach ($this->getChildrens($parent) as $child) { $desc = ""; $link = $this->createLink($child, $desc); $active = ($id === $child); $navBar .= " <li" .($active ? " class=\"active\"" : ""). "><a href=\"$link\">$desc</a></li>\n"; } return $navBar . " </ul>\n"; } } ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/BigXHTML.php?view=markup&rev=1.1 Index: phd/phpdotnet/phd/Package/Default/BigXHTML.php +++ phd/phpdotnet/phd/Package/Default/BigXHTML.php <?php namespace phpdotnet\phd; class Package_Default_BigXHTML extends Package_Default_XHTML { protected $formatname = "Big-XHTML"; protected $title = "Index"; public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); $this->chunked = false; } public function __destruct() { $this->close(); } public function appendData($data) { if ($this->appendToBuffer) { $this->buffer .= $data; return; } if ($this->flags & Render::CLOSE) { fwrite($this->fp, $data); /* Append footer */ fwrite($this->fp, $this->footer()); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { fwrite($this->fp, "\n".$data); $this->flags ^= Render::OPEN; } else { fwrite($this->fp, $data); } } public function header() { return <<<HEADER <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>$this->title</title> </head> <body> HEADER; } public function footer($eof = false) { return !$eof ? "\n<hr />\n" : "</body>\n</html>"; } public function close() { fwrite($this->fp, $this->footer(true)); fclose($this->fp); } public function update($event, $val = null) { switch($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(parent::getDefaultElementMap()); $this->registerTextMap(parent::getDefaultTextMap()); } break; case Render::INIT: if ($val) { if (!is_resource($this->fp)) { static $i = 0; $i++; $filename = Config::output_dir() . strtolower($this->getFormatName()) . $i . '.' . $this->ext; $this->fp = fopen($filename, "w+"); fwrite($this->fp, $this->header()); } } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } } public function createLink($for, &$desc = null, $type = self::SDESC) { $retval = '#' . $for; if (isset($this->indexes[$for])) { $result = $this->indexes[$for]; if ($type === self::SDESC) { $desc = $result["sdesc"] ?: $result["ldesc"]; } else { $desc = $result["ldesc"] ?: $result["sdesc"]; } } return $retval; } } ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/PHP.php?view=markup&rev=1.1 Index: phd/phpdotnet/phd/Package/Default/PHP.php +++ phd/phpdotnet/phd/Package/Default/PHP.php <?php namespace phpdotnet\phd; class Package_Default_PHP extends Package_Default_ChunkedXHTML { protected $myelementmap = array( 'acronym' => 'format_suppressed_tags', 'function' => 'format_suppressed_tags', 'link' => 'format_link', 'refpurpose' => 'format_refpurpose', 'varname' => array( /* DEFAULT */ 'var', 'fieldsynopsis' => 'format_fieldsynopsis_varname', ), 'xref' => 'format_xref', '.title' => array( /* DEFAULT */ false, 'info' => array( /* DEFAULT */ false, 'article' => 'format_container_chunk_top_title', 'appendix' => 'format_container_chunk_top_title', 'book' => 'format_container_chunk_top_title', 'chapter' => 'format_container_chunk_top_title', 'part' => 'format_container_chunk_top_title', 'set' => 'format_container_chunk_top_title', ), 'article' => 'format_container_chunk_top_title', 'appendix' => 'format_container_chunk_top_title', 'book' => 'format_container_chunk_top_title', 'chapter' => 'format_container_chunk_top_title', 'part' => 'format_container_chunk_top_title', 'set' => 'format_container_chunk_top_title', ), '.reference' => 'format_container_chunk_below', '.question' => array( /* DEFAULT */ false, 'questions' => 'format_phd_question', // From the PhD namespace ), ); protected $mytextmap = array( 'acronym' => 'format_acronym_text', 'function' => 'format_function_text', 'methodname' => array( /* DEFAULT */ 'format_function_text', 'constructorsynopsis' => array( /* DEFAULT */ 'format_function_text', 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'methodsynopsis' => array( /* DEFAULT */ 'format_function_text', 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'destructorsynopsis' => array( /* DEFAULT */ 'format_function_text', 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), ), 'refname' => 'format_refname_text', 'type' => array( /* DEFAULT */ 'format_type_text', 'classsynopsisinfo' => false, 'fieldsynopsis' => 'format_type_if_object_or_pseudo_text', 'methodparam' => 'format_type_if_object_or_pseudo_text', 'methodsynopsis' => array( /* DEFAULT */ 'format_type_if_object_or_pseudo_text', 'classsynopsis' => false, ), ), ); protected $formatname = "PHP"; protected $title = "Index"; private $acronyms = array(); private $versions = array(); private $refname = ""; public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); $this->ext = "php"; $this->versions = self::generateVersionInfo(Config::phpweb_version_filename()); $this->acronyms = self::generateAcronymInfo(Config::phpweb_acronym_filename()); } public function __destruct() { parent::close(); } public function header($id) { return '<?php include_once $_SERVER[\'DOCUMENT_ROOT\'] . \'/include/shared-manual.inc\'; $setup = array( "home" => array("index.php", "'.$this->title.'"), "head" => array("UTF-8", "en"), "this" => array(null, null), "up" => array(null, null), "prev" => array(null, null), "next" => array(null, null), "toc" => array(), "parents" => array(), ); manual_setup($setup); manual_header(); ?>'; } public function footer($id) { return "<?php manual_footer(); ?>"; } public function update($event, $val = null) { switch($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(array_merge(parent::getDefaultElementMap(), static::getDefaultElementMap())); $this->registerTextMap(array_merge(parent::getDefaultTextMap(), static::getDefaultTextMap())); } else { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: parent::update($event, $val); break; case Render::VERBOSE: parent::update($event, $val); break; } } protected function lookupRefname($for) { $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; } public static function generateVersionInfo($filename) { static $info; if ($info) { return $info; } $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(); $info = $versions; return $versions; } public static function generateAcronymInfo($filename) { static $info; if ($info) { return $info; } $r = new \XMLReader; if (!$r->open($filename)) { throw new \Exception("Could not open $filename"); } $acronyms = array(); while ($r->read()) { if ($r->nodeType != \XMLReader::ELEMENT) { continue; } if ($r->name == "term") { $r->read(); $k = $r->value; $acronyms[$k] = ""; } else if ($r->name == "simpara") { $r->read(); $acronyms[$k] = $r->value; } } $info = $acronyms; return $acronyms; } 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 acronymInfo($acronym) { return isset($this->acronyms[$acronym]) ? $this->acronyms[$acronym] : false; } public function format_acronym_text($value, $tag) { $resolved = $this->acronymInfo($value); if ($resolved) { return '<acronym title="' .$resolved. '">' .$value. '</acronym>'; } return '<acronym>'.$value.'</acronym>'; } public function format_refpurpose($open, $tag, $attrs, $props) { if ($open) { return '<p class="verinfo">(' .(htmlspecialchars($this->versionInfo($this->refname), ENT_QUOTES, "UTF-8")). ')</p><p class="refpurpose dc-title">'. $this->refname. ' â '; } return "</p>\n"; } public function format_fieldsynopsis_varname($open, $name, $attrs) { if ($open) { $href = ""; if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"])) { $href = $this->createLink($attrs[Reader::XMLNS_DOCBOOK]["linkend"]); $href = '<a href="' .$href. '">'; } if ($this->cchunk["fieldsynopsis"]["modifier"] == "const") { return '<var class="fieldsynopsis_varname">'.$href; } return '<var class="'.$name.'">'.$href.'$'; } if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"])) { return '</a></var>'; } return '</var>'; } public function format_refname_text($value, $tag) { $this->refname = $value; return false; } public function format_function_text($value, $tag, $display_value = null) { if ($display_value === null) { $display_value = $value; } $ref = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $value)); $filename = $this->lookupRefname($ref); if (($filename !== false) && $this->CURRENT_CHUNK !== $filename) { $desc = ""; $href = $this->createLink($filename, $desc); return '<a href="' . $href . '" class="function" title="' . $desc . '">' . $display_value . ($tag == "function" ? "()" : ""). '</a>'; } return '<strong>' . $display_value . ($tag === "function" ? "()" : ""). '</strong>'; } public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) { $value = $this->TEXT($value); if ($this->cchunk["classsynopsis"]["classname"] === false) { return $this->format_function_text($value, $tag); } if (strpos($value, '::')) { $explode = '::'; } elseif (strpos($value, '->')) { $explode = '->'; } else { return $this->format_function_text($value, $tag); } list($class, $method) = explode($explode, $value); if ($class !== $this->cchunk["classsynopsis"]["classname"]) { return $this->format_function_text($value, $tag); } return $this->format_function_text($value, $tag, $method); } public function format_type_if_object_or_pseudo_text($value, $tag) { if (in_array(strtolower($value), array("bool", "int", "double", "boolean", "integer", "float", "string", "array", "object", "resource", "null"))) { return false; } return self::format_type_text($value, $tag); } public function format_type_text($value, $tag) { $t = strtolower($value); switch($t) { case "bool": $id = "language.types.boolean"; break; case "int": case "long": $id = "language.types.integer"; break; case "double": $id = "language.types.float"; break; /* FIXME: These aren't documented yet */ case "binary": case "unicode": $id = "language.types.string"; break; case "void": case "boolean": case "integer": case "float": case "string": case "array": case "object": case "resource": case "null": $id = "language.types.$t"; break; case "mixed": case "number": case "callback": $id = "language.types.$t"; break; default: /* Check if its a classname. */ $t = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $t)); $id = "class.$t"; } $desc = ""; $href = $this->createLink($id, $desc); if ($href) { return '<a href="' .$href. '" class="' .$tag. ' ' .$value. '" title="' . $desc . '">' .$value. '</a>'; } return '<span class="' .$tag. ' ' .$value. '">' .$value. '</span>'; } } ?>
http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Format/Abstract/XHTML.php?r1=1.2&r2=1.3&diff_format=u Index: phd/phpdotnet/phd/Format/Abstract/XHTML.php diff -u phd/phpdotnet/phd/Format/Abstract/XHTML.php:1.2 phd/phpdotnet/phd/Format/Abstract/XHTML.php:1.3 --- phd/phpdotnet/phd/Format/Abstract/XHTML.php:1.2 Fri Jun 19 21:48:53 2009 +++ phd/phpdotnet/phd/Format/Abstract/XHTML.php Mon Jun 22 02:31:42 2009 @@ -1,17 +1,24 @@ <?php namespace phpdotnet\phd; -abstract class Format_Abstract_XHTML extends Format -{ +abstract class Format_Abstract_XHTML extends Format { private $formatname = "XHTML"; protected $title; - protected $flags; protected $ext = "html"; - protected $fp = array(); - protected $outputdir = __DIR__; + protected $outputdir; + protected $fp; + public $role = false; + + /* XHTMLPhDFormat */ + protected $openPara = 0; + protected $escapedPara = array(); + + /* PhDThemeXhtml */ + protected $chunked = true; + protected $mediamanager = null; + protected $lang = 'en'; - public $role = false; /* Current Chunk variables */ protected $cchunk = array(); /* Default Chunk variables */ @@ -49,11 +56,9 @@ public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); + $this->postConstruct(); } - public abstract function header($id); - public abstract function footer($id); - public function transformFromMap($open, $tag, $name, $attrs, $props) { if ($open) { $idstr = ""; @@ -64,151 +69,105 @@ return '<' .$tag. ' class="' .$name. '"' . $idstr . ($props["empty"] ? '/' : "") . '>'; } return '</' .$tag. '>'; - } - - public function appendData($data) { - if ($this->appendToBuffer) { - $this->buffer .= $data; - return; - } elseif ($this->flags & Render::CLOSE) { - $fp = array_pop($this->fp); - fwrite($fp, $data); - $this->writeChunk($this->CURRENT_CHUNK, $fp); - fclose($fp); - - $this->flags ^= Render::CLOSE; - } elseif ($this->flags & Render::OPEN) { - $this->fp[] = $fp = fopen("php://temp/maxmemory", "r+"); - fwrite($fp, $data); - - $this->flags ^= Render::OPEN; - } else { - $fp = end($this->fp); - fwrite($fp, $data); - } - } - - public function writeChunk($id, $fp) { - $filename = $this->outputdir . $id . '.' .$this->ext; - - rewind($fp); - file_put_contents($filename, $this->header($id)); - file_put_contents($filename, $fp, FILE_APPEND); - file_put_contents($filename, $this->footer($id), FILE_APPEND); - } + } - public function close() { - foreach ($this->fp as $fp) { - fclose($fp); - } + public function TEXT($str) { + return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } - public function createLink($for, &$desc = null, $type = Format::SDESC) { - $retval = null; - if (isset($this->indexes[$for])) { - $rsl = $this->indexes[$for]; - $retval = $rsl["filename"] . "." . $this->ext . '#' . $rsl["docbook_id"]; - $desc = $rsl["sdesc"] ?: $rsl["ldesc"]; + public function UNDEF($open, $name, $attrs, $props) { + if ($open) { + trigger_error("No mapper found for '{$name}'", E_USER_WARNING); } - return $retval; - } - - public function TEXT($str) { - return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } - public function CDATA($str) { + public function CDATA($str) { switch($this->role) { - case "php": - return '<div class="phpcode">' .(highlight_string(trim($str), 1)). '</div>'; - break; + case '': + return '<div class="cdata"><pre>' + . htmlspecialchars($str, ENT_QUOTES, "UTF-8") + . '</pre></div>'; default: - return '<div class="cdata"><pre>' .(htmlspecialchars($str, ENT_QUOTES, "UTF-8")). '</pre></div>'; + return '<div class="' . $this->role . 'code">' + . $this->highlight(trim($str), $this->role, 'xhtml') + . '</div>'; } } - public function UNDEF($open, $name, $attrs, $props) { - if ($open) { - trigger_error("No mapper found for '{$name}'", E_USER_WARNING); - } + public function getChunkInfo() { + return $this->cchunk; } - protected function createTOC($id, $lang) { - if (!$this->getChildrens($id)) { - return ""; - } - $toc = '<h2>' . $this->autogen('toc', $lang) . '</h2><ol>'; - foreach ($this->getChildrens($id) as $child) { - $isLDesc = null; - $isSDesc = null; - $long = $this->parse($this->getLongDescription($child, $isLDesc)); - $short = $this->getShortDescription($child, $isSDesc); - $link = $this->createLink($child); - - $list = ""; - if ($this->cchunk["name"] === "book" || $this->cchunk["name"] === "set") { - if ($this->getChildrens($child)) { - $list = "<ol>"; - foreach ($this->getChildrens($child) as $subChild) { - $isSubLDesc = null; - $isSubSDesc = null; - $subLong = $this->parse($this->getLongDescription($subChild, $isLDesc)); - $subShort = $this->getShortDescription($subChild, $isSubSDesc); - - $href = $this->createLink($subChild); - if ($isSubLDesc && $isSubSDesc) { - $list .= '<li><a href="' . $href . '">' . $subShort . '</a> â ' . $subLong . "</li>\n"; - } else { - $list .= '<li><a href="' . $href . '">' . ($subLong ?: $subShort) . '</a>' . "</li>\n"; - } - } - $list .="</ol>"; - } - } - if ($isLDesc && $isSDesc) { - $toc .= '<li><a href="' . $link . '">' . $short . '</a> â ' . $long . $list . "</li>\n"; - } else { - $toc .= '<li><a href="' . $link . '">' . ($long ?: $short) . '</a>' . $list . "</li>\n"; - } + /* Functions from PhDThemeXhtml */ + + /** + * Called after the constructor finished. + * This is needed since themes set their outputdir and outputfile + * in the constructor. That file/dir is used for mediamanager. + * That means we cannot instantiate and complete the manager in our + * constructor centrally. + * + * Each theme needs its own media manager, since the manager contains + * the output path. + * + * @return void + */ + public function postConstruct() { + $this->mediamanager = new MediaManager(Config::xml_root()); + $outputdir = Config::output_dir(); + if (isset($outputdir) && $outputdir) { + $this->mediamanager->output_dir = $outputdir; + } else { + $this->mediamanager->output_dir = $outputfile . '-data/'; + $this->mediamanager->relative_ref_path = basename($this->mediamanager->output_dir) . '/'; } - $toc .= "</ol>\n"; - return $toc; } - public function update($event, $val = null) { - switch($event) { - case Render::CHUNK: - $this->flags = $val; - break; + /* Functions from XHTMLPhDFormat */ - case Render::STANDALONE: - if ($val) { - $this->registerElementMap(static::getDefaultElementMap()); - $this->registerTextMap(static::getDefaultTextMap()); - } - break; + /** + * Closes a para tag when we are already in a paragraph. + * + * @return string HTML code + * + * @see $openPara + * @see restorePara() + */ + public function escapePara() { + if (!$this->openPara) { + return ''; + } - case Render::INIT: - $this->outputdir = $tmp = Config::output_dir() . strtolower($this->getFormatName()) . '/'; - if (file_exists($tmp)) { - if (!is_dir($tmp)) { - v("Output directory is a file?", E_USER_ERROR); - } - } else { - if (!mkdir($tmp)) { - v("Can't create output directory", E_USER_ERROR); - } - } - break; - case Render::VERBOSE: - v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); - break; + if (!isset($this->escapedPara[$this->openPara])) { + $this->escapedPara[$this->openPara] = 1; + return '</p>'; + } else { + ++$this->escapedPara[$this->openPara]; + return ''; } } - public function getChunkInfo() { - return $this->cchunk; + /** + * Opens a para tag again when we escaped one before. + * + * @return string HTML code + * + * @see $openPara + * @see escapePara() + */ + public function restorePara() { + if (!$this->openPara || !isset($this->escapedPara[$this->openPara])) { + return ''; + } + + if ($this->escapedPara[$this->openPara] == 1) { + unset($this->escapedPara[$this->openPara]); + return '<p>'; + } else { + --$this->escapedPara[$this->openPara]; + return ''; + } } } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/Factory.php?r1=1.3&r2=1.4&diff_format=u Index: phd/phpdotnet/phd/Package/Default/Factory.php diff -u phd/phpdotnet/phd/Package/Default/Factory.php:1.3 phd/phpdotnet/phd/Package/Default/Factory.php:1.4 --- phd/phpdotnet/phd/Package/Default/Factory.php:1.3 Sat Jun 20 06:55:42 2009 +++ phd/phpdotnet/phd/Package/Default/Factory.php Mon Jun 22 02:31:42 2009 @@ -1,20 +1,19 @@ <?php namespace phpdotnet\phd; -class Package_Default_Factory extends Format_Factory -{ +class Package_Default_Factory extends Format_Factory { public function createXhtmlFormat() { - return new Package_Default_XHTML(); + return new Package_Default_ChunkedXHTML(); } -/* + public function createBigXhtmlFormat() { - return new DefaultBigXHTMLFormat(); + return new Package_Default_BigXHTML(); } - + public function createPHPFormat() { - return new DefaultPHPFormat(); + return new Package_Default_PHP(); } -*/ + } ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/XHTML.php?r1=1.3&r2=1.4&diff_format=u Index: phd/phpdotnet/phd/Package/Default/XHTML.php diff -u phd/phpdotnet/phd/Package/Default/XHTML.php:1.3 phd/phpdotnet/phd/Package/Default/XHTML.php:1.4 --- phd/phpdotnet/phd/Package/Default/XHTML.php:1.3 Sat Jun 20 06:55:42 2009 +++ phd/phpdotnet/phd/Package/Default/XHTML.php Mon Jun 22 02:31:42 2009 @@ -1,9 +1,7 @@ <?php namespace phpdotnet\phd; -class Package_Default_XHTML extends Format_Abstract_XHTML -{ - private $formatname = "XHTML"; +abstract class Package_Default_XHTML extends Format_Abstract_XHTML { private $myelementmap = array( /* {{{ */ 'abstract' => 'div', /* Docbook-xsl prints "abstract"... */ 'abbrev' => 'abbr', @@ -99,7 +97,6 @@ 'errortype' => 'span', 'errorcode' => 'span', 'example' => 'div', - 'phpdoc:exception' => 'format_exception_chunk', 'formalpara' => 'p', 'fieldsynopsis' => array( /* DEFAULT */ 'format_fieldsynopsis', @@ -305,6 +302,7 @@ 'titleabbrev' => 'format_suppressed_tags', 'type' => 'span', 'userinput' => 'format_userinput', + 'uri' => 'tt', 'variablelist' => 'format_variablelist', 'varlistentry' => 'format_varlistentry', 'varname' => array( @@ -324,13 +322,24 @@ ), 'questions' => 'ol', // From the PhD namespace 'answer' => 'dd', + + //phpdoc: implement in the PHP Package + 'phpdoc:classref' => 'format_suppressed_tags', + 'phpdoc:exception' => 'format_suppressed_tags', + 'phpdoc:exceptionref' => 'format_suppressed_tags', + 'phpdoc:varentry' => 'format_suppressed_tags', + + //phd + 'phd:toc' => 'format_phd_toc', + ); /* }}} */ + private $mytextmap = array( 'segtitle' => 'format_segtitle_text', 'affiliation' => 'format_suppressed_text', 'contrib' => 'format_suppressed_text', 'shortaffil' => 'format_suppressed_text', - 'titleabbrev' => 'format_suppressed_text', + 'programlisting' => 'format_programlisting_text', 'alt' => 'format_alt_text', 'modifier' => array( @@ -358,10 +367,10 @@ ), 'literal' => 'format_literal_text', 'email' => 'format_email_text', - + 'titleabbrev' => 'format_suppressed_text', ); - protected $title = "PhD Default Xhtml"; + //protected $flags; public function __construct() { parent::__construct(); @@ -375,116 +384,59 @@ return $this->mytextmap; } - public function header($id) { - $title = $this->getLongDescription($id); - $lang = $this->CURRENT_LANG; - - $prev = $next = $parent = array("href" => null, "desc" => null); - - if ($parentId = $this->getParent($id)) { - $parent = array("href" => $this->getFilename($parentId) . '.' .$this->ext, - "desc" => $this->getShortDescription($parentId)); - } - if ($prevId = Format::getPrevious($id)) { - $prev = array("href" => Format::getFilename($prevId) . '.' .$this->ext, - "desc" => $this->getShortDescription($prevId)); - } - if ($nextId = Format::getNext($id)) { - $next = array("href" => Format::getFilename($nextId) . '.' .$this->ext, - "desc" => $this->getShortDescription($nextId)); - } - $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"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .$lang. '" lang="' .$lang. '"> -<head> - <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> - <title>'.$this->title.': '.$title.'</title> -</head> -<body> -<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">'.$this->title.'</a></div> - </div><hr/> -'; - } - - public function footer($id) { - return "\n </td>\n </tr>\n</table>\n</body>\n</html>\n"; - } - - 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.'">'.$this->title.'</a></li> -'; - // Fetch ancestors of the current node - $ancestors = array(); - $currentId = $id; - while (($currentId = $this->getParent($currentId)) && $currentId != "index") { - $desc = ""; - $link = $this->createLink($currentId, $desc); - $ancestors[] = array("desc" => $desc, "link" => $link); + protected function createTOC($id, $lang) { + if (!$this->getChildrens($id)) { + return ""; } - // Show them from the root to the closest parent - foreach (array_reverse($ancestors) as $ancestor) { - $navBar .= " <li class=\"header up\"><a href=\"{$ancestor["link"]}\">{$ancestor["desc"]}</a></li>\n"; - } - // Fetch siblings of the current node - $parent = $this->getParent($id); - foreach ($this->getChildrens($parent) as $child) { - $desc = ""; - $link = $this->createLink($child, $desc); - $active = ($id === $child); - $navBar .= " <li" .($active ? " class=\"active\"" : ""). "><a href=\"$link\">$desc</a></li>\n"; + $toc = '<strong>' . $this->autogen('toc', $lang) . '</strong><ul>'; + foreach ($this->getChildrens($id) as $child) { + $isLDesc = null; + $isSDesc = null; + $long = $this->parse($this->getLongDescription($child, $isLDesc)); + $short = $this->getShortDescription($child, $isSDesc); + $link = $this->createLink($child); + + $list = ""; + if ($this->cchunk["name"] === "book" || $this->cchunk["name"] === "set") { + if ($this->getChildrens($child)) { + $list = "<ul>"; + foreach ($this->getChildrens($child) as $subChild) { + $isSubLDesc = null; + $isSubSDesc = null; + $subLong = $this->parse($this->getLongDescription($subChild, $isLDesc)); + $subShort = $this->getShortDescription($subChild, $isSubSDesc); + + $href = $this->createLink($subChild); + if ($isSubLDesc && $isSubSDesc) { + $list .= '<li><a href="' . $href . '">' . $subShort . '</a> â ' . $subLong . "</li>\n"; + } else { + $list .= '<li><a href="' . $href . '">' . ($subLong ?: $subShort) . '</a>' . "</li>\n"; + } + } + $list .="</ul>"; + } + } + if ($isLDesc && $isSDesc) { + $toc .= '<li><a href="' . $link . '">' . $short . '</a> â ' . $long . $list . "</li>\n"; + } else { + $toc .= '<li><a href="' . $link . '">' . ($long ?: $short) . '</a>' . $list . "</li>\n"; + } + } + $toc .= "</ul>\n"; + return $toc; + } + + public function createLink($for, &$desc = null, $type = Format::SDESC) { + $retval = null; + if (isset($this->indexes[$for])) { + $rsl = $this->indexes[$for]; + $retval = $rsl["filename"] . "." . $this->ext . '#' . $rsl["docbook_id"]; + $desc = $rsl["sdesc"] ?: $rsl["ldesc"]; } - return $navBar . " </ul>\n"; + return $retval; } - + /* Functions format_* */ public function format_suppressed_tags($open, $name, $attrs, $props) { /* Ignore it */ @@ -566,18 +518,21 @@ } return '</div>'; } + public function format_author($open, $name, $attrs, $props) { if ($open) { return '<div class="' .$name. ' vcard">'; } return "</div>"; } + public function format_personname($open, $name, $attrs, $props) { if ($open) { return '<span class="' .$name. ' fn">'; } return "</span>"; } + public function format_name($open, $name, $attrs) { if ($open) { $class = ""; @@ -1324,10 +1279,10 @@ public function format_qandaset($open, $name, $attrs, $props) { if ($open) { $node = $this->getReader()->expand(); - $doc = new DOMDocument; + $doc = new \DOMDocument; $doc->appendChild($node); - $xp = new DOMXPath($doc); + $xp = new \DOMXPath($doc); $xp->registerNamespace("db", Reader::XMLNS_DOCBOOK); $questions = $xp->query("//db:qandaentry/db:question"); @@ -1379,5 +1334,4 @@ return '<<a href="mailto:' . $value . '">' . $value . '</a>>'; } - } http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Config.php?r1=1.62&r2=1.63&diff_format=u Index: phd/phpdotnet/phd/Config.php diff -u phd/phpdotnet/phd/Config.php:1.62 phd/phpdotnet/phd/Config.php:1.63 --- phd/phpdotnet/phd/Config.php:1.62 Mon Jun 22 01:22:52 2009 +++ phd/phpdotnet/phd/Config.php Mon Jun 22 02:31:42 2009 @@ -1,6 +1,6 @@ <?php namespace phpdotnet\phd; -/* $Id: Config.php,v 1.62 2009/06/22 01:22:52 moacir Exp $ */ +/* $Id: Config.php,v 1.63 2009/06/22 02:31:42 moacir Exp $ */ define("PHD_VERSION", "phd-from-cvs"); @@ -39,7 +39,7 @@ 'phd_info_output' => NULL, 'phd_info_color' => false, 'highlighter' => "phpdotnet\\phd\\Highlighter", - 'package' => 'PHP', + 'package' => 'Default', ); public static function init(array $a) { http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/ChunkedXHTML.php?view=markup&rev=1.1 Index: phd/phpdotnet/phd/Package/Default/ChunkedXHTML.php +++ phd/phpdotnet/phd/Package/Default/ChunkedXHTML.php <?php namespace phpdotnet\phd; class Package_Default_ChunkedXHTML extends Package_Default_XHTML { protected $formatname = "Chunked-XHTML"; protected $title = "Index"; public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); $this->chunked = true; } public function __destruct() { $this->close(); } public function appendData($data) { if ($this->appendToBuffer) { $this->buffer .= $data; return; } elseif ($this->flags & Render::CLOSE) { $fp = array_pop($this->fp); fwrite($fp, $data); $this->writeChunk($this->CURRENT_CHUNK, $fp); fclose($fp); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { $this->fp[] = $fp = fopen("php://temp/maxmemory", "r+"); fwrite($fp, $data); $this->flags ^= Render::OPEN; } else { $fp = end($this->fp); fwrite($fp, $data); } } public function writeChunk($id, $fp) { $filename = $this->outputdir . $id . '.' .$this->ext; rewind($fp); file_put_contents($filename, $this->header($id)); file_put_contents($filename, $fp, FILE_APPEND); file_put_contents($filename, $this->footer($id), FILE_APPEND); } public function close() { foreach ($this->fp as $fp) { fclose($fp); } } public function update($event, $val = null) { switch($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: $this->outputdir = $tmp = Config::output_dir() . strtolower($this->getFormatName()) . '/'; if (file_exists($tmp)) { if (!is_dir($tmp)) { v("Output directory is a file?", E_USER_ERROR); } } else { if (!mkdir($tmp)) { v("Can't create output directory", E_USER_ERROR); } } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } } public function header($id) { $title = $this->getLongDescription($id); $lang = Config::language(); $prev = $next = $parent = array("href" => null, "desc" => null); if ($parentId = $this->getParent($id)) { $parent = array("href" => $this->getFilename($parentId) . '.' .$this->ext, "desc" => $this->getShortDescription($parentId)); } if ($prevId = Format::getPrevious($id)) { $prev = array("href" => Format::getFilename($prevId) . '.' .$this->ext, "desc" => $this->getShortDescription($prevId)); } if ($nextId = Format::getNext($id)) { $next = array("href" => Format::getFilename($nextId) . '.' .$this->ext, "desc" => $this->getShortDescription($nextId)); } $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"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .$lang. '" lang="' .$lang. '"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>'.$this->title.': '.$title.'</title> </head> <body> <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">'.$this->title.'</a></div> </div><hr/> '; } public function footer($id) { return "\n </td>\n </tr>\n</table>\n</body>\n</html>\n"; } 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.'">'.$this->title.'</a></li> '; // Fetch ancestors of the current node $ancestors = array(); $currentId = $id; while (($currentId = $this->getParent($currentId)) && $currentId != "index") { $desc = ""; $link = $this->createLink($currentId, $desc); $ancestors[] = array("desc" => $desc, "link" => $link); } // Show them from the root to the closest parent foreach (array_reverse($ancestors) as $ancestor) { $navBar .= " <li class=\"header up\"><a href=\"{$ancestor["link"]}\">{$ancestor["desc"]}</a></li>\n"; } // Fetch siblings of the current node $parent = $this->getParent($id); foreach ($this->getChildrens($parent) as $child) { $desc = ""; $link = $this->createLink($child, $desc); $active = ($id === $child); $navBar .= " <li" .($active ? " class=\"active\"" : ""). "><a href=\"$link\">$desc</a></li>\n"; } return $navBar . " </ul>\n"; } } ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/BigXHTML.php?view=markup&rev=1.1 Index: phd/phpdotnet/phd/Package/Default/BigXHTML.php +++ phd/phpdotnet/phd/Package/Default/BigXHTML.php <?php namespace phpdotnet\phd; class Package_Default_BigXHTML extends Package_Default_XHTML { protected $formatname = "Big-XHTML"; protected $title = "Index"; public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); $this->chunked = false; } public function __destruct() { $this->close(); } public function appendData($data) { if ($this->appendToBuffer) { $this->buffer .= $data; return; } if ($this->flags & Render::CLOSE) { fwrite($this->fp, $data); /* Append footer */ fwrite($this->fp, $this->footer()); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { fwrite($this->fp, "\n".$data); $this->flags ^= Render::OPEN; } else { fwrite($this->fp, $data); } } public function header() { return <<<HEADER <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>$this->title</title> </head> <body> HEADER; } public function footer($eof = false) { return !$eof ? "\n<hr />\n" : "</body>\n</html>"; } public function close() { fwrite($this->fp, $this->footer(true)); fclose($this->fp); } public function update($event, $val = null) { switch($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(parent::getDefaultElementMap()); $this->registerTextMap(parent::getDefaultTextMap()); } break; case Render::INIT: if ($val) { if (!is_resource($this->fp)) { static $i = 0; $i++; $filename = Config::output_dir() . strtolower($this->getFormatName()) . $i . '.' . $this->ext; $this->fp = fopen($filename, "w+"); fwrite($this->fp, $this->header()); } } break; case Render::VERBOSE: v("Starting %s rendering", $this->getFormatName(), VERBOSE_FORMAT_RENDERING); break; } } public function createLink($for, &$desc = null, $type = self::SDESC) { $retval = '#' . $for; if (isset($this->indexes[$for])) { $result = $this->indexes[$for]; if ($type === self::SDESC) { $desc = $result["sdesc"] ?: $result["ldesc"]; } else { $desc = $result["ldesc"] ?: $result["sdesc"]; } } return $retval; } } ?> http://cvs.php.net/viewvc.cgi/phd/phpdotnet/phd/Package/Default/PHP.php?view=markup&rev=1.1 Index: phd/phpdotnet/phd/Package/Default/PHP.php +++ phd/phpdotnet/phd/Package/Default/PHP.php <?php namespace phpdotnet\phd; class Package_Default_PHP extends Package_Default_ChunkedXHTML { protected $myelementmap = array( 'acronym' => 'format_suppressed_tags', 'function' => 'format_suppressed_tags', 'link' => 'format_link', 'refpurpose' => 'format_refpurpose', 'varname' => array( /* DEFAULT */ 'var', 'fieldsynopsis' => 'format_fieldsynopsis_varname', ), 'xref' => 'format_xref', '.title' => array( /* DEFAULT */ false, 'info' => array( /* DEFAULT */ false, 'article' => 'format_container_chunk_top_title', 'appendix' => 'format_container_chunk_top_title', 'book' => 'format_container_chunk_top_title', 'chapter' => 'format_container_chunk_top_title', 'part' => 'format_container_chunk_top_title', 'set' => 'format_container_chunk_top_title', ), 'article' => 'format_container_chunk_top_title', 'appendix' => 'format_container_chunk_top_title', 'book' => 'format_container_chunk_top_title', 'chapter' => 'format_container_chunk_top_title', 'part' => 'format_container_chunk_top_title', 'set' => 'format_container_chunk_top_title', ), '.reference' => 'format_container_chunk_below', '.question' => array( /* DEFAULT */ false, 'questions' => 'format_phd_question', // From the PhD namespace ), ); protected $mytextmap = array( 'acronym' => 'format_acronym_text', 'function' => 'format_function_text', 'methodname' => array( /* DEFAULT */ 'format_function_text', 'constructorsynopsis' => array( /* DEFAULT */ 'format_function_text', 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'methodsynopsis' => array( /* DEFAULT */ 'format_function_text', 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'destructorsynopsis' => array( /* DEFAULT */ 'format_function_text', 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), ), 'refname' => 'format_refname_text', 'type' => array( /* DEFAULT */ 'format_type_text', 'classsynopsisinfo' => false, 'fieldsynopsis' => 'format_type_if_object_or_pseudo_text', 'methodparam' => 'format_type_if_object_or_pseudo_text', 'methodsynopsis' => array( /* DEFAULT */ 'format_type_if_object_or_pseudo_text', 'classsynopsis' => false, ), ), ); protected $formatname = "PHP"; protected $title = "Index"; private $acronyms = array(); private $versions = array(); private $refname = ""; public function __construct() { parent::__construct(); parent::registerFormatName($this->formatname); $this->ext = "php"; $this->versions = self::generateVersionInfo(Config::phpweb_version_filename()); $this->acronyms = self::generateAcronymInfo(Config::phpweb_acronym_filename()); } public function __destruct() { parent::close(); } public function header($id) { return '<?php include_once $_SERVER[\'DOCUMENT_ROOT\'] . \'/include/shared-manual.inc\'; $setup = array( "home" => array("index.php", "'.$this->title.'"), "head" => array("UTF-8", "en"), "this" => array(null, null), "up" => array(null, null), "prev" => array(null, null), "next" => array(null, null), "toc" => array(), "parents" => array(), ); manual_setup($setup); manual_header(); ?>'; } public function footer($id) { return "<?php manual_footer(); ?>"; } public function update($event, $val = null) { switch($event) { case Render::CHUNK: $this->flags = $val; break; case Render::STANDALONE: if ($val) { $this->registerElementMap(array_merge(parent::getDefaultElementMap(), static::getDefaultElementMap())); $this->registerTextMap(array_merge(parent::getDefaultTextMap(), static::getDefaultTextMap())); } else { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: parent::update($event, $val); break; case Render::VERBOSE: parent::update($event, $val); break; } } protected function lookupRefname($for) { $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; } public static function generateVersionInfo($filename) { static $info; if ($info) { return $info; } $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(); $info = $versions; return $versions; } public static function generateAcronymInfo($filename) { static $info; if ($info) { return $info; } $r = new \XMLReader; if (!$r->open($filename)) { throw new \Exception("Could not open $filename"); } $acronyms = array(); while ($r->read()) { if ($r->nodeType != \XMLReader::ELEMENT) { continue; } if ($r->name == "term") { $r->read(); $k = $r->value; $acronyms[$k] = ""; } else if ($r->name == "simpara") { $r->read(); $acronyms[$k] = $r->value; } } $info = $acronyms; return $acronyms; } 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 acronymInfo($acronym) { return isset($this->acronyms[$acronym]) ? $this->acronyms[$acronym] : false; } public function format_acronym_text($value, $tag) { $resolved = $this->acronymInfo($value); if ($resolved) { return '<acronym title="' .$resolved. '">' .$value. '</acronym>'; } return '<acronym>'.$value.'</acronym>'; } public function format_refpurpose($open, $tag, $attrs, $props) { if ($open) { return '<p class="verinfo">(' .(htmlspecialchars($this->versionInfo($this->refname), ENT_QUOTES, "UTF-8")). ')</p><p class="refpurpose dc-title">'. $this->refname. ' â '; } return "</p>\n"; } public function format_fieldsynopsis_varname($open, $name, $attrs) { if ($open) { $href = ""; if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"])) { $href = $this->createLink($attrs[Reader::XMLNS_DOCBOOK]["linkend"]); $href = '<a href="' .$href. '">'; } if ($this->cchunk["fieldsynopsis"]["modifier"] == "const") { return '<var class="fieldsynopsis_varname">'.$href; } return '<var class="'.$name.'">'.$href.'$'; } if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"])) { return '</a></var>'; } return '</var>'; } public function format_refname_text($value, $tag) { $this->refname = $value; return false; } public function format_function_text($value, $tag, $display_value = null) { if ($display_value === null) { $display_value = $value; } $ref = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $value)); $filename = $this->lookupRefname($ref); if (($filename !== false) && $this->CURRENT_CHUNK !== $filename) { $desc = ""; $href = $this->createLink($filename, $desc); return '<a href="' . $href . '" class="function" title="' . $desc . '">' . $display_value . ($tag == "function" ? "()" : ""). '</a>'; } return '<strong>' . $display_value . ($tag === "function" ? "()" : ""). '</strong>'; } public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) { $value = $this->TEXT($value); if ($this->cchunk["classsynopsis"]["classname"] === false) { return $this->format_function_text($value, $tag); } if (strpos($value, '::')) { $explode = '::'; } elseif (strpos($value, '->')) { $explode = '->'; } else { return $this->format_function_text($value, $tag); } list($class, $method) = explode($explode, $value); if ($class !== $this->cchunk["classsynopsis"]["classname"]) { return $this->format_function_text($value, $tag); } return $this->format_function_text($value, $tag, $method); } public function format_type_if_object_or_pseudo_text($value, $tag) { if (in_array(strtolower($value), array("bool", "int", "double", "boolean", "integer", "float", "string", "array", "object", "resource", "null"))) { return false; } return self::format_type_text($value, $tag); } public function format_type_text($value, $tag) { $t = strtolower($value); switch($t) { case "bool": $id = "language.types.boolean"; break; case "int": case "long": $id = "language.types.integer"; break; case "double": $id = "language.types.float"; break; /* FIXME: These aren't documented yet */ case "binary": case "unicode": $id = "language.types.string"; break; case "void": case "boolean": case "integer": case "float": case "string": case "array": case "object": case "resource": case "null": $id = "language.types.$t"; break; case "mixed": case "number": case "callback": $id = "language.types.$t"; break; default: /* Check if its a classname. */ $t = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $t)); $id = "class.$t"; } $desc = ""; $href = $this->createLink($id, $desc); if ($href) { return '<a href="' .$href. '" class="' .$tag. ' ' .$value. '" title="' . $desc . '">' .$value. '</a>'; } return '<span class="' .$tag. ' ' .$value. '">' .$value. '</span>'; } } ?>