package.xml000644 000000 000000 00000017743 11767147642 011374 0ustar00000000 000000 PhD_Generic doc.php.net Generic rendering package for PhD A generic rendering package for PhD Hannes Magnusson bjori bjori@php.net yes Christian Weiske cweiske cweiske@php.net yes Moacir de Oliveira moacir moacir@php.net yes 2012-06-16 1.1.6 1.1.0 stable stable BSD Style - Bump version 5.3.0 1.8.0 PhD doc.php.net 0.9.0 libxml xmlreader dom haru zlib 0.9.0 0.9.0 beta beta 2009-09-09 BSD Style - Initial release 0.9.1 0.9.1 beta beta 2009-12-21 BSD Style - Added support for <errortext> (Hannes) - Implemented PEAR request #2390: RSS feeds for PEAR Dcumentation Index (Christian) - Fixed bug #49925 - imagedata now supports width and/or depth (becomes width and/or height) (Richard Quadling) - Removed the format php (Moacir) - VERBOSE_MISSING_ATTRIBUTE message generated when missing one of the width/height attributes on imagedata (Richard Quadling) - VERBOSE_MISSING_ATTRIBUTE message generated when missing alt attributes on mediaobject > imagedata (Richard Quadling) 1.0.0 1.0.0 stable stable 2010-03-11 BSD Style - Fixed bug#50799 (No text mapping for screen). (Paul M Jones) - Fixed bug #46413 Weird examples in Unix manual pages (Rudy) 1.0.1 1.0.0 stable stable 2010-08-10 BSD Style - Fixed #51514 - Added tr, th and td mappings (Patch provided by Paul M Jones) (Richard Quadling) - Fixed #51346 - Extra whitespace when using <type> and plural (Daniel Egeberg) - Fixed #50666 - Missing entries in table (man pages) (Hannes) - Fixed #51301 - Wrong escape sequence (man pages) (Hannes) - Several formatting fixes for the unix manual pages (Hannes) - Added Generic Unix Manual pages output format (Hannes) - Fixed #51833 - Multiple paragraphs in notes render incorrectly (Daniel Egeberg) - Added format_option to bold options (Philip) 1.1.0 1.1.0 stable stable 2011-03-07 BSD Style - Allow xml:id on <table> (Richard Quadling) - Add class="note" to <note>s generated <blockquote> (Hannes) - Generate an ID for <refsect1> (Hannes) - Generate IDS for all <example>s (Hannes) 1.1.1 1.1.0 stable stable 2011-06-21 BSD Style - Fixed bug#54705 (Tables in manpages not visible). (Hannes) 1.1.2 1.1.0 stable stable 2011-12-18 BSD Style - Added support for authorinitials, printhistory, revhistory, revision and revremark (Hannes) - Added generate-index-for=(refentry,function,examples) support for the phpdoc PI handler (Hannes) 1.1.3 1.1.0 stable stable 2012-03-01 BSD Style - Allow link to methodsynopsis (Jakub Vrana) - Got rid of presentational tags: <b>, <i>, <tt> changed to <strong>, <em>, <code> (Alexey Borzov) - Make presentational attributes on table related-tags (align, valign, width) output as inline styles (Alexey Borzov) - Fixed ID generation for refsections (Alexey Borzov) 1.1.4 1.1.0 stable stable 2012-04-06 BSD Style - Bump version 1.1.5 1.1.0 stable stable 2012-06-07 BSD Style - Bump version PhD_Generic-1.1.6/phpdotnet/phd/Package/Generic/Factory.php000644 000000 000000 00000001350 11767147642 021621 0ustar00000000 000000 'Package_Generic_ChunkedXHTML', 'bigxhtml' => 'Package_Generic_BigXHTML', 'manpage' => 'Package_Generic_Manpage', ); /** * The package version */ private $version = '1.1.6'; public function __construct() { parent::setPackageName('Generic'); parent::setPackageVersion($this->version); parent::registerOutputFormats($this->formats); } } /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 */ PhD_Generic-1.1.6/phpdotnet/phd/Package/Generic/Manpage.php000644 000000 000000 00000072656 11767147642 021603 0ustar00000000 000000 'format_suppressed_tags', 'article' => 'format_suppressed_tags', 'abbrev' => 'format_suppressed_tags', 'abstract' => 'format_suppressed_tags', 'alt' => 'format_suppressed_tags', 'appendix' => 'format_suppressed_tags', 'application' => 'format_suppressed_tags', 'author' => 'format_suppressed_tags', 'authorgroup' => 'format_suppressed_tags', 'book' => 'format_suppressed_tags', 'blockquote' => 'format_suppressed_tags', 'calloutlist' => 'format_suppressed_tags', 'callout' => 'format_suppressed_tags', 'caution' => 'format_admonition', 'chapter' => 'format_suppressed_tags', 'citerefentry' => 'format_suppressed_tags', 'classname' => 'format_suppressed_tags', 'classsynopsis' => '.PP', 'classsynopsisinfo' => '.PP', 'co' => 'format_suppressed_tags', 'code' => 'format_suppressed_tags', 'command' => '\\fI', 'computeroutput' => 'format_suppressed_tags', 'constant' => '\\fB', 'constructorsynopsis' => 'format_methodsynopsis', 'copyright' => 'format_suppressed_tags', 'destructorsynopsis' => 'format_methodsynopsis', 'editor' => 'format_suppressed_tags', 'emphasis' => '\\fI', 'envar' => 'format_suppressed_tags', 'errortype' => 'format_suppressed_tags', 'example' => 'format_example', 'fieldsynopsis' => 'format_suppressed_tags', 'figure' => 'format_suppressed_tags', 'firstname' => 'format_suppressed_tags', 'footnote' => 'format_suppressed_tags', 'footnoteref' => 'format_suppressed_tags', 'filename' => '\\fI', 'formalpara' => 'format_indent', 'funcdef' => '.B', 'function' => array( /* DEFAULT */ 'format_suppressed_tags', 'member' => 'format_suppressed_tags', ), 'glossterm' => 'format_suppressed_tags', 'holder' => 'format_suppressed_tags', 'imagedata' => 'format_suppressed_tags', 'indexentry' => 'format_suppressed_tags', 'imageobject' => 'format_suppressed_tags', 'info' => 'format_suppressed_tags', 'indexdiv' => 'format_suppressed_tags', 'index' => 'format_suppressed_tags', 'informalexample' => '.PP', 'initializer' => array( /* DEFAULT */ 'format_suppressed_tags', 'methodparam' => 'format_suppressed_tags', ), 'interfacename' => 'format_suppressed_tags', 'itemizedlist' => 'format_itemizedlist', 'legalnotice' => 'format_suppressed_tags', 'link' => 'format_suppressed_tags', 'listitem' => array( /* DEFAULT */ false, 'varlistentry' => 'format_suppressed_tags', 'itemizedlist' => ".TP 0.2i\n\\(bu", 'orderedlist' => ".TP 0.2i\n\\(bu", ), 'literal' => '\\fI', 'literallayout' => 'format_verbatim', 'manvolnum' => 'format_manvolnum', 'mediaobject' => 'format_mediaobject', 'member' => 'format_member', 'methodname' => '\\fB', 'methodparam' => 'format_methodparam', 'methodsynopsis' => 'format_methodsynopsis', 'modifier' => 'format_suppressed_tags', 'note' => 'format_admonition', 'ooclass' => 'format_suppressed_tags', 'oointerface' => 'format_suppressed_tags', 'option' => '\\fI', 'optional' => 'format_suppressed_tags', 'orderedlist' => 'format_itemizedlist', 'othername' => 'format_suppressed_tags', 'othercredit' => 'format_suppressed_tags', 'partintro' => 'format_suppressed_tags', 'personname' => 'format_suppressed_tags', 'para' => array( /* DEFAULT */ '.PP', 'listitem' => 'format_suppressed_tags', 'entry' => 'format_suppressed_tags', ), 'paramdef' => 'format_suppressed_tags', 'parameter' => array( /* DEFAULT */ 'format_suppressed_tags', 'methodparam' => 'format_parameter_method', 'code' => '\\fI', ), 'productname' => 'format_suppressed_tags', 'preface' => 'format_suppressed_tags', 'part' => 'format_suppressed_tags', 'programlisting' => 'format_verbatim', 'property' => 'format_suppressed_tags', 'procedure' => 'format_suppressed_tags', 'primaryie' => 'format_suppressed_tags', 'pubdate' => 'format_suppressed_tags', 'qandaset' => 'format_suppressed_tags', 'qandaentry' => 'format_suppressed_tags', 'question' => 'format_suppressed_tags', 'answer' => 'format_suppressed_tags', 'quote' => 'format_suppressed_tags', 'refentry' => 'format_chunk', 'refentrytitle' => '\\fB', 'reference' => 'format_suppressed_tags', 'refname' => 'format_refname', 'refnamediv' => 'format_suppressed_tags', 'refpurpose' => 'format_refpurpose', 'refsect1' => 'format_refsect', 'refsect2' => 'format_suppressed_tags', 'refsection' => 'format_refsect', 'refsynopsisdiv' => 'format_refsynopsisdiv', 'replaceable' => '\\fI', 'set' => 'format_bookname', 'screen' => 'format_verbatim', 'section' => 'format_suppressed_tags', 'sect1' => 'format_suppressed_tags', 'sect2' => 'format_suppressed_tags', 'sect3' => 'format_suppressed_tags', 'sect4' => 'format_suppressed_tags', 'sect5' => 'format_suppressed_tags', 'seg' => 'format_seg', 'segindex' => 'format_suppressed_tags', 'seglistitem' => 'format_seglistitem', 'segmentedlist' => 'format_segmentedlist', 'segtitle' => 'format_suppressed_tags', 'simpara' => array( /* DEFAULT */ '.PP', 'listitem' => '', ), 'simplelist' => 'format_simplelist', 'simplesect' => 'format_suppressed_tags', 'subscript' => 'format_suppressed_tags', 'surname' => 'format_suppressed_tags', 'step' => 'format_suppressed_tags', 'synopsis' => 'format_suppressed_tags', 'systemitem' => '\\fB', 'tag' => 'format_suppressed_tags', 'term' => 'format_term', 'title' => array( /* DEFAULT */ '.B', 'segmentedlist' => '.B', 'refsect1' => 'format_refsect_title', 'refsection' => 'format_refsect_title', 'section' => 'format_refsect_title', ), 'tip' => 'format_admonition', 'titleabbrev' => 'format_suppressed_tags', 'type' => array( /* DEFAULT */ '\\fR', 'methodparam' => 'format_suppressed_tags' ), 'userinput' => '\\fB', 'variablelist' => 'format_indent', 'varlistentry' => ".TP 0.2i\n\\(bu ", 'varname' => 'format_suppressed_tags', 'void' => 'format_void', 'warning' => 'format_admonition', 'year' => 'format_suppressed_tags', 'xref' => 'format_xref', // GROFF (tbl) ARRAYS 'informaltable' => '.P', 'table' => '.P', 'tgroup' => 'format_tgroup', 'colspec' => 'format_suppressed_tags', 'thead' => 'format_thead', 'tbody' => 'format_suppressed_tags', 'row' => 'format_row', 'entry' => 'format_entry', 'phpdoc:classref' => 'format_suppressed_tags', 'phpdoc:exceptionref' => 'format_suppressed_tags', 'phpdoc:varentry' => 'format_suppressed_tags', ); /* }}} */ private $textmap = array( 'classname' => array( /* DEFAULT */ false, 'ooclass' => 'format_ooclass_name_text', ), 'function' => 'format_function_text', 'initializer' => array( /* DEFAULT */ false, 'methodparam' => 'format_initializer_method_text', ), 'literallayout' => 'format_verbatim_text', 'manvolnum' => 'format_text', 'parameter' => array( /* DEFAULT */ 'format_parameter_text', 'code' => false, 'methodparam' => 'format_parameter_method_text', ), 'programlisting' => 'format_verbatim_text', 'pubdate' => 'format_pubdate_text', 'refname' => 'format_refname_text', 'refpurpose' => 'format_text', 'screen' => 'format_verbatim_text', 'segtitle' => 'format_segtitle_text', 'title' => array( /* DEFAULT */ false, 'refsect' => 'format_refsect_text', 'refsect1' => 'format_refsect_text', 'section' => 'format_refsect_text', ), 'tag' => 'format_tag_text', 'type' => array( /* DEFAULT */ false, 'methodparam' => 'format_type_method_text', ), 'varname' => 'format_parameter_text', ); /* If a chunk is being processed */ protected $chunkOpen = false; /* Common properties for all functions pages */ protected $bookName = ""; protected $date = ""; /* Current Chunk variables */ protected $cchunk = array(); /* Default Chunk variables */ private $dchunk = array( "appendlater" => false, "firstitem" => false, "buffer" => array(), "examplenumber" => 0, "methodsynopsis" => array( "params" => array(), "firstsynopsis" => true, ), "open" => false, "ooclass" => null, "role" => null, "segtitle" => array(), "segindex" => 0, "funcname" => array(), "firstrefname" => true, ); public function __construct() { parent::__construct(); $this->registerFormatName("Generic Unix Manual Pages"); $this->setExt(Config::ext() === null ? ".3.gz" : Config::ext()); $this->setChunked(true); $this->cchunk = $this->dchunk; } public function update($event, $val = null) { switch($event) { case Render::CHUNK: switch($val) { case self::OPEN_CHUNK: if ($this->getFileStream()) { /* I have an already open stream, back it up */ $this->pChunk = $this->cchunk; } $this->pushFileStream(fopen("php://temp/maxmemory", "r+")); $this->cchunk = $this->dchunk; $this->chunkOpen = true; break; case self::CLOSE_CHUNK: $stream = $this->popFileStream(); $this->writeChunk($stream); fclose($stream); /* Do I have a parent stream I need to resume? */ if ($this->getFileStream()) { $this->cchunk = $this->pChunk; $this->chunkOpen = true; } else { $this->cchunk = array(); $this->chunkOpen = false; } break; default: var_dump("Unknown action"); } break; case Render::STANDALONE: if ($val) { $this->registerElementMap(self::getDefaultElementMap()); $this->registerTextMap(self::getDefaultTextMap()); } else { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: $this->setOutputDir(Config::output_dir() . strtolower($this->toValidName($this->getFormatName())) . '/'); if (file_exists($this->getOutputDir())) { if (!is_dir($this->getOutputDir())) { v("Output directory is a file?", E_USER_ERROR); } } else { if (!mkdir($this->getOutputDir(), 0777, true)) { 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 appendData($data) { if ($this->chunkOpen) { if (trim($data) === "") { return 0; } $streams = $this->getFileStream(); $stream = end($streams); return fwrite($stream, $data); } return 0; } public function writeChunk($stream) { if (!isset($this->cchunk["funcname"][0])) { return; } $index = 0; rewind($stream); $filename = $this->cchunk["funcname"][$index] . $this->getExt(); $gzfile = gzopen($this->getOutputDir() . $filename, "w9"); gzwrite($gzfile, $this->header($index)); gzwrite($gzfile, stream_get_contents($stream)); gzclose($gzfile); v("Wrote %s", $this->getOutputDir() . $filename, VERBOSE_CHUNK_WRITING); /* methods/functions with the same name */ while(isset($this->cchunk["funcname"][++$index])) { $filename = $this->cchunk["funcname"][$index] . $this->getExt(); rewind($stream); // Replace the default function name by the alternative one $content = preg_replace('/'.$this->cchunk["funcname"][0].'/', $this->cchunk["funcname"][$index], stream_get_contents($stream), 1); $gzfile = gzopen($this->getOutputDir() . $filename, "w9"); gzwrite($gzfile, $this->header($index)); gzwrite($gzfile, $content); gzclose($gzfile); v("Wrote %s", $this->getOutputDir() . $filename, VERBOSE_CHUNK_WRITING); } } public function header($index) { return ".TH " . strtoupper($this->cchunk["funcname"][$index]) . " 3 \"" . $this->date . "\" \"PhD manpage\" \"" . $this->bookName . "\"" . "\n"; } public function getChunkInfo() { return $this->cchunk; } public function getDefaultChunkInfo() { return $this->dchunk; } public function getDefaultElementMap() { return $this->elementmap; } public function getDefaultTextMap() { return $this->textmap; } public function format_chunk($open, $name, $attrs, $props) { if ($open) { $this->notify(Render::CHUNK, self::OPEN_CHUNK); } else { $this->notify(Render::CHUNK, self::CLOSE_CHUNK); } return false; } public function format_bookname($value, $tag) { $this->bookName = $value; return false; } 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_refsect_text($value, $tag) { if ($this->cchunk["appendlater"] && isset($this->cchunk["buffer"])) array_push($this->cchunk["buffer"], strtoupper('"'.$value.'"')); else return strtoupper('"'.$value.'"'); } public function format_refsect_title($open, $name, $attrs, $props) { if ($open) { if ($this->cchunk["appendlater"] && isset($this->cchunk["buffer"])) array_push($this->cchunk["buffer"], "\n.SH "); else return "\n.SH "; } return ""; } public function format_refname($open, $name, $attrs, $props) { if ($open) { return (isset($this->cchunk["firstrefname"]) && $this->cchunk["firstrefname"]) ? false : ""; } if (isset($this->cchunk["firstrefname"]) && $this->cchunk["firstrefname"]) { $this->cchunk["firstrefname"] = false; return false; } return ""; } /* public function format_refname($open, $name, $attrs, $props) { if ($open) { return "\n.SH " . $this->autogen($name, $props["lang"]) . "\n"; } return ""; } */ public function format_refname_text($value, $tag) { $this->cchunk["funcname"][] = $this->toValidName(trim($value)); if (isset($this->cchunk["firstrefname"]) && $this->cchunk["firstrefname"]) { return false; } return ""; } public function format_refpurpose($open, $name, $attrs, $props) { if ($open) { return " \- "; } } public function format_function_text($value, $tag) { return "\\fB" . $this->toValidName($value) . "\\fP(3)"; } public function format_parameter_text($value, $tag) { return "\\fI" . ((isset($value[0]) && $value[0] == "$") ? "" : "$") . $value . "\\fP"; } public function format_parameter_term_text($value, $tag) { return "\\fI$" . $value . "\\fP\n\-"; } public function format_term($open, $name, $attrs, $props) { if ($open) return ""; return "\n\-"; } public function format_simplelist($open, $name, $attrs, $props) { if (isset($this->cchunk["role"]) && $this->cchunk["role"] == "seealso") { if ($open) { $this->cchunk["firstitem"] = true; return ""; } return "."; } else { if ($open) { $this->cchunk["firstitem"] = true; return "\n.PP\n.RS\n"; } return "\n.RE\n.PP\n"; } } public function format_member($open, $name, $attrs, $props) { if ($open) { if (isset($this->cchunk["role"]) && $this->cchunk["role"] == "seealso") { if ($this->cchunk["firstitem"]) { $ret = ""; $this->cchunk["firstitem"] = false; } else { $ret = ", "; } return $ret; } if ($this->cchunk["firstitem"]) { $ret = "\n.TP 0.2i\n\\(bu"; $this->cchunk["firstitem"] = false; } else { $ret = "\n.TP 0.2i\n\\(bu"; } return $ret; } return ""; } public function format_admonition($open, $name, $attrs, $props) { if ($open) { return "\n.PP\n\\fB" . $this->autogen($name, $props["lang"]) . "\\fR\n.RS\n"; } return "\n.RE\n.PP\n"; } public function format_example($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["examplenumber"])) { return "\n.PP\n\\fB" . $this->autogen($name, $props["lang"]) . ++$this->cchunk["examplenumber"] . "\\fR\n.RS\n"; } return "\n.RE\n"; } public function format_itemizedlist($open, $name, $attrs, $props) { if ($open) { return "\n.PP\n.RS\n"; } return "\n.RE\n.PP\n"; } public function format_methodparam($open, $name, $attrs, $props) { if ($open) { $opt = isset($attrs[Reader::XMLNS_DOCBOOK]["choice"]) && $attrs[Reader::XMLNS_DOCBOOK]["choice"] == "opt"; $this->cchunk["methodsynopsis"]["params"][] = array( "optional" => $opt, "type" => "", "name" => "", "initializer" => "", "reference" => false, ); } return ""; } public function format_void($open, $name, $attrs, $props) { if ($open) { $this->cchunk["methodsynopsis"]["params"][] = array( "optional" => false, "type" => "void", "name" => "", "initializer" => "", "reference" => false, ); } return ""; } public function format_type_method_text($value, $tag) { $this->cchunk['methodsynopsis']['params'][count($this->cchunk['methodsynopsis']['params'])-1]['type'] = $value; return ""; } public function format_parameter_method($open, $name, $attrs, $props) { if ($open && isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "reference") { $this->cchunk['methodsynopsis']['params'][count($this->cchunk['methodsynopsis']['params'])-1]['reference'] = true; } return ""; } public function format_parameter_method_text($value, $tag) { $this->cchunk['methodsynopsis']['params'][count($this->cchunk['methodsynopsis']['params'])-1]['name'] = $value; return ""; } public function format_initializer_method_text($value, $tag) { $this->cchunk['methodsynopsis']['params'][count($this->cchunk['methodsynopsis']['params'])-1]['initializer'] = $value; return ""; } public function format_refsynopsisdiv($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["methodsynopsis"]["firstsynopsis"]) && $this->cchunk["methodsynopsis"]["firstsynopsis"]) { return "\n.SH " . $this->autogen("refsynopsis", $props["lang"]) . "\n"; } if (!$open && isset($this->cchunk["methodsynopsis"]["firstsynopsis"])) $this->cchunk["methodsynopsis"]["firstsynopsis"] = false; return ""; } public function format_methodsynopsis($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["methodsynopsis"]["firstsynopsis"]) && $this->cchunk["methodsynopsis"]["firstsynopsis"] && $this->cchunk["appendlater"]) { $this->cchunk["appendlater"] = false; return "\n.SH " . $this->autogen("refsynopsis", $props["lang"]) . "\n"; } if ($open) return "\n.br"; $params = array(); // write the formatted synopsis foreach ($this->cchunk['methodsynopsis']['params'] as $parameter) { array_push($params, ($parameter['optional'] ? "[" : "") . $parameter['type'] . " " . ($parameter['reference'] ? " \\fI&\\fP" : " ") . ($parameter['name'] ? "\\fI$" . $parameter['name'] . "\\fP" : "") . ($parameter['initializer'] ? " = " . $parameter['initializer'] : "") . ($parameter['optional'] ? "]" : "") ); } $ret = "\n(" . join($params, ", ") . ")"; $this->cchunk['methodsynopsis']['params'] = array(); // finally write what is in the buffer if (isset($this->cchunk["buffer"])) { $ret .= implode("", $this->cchunk["buffer"]); $this->cchunk["buffer"] = array(); } if (isset($this->cchunk["methodsynopsis"]["firstsynopsis"])) $this->cchunk["methodsynopsis"]["firstsynopsis"] = false; return $ret; } public function format_xref($open, $name, $attrs, $props) { if ($props['empty']) return "\"" . Format::getShortDescription($attrs[Reader::XMLNS_DOCBOOK]["linkend"]) . "\""; return ""; } public function format_verbatim($open, $name, $attrs, $props) { if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $this->role = $attrs[Reader::XMLNS_DOCBOOK]["role"]; } else { $this->role = false; } return "\n.PP\n.nf"; } return "\n.fi"; } public function format_verbatim_text($value, $tag) { return trim($value); } public function format_refsect($open, $name, $attrs, $props) { if ($open && isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $this->cchunk["role"] = $attrs[Reader::XMLNS_DOCBOOK]["role"]; if ($this->cchunk["role"] == "description") { $this->cchunk["appendlater"] = true; } } if (!$open) $this->cchunk["role"] = null; return ""; } // Returns the unformatted value without whitespaces (nor new lines) public function format_text($value, $tag) { return trim(preg_replace('/[ \n\t]+/', ' ', $value)); } public function format_tgroup($open, $name, $attrs, $props) { if ($open) { $nbCols = $attrs[Reader::XMLNS_DOCBOOK]["cols"]; $ret = "\n.TS\nbox, tab (|);\n"; for ($i = 0; $i < $nbCols; $i++) $ret .= "c | "; $ret .= "."; return $ret; } return "\n.TE\n.PP\n"; } public function format_thead($open, $name, $attrs, $props) { if ($open) { return ""; } return "\n="; } public function format_row($open, $name, $attrs, $props) { if ($open) { $this->cchunk["firstitem"] = true; return "\n"; } return ""; } public function format_entry($open, $name, $attrs, $props) { if ($open) { if ($this->cchunk["firstitem"]) { $this->cchunk["firstitem"] = false; return "\nT{\n"; } return "\n|T{\n"; } return "\n\nT}"; } public function format_segmentedlist($open, $name, $attrs, $props) { if ($open) { return "\n.P\n"; } $this->cchunk["segtitle"] = array(); return "\n"; } public function format_seglistitem($open, $name, $attrs, $props) { if ($open && isset($this->cchunk["segindex"])) $this->cchunk["segindex"] = 0; return ""; } public function format_seg($open, $name, $attrs, $props) { if (! (isset($this->cchunk["segtitle"]) && isset($this->cchunk["segtitle"][$this->cchunk["segindex"]])) ) return ""; if ($open) { return "\n.br\n\\fB" . $this->cchunk["segtitle"][$this->cchunk["segindex"]] . ":\\fR"; } $this->cchunk["segindex"]++; return ""; } public function format_segtitle_text($value, $tag) { if (isset($this->cchunk["segtitle"])) $this->cchunk["segtitle"][] = $value; return ""; } public function format_manvolnum($open, $name, $attrs, $props) { if ($open) { return "("; } return ")"; } public function format_ooclass_name_text($value, $tag) { return "\n.br\n\\fI" . $value . "\\fP"; } public function format_indent($open, $name, $attrs, $props) { if ($open) { return "\n.PP\n.RS\n"; } return "\n.RE\n.PP\n"; } public function format_tag_text($value, $tag) { return "<" . $value . ">"; } // Convert the function name to a Unix valid filename public function toValidName($functionName) { return str_replace(array("::", "->", "()", " ", '$', '/', '\\'), array(".", ".", "", "-", "", "", ""), $functionName); } public function format_mediaobject($open, $name, $attrs, $props) { if ($open) { return "\\fB" . $this->autogen($name, $props["lang"]) . "\\fP"; } return ""; } public function format_pubdate_text($value, $tag) { $this->date = $value; return false; } } /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 */ PhD_Generic-1.1.6/phpdotnet/phd/Package/Generic/PDF.php000644 000000 000000 00000126723 11767147642 020637 0ustar00000000 000000 'format_suppressed_tags', 'abbrev' => 'format_suppressed_tags', 'acronym' => 'format_suppressed_tags', 'alt' => 'format_suppressed_tags', 'application' => 'format_suppressed_tags', 'author' => array( /* DEFAULT */ 'format_newline', 'authorgroup' => 'format_authorgroup_author', ), 'authorgroup' => 'format_shifted_para', 'blockquote' => 'format_framed_block', 'book' => 'format_suppressed_tags', 'callout' => 'format_callout', 'calloutlist' => 'format_calloutlist', 'caution' => 'format_admonition', 'citerefentry' => 'format_suppressed_tags', 'classname' => array( /* DEFAULT */ 'format_suppressed_tags', 'ooclass' => array( /* DEFAULT */ 'format_bold', 'classsynopsisinfo' => 'format_suppressed_tags', ), ), 'co' => 'format_co', 'command' => 'format_italic', 'computeroutput' => 'format_suppressed_tags', 'constant' => 'format_bold', 'code' => 'format_verbatim_inline', 'copyright' => 'format_copyright', 'editor' => 'format_editor', 'example' => 'format_example', 'emphasis' => 'format_italic', 'envar' => 'format_suppressed_tags', 'errortype' => 'format_suppressed_tags', 'figure' => 'format_suppressed_tags', 'filename' => 'format_italic', 'firstname' => 'format_suppressed_tags', 'formalpara' => 'format_para', 'footnote' => 'format_footnote', 'footnoteref' => 'format_footnoteref', 'funcdef' => 'format_bold', 'function' => 'format_suppressed_tags', 'glossterm' => 'format_suppressed_tags', 'holder' => 'format_suppressed_tags', 'imagedata' => 'format_imagedata', 'imageobject' => 'format_shifted_para', 'index' => 'format_para', 'indexdiv' => 'format_para', 'indexentry' => 'format_shifted_line', 'info' => 'format_suppressed_tags', 'informalexample' => 'format_para', 'itemizedlist' => 'format_shifted_para', 'legalnotice' => 'format_suppressed_tags', 'link' => 'format_link', 'listitem' => array( /* DEFAULT */ 'format_listitem', 'varlistentry' => 'format_shifted_para', ), 'literal' => 'format_italic', 'literallayout' => 'format_verbatim_inline', 'manvolnum' => 'format_manvolnum', 'mediaobject' => 'format_suppressed_tags', 'member' => 'format_member', 'note' => 'format_admonition', 'option' => 'format_italic', 'optional' => 'format_suppressed_tags', 'orderedlist' => 'format_shifted_para', 'othercredit' => 'format_newline', 'othername' => 'format_suppressed_tags', 'para' => array( /* DEFAULT */ 'format_para', 'callout' => 'format_suppressed_tags', 'listitem' => 'format_suppressed_tags', 'step' => 'format_suppressed_tags', ), 'partintro' => 'format_para', 'personname' => 'format_suppressed_tags', 'preface' => 'format_suppressed_tags', 'primaryie' => 'format_suppressed_tags', 'procedure' => 'format_procedure', 'productname' => 'format_suppressed_tags', 'programlisting' => 'format_verbatim_block', 'property' => array( /* DEFAULT */ 'format_suppressed_tags', 'classsynopsisinfo' => 'format_italic', ), 'pubdate' => 'format_para', 'quote' => 'format_suppressed_tags', 'refentrytitle' => 'format_bold', 'refname' => 'format_title', 'refnamediv' => 'format_suppressed_tags', 'refpurpose' => 'format_refpurpose', 'refsect1' => 'format_suppressed_tags', 'refsection' => 'format_refsection', // DUMMY REFSECTION DELETION 'refsynopsisdiv' => 'format_para', 'replaceable' => 'format_italic', 'screen' => 'format_verbatim_block', 'section' => 'format_suppressed_tags', 'sect1' => 'format_suppressed_tags', 'sect2' => 'format_suppressed_tags', 'sect3' => 'format_suppressed_tags', 'sect4' => 'format_suppressed_tags', 'sect5' => 'format_suppressed_tags', 'seg' => 'format_seg', 'segmentedlist' => 'format_segmentedlist', 'seglistitem' => 'format_seglistitem', 'segtitle' => 'format_suppressed_tags', 'set' => 'format_suppressed_tags', 'simpara' => array( /* DEFAULT */ 'format_para', 'callout' => 'format_suppressed_tags', 'listitem' => 'format_suppressed_tags', 'step' => 'format_suppressed_tags', ), 'simplelist' => 'format_shifted_para', 'simplesect' => 'format_suppressed_tags', 'step' => 'format_suppressed_tags', 'subscript' => 'format_indice', 'superscript' => 'format_indice', 'surname' => 'format_suppressed_tags', 'synopsis' => 'format_verbatim_block', 'systemitem' => 'format_verbatim_inline', 'tag' => 'format_verbatim_inline', 'term' => 'format_suppressed_tags', 'title' => array( /* DEFAULT */ 'format_title', 'example' => 'format_example_title', 'formalpara' => 'format_title3', 'info' => array( /* DEFAULT */ 'format_title', 'example' => 'format_example_title', 'note' => 'format_title3', 'table' => 'format_title3', 'informaltable' => 'format_title3', 'warning' => 'format_title3', ), 'informaltable' => 'format_title3', 'legalnotice' => 'format_title2', 'note' => 'format_title3', 'preface' => 'format_title', 'procedure' => 'format_bold', 'refsect1' => 'format_title2', 'refsect2' => 'format_title3', 'refsect3' => 'format_title3', 'section' => 'format_title2', 'sect1' => 'format_title2', 'sect2' => 'format_title3', 'sect3' => 'format_title3', 'sect4' => 'format_title3', 'segmentedlist' => 'format_bold', 'table' => 'format_title3', 'variablelist' => 'format_bold', 'warning' => 'format_title3', ), 'tip' => 'format_admonition', 'titleabbrev' => 'format_suppressed_tags', 'type' => 'format_suppressed_tags', 'userinput' => 'format_bold', 'variablelist' => 'format_suppressed_tags', /* hack for phpdoc:varentry */ 'phpdoc:varentry' => 'format_suppressed_tags', 'varlistentry' => 'format_newline', 'varname' => 'format_italic', 'warning' => 'format_admonition', 'xref' => 'format_link', 'year' => 'format_suppressed_tags', // TABLES 'informaltable' => 'format_table', 'table' => 'format_table', 'tgroup' => 'format_tgroup', 'colspec' => 'format_colspec', 'spanspec' => 'format_suppressed_tags', 'thead' => 'format_thead', 'tbody' => 'format_suppressed_tags', 'row' => 'format_row', 'entry' => array ( /* DEFAULT */ 'format_entry', 'row' => array( /* DEFAULT */ 'format_entry', 'thead' => 'format_th_entry', 'tfoot' => 'format_th_entry', 'tbody' => 'format_entry', ), ), // SYNOPSISES & OO STUFF 'void' => 'format_void', 'methodname' => 'format_bold', 'methodparam' => 'format_methodparam', 'methodsynopsis' => 'format_methodsynopsis', 'parameter' => array( /* DEFAULT */ 'format_parameter', 'methodparam' => 'format_methodparam_parameter', ), 'interfacename' => 'format_suppressed_tags', 'ooclass' => array( /* DEFAULT */ 'format_suppressed_tags', 'classsynopsis' => 'format_framed_para', ), 'oointerface' => array( /* DEFAULT */ 'format_suppressed_tags', 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface', ), 'classsynopsis' => 'format_classsynopsis', 'classsynopsisinfo' => 'format_classsynopsisinfo', 'fieldsynopsis' => array( /* DEFAULT */ 'format_fieldsynopsis', 'entry' => 'format_para', ), 'modifier' => 'format_suppressed_tags', 'constructorsynopsis' => 'format_methodsynopsis', 'destructorsynopsis' => 'format_methodsynopsis', 'initializer' => 'format_initializer', // FAQ 'qandaset' => 'format_para', 'qandaentry' => 'format_para', 'question' => 'format_bold', 'answer' => 'format_shifted_para', ); /* }}} */ private $textmap = array( 'function' => 'format_function_text', 'link' => 'format_link_text', 'quote' => 'format_quote_text', 'refname' => 'format_refname_text', 'titleabbrev' => 'format_suppressed_text', 'segtitle' => 'format_segtitle_text', 'modifier' => array( /* DEFAULT */ false, 'fieldsynopsis' => 'format_fieldsynopsis_modifier_text', ), 'methodname' => array( /* DEFAULT */ false, 'constructorsynopsis' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'methodsynopsis' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'destructorsynopsis' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), ), ); protected $lang = ""; /* Current Chunk variables */ private $cchunk = array(); /* Default Chunk variables */ private $dchunk = array( "xml-base" => "", "refsection" => false, "examplenumber" => 0, "href" => "", "is-xref" => false, "linkend" => "", "links-to-resolve" => array( /* $id => array( $target ), */ ), "refname" => "", "table" => false, "verbatim-block" => false, "segmentedlist" => array( "seglistitem" => 0, "segtitle" => array( ), ), "classsynopsis" => array( "close" => false, "classname" => false, ), "classsynopsisinfo" => array( "implements" => false, "ooclass" => false, ), "fieldsynopsis" => array( "modifier" => "public", ), "footnote" => array( ), "tablefootnotes" => array( ), "footrefs" => array(), "co" => 0, "corefs" => array(), "callouts" => 0, ); public function __construct() { parent::__construct(); $this->setExt(Config::ext() === null ? ".pdf" : Config::ext()); $this->pdfDoc = new PdfWriter(); } public function __destruct() { unset($this->pdfDoc); } public function getChunkInfo($info) { if (isset($this->cchunk[$info])) return $this->cchunk[$info]; else return null; } public function setChunkInfo($info, $value) { $this->cchunk[$info] = $value; } public function getDefaultChunkInfo() { return $this->dchunk; } public function getDefaultElementmap() { return $this->elementmap; } public function getDefaultTextmap() { return $this->textmap; } public function TEXT($str) { if (isset($this->cchunk["refsection"]) && $this->cchunk["refsection"]) // DUMMY REFSECTION DELETION return ""; if (isset($this->cchunk["verbatim-block"]) && $this->cchunk["verbatim-block"]) { $this->pdfDoc->appendText(utf8_decode($str)); return ""; } $ret = utf8_decode(trim(preg_replace('/[ \n\t]+/', ' ', $str))); // No whitespace if current text value begins with ',', ';', ':', '.' if (strncmp($ret, ",", 1) && strncmp($ret, ";", 1) && strncmp($ret, ":", 1) && strncmp($ret, ".", 1)) $this->pdfDoc->appendText(" " . $ret); else $this->pdfDoc->appendText($ret); return ""; } public function format_suppressed_tags($open, $name) { /* Ignore it */ return ""; } public function format_suppressed_text($value, $tag) { /* Suppress any content */ return ""; } public function newChunk() { $this->cchunk = $this->dchunk; } // DUMMY REFSECTION DELETION public function format_refsection($open, $name, $attrs, $props) { if ($open) { $this->cchunk["refsection"] = true; } else { $this->cchunk["refsection"] = false; } return ""; } public function format_para($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::PARA); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); } return ""; } public function format_shifted_para($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->shift(); $this->pdfDoc->add(PdfWriter::PARA); } else { $this->pdfDoc->unshift(); $this->pdfDoc->add(PdfWriter::LINE_JUMP); } return ""; } public function format_shifted_line($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->shift(); $this->pdfDoc->add(PdfWriter::LINE_JUMP); } else { $this->pdfDoc->unshift(); } return ""; } public function format_title($open, $name, $attrs, $props) { if ($props["empty"]) return ''; if ($open) { $this->pdfDoc->add(PdfWriter::TITLE); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->revertFont(); } return ""; } public function format_title2($open, $name, $attrs, $props) { if ($props["empty"]) return ''; if ($open) { $this->pdfDoc->add(PdfWriter::TITLE2); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->revertFont(); } return ""; } public function format_title3($open, $name, $attrs, $props) { if ($props["empty"]) return ''; if ($open) { $this->pdfDoc->add(PdfWriter::TITLE3); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->revertFont(); } return ""; } public function format_bold($open, $name, $attrs, $props) { if ($props["empty"]) return ''; if ($open) { $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); } else { $this->pdfDoc->revertFont(); } return ""; } public function format_italic($open, $name, $attrs, $props) { if ($props["empty"]) return ''; if ($open) { $this->pdfDoc->setFont(PdfWriter::FONT_ITALIC); } else { $this->pdfDoc->revertFont(); } return ""; } public function format_admonition($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::ADMONITION); $this->pdfDoc->appendText($this->autogen($name, $props["lang"])); $this->pdfDoc->add(PdfWriter::ADMONITION_CONTENT); } else { $this->pdfDoc->add(PdfWriter::END_ADMONITION); } return ""; } public function format_example($open, $name, $attrs, $props) { if ($open) { $this->lang = $props["lang"]; $this->cchunk["examplenumber"]++; $this->pdfDoc->add(PdfWriter::ADMONITION); } else { $this->pdfDoc->add(PdfWriter::END_ADMONITION); } return ""; } public function format_example_title($open, $name, $attrs, $props) { if ($props["empty"]) { $this->pdfDoc->appendText($this->autogen("example", $this->lang) . $this->cchunk["examplenumber"]); $this->pdfDoc->add(PdfWriter::ADMONITION_CONTENT); } elseif ($open) { $this->pdfDoc->appendText($this->autogen("example", $this->lang) . $this->cchunk["examplenumber"] . " -"); } else { $this->pdfDoc->add(PdfWriter::ADMONITION_CONTENT); } return ""; } public function format_newpage($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::PAGE); } return ""; } public function format_verbatim_block($open, $name, $attrs, $props) { if ($open) { $this->cchunk["verbatim-block"] = true; $this->pdfDoc->add(PdfWriter::VERBATIM_BLOCK); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->revertFont(); $this->cchunk["verbatim-block"] = false; } return ""; } public function format_verbatim_inline($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 10); } else { $this->pdfDoc->revertFont(); } return ""; } public function format_framed_block($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); } else { $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK); } return ""; } public function format_framed_para($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); $this->format_para($open, $name, $attrs, $props); } else { $this->format_para($open, $name, $attrs, $props); $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK); } return ""; } public function format_newline($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::LINE_JUMP); } } public function format_link($open, $name, $attrs, $props) { if ($open && ! $props["empty"]) { $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0, 0, 1)); // blue if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"])) { $this->cchunk["linkend"] = $attrs[Reader::XMLNS_DOCBOOK]["linkend"]; } elseif(isset($attrs[Reader::XMLNS_XLINK]["href"])) { $this->cchunk["href"] = $attrs[Reader::XMLNS_XLINK]["href"]; } } elseif ($open && $name == "xref" && isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"]) && $linkend = $attrs[Reader::XMLNS_DOCBOOK]["linkend"]) { $this->cchunk["linkend"] = $linkend; $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0, 0, 1)); // blue $this->format_link_text(Format::getShortDescription($linkend), $name); $this->pdfDoc->revertFont(); $this->cchunk["linkend"] = ""; } elseif (!$open) { $this->cchunk["href"] = ""; $this->cchunk["linkend"] = ""; $this->pdfDoc->revertFont(); } return ""; } public function format_link_text($value, $tag) { $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); if (isset($this->cchunk["href"]) && $this->cchunk["href"]) { $this->pdfDoc->add(PdfWriter::URL_ANNOTATION, array(chr(187) . chr(160) . $value, $this->cchunk["href"])); // links with >> symbol } elseif (isset($this->cchunk["linkend"]) && $linkend = $this->cchunk["linkend"]) { $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, $value); if (!isset($this->cchunk["links-to-resolve"][$linkend])) $this->cchunk["links-to-resolve"][$linkend] = array(); foreach ($linkAreas as $area) $this->cchunk["links-to-resolve"][$linkend][] = $area; } return ""; } public function format_function_text($value, $tag, $display_value = null) { $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); if ($display_value === null) { $display_value = $value; } $ref = strtolower(str_replace(array("_", "::", "->"), array("-", "-", "-"), $value)); if (($linkend = $this->getRefnameLink($ref)) !== null) { $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0, 0, 1)); // blue $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, $display_value.($tag == "function" ? "()" : "")); if (!isset($this->cchunk["links-to-resolve"][$linkend])) $this->cchunk["links-to-resolve"][$linkend] = array(); foreach ($linkAreas as $area) $this->cchunk["links-to-resolve"][$linkend][] = $area; } else { $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); $this->pdfDoc->appendText(" " . $display_value.($tag == "function" ? "()" : "")); } $this->pdfDoc->revertFont(); return ""; } public function format_authorgroup_author($open, $name, $attrs, $props) { if ($open) { if ($props["sibling"] !== $name) { $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); $this->pdfDoc->appendText($this->autogen("by", $props["lang"])); $this->pdfDoc->revertFont(); } $this->pdfDoc->add(PdfWriter::LINE_JUMP); } return ""; } public function format_editor($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); $this->pdfDoc->appendText($this->autogen("editedby", $props["lang"])); $this->pdfDoc->revertFont(); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); } return ""; } public function format_copyright($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::PARA); $this->pdfDoc->appendText(utf8_decode("©")); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); } return ""; } // Lists {{{ public function format_listitem($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->add(PdfWriter::ADD_BULLET); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP, 0.5); } return ""; } public function format_procedure($open, $name, $attrs, $props) { $this->cchunk["step"] = 0; return $this->format_shifted_para($open, $name, $attrs, $props); } public function format_step($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->add(PdfWriter::ADD_NUMBER_ITEM, (++$this->cchunk["step"])."."); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP, 0.5); } return ""; } public function format_member($open, $name, $attrs, $props) { if ($open) { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->add(PdfWriter::ADD_BULLET); } return ""; } public function format_segmentedlist($open, $name, $attrs, $props) { $this->cchunk["segmentedlist"] = $this->dchunk["segmentedlist"]; return $this->format_para($open, $name, $attrs, $props); } public function format_segtitle_text($value, $tag) { $this->cchunk["segmentedlist"]["segtitle"][count($this->cchunk["segmentedlist"]["segtitle"])] = $value; return ''; } public function format_seglistitem($open, $name, $attrs) { if ($open) { $this->cchunk["segmentedlist"]["seglistitem"] = 0; } return ''; } public function format_seg($open, $name, $attrs) { if ($open) { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); $this->pdfDoc->appendText($this->cchunk["segmentedlist"]["segtitle"][$this->cchunk["segmentedlist"]["seglistitem"]++].":"); $this->pdfDoc->revertFont(); } return ''; } // }}} Lists // Tables {{{ public function format_table($open, $name, $attrs, $props) { if ($open) { $this->cchunk["table"] = true; $this->pdfDoc->add(PdfWriter::PARA); } else { $this->cchunk["table"] = false; $this->pdfDoc->add(PdfWriter::END_TABLE); if ($this->cchunk["tablefootnotes"]) { $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->pdfDoc->appendBufferNow(); foreach ($this->cchunk["footrefs"] as $ref) foreach ($ref as $area) $this->pdfDoc->resolveInternalLink($area[0], array($area[1], $area[2], $area[3], $area[4]), $this->pdfDoc->getCurrentPage()); $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK, array(2)); // With Dash line $this->cchunk["tablefootnotes"] = $this->dchunk["tablefootnotes"]; } } return ""; } public function format_colspec($open, $name, $attrs) { if ($open) { Format::colspec($attrs[Reader::XMLNS_DOCBOOK]); } return ""; } public function format_thead($open, $name, $attrs) { if ($open) { $this->pdfDoc->setFont(PdfWriter::FONT_BOLD); } else { $this->pdfDoc->revertFont(); } return ""; } public function format_row($open, $name, $attrs) { if ($open) { Format::initRow(); $valign = isset($attrs[Reader::XMLNS_DOCBOOK]['valign']) ? $attrs[Reader::XMLNS_DOCBOOK]['valign'] : 'middle'; $colCount = Format::getColCount(); $this->pdfDoc->add(PdfWriter::TABLE_ROW, array($colCount, $valign)); } else { $this->pdfDoc->add(PdfWriter::TABLE_END_ROW); } return ""; } public function format_th_entry($open, $name, $attrs, $props) { $align = (isset($attrs["align"]) ? $attrs["align"] : "center"); if ($props["empty"]) { $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array(1, 1, $align)); $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); } if ($open) { $dbattrs = Format::getColspec($attrs[Reader::XMLNS_DOCBOOK]); $align = (isset($dbattrs["align"]) ? $dbattrs["align"] : $align); $colspan = Format::colspan($attrs[Reader::XMLNS_DOCBOOK]); $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array($colspan, 1, $align)); } else { $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); } return ""; } public function format_entry($open, $name, $attrs, $props) { $align = (isset($attrs["align"]) ? $attrs["align"] : "left"); if ($props["empty"]) { $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array(1, 1, $align)); $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); return; } if ($open) { $dbattrs = Format::getColspec($attrs[Reader::XMLNS_DOCBOOK]); $align = (isset($dbattrs["align"]) ? $dbattrs["align"] : $align); $retval = ""; if (isset($dbattrs["colname"])) { for($i=Format::getEntryOffset($dbattrs); $i>0; --$i) { $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array(1, 1, $align)); $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); } } /* * "colspan" is *not* an standard prop, only used to overwrite the * colspan for s in tables */ if (isset($props["colspan"])) { $colspan = $props["colspan"]; } else { $colspan = Format::colspan($dbattrs); } $rowspan = Format::rowspan($dbattrs); $this->pdfDoc->add(PdfWriter::TABLE_ENTRY, array($colspan, $rowspan, $align)); } else { $this->pdfDoc->add(PdfWriter::TABLE_END_ENTRY); } return ""; } public function format_tgroup($open, $name, $attrs, $props) { if ($open) { Format::tgroup($attrs[Reader::XMLNS_DOCBOOK]); if (isset($attrs[Reader::XMLNS_DOCBOOK]["cols"])) $this->pdfDoc->add(PdfWriter::TABLE, $attrs[Reader::XMLNS_DOCBOOK]["cols"]); } else { } return ""; } // }}} Tables // Synopsises {{{ public function format_methodsynopsis($open, $name, $attrs, $props) { if ($open) { $this->params = array("count" => 0, "opt" => 0, "content" => ""); return $this->format_para($open, $name, $attrs, $props); } $content = ""; if ($this->params["opt"]) { $content = str_repeat(" ]", $this->params["opt"]); } $content .= " )"; $this->pdfDoc->appendText($content); return $this->format_para($open, $name, $attrs, $props); } public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) { $value = $this->TEXT($value); if ($this->cchunk["classsynopsis"]["classname"] === false) { $this->pdfDoc->appendText($value); return ''; } if (strpos($value, '::')) { $explode = '::'; } elseif (strpos($value, '->')) { $explode = '->'; } else { $this->pdfDoc->appendText($value); return ''; } list($class, $method) = explode($explode, $value); if ($class !== $this->cchunk["classsynopsis"]["classname"]) { $this->pdfDoc->appendText($value); return ''; } $this->pdfDoc->appendText($method); return ''; } public function format_methodparam_parameter($open, $name, $attrs, $props) { if ($props["empty"]) return ''; if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 10); $this->pdfDoc->appendText(" &$"); return ''; } $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 10); $this->pdfDoc->appendText(" $"); return ''; } $this->pdfDoc->revertFont(); return ''; } public function format_parameter($open, $name, $attrs, $props) { if ($props["empty"]) return ''; if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM_ITALIC, 10); $this->pdfDoc->appendText(" &"); return ''; } $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM_ITALIC, 10); return ''; } $this->pdfDoc->revertFont(); return ''; } public function format_methodparam($open, $name, $attrs) { if ($open) { $content = ''; if ($this->params["count"] == 0) { $content .= " ("; } if (isset($attrs[Reader::XMLNS_DOCBOOK]["choice"]) && $attrs[Reader::XMLNS_DOCBOOK]["choice"] == "opt") { $this->params["opt"]++; $content .= " ["; } else if($this->params["opt"]) { $content .= str_repeat(" ]", $this->params["opt"]); $this->params["opt"] = 0; } if ($this->params["count"]) { $content .= ","; } $content .= ''; ++$this->params["count"]; $this->pdfDoc->appendText($content); return ''; } return ''; } public function format_void($open, $name, $attrs) { $this->pdfDoc->appendText(" ( void"); return ''; } public function format_classsynopsisinfo($open, $name, $attrs, $props) { $this->cchunk["classsynopsisinfo"] = $this->dchunk["classsynopsisinfo"]; if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { $this->format_para($open, $name, $attrs, $props); $this->pdfDoc->appendText("/* "); return ''; } return $this->format_para($open, $name, $attrs, $props); } if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { $this->pdfDoc->appendText(" */"); return $this->format_para($open, $name, $attrs, $props); } $this->cchunk["classsynopsis"]["close"] = true; $this->pdfDoc->appendText(" {"); $this->pdfDoc->shift(); return $this->format_para($open, $name, $attrs, $props); } public function format_classsynopsisinfo_oointerface($open, $name, $attrs) { if ($open) { if ($this->cchunk["classsynopsisinfo"]["implements"] === false) { $this->cchunk["classsynopsisinfo"]["implements"] = true; $this->pdfDoc->appendText(" implements"); return ''; } $this->pdfDoc->appendText(","); return ''; } return ''; } public function format_classsynopsis($open, $name, $attrs, $props) { if ($open) { return $this->format_para($open, $name, $attrs, $props); } if ($this->cchunk["classsynopsis"]["close"] === true) { $this->cchunk["classsynopsis"]["close"] = false; $this->pdfDoc->unshift(); $this->pdfDoc->appendText("}"); } return $this->format_para($open, $name, $attrs, $props); } public function format_fieldsynopsis_modifier_text($value, $tag) { $this->cchunk["fieldsynopsis"]["modifier"] = trim($value); $this->pdfDoc->appendText($this->TEXT($value)); return ''; } public function format_fieldsynopsis($open, $name, $attrs, $props) { $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"]; if ($open) { return $this->format_para($open, $name, $attrs, $props); } $this->pdfDoc->appendText(";"); return $this->format_para($open, $name, $attrs, $props); } public function format_initializer($open, $name, $attrs) { if ($open) { $this->pdfDoc->appendText(" = "); } return ''; } // }}} Synopsises // Footnotes & Callouts {{{ public function format_footnoteref($open, $name, $attrs, $props) { if ($open) { $linkend = $attrs[Reader::XMLNS_DOCBOOK]["linkend"]; $found = false; foreach($this->cchunk["footnote"] as $k => $note) { if ($note["id"] === $linkend) { $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0,0,1)); $this->cchunk["footrefs"][] = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[".($k + 1)."]"); $this->pdfDoc->revertFont(); } } return ''; } } public function format_footnote($open, $name, $attrs, $props) { if ($open) { $count = count($this->cchunk["footnote"]); $noteid = isset($attrs[Reader::XMLNS_XML]["id"]) ? $attrs[Reader::XMLNS_XML]["id"] : $count + 1; $note = array("id" => $noteid, "str" => ""); $this->cchunk["footnote"][$count] = $note; if ($this->cchunk["table"]) { $this->cchunk["tablefootnotes"][$count] = $noteid; } $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0,0,1)); $this->cchunk["footrefs"][] = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[".($count + 1)."]"); $this->pdfDoc->revertFont(); $this->pdfDoc->setAppendToBuffer(true); $this->pdfDoc->setFont(PdfWriter::FONT_BOLD, 12, array(0,0,1)); $this->pdfDoc->appendText("[".($count + 1)."]"); $this->pdfDoc->revertFont(); return ""; } $this->pdfDoc->appendText("\n"); $this->pdfDoc->setAppendToBuffer(false); return ""; } public function format_co($open, $name, $attrs, $props) { if (($open || $props["empty"]) && isset($attrs[Reader::XMLNS_XML]["id"]) && $id = $attrs[Reader::XMLNS_XML]["id"]) { $co = ++$this->cchunk["co"]; $this->pdfDoc->setFont(PdfWriter::FONT_NORMAL, 12, array(0,0,1)); if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkends"]) && $linkends = $attrs[Reader::XMLNS_DOCBOOK]["linkends"]) { $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[{$co}]"); if (!isset($this->cchunk["links-to-resolve"][$linkends])) $this->cchunk["links-to-resolve"][$linkends] = array(); foreach ($linkAreas as $area) $this->cchunk["links-to-resolve"][$linkends][] = $area; } $this->pdfDoc->revertFont(); } return ""; } public function format_calloutlist($open, $name, $attrs) { if ($open) { $this->pdfDoc->add(PdfWriter::FRAMED_BLOCK); $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->cchunk["co"] = 0; } else { $this->pdfDoc->add(PdfWriter::END_FRAMED_BLOCK, array(2)); // With Dash line $this->cchunk["co"] = 0; } return ''; } public function format_callout($open, $name, $attrs) { if ($open) { $co = ++$this->cchunk["co"]; $this->pdfDoc->setFont(PdfWriter::FONT_BOLD, 12, array(0,0,1)); if (isset($attrs[Reader::XMLNS_DOCBOOK]["arearefs"]) && $ref = $attrs[Reader::XMLNS_DOCBOOK]["arearefs"]) { $linkAreas = $this->pdfDoc->add(PdfWriter::LINK_ANNOTATION, "[{$co}]"); if (!isset($this->cchunk["links-to-resolve"][$ref])) $this->cchunk["links-to-resolve"][$ref] = array(); foreach ($linkAreas as $area) $this->cchunk["links-to-resolve"][$ref][] = $area; } $this->pdfDoc->revertFont(); } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); } return ''; } // }}} Footnotes & Callouts public function format_quote_text($value, $tag) { $value = trim(preg_replace('/[ \n\t]+/', ' ', $value)); $this->pdfDoc->appendText(' "'.$value.'"'); return ""; } public function format_refname_text($value, $tag) { $this->cchunk["refname"][] = $value; $this->pdfDoc->appendText(trim(preg_replace('/[ \n\t]+/', ' ', $value))); return ""; } public function format_refpurpose($open, $tag, $attrs, $props) { if ($props["empty"]) { $this->pdfDoc->add(PdfWriter::PARA); foreach($this->cchunk["refname"] as $refname) { $this->pdfDoc->appendText(" " . $refname . " --"); } $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->cchunk["refname"] = array(); } elseif ($open) { $this->pdfDoc->add(PdfWriter::PARA); foreach($this->cchunk["refname"] as $refname) { $this->pdfDoc->appendText(" " . $refname . " --"); } } else { $this->pdfDoc->add(PdfWriter::LINE_JUMP); $this->cchunk["refname"] = array(); } return ""; } public function format_manvolnum($open, $name, $attrs) { if ($open) { $this->pdfDoc->appendText(")"); return ''; } $this->pdfDoc->appendText(")"); return ''; return ")"; } public function format_indice($open, $name, $attrs) { if (($open && $name == "subscript") || (!$open && $name == "superscript")) { $this->pdfDoc->vOffset("-4"); return ''; } $this->pdfDoc->vOffset("4"); return ''; } public function format_imagedata($open, $name, $attrs, $props) { if ($props["empty"] && isset($this->cchunk["xml-base"]) && ($base = $this->cchunk["xml-base"]) && isset($attrs[Reader::XMLNS_DOCBOOK]["fileref"]) && ($fileref = $attrs[Reader::XMLNS_DOCBOOK]["fileref"])) { $imagePath = Config::xml_root() . DIRECTORY_SEPARATOR . $base . $fileref; if (file_exists($imagePath)) $this->pdfDoc->add(PdfWriter::IMAGE, $imagePath); } return ''; } } /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 */ PhD_Generic-1.1.6/phpdotnet/phd/Package/Generic/BigXHTML.php000644 000000 000000 00000006774 11767147642 021547 0ustar00000000 000000 registerFormatName("Big-XHTML"); $this->setTitle("Index"); $this->setChunked(false); } public function __destruct() { $this->close(); } public function appendData($data) { if ($this->appendToBuffer) { $this->buffer .= $data; return; } if ($this->flags & Render::CLOSE) { fwrite($this->getFileStream(), $data); /* Append footer */ fwrite($this->getFileStream(), $this->footer()); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { fwrite($this->getFileStream(), "\n".$data); $this->flags ^= Render::OPEN; } else { fwrite($this->getFileStream(), $data); } } public function header() { $root = Format::getRootIndex(); $style = $this->createCSSLinks(); return <<
{$root["ldesc"]} {$style} HEADER; } public function footer($eof = false) { return !$eof ? "\n
\n" : "\n"; } public function close() { if ($this->getFileStream()) { fwrite($this->getFileStream(), $this->footer(true)); fclose($this->getFileStream()); } } 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->getFileStream())) { $filename = Config::output_dir(); if (Config::output_filename()) { $filename .= Config::output_filename(); } else { $filename .= strtolower($this->getFormatName()) . $this->getExt(); } $this->postConstruct(); if (Config::css()) { $this->fetchStylesheet(); } $this->setFileStream(fopen($filename, "w+")); fwrite($this->getFileStream(), $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; } } /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 */ PhD_Generic-1.1.6/phpdotnet/phd/Package/Generic/ChunkedXHTML.php000644 000000 000000 00000015673 11767147642 022425 0ustar00000000 000000 registerFormatName("Chunked-XHTML"); $this->setTitle("Index"); $this->setChunked(true); } public function __destruct() { $this->close(); } public function appendData($data) { if ($this->appendToBuffer) { $this->buffer .= $data; return; } elseif ($this->flags & Render::CLOSE) { $fp = $this->popFileStream(); fwrite($fp, $data); $this->writeChunk($this->CURRENT_CHUNK, $fp); fclose($fp); $this->flags ^= Render::CLOSE; } elseif ($this->flags & Render::OPEN) { $fp = fopen("php://temp/maxmemory", "r+"); fwrite($fp, $data); $this->pushFileStream($fp); $this->flags ^= Render::OPEN; } else { $fp = $this->getFileStream(); fwrite(end($fp), $data); } } public function writeChunk($id, $fp) { $filename = $this->getOutputDir() . Format::getFilename($id) . $this->getExt(); 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->getFileStream() 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: if ($this->appendToBuffer) { return; //Don't create output dir when rendering to buffer } $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . '/'); $this->postConstruct(); if (file_exists($this->getOutputDir())) { if (!is_dir($this->getOutputDir())) { v("Output directory is a file?", E_USER_ERROR); } } else { if (!mkdir($this->getOutputDir(), 0777, true)) { v("Can't create output directory", E_USER_ERROR); } } if (Config::css()) { $this->fetchStylesheet(); } 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(); $root = Format::getRootIndex(); static $cssLinks = null; if ($cssLinks === null) { $cssLinks = $this->createCSSLinks(); } $prev = $next = $parent = array("href" => null, "desc" => null); if ($parentId = $this->getParent($id)) { $parent = array("href" => $this->getFilename($parentId) . $this->getExt(), "desc" => $this->getShortDescription($parentId)); } if ($prevId = Format::getPrevious($id)) { $prev = array("href" => Format::getFilename($prevId) . $this->getExt(), "desc" => $this->getShortDescription($prevId)); } if ($nextId = Format::getNext($id)) { $next = array("href" => Format::getFilename($nextId) . $this->getExt(), "desc" => $this->getShortDescription($nextId)); } $navBar = $this->createNavBar($id); return ' '.(($title != $root["ldesc"]) ? $root["ldesc"].': ' : "").$title.' '.$cssLinks.' \n \n
'.$navBar.'
'.($prevId ? '' : '') .' '.($nextId ? '' : '') .' '.($parentId ? '' : '') .'

'; } public function footer($id) { return "\n
\n\n\n"; } protected function createNavBar($id) { $root = Format::getRootIndex(); $navBar = ' \n"; } } /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 */ PhD_Generic-1.1.6/phpdotnet/phd/Package/Generic/TocFeed.php000644 000000 000000 00000031551 11767147642 021531 0ustar00000000 000000 * @license http://www.opensource.org/licenses/bsd-license.php BSD Style * @link https://doc.php.net/phd/ */ abstract class Package_Generic_TocFeed extends Format { /** * Mapping of docbook tags to class methods * * @var array */ private $myelementmap = array( 'article' => 'format_chunk', 'appendix' => 'format_chunk', 'bibliography' => 'format_chunk', 'book' => 'format_chunk', 'chapter' => 'format_chunk', 'colophon' => 'format_chunk', 'glossary' => 'format_chunk', 'index' => 'format_chunk', 'legalnotice' => 'format_chunk', 'part' => 'format_chunk', 'preface' => 'format_chunk', 'refentry' => 'format_chunk', 'reference' => 'format_chunk', 'sect1' => 'format_chunk', 'section' => 'format_chunk', 'set' => 'format_chunk', 'setindex' => 'format_chunk', ); /** * We do not need any texts * * @var array */ private $mytextmap = array(); /** * Name of TOC feed format used by PhD internally. * * Inheriting classes should change this. * * @var string */ protected $formatName = 'TocFeed'; /** * File extension with leading dot for * links from atom feed to chunks. * * Inheriting classes should change this if neccessary. * * @var string * @usedby createTargetLink() */ protected $targetExt = '.htm'; /** * Base URI for links from atom feed to chunks (HTML files). * * Inheriting classes should change this if neccessary. * * @var string * @usedby createTargetLink() */ protected $targetBaseUri = null; /** * Base URI for the feed files themselves. * * Inheriting classes should change this if neccessary. * If this variable is not set, __construct() sets * it to $targetBaseUri * * @var string * @usedby createLink() */ protected $feedBaseUri = null; /** * Author string used in atom feed files. * * Inheriting classes should change this. * * @var string * @usedby header() */ protected $author = 'PhD - The PHP Docbook Renderer'; /** * Prefix for atom entry id values. * * Inheriting classes should change this. * * @internal * We are using tag URIs here. * @link http://www.faqs.org/rfcs/rfc4151.html * @link http://diveintomark.org/archives/2004/05/28/howto-atom-id * * And no, this date should never be changed. * * @var string */ protected $idprefix = 'tag:doc.php.net,2009-10-13:/phd/FIXME/'; /** * Date used in feed tags. * ISO 8601 format (2004-02-12T15:19:21+00:00) * * @internal * Set in __construct to be as fast as possible * and don't waste time on re-generating the same * data again and again. * * @var string */ protected $date = null; /** * Creates a new instance. */ public function __construct() { parent::__construct(); $this->registerFormatName($this->formatName); $this->setTitle('Index'); $this->setChunked(true); $this->setExt(Config::ext() === null ? ".atom" : Config::ext()); $this->date = date('c'); if ($this->feedBaseUri === null) { $this->feedBaseUri = $this->targetBaseUri; } } /** * Closes all open file pointers * * @return void */ public function __destruct() { $this->close(); } /** * Closes all open file streams * * @return void * * @uses getFileStream() */ public function close() { foreach ($this->getFileStream() as $fp) { fclose($fp); } } /** * Called by Format::notify(). * * Possible events: * - Render::STANDALONE * Always called with true as value from Render::attach() * Deprecated. * * - Render::INIT * Called from Render::execute() when rendering * is being started. Value is always true * * - Render::FINALIZE (from Render::execute()) * Called from Render::execute() when there is * nothing more to read in the XML file. * * - Render::VERBOSE * Called if the user specified the --verbose option * as commandline parameter. Called in render.php * * - Render::CHUNK * Called when a new chunk is opened or closed. * Value is either Render::OPEN or Render::CLOSE * * @param integer $event Event flag (see Render class) * @param mixed $val Additional value flag. Depends * on $event type * * @return void */ public function update($event, $val = null) { switch($event) { case Render::STANDALONE: if ($val) { $this->registerElementMap(static::getDefaultElementMap()); $this->registerTextMap(static::getDefaultTextMap()); } break; case Render::INIT: $this->setOutputDir( Config::output_dir() . strtolower($this->getFormatName()) . '/' ); $dir = $this->getOutputDir(); if (file_exists($dir)) { if (!is_dir($dir)) { v('Output directory is a file?', E_USER_ERROR); } } else { if (!mkdir($dir, 0777, true)) { v('Cannot create output directory', E_USER_ERROR); } } break; case Render::VERBOSE: v( 'Starting %s rendering', $this->getFormatName(), VERBOSE_FORMAT_RENDERING ); break; } } /** * Appends stringular data to the current file. * This method is controlled by the flags * in $this->flags. * * @param string $data Data to write into the file * * @return void */ public function appendData($data) { //we do not need this } /** * Writes a single chunk file. * * @param string $id XML Id. Used to determine filename, * header and footer * @param string $content XML Atom content to save * * @return boolean True if the file has been written, false if not. * * @uses Format::getFilename() * @uses header() * @uses footer() */ public function writeChunk($id, $content) { $filepart = $this->getFilename($id); if (!$filepart) { return false; } $filename = $this->getOutputDir() . $filepart . $this->getExt(); file_put_contents($filename, $this->header($id)); file_put_contents($filename, $content, FILE_APPEND); file_put_contents($filename, $this->footer($id), FILE_APPEND); return true; } /** * Format a chunked element * * @param boolean $open If the tag is opened or closed * @param string $name Name of the tag * @param array $attrs XML tag attributes * @param array $props FIXME * * @return string Atom feed entries representing the TOC * * @uses createAtomToc() */ public function format_chunk($open, $name, $attrs, $props) { if (!$open) { //$this->notify(Render::CHUNK, Render::CLOSE); return ''; } if (isset($attrs[Reader::XMLNS_PHD]['chunk']) && $attrs[Reader::XMLNS_PHD]['chunk'] == 'false' ) { //not chunked? no feed! return ''; } if (!isset($attrs[Reader::XMLNS_XML]['id'])) { //if we do not have a hard id, then // we cannot link to the file. // So without an id, there is no atom file return ''; } $id = $attrs[Reader::XMLNS_XML]['id']; $this->writeChunk( $id, $this->createAtomToc($id) ); //$this->notify(Render::CHUNK, Render::OPEN); return ''; } /** * Create a list of atom entries containing * the table of contents of the given $id. * * @param string $id Chunk ID to generate TOC for * * @return string String with XML data */ protected function createAtomToc($id) { $chunks = static::getChildren($id); if (count($chunks) == 0) { return ''; } $toc = ''; $date = $this->date; foreach ($chunks as $junk => $chunkid) { $long = $this->getLongDescription($chunkid); $short = $this->getShortDescription($chunkid); $id = $this->idprefix . $chunkid; if ($long && $short && $long != $short) { $title = $short . ' -- ' . $long; } else { $title = ($long ?: $short); } $link = $this->createTargetLink($chunkid); $toc .= << {$title} {$date} {$id} ATM; } return $toc; } /** * Create the file header. * * @param string $id XML ID of node being rendered. * * @return string Generated file header * * @usedby writeChunk() */ public function header($id) { $title = htmlspecialchars($this->getLongDescription($id)); $date = $this->date; $lang = Config::language(); $selflink = $this->createLink($id); $htmllink = $this->createTargetLink($id); $author = htmlspecialchars($this->author); $atomid = $this->idprefix . 'file/' . $id; return << {$title} {$date} {$atomid} PhD {$author} XML; } /** * Create the file footer. * * @param string $id XML ID of node being rendered. * * @return string Generated file footer * * @usedby writeChunk() */ public function footer($id) { return "\n"; } /** * Returns the element mapping array. * We use this method so child classes can easily overwrite it. * * @return array */ public function getDefaultElementMap() { return $this->myelementmap; } /** * Returns the text mapping array. * We use this method so child classes can easily overwrite it. * * @return array */ public function getDefaultTextMap() { return $this->mytextmap; } /* * Abstract methods inherited from Format */ public function transformFromMap($open, $tag, $name, $attrs, $props) { } public function UNDEF($open, $name, $attrs, $props) { } public function TEXT($value) { } public function CDATA($value) { } /** * Create full URL for Atom feed. * * Every class inheriting from this one should * to overwrite this method to return full absolute URIs, * or modify $targetBaseUri. * * @param string $id Chunk ID * @param string &$desc Description of link, to be filled if neccessary. * Not used here. * @param integer $type Format of description, Format::SDESC or * Format::LDESC. * Not used here. * * @return string Relative or absolute URI to access $for * * @uses $targetBaseUri */ public function createLink($id, &$desc = null, $type = Format::SDESC) { return $this->feedBaseUri . $id . $this->ext; } /** * Create external link from Atom feed to given chunk ID (HTML). * * Every class inheriting from this one should * to overwrite this method to return full absolute URIs, * or modify $targetBaseUri and $targetExt. * * @param string $id Chunk ID * * @return string Absolute URI to chunk * * @uses $targetBaseUri * @uses $targetExt */ public function createTargetLink($id) { return $this->targetBaseUri. $id . $this->targetExt; } } /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 */ PhD_Generic-1.1.6/phpdotnet/phd/Package/Generic/XHTML.php000644 000000 000000 00000177311 11767147642 021121 0ustar00000000 000000 'div', /* Docbook-xsl prints "abstract"... */ 'abbrev' => 'abbr', 'acronym' => 'acronym', 'affiliation' => 'format_suppressed_tags', 'alt' => 'format_suppressed_tags', 'arg' => 'format_suppressed_tags', 'article' => 'format_container_chunk_top', 'author' => array( /* DEFAULT */ 'format_author', 'authorgroup' => 'format_authorgroup_author', ), 'authorgroup' => 'div', 'authorinitials' => 'format_entry', 'appendix' => 'format_container_chunk_top', 'application' => 'span', 'blockquote' => 'blockquote', 'bibliography' => array( /* DEFAULT */ 'format_div', 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'book' => 'format_container_chunk_top', 'chapter' => 'format_container_chunk_top', 'citetitle' => 'em', 'cmdsynopsis' => 'format_cmdsynopsis', 'co' => 'format_co', 'colophon' => 'format_chunk', 'copyright' => 'format_copyright', 'date' => array( /* DEFAULT */ 'p', 'revision' => 'format_entry', ), 'editor' => 'format_editor', 'edition' => 'format_suppressed_tags', 'email' => 'format_suppressed_tags', 'errortext' => 'code', 'firstname' => 'format_name', 'footnote' => 'format_footnote', 'footnoteref' => 'format_footnoteref', 'funcdef' => 'format_suppressed_tags', 'funcsynopsis' => 'div', 'funcsynopsisinfo' => 'pre', 'function' => 'span', 'funcprototype' => 'code', 'surname' => 'format_name', 'othername' => 'format_name', 'optional' => 'span', 'honorific' => 'span', 'glossary' => array( /* DEFAULT */ 'format_div', 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'calloutlist' => 'format_calloutlist', 'callout' => 'format_callout', 'caution' => 'format_admonition', 'citation' => 'format_citation', 'citerefentry' => 'span', 'classname' => array( /* DEFAULT */ 'span', 'ooclass' => array( /* DEFAULT */ 'strong', 'classsynopsisinfo' => 'format_classsynopsisinfo_ooclass_classname', ), ), 'classsynopsis' => 'format_classsynopsis', 'classsynopsisinfo' => 'format_classsynopsisinfo', 'code' => 'code', 'collab' => 'span', 'collabname' => 'span', 'contrib' => 'format_suppressed_tags', 'colspec' => 'format_colspec', 'command' => 'strong', 'computeroutput' => 'span', /* FIXME: This is one crazy stupid workaround for footnotes */ 'constant' => array( /* DEFAULT */ 'format_constant', 'para' => array( /* DEFAULT */ 'format_constant', 'footnote' => 'format_footnote_constant', ), ), 'constructorsynopsis' => 'format_methodsynopsis', 'destructorsynopsis' => 'format_methodsynopsis', 'emphasis' => 'em', 'enumname' => 'span', 'entry' => array ( /* DEFAULT */ 'format_entry', 'row' => array( /* DEFAULT */ 'format_entry', 'thead' => 'format_th_entry', 'tfoot' => 'format_th_entry', 'tbody' => 'format_entry', ), ), 'envar' => 'span', 'errortype' => 'span', 'errorcode' => 'span', 'example' => 'format_example', 'formalpara' => 'p', 'fieldsynopsis' => array( /* DEFAULT */ 'format_fieldsynopsis', 'entry' => 'format_div', ), 'figure' => 'div', 'filename' => 'var', 'glossentry' => 'li', 'glossdef' => 'p', 'glosslist' => 'format_itemizedlist', 'glossterm' => 'span', 'holder' => 'span', 'imageobject' => 'format_div', 'imagedata' => 'format_imagedata', 'important' => 'format_admonition', 'index' => array( /* DEFAULT */ 'format_div', 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'info' => array( /* DEFAULT */ 'format_div', 'note' => 'span', ), 'informalexample' => 'format_div', 'informaltable' => 'format_table', 'indexdiv' => 'format_dl', 'indexentry' => 'dd', 'initializer' => 'format_initializer', 'itemizedlist' => 'format_itemizedlist', 'legalnotice' => 'format_chunk', 'listitem' => array( /* DEFAULT */ 'li', 'varlistentry' => 'format_varlistentry_listitem', ), 'literal' => 'format_literal', 'literallayout' => 'pre', 'link' => 'format_link', 'xref' => 'format_xref', 'manvolnum' => 'format_manvolnum', 'inlinemediaobject' => 'format_mediaobject', 'mediaobject' => 'format_mediaobject', 'methodparam' => 'format_methodparam', 'methodsynopsis' => 'format_methodsynopsis', 'methodname' => 'format_methodname', 'member' => 'li', 'modifier' => 'span', 'note' => 'format_note', 'orgname' => 'span', 'othercredit' => 'format_div', 'ooclass' => array( /* DEFAULT */ 'span', 'classsynopsis' => 'format_div', ), 'oointerface' => array( /* DEFAULT */ 'span', 'classsynopsisinfo' => 'format_classsynopsisinfo_oointerface', ), 'interfacename' => 'span', 'exceptionname' => 'span', 'option' => 'format_option', 'orderedlist' => 'format_orderedlist', 'para' => array( /* DEFAULT */ 'p', 'example' => 'format_example_content', 'footnote' => 'format_footnote_para', 'refsect1' => 'format_refsect1_para', 'question' => 'format_suppressed_tags', ), 'paramdef' => 'format_suppressed_tags', 'parameter' => array( /* DEFAULT */ 'format_parameter', 'methodparam' => 'format_methodparam_parameter', ), 'part' => 'format_container_chunk_top', 'partintro' => 'format_div', 'personname' => 'format_personname', 'personblurb' => 'format_div', 'phrase' => 'span', 'preface' => 'format_chunk', 'printhistory' => 'format_div', 'primaryie' => 'format_suppressed_tags', 'procedure' => 'format_procedure', 'productname' => 'span', 'programlisting' => 'format_programlisting', 'prompt' => 'span', 'propname' => 'span', 'property' => array( /* DEFAULT */ 'span', 'classsynopsisinfo' => 'format_varname', ), 'proptype' => 'span', 'pubdate' => 'format_div', /* Docbook-XSL prints "published" */ 'refentry' => 'format_chunk', 'refentrytitle' => 'span', 'refpurpose' => 'p', 'reference' => 'format_container_chunk_below', 'refsect1' => 'format_refsect', 'refsect2' => 'format_refsect', 'refsect3' => 'format_refsect', 'refsynopsisdiv' => 'div', 'refname' => 'h1', 'refnamediv' => 'div', 'releaseinfo' => 'div', 'replaceable' => 'span', 'revhistory' => 'format_table', 'revision' => 'format_row', 'revremark' => 'format_entry', 'row' => 'format_row', 'screen' => 'format_screen', 'screenshot' => 'format_div', 'sect1' => 'format_chunk', 'sect2' => 'div', 'sect3' => 'div', 'sect4' => 'div', 'sect5' => 'div', 'section' => array( /* DEFAULT */ 'div', 'sect1' => 'format_section_chunk', 'chapter' => 'format_section_chunk', 'appendix' => 'format_section_chunk', 'article' => 'format_section_chunk', 'part' => 'format_section_chunk', 'reference' => 'format_section_chunk', 'refentry' => 'format_section_chunk', 'index' => 'format_section_chunk', 'bibliography' => 'format_section_chunk', 'glossary' => 'format_section_chunk', 'colopone' => 'format_section_chunk', 'book' => 'format_section_chunk', 'set' => 'format_section_chunk', 'setindex' => 'format_section_chunk', 'legalnotice' => 'format_section_chunk', ), 'seg' => 'format_seg', 'segmentedlist' => 'format_segmentedlist', 'seglistitem' => 'format_seglistitem', 'segtitle' => 'format_suppressed_tags', 'set' => 'format_container_chunk_top', 'setindex' => 'format_chunk', 'shortaffil' => 'format_suppressed_tags', 'sidebar' => 'format_note', 'simplelist' => 'format_itemizedlist', /* FIXME: simplelists has few attributes that need to be implemented */ 'simplesect' => 'format_div', 'simpara' => array( /* DEFAULT */ 'p', 'note' => 'span', 'listitem' => 'span', 'entry' => 'span', 'example' => 'format_example_content', ), 'spanspec' => 'format_suppressed_tags', 'step' => 'format_step', 'superscript' => 'sup', 'subscript' => 'sub', 'systemitem' => 'format_systemitem', 'symbol' => 'span', 'synopsis' => 'pre', 'tag' => 'code', 'table' => 'format_table', 'firstterm' => 'format_term', 'term' => 'format_term', 'tfoot' => 'format_th', 'tbody' => 'format_tbody', 'td' => 'format_th', 'th' => 'format_th', 'thead' => 'format_th', 'tgroup' => 'format_tgroup', 'tip' => 'format_admonition', 'title' => array( /* DEFAULT */ 'h1', 'example' => 'format_example_title', 'formalpara' => 'h5', 'info' => array( /* DEFAULT */ 'h1', 'example' => 'format_example_title', 'note' => 'format_note_title', 'table' => 'format_table_title', 'informaltable' => 'format_table_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', ), 'indexdiv' => 'dt', 'legalnotice' => 'h4', 'note' => 'format_note_title', 'phd:toc' => 'strong', 'procedure' => 'strong', 'refsect1' => 'h3', 'refsect2' => 'h4', 'refsect3' => 'h5', 'section' => 'h2', 'sect1' => 'h2', 'sect2' => 'h3', 'sect3' => 'h4', 'sect4' => 'h5', 'segmentedlist' => 'strong', 'table' => 'format_table_title', 'variablelist' => 'strong', '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', ), 'titleabbrev' => 'format_suppressed_tags', 'token' => 'code', 'tr' => 'format_row', 'trademark' => 'format_trademark', 'type' => 'span', 'userinput' => 'format_userinput', 'uri' => 'code', 'variablelist' => 'format_variablelist', 'varlistentry' => 'format_varlistentry', 'varname' => array( /* DEFAULT */ 'var', 'fieldsynopsis' => 'format_fieldsynopsis_varname', ), 'void' => 'format_void', 'warning' => 'format_admonition', 'xref' => 'format_xref', 'year' => 'span', 'quote' => 'format_quote', 'qandaset' => 'format_qandaset', 'qandaentry' => 'dl', 'question' => array( /* DEFAULT */ 'format_question', 'questions' => 'format_phd_question', // From the PhD namespace ), 'questions' => 'ol', // From the PhD namespace 'answer' => 'dd', //phpdoc: implemented 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', 'edition' => 'format_suppressed_text', 'programlisting' => 'format_programlisting_text', 'screen' => 'format_screen_text', 'alt' => 'format_alt_text', 'modifier' => array( /* DEFAULT */ false, 'fieldsynopsis' => 'format_fieldsynopsis_modifier_text', ), 'classname' => array( /* DEFAULT */ false, 'ooclass' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_ooclass_classname_text', ), ), 'methodname' => array( /* DEFAULT */ false, 'constructorsynopsis' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'methodsynopsis' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), 'destructorsynopsis' => array( /* DEFAULT */ false, 'classsynopsis' => 'format_classsynopsis_methodsynopsis_methodname_text', ), ), 'para' => array( /* DEFAULT */ false, 'footnote' => 'format_footnote_para_text', ), /* FIXME: This is one crazy stupid workaround for footnotes */ 'constant' => array( /* DEFAULT */ false, 'para' => array( /* DEFAULT */ false, 'footnote' => 'format_footnote_constant_text', ), ), 'literal' => 'format_literal_text', 'email' => 'format_email_text', 'titleabbrev' => 'format_suppressed_text', ); /* Current Chunk variables */ protected $cchunk = array(); /* Default Chunk variables */ private $dchunk = array( "classsynopsis" => array( "close" => false, "classname" => false, ), "classsynopsisinfo" => array( "implements" => false, "ooclass" => false, ), "examples" => 0, "fieldsynopsis" => array( "modifier" => "public", ), "co" => 0, "callouts" => 0, "segmentedlist" => array( "seglistitem" => 0, "segtitle" => array( ), ), "table" => false, "procedure" => false, "mediaobject" => array( "alt" => false, ), "footnote" => array( ), "tablefootnotes" => array( ), "chunk_id" => null, "varlistentry" => array( "listitems" => array(), ), ); protected $pihandlers = array( 'dbhtml' => 'PI_DBHTMLHandler', 'dbtimestamp' => 'PI_DBHTMLHandler', ); protected $stylesheets = array(); public function __construct() { parent::__construct(); $this->registerPIHandlers($this->pihandlers); $this->setExt(Config::ext() === null ? ".html" : Config::ext()); } public function getDefaultElementMap() { return $this->myelementmap; } public function getDefaultTextMap() { return $this->mytextmap; } public function getChunkInfo() { return $this->cchunk; } public function getDefaultChunkInfo() { return $this->dchunk; } protected function createTOC($id, $name, $props, $depth = 1, $header = true) { if (!$this->getChildren($id) || $depth == 0) { return ""; } $toc = ''; if ($header) { $toc .= $this->getTocHeader($props); } $toc .= "
    \n"; foreach ($this->getChildren($id) as $child) { $isLDesc = null; $isSDesc = null; $long = $this->getLongDescription($child, $isLDesc); $short = $this->getShortDescription($child, $isSDesc); $link = $this->createLink($child); $list = ""; if ($depth > 1 ) { $list = $this->createTOC($child, $name, $props, $depth -1, false); } if ($isLDesc && $isSDesc) { $toc .= '
  • ' . $short . ' — ' . $long . $list . "
  • \n"; } else { $toc .= '
  • ' . ($long ? $long : $short) . '' . $list . "
  • \n"; } } $toc .= "
\n"; return $toc; } protected function getTocHeader($props) { return '' . $this->autogen('toc', $props['lang']) . ''; } /** * Handle a tag. */ function format_phd_toc($open, $name, $attrs, $props) { if ($open) { return '
'; } return $this->createToc( $attrs[Reader::XMLNS_PHD]['element'], 'phd-toc', $props, isset($attrs[Reader::XMLNS_PHD]['toc-depth']) ? (int)$attrs[Reader::XMLNS_PHD]['toc-depth'] : 1, false ) . "
\n"; } 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; if ($rsl["filename"] != $rsl["docbook_id"]) { $retval .= '#' . $rsl["docbook_id"]; } $desc = $rsl["sdesc"] ?: $rsl["ldesc"]; } return $retval; } protected function createCSSLinks() { $cssLinks = ''; foreach ((array)$this->stylesheets as $css) { if ($this->isChunked()) { $cssLinks .= "\n"; } else { $cssLinks .= "\n"; } } return $cssLinks; } protected function fetchStylesheet($name = null) { if (!$this->isChunked()) { foreach ((array)Config::css() as $css) { if ($style = file_get_contents($css)) { $this->stylesheets[] = $style; } else { v("Stylesheet %s not fetched.", $css, E_USER_WARNING); } } return; } $stylesDir = $this->getOutputDir(); if (!$stylesDir) { $stylesDir = Config::output_dir(); } $stylesDir .= 'styles/'; if (file_exists($stylesDir)) { if (!is_dir($stylesDir)) { v("The styles/ directory is a file?", E_USER_ERROR); } } else { if (!mkdir($stylesDir, 0777, true)) { v("Can't create the styles/ directory.", E_USER_ERROR); } } foreach ((array)Config::css() as $css) { $basename = basename($css); $dest = md5(substr($css, 0, -strlen($basename))) . '-' . $basename; if (@copy($css, $stylesDir . $dest)) { $this->stylesheets[] = $dest; } else { v('Impossible to copy the %s file.', $css, E_USER_WARNING); } } } /* Functions format_* */ public function format_suppressed_tags($open, $name, $attrs, $props) { /* Ignore it */ return ""; } public function format_suppressed_text($value, $tag) { /* Suppress any content */ return ""; } public function format_link($open, $name, $attrs, $props) { $link = null; if ($open) { $link = $class = $content = ""; if (isset($attrs[Reader::XMLNS_DOCBOOK]["linkend"])) { $link = $this->createLink($attrs[Reader::XMLNS_DOCBOOK]["linkend"]); } elseif (isset($attrs[Reader::XMLNS_XLINK]["href"])) { $link = $attrs[Reader::XMLNS_XLINK]["href"]; $class = " external"; $content = "» "; } if ($props["empty"]) { $content .= $link .""; } return '' . $content; } return ""; } public function format_xref($open, $name, $attrs, $props) { if ($open) { $desc = ""; $link = $this->createLink($attrs[Reader::XMLNS_DOCBOOK]["linkend"], $desc); $ret = '' .$desc; if ($props["empty"]) { return $ret. ""; } return $ret; } return ""; } public function format_option($open, $name, $attrs) { if ($open) { if(!isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $attrs[Reader::XMLNS_DOCBOOK]["role"] = "unknown"; } $this->role = $role = $attrs[Reader::XMLNS_DOCBOOK]["role"]; return ''; } $this->role = null; return "\n"; } public function format_literal($open, $name, $attrs) { if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $this->role = $attrs[Reader::XMLNS_DOCBOOK]["role"]; } else { $this->role = false; } return ''; } $this->role = false; return ''; } public function format_literal_text($value, $tag) { switch ($this->role) { case 'infdec': $value = (float)$value; $p = strpos($value, '.'); $str = substr($value, 0, $p + 1); $str .= ''; $str .= substr($value, $p + 1); $str .= ''; return $str; default: return $this->TEXT($value); } } public function format_copyright($open, $name, $attrs) { if ($open) { return '
© '; } return '
'; } public function format_author($open, $name, $attrs, $props) { if ($open) { return '
'; } return "
"; } public function format_personname($open, $name, $attrs, $props) { if ($open) { return ''; } return ""; } public function format_name($open, $name, $attrs) { if ($open) { $class = ""; switch($name) { case "firstname": $class = " given-name"; break; case "surname": $class = " family-name"; break; case "othername": if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { /* We might want to add support for other roles */ switch($attrs[Reader::XMLNS_DOCBOOK]["role"]) { case "nickname": $class = " nickname"; break; } } break; } return ' '; } return ' '; } public function format_container_chunk_top($open, $name, $attrs, $props) { $this->cchunk = $this->dchunk; $this->cchunk["name"] = $name; if(isset($attrs[Reader::XMLNS_XML]["id"])) { $id = $attrs[Reader::XMLNS_XML]["id"]; } else { $id = uniqid("phd"); } if ($open) { $this->CURRENT_CHUNK = $id; $this->notify(Render::CHUNK, Render::OPEN); return '
'; } $this->CURRENT_CHUNK = $id; $this->notify(Render::CHUNK, Render::CLOSE); $toc = ""; if (!in_array($id, $this->TOC_WRITTEN)) { $toc = $this->createTOC($id, $name, $props); } return $toc."
"; } public function format_container_chunk_top_title($open, $name, $attrs, $props) { if ($open) { return '

'; } $id = $this->CURRENT_CHUNK; $toc = $this->createTOC($id, $name, $props, 2); $this->TOC_WRITTEN[] = $id; return '

'.$toc; } public function format_container_chunk_below($open, $name, $attrs, $props) { $this->cchunk = $this->dchunk; $this->cchunk["name"] = $name; if(isset($attrs[Reader::XMLNS_XML]["id"])) { $id = $attrs[Reader::XMLNS_XML]["id"]; } else { /* FIXME: This will obviously not exist in the db.. */ $id = uniqid("phd"); } if ($open) { $this->CURRENT_CHUNK = $id; $this->notify(Render::CHUNK, Render::OPEN); return '
'; } $toc = '
    '; $desc = ""; if (!in_array($id, $this->TOC_WRITTEN)) { $toc = $this->createTOC($id, $name, $props); } $toc .= "
\n"; $this->CURRENT_CHUNK = $id; $this->notify(Render::CHUNK, Render::CLOSE); return $toc . '
'; } public function format_exception_chunk($open, $name, $attrs, $props) { return $this->format_container_chunk_below($open, "reference", $attrs, $props); } public function format_section_chunk($open, $name, $attrs, $props) { if ($open) { if (!isset($attrs[Reader::XMLNS_XML]["id"])) { $this->isSectionChunk[] = false; return $this->transformFromMap($open, "div", $name, $attrs, $props); } $this->isSectionChunk[] = true; return $this->format_chunk($open, $name, $attrs, $props); } if (array_pop($this->isSectionChunk)) { return $this->format_chunk($open, $name, $attrs, $props); } return $this->transformFromMap($open, "div", $name, $attrs, $props); } public function format_chunk($open, $name, $attrs, $props) { if ($open) { $this->cchunk = $this->dchunk; if(isset($attrs[Reader::XMLNS_XML]["id"])) { $id = $attrs[Reader::XMLNS_XML]["id"]; } else { $id = uniqid("phd"); } $class = $name; if ($name === "refentry") { //$class .= " -rel-posting"; } $this->CURRENT_CHUNK = $id; $this->CURRENT_LANG = $props["lang"]; $this->notify(Render::CHUNK, Render::OPEN); return '
'; } $this->notify(Render::CHUNK, Render::CLOSE); $str = ""; foreach ($this->cchunk["footnote"] as $k => $note) { $str .= '
'; $str .= '[' .($k + 1). ']'; $str .= $note["str"]; $str .= "
\n"; } $this->cchunk = $this->dchunk; return $str. "
"; } public function format_refsect1_para($open, $name, $attrs, $props) { if ($open) { switch ($props["sibling"]) { case "methodsynopsis": case "constructorsynopsis": case "destructorsynopsis": return '

'; break; default: return '

'; } } return '

'; } public function format_refsect($open, $name, $attrs) { static $role = 0; if ($open) { if(!isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $attrs[Reader::XMLNS_DOCBOOK]["role"] = "unknown-" . ++$role; } $this->role = $role = $attrs[Reader::XMLNS_DOCBOOK]["role"]; if (isset($attrs[Reader::XMLNS_XML]["id"])) { $id = $attrs[Reader::XMLNS_XML]["id"]; } else { $id = $name. "-" . $this->CURRENT_CHUNK . "-" . $role; } return '
'; } $this->role = null; return "
\n"; } public function format_classsynopsisinfo_oointerface($open, $name, $attrs) { if ($open) { if ($this->cchunk["classsynopsisinfo"]["implements"] === false) { $this->cchunk["classsynopsisinfo"]["implements"] = true; return 'implements '; } return ', '; } return ""; } public function format_classsynopsisinfo_ooclass_classname($open, $name, $attrs) { if ($open) { if ($this->cchunk["classsynopsisinfo"]["ooclass"] === false) { $this->cchunk["classsynopsisinfo"]["ooclass"] = true; return ' class '; } return ' '; } return ""; } public function format_classsynopsisinfo($open, $name, $attrs) { $this->cchunk["classsynopsisinfo"] = $this->dchunk["classsynopsisinfo"]; if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { return '
/* '; } return '
'; } if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) && $attrs[Reader::XMLNS_DOCBOOK]["role"] == "comment") { return ' */
'; } $this->cchunk["classsynopsis"]["close"] = true; return ' {
'; } public function format_classsynopsis($open, $name, $attrs) { if ($open) { return '
'; } if ($this->cchunk["classsynopsis"]["close"] === true) { $this->cchunk["classsynopsis"]["close"] = false; return "}
"; } return ""; } public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) { $value = $this->TEXT($value); if ($this->cchunk["classsynopsis"]["classname"] === false) { return $value; } if (strpos($value, '::')) { $explode = '::'; } elseif (strpos($value, '->')) { $explode = '->'; } elseif (strpos($value, '->')) { $explode = '->'; } else { return $value; } list($class, $method) = explode($explode, $value); if ($class !== $this->cchunk["classsynopsis"]["classname"]) { return $value; } return $method; } public function format_classsynopsis_ooclass_classname_text($value, $tag) { $this->cchunk["classsynopsis"]["classname"] = $value; return $this->TEXT($value); } public function format_fieldsynopsis($open, $name, $attrs) { $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"]; if ($open) { return '
'; } return ";
\n"; } public function format_fieldsynopsis_modifier_text($value, $tag) { $this->cchunk["fieldsynopsis"]["modifier"] = trim($value); return $this->TEXT($value); } public function format_methodsynopsis($open, $name, $attrs) { if ($open) { $this->params = array("count" => 0, "opt" => 0, "content" => ""); $id = (isset($attrs[Reader::XMLNS_XML]["id"]) ? ' id="'.$attrs[Reader::XMLNS_XML]["id"].'"' : ''); return '
'; } $content = ""; if ($this->params["opt"]) { $content = str_repeat("]", $this->params["opt"]); } $content .= " )"; $content .= "
\n"; return $content; } public function format_methodparam_parameter($open, $name, $attrs, $props) { if ($props["empty"]) { return ''; } if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { return ' &$'; } return ' $'; } return ""; } public function format_initializer($open, $name, $attrs) { if ($open) { return ' = '; } return ''; } public function format_parameter($open, $name, $attrs, $props) { if ($props["empty"]) { return ''; } if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { return '&'; } return ''; } return ""; } public function format_void($open, $name, $attrs, $props) { if ($props['sibling'] == 'methodname') { return ' ( void'; } else { return 'void'; } } public function format_methodparam($open, $name, $attrs) { if ($open) { $content = ''; if ($this->params["count"] == 0) { $content .= " ("; } if (isset($attrs[Reader::XMLNS_DOCBOOK]["choice"]) && $attrs[Reader::XMLNS_DOCBOOK]["choice"] == "opt") { $this->params["opt"]++; $content .= "["; } else if($this->params["opt"]) { $content .= str_repeat("]", $this->params["opt"]); $this->params["opt"] = 0; } if ($this->params["count"]) { $content .= ","; } $content .= ' '; ++$this->params["count"]; return $content; } return ""; } public function format_methodname($open, $name, $attr) { if ($open) { return ' '; } return ''; } public function format_varname($open, $name, $attrs) { if ($open) { return '$'; } return ""; } public function format_fieldsynopsis_varname($open, $name, $attrs) { if ($open) { if ($this->cchunk["fieldsynopsis"]["modifier"] === "const") { return ''; } return '$'; } return ''; } public function format_footnoteref($open, $name, $attrs, $props) { if ($open) { $linkend = $attrs[Reader::XMLNS_DOCBOOK]["linkend"]; $found = false; foreach($this->cchunk["footnote"] as $k => $note) { if ($note["id"] === $linkend) { return '[' .($k + 1). ']'; } } trigger_error("footnoteref ID '$linkend' not found", E_USER_WARNING); return ""; } } public function format_footnote($open, $name, $attrs, $props) { if ($open) { $count = count($this->cchunk["footnote"]); $noteid = isset($attrs[Reader::XMLNS_XML]["id"]) ? $attrs[Reader::XMLNS_XML]["id"] : $count + 1; $note = array("id" => $noteid, "str" => ""); $this->cchunk["footnote"][$count] = $note; if ($this->cchunk["table"]) { $this->cchunk["tablefootnotes"][$count] = $noteid; } return '[' .($count + 1). ']'; } return ""; } /* {{{ FIXME: These are crazy workarounds :( */ public function format_footnote_constant($open, $name, $attrs, $props) { $k = count($this->cchunk["footnote"]) - 1; $this->cchunk["footnote"][$k]["str"] .= self::format_constant($open, $name, $attrs, $props); return ""; } public function format_footnote_constant_text($value, $tag) { $k = count($this->cchunk["footnote"]) - 1; $this->cchunk["footnote"][$k]["str"] .= $value; return ""; } public function format_footnote_para($open, $name, $attrs, $props) { $k = count($this->cchunk["footnote"]) - 1; if ($open) { $this->cchunk["footnote"][$k]["str"] .= ''; return ""; } $this->cchunk["footnote"][$k]["str"] .= ""; return ""; } public function format_footnote_para_text($value, $tag) { $k = count($this->cchunk["footnote"]) - 1; $this->cchunk["footnote"][$k]["str"] .= $value; return ""; } /* }}} */ public function format_co($open, $name, $attrs, $props) { if (($open || $props["empty"]) && isset($attrs[Reader::XMLNS_XML]["id"])) { $co = ++$this->cchunk["co"]; return '' .str_repeat("*", $co) .''; } /* Suppress closing tag if any */ return ""; } public function format_calloutlist($open, $name, $attrs) { if ($open) { $this->cchunk["callouts"] = 0; return ''; } return '
'; } public function format_callout($open, $name, $attrs) { if ($open) { return '' .str_repeat("*", ++$this->cchunk["callouts"]). ''; } return "\n"; } public function format_quote($open, $name, $attrs) { if ($open) { return '"'; } return '"'; } public function format_manvolnum($open, $name, $attrs) { if ($open) { return '('; } return ")"; } public function format_segmentedlist($open, $name, $attrs) { $this->cchunk["segmentedlist"] = $this->dchunk["segmentedlist"]; if ($open) { return '
'; } return '
'; } public function format_segtitle_text($value, $tag) { $this->cchunk["segmentedlist"]["segtitle"][count($this->cchunk["segmentedlist"]["segtitle"])] = $value; /* Suppress the text */ return ""; } public function format_seglistitem($open, $name, $attrs) { if ($open) { $this->cchunk["segmentedlist"]["seglistitem"] = 0; return '
'; } return '
'; } public function format_seg($open, $name, $attrs) { if ($open) { return '
' .$this->cchunk["segmentedlist"]["segtitle"][$this->cchunk["segmentedlist"]["seglistitem"]++]. ':'; } return '
'; } public function format_procedure($open, $name, $attrs) { $this->cchunk["procedure"] = false; if ($open) { return '
'; } return '
'; } public function format_step($open, $name, $attrs) { if ($open) { $ret = ""; if ($this->cchunk["procedure"] === false) { $this->cchunk["procedure"] = true; $ret = '
    '; } return $ret . "
  1. "; } return '
  2. '; } public function format_variablelist($open, $name, $attrs) { if ($open) { return "
    \n"; } return "
    \n"; } public function format_varlistentry($open, $name, $attrs) { if ($open) { return isset($attrs[Reader::XMLNS_XML]["id"]) ? '
    ' : "
    \n"; } return "
    \n"; } public function format_varlistentry_listitem($open, $name, $attrs) { if ($open) { return "
    \n"; } return "
    \n"; } public function format_term($open, $name, $attrs, $props) { if ($open) { if ($props["sibling"] == $name) { return '
    '; } return ''; } return ""; } public function format_trademark($open, $name, $attrs, $props) { if ($open) { return ''; } return '®'; } public function format_userinput($open, $name, $attrs) { if ($open) { return ''; } return ""; } public function format_systemitem($open, $name, $attrs) { if ($open) { $val = isset($attrs[Reader::XMLNS_DOCBOOK]["role"]) ? $attrs[Reader::XMLNS_DOCBOOK]["role"] : null; switch($val) { case "directive": /* FIXME: Different roles should probably be handled differently */ default: return ''; } } return ""; } public function format_example_content($open, $name, $attrs) { if ($open) { return '

    '; } return "

    "; } public function format_programlisting($open, $name, $attrs) { if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]["role"])) { $this->role = $attrs[Reader::XMLNS_DOCBOOK]["role"]; } else { $this->role = false; } return '
    '; } $this->role = false; return "
    \n"; } public function format_programlisting_text($value, $tag) { return $this->CDATA($value); } public function format_screen($open, $name, $attrs) { if ($open) { return '
    '; } return '
    '; } public function format_constant($open, $name, $attrs) { if ($open) { return ""; } return ""; } public function admonition_title($title, $lang) { return '' .($this->autogen($title, $lang)). ''; } public function format_admonition($open, $name, $attrs, $props) { if ($open) { return '
    ' .$this->admonition_title($name, $props["lang"]); } return "
    "; } public function format_authorgroup_author($open, $name, $attrs, $props) { if ($open) { if ($props["sibling"] !== $name) { return '
    ' .$this->admonition_title("by", $props["lang"]). ':
    '; } return '
    '; } return "
    \n"; } public function format_editor($open, $name, $attrs, $props) { if ($open) { return '
    ' .$this->admonition_title("editedby", $props["lang"]). ': '; } return "
    \n"; } public function format_note($open, $name, $attrs, $props) { if ($open) { return '

    '.$this->admonition_title("note", $props["lang"]). ': '; } return "

    "; } public function format_note_title($open, $name, $attrs) { if ($open) { return ''; } return '
    '; } public function format_example($open, $name, $attrs, $props) { static $n = 0; if ($open) { ++$n; if (isset($props["id"])) { return '
    '; } return '
    '; } return '
    '; } public function format_example_title($open, $name, $attrs, $props) { if ($props["empty"]) { return ""; } if ($open) { return "

    " . ($this->autogen('example', $props['lang']) . (isset($this->cchunk["examples"]) ? ++$this->cchunk["examples"] : "")) . " "; } return "

    "; } public function format_table_title($open, $name, $attrs, $props) { if ($props["empty"]) { return ""; } if ($open) { return ""; } return ""; } public function format_mediaobject($open, $name, $attrs) { $this->cchunk["mediaobject"] = $this->dchunk["mediaobject"]; if ($open) { return '
    '; } return '
    '; } public function format_alt_text($value, $tag) { $this->cchunk["mediaobject"]["alt"] = $value; } public function format_imagedata($open, $name, $attrs) { $file = $attrs[Reader::XMLNS_DOCBOOK]["fileref"]; if ($newpath = $this->mediamanager->handleFile($file)) { $curfile = $this->mediamanager->findFile($file); $width = isset($attrs[Reader::XMLNS_DOCBOOK]["width"]) ? 'width="' . $attrs[Reader::XMLNS_DOCBOOK]["width"] . '"' : ''; $height = isset($attrs[Reader::XMLNS_DOCBOOK]["depth"]) ? 'height="' . $attrs[Reader::XMLNS_DOCBOOK]["depth"] . '"' : ''; $alt = 'alt="' . ($this->cchunk["mediaobject"]["alt"] !== false ? $this->cchunk["mediaobject"]["alt"] : basename($file)) . '"'; // Generate height and width when none are supplied. if ($curfile && '' === $width . $height) { list(,,,$dimensions,,,,) = getimagesize($curfile); } else { $dimensions = $width . ' ' . $height; } // Generate warnings when only 1 dimension supplied or alt is not supplied. if (!$width xor !$height) { v('Missing %s attribute for %s', (!$width ? 'width' : 'height'), $file, VERBOSE_MISSING_ATTRIBUTES); } if (false === $this->cchunk["mediaobject"]["alt"]) { v('Missing alt attribute for %s', $file, VERBOSE_MISSING_ATTRIBUTES); } return ''; } else { return ''; } } public function format_table($open, $name, $attrs, $props) { if ($open) { $this->cchunk["table"] = true; // Initialize an empty tgroup in case we never process such element Format::tgroup(array()); $idstr = ''; if (isset($attrs[Reader::XMLNS_XML]["id"])) { $idstr = ' id="' . $attrs[Reader::XMLNS_XML]["id"] . '"'; } return ''; } $this->cchunk["table"] = false; $str = ""; if (isset($this->cchunk["tablefootnotes"]) && $this->cchunk["tablefootnotes"]) { $opts = array(Reader::XMLNS_DOCBOOK => array()); $str = $this->format_tbody(true, "footnote", $opts, $props); $str .= $this->format_row(true, "footnote", $opts, $props); $str .= $this->format_entry(true, "footnote", $opts, $props+array("colspan" => $this->getColCount())); foreach ($this->cchunk["tablefootnotes"] as $k => $noteid) { $str .= '
    '; $str .= '[' .($k + 1). ']' .$this->cchunk["footnote"][$k]["str"]; unset($this->cchunk["footnote"][$k]); $str .= "
    \n"; } $str .= $this->format_entry(false, "footnote", $opts, $props); $str .= $this->format_row(false, "footnote", $opts, $props); $str .= $this->format_tbody(false, "footnote", $opts, $props); $this->cchunk["tablefootnotes"] = $this->dchunk["tablefootnotes"]; } return "$str\n"; } public function format_tgroup($open, $name, $attrs) { if ($open) { Format::tgroup($attrs[Reader::XMLNS_DOCBOOK]); return ''; } return ''; } private static function parse_table_entry_attributes($attrs) { $style = array(); $retval = ''; if (!empty($attrs['align'])) { if ('char' != $attrs['align']) { $style[] = 'text-align: ' . $attrs['align']; } elseif (isset($attrs['char'])) { // There's no analogue in CSS, but as this stuff isn't supported // in any browser, it is unlikely to appear in DocBook anyway $retval .= ' align="char" char="' . htmlspecialchars($attrs["char"], ENT_QUOTES) . '"'; if (isset($attrs['charoff'])) { $retval .= ' charoff="' . htmlspecialchars($attrs["charoff"], ENT_QUOTES) . '"'; } } } if (isset($attrs["valign"])) { $style[] = 'vertical-align: ' . $attrs["valign"]; } if (isset($attrs["colwidth"])) { if (preg_match('/^\\d+\\*$/', $attrs['colwidth'])) { // relative_length measure has no analogue in CSS and is // unsupported in browsers, leave as is $retval .= ' width="' . $attrs['colwidth'] . '"'; } else { // probably fixed width, use inline styles $style[] = 'width: ' . $attrs['colwidth']; } } return $retval . (empty($style) ? '' : ' style="' . implode('; ', $style) . ';"'); } public function format_colspec($open, $name, $attrs) { if ($open) { $str = self::parse_table_entry_attributes(Format::colspec($attrs[Reader::XMLNS_DOCBOOK])); return ''; } /* noop */ } public function format_th($open, $name, $attrs) { if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]['valign'])) { return '<' . $name . ' style="vertical-align: ' . $attrs[Reader::XMLNS_DOCBOOK]['valign'] . ';">'; } else { return '<' . $name . '>'; } } return "\n"; } public function format_tbody($open, $name, $attrs) { if ($open) { if (isset($attrs[Reader::XMLNS_DOCBOOK]['valign'])) { return ''; } else { return ''; } } return ""; } public function format_row($open, $name, $attrs) { if ($open) { $idstr = ''; if (isset($attrs[Reader::XMLNS_XML]['id'])) { $idstr = ' id="'. $attrs[Reader::XMLNS_XML]['id']. '"'; } Format::initRow(); if (isset($attrs[Reader::XMLNS_DOCBOOK]['valign'])) { return ''; } else { return ''; } } return "\n"; } public function format_th_entry($open, $name, $attrs, $props) { if ($props["empty"]) { return ' '; } if ($open) { $colspan = Format::colspan($attrs[Reader::XMLNS_DOCBOOK]); if ($colspan == 1) { return ''; } else { return ''; } } return ''; } public function format_entry($open, $name, $attrs, $props) { if ($props["empty"]) { return ' '; } if ($open) { $dbattrs = (array)Format::getColspec($attrs[Reader::XMLNS_DOCBOOK]); $retval = ""; if (isset($dbattrs["colname"])) { for($i=Format::getEntryOffset($dbattrs); $i>0; --$i) { $retval .= ' '; } } /* * "colspan" is *not* an standard prop, only used to overwrite the * colspan for s in tables */ if (isset($props["colspan"])) { $colspan = $props["colspan"]; } else { $colspan = Format::colspan($dbattrs); } $rowspan = Format::rowspan($dbattrs); $moreattrs = self::parse_table_entry_attributes($dbattrs); $sColspan = $colspan == 1 ? '' : ' colspan="' .((int)$colspan) . '"'; $sRowspan = $rowspan == 1 ? '' : ' rowspan="' .((int)$rowspan). '"'; return $retval. ''; } return ""; } public function format_qandaset($open, $name, $attrs, $props) { if ($open) { $node = ReaderKeeper::getReader()->expand(); $doc = new \DOMDocument; $doc->appendChild($node); $xp = new \DOMXPath($doc); $xp->registerNamespace("db", Reader::XMLNS_DOCBOOK); $questions = $xp->query("//db:qandaentry/db:question"); $retval = '
      '; foreach($questions as $node) { $id = $xp->evaluate("ancestor::db:qandaentry", $node)->item(0)->getAttributeNs(Reader::XMLNS_XML, "id"); /* FIXME: No ID? How can we create an anchor for it then? */ if (!$id) { $id = uniqid("phd"); } $retval .= '
    1. '.htmlentities($node->textContent, ENT_QUOTES, "UTF-8").'
    2. '; } $retval .= "
    "; return $retval; } } public function format_question($open, $name, $attrs, $props) { if ($open) { return '
    '; } return '
    '; } public function format_phd_question($open, $name, $attrs, $props) { if ($open) { $href = $this->createLink($attrs[Reader::XMLNS_XML]["id"]); return '
  3. '; } return '
  4. '; } public function format_citation($open, $name, $attrs, $props) { if ($open) { return '['; } return ']'; } public function format_email_text($value) { return '<' . $value . '>'; } public function format_bold_paragraph($open, $name, $attrs, $props) { if ($props["empty"]) { return ""; } if ($open) { return "

    "; } return "

    "; } /** * Functions from the old XHTMLPhDFormat */ public function format_legalnotice_chunk($open, $name, $attrs) { if ($open) { return '
    '; } return "
    \n"; } public function format_div($open, $name, $attrs, $props) { if ($open) { return '
    '; } return '
    '; } public function format_screen_text($value, $tag) { return nl2br($this->TEXT($value)); } /** * Renders a tag. * * @return string HTML code */ public function format_tag($open, $name, $attrs, $props) { static $arFixes = array( 'attribute' => array('', ''), 'attvalue' => array('"', '"'), 'comment' => array('<!--', '-->'), 'element' => array('', ''), 'emptytag' => array('<', '/>'), 'endtag' => array('</', '>'), 'genentity' => array('&', ';'), 'localname' => array('', ''), 'namespace' => array('', ''), 'numcharref' => array('&#', ';'), 'paramentity' => array('%', ';'), 'pi' => array('<?', '?>'), 'prefix' => array('', ''), 'starttag' => array('<', '>'), 'xmlpi' => array('<?', '?>'), ); if ($props['empty']) { return ''; } $class = 'starttag'; if (isset($attrs['class'])) { $class = $attrs['class']; } if (!isset($arFixes[$class])) { trigger_error('Unknown tag class "' . $class . '"', E_USER_WARNING); $class = 'starttag'; } if (!$open) { return $arFixes[$class][1] . '
    '; } return '' . $arFixes[$class][0]; } public function format_dl($open, $name, $attrs, $props) { if ($open) { return '
    '; } return '
    '; } public function format_itemizedlist($open, $name, $attrs, $props) { if ($open) { return '
      '; } return '
    '; } public function format_orderedlist($open, $name, $attrs, $props) { if ($open) { $numeration = "1"; if (isset($attrs[Reader::XMLNS_DOCBOOK]["numeration"])) { switch($attrs[Reader::XMLNS_DOCBOOK]["numeration"]) { case "upperalpha": $numeration = "A"; break; case "loweralpha": $numeration = "a"; break; case "upperroman": $numeration = "I"; break; case "lowerroman": $numeration = "i"; break; } } return '
      '; } return '
    '; } } /* * vim600: sw=4 ts=4 syntax=php et * vim<600: sw=4 ts=4 */