cvs: phd /formats xhtml.php /themes/php bightml.php phpdotnet.php phpweb.php
| From: | Hannes Magnusson | Date: | Sun, 30 Sep 2007 15:23:40 +0000 |
| Subject: | cvs: phd /formats xhtml.php /themes/php bightml.php phpdotnet.php phpweb.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-108@lists.php.net to get a copy of this message | ||
bjori Sun Sep 30 15:23:40 2007 UTC
Modified files:
/phd/formats xhtml.php
/phd/themes/php phpdotnet.php phpweb.php bightml.php
Log:
- Implemented: indexdiv, indexentry & primaryie
- Implemented: qandaset, qandaentry, question & answer
- Fixed the markup for commands
http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.29&r2=1.30&diff_format=u
Index: phd/formats/xhtml.php
diff -u phd/formats/xhtml.php:1.29 phd/formats/xhtml.php:1.30
--- phd/formats/xhtml.php:1.29 Sat Sep 29 18:18:44 2007
+++ phd/formats/xhtml.php Sun Sep 30 15:23:40 2007
@@ -1,5 +1,5 @@
<?php
-/* $Id: xhtml.php,v 1.29 2007/09/29 18:18:44 bjori Exp $ */
+/* $Id: xhtml.php,v 1.30 2007/09/30 15:23:40 bjori Exp $ */
class XHTMLPhDFormat extends PhDFormat {
protected $elementmap = array( /* {{{ */
@@ -54,7 +54,7 @@
'collab' => 'span',
'collabname' => 'span',
'colspec' => 'format_colspec',
- 'command' => 'span',
+ 'command' => 'strong',
'computeroutput' => 'span',
'constant' => 'format_constant',
'constructorsynopsis' => 'format_methodsynopsis',
@@ -93,6 +93,8 @@
'info' => 'div',
'informalexample' => 'div',
'informaltable' => 'table',
+ 'indexdiv' => 'dl',
+ 'indexentry' => 'dd',
'initializer' => 'format_initializer',
'itemizedlist' => 'ul',
'listitem' => array(
@@ -133,6 +135,7 @@
'partintro' => 'div',
'personname' => 'span',
'preface' => 'format_chunk',
+ 'primaryie' => 'format_suppressed_tags',
'procedure' => 'format_procedure',
'productname' => 'span',
'programlisting' => 'format_programlisting',
@@ -196,6 +199,7 @@
'example' => 'format_bold_paragraph',
'note' => 'format_note_title',
),
+ 'indexdiv' => 'dt',
'legalnotice' => 'h4',
'note' => 'format_note_title',
'procedure' => 'b',
@@ -221,6 +225,10 @@
'warning' => 'div',
'year' => 'span',
'quote' => 'format_quote',
+ 'qandaset' => 'div',
+ 'qandaentry' => 'dl',
+ 'question' => 'dt',
+ 'answer' => 'dd',
); /* }}} */
protected $textmap = array(
'segtitle' => 'format_segtitle_text',
http://cvs.php.net/viewvc.cgi/phd/themes/php/phpdotnet.php?r1=1.16&r2=1.17&diff_format=u
Index: phd/themes/php/phpdotnet.php
diff -u phd/themes/php/phpdotnet.php:1.16 phd/themes/php/phpdotnet.php:1.17
--- phd/themes/php/phpdotnet.php:1.16 Sat Sep 29 15:47:45 2007
+++ phd/themes/php/phpdotnet.php Sun Sep 30 15:23:40 2007
@@ -1,5 +1,5 @@
<?php
-/* $Id: phpdotnet.php,v 1.16 2007/09/29 15:47:45 bjori Exp $ */
+/* $Id: phpdotnet.php,v 1.17 2007/09/30 15:23:40 bjori Exp $ */
class phpdotnet extends PhDHelper {
protected $elementmap = array(
@@ -54,6 +54,10 @@
'section' => 'format_chunk',
'set' => 'format_root_chunk',
'setindex' => 'format_chunk',
+ 'qandaset' => 'format_qandaset',
+ 'qandaentry' => 'format_qandaentry',
+ 'question' => 'format_question',
+ 'answer' => 'format_answer',
);
protected $textmap = array(
'acronym' => 'format_acronym_text',
@@ -329,6 +333,48 @@
return sprintf('<span class="%s %s">%2$s</span>', $tagname,
$type);
}
+ /* FIXME: This function is a crazy performance killer */
+ public function qandaset($stream) {
+ $xml = stream_get_contents($stream);
+
+ libxml_use_internal_errors(true);
+ $doc = new DOMDocument("1.0", "UTF-8");
+ $doc->preserveWhitespace = false;
+ $doc->loadHTML(html_entity_decode('<div>'
.str_replace("<", "&lt;", $xml) .'</div>',
ENT_QUOTES, "UTF-8"));
+ fclose($stream);
+ libxml_clear_errors();
+ libxml_use_internal_errors(false);
+
+ $xpath = new DOMXPath($doc);
+ $nlist = $xpath->query("//html/body/div/dl/dt");
+ $ret = '<div class="qandaset"><ol
class="qandaset_questions">';
+ $i = 0;
+ foreach($nlist as $node) {
+ $ret .= sprintf('<li><a
href="#%s">%s</a></li>', $this->tmp["qandaentry"][$i++],
$node->textContent);
+ }
+
+ return $ret.'</ul>'.$xml.'</div>';
+ }
+ public function format_qandaentry($open, $name, $attrs) {
+ if ($open) {
+ $this->tmp["qandaentry"][] = $attrs[PhDReader::XMLNS_XML]["id"];
+ return '<dl>';
+ }
+ return '</dl>';
+ }
+ public function format_answer($open, $name, $attrs) {
+ if ($open) {
+ return '<dd><a name="'
.end($this->tmp["qandaentry"]).'"></a>';
+ }
+ return "</dd>";
+ }
+ public function format_question($open, $name, $attrs) {
+ if ($open) {
+ return '<dt><strong>';
+ }
+ return '</strong></dt>';
+ }
+
}
/*
http://cvs.php.net/viewvc.cgi/phd/themes/php/phpweb.php?r1=1.11&r2=1.12&diff_format=u
Index: phd/themes/php/phpweb.php
diff -u phd/themes/php/phpweb.php:1.11 phd/themes/php/phpweb.php:1.12
--- phd/themes/php/phpweb.php:1.11 Sat Aug 25 11:10:21 2007
+++ phd/themes/php/phpweb.php Sun Sep 30 15:23:40 2007
@@ -1,5 +1,5 @@
<?php
-/* $Id: phpweb.php,v 1.11 2007/08/25 11:10:21 bjori Exp $ */
+/* $Id: phpweb.php,v 1.12 2007/09/30 15:23:40 bjori Exp $ */
class phpweb extends phpdotnet implements PhDTheme {
protected $streams = array();
@@ -187,6 +187,17 @@
public function __destruct() {
copy("php/manual.php", "php/index.php");
}
+ public function format_qandaset($open, $name, $attrs) {
+ if ($open) {
+ $this->tmp["qandaentry"] = array();
+ $this->appendData(null, PhDReader::OPEN_CHUNK);
+ return '';
+ }
+
+ $stream = array_pop($this->streams);
+ rewind($stream);
+ return parent::qandaset($stream);
+ }
}
/*
http://cvs.php.net/viewvc.cgi/phd/themes/php/bightml.php?r1=1.3&r2=1.4&diff_format=u
Index: phd/themes/php/bightml.php
diff -u phd/themes/php/bightml.php:1.3 phd/themes/php/bightml.php:1.4
--- phd/themes/php/bightml.php:1.3 Fri Aug 10 20:16:14 2007
+++ phd/themes/php/bightml.php Sun Sep 30 15:23:40 2007
@@ -1,5 +1,5 @@
<?php
-/* $Id: bightml.php,v 1.3 2007/08/10 20:16:14 bjori Exp $ */
+/* $Id: bightml.php,v 1.4 2007/09/30 15:23:40 bjori Exp $ */
class bightml extends phpdotnet implements PhDTheme {
public function __construct(array $IDs, $filename, $ext = "html") {
@@ -23,7 +23,21 @@
public function footer() {
fwrite($this->stream, "</body></html>");
}
+ public function format_qandaset($open, $name, $attrs) {
+ if ($open) {
+ $this->tmp["qandaentry"] = array();
+ $this->ostream = $this->stream;
+ $this->stream = fopen("php://temp/maxmemory", "r+");
+ return '';
+ }
+
+ $stream = $this->stream;
+ $this->stream = $this->ostream;
+ unset($this->ostream);
+ rewind($stream);
+ return parent::qandaset($stream);
+ }
}