'div', /* Docbook-xsl prints "abstract"... */ 'acronym' => 'acronym', 'article' => 'format_container_chunk', 'author' => 'div', 'authorgroup' => 'div', /* DocBook-xsl prints out "by" (i.e. "PHP Manual by ...") */ 'appendix' => 'format_container_chunk', 'application' => 'span', 'bibliography' => array( /* DEFAULT */ 'div', 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'book' => 'format_container_chunk', 'chapter' => 'format_container_chunk', 'colophon' => 'format_chunk', 'firstname' => 'span', 'surname' => 'span', 'othername' => 'span', 'honorific' => 'span', 'glossary' => array( /* DEFAULT */ 'div', 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'caution' => 'div', 'classname' => array( /* DEFAULT */ 'span', 'ooclass' => 'b', ), 'classsynopsis' => 'format_classsynopsis', 'classsynopsisinfo' => 'format_classsynopsisinfo', 'code' => 'code', 'collab' => 'span', 'collabname' => 'span', 'colspec' => 'format_colspec', 'command' => 'span', 'computeroutput' => 'span', 'constant' => 'format_constant', 'constructorsynopsis' => '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', 'example' => 'div', 'fieldsynopsis' => array( /* DEFAULT */ 'format_fieldsynopsis', 'entry' => 'div', ), 'filename' => 'var', 'glossterm' => 'span', 'holder' => 'span', 'imageobject' => 'div', 'imagedata' => 'format_imagedata', 'index' => array( /* DEFAULT */ 'div', 'article' => 'format_chunk', 'book' => 'format_chunk', 'part' => 'format_chunk', ), 'info' => 'div', 'informalexample' => 'div', 'informaltable' => 'table', 'itemizedlist' => 'ul', 'listitem' => array( /* DEFAULT */ 'li', 'varlistentry' => 'format_varlistentry_listitem', ), 'literal' => 'i', 'mediaobject' => 'div', 'methodparam' => 'format_methodparam', 'methodsynopsis' => 'format_methodsynopsis', 'methodname' => 'format_methodname', 'member' => 'li', 'modifier' => 'span', 'note' => 'format_note', 'ooclass' => array( /* DEFAULT */ 'span', 'classsynopsis' => 'format_classsynopsis_ooclass', ), 'option' => 'span', 'orderedlist' => 'ol', 'para' => array( /* DEFAULT */ 'p', 'example' => 'format_example_content', ), 'parameter' => array( /* DEFAULT */ 'format_parameter', 'methodparam' => 'format_methodparam_parameter', ), 'part' => 'format_container_chunk', 'partintro' => 'div', 'personname' => 'span', 'preface' => 'format_chunk', 'productname' => 'span', 'programlisting' => 'format_programlisting', 'propname' => 'span', 'property' => array( /* DEFAULT */ 'span', 'classsynopsisinfo' => 'format_varname', ), 'proptype' => 'span', 'refentry' => 'format_chunk', 'reference' => 'format_container_chunk', 'refsect1' => 'format_refsect', 'refsect2' => 'format_refsect', 'refsect3' => 'format_refsect', 'refname' => 'h1', 'refnamediv' => 'div', 'row' => 'format_row', 'screen' => 'format_screen', 'sect1' => 'format_chunk', 'sect2' => 'format_chunk', 'sect3' => 'format_chunk', 'sect4' => 'format_chunk', 'sect5' => 'format_chunk', 'section' => 'format_chunk', 'set' => 'format_chunk', 'setindex' => 'format_chunk', 'simplelist' => 'ul', 'simpara' => array( /* DEFAULT */ 'p', 'note' => 'span', 'listitem' => 'span', 'entry' => 'span', 'example' => 'format_example_content', ), 'systemitem' => 'format_systemitem', 'tag' => 'code', 'table' => 'format_table', 'term' => 'span', 'tfoot' => 'format_th', 'thead' => 'format_th', 'tgroup' => 'format_tgroup', 'tip' => 'div', 'title' => array( /* DEFAULT */ 'h1', 'example' => 'format_bold_paragraph', 'info' => array( /* DEFAULT */ 'h1', 'example' => 'format_bold_paragraph', ), 'legalnotice' => 'h4', 'note' => 'format_note_title', 'refsect1' => 'h3', 'refsect2' => 'h4', 'refsect3' => 'h5', 'section' => 'h2', 'sect1' => 'h2', 'sect2' => 'h3', 'sect3' => 'h4', 'table' => 'format_bold_paragraph', ), 'type' => 'span', 'userinput' => 'format_userinput', 'variablelist' => 'format_variablelist', 'varlistentry' => 'format_varlistentry', 'varname' => array( /* DEFAULT */ 'var', 'fieldsynopsis' => 'format_varname', ), 'void' => 'format_void', 'warning' => 'div', 'year' => 'span', ); /* }}} */ protected $textmap = array( ); protected $role = false; public function __construct(array $IDs) { parent::__construct($IDs); } public function __call($func, $args) { if ($args[0]) { trigger_error("No mapper found for '{$func}'", E_USER_WARNING); return "{$args[1]}"; } return "/{$args[1]}"; } public function transformFromMap($open, $tag, $name) { if ($open) { return sprintf('<%s class="%s">', $tag, $name); } return ""; } public function CDATA($str) { switch($this->role) { case "php": return sprintf('
%s
', highlight_string(trim($str), 1)); break; default: return sprintf('
%s
', htmlspecialchars($str, ENT_QUOTES, "UTF-8")); } } public function TEXT($str) { return htmlspecialchars($str, ENT_QUOTES, "UTF-8"); } public function format_container_chunk($open, $name, $attrs) { if ($open) { return sprintf('
', $attrs[PhDReader::XMLNS_XML]["id"], $name); } return "
"; } public function format_chunk($open, $name, $attrs) { if ($open) { if(isset($attrs[PhDReader::XMLNS_XML]["id"])) { return sprintf('
', $attrs[PhDReader::XMLNS_XML]["id"], $name); } return sprintf('
', $name); } return "
"; } public function format_refsect($open, $name, $attrs) { if ($open) { if(!isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { $attrs[PhDReader::XMLNS_DOCBOOK] = "unkown"; } return sprintf('
', $name, $attrs[PhDReader::XMLNS_DOCBOOK]["role"]); } return "
\n"; } public function format_classsynopsis_ooclass($open, $name, $attrs) { if ($open) { return 'class '; } return " {"; } public function format_classsynopsis($open, $name, $attrs) { if ($open) { return '
'; } return "}
"; } public function format_classsynopsisinfo($open, $name, $attrs) { if ($open) { return '
'; } return ";
\n"; } public function format_fieldsynopsis($open, $name, $attrs) { if ($open) { return '
'; } return ";
\n"; } public function format_methodsynopsis($open, $name, $attrs) { if ($open) { $this->params = array("count" => 0, "opt" => 0, "content" => ""); 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) { if ($open) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { return ' &$'; } return ' $'; } return ""; } public function format_parameter($open, $name, $attrs) { if ($open) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { return '&'; } return ''; } return "\n"; } public function format_void($open, $name, $attrs) { return ' ( void'; } public function format_methodparam($open, $name, $attrs) { if ($open) { $content = ''; if ($this->params["count"] == 0) { $content .= " ("; } if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["choice"]) && $attrs[PhDReader::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 "\n"; } 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[PhDReader::XMLNS_XML]["id"]) ? sprintf('
', $attrs[PhDReader::XMLNS_XML]["id"]) : "
\n"; } return "
\n"; } public function format_varlistentry_listitem($open, $name, $attrs) { if ($open) { return "
\n"; } return "
\n"; } public function format_userinput($open, $name, $attrs) { if ($open) { return sprintf('', $name); } return "\n"; } public function format_systemitem($open, $name, $attrs) { if ($open) { $val = isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) ? $attrs[PhDReader::XMLNS_DOCBOOK]["role"] : null; switch($val) { case "directive": /* FIXME: Different roles should probably be handled differently */ default: return sprintf('', $name); } } return "\n"; } public function format_example_content($open, $name, $attrs) { if ($open) { return '

'; } return "

"; } public function format_programlisting($open, $name, $attrs) { if ($open) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { $this->role = $attrs[PhDReader::XMLNS_DOCBOOK]["role"]; } else { $this->role = false; } return '
'; } $this->role = false; return "
\n"; } public function format_screen($open, $name, $attrs) { if ($open) { return '
';
        }
        return '
'; } public function format_constant($open, $name, $attrs) { if ($open) { return ""; } return ""; } public function format_note($open, $name, $attrs) { if ($open) { return '

'; } return "

"; } public function format_note_title($open, $name, $attrs) { if ($open) { return ''; } return ''; } public function format_bold_paragraph($open, $name, $attrs) { if ($open) { return "

"; } return "

"; } public function format_imagedata($open, $name, $attrs) { return sprintf('', $attrs[PhDReader::XMLNS_DOCBOOK]["fileref"]); } public function format_table($open, $name, $attrs) { if ($open) { return ''; } return "
\n"; } public function format_tgroup($open, $name, $attrs) { if ($open) { PhDFormat::tgroup($attrs[PhDReader::XMLNS_DOCBOOK]); return "\n"; } return "\n"; } private function parse_table_entry_attributes($attrs) { $retval = sprintf('align="%s"', $attrs["align"]); if ($attrs["align"] == "char" && isset($attrs["char"])) { $retval .= sprintf(' char="%s"', htmlspecialchars($attrs["char"], ENT_QUOTES)); if (isset($attrs["charoff"])) { $retval .= sprintf(' charoff="%s"', htmlspecialchars($attrs["charoff"], ENT_QUOTES)); } } if (isset($attrs["valign"])) { $retval .= sprintf(' valign="%s"', $attrs["valign"]); } if (isset($attrs["colwidth"])) { $retval .= sprintf(' width="%d"', $attrs["colwidth"]); } return $retval; } public function format_colspec($open, $name, $attrs) { if ($open) { $str = self::parse_table_entry_attributes(PhDFormat::colspec($attrs[PhDReader::XMLNS_DOCBOOK])); return sprintf('', $str); } /* noop */ } public function format_th($open, $name, $attrs) { if ($open) { $valign = PhDFormat::valign($attrs[PhDReader::XMLNS_DOCBOOK]); return sprintf('<%s valign="%s">', $name, $valign); } return "\n"; } public function format_tbody($open, $name, $attrs) { if ($open) { $valign = PhDFormat::valign($attrs[PhDReader::XMLNS_DOCBOOK]); return sprintf('', $valign); } return ""; } public function format_row($open, $name, $attrs) { if ($open) { PhDFormat::initRow(); $valign = PhDFormat::valign($attrs[PhDReader::XMLNS_DOCBOOK]); return sprintf('', $valign); } return "\n"; } public function format_th_entry($open, $name, $attrs = array()) { if ($open) { $colspan = PhDFormat::colspan($attrs[PhDReader::XMLNS_DOCBOOK]); return sprintf('', $colspan); } return ''; } public function format_entry($open, $name, $attrs) { if ($open) { $dbattrs = PhDFormat::getColspec($attrs[PhDReader::XMLNS_DOCBOOK]); $retval = ""; if (isset($dbattrs["colname"])) { for($i=PhDFormat::getEntryOffset($dbattrs); $i>0; --$i) { $retval .= ' '; } } $colspan = PhDFormat::colspan($dbattrs); $rowspan = PhDFormat::rowspan($dbattrs); $moreattrs = self::parse_table_entry_attributes($dbattrs); return sprintf('%s', $retval, $colspan, $rowspan, $moreattrs); } return ""; } } /* * vim600: sw=4 ts=4 fdm=syntax syntax=php et * vim<600: sw=4 ts=4 */