cvs: phd /formats xhtml.php /include PhDFormat.class.php
| From: | Hannes Magnusson | Date: | Fri, 02 Jan 2009 00:44:58 +0000 |
| Subject: | cvs: phd /formats xhtml.php /include PhDFormat.class.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2915@lists.php.net to get a copy of this message | ||
bjori Fri Jan 2 00:44:58 2009 UTC
Modified files:
/phd/formats xhtml.php
/phd/include PhDFormat.class.php
Log:
MFB: Sync all the changes in the last couple of hours
http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.81&r2=1.82&diff_format=u
Index: phd/formats/xhtml.php
diff -u phd/formats/xhtml.php:1.81 phd/formats/xhtml.php:1.82
--- phd/formats/xhtml.php:1.81 Thu Jan 1 21:32:56 2009
+++ phd/formats/xhtml.php Fri Jan 2 00:44:58 2009
@@ -1,5 +1,5 @@
<?php
-/* $Id: xhtml.php,v 1.81 2009/01/01 21:32:56 bjori Exp $ */
+/* $Id: xhtml.php,v 1.82 2009/01/02 00:44:58 bjori Exp $ */
class XHTMLPhDFormat extends PhDFormat {
protected $elementmap = array( /* {{{ */
@@ -124,7 +124,7 @@
'note' => 'span',
),
'informalexample' => 'format_div',
- 'informaltable' => 'table',
+ 'informaltable' => 'format_table',
'indexdiv' => 'format_dl',
'indexentry' => 'dd',
'initializer' => 'format_initializer',
@@ -801,7 +801,7 @@
public function format_methodparam_parameter($open, $name, $attrs) {
if ($open) {
if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
- return ' <tt class="parameter reference">&$';
+ return ' <tt class="parameter reference">&$';
}
return ' <tt class="parameter">$';
}
@@ -816,7 +816,7 @@
public function format_parameter($open, $name, $attrs) {
if ($open) {
if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
- return '<i><tt class="parameter reference">&';
+ return '<i><tt class="parameter
reference">&';
}
return '<i><tt class="parameter">';
}
@@ -1107,9 +1107,12 @@
}
public function format_example_content($open, $name, $attrs) {
if ($open) {
- return '<div class="example-contents"><p>';
+ $retval = $this->escapePara() . '<div
class="example-contents"><p>';
+ ++$this->openPara;
+ return $retval;
}
- return "</p></div>";
+ --$this->openPara;
+ return "</p></div>" . $this->restorePara();
}
public function format_programlisting($open, $name, $attrs) {
if ($open) {
@@ -1119,23 +1122,23 @@
$this->role = false;
}
- return '<div class="example-contents">';
+ return $this->escapePara() . '<div
class="example-contents">';
}
$this->role = false;
- return "</div>\n";
+ return "</div>\n" . $this->restorePara();
}
public function format_programlisting_text($value, $tag) {
- return $this->CDATA($value);
+ return nl2br($value);
}
public function format_screen($open, $name, $attrs) {
if ($open) {
- return '<div class="example-contents"><pre>';
+ return '<div class="example-contents screen">';
}
- return '</pre></div>';
+ return '</div>';
}
public function format_constant($open, $name, $attrs) {
if ($open) {
- return "<b><tt>";
+ return "<b><tt class=\"constant\">";
}
return "</tt></b>";
}
@@ -1167,9 +1170,13 @@
}
public function format_note($open, $name, $attrs, $props) {
if ($open) {
- return
'<blockquote><p>'.$this->admonition_title("note",
$props["lang"]). ': ';
+ $retval = $this->escapePara() .
'<blockquote><p>'.$this->admonition_title("note",
$props["lang"]). ': ';
+ ++$this->openPara;
+ return $retval;
}
- return "</p></blockquote>";
+
+ --$this->openPara;
+ return "</p></blockquote>" . $this->restorePara();
}
public function format_note_title($open, $name, $attrs) {
if ($open) {
@@ -1189,8 +1196,10 @@
return "";
}
if ($open) {
+ ++$this->openPara;
return "<p><b>";
}
+ --$this->openPara;
return "</b></p>";
}
public function format_table_title($open, $name, $attrs, $props) {
@@ -1264,7 +1273,7 @@
public function format_table($open, $name, $attrs, $props) {
if ($open) {
$this->cchunk["table"] = true;
- return '<table class="doctable formaltable">';
+ return $this->escapePara() . '<table class="doctable '.$name.
'">';
}
$this->cchunk["table"] = false;
$str = "";
@@ -1288,7 +1297,7 @@
$this->cchunk["tablefootnotes"] =
$this->dchunk["tablefootnotes"];
}
- return "$str</table>\n";
+ return "$str</table>\n" . $this->restorePara();
}
public function format_tgroup($open, $name, $attrs) {
if ($open) {
@@ -1309,7 +1318,31 @@
$retval .= ' valign="' .$attrs["valign"]. '"';
}
if (isset($attrs["colwidth"])) {
- $retval .= ' width="' .((int)$attrs["colwidth"]).
'"';
+ $width = $attrs["colwidth"];
+ if (is_numeric($width)) {
+ $retval .= ' width="' .((int)$width). '"';
+ }
+ // N*
+ elseif(($pos = strpos($width, "*")) !== false) {
+ $cols = $this->getColCount();
+ $length = 100/$cols;
+ if (substr($width, -1) !== "*") {
+ trigger_error("Mixing proportion and fixed measure not implemented",
E_USER_WARNING);
+ }
+ // Standard length
+ elseif($width == "*" || $width == "1*") {
+ }
+ else {
+ $width = (int)substr($width, 0, $pos);
+ $length *= $width;
+ }
+ $retval = ' width="' .$length. '%"';
+
+ }
+ // Npt or Npx or other weird format
+ else {
+ $retval .= ' width="' .htmlentities($attrs["colwidth"],
ENT_QUOTES, "UTF-8"). '"';
+ }
}
return $retval;
}
http://cvs.php.net/viewvc.cgi/phd/include/PhDFormat.class.php?r1=1.11&r2=1.12&diff_format=u
Index: phd/include/PhDFormat.class.php
diff -u phd/include/PhDFormat.class.php:1.11 phd/include/PhDFormat.class.php:1.12
--- phd/include/PhDFormat.class.php:1.11 Sat Nov 1 06:02:04 2008
+++ phd/include/PhDFormat.class.php Fri Jan 2 00:44:58 2009
@@ -1,5 +1,5 @@
<?php
-/* $Id: PhDFormat.class.php,v 1.11 2008/11/01 06:02:04 cweiske Exp $ */
+/* $Id: PhDFormat.class.php,v 1.12 2009/01/02 00:44:58 bjori Exp $ */
abstract class PhDFormat extends PhDHelper {
private $TABLE = array();
@@ -31,17 +31,28 @@
$this->TABLE["colspec"] = array();
}
public function colspec(array $attrs) {
- $colspec = self::getColSpec($attrs);
+ $colspec = self::getColspec($attrs, false);
$this->TABLE["colspec"][$colspec["colnum"]] = $colspec;
return $colspec;
}
- public function getColspec(array $attrs) {
+ public function getColspec(array $attrs, $forRow = true) {
/* defaults */
- $defaults["colname"] = count($this->TABLE["colspec"])+1;
- $defaults["colnum"] = count($this->TABLE["colspec"])+1;
- $defaults["align"] = "left";
-
- return array_merge($defaults, $this->TABLE["defaults"], $attrs);
+ $defaults = array(
+ "colname" => count($this->TABLE["colspec"])+1,
+ "colnum" => count($this->TABLE["colspec"])+1,
+ "align" => "left",
+ );
+
+ $retval = array_merge($defaults, $this->TABLE["defaults"], $attrs);
+ if ($forRow) {
+ foreach($this->TABLE["colspec"] as $colspec) {
+ if ($colspec["colname"] == $retval["colname"]) {
+ $retval = array_merge($retval, $colspec);
+ break;
+ }
+ }
+ }
+ return $retval;
}
public function getColCount() {
return $this->TABLE["cols"];