cvs: phd /themes/pear pearchunkedhtml.php peartheme.php
| From: | Christian Weiske | Date: | Wed, 08 Oct 2008 20:19:42 +0000 |
| Subject: | cvs: phd /themes/pear pearchunkedhtml.php peartheme.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2217@lists.php.net to get a copy of this message | ||
cweiske Wed Oct 8 20:19:42 2008 UTC
Modified files:
/phd/themes/pear pearchunkedhtml.php peartheme.php
Log:
Rework peartheme to generate cleaner and valid html
http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearchunkedhtml.php?r1=1.4&r2=1.5&diff_format=u Index: phd/themes/pear/pearchunkedhtml.php diff -u phd/themes/pear/pearchunkedhtml.php:1.4 phd/themes/pear/pearchunkedhtml.php:1.5 --- phd/themes/pear/pearchunkedhtml.php:1.4 Sun Oct 5 17:52:48 2008 +++ phd/themes/pear/pearchunkedhtml.php Wed Oct 8 20:19:41 2008 @@ -60,12 +60,14 @@ </table> <hr/> </div> + NAV; - $header .= $nav . "<div id=\"doc3\"><div id=\"body\">"; + $header .= $nav . "<div id=\"body\">\n"; return $header; } public function footer($id) { + //FIXME: don't print empty links $nav = <<<NAV <div class="navfooter"> <hr /> @@ -82,8 +84,9 @@ </tr> </table> </div> + NAV; - return "</div></div>$nav</body></html>\n"; + return "</div>\n$nav</body></html>\n"; } public function __destruct() { if (file_exists($this->outputdir . "guide.html") && !file_exists($this->outputdir . 'index.html')) { http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?r1=1.6&r2=1.7&diff_format=u Index: phd/themes/pear/peartheme.php diff -u phd/themes/pear/peartheme.php:1.6 phd/themes/pear/peartheme.php:1.7 --- phd/themes/pear/peartheme.php:1.6 Sun Oct 5 17:52:48 2008 +++ phd/themes/pear/peartheme.php Wed Oct 8 20:19:41 2008 @@ -24,7 +24,6 @@ 'colophon' => 'format_chunk', 'constant' => 'b', 'emphasis' => 'format_emphasis', - 'entry' => 'format_entry', 'filename' => array( /* DEFAULT */ 'tt', 'titleabbrev' => 'format_suppressed_tags', @@ -53,8 +52,9 @@ 'important' => 'format_admonition', 'info' => array( /* DEFAULT */ false, - 'chapter' => 'format_comment', +// 'chapter' => 'format_comment', 'refsynopsisdiv' => 'format_comment', + 'warning' => 'format_suppressed_tags', ), 'index' => array( /* DEFAULT */ false, @@ -63,8 +63,10 @@ 'part' => 'format_chunk', ), 'informalexample' => 'div', - 'informaltable' => 'format_table', - 'itemizedlist' => 'ul', + 'informaltable' => array( + /* DEFAULT */ 'format_table', + 'para' => 'format_para_informaltable', + ), 'legalnotice' => 'format_chunk', 'link' => 'format_link', 'listitem' => array( @@ -104,7 +106,6 @@ 'refpurpose' => 'format_refpurpose', 'refsection' => 'format_container_chunk', 'refsynopsisdiv' => 'format_refsynopsisdiv', - 'row' => 'tr', 'screen' => 'format_screen', 'sect1' => 'format_chunk', 'sect2' => 'format_chunk', @@ -139,6 +140,7 @@ 'chapter' => 'format_container_chunk_title', //'example' => 'format_example_title', 'part' => 'format_container_chunk_title', + 'warning' => 'format_warning_title', ), 'refsect1' => 'h2', 'refsect2' => 'h3', @@ -242,36 +244,39 @@ } public function format_container_chunk($open, $name, $attrs, $props) { - if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) + if (!isset($attrs[PhDReader::XMLNS_XML]['id'])) { return "<div class=\"{$name}\">"; + } $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; - if ($open) { - if ($props["isChunk"]) { - $this->cchunk = $this->dchunk; + + if (!$open) { + return "</div>\n"; + } + + if ($props["isChunk"]) { + $this->cchunk = $this->dchunk; + } + $chunks = PhDHelper::getChildren($id); + if (count($chunks)) { + $content = "<div class=\"TOC\">\n <dl>\n <dt><b>" . $this->autogen("toc", $props["lang"]) . "</b></dt>\n"; + foreach ($chunks as $chunkid => $junk) { + $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); + $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); + if ($long && $short && $long != $short) { + $desc = $short. '</a> -- ' .$long; + } else { + $desc = ($long ? $long : $short). '</a>'; + } + if ($this->chunked) { + $content .= " <dt><a href=\"{$chunkid}.{$this->ext}\">" . $desc . "</dt>\n"; + } else { + $content .= " <dt><a href=\"#{$chunkid}\">" . $this->format->TEXT(PhDHelper::getDescription($chunkid, false)) . "</a></dt>\n"; + } } - $chunks = PhDHelper::getChildren($id); - if (count($chunks)) { - $content = "<div class=\"TOC\">\n <dl>\n <dt><b>" . $this->autogen("toc", $props["lang"]) . "</b></dt>\n"; - foreach($chunks as $chunkid => $junk) { - $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); - $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); - if ($long && $short && $long != $short) { - $desc = $short. '</a> -- ' .$long; - } else { - $desc = ($long ? $long : $short). '</a>'; - } - if ($this->chunked) { - $content .= " <dt><a href=\"{$chunkid}.{$this->ext}\">" . $desc . "</dt>\n"; - } else { - $content .= " <dt><a href=\"#{$chunkid}\">" . $this->format->TEXT(PhDHelper::getDescription($chunkid, false)) . "</a></dt>\n"; - } - } $content .= " </dl>\n</div>\n"; $this->cchunk["container_chunk"] = $content; - } - return "<div class=\"{$name}\" id=\"{$id}\">"; } - return "</div>\n"; + return "<div class=\"{$name}\" id=\"{$id}\">"; } public function format_exception_chunk($open, $name, $attrs, $props) { @@ -285,26 +290,30 @@ } $chunks = PhDHelper::getChildren($id); - $content = '<p><b>' . $this->autogen("toc", $props["lang"]) . '</b></p><ul class="chunklist chunklist_'.$name.'">'; - foreach($chunks as $chunkid => $junk) { - $href = $this->chunked ? $chunkid .'.'. $this->ext : "#$chunkid"; - $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); - $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); - $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a>'; - $children = PhDHelper::getChildren($chunkid); - if (count($children)) { - $content .= '<ul class="chunklist chunklist_'.$name.' chunklist_children">'; - foreach(PhDHelper::getChildren($chunkid) as $childid => $junk) { - $href = $this->chunked ? $childid .'.'. $this->ext : "#$childid"; - $long = $this->format->TEXT(PhDHelper::getDescription($childid, true)); - $short = $this->format->TEXT(PhDHelper::getDescription($childid, false)); - $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a></li>'; + $content = '<p><b>' . $this->autogen("toc", $props["lang"]) . "</b></p>\n"; + if (count($chunks)) { + $content .= '<ul class="chunklist chunklist_'.$name.'">' . "\n"; + foreach ($chunks as $chunkid => $junk) { + $href = $this->chunked ? $chunkid .'.'. $this->ext : "#$chunkid"; + $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); + $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); + $content .= ' <li><a href="' .$href. '">' .($long ? $long : $short). '</a>'; + $children = PhDHelper::getChildren($chunkid); + if (count($children)) { + $content .= "\n" . ' <ul class="chunklist chunklist_'.$name.' chunklist_children">' . "\n"; + foreach (PhDHelper::getChildren($chunkid) as $childid => $junk) { + $href = $this->chunked ? $childid .'.'. $this->ext : "#$childid"; + $long = $this->format->TEXT(PhDHelper::getDescription($childid, true)); + $short = $this->format->TEXT(PhDHelper::getDescription($childid, false)); + $content .= ' <li><a href="' .$href. '">' .($long ? $long : $short). "</a></li>\n"; + } + $content .= " </ul>\n "; } - $content .="</ul>"; + $content .= "</li>\n"; } - $content .= "</li>"; + $content .= "</ul>\n"; } - $content .= "</ul>"; + $content .= "</div>\n"; return $content; } @@ -389,6 +398,13 @@ return '</' .$tag. '>'; } + public function format_para_informaltable($open, $name, $attrs, $props) { + if ($open) { + return '</p>' . $this->format_table($open, $name, $attrs, $props); + } + return $this->format_table($open, $name, $attrs, $props) . '<p>'; + } + public function format_programlisting($open, $name, $attrs) { if ($open) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { @@ -487,25 +503,36 @@ public function format_admonition($open, $name, $attrs, $props) { if ($open) { - return '<p><div class="' . $name . '"><blockquote class="' . $name . '"><p><b>'.$this->autogen($name, $props["lang"]). ': </b>'; + return '<blockquote class="' . $name . '"><p><b>'.$this->autogen($name, $props["lang"]). ': </b>'; } - return "</p></blockquote></div></p>"; + return "</p></blockquote>\n"; } public function format_table($open, $name, $attrs, $props) { if ($open) { - return '<p><div class="'.$name.'"><table border="1" class="CALSTABLE">'; + return '<table border="1" class="'.$name.'">'; } - return "</table></div></p>"; + return "</table>\n"; } public function format_entry($open, $name, $attrs, $props) { if ($open) { - return '<td align="left" valign="middle">'; + if ($props['empty']) { + return '<td></td>'; + } + return '<td>'; } return "</td>"; } + public function format_th_entry($open, $name, $attrs) { + if ($open) { + $colspan = PhDFormat::colspan($attrs[PhDReader::XMLNS_DOCBOOK]); + return '<th colspan="' .((int)$colspan). '">'; + } + return '</th>'; + } + public function format_table_title($open, $name, $attrs, $props) { if ($props["empty"]) return ""; @@ -531,25 +558,27 @@ public function format_warning($open, $name, $attrs, $props) { if ($open) { - return '<div class="warning"><table class="warning" border="1" width="100%"><tbody>'; + return '<div class="warning" style="border: 3px double black; padding: 5px">' . "\n"; } - return "</td></tr></tbody></table></div>"; + return "</div>\n"; } public function format_warning_title($open, $name, $attrs, $props) { if ($open) { - return '<tr><td align="center"><b>'; + return '<strong class="warning_title" style="display:block; text-align: center; width:100%">'; } - return "</b></td></tr>"; + return "</strong>\n"; } public function format_warning_para($open, $name, $attrs, $props) { if ($open) { - if (!$props["sibling"]) - return '<tr align="center"><td><b>' . $this->autogen("warning", $props["lang"]) . "</b></td></tr>" . '<tr><td align="left"><p>'; - return '<tr><td align="left"><p>'; + if (!$props['sibling']) { + return '<strong>' . $this->autogen("warning", $props["lang"]) . "</strong>\n" + . '<p>'; + } + return '<p>'; } - return "</p></td></tr>"; + return "</p>\n"; } public function format_refname_function_text($value) {
http://cvs.php.net/viewvc.cgi/phd/themes/pear/pearchunkedhtml.php?r1=1.4&r2=1.5&diff_format=u Index: phd/themes/pear/pearchunkedhtml.php diff -u phd/themes/pear/pearchunkedhtml.php:1.4 phd/themes/pear/pearchunkedhtml.php:1.5 --- phd/themes/pear/pearchunkedhtml.php:1.4 Sun Oct 5 17:52:48 2008 +++ phd/themes/pear/pearchunkedhtml.php Wed Oct 8 20:19:41 2008 @@ -60,12 +60,14 @@ </table> <hr/> </div> + NAV; - $header .= $nav . "<div id=\"doc3\"><div id=\"body\">"; + $header .= $nav . "<div id=\"body\">\n"; return $header; } public function footer($id) { + //FIXME: don't print empty links $nav = <<<NAV <div class="navfooter"> <hr /> @@ -82,8 +84,9 @@ </tr> </table> </div> + NAV; - return "</div></div>$nav</body></html>\n"; + return "</div>\n$nav</body></html>\n"; } public function __destruct() { if (file_exists($this->outputdir . "guide.html") && !file_exists($this->outputdir . 'index.html')) { http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?r1=1.6&r2=1.7&diff_format=u Index: phd/themes/pear/peartheme.php diff -u phd/themes/pear/peartheme.php:1.6 phd/themes/pear/peartheme.php:1.7 --- phd/themes/pear/peartheme.php:1.6 Sun Oct 5 17:52:48 2008 +++ phd/themes/pear/peartheme.php Wed Oct 8 20:19:41 2008 @@ -24,7 +24,6 @@ 'colophon' => 'format_chunk', 'constant' => 'b', 'emphasis' => 'format_emphasis', - 'entry' => 'format_entry', 'filename' => array( /* DEFAULT */ 'tt', 'titleabbrev' => 'format_suppressed_tags', @@ -53,8 +52,9 @@ 'important' => 'format_admonition', 'info' => array( /* DEFAULT */ false, - 'chapter' => 'format_comment', +// 'chapter' => 'format_comment', 'refsynopsisdiv' => 'format_comment', + 'warning' => 'format_suppressed_tags', ), 'index' => array( /* DEFAULT */ false, @@ -63,8 +63,10 @@ 'part' => 'format_chunk', ), 'informalexample' => 'div', - 'informaltable' => 'format_table', - 'itemizedlist' => 'ul', + 'informaltable' => array( + /* DEFAULT */ 'format_table', + 'para' => 'format_para_informaltable', + ), 'legalnotice' => 'format_chunk', 'link' => 'format_link', 'listitem' => array( @@ -104,7 +106,6 @@ 'refpurpose' => 'format_refpurpose', 'refsection' => 'format_container_chunk', 'refsynopsisdiv' => 'format_refsynopsisdiv', - 'row' => 'tr', 'screen' => 'format_screen', 'sect1' => 'format_chunk', 'sect2' => 'format_chunk', @@ -139,6 +140,7 @@ 'chapter' => 'format_container_chunk_title', //'example' => 'format_example_title', 'part' => 'format_container_chunk_title', + 'warning' => 'format_warning_title', ), 'refsect1' => 'h2', 'refsect2' => 'h3', @@ -242,36 +244,39 @@ } public function format_container_chunk($open, $name, $attrs, $props) { - if (!isset($attrs[PhDReader::XMLNS_XML]["id"])) + if (!isset($attrs[PhDReader::XMLNS_XML]['id'])) { return "<div class=\"{$name}\">"; + } $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; - if ($open) { - if ($props["isChunk"]) { - $this->cchunk = $this->dchunk; + + if (!$open) { + return "</div>\n"; + } + + if ($props["isChunk"]) { + $this->cchunk = $this->dchunk; + } + $chunks = PhDHelper::getChildren($id); + if (count($chunks)) { + $content = "<div class=\"TOC\">\n <dl>\n <dt><b>" . $this->autogen("toc", $props["lang"]) . "</b></dt>\n"; + foreach ($chunks as $chunkid => $junk) { + $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); + $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); + if ($long && $short && $long != $short) { + $desc = $short. '</a> -- ' .$long; + } else { + $desc = ($long ? $long : $short). '</a>'; + } + if ($this->chunked) { + $content .= " <dt><a href=\"{$chunkid}.{$this->ext}\">" . $desc . "</dt>\n"; + } else { + $content .= " <dt><a href=\"#{$chunkid}\">" . $this->format->TEXT(PhDHelper::getDescription($chunkid, false)) . "</a></dt>\n"; + } } - $chunks = PhDHelper::getChildren($id); - if (count($chunks)) { - $content = "<div class=\"TOC\">\n <dl>\n <dt><b>" . $this->autogen("toc", $props["lang"]) . "</b></dt>\n"; - foreach($chunks as $chunkid => $junk) { - $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); - $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); - if ($long && $short && $long != $short) { - $desc = $short. '</a> -- ' .$long; - } else { - $desc = ($long ? $long : $short). '</a>'; - } - if ($this->chunked) { - $content .= " <dt><a href=\"{$chunkid}.{$this->ext}\">" . $desc . "</dt>\n"; - } else { - $content .= " <dt><a href=\"#{$chunkid}\">" . $this->format->TEXT(PhDHelper::getDescription($chunkid, false)) . "</a></dt>\n"; - } - } $content .= " </dl>\n</div>\n"; $this->cchunk["container_chunk"] = $content; - } - return "<div class=\"{$name}\" id=\"{$id}\">"; } - return "</div>\n"; + return "<div class=\"{$name}\" id=\"{$id}\">"; } public function format_exception_chunk($open, $name, $attrs, $props) { @@ -285,26 +290,30 @@ } $chunks = PhDHelper::getChildren($id); - $content = '<p><b>' . $this->autogen("toc", $props["lang"]) . '</b></p><ul class="chunklist chunklist_'.$name.'">'; - foreach($chunks as $chunkid => $junk) { - $href = $this->chunked ? $chunkid .'.'. $this->ext : "#$chunkid"; - $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); - $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); - $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a>'; - $children = PhDHelper::getChildren($chunkid); - if (count($children)) { - $content .= '<ul class="chunklist chunklist_'.$name.' chunklist_children">'; - foreach(PhDHelper::getChildren($chunkid) as $childid => $junk) { - $href = $this->chunked ? $childid .'.'. $this->ext : "#$childid"; - $long = $this->format->TEXT(PhDHelper::getDescription($childid, true)); - $short = $this->format->TEXT(PhDHelper::getDescription($childid, false)); - $content .= '<li><a href="' .$href. '">' .($long ? $long : $short). '</a></li>'; + $content = '<p><b>' . $this->autogen("toc", $props["lang"]) . "</b></p>\n"; + if (count($chunks)) { + $content .= '<ul class="chunklist chunklist_'.$name.'">' . "\n"; + foreach ($chunks as $chunkid => $junk) { + $href = $this->chunked ? $chunkid .'.'. $this->ext : "#$chunkid"; + $long = $this->format->TEXT(PhDHelper::getDescription($chunkid, true)); + $short = $this->format->TEXT(PhDHelper::getDescription($chunkid, false)); + $content .= ' <li><a href="' .$href. '">' .($long ? $long : $short). '</a>'; + $children = PhDHelper::getChildren($chunkid); + if (count($children)) { + $content .= "\n" . ' <ul class="chunklist chunklist_'.$name.' chunklist_children">' . "\n"; + foreach (PhDHelper::getChildren($chunkid) as $childid => $junk) { + $href = $this->chunked ? $childid .'.'. $this->ext : "#$childid"; + $long = $this->format->TEXT(PhDHelper::getDescription($childid, true)); + $short = $this->format->TEXT(PhDHelper::getDescription($childid, false)); + $content .= ' <li><a href="' .$href. '">' .($long ? $long : $short). "</a></li>\n"; + } + $content .= " </ul>\n "; } - $content .="</ul>"; + $content .= "</li>\n"; } - $content .= "</li>"; + $content .= "</ul>\n"; } - $content .= "</ul>"; + $content .= "</div>\n"; return $content; } @@ -389,6 +398,13 @@ return '</' .$tag. '>'; } + public function format_para_informaltable($open, $name, $attrs, $props) { + if ($open) { + return '</p>' . $this->format_table($open, $name, $attrs, $props); + } + return $this->format_table($open, $name, $attrs, $props) . '<p>'; + } + public function format_programlisting($open, $name, $attrs) { if ($open) { if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) { @@ -487,25 +503,36 @@ public function format_admonition($open, $name, $attrs, $props) { if ($open) { - return '<p><div class="' . $name . '"><blockquote class="' . $name . '"><p><b>'.$this->autogen($name, $props["lang"]). ': </b>'; + return '<blockquote class="' . $name . '"><p><b>'.$this->autogen($name, $props["lang"]). ': </b>'; } - return "</p></blockquote></div></p>"; + return "</p></blockquote>\n"; } public function format_table($open, $name, $attrs, $props) { if ($open) { - return '<p><div class="'.$name.'"><table border="1" class="CALSTABLE">'; + return '<table border="1" class="'.$name.'">'; } - return "</table></div></p>"; + return "</table>\n"; } public function format_entry($open, $name, $attrs, $props) { if ($open) { - return '<td align="left" valign="middle">'; + if ($props['empty']) { + return '<td></td>'; + } + return '<td>'; } return "</td>"; } + public function format_th_entry($open, $name, $attrs) { + if ($open) { + $colspan = PhDFormat::colspan($attrs[PhDReader::XMLNS_DOCBOOK]); + return '<th colspan="' .((int)$colspan). '">'; + } + return '</th>'; + } + public function format_table_title($open, $name, $attrs, $props) { if ($props["empty"]) return ""; @@ -531,25 +558,27 @@ public function format_warning($open, $name, $attrs, $props) { if ($open) { - return '<div class="warning"><table class="warning" border="1" width="100%"><tbody>'; + return '<div class="warning" style="border: 3px double black; padding: 5px">' . "\n"; } - return "</td></tr></tbody></table></div>"; + return "</div>\n"; } public function format_warning_title($open, $name, $attrs, $props) { if ($open) { - return '<tr><td align="center"><b>'; + return '<strong class="warning_title" style="display:block; text-align: center; width:100%">'; } - return "</b></td></tr>"; + return "</strong>\n"; } public function format_warning_para($open, $name, $attrs, $props) { if ($open) { - if (!$props["sibling"]) - return '<tr align="center"><td><b>' . $this->autogen("warning", $props["lang"]) . "</b></td></tr>" . '<tr><td align="left"><p>'; - return '<tr><td align="left"><p>'; + if (!$props['sibling']) { + return '<strong>' . $this->autogen("warning", $props["lang"]) . "</strong>\n" + . '<p>'; + } + return '<p>'; } - return "</p></td></tr>"; + return "</p>\n"; } public function format_refname_function_text($value) {