[git] phd.git branch rsync created. ae0b5c9
| From: | dsp@php.net | Date: | Fri, 02 Mar 2012 14:28:07 +0000 |
| Subject: | [git] phd.git branch rsync created. ae0b5c9 | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-9787@lists.php.net to get a copy of this message | ||
The branch, rsync on phd.git has been created
at ae0b5c94be35de41a41dd2b3bf037bf08f53a032 (commit)
-- Log ----------------------------------------
commit ae0b5c94be35de41a41dd2b3bf037bf08f53a032
Author: Hannes Magnusson <bjori@php.net>
Date: Tue May 18 14:06:39 2010 +0000
Useless ws change to test committing to branch using git-svn cloned from
github \o/
diff --git a/config.php b/config.php
index e1520a0..9daa22e 100644
--- a/config.php
+++ b/config.php
@@ -381,3 +381,4 @@ $OPTIONS["acronyms_file"] =
$OPTIONS["xml_root"]."/entities/acronyms.xml";
* vim600: sw=4 ts=4 syntax=php et
* vim<600: sw=4 ts=4
*/
+
commit e19b791ee1973fac49fd3b95805690f9aed2c789
Author: Gwynne Raskind <gwynne@php.net>
Date: Thu Jul 16 08:10:50 2009 +0000
one more attempt at ridding us of some of those annoying mime types
commit 0f81f1a0a97cd7939a015f3f90f508688be03788
Author: Gwynne Raskind <gwynne@php.net>
Date: Mon Jul 13 12:15:13 2009 +0000
fix a huge number of wrong MIME types. UGH.
commit 297c454d04b6aecd4024497893ab052028f26555
Author: Hannes Magnusson <bjori@php.net>
Date: Thu Apr 17 20:18:23 2008 +0000
MFH: Fixed bug#44690 (Please restore manual main page)
diff --git a/phpdotnet/phd/Theme/PHP/Web.php b/phpdotnet/phd/Theme/PHP/Web.php
index 238ef05..de011bd 100644
--- a/phpdotnet/phd/Theme/PHP/Web.php
+++ b/phpdotnet/phd/Theme/PHP/Web.php
@@ -11,8 +11,16 @@ class phpweb extends phpdotnet {
public function __construct($IDs, $filename, $ext = "php", $chunked = true) {
parent::__construct($IDs, $filename, $ext, $chunked);
$this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext
. DIRECTORY_SEPARATOR;
- if (!file_exists($this->outputdir) || is_file($this->outputdir))
mkdir($this->outputdir) or die("Can't create the cache directory");
- if (!file_exists($this->outputdir . "toc") || is_file($this->outputdir .
"toc")) mkdir($this->outputdir . "toc") or die("Can't create the
toc directory");
+ if (!file_exists($this->outputdir) || is_file($this->outputdir)) {
+ mkdir($this->outputdir) or die("Can't create the cache directory");
+ } else {
+ if (file_exists($this->outputdir . "index.php")) {
+ unlink($this->outputdir . "index.php");
+ }
+ }
+ if (!file_exists($this->outputdir . "toc") || is_file($this->outputdir .
"toc")) {
+ mkdir($this->outputdir . "toc") or die("Can't create the toc
directory");
+ }
}
public function writeChunk($id, $stream) {
rewind($stream);
@@ -203,7 +211,7 @@ manual_header();
return $next;
}
public function __destruct() {
- if (file_exists($this->outputdir . "manual.php")) {
+ if (file_exists($this->outputdir . "manual.php") &&
!file_exists($this->outputdir . "index.php")) {
copy($this->outputdir . "manual.php", $this->outputdir .
"index.php");
}
}
diff --git a/themes/php/phpweb.php b/themes/php/phpweb.php
index 238ef05..de011bd 100644
--- a/themes/php/phpweb.php
+++ b/themes/php/phpweb.php
@@ -11,8 +11,16 @@ class phpweb extends phpdotnet {
public function __construct($IDs, $filename, $ext = "php", $chunked = true) {
parent::__construct($IDs, $filename, $ext, $chunked);
$this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext
. DIRECTORY_SEPARATOR;
- if (!file_exists($this->outputdir) || is_file($this->outputdir))
mkdir($this->outputdir) or die("Can't create the cache directory");
- if (!file_exists($this->outputdir . "toc") || is_file($this->outputdir .
"toc")) mkdir($this->outputdir . "toc") or die("Can't create the
toc directory");
+ if (!file_exists($this->outputdir) || is_file($this->outputdir)) {
+ mkdir($this->outputdir) or die("Can't create the cache directory");
+ } else {
+ if (file_exists($this->outputdir . "index.php")) {
+ unlink($this->outputdir . "index.php");
+ }
+ }
+ if (!file_exists($this->outputdir . "toc") || is_file($this->outputdir .
"toc")) {
+ mkdir($this->outputdir . "toc") or die("Can't create the toc
directory");
+ }
}
public function writeChunk($id, $stream) {
rewind($stream);
@@ -203,7 +211,7 @@ manual_header();
return $next;
}
public function __destruct() {
- if (file_exists($this->outputdir . "manual.php")) {
+ if (file_exists($this->outputdir . "manual.php") &&
!file_exists($this->outputdir . "index.php")) {
copy($this->outputdir . "manual.php", $this->outputdir .
"index.php");
}
}
commit 70493b4222f5d6145de6870968c7ee263d92bad9
Author: Hannes Magnusson <bjori@php.net>
Date: Mon Apr 7 05:44:10 2008 +0000
MFH
diff --git a/include/langs/fr.xml b/include/langs/fr.xml
new file mode 100644
index 0000000..4769cde
--- /dev/null
+++ b/include/langs/fr.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- $Revision: 1.1.2.2 $ -->
+<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
+
+<section xml:id="autogen" xml:lang="en">
+ <title>Autogenerated text</title>
+ <variablelist>
+ <varlistentry>
+ <term>toc</term>
+ <listitem>
+ <simpara>Sommaire</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>warning</term>
+ <listitem>
+ <simpara>Avertissement</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>note</term>
+ <listitem>
+ <simpara>Note</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>caution</term>
+ <listitem>
+ <simpara>Attention</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>tip</term>
+ <listitem>
+ <simpara>Astuce</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>par</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Ãdité par</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Exemple #</simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+</section>
+
diff --git a/package.xml b/package.xml
index 9991046..71fc484 100644
--- a/package.xml
+++ b/package.xml
@@ -29,35 +29,18 @@
<active>yes</active>
</developer>
- <date>2008-03-31</date>
+ <date>2008-05-10</date>
<version>
- <release>0.2.3</release>
- <api>0.2.3</api>
+ <release>0.2.4</release>
+ <api>0.2.4</api>
</version>
<stability>
- <release>beta</release>
+ <release>snapshot</release>
<api>beta</api>
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
<notes>
- - Added initial hCalendar support for <author>. (Hannes)
- - Added initial eRDF support for <refentry>. (Hannes)
- - Added support for <footnote> and <footnoteref>. (Gwynne, Hannes)
- - Added anchor generation for various elements. (Hannes)
- - Added option (-s/--skip) to skip rendering of chunks. (Hannes)
- - Added option (-o/--output) to specify output directory (FR#43193). (Richard)
- - Added support for <sect4> titles . (Gwynne)
- - Added an 'infdec' role to <literal> in XHTML. (Gwynne)
- - Fixed couple of typos in PhD info messages. (Richard Q.)
- - Reformatted package.xml for readability and consistency. (Gwynne)
- - Merged README.RENDERER into README and updated README with current information. (Gwynne)
- - Gwynne is a developer of PhD, unfortunately. (Gwynne)
- - Made 'Example #' text localizeable. (Gwynne)
- - Added Russion support (for autogenerated texts). (Tony)
- - Updated translations:
- - Japanese (Masahiro)
- - Brazilian Portuguese (Felipe)
- - German (Mark)
+ - Added French support (for autogenerated texts). (Yannick)
</notes>
<contents>
@@ -72,6 +55,7 @@
<file baseinstalldir="phd" name="include/langs/cs.xml"
role="php"/>
<file baseinstalldir="phd" name="include/langs/de.xml"
role="php"/>
<file baseinstalldir="phd" name="include/langs/en.xml"
role="php"/>
+ <file baseinstalldir="phd" name="include/langs/fr.xml"
role="php"/>
<file baseinstalldir="phd" name="include/langs/it.xml"
role="php"/>
<file baseinstalldir="phd" name="include/langs/ja.xml"
role="php"/>
<file baseinstalldir="phd" name="include/langs/pl.xml"
role="php"/>
@@ -266,6 +250,39 @@
</notes>
</release>
+ <release>
+ <version>
+ <release>0.2.3</release>
+ <api>0.2.3</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2008-03-31</date>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
+ <notes>
+ - Added initial hCalendar support for <author>. (Hannes)
+ - Added initial eRDF support for <refentry>. (Hannes)
+ - Added support for <footnote> and <footnoteref>. (Gwynne,
Hannes)
+ - Added anchor generation for various elements. (Hannes)
+ - Added option (-s/--skip) to skip rendering of chunks. (Hannes)
+ - Added option (-o/--output) to specify output directory (FR#43193). (Richard)
+ - Added support for <sect4> titles . (Gwynne)
+ - Added an 'infdec' role to <literal> in XHTML. (Gwynne)
+ - Fixed couple of typos in PhD info messages. (Richard Q.)
+ - Reformatted package.xml for readability and consistency. (Gwynne)
+ - Merged README.RENDERER into README and updated README with current information. (Gwynne)
+ - Gwynne is a developer of PhD, unfortunately. (Gwynne)
+ - Made 'Example #' text localizeable. (Gwynne)
+ - Added Russion support (for autogenerated texts). (Tony)
+ - Updated translations:
+ - Japanese (Masahiro)
+ - Brazilian Portuguese (Felipe)
+ - German (Mark)
+ </notes>
+ </release>
+
</changelog>
</package>
diff --git a/phpdotnet/phd/data/langs/fr.xml b/phpdotnet/phd/data/langs/fr.xml
new file mode 100644
index 0000000..4769cde
--- /dev/null
+++ b/phpdotnet/phd/data/langs/fr.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- $Revision: 1.1.2.2 $ -->
+<!-- EN-Revision: 1.4 Maintainer: yannick Status: ready -->
+
+<section xml:id="autogen" xml:lang="en">
+ <title>Autogenerated text</title>
+ <variablelist>
+ <varlistentry>
+ <term>toc</term>
+ <listitem>
+ <simpara>Sommaire</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>warning</term>
+ <listitem>
+ <simpara>Avertissement</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>note</term>
+ <listitem>
+ <simpara>Note</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>caution</term>
+ <listitem>
+ <simpara>Attention</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>tip</term>
+ <listitem>
+ <simpara>Astuce</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>par</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Ãdité par</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Exemple #</simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+</section>
+
commit 62d32e6697030d6a1706f9f9795e35bae46a3ddb
Author: Hannes Magnusson <bjori@php.net>
Date: Tue Apr 1 17:22:15 2008 +0000
MFH
diff --git a/README b/README
index c08db71..5a780de 100644
--- a/README
+++ b/README
@@ -1,33 +1,71 @@
PhD - PHP DocBook
-Copyright(c) 2007 Gwynne Raskind and Hannes Magnusson
+Copyright(c) 2007-2008 The PHP Documentation Team
All Rights Reserved.
+<bjori@php.net>
<gwynne@php.net>
$Id$
-At this time, all code and ideas here are completely experimental and untested.
-Don't even pretend you know what you're doing in here unless you're one of the
-authors. Please do ALL discussion inside the RFC/ directory and leave the rest
-of the filespace clean. More comments and information to come.
-
-IMPORTANT
-At the moment, the code relies on the following:
- - PHP 5.2.3 or later (including 5.2.4-dev). NOT COMPATIBLE WITH PHP 6.
+At the moment, the code depends upon the following:
+ - PHP 5.2.3 or later. PHP 5.3 is recommended. PHP 6 is unsupported, but
+ might work.
- An available CLI binary.
- - SQLite 3, using the PDO driver.
- - PCRE.
- - DOM and libXML2.
- - register_globals, magic_quotes_*, and safe_mode OFF.
- - The "nowdoc" patch for PHP_5_2, available at:
- <http://phpdoc.gwynne.dyndns.org/nowdocs/PHP_5_2.patch>
-
- I recognize the annoyance and confusion involved here; if nowdocs aren't
- implemented in mainline PHP by 5.3, I'll drop them completely and live
- without. However, PhD currently serves as a real-use case for nowdocs,
- and I'd like to have this be their chance to prove their worth. Until
- that decision is made, I'll make every effort to make their use less of a
- hassle for those who can't compile their own PHP.
-
-
-
-vim600: sw=4 ts=4 et
-vim<600: sw=4 ts=4
+ - DOM, libXML2, and xmlreader.
+
+
+Installing the PhD renderer:
+ From Release ball:
+ pear install http://doc.php.net/phd/PhD-x.y.z.tgz
+ # Where x.y.z is the version number, i.e. 0.2.3
+
+ From CVS:
+ cvs -d:pserver:cvsread@cvs.php.net/repository co phd
+ cd phd
+ pear install -f package.xml
+
+After installing PhD you can use the
phd command
+to render the documentations.
+Currently phd will use the current working directory to render the
+bightml.html file, create a html/ folder for the chunkedhtml and
+php/ folder for the phpweb theme.
+
+
+Rendering the documentations for the first time:
+ WINDOWS:
+ #1) cd c:\
+ #2) cvs -d:pserver:cvsread@cvs.php.net/repository co phpdoc
+ #3) cd phpdoc
+ #4) php configure.php
+ (Using PHP5.3:)
+ #5) phd --docbook c:\phpdoc\.manual.xml
+ (Using PHP prior to 5.3:)
+ #5-old) phd c:\phpdoc\
+
+ *NIX:
+ #1) cd ~
+ #2) cvs -d:pserver:cvsread@cvs.php.net/repository co phpdoc
+ #3) cd phpdoc
+ #4) php configure.php
+ (Using PHP5.3:)
+ #5) phd --docbook ~/phpdoc/.manual.xml
+ (Using PHP prior to 5.3:)
+ #5-old) phd -d ~/phpdoc/.manual.xml
+ NOTE: The short form works on PHP5.3 too
+
+
+This will create
+ "php" directory containing the "phpweb" files
+ NOTE: You CANNOT view these files without a phpweb mirror running.
+ See http://doc.php.net/wiki/phd/view#viewing_the_phpfolder
+ "html" direcotry containing the "downloadable chunked html" files
+ NOTE: Do NOT move these files onto your webserver. Just double click
+ them and your browser will open and show you the content
+ "bightml.html" file, which is the "downloadable bightml" file
+
+Now edit the XML files as you wish in the phpdoc folder.
+To build the documentation again follow the instructions above, skipping step#2.
+
+The phd command optionally takes more arguments.
+For information about those arguments please type phd -h
+
+
+- The PHP Documentation team
diff --git a/build.php b/build.php
index 3a9a958..cc7c339 100644
--- a/build.php
+++ b/build.php
@@ -2,40 +2,22 @@
<?php
/* $Id$ */
-function err($no, $str, $file, $line) {
- global $notify;
- if (strpos($str, "No mapper") !== false) {
-// $notify->update("Another missing function", strstr($str,
"'"))->show();
- return false;
- }
-
- $err = new PHNotify("Something wrong!", "$str\n$file:$line\n",
"dialog-error");
- $err
- ->urgency(PHNotify::URGENCY_CRITICAL)
- ->timeout(PHNotify::EXPIRES_NEVER)
- ->hint("x", 1680/2)->hint("y", 1050/2)
- ->show();
- return false;
-}
-
-if ($err = extension_loaded("phnotify")) {
- $notify = new PHNotify("Starting build");
- $notify->urgency(PHNotify::URGENCY_LOW)->hint("x",
1680)->hint("y", 10)->show();
- $start = microtime(true);
- set_error_handler("err");
-}
-
+/* {{{ Find the $ROOT directory of PhD
+ @php_dir@ will be replaced by the pear package manager
+ If @php_dir@ however hasn't been replaced by anything,
+ fallback to the dir containing this file */
$ROOT = "@php_dir@/phd";
if ($ROOT == "@php_dir"."@/phd") {
$ROOT = dirname(__FILE__);
}
+/* }}} */
(@include $ROOT."/config.php")
&& isset($OPTIONS)
&& is_array($OPTIONS)
&& isset($OPTIONS["output_format"], $OPTIONS["output_theme"])
&& is_array($OPTIONS["output_theme"])
- or die("Invalid configuration/file not found.\nYou need to run setup/setup.php
first\n");
+ or die("Invalid configuration/file not found.\nThis should never happen, did you edit
config.php yourself?\n");
require $ROOT. "/include/PhDReader.class.php";
require $ROOT. "/include/PhDPartialReader.class.php";
@@ -43,24 +25,46 @@ require $ROOT. "/include/PhDHelper.class.php";
require $ROOT. "/include/PhDFormat.class.php";
require $ROOT. "/include/PhDTheme.class.php";
-if ($OPTIONS["index"]) {
+/* {{{ Build the .ser file names to allow multiple sources for PHD. */
+$OPTIONS['index_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR .
'.index_' . basename($OPTIONS['xml_file'], '.xml') . '.ser';
+$OPTIONS['refnames_location'] = $OPTIONS['xml_root'] . DIRECTORY_SEPARATOR .
'.refnames_' . basename($OPTIONS['xml_file'], '.xml') .
'.ser';
+/* }}} */
+
+/* {{{ Index the DocBook file or load from .ser cache files
+ NOTE: There are two cache files (where * is the basename of the XML source file):
+ - index_*.ser (containing the ID infos)
+ - refnames_*.ser (containing <refname> => File ID) */
+if (!$OPTIONS["index"] && (file_exists($OPTIONS['index_location'])
&& file_exists($OPTIONS['refnames_location']))) {
+ /* FIXME: Load from sqlite db? */
+ if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
+ v("Unserializing cached index files...\n");
+ }
+ $IDs = unserialize(file_get_contents($OPTIONS['index_location']));
+ $REFS = unserialize(file_get_contents($OPTIONS['refnames_location']));
+ if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
+ v("Unserialization done\n");
+ }
+} else {
if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
v("Indexing...\n");
}
+ /* This file will "return" an $IDs & $REFS array */
require $ROOT. "/mktoc.php";
- if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
- v("Indexing done\n");
+
+ file_put_contents($OPTIONS['index_location'], $ids = serialize($IDs));
+ file_put_contents($OPTIONS['refnames_location'], $refs = serialize($REFS));
+
+ $IDs2 = unserialize($ids);
+ $REFS2 = unserialize($refs);
+ if ($IDs !== $IDs2 || $REFS !== $REFS2) {
+ v("WARNING: Serialized representation does not match");
}
- if ($err) {
- $mktoc = microtime(true);
- $notify
- ->update("mktoc finished", sprintf("mktoc ran for
<b>%d</b> sec", $mktoc-$start))
- ->show();
+ if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
+ v("Indexing done\n");
}
-} else {
- /* FIXME: Load from sqlite db? */
}
+/* }}} */
foreach($OPTIONS["output_format"] as $output_format) {
if ($OPTIONS["verbose"] & VERBOSE_FORMAT_RENDERING) {
@@ -72,11 +76,14 @@ foreach($OPTIONS["output_format"] as $output_format) {
break;
}
+ // {{{ Initialize the output format and fetch the methodmaps
require $ROOT. "/formats/$output_format.php";
- $format = new $classname($IDs);
+ $format = new $classname(array($IDs, $REFS));
$formatmap = $format->getElementMap();
$formattextmap = $format->getTextMap();
+ /* }}} */
+ /* {{{ initialize output themes and fetch the methodmaps */
$themes = $elementmaps = $textmaps = array();
foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) {
is_dir($ROOT. "/themes/$theme") or die("Can't find the
'$theme' theme");
@@ -88,8 +95,9 @@ foreach($OPTIONS["output_format"] as $output_format) {
$themename = basename($themename);
require_once $ROOT. "/themes/$theme/$themename.php";
switch($theme) {
+ // FIXME: This is stupid and definetly does not belong in here.
case "php":
- $themes[$themename] = new $themename($IDs,
+ $themes[$themename] = new $themename(array($IDs, $REFS),
array(
"version" => $OPTIONS["version_info"],
"acronym" => $OPTIONS["acronyms_file"],
@@ -97,10 +105,10 @@ foreach($OPTIONS["output_format"] as $output_format) {
);
break;
default:
- $themes[$themename] = new $themename($IDs);
+ $themes[$themename] = new $themename(array($IDs, $REFS));
}
- // WARNING: this needs to go away when we add support for
+ // FIXME: this needs to go away when we add support for
// things other than xhtml
$themes[$themename]->registerFormat($format);
@@ -118,11 +126,24 @@ foreach($OPTIONS["output_format"] as $output_format) {
}
}
+ /* }}} */
- if (!empty($OPTIONS["render_ids"])) {
+ /* {{{ Initialize the PhD[Partial]Reader */
+ if (!empty($OPTIONS["render_ids"]) || !empty($OPTIONS["skip_ids"])) {
+ $idlist = $OPTIONS["render_ids"]+$OPTIONS["skip_ids"];
if ($OPTIONS["verbose"] & VERBOSE_RENDER_STYLE) {
v("Running partial build\n");
}
+ if (!is_array($idlist)) {
+ $idlist = array($idlist => 1);
+ }
+ foreach($idlist as $id => $notused) {
+ if (!isset($IDs[$id])) {
+ v("Unknown ID %s, bailing\n", $id);
+ exit(1);
+ }
+ }
+
$reader = new PhDPartialReader($OPTIONS);
} else {
if ($OPTIONS["verbose"] & VERBOSE_RENDER_STYLE) {
@@ -130,13 +151,14 @@ foreach($OPTIONS["output_format"] as $output_format) {
}
$reader = new PhDReader($OPTIONS);
}
+ /* }}} */
while($reader->read()) {
$nodetype = $reader->nodeType;
switch($nodetype) {
case XMLReader::ELEMENT:
- case XMLReader::END_ELEMENT:
+ case XMLReader::END_ELEMENT: /* {{{ */
$nodename = $reader->name;
$open = $nodetype == XMLReader::ELEMENT;
$isChunk = $reader->isChunk;
@@ -158,7 +180,7 @@ foreach($OPTIONS["output_format"] as $output_format) {
}
if ($tag) {
if (strncmp($tag, "format_", 7)) {
- $retval = $themes[$theme]->transformFromMap($open, $tag, $nodename,
$props);
+ $retval = $themes[$theme]->transformFromMap($open, $tag, $nodename,
$attrs, $props);
if ($retval !== false) {
$themes[$theme]->appendData($retval, $isChunk);
$skip[] = $theme;
@@ -185,7 +207,7 @@ foreach($OPTIONS["output_format"] as $output_format) {
$tag = $reader->notXPath($tag);
}
if (strncmp($tag, "format_", 7)) {
- $retval = $format->transformFromMap($open, $tag, $nodename, $props);
+ $retval = $format->transformFromMap($open, $tag, $nodename, $attrs,
$props);
foreach($themes as $name => $theme) {
if (!in_array($name, $skip)) {
$theme->appendData($retval, $isChunk);
@@ -203,8 +225,9 @@ foreach($OPTIONS["output_format"] as $output_format) {
}
}
break;
+ /* }}} */
- case XMLReader::TEXT:
+ case XMLReader::TEXT: /* {{{ */
$skip = array();
$value = $reader->value;
$parentname = $reader->getParentTagName();
@@ -245,22 +268,26 @@ foreach($OPTIONS["output_format"] as $output_format) {
}
}
break;
+ /* }}} */
- case XMLReader::CDATA:
+ case XMLReader::CDATA: /* {{{ */
$value = $reader->value;
$retval = $format->CDATA($value);
foreach($themes as $name => $theme) {
$theme->appendData($retval, false);
}
break;
+ /* }}} */
case XMLReader::WHITESPACE:
- case XMLReader::SIGNIFICANT_WHITESPACE:
+ case XMLReader::SIGNIFICANT_WHITESPACE: /* {{{ */
$value = $reader->value;
foreach($themes as $name => $theme) {
$theme->appendData($value, false);
}
break;
+ /* }}} */
+
case XMLReader::COMMENT:
case XMLReader::DOC_TYPE:
/* swallow it */
@@ -278,18 +305,10 @@ foreach($OPTIONS["output_format"] as $output_format) {
v("Finished rendering\n");
}
- if ($err) {
- $end = microtime(true);
- $notify
- ->update(
- "PhD build finished",
- sprintf("mktoc build: <b>%d</b> sec\nPhD build :
<b>%d</b> sec\n--\nTotal time: <b>%d</b> seconds\n", $mktoc-$start,
$end-$mktoc, $end-$start))
- ->show();
- }
} // foreach($OPTIONS["output_thtemes"])
/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
+* vim600: sw=4 ts=4 syntax=php et
* vim<600: sw=4 ts=4
*/
diff --git a/config.php b/config.php
index 703614b..e1520a0 100644
--- a/config.php
+++ b/config.php
@@ -1,11 +1,13 @@
<?php
/* $Id$ */
+/* {{{ Print messages to stderr: v("printf-format-text", $arg1, ...) */
function v($msg) {
$args = func_get_args();
$args[0] = date($GLOBALS["OPTIONS"]["date_format"]);
vfprintf(STDERR, "[%s] $msg", $args);
}
+/* }}} */
define('VERBOSE_INDEXING', 0x01);
define('VERBOSE_FORMAT_RENDERING', 0x02);
@@ -16,10 +18,11 @@ define('VERBOSE_PARTIAL_CHILD_READING', 0x20);
define('VERBOSE_TOC_WRITING', 0x40);
define('VERBOSE_CHUNK_WRITING', 0x80);
-define('VERBOSE_ALL',VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_PARTIAL_CHILD_READING|VERBOSE_TOC_WRITING|VERBOSE_CHUNK_WRITING);
+define('VERBOSE_ALL', 0xFF);
-define("PHD_VERSION", "0.2.1");
+define("PHD_VERSION", "0.2.3");
+/* {{{ Default $OPTIONS */
$OPTIONS = array (
'output_format' => array('xhtml'),
'output_theme' => array(
@@ -42,26 +45,34 @@ $OPTIONS = array (
'enforce_revisions' => false,
'compatibility_mode' => true,
'build_log_file' => 'none',
- 'debug' => true,
- 'verbose' =>
VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_TOC_WRITING,
+ 'verbose' => VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING),
'date_format' => "H:i:s",
'render_ids' => array(
),
+ 'skip_ids' => array(
+ ),
+ 'output_dir' => '.',
);
+/* }}} */
+/* {{{ getopt() options */
$opts = array(
"format:" => "f:", // The format to render (xhtml, pdf...)
"theme:" => "t:", // The theme to render (phpweb, bightml..)
"index:" => "i:", // Re-index or load from cache
"docbook:" => "d:", // The Docbook XML file to render from (.manual.xml)
- "partial:" => "p:", // The ID to render (optionally ignoring its
childrens)
+ "output:" => "o:", // The output directory
+ "partial:" => "p:", // The ID to render (optionally ignoring its
children)
+ "skip:" => "s:", // The ID to skip (optionally skipping its children
too)
"verbose:" => "v", // Adjust the verbosity level
+ "list::" => "l::", // List supported themes/formats
"version" => "V", // Print out version information
"help" => "h", // Print out help
);
+/* }}} */
-/* Fix for Windows prior to PHP5.3 */
+/* {{{ Workaround/fix for Windows prior to PHP5.3 */
if (!function_exists("getopt")) {
function getopt($short, $long) {
v("I'm sorry, you are running an operating system that does not support
getopt()\n");
@@ -70,15 +81,17 @@ if (!function_exists("getopt")) {
return array();
}
}
+/* }}} */
$args = getopt(implode("", array_values($opts)), array_keys($opts));
if($args === false) {
v("Something happend with getopt(), please report a bug\n");
- exit(-1);
+ exit(1);
}
$verbose = 0;
$docbook = false;
+
foreach($args as $k => $v) {
switch($k) {
/* {{{ Docbook file */
@@ -86,11 +99,11 @@ foreach($args as $k => $v) {
case "docbook":
if (is_array($v)) {
v("Can only parse one file at a time\n");
- exit(-1);
+ exit(1);
}
if (!file_exists($v) || is_dir($v) || !is_readable($v)) {
v("'%s' is not a readable docbook file\n", $v);
- exit(-1);
+ exit(1);
}
$OPTIONS["xml_root"] = dirname($v);
$OPTIONS["xml_file"] = $v;
@@ -98,12 +111,28 @@ foreach($args as $k => $v) {
break;
/* }}} */
+ /* {{{ Output location */
+ case "o":
+ case "output":
+ if (is_array($v)) {
+ v("Only a single location can be supplied\n");
+ exit(1);
+ }
+ @mkdir($v, 0777, true);
+ if (!is_dir($v) || !is_readable($v)) {
+ v("'%s' is not a valid directory\n", $v);
+ exit(1);
+ }
+ $OPTIONS["output_dir"] = $v;
+ break;
+ /* }}} */
+
/* {{{ Build format */
case "f":
case "format":
if ($v != "xhtml") {
v("Only xhtml is supported at this time\n");
- exit(-1);
+ exit(1);
}
break;
/* }}} */
@@ -113,7 +142,7 @@ foreach($args as $k => $v) {
case "index":
if (is_array($v)) {
v("You cannot pass %s more than once\n", $k);
- exit(-1);
+ exit(1);
}
switch ($v) {
case "yes":
@@ -128,8 +157,48 @@ foreach($args as $k => $v) {
break;
default:
v("yes/no || true/false || 1/0 expected\n");
- exit(-1);
+ exit(1);
+ }
+ break;
+ /* }}} */
+
+ /* {{{ Print out a list of formats/themes */
+ case "l":
+ case "list":
+ /* FIXME: This list should be created dynamically */
+ foreach((array)$v as $val) {
+ switch($val) {
+ case "f":
+ case "format":
+ case "formats":
+ echo "Supported formats:\n";
+ echo "\txhtml\n";
+ break;
+
+ case "t":
+ case "theme":
+ case "themes":
+ echo "Supported themes:\n";
+ echo "\tphpweb\n";
+ echo "\tchunkedhtml\n";
+ echo "\tbightml\n";
+ break;
+
+ default:
+ echo "Unknown list type '$val'\n";
+ /* break omitted intentionally */
+
+ case false:
+ echo "Supported formats:\n";
+ echo "\txhtml\n";
+ echo "Supported themes:\n";
+ echo "\tphpweb\n";
+ echo "\tchunkedhtml\n";
+ echo "\tbightml\n";
+ break;
+ }
}
+ exit(0);
break;
/* }}} */
@@ -151,6 +220,24 @@ foreach($args as $k => $v) {
break;
/* }}} */
+ /* {{{ Skip list */
+ case "s":
+ case "skip":
+ foreach((array)$v as $i => $val) {
+ $recursive = true;
+ if (strpos($val, "=") !== false) {
+ list($val, $recursive) = explode("=", $val);
+
+ if (!is_numeric($recursive) && defined($recursive)) {
+ $recursive = constant($recursive);
+ }
+ $recursive = (bool) $recursive;
+ }
+ $OPTIONS["skip_ids"][$val] = $recursive;
+ }
+ break;
+ /* }}} */
+
/* {{{ Output themes */
case "t":
case "theme":
@@ -167,8 +254,8 @@ foreach($args as $k => $v) {
}
break;
default:
- v("Unkown theme '%s'\n", $val);
- exit(-1);
+ v("Unknown theme '%s'\n", $val);
+ exit(1);
}
}
break;
@@ -183,7 +270,7 @@ foreach($args as $k => $v) {
} elseif (is_numeric($const)) {
$verbose |= (int)$const;
} else {
- v("Unkown option passed to --$k, $const\n");
+ v("Unknown option passed to --$k, $const\n");
}
}
}
@@ -201,59 +288,76 @@ foreach($args as $k => $v) {
$OPTIONS["verbose"] = $verbose;
break;
/* }}} */
-
+
+ /* {{{ Version info */
case "V":
case "version":
v("PhD version: %s\n", PHD_VERSION);
- v("Copyright (c) 2007 The PHP Documentation Group\n");
+ v("Copyright (c) 2008 The PHP Documentation Group\n");
exit(0);
+ /* }}} */
+ /* {{{ Help/usage info */
case "usage":
case "help":
case "h":
echo "PhD version: " .PHD_VERSION;
- echo "\nCopyright (c) 2007 The PHP Documentation Group\n
+ echo "\nCopyright (c) 2008 The PHP Documentation Group\n
-v
- --versbose <int> Adjusts the verbosity level.
+ --verbose <int> Adjusts the verbosity level
-f <formatname>
--format <formatname> The build format to use
-t <themename>
--theme <themename> The theme to use
- -i
- --index Index before rendering or load from cache [NOTE: Not supported yet]
+ -i <bool>
+ --index <bool> Index before rendering (default) or load from cache (false)
-d <filename>
--docbook <filename> The Docbook file to render from
-p <id[=bool]>
- --partial <id[=bool]> The ID to render, optionally ignoring its children pages
(default to true; render childrens)
+ --partial <id[=bool]> The ID to render, optionally skipping its children chunks
(default to true; render children)
+ -s <id[=bool]>
+ --skip <id[=bool]> The ID to skip, optionally skipping its children chunks (default
to true; skip children)
+ -l <formats/themes>
+ --list <formats/themes> Print out the supported formats/themes (default: both)
+ -o <directory>
+ --output <directory> The output directory (default: .)
-V
--version Print the PhD version information
-h
--help This help
-All options can be passed multiple times for greater affect.
+Most options can be passed multiple times for greater affect.
NOTE: Long options are only supported using PHP5.3\n";
exit(0);
break;
+ /* }}} */
+ /* {{{ Unsupported option this should *never* happen */
default:
v("Hmh, something weird has happend, I don't know this option");
var_dump($k, $v);
- exit(-1);
+ exit(1);
+ /* }}} */
}
}
-if (!$docbook) {
+/* {{{ BC for PhD 0.0.* (and PHP5.2 on Windows)
+ i.e. `phd path/to/.manual.xml */
+if (!$docbook && $argc > 1) {
$arg = $argv[$argc-1];
if (is_dir($arg)) {
$OPTIONS["xml_root"] = $arg;
- $OPTIONS["xml_file"] = $arg . "/.manual.xml";
+ $OPTIONS["xml_file"] = $arg . DIRECTORY_SEPARATOR . ".manual.xml";
} elseif (is_file($arg)) {
$OPTIONS["xml_root"] = dirname($arg);
$OPTIONS["xml_file"] = $arg;
}
}
+/* }}} */
+/* {{{ If no docbook file was passed, ask for it
+ This loop should be removed in PhD 0.3.0, and replaced with a fatal errormsg */
while (!is_dir($OPTIONS["xml_root"]) || !is_file($OPTIONS["xml_file"])) {
print "I need to know where you keep your '.manual.xml' file (I didn't find
it in " . $OPTIONS["xml_root"] . "): ";
$root = trim(fgets(STDIN));
@@ -265,12 +369,15 @@ while (!is_dir($OPTIONS["xml_root"]) ||
!is_file($OPTIONS["xml_file"])) {
$OPTIONS["xml_root"] = $root;
}
}
+/* }}} */
+
+/* This needs to be done in *all* cases! */
+$OPTIONS["output_dir"] = realpath($OPTIONS["output_dir"]) .
DIRECTORY_SEPARATOR;
$OPTIONS["version_info"] =
$OPTIONS["xml_root"]."/phpbook/phpbook-xsl/version.xml";
$OPTIONS["acronyms_file"] =
$OPTIONS["xml_root"]."/entities/acronyms.xml";
/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
+* vim600: sw=4 ts=4 syntax=php et
* vim<600: sw=4 ts=4
*/
-
diff --git a/convert.php b/convert.php
deleted file mode 100644
index e69de29..0000000
diff --git a/ext/indexer_raq/indexer.php b/ext/indexer_raq/indexer.php
new file mode 100644
index 0000000..31b5eb6
--- /dev/null
+++ b/ext/indexer_raq/indexer.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * array addNode ( array &ar1, string $id [, string $parentid] )
+ **/
+function addNode(array &$a_Nodes, $s_ID, $s_ParentID = 'ROOT') {
+ $a_Nodes[$s_ID] = array(
+ 'ID' => $s_ID,
+ 'Up' => &$a_Nodes[$s_ParentID],
+ );
+ $a_Nodes[$s_ParentID]['Dn'][$s_ID] = &$a_Nodes[$s_ID];
+ return $a_Nodes[$s_ID];
+}
+
+// Quick hack until indexer is in /phd with config and build
+$ROOT = dirname(__FILE__) . '/../..';
+
+// Load the config (to get where the XML file is.
+(@include $ROOT."/config.php")
+ && isset($OPTIONS)
+ && is_array($OPTIONS)
+ or die("Invalid configuration/file not found.\nThis should never happen, did you edit
config.php yourself?\n");
+
+
+// Define an empty tree.
+$a_Nodes = array(
+ 'ROOT' => array(
+ 'ID' => 'ROOT',
+ ),
+);
+
+// Define the movable node.
+$a_CurrentNode = $a_Nodes['ROOT'];
+
+/*
+
+(DONE) I read an XML node.
+
+(DONE) If the nodeType is ELEMENT and the XML node has an ID, then add a new
+ node to the tree and use this new node as the current node.
+
+(DONE) If the nodeType is 15 and the stack says that this was an ID'd node,
+ then set the currentparent to the currentparent's parent.
+
+(TODO) Log values from specific nodes to the current ID node - like
+ title/refname/refpurpose/etc.
+
+(TODO) The ID should be normalised. Pointers please.
+*/
+
+$dt_Start = microtime(true);
+$o_XML = new XMLReader();
+$o_XML->open($OPTIONS['xml_file'], 'UTF-8');
+while($o_XML->read()) {
+ switch($o_XML->nodeType) {
+ case XMLReader::ELEMENT: // We have an element.
+ // Does it have an ID?
+ if ($o_XML->hasAttributes && $o_XML->moveToAttributeNs('id',
'http://www.w3.org/XML/1998/namespace')) {
+ // Log a new node.
+ $a_CurrentNode = addNode($a_Nodes, $o_XML->value,
$a_CurrentNode['ID']);
+ }
+ break;
+
+ case XMLReader::END_ELEMENT : // We have finished with the element.
+ // Does it have an ID?
+ if ($o_XML->hasAttributes && $o_XML->moveToAttributeNs('id',
'http://www.w3.org/XML/1998/namespace')) {
+ // Move up the stored node tree.
+ $a_CurrentNode = $a_CurrentNode['Up'];
+ }
+ break;
+ }
+}
+echo 'Read XML and added ', count($a_Nodes), ' IDs to node tree in ',
microtime(True) - $dt_Start, PHP_EOL;
+
+$dt_Start = microtime(True);
+reset($a_Nodes);
+do {
+ $a_Prev = prev($a_Nodes);
+ if (False === $a_Prev) {
+ $a_Prev = reset($a_Nodes);
+ }
+ $a_Current = next($a_Nodes);
+ $a_Next = next($a_Nodes);
+ if (False === $a_Next) {
+ $a_Next = reset($a_Nodes);
+ }
+ $a_Nodes[$a_Current['ID']] += array(
+ 'PR' => &$a_Nodes[$a_Prev['ID']],
+ 'NX' => &$a_Nodes[$a_Next['ID']],
+ );
+}
+while('ROOT' !== $a_Next['ID']);
+echo 'Added next/prev values to node tree in ', microtime(True) - $dt_Start, PHP_EOL;
+
+// Store the index locally as to not pollute anything.
+file_put_contents('./index.ser', serialize($a_Nodes));
+
+// Test left and right of function.str-repeat
+$s_ID = 'function.str-repeat';
+echo "{$a_Nodes[$s_ID]['PR']['ID']} << $s_ID >>
{$a_Nodes[$s_ID]['NX']['ID']}", PHP_EOL;
\ No newline at end of file
diff --git a/formats/chm.php b/formats/chm.php
deleted file mode 100644
index e69de29..0000000
diff --git a/formats/pdf.php b/formats/pdf.php
deleted file mode 100644
index e69de29..0000000
diff --git a/formats/plaintext.php b/formats/plaintext.php
deleted file mode 100644
index e69de29..0000000
diff --git a/formats/xchm.php b/formats/xchm.php
deleted file mode 100644
index e69de29..0000000
diff --git a/formats/xhtml.php b/formats/xhtml.php
index 7a872c0..ed0f48e 100644
--- a/formats/xhtml.php
+++ b/formats/xhtml.php
@@ -9,8 +9,11 @@ class XHTMLPhDFormat extends PhDFormat {
'affiliation' => 'format_suppressed_tags',
'alt' => 'format_suppressed_tags',
'article' => 'format_container_chunk',
- 'author' => 'div',
- 'authorgroup' => 'div', /* DocBook-xsl prints out
"by" (i.e. "PHP Manual by ...") */
+ 'author' => array(
+ /* DEFAULT */ 'format_author',
+ 'authorgroup' => 'format_authorgroup_author',
+ ),
+ 'authorgroup' => 'div',
'appendix' => 'format_container_chunk',
'application' => 'span',
'blockquote' => 'blockquote',
@@ -25,8 +28,10 @@ class XHTMLPhDFormat extends PhDFormat {
'co' => 'format_co',
'colophon' => 'format_chunk',
'copyright' => 'format_copyright',
- 'editor' => 'div', /* Docbook-xsl prints "edited
by" */
+ 'editor' => 'format_editor',
'firstname' => 'format_name',
+ 'footnote' => 'format_footnote',
+ 'footnoteref' => 'format_footnoteref',
'surname' => 'format_name',
'othername' => 'format_name',
'optional' => 'span',
@@ -57,7 +62,14 @@ class XHTMLPhDFormat extends PhDFormat {
'colspec' => 'format_colspec',
'command' => 'strong',
'computeroutput' => 'span',
- 'constant' => 'format_constant',
+ /* 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',
@@ -107,7 +119,7 @@ class XHTMLPhDFormat extends PhDFormat {
/* DEFAULT */ 'li',
'varlistentry' => 'format_varlistentry_listitem',
),
- 'literal' => 'i',
+ 'literal' => 'format_literal',
'literallayout' => 'pre',
'manvolnum' => 'format_manvolnum',
'mediaobject' => 'format_mediaobject',
@@ -134,6 +146,8 @@ class XHTMLPhDFormat extends PhDFormat {
/* DEFAULT */ 'p',
'example' => 'format_example_content',
'note' => 'format_note_content',
+ 'footnote' => 'format_footnote_para',
+ 'refsect1' => 'format_refsect1_para',
),
'parameter' => array(
/* DEFAULT */ 'format_parameter',
@@ -141,7 +155,7 @@ class XHTMLPhDFormat extends PhDFormat {
),
'part' => 'format_container_chunk',
'partintro' => 'div',
- 'personname' => 'span',
+ 'personname' => 'format_personname',
'preface' => 'format_chunk',
'primaryie' => 'format_suppressed_tags',
'procedure' => 'format_procedure',
@@ -197,6 +211,7 @@ class XHTMLPhDFormat extends PhDFormat {
'table' => 'format_table',
'term' => 'format_term',
'tfoot' => 'format_th',
+ 'tbody' => 'format_tbody',
'thead' => 'format_th',
'tgroup' => 'format_tgroup',
'tip' => 'format_admonition',
@@ -222,6 +237,7 @@ class XHTMLPhDFormat extends PhDFormat {
'sect1' => 'h2',
'sect2' => 'h3',
'sect3' => 'h4',
+ 'sect4' => 'h5',
'segmentedlist' => 'strong',
'table' => 'format_table_title',
'variablelist' => 'strong',
@@ -276,11 +292,56 @@ class XHTMLPhDFormat extends PhDFormat {
'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',
+
);
- protected $role = false;
- protected $tmp = array();
+ public $role = false;
+ /* Current Chunk variables */
+ protected $cchunk = array();
+ /* Default Chunk variables */
+ protected $dchunk = array(
+ "classsynopsis" => array(
+ "close" => false,
+ "classname" => false,
+ ),
+ "classsynopsisinfo" => array(
+ "implements" => false,
+ "ooclass" => false,
+ ),
+ "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(
+ ),
+ );
public function __construct(array $IDs) {
parent::__construct($IDs);
@@ -292,9 +353,14 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "<font color='red'
size='+3'>/{$args[1]}</font>";
}
- public function transformFromMap($open, $tag, $name, $props) {
+ public function transformFromMap($open, $tag, $name, $attrs, $props) {
if ($open) {
- return '<' .$tag. ' class="' .$name. '"' .
($props["empty"] ? '/' : "") . '>';
+ $idstr = "";
+ if (isset($attrs[PhDReader::XMLNS_XML]["id"])) {
+ $id = $attrs[PhDReader::XMLNS_XML]["id"];
+ $idstr = ' id="' .$id. '" name="' .$id.
'"';
+ }
+ return '<' .$tag. ' class="' .$name. '"' .
($props["empty"] ? '/' : "") . $idstr. '>';
}
return '</' .$tag. '>';
}
@@ -318,21 +384,83 @@ class XHTMLPhDFormat extends PhDFormat {
/* Suppress any content */
return "";
}
-
+
+ public function format_literal($open, $name, $attrs) {
+ if ($open) {
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
+ $this->role = $attrs[PhDReader::XMLNS_DOCBOOK]["role"];
+ } else {
+ $this->role = false;
+ }
+ return '<i>';
+ }
+ $this->role = false;
+ return '</i>';
+ }
+ 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 .= '<span style="text-decoration: overline;">';
+ $str .= substr($value, $p + 1);
+ $str .= '</span>';
+ return $str;
+ default:
+ return $this->TEXT($value);
+ }
+ }
+
public function format_copyright($open, $name, $attrs) {
if ($open) {
return '<div class="'.$name.'">© ';
}
return '</div>';
}
+ public function format_author($open, $name, $attrs, $props) {
+ if ($open) {
+ return '<div class="' .$name. ' vcard">';
+ }
+ return "</div>";
+ }
+ public function format_personname($open, $name, $attrs, $props) {
+ if ($open) {
+ return '<span class="' .$name. ' fn">';
+ }
+ return "</span>";
+ }
public function format_name($open, $name, $attrs) {
if ($open) {
- return ' <span class="'.$name.'">';
+ $class = "";
+ switch($name) {
+ case "firstname":
+ $class = " given-name";
+ break;
+
+ case "surname":
+ $class = " family-name";
+ break;
+
+ case "othername":
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
+ /* We maight want to add support for other roles */
+ switch($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) {
+ case "nickname":
+ $class = " nickname";
+ break;
+ }
+ }
+ break;
+ }
+
+ return ' <span class="' . $name . $class . '">';
}
return '</span> ';
}
public function format_container_chunk($open, $name, $attrs) {
+ $this->cchunk = $this->dchunk;
if ($open) {
return '<div id="' .$attrs[PhDReader::XMLNS_XML]["id"].
'" class="' .$name. '">';
}
@@ -346,27 +474,59 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_chunk($open, $name, $attrs) {
if ($open) {
+ $this->cchunk = $this->dchunk;
if(isset($attrs[PhDReader::XMLNS_XML]["id"])) {
- return '<div id="' .$attrs[PhDReader::XMLNS_XML]["id"].
'" class="' .$name. '">';
+ $class = $name;
+ if ($name === "refentry") {
+ //$class .= " -rel-posting";
+ }
+ return '<div id="' .$attrs[PhDReader::XMLNS_XML]["id"].
'" class="' .$class. '">';
}
return '<div class="' .$name. '">';
}
- return "</div>";
+ $str = "";
+ foreach ($this->cchunk["footnote"] as $k => $note) {
+ $str .= '<div class="footnote">';
+ $str .= '<a name="fnid' .$note["id"]. '"
href="#fn' .$note["id"]. '"><sup>[' .($k + 1).
']</sup></a>';
+ $str .= $note["str"];
+ $str .= "</div>\n";
+ }
+ $this->cchunk["footnote"] = $this->dchunk["footnote"];
+
+ return $str. "</div>";
+ }
+ public function format_refsect1_para($open, $name, $attrs, $props) {
+ if ($open) {
+ switch ($props["sibling"]) {
+ case "methodsynopsis":
+ case "constructorsynopsis":
+ case "destructorsynopsis":
+ return '<p class="'.$name.' rdfs-comment">';
+ break;
+
+ default:
+ return '<p class="'.$name.'">';
+ }
+
+ }
+ return '</p>';
}
public function format_refsect($open, $name, $attrs) {
if ($open) {
if(!isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
- $attrs[PhDReader::XMLNS_DOCBOOK] = "unkown";
+ $attrs[PhDReader::XMLNS_DOCBOOK]["role"] = "unknown";
}
- return '<div class="' .$name.' '
.$attrs[PhDReader::XMLNS_DOCBOOK]["role"]. '">';
+ $this->role = $role = $attrs[PhDReader::XMLNS_DOCBOOK]["role"];
+ return '<div class="' .$name.' ' .$role.
'">';
}
+ $this->role = null;
return "</div>\n";
}
public function format_classsynopsisinfo_oointerface($open, $name, $attrs) {
if ($open) {
- if (isset($this->tmp["classsynopsisinfo"]) &&
!isset($this->tmp["classsynopsisinfo"]["implements"])) {
- $this->tmp["classsynopsisinfo"]["implements"] = true;
+ if ($this->cchunk["classsynopsisinfo"]["implements"] === false)
{
+ $this->cchunk["classsynopsisinfo"]["implements"] = true;
return '<span class="'.$name.'">implements ';
}
return '<span class="'.$name.'">, ';
@@ -376,8 +536,8 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_classsynopsisinfo_ooclass_classname($open, $name, $attrs) {
if ($open) {
- if (isset($this->tmp["classsynopsisinfo"]) &&
!isset($this->tmp["classsynopsisinfo"]["ooclass"])) {
- $this->tmp["classsynopsisinfo"]["ooclass"] = true;
+ if ($this->cchunk["classsynopsisinfo"]["ooclass"] === false) {
+ $this->cchunk["classsynopsisinfo"]["ooclass"] = true;
return ' class <b class="'.$name.'">';
}
return '<b class="'.$name.'"> ';
@@ -385,7 +545,7 @@ class XHTMLPhDFormat extends PhDFormat {
return "</b>";
}
public function format_classsynopsisinfo($open, $name, $attrs) {
- $this->tmp["classsynopsisinfo"] = array();
+ $this->cchunk["classsynopsisinfo"] =
$this->dchunk["classsynopsisinfo"];
if ($open) {
if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) &&
$attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "comment") {
return '<div class="'.$name.'
classsynopsisinfo_comment">/* ';
@@ -396,7 +556,7 @@ class XHTMLPhDFormat extends PhDFormat {
if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) &&
$attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "comment") {
return ' */</div>';
}
- $this->tmp["classsynopsisinfo"]["close"] = true;
+ $this->cchunk["classsynopsis"]["close"] = true;
return ' {</div>';
}
@@ -405,52 +565,53 @@ class XHTMLPhDFormat extends PhDFormat {
return '<div class="'.$name.'">';
}
- if (isset($this->tmp["classsynopsisinfo"]) &&
isset($this->tmp["classsynopsisinfo"]["close"]) &&
$this->tmp["classsynopsisinfo"]["close"]) {
- $this->tmp["classsynopsisinfo"]["close"] = false;
+ if ($this->cchunk["classsynopsis"]["close"] === true) {
+ $this->cchunk["classsynopsis"]["close"] = false;
return "}</div>";
}
return "</div>";
}
public function format_classsynopsis_ooclass_classname_text($value, $tag) {
- $this->tmp["classsynopsis"]["classname"] = $value;
- return $value;
+ $this->cchunk["classsynopsis"]["classname"] = $value;
+ return $this->TEXT($value);
}
public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
- if (!isset($this->tmp["classsynopsis"]["classname"])) {
+ $value = $this->TEXT($value);
+ if ($this->cchunk["classsynopsis"]["classname"] === false) {
return $value;
}
if (strpos($value, '::')) {
$explode = '::';
- } else if (strpos($value, '->')) {
+ } elseif (strpos($value, '->')) {
$explode = '->';
} else {
return $value;
}
list($class, $method) = explode($explode, $value);
- if ($class !== $this->tmp["classsynopsis"]["classname"]) {
+ if ($class !== $this->cchunk["classsynopsis"]["classname"]) {
return $value;
}
return $method;
}
public function format_fieldsynopsis($open, $name, $attrs) {
- $this->tmp["fieldsynopsis"] = array();
+ $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"];
if ($open) {
return '<div class="'.$name.'">';
}
return ";</div>\n";
}
public function format_fieldsynopsis_modifier_text($value, $tag) {
- $this->tmp["fieldsynopsis"]["modifier"] = trim($value);
- return $value;
+ $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" => "");
- return '<div class="'.$name.'">';
+ return '<div class="'.$name.' dc-description">';
}
$content = "";
if ($this->params["opt"]) {
@@ -527,7 +688,7 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_fieldsynopsis_varname($open, $name, $attrs) {
if ($open) {
- if (isset($this->tmp["fieldsynopsis"]["modifier"]) &&
$this->tmp["fieldsynopsis"]["modifier"] == "const") {
+ if ($this->cchunk["fieldsynopsis"]["modifier"] ===
"const") {
return '<var class="fieldsynopsis_varname">';
}
return '<var class="'.$name.'">$';
@@ -535,28 +696,80 @@ class XHTMLPhDFormat extends PhDFormat {
return '</var>';
}
+ public function format_footnoteref($open, $name, $attrs, $props) {
+ if ($open) {
+ $linkend = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"];
+ $found = false;
+ foreach($this->cchunk["footnote"] as $k => $note) {
+ if ($note["id"] === $linkend) {
+ return '<a href="#fnid' .$note["id"].
'"><sup>[' .($k + 1). ']</sup></a>';
+ }
+ }
+ 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[PhDReader::XMLNS_XML]["id"]) ?
$attrs[PhDReader::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 '<a href="#fnid' .$noteid. '"
name="fn'.$noteid.'"><sup>[' .($count + 1).
']</sup></a>';
+ }
+ 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"] .= '<span
class="para footnote">';
+ return "";
+ }
+
+ $this->cchunk["footnote"][$k]["str"] .= "</span>";
+ 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[PhDReader::XMLNS_XML]["id"])) {
- if(isset($this->tmp["co"])) {
- ++$this->tmp["co"];
- } else {
- $this->tmp["co"] = 1;
- }
- return '<a
name="'.$attrs[PhDReader::XMLNS_XML]["id"].'"
id="'.$attrs[PhDReader::XMLNS_XML]["id"].'">'
.str_repeat("*", $this->tmp["co"]) .'</a>';
+ $co = ++$this->cchunk["co"];
+ return '<a
name="'.$attrs[PhDReader::XMLNS_XML]["id"].'"
id="'.$attrs[PhDReader::XMLNS_XML]["id"].'">'
.str_repeat("*", $co) .'</a>';
}
/* Suppress closing tag if any */
return "";
}
public function format_calloutlist($open, $name, $attrs) {
if ($open) {
- $this->tmp["callouts"] = 0;
+ $this->cchunk["callouts"] = 0;
return '<table>';
}
return '</table>';
}
public function format_callout($open, $name, $attrs) {
if ($open) {
- return '<tr><td><a
href="#'.$attrs[PhDReader::XMLNS_DOCBOOK]["arearefs"].'">'
.str_repeat("*", ++$this->tmp["callouts"]).
'</a></td><td>';
+ return '<tr><td><a
href="#'.$attrs[PhDReader::XMLNS_DOCBOOK]["arearefs"].'">'
.str_repeat("*", ++$this->cchunk["callouts"]).
'</a></td><td>';
}
return "</td></tr>\n";
}
@@ -574,32 +787,32 @@ class XHTMLPhDFormat extends PhDFormat {
return ")</span>";
}
public function format_segmentedlist($open, $name, $attrs) {
- $this->tmp["segmentedlist"] = array("segtitle" => array());
+ $this->cchunk["segmentedlist"] = $this->dchunk["segmentedlist"];
if ($open) {
return '<div class="'.$name.'">';
}
return '</div>';
}
public function format_segtitle_text($value, $tag) {
-
$this->tmp["segmentedlist"]["segtitle"][count($this->tmp["segmentedlist"]["segtitle"])]
= $value;
+
$this->cchunk["segmentedlist"]["segtitle"][count($this->cchunk["segmentedlist"]["segtitle"])]
= $value;
/* Suppress the text */
return "";
}
public function format_seglistitem($open, $name, $attrs) {
if ($open) {
- $this->tmp["segmentedlist"]["seglistitem"] = 0;
+ $this->cchunk["segmentedlist"]["seglistitem"] = 0;
return '<div class="'.$name.'">';
}
return '</div>';
}
public function format_seg($open, $name, $attrs) {
if ($open) {
- return '<div class="seg"><strong><span
class="segtitle">'
.$this->tmp["segmentedlist"]["segtitle"][$this->tmp["segmentedlist"]["seglistitem"]++].
':</span></strong>';
+ return '<div class="seg"><strong><span
class="segtitle">'
.$this->cchunk["segmentedlist"]["segtitle"][$this->cchunk["segmentedlist"]["seglistitem"]++].
':</span></strong>';
}
return '</div>';
}
public function format_procedure($open, $name, $attrs) {
- $this->tmp["procedure"] = false;
+ $this->cchunk["procedure"] = false;
if ($open) {
return '<div class="'.$name.'">';
}
@@ -608,8 +821,8 @@ class XHTMLPhDFormat extends PhDFormat {
public function format_step($open, $name, $attrs) {
if ($open) {
$ret = "";
- if (!$this->tmp["procedure"]) {
- $this->tmp["procedure"] = true;
+ if ($this->cchunk["procedure"] === false) {
+ $this->cchunk["procedure"] = true;
$ret = '<ol type="1">';
}
return $ret . "<li>";
@@ -701,6 +914,21 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</div>";
}
+ public function format_authorgroup_author($open, $name, $attrs, $props) {
+ if ($open) {
+ if ($props["sibling"] !== $name) {
+ return '<div class="'.$name.' vcard">'
.$this->admonition_title("by", $props["lang"]). ':<br />';
+ }
+ return '<div class="'.$name.' vcard">';
+ }
+ return "</div>\n";
+ }
+ public function format_editor($open, $name, $attrs, $props) {
+ if ($open) {
+ return '<div class="editor vcard">'
.$this->admonition_title("editedby", $props["lang"]). ': ';
+ }
+ return "</div>\n";
+ }
public function format_note($open, $name, $attrs, $props) {
if ($open) {
return
'<blockquote><p>'.$this->admonition_title("note",
$props["lang"]). ': ';
@@ -740,27 +968,50 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_mediaobject($open, $name, $attrs) {
- $this->tmp["mediaobject"] = array();
+ $this->cchunk["mediaobject"] = $this->dchunk["mediaobject"];
if ($open) {
return '<div class="'.$name.'">';
}
return '</div>';
}
public function format_alt_text($value, $tag) {
- $this->tmp["mediaobject"]["alt"] = $value;
+ $this->cchunk["mediaobject"]["alt"] = $value;
}
public function format_imagedata($open, $name, $attrs) {
- if (isset($this->tmp["mediaobject"]["alt"])) {
- return '<img src="'
.$attrs[PhDReader::XMLNS_DOCBOOK]["fileref"]. '" alt="'
.$this->tmp["mediaobject"]["alt"]. '" />';
+ if ($this->cchunk["mediaobject"]["alt"] !== false) {
+ return '<img src="'
.$attrs[PhDReader::XMLNS_DOCBOOK]["fileref"]. '" alt="'
.$this->cchunk["mediaobject"]["alt"]. '" />';
}
return '<img src="'
.$attrs[PhDReader::XMLNS_DOCBOOK]["fileref"]. '" />';
}
- public function format_table($open, $name, $attrs) {
+ public function format_table($open, $name, $attrs, $props) {
if ($open) {
+ $this->cchunk["table"] = true;
return '<table border="5">';
}
- return "</table>\n";
+ $this->cchunk["table"] = false;
+ $str = "";
+ if ($this->cchunk["tablefootnotes"]) {
+ $opts = array(PhDReader::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 .= '<div class="footnote">';
+ $str .= '<a name="fnid' .$noteid. '"
href="#fn' .$noteid .'"><sup>[' .($k + 1).
']</sup></a>' .$this->cchunk["footnote"][$k]["str"] .
"\n";
+ unset($this->cchunk["footnote"][$k]);
+ $str .= "</div>\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</table>\n";
}
public function format_tgroup($open, $name, $attrs) {
if ($open) {
@@ -803,7 +1054,7 @@ class XHTMLPhDFormat extends PhDFormat {
public function format_tbody($open, $name, $attrs) {
if ($open) {
$valign = PhDFormat::valign($attrs[PhDReader::XMLNS_DOCBOOK]);
- return '<tbody valign="' .$valign. '">';
+ return '<tbody valign="' .$valign. '" class="'
.$name. '">';
}
return "</tbody>";
}
@@ -815,7 +1066,7 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</tr>\n";
}
- public function format_th_entry($open, $name, $attrs = array()) {
+ public function format_th_entry($open, $name, $attrs) {
if ($open) {
$colspan = PhDFormat::colspan($attrs[PhDReader::XMLNS_DOCBOOK]);
return '<th colspan="' .((int)$colspan). '">';
@@ -836,7 +1087,16 @@ class XHTMLPhDFormat extends PhDFormat {
}
}
- $colspan = PhDFormat::colspan($dbattrs);
+ /*
+ * "colspan" is *not* an standard prop, only used to overwrite the
+ * colspan for <footnote>s in tables
+ */
+ if (isset($props["colspan"])) {
+ $colspan = $props["colspan"];
+ } else {
+ $colspan = PhDFormat::colspan($dbattrs);
+ }
+
$rowspan = PhDFormat::rowspan($dbattrs);
$moreattrs = self::parse_table_entry_attributes($dbattrs);
return $retval. '<td colspan="' .((int)$colspan). '"
rowspan="' .((int)$rowspan). '" ' .$moreattrs. '>';
diff --git a/formats/xml.php b/formats/xml.php
deleted file mode 100644
index e69de29..0000000
diff --git a/include/PhDFormat.class.php b/include/PhDFormat.class.php
index ad4de72..1a99ce5 100644
--- a/include/PhDFormat.class.php
+++ b/include/PhDFormat.class.php
@@ -5,7 +5,7 @@ abstract class PhDFormat extends PhDHelper {
private $TABLE = array();
/* abstract functions */
- abstract public function transformFromMap($open, $tag, $name, $props);
+ abstract public function transformFromMap($open, $tag, $name, $attrs, $props);
abstract public function CDATA($data);
abstract public function TEXT($data);
abstract public function __call($func, $args);
@@ -33,6 +33,9 @@ abstract class PhDFormat extends PhDHelper {
return array_merge($defaults, $this->TABLE["defaults"], $attrs);
}
+ public function getColCount() {
+ return $this->TABLE["cols"];
+ }
public function valign($attrs) {
return isset($attrs["valign"]) ? $attrs["valign"] : "middle";
diff --git a/include/PhDHelper.class.php b/include/PhDHelper.class.php
index ce3f157..837d10c 100644
--- a/include/PhDHelper.class.php
+++ b/include/PhDHelper.class.php
@@ -3,12 +3,14 @@
class PhDHelper {
private $IDs = array();
+ private $refs = array();
/* abstract */ protected $elementmap = array();
/* abstract */ protected $textmap = array();
private static $autogen = array();
- public function __construct(array $IDs) {
- $this->IDs = $IDs;
+ public function __construct(array $a) {
+ $this->IDs = $a[0];
+ $this->refs = $a[1];
}
final public function getFilename($id) {
return isset($this->IDs[$id]) ? $this->IDs[$id]["filename"] : false;
@@ -24,6 +26,9 @@ class PhDHelper {
final public function getParent($id) {
return $this->IDs[$id]["parent"];
}
+ public function getRefnameLink($ref) {
+ return isset($this->refs[$ref]) ? $this->refs[$ref] : null;
+ }
final public function getElementMap() {
return $this->elementmap;
}
diff --git a/include/PhDPartialReader.class.php b/include/PhDPartialReader.class.php
index 83fbe49..f39bd19 100644
--- a/include/PhDPartialReader.class.php
+++ b/include/PhDPartialReader.class.php
@@ -3,6 +3,7 @@
class PhDPartialReader extends PhDReader {
protected $partial = array();
+ protected $skip = array();
public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) {
parent::__construct($opts, $encoding, $xml_opts);
@@ -13,6 +14,13 @@ class PhDPartialReader extends PhDReader {
} else {
$this->partial[$opts["render_ids"]] = 1;
}
+ if (isset($opts["skip_ids"])) {
+ if (is_array($opts["skip_ids"])) {
+ $this->skip = $opts["skip_ids"];
+ } else {
+ $this->skip[$opts["skip_ids"]] = 1;
+ }
+ }
} else {
throw new Exception("Didn't get any IDs to seek");
}
@@ -21,6 +29,7 @@ class PhDPartialReader extends PhDReader {
public function read() {
static $seeked = 0;
static $currently_reading = false;
+ static $currently_skipping = false;
$ignore = false;
while($ret = parent::read()) {
@@ -42,6 +51,30 @@ class PhDPartialReader extends PhDReader {
++$seeked;
}
return $ret;
+ } elseif (isset($this->skip[$id])) {
+ if ($this->isChunk == PhDReader::CLOSE_CHUNK) {
+ if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) {
+ v("%s done\n", $id);
+ }
+ unset($this->skip[$id]);
+ $currently_skipping = false;
+ $ignore = false;
+ } else {
+ if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) {
+ v("Skipping %s...\n", $id);
+ }
+ $currently_skipping = $id;
+ $ignore = true;
+ }
+ } elseif ($currently_skipping && $this->skip[$currently_skipping]) {
+ if ($this->opts["verbose"] & VERBOSE_PARTIAL_CHILD_READING) {
+ if ($this->isChunk == PhDReader::OPEN_CHUNK) {
+ v("Skipping child of %s, %s\n", $currently_reading, $id);
+ } else {
+ v("%s done\n", $id);
+ }
+ }
+ $ignore = true;
} elseif ($currently_reading && $this->partial[$currently_reading]) {
if ($this->opts["verbose"] & VERBOSE_PARTIAL_CHILD_READING) {
if ($this->isChunk == PhDReader::OPEN_CHUNK) {
diff --git a/include/PhDReader.class.php b/include/PhDReader.class.php
index ea2cfb8..60d848f 100644
--- a/include/PhDReader.class.php
+++ b/include/PhDReader.class.php
@@ -3,19 +3,22 @@
//6271
class PhDReader extends XMLReader {
+
+ /* {{{ Class constants */
const XMLNS_XML = "http://www.w3.org/XML/1998/namespace";
const XMLNS_XLINK = "http://www.w3.org/1999/xlink";
const XMLNS_PHD = "http://www.php.net/ns/phd";
const XMLNS_DOCBOOK = "http://docbook.org/ns/docbook";
const OPEN_CHUNK = 0x01;
const CLOSE_CHUNK = 0x02;
+ /* }}} */
+ /* {{{ Private props */
private $STACK = array();
private $LAST_DEPTH = -1;
private $lastChunkDepth = -1;
private $PREVIOUS_SIBLING = "";
-
- public $isChunk = false;
+ /* }}} */
protected $CHUNK_ME = array( /* {{{ */
'article' => true,
@@ -59,7 +62,9 @@ class PhDReader extends XMLReader {
); /* }}} */
protected $opts = array();
- public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) {
+ public $isChunk = false;
+
+ public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { /* {{{ */
if (!XMLReader::open($opts["xml_file"], $encoding, $xml_opts)) {
throw new Exception("Cannot open {$opts["xml_file"]}");
}
@@ -69,9 +74,9 @@ class PhDReader extends XMLReader {
}
}
$this->opts = $opts;
- }
+ } /* }}} */
- public function notXPath($tag, $depth = 0) {
+ public function notXPath($tag, $depth = 0) { /* {{{ */
if(!$depth) {
$depth = $this->depth;
}
@@ -83,36 +88,36 @@ class PhDReader extends XMLReader {
}
} while (is_array($tag));
return $tag;
- }
+ } /* }}} */
/* Seek to an ID within the file. */
- public function seek($id) {
+ public function seek($id) { /* {{{ */
while(XMLReader::read()) {
if ($this->nodeType === XMLREADER::ELEMENT && $this->hasAttributes
&& XMLReader::moveToAttributeNs("id", self::XMLNS_XML) && $this->value
=== $id) {
return XMLReader::moveToElement();
}
}
return false;
- }
+ } /* }}} */
/* Get the ID of current node */
- public function getID() {
+ public function getID() { /* {{{ */
if ($this->hasAttributes && XMLReader::moveToAttributeNs("id",
self::XMLNS_XML)) {
$id = $this->value;
XMLReader::moveToElement();
return $id;
}
return "";
- }
+ } /* }}} */
- public function getParentTagName() {
+ public function getParentTagName() { /* {{{ */
return $this->STACK[$this->depth-1];
- }
- public function getPreviousSiblingTagName() {
+ } /* }}} */
+ public function getPreviousSiblingTagName() { /* {{{ */
return $this->PREVIOUS_SIBLING;
- }
+ } /* }}} */
- public function read() {
+ public function read() { /* {{{ */
$this->isChunk = false;
if(XMLReader::read()) {
$type = $this->nodeType;
@@ -144,21 +149,21 @@ class PhDReader extends XMLReader {
return true;
}
return false;
- }
+ } /* }}} */
/* Get the attribute value by name, if exists. */
- public function readAttribute($attr) {
+ public function readAttribute($attr) { /* {{{ */
$retval = XMLReader::moveToAttribute($attr) ? $this->value : "";
XMLReader::moveToElement();
return $retval;
- }
- public function readAttributeNs($attr, $ns) {
+ } /* }}} */
+ public function readAttributeNs($attr, $ns) { /* {{{ */
$retval = XMLReader::moveToAttributeNs($attr, $ns) ? $this->value : "";
XMLReader::moveToElement();
return $retval;
- }
+ } /* }}} */
/* Get all attributes of current node */
- public function getAttributes() {
+ public function getAttributes() { /* {{{ */
$attrs = array(PhDReader::XMLNS_DOCBOOK => array(), PhDReader::XMLNS_XML => array());
if ($this->hasAttributes) {
XMLReader::moveToFirstAttribute();
@@ -170,11 +175,11 @@ class PhDReader extends XMLReader {
XMLReader::moveToElement();
}
return $attrs;
- }
+ } /* }}} */
/* Get the content of a named node, or the current node. */
- public function readContent($node = null) {
+ public function readContent($node = null) { /* {{{ */
$retval = "";
if($this->isEmptyElement) {
@@ -188,14 +193,14 @@ class PhDReader extends XMLReader {
$retval .= $this->value;
}
return $retval;
- }
+ } /* }}} */
/* Read $nodeName until END_ELEMENT */
- public function readNode($nodeName) {
+ public function readNode($nodeName) { /* {{{ */
return XMLReader::read() && !($this->nodeType === XMLReader::END_ELEMENT
&& $this->name == $nodeName);
- }
+ } /* }}} */
- public function isChunk($tag) {
+ public function isChunk($tag) { /* {{{ */
if (isset($this->CHUNK_ME[$tag])) {
$isChunk = $this->CHUNK_ME[$tag];
if (is_array($isChunk)) {
@@ -207,14 +212,14 @@ class PhDReader extends XMLReader {
return $isChunk;
}
return false;
- }
- public function isSectionChunk($tag) {
+ } /* }}} */
+ public function isSectionChunk($tag) { /* {{{ */
if ($this->PREVIOUS_SIBLING == $tag && $this->checkSectionDepth()) {
return true;
}
return false;
- }
- protected function checkSectionDepth() {
+ } /* }}} */
+ protected function checkSectionDepth() { /* {{{ */
static $allowedParents = array("section", "sect2", "sect3",
"sect4", "sect5");
static $chunkers = array(
"sect1", "preface", "chapter", "appendix",
"article", "part", "reference", "refentry",
@@ -234,11 +239,11 @@ class PhDReader extends XMLReader {
return true;
}
return false;
- }
+ } /* }}} */
}
/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
+* vim600: sw=4 ts=4 syntax=php fdm=marker et
* vim<600: sw=4 ts=4
*/
diff --git a/include/langs/bg.xml b/include/langs/bg.xml
index 657abc9..1b782d1 100644
--- a/include/langs/bg.xml
+++ b/include/langs/bg.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="bg">
<title>Autogenerated text</title>
<variablelist>
@@ -33,5 +33,23 @@
<simpara>СÑвеÑ</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/cs.xml b/include/langs/cs.xml
index 7d4f819..93ab2f1 100644
--- a/include/langs/cs.xml
+++ b/include/langs/cs.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="cs">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Tip</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/de.xml b/include/langs/de.xml
index e417ce3..508c365 100644
--- a/include/langs/de.xml
+++ b/include/langs/de.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="de">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Tipp</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>von</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Herausgegeben von</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Beispiel #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/en.xml b/include/langs/en.xml
index bbeb9d0..d5fb60b 100644
--- a/include/langs/en.xml
+++ b/include/langs/en.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="en">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Tip</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/it.xml b/include/langs/it.xml
index d12dae5..eb480f0 100644
--- a/include/langs/it.xml
+++ b/include/langs/it.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="it">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Suggerimento</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/ja.xml b/include/langs/ja.xml
index 839fd8f..bc72ba7 100644
--- a/include/langs/ja.xml
+++ b/include/langs/ja.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="ja">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>ãã³ã</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>èè
</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>ç·¨é</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>ä¾</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/pl.xml b/include/langs/pl.xml
index 1237caf..3b78d5e 100644
--- a/include/langs/pl.xml
+++ b/include/langs/pl.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="pl">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Wskazówka</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/pt_BR.xml b/include/langs/pt_BR.xml
index fdb0e69..fae723c 100644
--- a/include/langs/pt_BR.xml
+++ b/include/langs/pt_BR.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="pt_BR">
- <title>Autogenerated text</title>
+ <title>Texto autogerado</title>
<variablelist>
<varlistentry>
<term>toc</term>
@@ -33,5 +33,23 @@
<simpara>Dica</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>por</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Editado por</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Exemplo #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/ro.xml b/include/langs/ro.xml
index 7bac21e..c560c4a 100644
--- a/include/langs/ro.xml
+++ b/include/langs/ro.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="ro">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Sfat</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/include/langs/ru.xml b/include/langs/ru.xml
new file mode 100644
index 0000000..857b534
--- /dev/null
+++ b/include/langs/ru.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- $Revision: 1.3.2.2 $ -->
+<section xml:id="autogen" xml:lang="ru">
+ <title>СгенеÑиÑованнÑй
ÑекÑÑ</title>
+ <variablelist>
+ <varlistentry>
+ <term>toc</term>
+ <listitem>
+ <simpara>СодеÑжание</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>warning</term>
+ <listitem>
+ <simpara>Ðнимание</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>note</term>
+ <listitem>
+ <simpara>ÐамеÑание</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>caution</term>
+ <listitem>
+ <simpara>ÐÑедоÑÑеÑежение</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>tip</term>
+ <listitem>
+ <simpara>ÐодÑказка</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Ðод ÑедакÑией</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>ÐÑÐ¸Ð¼ÐµÑ #</simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+</section>
+
diff --git a/index.php b/index.php
deleted file mode 100644
index e69de29..0000000
diff --git a/makestatic.php b/makestatic.php
deleted file mode 100644
index e69de29..0000000
diff --git a/mktoc.php b/mktoc.php
index 83e113d..4de4e6d 100644
--- a/mktoc.php
+++ b/mktoc.php
@@ -1,7 +1,7 @@
<?php
/* $Id$ */
$r = new PhDReader($OPTIONS);
-$FILENAMES = array();
+$REFS = $FILENAMES = array();
$CURRENT_FILENAME = $LAST_CHUNK = "";
#FIXME: This is a workaround for the <legalnotice> element in the PHP manual
@@ -12,14 +12,22 @@ while($r->read()) {
if (!($id = $r->getID())) {
$name = $r->name;
if (empty($IDs[$lastid]["sdesc"])) {
- $name = $r->name;
- if ($name == "refname" || $name == "titleabbrev") {
+ if ($name == "refname") {
+ $IDs[$lastid]["sdesc"] = $refname = trim($r->readContent($name));
+ $ref = strtolower(str_replace(array("_", "::",
"->"), array("-", "-", "-"), $refname));
+ $REFS[$ref] = $lastid;
+ continue;
+ }
+ elseif($name == "titleabbrev") {
$IDs[$lastid]["sdesc"] = trim($r->readContent($name));
continue;
}
+ } elseif($name == "refname") {
+ $refname = trim($r->readContent($name));
+ $ref = strtolower(str_replace(array("_", "::", "->"),
array("-", "-", "-"), $refname));
+ $REFS[$ref] = $lastid;
}
if (empty($IDs[$lastid]["ldesc"])) {
- $name = $r->name;
if ($name == "title" || $name == "refpurpose") {
$IDs[$lastid]["ldesc"] = trim($r->readContent($name));
}
diff --git a/package.xml b/package.xml
index b8b38d1..9991046 100644
--- a/package.xml
+++ b/package.xml
@@ -1,35 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
-<package xmlns="http://pear.php.net/dtd/package-2.0"
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
packagerversion="1.5.4" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+<package xmlns="http://pear.php.net/dtd/package-2.0"
+ xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ packagerversion="1.5.4"
+ version="2.0"
+ xsi:schemaLocation="
+ http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+
<name>PhD</name>
- <uri>http://doc.php.net/phd/phd-0.2.1</uri>
+ <channel>doc.php.net</channel>
<summary>A PHP based Docbook renderer</summary>
<description>
- PhD is a PHP based Docbook renderer aimed to replace the Docbook-XSL
- and various other requirements needed to build the PHP.net documentation
- </description>
+ PhD is a PHP based Docbook renderer aimed to replace Docbook-XSL and various
+ other requirements needed to build the PHP.net documentation.
+ </description>
+
<lead>
<name>Hannes Magnusson</name>
<user>bjori</user>
<email>bjori@php.net</email>
<active>yes</active>
</lead>
- <date>2007-12-30</date>
+ <developer>
+ <name>Gwynne Raskind</name>
+ <user>gwynne</user>
+ <email>gwynne@php.net</email>
+ <active>yes</active>
+ </developer>
+
+ <date>2008-03-31</date>
<version>
- <release>0.2.1</release>
- <api>0.2.1</api>
+ <release>0.2.3</release>
+ <api>0.2.3</api>
</version>
<stability>
- <release>snapshot</release>
- <api>devel</api>
+ <release>beta</release>
+ <api>beta</api>
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
<notes>
- - Multiple <term>s should be line seperated
- - Fixed autogenerated links to methods (Edward Z.)
- - Compressed methodnames in classsynopsis (Edward Z.)
- - Added HTML headers for the bightml theme
- - Removed warnings about missing translation files
+ - Added initial hCalendar support for <author>. (Hannes)
+ - Added initial eRDF support for <refentry>. (Hannes)
+ - Added support for <footnote> and <footnoteref>. (Gwynne, Hannes)
+ - Added anchor generation for various elements. (Hannes)
+ - Added option (-s/--skip) to skip rendering of chunks. (Hannes)
+ - Added option (-o/--output) to specify output directory (FR#43193). (Richard)
+ - Added support for <sect4> titles . (Gwynne)
+ - Added an 'infdec' role to <literal> in XHTML. (Gwynne)
+ - Fixed couple of typos in PhD info messages. (Richard Q.)
+ - Reformatted package.xml for readability and consistency. (Gwynne)
+ - Merged README.RENDERER into README and updated README with current information. (Gwynne)
+ - Gwynne is a developer of PhD, unfortunately. (Gwynne)
+ - Made 'Example #' text localizeable. (Gwynne)
+ - Added Russion support (for autogenerated texts). (Tony)
+ - Updated translations:
+ - Japanese (Masahiro)
+ - Brazilian Portuguese (Felipe)
+ - German (Mark)
</notes>
+
<contents>
<dir baseinstalldir="phd" name="/">
<file baseinstalldir="phd" name="formats/xhtml.php"
role="php"/>
@@ -47,6 +77,7 @@
<file baseinstalldir="phd" name="include/langs/pl.xml"
role="php"/>
<file baseinstalldir="phd" name="include/langs/pt_BR.xml"
role="php"/>
<file baseinstalldir="phd" name="include/langs/ro.xml"
role="php"/>
+ <file baseinstalldir="phd" name="include/langs/ru.xml"
role="php"/>
<file baseinstalldir="phd" name="themes/php/bightml.php"
role="php"/>
<file baseinstalldir="phd" name="themes/php/chunkedhtml.php"
role="php"/>
<file baseinstalldir="phd" name="themes/php/phpdotnet.php"
role="php"/>
@@ -62,10 +93,11 @@
<file baseinstalldir="phd" name="config.php" role="php"/>
<file baseinstalldir="phd" name="LICENSE" role="php"/>
<file baseinstalldir="phd" name="mktoc.php" role="php"/>
- <file baseinstalldir="phd" name="README.RENDERER"
role="php"/>
+ <file baseinstalldir="phd" name="README" role="php"/>
<file baseinstalldir="phd" name="TODO.RENDERER"
role="php"/>
</dir>
</contents>
+
<dependencies>
<required>
<php>
@@ -85,6 +117,7 @@
</extension>
</required>
</dependencies>
+
<phprelease>
<installconditions>
<os>
@@ -101,7 +134,9 @@
<ignore name="phd.bat"/>
</filelist>
</phprelease>
+
<changelog>
+
<release>
<version>
<release>0.1</release>
@@ -113,10 +148,11 @@
</stability>
<date>2007-10-01</date>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
- <notes>Initial release</notes>
+ <notes>
+ - Initial release
+ </notes>
</release>
- </changelog>
- <changelog>
+
<release>
<version>
<release>0.1.0</release>
@@ -127,35 +163,35 @@
<api>devel</api>
</stability>
<date>2007-10-20</date>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
<notes>
- - Add example numbering
- - Improved support for modifiers in fieldsynopsis
- - Remove () from refname when looking for version info (reported by Paul Reinheimer)
- - Print notes inline with its title (reported by Philip Olson)
- - Check if we have an open "{" before we print "}"
- - Escape the version info (patch by Richard Q.)
- - Fixed variablelist titles
- - Fixed table info titles
- - Fixed empty table cells (reported by Mark Wiesemann)
- - Fixed table title markup (reported by Richard Q.)
- - Fixed non-closing b element for empty <title />s (reported by Joshua Thompson
and Philip Olson)
- - Fixed bug#43013 (Description rather then function name for right arrows on extension pages)
(patch by Richard Q.)
- - Fixed bug#42906 (docs.php.net bold instead of links)
- - Fixed bug#42860 (cannot render <orgname> element)
- - Fixed bug#42845 (Copyright page has no TOC)
- - Language support (for autogenerated texts):
- * Bulgarian (by Kouber Saparev)
- * Czech (by Jakub Vrana)
- * German (by Oliver Albers)
- * Italian (by Marco Cucinato)
- * Japanese (by TAKAGI Masahiro)
- * Polish (by Jaroslaw Glowacki)
- * Brazilian Portuguese (by Diego Feitosa)
- * Romanian (by Simion Onea)
+ - Added example numbering. (Hannes)
+ - Improved support for modifiers in fieldsynopsis. (Hannes)
+ - Remove () from refname when looking for version info, reported by Paul Reinheimer.
(Hannes)
+ - Print notes inline with its title, reported by Philip Olson. (Hannes)
+ - Check if we have an open "{" before we print "}". (Hannes)
+ - Escape the version info. (Richard Q.)
+ - Fixed variablelist titles. (Hannes)
+ - Fixed table info titles. (Hannes)
+ - Fixed empty table cells, reported by Mark Wiesemann. (Hannes)
+ - Fixed table title markup, reported by Richard Q. (Hannes)
+ - Fixed non-closing b element for empty <title />s, reported by Joshua
Thompson and Philip Olson. (Hannes)
+ - Fixed bug#43013 (Description rather then function name for right arrows on extension
pages). (Richard Q.)
+ - Fixed bug#42906 (docs.php.net bold instead of links). (Hannes)
+ - Fixed bug#42860 (cannot render <orgname> element). (Hannes)
+ - Fixed bug#42845 (Copyright page has no TOC). (Hannes)
+ - Language support (for autogenerated texts):
+ * Bulgarian (by Kouber Saparev)
+ * Czech (by Jakub Vrana)
+ * German (by Oliver Albers)
+ * Italian (by Marco Cucinato)
+ * Japanese (by TAKAGI Masahiro)
+ * Polish (by Jaroslaw Glowacki)
+ * Brazilian Portuguese (by Diego Feitosa)
+ * Romanian (by Simion Onea)
</notes>
</release>
- </changelog>
- <changelog>
+
<release>
<version>
<release>0.2.0</release>
@@ -166,17 +202,70 @@
<api>devel</api>
</stability>
<date>2007-11-08</date>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
<notes>
- - Added partial rendering
- - Added various verbosity levels
- - Added getopt() parsing for few configuration options
- - Added support for errorcode, symbol and superscript elements (used by few translations)
- - Suppressed the contrib element
+ - Added partial rendering. (Hannes)
+ - Added various verbosity levels. (Hannes)
+ - Added getopt() parsing for few configuration options. (Hannes)
+ - Added support for errorcode, symbol and superscript elements (used by few translations).
(Hannes)
+ - Suppressed the contrib element. (Hannes)
+ - Fixed bug#43192 (Chunked HTML output difficult to use without TOC). (Edward Z. Yang)
+ - Fixed bug#43191 (build.php fails to included necessary theme dependencies). (Edward Z.
Yang, Richard Q)
+ </notes>
+ </release>
- - Fixed bug#43192 (Chunked HTML output difficult to use without TOC). (Edward Z. Yang)
- - Fixed bug#43191 (build.php fails to included necessary theme dependencies). (Edward Z. Yang,
Richard Q)
+ <release>
+ <version>
+ <release>0.2.1</release>
+ <api>0.2.1</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>devel</api>
+ </stability>
+ <date>2007-12-30</date>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
+ <notes>
+ - Multiple <term>s should be line seperated. (Hannes)
+ - Fixed autogenerated links to methods. (Edward Z.)
+ - Compressed methodnames in classsynopsis. (Edward Z.)
+ - Added HTML headers for the bightml theme. (Hannes)
+ - Removed warnings about missing translation files. (Hannes)
</notes>
</release>
+
+ <release>
+ <version>
+ <release>0.2.2</release>
+ <api>0.2.2</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>devel</api>
+ </stability>
+ <date>2008-01-30</date>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
+ <notes>
+ - Removed support for phnotify. (Hannes)
+ - Added index chaching. (Edward Z.)
+ - Added option (-l/--list) to list the supported formats/themes.(Hannes)
+ - Added support for linkend in fieldsynopsis varnames. (Hannes)
+ - Added autogenerated "Edited by" text for <editor>. (Hannes)
+ - Added autogenerated "by" text for the first <author> element in
<authorgroup>. (Hannes)
+ - Added missing closing "}" for classsynopsis. (Hannes)
+ - Fixed E_NOTICE on empty references. (Hannes)
+ - Fixed weird error message when no arguments are given, reported by Tony. (Hannes)
+ - Fixed typos in the argument descriptions (--help), reported by Tony. (Hannes)
+ - Fixed bug#43972 (PhD doesn't warn on missing partial IDs). (Hannes)
+ - Fixed bug#43904 (PhD doesn't detect <section> without xml:id).
(Hannes)
+ - Fixed bug#43489 (Class synopsis return types are not links). (Hannes)
+ - Fixed bug#43440 (Wrong encoding on some parts of the page). (Hannes)
+ - Fixed bug#43428 (Empty TOC). (Hannes)
+ - Fixed bug#43421 (All intra-document hyperlinks broken in the Single HTML file form of
manual). (Hannes)
+ - Fixed bug#43416 (Function links do not render as links). (Hannes)
+ </notes>
+ </release>
+
</changelog>
</package>
diff --git a/phd.bat b/phd.bat
new file mode 100644
index 0000000..5620105
--- /dev/null
+++ b/phd.bat
@@ -0,0 +1 @@
+@@php_bin@ @bin_dir@\build.php %1
diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php
index 703614b..e1520a0 100644
--- a/phpdotnet/phd/Config.php
+++ b/phpdotnet/phd/Config.php
@@ -1,11 +1,13 @@
<?php
/* $Id$ */
+/* {{{ Print messages to stderr: v("printf-format-text", $arg1, ...) */
function v($msg) {
$args = func_get_args();
$args[0] = date($GLOBALS["OPTIONS"]["date_format"]);
vfprintf(STDERR, "[%s] $msg", $args);
}
+/* }}} */
define('VERBOSE_INDEXING', 0x01);
define('VERBOSE_FORMAT_RENDERING', 0x02);
@@ -16,10 +18,11 @@ define('VERBOSE_PARTIAL_CHILD_READING', 0x20);
define('VERBOSE_TOC_WRITING', 0x40);
define('VERBOSE_CHUNK_WRITING', 0x80);
-define('VERBOSE_ALL',VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_PARTIAL_CHILD_READING|VERBOSE_TOC_WRITING|VERBOSE_CHUNK_WRITING);
+define('VERBOSE_ALL', 0xFF);
-define("PHD_VERSION", "0.2.1");
+define("PHD_VERSION", "0.2.3");
+/* {{{ Default $OPTIONS */
$OPTIONS = array (
'output_format' => array('xhtml'),
'output_theme' => array(
@@ -42,26 +45,34 @@ $OPTIONS = array (
'enforce_revisions' => false,
'compatibility_mode' => true,
'build_log_file' => 'none',
- 'debug' => true,
- 'verbose' =>
VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_TOC_WRITING,
+ 'verbose' => VERBOSE_ALL^(VERBOSE_PARTIAL_CHILD_READING|VERBOSE_CHUNK_WRITING),
'date_format' => "H:i:s",
'render_ids' => array(
),
+ 'skip_ids' => array(
+ ),
+ 'output_dir' => '.',
);
+/* }}} */
+/* {{{ getopt() options */
$opts = array(
"format:" => "f:", // The format to render (xhtml, pdf...)
"theme:" => "t:", // The theme to render (phpweb, bightml..)
"index:" => "i:", // Re-index or load from cache
"docbook:" => "d:", // The Docbook XML file to render from (.manual.xml)
- "partial:" => "p:", // The ID to render (optionally ignoring its
childrens)
+ "output:" => "o:", // The output directory
+ "partial:" => "p:", // The ID to render (optionally ignoring its
children)
+ "skip:" => "s:", // The ID to skip (optionally skipping its children
too)
"verbose:" => "v", // Adjust the verbosity level
+ "list::" => "l::", // List supported themes/formats
"version" => "V", // Print out version information
"help" => "h", // Print out help
);
+/* }}} */
-/* Fix for Windows prior to PHP5.3 */
+/* {{{ Workaround/fix for Windows prior to PHP5.3 */
if (!function_exists("getopt")) {
function getopt($short, $long) {
v("I'm sorry, you are running an operating system that does not support
getopt()\n");
@@ -70,15 +81,17 @@ if (!function_exists("getopt")) {
return array();
}
}
+/* }}} */
$args = getopt(implode("", array_values($opts)), array_keys($opts));
if($args === false) {
v("Something happend with getopt(), please report a bug\n");
- exit(-1);
+ exit(1);
}
$verbose = 0;
$docbook = false;
+
foreach($args as $k => $v) {
switch($k) {
/* {{{ Docbook file */
@@ -86,11 +99,11 @@ foreach($args as $k => $v) {
case "docbook":
if (is_array($v)) {
v("Can only parse one file at a time\n");
- exit(-1);
+ exit(1);
}
if (!file_exists($v) || is_dir($v) || !is_readable($v)) {
v("'%s' is not a readable docbook file\n", $v);
- exit(-1);
+ exit(1);
}
$OPTIONS["xml_root"] = dirname($v);
$OPTIONS["xml_file"] = $v;
@@ -98,12 +111,28 @@ foreach($args as $k => $v) {
break;
/* }}} */
+ /* {{{ Output location */
+ case "o":
+ case "output":
+ if (is_array($v)) {
+ v("Only a single location can be supplied\n");
+ exit(1);
+ }
+ @mkdir($v, 0777, true);
+ if (!is_dir($v) || !is_readable($v)) {
+ v("'%s' is not a valid directory\n", $v);
+ exit(1);
+ }
+ $OPTIONS["output_dir"] = $v;
+ break;
+ /* }}} */
+
/* {{{ Build format */
case "f":
case "format":
if ($v != "xhtml") {
v("Only xhtml is supported at this time\n");
- exit(-1);
+ exit(1);
}
break;
/* }}} */
@@ -113,7 +142,7 @@ foreach($args as $k => $v) {
case "index":
if (is_array($v)) {
v("You cannot pass %s more than once\n", $k);
- exit(-1);
+ exit(1);
}
switch ($v) {
case "yes":
@@ -128,8 +157,48 @@ foreach($args as $k => $v) {
break;
default:
v("yes/no || true/false || 1/0 expected\n");
- exit(-1);
+ exit(1);
+ }
+ break;
+ /* }}} */
+
+ /* {{{ Print out a list of formats/themes */
+ case "l":
+ case "list":
+ /* FIXME: This list should be created dynamically */
+ foreach((array)$v as $val) {
+ switch($val) {
+ case "f":
+ case "format":
+ case "formats":
+ echo "Supported formats:\n";
+ echo "\txhtml\n";
+ break;
+
+ case "t":
+ case "theme":
+ case "themes":
+ echo "Supported themes:\n";
+ echo "\tphpweb\n";
+ echo "\tchunkedhtml\n";
+ echo "\tbightml\n";
+ break;
+
+ default:
+ echo "Unknown list type '$val'\n";
+ /* break omitted intentionally */
+
+ case false:
+ echo "Supported formats:\n";
+ echo "\txhtml\n";
+ echo "Supported themes:\n";
+ echo "\tphpweb\n";
+ echo "\tchunkedhtml\n";
+ echo "\tbightml\n";
+ break;
+ }
}
+ exit(0);
break;
/* }}} */
@@ -151,6 +220,24 @@ foreach($args as $k => $v) {
break;
/* }}} */
+ /* {{{ Skip list */
+ case "s":
+ case "skip":
+ foreach((array)$v as $i => $val) {
+ $recursive = true;
+ if (strpos($val, "=") !== false) {
+ list($val, $recursive) = explode("=", $val);
+
+ if (!is_numeric($recursive) && defined($recursive)) {
+ $recursive = constant($recursive);
+ }
+ $recursive = (bool) $recursive;
+ }
+ $OPTIONS["skip_ids"][$val] = $recursive;
+ }
+ break;
+ /* }}} */
+
/* {{{ Output themes */
case "t":
case "theme":
@@ -167,8 +254,8 @@ foreach($args as $k => $v) {
}
break;
default:
- v("Unkown theme '%s'\n", $val);
- exit(-1);
+ v("Unknown theme '%s'\n", $val);
+ exit(1);
}
}
break;
@@ -183,7 +270,7 @@ foreach($args as $k => $v) {
} elseif (is_numeric($const)) {
$verbose |= (int)$const;
} else {
- v("Unkown option passed to --$k, $const\n");
+ v("Unknown option passed to --$k, $const\n");
}
}
}
@@ -201,59 +288,76 @@ foreach($args as $k => $v) {
$OPTIONS["verbose"] = $verbose;
break;
/* }}} */
-
+
+ /* {{{ Version info */
case "V":
case "version":
v("PhD version: %s\n", PHD_VERSION);
- v("Copyright (c) 2007 The PHP Documentation Group\n");
+ v("Copyright (c) 2008 The PHP Documentation Group\n");
exit(0);
+ /* }}} */
+ /* {{{ Help/usage info */
case "usage":
case "help":
case "h":
echo "PhD version: " .PHD_VERSION;
- echo "\nCopyright (c) 2007 The PHP Documentation Group\n
+ echo "\nCopyright (c) 2008 The PHP Documentation Group\n
-v
- --versbose <int> Adjusts the verbosity level.
+ --verbose <int> Adjusts the verbosity level
-f <formatname>
--format <formatname> The build format to use
-t <themename>
--theme <themename> The theme to use
- -i
- --index Index before rendering or load from cache [NOTE: Not supported yet]
+ -i <bool>
+ --index <bool> Index before rendering (default) or load from cache (false)
-d <filename>
--docbook <filename> The Docbook file to render from
-p <id[=bool]>
- --partial <id[=bool]> The ID to render, optionally ignoring its children pages
(default to true; render childrens)
+ --partial <id[=bool]> The ID to render, optionally skipping its children chunks
(default to true; render children)
+ -s <id[=bool]>
+ --skip <id[=bool]> The ID to skip, optionally skipping its children chunks (default
to true; skip children)
+ -l <formats/themes>
+ --list <formats/themes> Print out the supported formats/themes (default: both)
+ -o <directory>
+ --output <directory> The output directory (default: .)
-V
--version Print the PhD version information
-h
--help This help
-All options can be passed multiple times for greater affect.
+Most options can be passed multiple times for greater affect.
NOTE: Long options are only supported using PHP5.3\n";
exit(0);
break;
+ /* }}} */
+ /* {{{ Unsupported option this should *never* happen */
default:
v("Hmh, something weird has happend, I don't know this option");
var_dump($k, $v);
- exit(-1);
+ exit(1);
+ /* }}} */
}
}
-if (!$docbook) {
+/* {{{ BC for PhD 0.0.* (and PHP5.2 on Windows)
+ i.e. `phd path/to/.manual.xml */
+if (!$docbook && $argc > 1) {
$arg = $argv[$argc-1];
if (is_dir($arg)) {
$OPTIONS["xml_root"] = $arg;
- $OPTIONS["xml_file"] = $arg . "/.manual.xml";
+ $OPTIONS["xml_file"] = $arg . DIRECTORY_SEPARATOR . ".manual.xml";
} elseif (is_file($arg)) {
$OPTIONS["xml_root"] = dirname($arg);
$OPTIONS["xml_file"] = $arg;
}
}
+/* }}} */
+/* {{{ If no docbook file was passed, ask for it
+ This loop should be removed in PhD 0.3.0, and replaced with a fatal errormsg */
while (!is_dir($OPTIONS["xml_root"]) || !is_file($OPTIONS["xml_file"])) {
print "I need to know where you keep your '.manual.xml' file (I didn't find
it in " . $OPTIONS["xml_root"] . "): ";
$root = trim(fgets(STDIN));
@@ -265,12 +369,15 @@ while (!is_dir($OPTIONS["xml_root"]) ||
!is_file($OPTIONS["xml_file"])) {
$OPTIONS["xml_root"] = $root;
}
}
+/* }}} */
+
+/* This needs to be done in *all* cases! */
+$OPTIONS["output_dir"] = realpath($OPTIONS["output_dir"]) .
DIRECTORY_SEPARATOR;
$OPTIONS["version_info"] =
$OPTIONS["xml_root"]."/phpbook/phpbook-xsl/version.xml";
$OPTIONS["acronyms_file"] =
$OPTIONS["xml_root"]."/entities/acronyms.xml";
/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
+* vim600: sw=4 ts=4 syntax=php et
* vim<600: sw=4 ts=4
*/
-
diff --git a/phpdotnet/phd/Format/Legacy.php b/phpdotnet/phd/Format/Legacy.php
index ad4de72..1a99ce5 100644
--- a/phpdotnet/phd/Format/Legacy.php
+++ b/phpdotnet/phd/Format/Legacy.php
@@ -5,7 +5,7 @@ abstract class PhDFormat extends PhDHelper {
private $TABLE = array();
/* abstract functions */
- abstract public function transformFromMap($open, $tag, $name, $props);
+ abstract public function transformFromMap($open, $tag, $name, $attrs, $props);
abstract public function CDATA($data);
abstract public function TEXT($data);
abstract public function __call($func, $args);
@@ -33,6 +33,9 @@ abstract class PhDFormat extends PhDHelper {
return array_merge($defaults, $this->TABLE["defaults"], $attrs);
}
+ public function getColCount() {
+ return $this->TABLE["cols"];
+ }
public function valign($attrs) {
return isset($attrs["valign"]) ? $attrs["valign"] : "middle";
diff --git a/phpdotnet/phd/Format/PDF.php b/phpdotnet/phd/Format/PDF.php
deleted file mode 100644
index e69de29..0000000
diff --git a/phpdotnet/phd/Format/XHTML.php b/phpdotnet/phd/Format/XHTML.php
index 7a872c0..ed0f48e 100644
--- a/phpdotnet/phd/Format/XHTML.php
+++ b/phpdotnet/phd/Format/XHTML.php
@@ -9,8 +9,11 @@ class XHTMLPhDFormat extends PhDFormat {
'affiliation' => 'format_suppressed_tags',
'alt' => 'format_suppressed_tags',
'article' => 'format_container_chunk',
- 'author' => 'div',
- 'authorgroup' => 'div', /* DocBook-xsl prints out
"by" (i.e. "PHP Manual by ...") */
+ 'author' => array(
+ /* DEFAULT */ 'format_author',
+ 'authorgroup' => 'format_authorgroup_author',
+ ),
+ 'authorgroup' => 'div',
'appendix' => 'format_container_chunk',
'application' => 'span',
'blockquote' => 'blockquote',
@@ -25,8 +28,10 @@ class XHTMLPhDFormat extends PhDFormat {
'co' => 'format_co',
'colophon' => 'format_chunk',
'copyright' => 'format_copyright',
- 'editor' => 'div', /* Docbook-xsl prints "edited
by" */
+ 'editor' => 'format_editor',
'firstname' => 'format_name',
+ 'footnote' => 'format_footnote',
+ 'footnoteref' => 'format_footnoteref',
'surname' => 'format_name',
'othername' => 'format_name',
'optional' => 'span',
@@ -57,7 +62,14 @@ class XHTMLPhDFormat extends PhDFormat {
'colspec' => 'format_colspec',
'command' => 'strong',
'computeroutput' => 'span',
- 'constant' => 'format_constant',
+ /* 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',
@@ -107,7 +119,7 @@ class XHTMLPhDFormat extends PhDFormat {
/* DEFAULT */ 'li',
'varlistentry' => 'format_varlistentry_listitem',
),
- 'literal' => 'i',
+ 'literal' => 'format_literal',
'literallayout' => 'pre',
'manvolnum' => 'format_manvolnum',
'mediaobject' => 'format_mediaobject',
@@ -134,6 +146,8 @@ class XHTMLPhDFormat extends PhDFormat {
/* DEFAULT */ 'p',
'example' => 'format_example_content',
'note' => 'format_note_content',
+ 'footnote' => 'format_footnote_para',
+ 'refsect1' => 'format_refsect1_para',
),
'parameter' => array(
/* DEFAULT */ 'format_parameter',
@@ -141,7 +155,7 @@ class XHTMLPhDFormat extends PhDFormat {
),
'part' => 'format_container_chunk',
'partintro' => 'div',
- 'personname' => 'span',
+ 'personname' => 'format_personname',
'preface' => 'format_chunk',
'primaryie' => 'format_suppressed_tags',
'procedure' => 'format_procedure',
@@ -197,6 +211,7 @@ class XHTMLPhDFormat extends PhDFormat {
'table' => 'format_table',
'term' => 'format_term',
'tfoot' => 'format_th',
+ 'tbody' => 'format_tbody',
'thead' => 'format_th',
'tgroup' => 'format_tgroup',
'tip' => 'format_admonition',
@@ -222,6 +237,7 @@ class XHTMLPhDFormat extends PhDFormat {
'sect1' => 'h2',
'sect2' => 'h3',
'sect3' => 'h4',
+ 'sect4' => 'h5',
'segmentedlist' => 'strong',
'table' => 'format_table_title',
'variablelist' => 'strong',
@@ -276,11 +292,56 @@ class XHTMLPhDFormat extends PhDFormat {
'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',
+
);
- protected $role = false;
- protected $tmp = array();
+ public $role = false;
+ /* Current Chunk variables */
+ protected $cchunk = array();
+ /* Default Chunk variables */
+ protected $dchunk = array(
+ "classsynopsis" => array(
+ "close" => false,
+ "classname" => false,
+ ),
+ "classsynopsisinfo" => array(
+ "implements" => false,
+ "ooclass" => false,
+ ),
+ "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(
+ ),
+ );
public function __construct(array $IDs) {
parent::__construct($IDs);
@@ -292,9 +353,14 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "<font color='red'
size='+3'>/{$args[1]}</font>";
}
- public function transformFromMap($open, $tag, $name, $props) {
+ public function transformFromMap($open, $tag, $name, $attrs, $props) {
if ($open) {
- return '<' .$tag. ' class="' .$name. '"' .
($props["empty"] ? '/' : "") . '>';
+ $idstr = "";
+ if (isset($attrs[PhDReader::XMLNS_XML]["id"])) {
+ $id = $attrs[PhDReader::XMLNS_XML]["id"];
+ $idstr = ' id="' .$id. '" name="' .$id.
'"';
+ }
+ return '<' .$tag. ' class="' .$name. '"' .
($props["empty"] ? '/' : "") . $idstr. '>';
}
return '</' .$tag. '>';
}
@@ -318,21 +384,83 @@ class XHTMLPhDFormat extends PhDFormat {
/* Suppress any content */
return "";
}
-
+
+ public function format_literal($open, $name, $attrs) {
+ if ($open) {
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
+ $this->role = $attrs[PhDReader::XMLNS_DOCBOOK]["role"];
+ } else {
+ $this->role = false;
+ }
+ return '<i>';
+ }
+ $this->role = false;
+ return '</i>';
+ }
+ 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 .= '<span style="text-decoration: overline;">';
+ $str .= substr($value, $p + 1);
+ $str .= '</span>';
+ return $str;
+ default:
+ return $this->TEXT($value);
+ }
+ }
+
public function format_copyright($open, $name, $attrs) {
if ($open) {
return '<div class="'.$name.'">© ';
}
return '</div>';
}
+ public function format_author($open, $name, $attrs, $props) {
+ if ($open) {
+ return '<div class="' .$name. ' vcard">';
+ }
+ return "</div>";
+ }
+ public function format_personname($open, $name, $attrs, $props) {
+ if ($open) {
+ return '<span class="' .$name. ' fn">';
+ }
+ return "</span>";
+ }
public function format_name($open, $name, $attrs) {
if ($open) {
- return ' <span class="'.$name.'">';
+ $class = "";
+ switch($name) {
+ case "firstname":
+ $class = " given-name";
+ break;
+
+ case "surname":
+ $class = " family-name";
+ break;
+
+ case "othername":
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
+ /* We maight want to add support for other roles */
+ switch($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) {
+ case "nickname":
+ $class = " nickname";
+ break;
+ }
+ }
+ break;
+ }
+
+ return ' <span class="' . $name . $class . '">';
}
return '</span> ';
}
public function format_container_chunk($open, $name, $attrs) {
+ $this->cchunk = $this->dchunk;
if ($open) {
return '<div id="' .$attrs[PhDReader::XMLNS_XML]["id"].
'" class="' .$name. '">';
}
@@ -346,27 +474,59 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_chunk($open, $name, $attrs) {
if ($open) {
+ $this->cchunk = $this->dchunk;
if(isset($attrs[PhDReader::XMLNS_XML]["id"])) {
- return '<div id="' .$attrs[PhDReader::XMLNS_XML]["id"].
'" class="' .$name. '">';
+ $class = $name;
+ if ($name === "refentry") {
+ //$class .= " -rel-posting";
+ }
+ return '<div id="' .$attrs[PhDReader::XMLNS_XML]["id"].
'" class="' .$class. '">';
}
return '<div class="' .$name. '">';
}
- return "</div>";
+ $str = "";
+ foreach ($this->cchunk["footnote"] as $k => $note) {
+ $str .= '<div class="footnote">';
+ $str .= '<a name="fnid' .$note["id"]. '"
href="#fn' .$note["id"]. '"><sup>[' .($k + 1).
']</sup></a>';
+ $str .= $note["str"];
+ $str .= "</div>\n";
+ }
+ $this->cchunk["footnote"] = $this->dchunk["footnote"];
+
+ return $str. "</div>";
+ }
+ public function format_refsect1_para($open, $name, $attrs, $props) {
+ if ($open) {
+ switch ($props["sibling"]) {
+ case "methodsynopsis":
+ case "constructorsynopsis":
+ case "destructorsynopsis":
+ return '<p class="'.$name.' rdfs-comment">';
+ break;
+
+ default:
+ return '<p class="'.$name.'">';
+ }
+
+ }
+ return '</p>';
}
public function format_refsect($open, $name, $attrs) {
if ($open) {
if(!isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"])) {
- $attrs[PhDReader::XMLNS_DOCBOOK] = "unkown";
+ $attrs[PhDReader::XMLNS_DOCBOOK]["role"] = "unknown";
}
- return '<div class="' .$name.' '
.$attrs[PhDReader::XMLNS_DOCBOOK]["role"]. '">';
+ $this->role = $role = $attrs[PhDReader::XMLNS_DOCBOOK]["role"];
+ return '<div class="' .$name.' ' .$role.
'">';
}
+ $this->role = null;
return "</div>\n";
}
public function format_classsynopsisinfo_oointerface($open, $name, $attrs) {
if ($open) {
- if (isset($this->tmp["classsynopsisinfo"]) &&
!isset($this->tmp["classsynopsisinfo"]["implements"])) {
- $this->tmp["classsynopsisinfo"]["implements"] = true;
+ if ($this->cchunk["classsynopsisinfo"]["implements"] === false)
{
+ $this->cchunk["classsynopsisinfo"]["implements"] = true;
return '<span class="'.$name.'">implements ';
}
return '<span class="'.$name.'">, ';
@@ -376,8 +536,8 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_classsynopsisinfo_ooclass_classname($open, $name, $attrs) {
if ($open) {
- if (isset($this->tmp["classsynopsisinfo"]) &&
!isset($this->tmp["classsynopsisinfo"]["ooclass"])) {
- $this->tmp["classsynopsisinfo"]["ooclass"] = true;
+ if ($this->cchunk["classsynopsisinfo"]["ooclass"] === false) {
+ $this->cchunk["classsynopsisinfo"]["ooclass"] = true;
return ' class <b class="'.$name.'">';
}
return '<b class="'.$name.'"> ';
@@ -385,7 +545,7 @@ class XHTMLPhDFormat extends PhDFormat {
return "</b>";
}
public function format_classsynopsisinfo($open, $name, $attrs) {
- $this->tmp["classsynopsisinfo"] = array();
+ $this->cchunk["classsynopsisinfo"] =
$this->dchunk["classsynopsisinfo"];
if ($open) {
if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) &&
$attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "comment") {
return '<div class="'.$name.'
classsynopsisinfo_comment">/* ';
@@ -396,7 +556,7 @@ class XHTMLPhDFormat extends PhDFormat {
if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["role"]) &&
$attrs[PhDReader::XMLNS_DOCBOOK]["role"] == "comment") {
return ' */</div>';
}
- $this->tmp["classsynopsisinfo"]["close"] = true;
+ $this->cchunk["classsynopsis"]["close"] = true;
return ' {</div>';
}
@@ -405,52 +565,53 @@ class XHTMLPhDFormat extends PhDFormat {
return '<div class="'.$name.'">';
}
- if (isset($this->tmp["classsynopsisinfo"]) &&
isset($this->tmp["classsynopsisinfo"]["close"]) &&
$this->tmp["classsynopsisinfo"]["close"]) {
- $this->tmp["classsynopsisinfo"]["close"] = false;
+ if ($this->cchunk["classsynopsis"]["close"] === true) {
+ $this->cchunk["classsynopsis"]["close"] = false;
return "}</div>";
}
return "</div>";
}
public function format_classsynopsis_ooclass_classname_text($value, $tag) {
- $this->tmp["classsynopsis"]["classname"] = $value;
- return $value;
+ $this->cchunk["classsynopsis"]["classname"] = $value;
+ return $this->TEXT($value);
}
public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
- if (!isset($this->tmp["classsynopsis"]["classname"])) {
+ $value = $this->TEXT($value);
+ if ($this->cchunk["classsynopsis"]["classname"] === false) {
return $value;
}
if (strpos($value, '::')) {
$explode = '::';
- } else if (strpos($value, '->')) {
+ } elseif (strpos($value, '->')) {
$explode = '->';
} else {
return $value;
}
list($class, $method) = explode($explode, $value);
- if ($class !== $this->tmp["classsynopsis"]["classname"]) {
+ if ($class !== $this->cchunk["classsynopsis"]["classname"]) {
return $value;
}
return $method;
}
public function format_fieldsynopsis($open, $name, $attrs) {
- $this->tmp["fieldsynopsis"] = array();
+ $this->cchunk["fieldsynopsis"] = $this->dchunk["fieldsynopsis"];
if ($open) {
return '<div class="'.$name.'">';
}
return ";</div>\n";
}
public function format_fieldsynopsis_modifier_text($value, $tag) {
- $this->tmp["fieldsynopsis"]["modifier"] = trim($value);
- return $value;
+ $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" => "");
- return '<div class="'.$name.'">';
+ return '<div class="'.$name.' dc-description">';
}
$content = "";
if ($this->params["opt"]) {
@@ -527,7 +688,7 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_fieldsynopsis_varname($open, $name, $attrs) {
if ($open) {
- if (isset($this->tmp["fieldsynopsis"]["modifier"]) &&
$this->tmp["fieldsynopsis"]["modifier"] == "const") {
+ if ($this->cchunk["fieldsynopsis"]["modifier"] ===
"const") {
return '<var class="fieldsynopsis_varname">';
}
return '<var class="'.$name.'">$';
@@ -535,28 +696,80 @@ class XHTMLPhDFormat extends PhDFormat {
return '</var>';
}
+ public function format_footnoteref($open, $name, $attrs, $props) {
+ if ($open) {
+ $linkend = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"];
+ $found = false;
+ foreach($this->cchunk["footnote"] as $k => $note) {
+ if ($note["id"] === $linkend) {
+ return '<a href="#fnid' .$note["id"].
'"><sup>[' .($k + 1). ']</sup></a>';
+ }
+ }
+ 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[PhDReader::XMLNS_XML]["id"]) ?
$attrs[PhDReader::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 '<a href="#fnid' .$noteid. '"
name="fn'.$noteid.'"><sup>[' .($count + 1).
']</sup></a>';
+ }
+ 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"] .= '<span
class="para footnote">';
+ return "";
+ }
+
+ $this->cchunk["footnote"][$k]["str"] .= "</span>";
+ 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[PhDReader::XMLNS_XML]["id"])) {
- if(isset($this->tmp["co"])) {
- ++$this->tmp["co"];
- } else {
- $this->tmp["co"] = 1;
- }
- return '<a
name="'.$attrs[PhDReader::XMLNS_XML]["id"].'"
id="'.$attrs[PhDReader::XMLNS_XML]["id"].'">'
.str_repeat("*", $this->tmp["co"]) .'</a>';
+ $co = ++$this->cchunk["co"];
+ return '<a
name="'.$attrs[PhDReader::XMLNS_XML]["id"].'"
id="'.$attrs[PhDReader::XMLNS_XML]["id"].'">'
.str_repeat("*", $co) .'</a>';
}
/* Suppress closing tag if any */
return "";
}
public function format_calloutlist($open, $name, $attrs) {
if ($open) {
- $this->tmp["callouts"] = 0;
+ $this->cchunk["callouts"] = 0;
return '<table>';
}
return '</table>';
}
public function format_callout($open, $name, $attrs) {
if ($open) {
- return '<tr><td><a
href="#'.$attrs[PhDReader::XMLNS_DOCBOOK]["arearefs"].'">'
.str_repeat("*", ++$this->tmp["callouts"]).
'</a></td><td>';
+ return '<tr><td><a
href="#'.$attrs[PhDReader::XMLNS_DOCBOOK]["arearefs"].'">'
.str_repeat("*", ++$this->cchunk["callouts"]).
'</a></td><td>';
}
return "</td></tr>\n";
}
@@ -574,32 +787,32 @@ class XHTMLPhDFormat extends PhDFormat {
return ")</span>";
}
public function format_segmentedlist($open, $name, $attrs) {
- $this->tmp["segmentedlist"] = array("segtitle" => array());
+ $this->cchunk["segmentedlist"] = $this->dchunk["segmentedlist"];
if ($open) {
return '<div class="'.$name.'">';
}
return '</div>';
}
public function format_segtitle_text($value, $tag) {
-
$this->tmp["segmentedlist"]["segtitle"][count($this->tmp["segmentedlist"]["segtitle"])]
= $value;
+
$this->cchunk["segmentedlist"]["segtitle"][count($this->cchunk["segmentedlist"]["segtitle"])]
= $value;
/* Suppress the text */
return "";
}
public function format_seglistitem($open, $name, $attrs) {
if ($open) {
- $this->tmp["segmentedlist"]["seglistitem"] = 0;
+ $this->cchunk["segmentedlist"]["seglistitem"] = 0;
return '<div class="'.$name.'">';
}
return '</div>';
}
public function format_seg($open, $name, $attrs) {
if ($open) {
- return '<div class="seg"><strong><span
class="segtitle">'
.$this->tmp["segmentedlist"]["segtitle"][$this->tmp["segmentedlist"]["seglistitem"]++].
':</span></strong>';
+ return '<div class="seg"><strong><span
class="segtitle">'
.$this->cchunk["segmentedlist"]["segtitle"][$this->cchunk["segmentedlist"]["seglistitem"]++].
':</span></strong>';
}
return '</div>';
}
public function format_procedure($open, $name, $attrs) {
- $this->tmp["procedure"] = false;
+ $this->cchunk["procedure"] = false;
if ($open) {
return '<div class="'.$name.'">';
}
@@ -608,8 +821,8 @@ class XHTMLPhDFormat extends PhDFormat {
public function format_step($open, $name, $attrs) {
if ($open) {
$ret = "";
- if (!$this->tmp["procedure"]) {
- $this->tmp["procedure"] = true;
+ if ($this->cchunk["procedure"] === false) {
+ $this->cchunk["procedure"] = true;
$ret = '<ol type="1">';
}
return $ret . "<li>";
@@ -701,6 +914,21 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</div>";
}
+ public function format_authorgroup_author($open, $name, $attrs, $props) {
+ if ($open) {
+ if ($props["sibling"] !== $name) {
+ return '<div class="'.$name.' vcard">'
.$this->admonition_title("by", $props["lang"]). ':<br />';
+ }
+ return '<div class="'.$name.' vcard">';
+ }
+ return "</div>\n";
+ }
+ public function format_editor($open, $name, $attrs, $props) {
+ if ($open) {
+ return '<div class="editor vcard">'
.$this->admonition_title("editedby", $props["lang"]). ': ';
+ }
+ return "</div>\n";
+ }
public function format_note($open, $name, $attrs, $props) {
if ($open) {
return
'<blockquote><p>'.$this->admonition_title("note",
$props["lang"]). ': ';
@@ -740,27 +968,50 @@ class XHTMLPhDFormat extends PhDFormat {
}
public function format_mediaobject($open, $name, $attrs) {
- $this->tmp["mediaobject"] = array();
+ $this->cchunk["mediaobject"] = $this->dchunk["mediaobject"];
if ($open) {
return '<div class="'.$name.'">';
}
return '</div>';
}
public function format_alt_text($value, $tag) {
- $this->tmp["mediaobject"]["alt"] = $value;
+ $this->cchunk["mediaobject"]["alt"] = $value;
}
public function format_imagedata($open, $name, $attrs) {
- if (isset($this->tmp["mediaobject"]["alt"])) {
- return '<img src="'
.$attrs[PhDReader::XMLNS_DOCBOOK]["fileref"]. '" alt="'
.$this->tmp["mediaobject"]["alt"]. '" />';
+ if ($this->cchunk["mediaobject"]["alt"] !== false) {
+ return '<img src="'
.$attrs[PhDReader::XMLNS_DOCBOOK]["fileref"]. '" alt="'
.$this->cchunk["mediaobject"]["alt"]. '" />';
}
return '<img src="'
.$attrs[PhDReader::XMLNS_DOCBOOK]["fileref"]. '" />';
}
- public function format_table($open, $name, $attrs) {
+ public function format_table($open, $name, $attrs, $props) {
if ($open) {
+ $this->cchunk["table"] = true;
return '<table border="5">';
}
- return "</table>\n";
+ $this->cchunk["table"] = false;
+ $str = "";
+ if ($this->cchunk["tablefootnotes"]) {
+ $opts = array(PhDReader::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 .= '<div class="footnote">';
+ $str .= '<a name="fnid' .$noteid. '"
href="#fn' .$noteid .'"><sup>[' .($k + 1).
']</sup></a>' .$this->cchunk["footnote"][$k]["str"] .
"\n";
+ unset($this->cchunk["footnote"][$k]);
+ $str .= "</div>\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</table>\n";
}
public function format_tgroup($open, $name, $attrs) {
if ($open) {
@@ -803,7 +1054,7 @@ class XHTMLPhDFormat extends PhDFormat {
public function format_tbody($open, $name, $attrs) {
if ($open) {
$valign = PhDFormat::valign($attrs[PhDReader::XMLNS_DOCBOOK]);
- return '<tbody valign="' .$valign. '">';
+ return '<tbody valign="' .$valign. '" class="'
.$name. '">';
}
return "</tbody>";
}
@@ -815,7 +1066,7 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</tr>\n";
}
- public function format_th_entry($open, $name, $attrs = array()) {
+ public function format_th_entry($open, $name, $attrs) {
if ($open) {
$colspan = PhDFormat::colspan($attrs[PhDReader::XMLNS_DOCBOOK]);
return '<th colspan="' .((int)$colspan). '">';
@@ -836,7 +1087,16 @@ class XHTMLPhDFormat extends PhDFormat {
}
}
- $colspan = PhDFormat::colspan($dbattrs);
+ /*
+ * "colspan" is *not* an standard prop, only used to overwrite the
+ * colspan for <footnote>s in tables
+ */
+ if (isset($props["colspan"])) {
+ $colspan = $props["colspan"];
+ } else {
+ $colspan = PhDFormat::colspan($dbattrs);
+ }
+
$rowspan = PhDFormat::rowspan($dbattrs);
$moreattrs = self::parse_table_entry_attributes($dbattrs);
return $retval. '<td colspan="' .((int)$colspan). '"
rowspan="' .((int)$rowspan). '" ' .$moreattrs. '>';
diff --git a/phpdotnet/phd/Helper.php b/phpdotnet/phd/Helper.php
index ce3f157..837d10c 100644
--- a/phpdotnet/phd/Helper.php
+++ b/phpdotnet/phd/Helper.php
@@ -3,12 +3,14 @@
class PhDHelper {
private $IDs = array();
+ private $refs = array();
/* abstract */ protected $elementmap = array();
/* abstract */ protected $textmap = array();
private static $autogen = array();
- public function __construct(array $IDs) {
- $this->IDs = $IDs;
+ public function __construct(array $a) {
+ $this->IDs = $a[0];
+ $this->refs = $a[1];
}
final public function getFilename($id) {
return isset($this->IDs[$id]) ? $this->IDs[$id]["filename"] : false;
@@ -24,6 +26,9 @@ class PhDHelper {
final public function getParent($id) {
return $this->IDs[$id]["parent"];
}
+ public function getRefnameLink($ref) {
+ return isset($this->refs[$ref]) ? $this->refs[$ref] : null;
+ }
final public function getElementMap() {
return $this->elementmap;
}
diff --git a/phpdotnet/phd/Reader/Legacy.php b/phpdotnet/phd/Reader/Legacy.php
index ea2cfb8..60d848f 100644
--- a/phpdotnet/phd/Reader/Legacy.php
+++ b/phpdotnet/phd/Reader/Legacy.php
@@ -3,19 +3,22 @@
//6271
class PhDReader extends XMLReader {
+
+ /* {{{ Class constants */
const XMLNS_XML = "http://www.w3.org/XML/1998/namespace";
const XMLNS_XLINK = "http://www.w3.org/1999/xlink";
const XMLNS_PHD = "http://www.php.net/ns/phd";
const XMLNS_DOCBOOK = "http://docbook.org/ns/docbook";
const OPEN_CHUNK = 0x01;
const CLOSE_CHUNK = 0x02;
+ /* }}} */
+ /* {{{ Private props */
private $STACK = array();
private $LAST_DEPTH = -1;
private $lastChunkDepth = -1;
private $PREVIOUS_SIBLING = "";
-
- public $isChunk = false;
+ /* }}} */
protected $CHUNK_ME = array( /* {{{ */
'article' => true,
@@ -59,7 +62,9 @@ class PhDReader extends XMLReader {
); /* }}} */
protected $opts = array();
- public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) {
+ public $isChunk = false;
+
+ public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) { /* {{{ */
if (!XMLReader::open($opts["xml_file"], $encoding, $xml_opts)) {
throw new Exception("Cannot open {$opts["xml_file"]}");
}
@@ -69,9 +74,9 @@ class PhDReader extends XMLReader {
}
}
$this->opts = $opts;
- }
+ } /* }}} */
- public function notXPath($tag, $depth = 0) {
+ public function notXPath($tag, $depth = 0) { /* {{{ */
if(!$depth) {
$depth = $this->depth;
}
@@ -83,36 +88,36 @@ class PhDReader extends XMLReader {
}
} while (is_array($tag));
return $tag;
- }
+ } /* }}} */
/* Seek to an ID within the file. */
- public function seek($id) {
+ public function seek($id) { /* {{{ */
while(XMLReader::read()) {
if ($this->nodeType === XMLREADER::ELEMENT && $this->hasAttributes
&& XMLReader::moveToAttributeNs("id", self::XMLNS_XML) && $this->value
=== $id) {
return XMLReader::moveToElement();
}
}
return false;
- }
+ } /* }}} */
/* Get the ID of current node */
- public function getID() {
+ public function getID() { /* {{{ */
if ($this->hasAttributes && XMLReader::moveToAttributeNs("id",
self::XMLNS_XML)) {
$id = $this->value;
XMLReader::moveToElement();
return $id;
}
return "";
- }
+ } /* }}} */
- public function getParentTagName() {
+ public function getParentTagName() { /* {{{ */
return $this->STACK[$this->depth-1];
- }
- public function getPreviousSiblingTagName() {
+ } /* }}} */
+ public function getPreviousSiblingTagName() { /* {{{ */
return $this->PREVIOUS_SIBLING;
- }
+ } /* }}} */
- public function read() {
+ public function read() { /* {{{ */
$this->isChunk = false;
if(XMLReader::read()) {
$type = $this->nodeType;
@@ -144,21 +149,21 @@ class PhDReader extends XMLReader {
return true;
}
return false;
- }
+ } /* }}} */
/* Get the attribute value by name, if exists. */
- public function readAttribute($attr) {
+ public function readAttribute($attr) { /* {{{ */
$retval = XMLReader::moveToAttribute($attr) ? $this->value : "";
XMLReader::moveToElement();
return $retval;
- }
- public function readAttributeNs($attr, $ns) {
+ } /* }}} */
+ public function readAttributeNs($attr, $ns) { /* {{{ */
$retval = XMLReader::moveToAttributeNs($attr, $ns) ? $this->value : "";
XMLReader::moveToElement();
return $retval;
- }
+ } /* }}} */
/* Get all attributes of current node */
- public function getAttributes() {
+ public function getAttributes() { /* {{{ */
$attrs = array(PhDReader::XMLNS_DOCBOOK => array(), PhDReader::XMLNS_XML => array());
if ($this->hasAttributes) {
XMLReader::moveToFirstAttribute();
@@ -170,11 +175,11 @@ class PhDReader extends XMLReader {
XMLReader::moveToElement();
}
return $attrs;
- }
+ } /* }}} */
/* Get the content of a named node, or the current node. */
- public function readContent($node = null) {
+ public function readContent($node = null) { /* {{{ */
$retval = "";
if($this->isEmptyElement) {
@@ -188,14 +193,14 @@ class PhDReader extends XMLReader {
$retval .= $this->value;
}
return $retval;
- }
+ } /* }}} */
/* Read $nodeName until END_ELEMENT */
- public function readNode($nodeName) {
+ public function readNode($nodeName) { /* {{{ */
return XMLReader::read() && !($this->nodeType === XMLReader::END_ELEMENT
&& $this->name == $nodeName);
- }
+ } /* }}} */
- public function isChunk($tag) {
+ public function isChunk($tag) { /* {{{ */
if (isset($this->CHUNK_ME[$tag])) {
$isChunk = $this->CHUNK_ME[$tag];
if (is_array($isChunk)) {
@@ -207,14 +212,14 @@ class PhDReader extends XMLReader {
return $isChunk;
}
return false;
- }
- public function isSectionChunk($tag) {
+ } /* }}} */
+ public function isSectionChunk($tag) { /* {{{ */
if ($this->PREVIOUS_SIBLING == $tag && $this->checkSectionDepth()) {
return true;
}
return false;
- }
- protected function checkSectionDepth() {
+ } /* }}} */
+ protected function checkSectionDepth() { /* {{{ */
static $allowedParents = array("section", "sect2", "sect3",
"sect4", "sect5");
static $chunkers = array(
"sect1", "preface", "chapter", "appendix",
"article", "part", "reference", "refentry",
@@ -234,11 +239,11 @@ class PhDReader extends XMLReader {
return true;
}
return false;
- }
+ } /* }}} */
}
/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
+* vim600: sw=4 ts=4 syntax=php fdm=marker et
* vim<600: sw=4 ts=4
*/
diff --git a/phpdotnet/phd/Reader/Partial.php b/phpdotnet/phd/Reader/Partial.php
index 83fbe49..f39bd19 100644
--- a/phpdotnet/phd/Reader/Partial.php
+++ b/phpdotnet/phd/Reader/Partial.php
@@ -3,6 +3,7 @@
class PhDPartialReader extends PhDReader {
protected $partial = array();
+ protected $skip = array();
public function __construct($opts, $encoding = "UTF-8", $xml_opts = NULL) {
parent::__construct($opts, $encoding, $xml_opts);
@@ -13,6 +14,13 @@ class PhDPartialReader extends PhDReader {
} else {
$this->partial[$opts["render_ids"]] = 1;
}
+ if (isset($opts["skip_ids"])) {
+ if (is_array($opts["skip_ids"])) {
+ $this->skip = $opts["skip_ids"];
+ } else {
+ $this->skip[$opts["skip_ids"]] = 1;
+ }
+ }
} else {
throw new Exception("Didn't get any IDs to seek");
}
@@ -21,6 +29,7 @@ class PhDPartialReader extends PhDReader {
public function read() {
static $seeked = 0;
static $currently_reading = false;
+ static $currently_skipping = false;
$ignore = false;
while($ret = parent::read()) {
@@ -42,6 +51,30 @@ class PhDPartialReader extends PhDReader {
++$seeked;
}
return $ret;
+ } elseif (isset($this->skip[$id])) {
+ if ($this->isChunk == PhDReader::CLOSE_CHUNK) {
+ if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) {
+ v("%s done\n", $id);
+ }
+ unset($this->skip[$id]);
+ $currently_skipping = false;
+ $ignore = false;
+ } else {
+ if ($this->opts["verbose"] & VERBOSE_PARTIAL_READING) {
+ v("Skipping %s...\n", $id);
+ }
+ $currently_skipping = $id;
+ $ignore = true;
+ }
+ } elseif ($currently_skipping && $this->skip[$currently_skipping]) {
+ if ($this->opts["verbose"] & VERBOSE_PARTIAL_CHILD_READING) {
+ if ($this->isChunk == PhDReader::OPEN_CHUNK) {
+ v("Skipping child of %s, %s\n", $currently_reading, $id);
+ } else {
+ v("%s done\n", $id);
+ }
+ }
+ $ignore = true;
} elseif ($currently_reading && $this->partial[$currently_reading]) {
if ($this->opts["verbose"] & VERBOSE_PARTIAL_CHILD_READING) {
if ($this->isChunk == PhDReader::OPEN_CHUNK) {
diff --git a/phpdotnet/phd/Theme/PHP/BigHTML.php b/phpdotnet/phd/Theme/PHP/BigHTML.php
index 51f0e03..21f4f4d 100644
--- a/phpdotnet/phd/Theme/PHP/BigHTML.php
+++ b/phpdotnet/phd/Theme/PHP/BigHTML.php
@@ -5,7 +5,7 @@ require_once $ROOT . '/themes/php/phpdotnet.php';
class bightml extends phpdotnet {
public function __construct(array $IDs, $filename, $ext = "html") {
parent::__construct($IDs, $filename, $ext, false);
- $this->stream = fopen("bightml.html", "w");
+ $this->stream = fopen($GLOBALS['OPTIONS']['output_dir'] .
"bightml.html", "w");
self::header();
}
public function appendData($data, $isChunk) {
@@ -33,7 +33,7 @@ class bightml extends phpdotnet {
}
public function format_qandaset($open, $name, $attrs) {
if ($open) {
- $this->tmp["qandaentry"] = array();
+ $this->cchunk["qandaentry"] = array();
$this->ostream = $this->stream;
$this->stream = fopen("php://temp/maxmemory", "r+");
return '';
diff --git a/phpdotnet/phd/Theme/PHP/ChunkedHTML.php b/phpdotnet/phd/Theme/PHP/ChunkedHTML.php
index cd2d791..db20a32 100644
--- a/phpdotnet/phd/Theme/PHP/ChunkedHTML.php
+++ b/phpdotnet/phd/Theme/PHP/ChunkedHTML.php
@@ -7,8 +7,9 @@ class chunkedhtml extends phpweb {
public function __construct(array $IDs, $filename, $ext = "html") {
phpdotnet::__construct($IDs, $filename, $ext, true);
- if(!file_exists("html") || is_file("html")) mkdir("html") or
die("Can't create the cache directory");
- elseif (file_exists('html/index.html')) unlink('html/index.html'); //
preserve back-compat
+ $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext .
DIRECTORY_SEPARATOR;
+ if(!file_exists($this->outputdir) || is_file($this->outputdir))
mkdir($this->outputdir) or die("Can't create the cache directory");
+ elseif (file_exists($this->outputdir . 'index.html'))
unlink($this->outputdir . 'index.html'); // preserve back-compat
}
public function header($id) {
$title = PhDHelper::getDescription($id, true);
@@ -48,8 +49,8 @@ NAV;
return "<hr />$nav</body></html>\n";
}
public function __destruct() {
- if (file_exists("html/manual.html") &&
!file_exists('html/index.html')) {
- copy("html/manual.html", "html/index.html");
+ if (file_exists($this->outputdir . "manual.html") &&
!file_exists($this->outputdir . 'index.html')) {
+ copy($this->outputdir . "manual.html", $this->outputdir .
"index.html");
}
}
}
diff --git a/phpdotnet/phd/Theme/PHP/PHPDotNet.php b/phpdotnet/phd/Theme/PHP/PHPDotNet.php
index bffde4c..7a530f1 100644
--- a/phpdotnet/phd/Theme/PHP/PHPDotNet.php
+++ b/phpdotnet/phd/Theme/PHP/PHPDotNet.php
@@ -32,6 +32,10 @@ abstract class phpdotnet extends PhDTheme {
'methodparam' => false,
'methodsynopsis' => false,
),
+ 'varname' => array(
+ /* DEFAULT */ false,
+ 'fieldsynopsis' => 'format_fieldsynopsis_varname',
+ ),
'xref' => 'format_link',
@@ -98,9 +102,12 @@ abstract class phpdotnet extends PhDTheme {
'type' => array(
/* DEFAULT */ 'format_type_text',
'classsynopsisinfo' => false,
- 'fieldsynopsis' => false,
- 'methodparam' => false,
- 'methodsynopsis' => false,
+ 'fieldsynopsis' => 'format_type_if_object_or_pseudo_text',
+ 'methodparam' => 'format_type_if_object_or_pseudo_text',
+ 'methodsynopsis' => array(
+ /* DEFAULT */ 'format_type_if_object_or_pseudo_text',
+ 'classsynopsis' => false,
+ ),
),
'refname' => 'format_refname_text',
@@ -112,9 +119,21 @@ abstract class phpdotnet extends PhDTheme {
protected $lang = "en";
protected $CURRENT_ID = "";
- protected $CURRENT_FUNCTION = null;
protected $refname;
+ /* Current Chunk settings */
+ protected $cchunk = array();
+ /* Default Chunk settings */
+ protected $dchunk = array(
+ "fieldsynopsis" => array(
+ "modifier" => "public",
+ ),
+ "container_chunk" => null,
+ "qandaentry" => array(
+ ),
+ "examples" => 0,
+ );
+
public function __construct(array $IDs, array $filenames, $ext = "php", $chunked =
true) {
parent::__construct($IDs, $ext);
$this->ext = $ext;
@@ -182,13 +201,17 @@ abstract class phpdotnet extends PhDTheme {
if ($open) {
$content = $fragment = "";
$class = $name;
+
if(isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) {
$linkto = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"];
$id = $href = PhDHelper::getFilename($linkto);
+
if ($id != $linkto) {
$fragment = "#$linkto";
}
- $href .= ".".$this->ext;
+ if ($this->chunked) {
+ $href .= ".".$this->ext;
+ }
} elseif(isset($attrs[PhDReader::XMLNS_XLINK]["href"])) {
$href = $attrs[PhDReader::XMLNS_XLINK]["href"];
$content = "» ";
@@ -215,15 +238,50 @@ abstract class phpdotnet extends PhDTheme {
return '<a href="' .$link.$href.$fragment. '"
class="' .$class. '">' .$content.$href.$fragment.
'</a>';
} else {
if ($this->chunked) {
- $link = "";
+ $link = $href.$fragment;
+ } elseif(isset($linkto)) {
+ if ($fragment) {
+ $link = $fragment;
+ } else {
+ $link = "#$href";
+ }
} else {
- $link = "#";
+ $link = $href;
}
- return '<a href="' .$link.$href.$fragment. '"
class="' .$class. '">' .$content;
+ return '<a href="' .$link. '" class="'
.$class. '">' .$content;
}
}
return "</a>";
}
+ public function format_fieldsynopsis_varname($open, $name, $attrs) {
+ if ($open) {
+ $href = "";
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) {
+ $linkto = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"];
+ $href = PhDHelper::getFilename($linkto);
+
+ if ($this->chunked) {
+ if ($href != $linkto) {
+ $href .= ".{$this->ext}#{$linkto}";
+ } else {
+ $href .= '.' .$this->ext;
+ }
+ } else {
+ $href = '#' .$linkto;
+ }
+ $href = '<a href="' .$href. '">';
+ }
+ if ($this->cchunk["fieldsynopsis"]["modifier"] ==
"const") {
+ return '<var class="fieldsynopsis_varname">'.$href;
+ }
+ return '<var
class="'.$name.'">'.$href.'$';
+ }
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) {
+ return '</a></var>';
+ }
+ return '</var>';
+ }
+
@@ -247,7 +305,7 @@ abstract class phpdotnet extends PhDTheme {
}
public function format_refpurpose($open, $tag, $attrs) {
if ($open) {
- return '<p class="verinfo">('
.(htmlspecialchars($this->versionInfo($this->refname), ENT_QUOTES, "UTF-8")).
')</p><p class="refpurpose">'. $this->refname. ' â
';
+ return '<p class="verinfo">('
.(htmlspecialchars($this->versionInfo($this->refname), ENT_QUOTES, "UTF-8")).
')</p><p class="refpurpose dc-title">'. $this->refname. '
â ';
}
return "</p>\n";
}
@@ -258,17 +316,9 @@ abstract class phpdotnet extends PhDTheme {
public function format_chunk($open, $name, $attrs, $props) {
if (isset($attrs[PhDReader::XMLNS_XML]["id"])) {
$this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"];
- if ($name == "refentry") {
- if(strpos($id, "function.") !== false) {
- $id = substr($id, 9);
- }
- $this->CURRENT_FUNCTION = $id;
- } else {
- $this->CURRENT_FUNCTION = null;
- }
}
if ($props["isChunk"]) {
- $this->tmp["chunk"] = array("examples" => 0);
+ $this->cchunk = $this->dchunk;
}
if (isset($props["lang"])) {
$this->lang = $props["lang"];
@@ -277,10 +327,9 @@ abstract class phpdotnet extends PhDTheme {
}
public function format_container_chunk($open, $name, $attrs, $props) {
$this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"];
- $this->CURRENT_FUNCTION = null;
if ($open) {
if ($props["isChunk"]) {
- $this->tmp["chunk"] = array("examples" => 0);
+ $this->cchunk = $this->dchunk;
}
if ($name != "reference") {
$chunks = PhDHelper::getChildren($id);
@@ -289,10 +338,14 @@ abstract class phpdotnet extends PhDTheme {
}
$content = '<h2>'.$this->autogen("toc",
$props["lang"]). '</h2><ul class="chunklist
chunklist_'.$name.'">';
foreach($chunks as $chunkid => $junk) {
- $content .= '<li><a href="' .($this->chunked ?
"" : "#").$chunkid. '.' .$this->ext. '">'
.(PhDHelper::getDescription($chunkid, true)). '</a></li>';
+ if ($this->chunked) {
+ $content .= '<li><a href="'.$chunkid. '.'
.$this->ext. '">' .(PhDHelper::getDescription($chunkid, true)).
'</a></li>';
+ } else {
+ $content .= '<li><a href="#'.$chunkid.
'">' .(PhDHelper::getDescription($chunkid, true)).
'</a></li>';
+ }
}
$content .= "</ul>\n";
- $this->tmp["container_chunk"] = $content;
+ $this->cchunk["container_chunk"] = $content;
}
return "<div>";
}
@@ -300,10 +353,14 @@ abstract class phpdotnet extends PhDTheme {
$content = "";
if ($name == "reference") {
$chunks = PhDHelper::getChildren($id);
- if (count($chunks) > 1) {
+ if (count($chunks)) {
$content = '<h2>'.$this->autogen("toc",
$props["lang"]). '</h2><ul class="chunklist
chunklist_reference">';
foreach($chunks as $chunkid => $junk) {
- $content .= '<li><a href="' .($this->chunked ?
"" : "#").$chunkid. '.' .$this->ext. '">'
.(PhDHelper::getDescription($chunkid, false)). '</a> â '
.(PhDHelper::getDescription($chunkid, true)). '</li>';
+ if ($this->chunked) {
+ $content .= '<li><a href="'.$chunkid. '.'
.$this->ext. '">' .(PhDHelper::getDescription($chunkid, false)).
'</a> â ' .(PhDHelper::getDescription($chunkid, true)).
'</li>';
+ } else {
+ $content .= '<li><a
href="#'.$chunkid.'">' .(PhDHelper::getDescription($chunkid, false)).
'</a> â ' .(PhDHelper::getDescription($chunkid, true)).
'</li>';
+ }
}
$content .= "</ul>\n";
}
@@ -317,15 +374,14 @@ abstract class phpdotnet extends PhDTheme {
return "<h1>";
}
$ret = "";
- if ($this->tmp["container_chunk"]) {
- $ret = $this->tmp["container_chunk"];
- $this->tmp["container_chunk"] = null;
+ if ($this->cchunk["container_chunk"]) {
+ $ret = $this->cchunk["container_chunk"];
+ $this->cchunk["container_chunk"] = null;
}
return "</h1>\n" .$ret;
}
public function format_root_chunk($open, $name, $attrs) {
$this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"];
- $this->CURRENT_FUNCTION = null;
if ($open) {
return "<div>";
}
@@ -377,24 +433,25 @@ abstract class phpdotnet extends PhDTheme {
if ($display_value === null) {
$display_value = $value;
}
+ $rel = "";
+ if ($this->format->role == "seealso") {
+ $rel = ' rel="rdfs-seeAlso"';
+ }
- $link = strtolower(str_replace(array("__", "_", "::",
"->"), array("", "-", "-", "-"), $value));
- $oop_link = strtolower(str_replace(array("_", "::", "->"),
array("", ".", "."), $value));
-
- if (
- (
- $this->CURRENT_FUNCTION === $link ||
- !($filename = PhDHelper::getFilename("function.$link"))
- ) &&
- (
- $this->CURRENT_ID === $oop_link ||
- !($filename = PhDHelper::getFilename($oop_link))
- )
- ) {
- return '<b>' .$display_value.($tag == "function" ?
"()" : ""). '</b>';
+ $ref = strtolower(str_replace(array("_", "::", "->"),
array("-", "-", "-"), $value));
+ if (($filename = $this->getRefnameLink($ref)) !== null && $this->CURRENT_ID
!== $filename) {
+ if ($this->chunked) {
+ return '<a href="'.$filename. '.' .$this->ext.
'" class="function"'.$rel.'>' .$display_value.($tag ==
"function" ? "()" : ""). '</a>';
+ }
+ return '<a href="#'.$filename. '"
class="function"'.$rel.'>' .$display_value.($tag == "function"
? "()" : ""). '</a>';
}
-
- return '<a href="' .($this->chunked ? "" :
"#").$filename. '.' .$this->ext. '"
class="function">' .$display_value.($tag == "function" ? "()"
: ""). '</a>';
+ return '<b>' .$display_value.($tag == "function" ? "()"
: ""). '</b>';
+ }
+ public function format_type_if_object_or_pseudo_text($type, $tagname) {
+ if (in_array(strtolower($type), array("bool", "int",
"double", "boolean", "integer", "float", "string",
"array", "object", "resource", "null"))) {
+ return false;
+ }
+ return self::format_type_text($type, $tagname);
}
public function format_type_text($type, $tagname) {
$t = strtolower($type);
@@ -445,7 +502,7 @@ abstract class phpdotnet extends PhDTheme {
return "";
}
if ($open) {
- return "<p><b>Example#"
.++$this->tmp["chunk"]["examples"]. " ";
+ return "<p><b>" . ($this->autogen('example',
$props['lang']) . ++$this->cchunk["examples"]) . " ";
}
return "</b></p>";
}
@@ -454,34 +511,37 @@ abstract class phpdotnet extends PhDTheme {
public function qandaset($stream) {
$xml = stream_get_contents($stream);
- libxml_use_internal_errors(true);
+ $old = 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"));
+ $doc->loadXML(html_entity_decode(str_replace("&",
"&amp;", "<div>$xml</div>"), ENT_QUOTES,
"UTF-8"));
+ if ($err = libxml_get_errors()) {
+ print_r($err);
+ libxml_clear_errors();
+ }
fclose($stream);
- libxml_clear_errors();
- libxml_use_internal_errors(false);
+ libxml_use_internal_errors($old);
$xpath = new DOMXPath($doc);
- $nlist = $xpath->query("//html/body/div/dl/dt");
+ $nlist = $xpath->query("//div/dl/dt");
$ret = '<div class="qandaset"><ol
class="qandaset_questions">';
$i = 0;
foreach($nlist as $node) {
- $ret .= '<li><a href="#'
.($this->tmp["qandaentry"][$i++]). '">'
.(htmlspecialchars($node->textContent,ENT_QUOTES, "UTF-8")).
'</a></li>';
+ $ret .= '<li><a href="#'
.($this->cchunk["qandaentry"][$i++]). '">' .($node->textContent).
'</a></li>';
}
- return $ret.'</ul>'.$xml.'</div>';
+ return $ret.'</ol>'.$xml.'</div>';
}
public function format_qandaentry($open, $name, $attrs) {
if ($open) {
- $this->tmp["qandaentry"][] = $attrs[PhDReader::XMLNS_XML]["id"];
+ $this->cchunk["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><a name="'
.end($this->cchunk["qandaentry"]).'"></a>';
}
return "</dd>";
}
diff --git a/phpdotnet/phd/Theme/PHP/Web.php b/phpdotnet/phd/Theme/PHP/Web.php
index 5fd6259..238ef05 100644
--- a/phpdotnet/phd/Theme/PHP/Web.php
+++ b/phpdotnet/phd/Theme/PHP/Web.php
@@ -5,31 +5,52 @@ require_once $ROOT . '/themes/php/phpdotnet.php';
class phpweb extends phpdotnet {
protected $streams = array();
protected $writeit = false;
+ protected $outputdir = '';
public function __construct($IDs, $filename, $ext = "php", $chunked = true) {
parent::__construct($IDs, $filename, $ext, $chunked);
- if (!file_exists("php") || is_file("php")) mkdir("php") or
die("Can't create the cache directory");
- if (!file_exists("php/toc") || is_file("php/toc"))
mkdir("php/toc") or die("Can't create the toc directory");
+ $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext
. DIRECTORY_SEPARATOR;
+ if (!file_exists($this->outputdir) || is_file($this->outputdir))
mkdir($this->outputdir) or die("Can't create the cache directory");
+ if (!file_exists($this->outputdir . "toc") || is_file($this->outputdir .
"toc")) mkdir($this->outputdir . "toc") or die("Can't create the
toc directory");
}
public function writeChunk($id, $stream) {
rewind($stream);
- $filename = $this->ext."/$id.".$this->ext;
- file_put_contents($filename, $this->header($id));
- file_put_contents($filename, $stream, FILE_APPEND);
- file_put_contents($filename, $this->footer($id), FILE_APPEND);
+
+ // Create random filename when the chunk doesn't have an ID
+ if ($id === null) {
+ $filename = tempnam($this->outputdir, 'phd');
+ $newfilename = $this->outputdir . basename($filename, '.tmp') .
'.' . $this->ext;
+ if(rename($filename, $newfilename)) {
+ $filename = basename($filename, '.tmp');
+ } else {
+ throw new Exception("Cannot rename $filename to $newfilename");
+ }
+ v("WARNING: Chunk without an ID found, TOC will NOT work. Wrote content to
$newfilename.\n");
+ } else {
+ $filename = $id;
+ }
+ $filename .= '.' . $this->ext;
+
+ file_put_contents($this->outputdir . $filename, $this->header($id));
+ file_put_contents($this->outputdir . $filename, $stream, FILE_APPEND);
+ file_put_contents($this->outputdir . $filename, $this->footer($id), FILE_APPEND);
+
if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_CHUNK_WRITING) {
- v("Wrote %s\n", $filename);
+ v("Wrote %s\n", $this->outputdir . $filename);
}
}
public function appendData($data, $isChunk) {
switch($isChunk) {
case PhDReader::CLOSE_CHUNK:
$id = $this->CURRENT_ID;
+
$stream = array_pop($this->streams);
$retval = fwrite($stream, $data);
$this->writeChunk($id, $stream);
fclose($stream);
+
+ $this->CURRENT_ID = null;
return $retval;
break;
@@ -45,7 +66,7 @@ class phpweb extends phpdotnet {
public function header($id) {
$ext = '.' .$this->ext;
$parent = PhDHelper::getParent($id);
- $filename = $this->ext . DIRECTORY_SEPARATOR . "toc" . DIRECTORY_SEPARATOR .
$parent . ".inc";
+ $filename = "toc" . DIRECTORY_SEPARATOR . $parent . ".inc";
$up = array(null, null);
$incl = '';
@@ -57,7 +78,8 @@ class phpweb extends phpdotnet {
* to easily add new pages without needing to rebuild the entire
* section.
*/
- if (!file_exists($filename)) {
+ if (!file_exists($this->outputdir . $filename)) {
+ $toc = array();
foreach($siblings as $sid => $array) {
$toc[] = array($sid.$ext, empty($array["sdesc"]) ?
$array["ldesc"] : $array["sdesc"]);
@@ -73,10 +95,10 @@ class phpweb extends phpdotnet {
$TOC = ' . var_export($toc, true) . ';
$PARENTS = ' . var_export($parents, true) . ';';
- file_put_contents($filename, $content);
+ file_put_contents($this->outputdir . $filename, $content);
if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_TOC_WRITING) {
- v("Wrote TOC (%s)\n", $filename);
+ v("Wrote TOC (%s)\n", $this->outputdir . $filename);
}
}
@@ -181,13 +203,13 @@ manual_header();
return $next;
}
public function __destruct() {
- if (file_exists("php/manual.php")) {
- copy("php/manual.php", "php/index.php");
+ if (file_exists($this->outputdir . "manual.php")) {
+ copy($this->outputdir . "manual.php", $this->outputdir .
"index.php");
}
}
public function format_qandaset($open, $name, $attrs) {
if ($open) {
- $this->tmp["qandaentry"] = array();
+ $this->cchunk["qandaentry"] = array();
$this->appendData(null, PhDReader::OPEN_CHUNK);
return '';
}
diff --git a/phpdotnet/phd/data/langs/bg.xml b/phpdotnet/phd/data/langs/bg.xml
index 657abc9..1b782d1 100644
--- a/phpdotnet/phd/data/langs/bg.xml
+++ b/phpdotnet/phd/data/langs/bg.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="bg">
<title>Autogenerated text</title>
<variablelist>
@@ -33,5 +33,23 @@
<simpara>СÑвеÑ</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/cs.xml b/phpdotnet/phd/data/langs/cs.xml
index 7d4f819..93ab2f1 100644
--- a/phpdotnet/phd/data/langs/cs.xml
+++ b/phpdotnet/phd/data/langs/cs.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="cs">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Tip</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/de.xml b/phpdotnet/phd/data/langs/de.xml
index e417ce3..508c365 100644
--- a/phpdotnet/phd/data/langs/de.xml
+++ b/phpdotnet/phd/data/langs/de.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="de">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Tipp</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>von</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Herausgegeben von</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Beispiel #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/en.xml b/phpdotnet/phd/data/langs/en.xml
index bbeb9d0..d5fb60b 100644
--- a/phpdotnet/phd/data/langs/en.xml
+++ b/phpdotnet/phd/data/langs/en.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="en">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Tip</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/it.xml b/phpdotnet/phd/data/langs/it.xml
index d12dae5..eb480f0 100644
--- a/phpdotnet/phd/data/langs/it.xml
+++ b/phpdotnet/phd/data/langs/it.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="it">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Suggerimento</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/ja.xml b/phpdotnet/phd/data/langs/ja.xml
index 839fd8f..bc72ba7 100644
--- a/phpdotnet/phd/data/langs/ja.xml
+++ b/phpdotnet/phd/data/langs/ja.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="ja">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>ãã³ã</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>èè
</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>ç·¨é</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>ä¾</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/pl.xml b/phpdotnet/phd/data/langs/pl.xml
index 1237caf..3b78d5e 100644
--- a/phpdotnet/phd/data/langs/pl.xml
+++ b/phpdotnet/phd/data/langs/pl.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="pl">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Wskazówka</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/pt_BR.xml b/phpdotnet/phd/data/langs/pt_BR.xml
index fdb0e69..fae723c 100644
--- a/phpdotnet/phd/data/langs/pt_BR.xml
+++ b/phpdotnet/phd/data/langs/pt_BR.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="pt_BR">
- <title>Autogenerated text</title>
+ <title>Texto autogerado</title>
<variablelist>
<varlistentry>
<term>toc</term>
@@ -33,5 +33,23 @@
<simpara>Dica</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>por</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Editado por</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Exemplo #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/ro.xml b/phpdotnet/phd/data/langs/ro.xml
index 7bac21e..c560c4a 100644
--- a/phpdotnet/phd/data/langs/ro.xml
+++ b/phpdotnet/phd/data/langs/ro.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.2.2.1 $ -->
<section xml:id="autogen" xml:lang="ro">
<title>Autogenerated text</title>
<variablelist>
@@ -33,6 +33,24 @@
<simpara>Sfat</simpara>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Edited By</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>Example #</simpara>
+ </listitem>
+ </varlistentry>
</variablelist>
</section>
diff --git a/phpdotnet/phd/data/langs/ru.xml b/phpdotnet/phd/data/langs/ru.xml
new file mode 100644
index 0000000..857b534
--- /dev/null
+++ b/phpdotnet/phd/data/langs/ru.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!-- $Revision: 1.3.2.2 $ -->
+<section xml:id="autogen" xml:lang="ru">
+ <title>СгенеÑиÑованнÑй
ÑекÑÑ</title>
+ <variablelist>
+ <varlistentry>
+ <term>toc</term>
+ <listitem>
+ <simpara>СодеÑжание</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>warning</term>
+ <listitem>
+ <simpara>Ðнимание</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>note</term>
+ <listitem>
+ <simpara>ÐамеÑание</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>caution</term>
+ <listitem>
+ <simpara>ÐÑедоÑÑеÑежение</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>tip</term>
+ <listitem>
+ <simpara>ÐодÑказка</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>by</term>
+ <listitem>
+ <simpara>by</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>editedby</term>
+ <listitem>
+ <simpara>Ðод ÑедакÑией</simpara>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>example</term>
+ <listitem>
+ <simpara>ÐÑÐ¸Ð¼ÐµÑ #</simpara>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+</section>
+
diff --git a/setup/Configurator.class.php b/setup/Configurator.class.php
deleted file mode 100644
index c6e72dc..0000000
--- a/setup/Configurator.class.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | Provides the common code for managing the config.php file in setup.php. |
- +-------------------------------------------------------------------------+
-*/
-
-require_once 'Template_File.class.php';
-
-class PhD_Configurator {
-
- protected $config_php_path = '';
-
- public function __construct() {
- $this->config_php_path = dirname( __FILE__ ) . '/../config.php';
- }
-
- public function __destruct() {
- }
-
- public function __get( $name ) {
- return $GLOBALS[ 'OPTIONS' ][ $name ];
- }
-
- public function __isset( $name ) {
- return isset( $GLOBALS[ 'OPTIONS' ][ $name ] );
- }
-
- public function __set( $name, $value ) {
- $GLOBALS[ 'OPTIONS' ][ $name ] = $value;
- }
-
- public function __unset( $name ) {
- unset( $GLOBALS[ 'OPTIONS' ][ $name ] );
- }
-
- public function readConfig() {
- if ( file_exists( $this->config_php_path ) && is_readable(
$this->config_php_path ) && is_file( $this->config_php_path ) ) {
- require $this->config_php_path;
- $GLOBALS[ 'OPTIONS' ] = $OPTIONS;
- } else if ( file_exists( $this->config_php_path ) ) {
- PhD_Error( PhD_Errors::CONFIG_UNREADABLE );
- }
- }
-
- public function writeConfig() {
- try {
- $file = new Template_File( dirname( __FILE__ ) . '/config.in.php',
$this->config_php_path, TRUE );
- $file->SETUP_REV = $GLOBALS[ 'SETUP_REVISION' ];
- $file->SETUP_DATE = date( DATE_RFC2822 );
- $file->OPTION_ARRAY = var_export( $GLOBALS[ 'OPTIONS' ], 1 );
- $file->writeTemplate();
- unset( $file );
- } catch ( Exception $e ) {
- $codeMap = array(
- Template_File::DIR_UNREADABLE => PhD_Errors::TEMPLATE_UNREADABLE,
- Template_File::DIR_UNWRITEABLE => PhD_Errors::CONFIG_DIR_INACCESSIBLE,
- Template_File::TEMPLATE_MISSING => PhD_Errors::TEMPLATE_MISSING,
- Template_File::TEMPLATE_UNREADABLE => PhD_Errors::TEMPLATE_UNREADABLE,
- Template_File::FILE_IN_THE_WAY => PhD_Errors::CONFIG_IN_THE_WAY,
- Template_File::FILE_UNWRITEABLE => PhD_Errors::CONFIG_UNWRITEABLE,
- Template_File::NO_OUTPUT_PATH => PhD_Errors::INTERNAL_ERROR,
- );
- PhD_Error( isset( $codeMap[ $e->getCode() ] ) ? $codeMap[ $e->getCode() ] :
PhD_Errors::INTERNAL_ERROR );
- }
- }
-
-}
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/setup/Option_Metadata.inc.php b/setup/Option_Metadata.inc.php
deleted file mode 100644
index 4f9d303..0000000
--- a/setup/Option_Metadata.inc.php
+++ /dev/null
@@ -1,349 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | The metadata for PhD configuration options. |
- +-------------------------------------------------------------------------+
-*/
-
-require_once 'PhD_Options.class.php';
-
-function OPTIONS_META_scan_script_dir( $name ) {
- static $lists = NULL;
-
- if ( is_null( $lists ) ) {
- $lists = array();
- }
- if ( !isset( $lists[ $name ] ) ) {
- $path = dirname( __FILE__ ) . "/../{$name}";
- if ( ( $files = @scandir( $path ) ) === FALSE ) {
- PhD_Error( strtoupper( $name ) . '_UNREADABLE' );
- }
- $fileList = array_map( create_function( '$v', 'return substr( $v, 0, -4
);' ),
- array_filter( $files, create_function( '$v', 'return substr( $v, -4 ) ==
".php" && is_file( "'.$path.'/{$v}" );' ) ) );
- if ( count( $fileList ) == 0 ) {
- PhD_Error( strtoupper( $name ) . '_UNAVAILABLE' );
- }
- $lists[ $name ] = $fileList;
- }
- return $lists[ $name ];
-}
-
-function OPTIONS_META_scan_dirs_dir( $name ) {
- static $lists = NULL;
-
- if ( is_null( $lists ) ) {
- $lists = array();
- }
- if ( !isset( $lists[ $name ] ) ) {
- $path = dirname( __FILE__ ) . "/../{$name}";
- if ( ( $files = @scandir( $path ) ) === FALSE ) {
- PhD_Error( strtoupper( $name ) . '_UNREADABLE' );
- }
- $folderList = array_filter( $files,
- create_function( '$v', 'return is_dir(
"'.$path.'/{$v}" ) && !in_array( $v, array( ".",
"..", ".svn", "CVS" ) );' ) );
- if ( count( $folderList ) == 0 ) {
- PhD_Error( strtoupper( $name ) . '_UNAVAILABLE' );
- }
- $lists[ $name ] = $folderList;
- }
- return $lists[ $name ];
-}
-
-function OPTIONS_META_get_languages() {
- global $OPTIONS_DATA, $OPTIONS;
- static $languages = NULL;
-
- if ( is_null( $languages ) ) {
- $d = $OPTIONS[ 'xml_root' ];
- if ( ( $languageList = @scandir( $d ) ) === FALSE ) {
- PhD_Error( "Unable to scan XML root." );
- }
- $c = 'return is_dir( "'.$d.'/{$v}" ) && !in_array( $v,
array( ".", "..", "CVS", ".svn" ) );';
- $languages = array_filter( $languageList, create_function( '$v', $c ) );
- }
- return $languages;
-}
-
-function OPTIONS_META_validate_file_save( $v, $rp = NULL ) {
- if ( ( $rp = realpath( $v ) ) === FALSE ) {
- return FALSE;
- }
- $d = dirname( $rp );
- if ( !is_dir( $d ) || !is_writable( $d ) || !is_executable( $d ) ||
- ( file_exists( $rp ) && ( !is_writable( $rp ) || is_dir( $rp ) ) ) ) {
- return FALSE;
- }
- return TRUE;
-}
-
-$OPTIONS_DATA = array(
- 'output_format' => array(
- 'display_name' => "Output Format",
- 'type' => PhD_Options::TYPE_LIST,
- 'default_value' => 'xhtml',
- 'description' => <<<~MESSAGE
-The output format for PhD determines the final form of any output it produces.
-Generally, this will be directly related to the medium in which it is used.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-Some possible options are HTML4, XHTML, XML (the identity transformation), CHM,
-WML, PDF, and plaintext. For a full list, see the formats/ folder. The default
-is the builtin XHTML. The selected theme will determine the version and
-conformance of any XML-based format.
-MESSAGE
- ,
- 'value_list_func' => create_function( '', <<<~FUNCTION
-return OPTIONS_META_scan_script_dir( 'formats' );
-FUNCTION
- ),
- 'prompt' => 'Choose a format',
- 'invalid_message' => 'That is not an available format. Please try
again.'
- ),
-
- 'output_theme' => array(
- 'display_name' => 'Output Theme',
- 'type' => PhD_Options::TYPE_LIST,
- 'default_value' => 'default',
- 'description' => <<<~MESSAGE
-The output theme for PhD determines site-specific alterations to the selected
-output format.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-The default theme is, simply enough, the builtin "default", which will display
-an error message for all cases. A valid theme must be selected by the
-administrator for the site to function.
-MESSAGE
- ,
- 'value_list_func' => create_function( '', <<<~FUNCTION
-return array_merge( array( 'default' ), OPTIONS_META_scan_dirs_dir( 'themes' )
);
-FUNCTION
- ),
- 'prompt' => 'Choose a theme',
- 'invalid_message' => 'That is not an available theme. Please try
again.'
- ),
-
- 'output_encoding' => array(
- 'display_name' => 'Output Encoding',
- 'type' => PhD_Options::TYPE_ARBITRARY,
- 'default_value' => 'utf-8',
- 'description' => <<<~MESSAGE
-The output encoding for PDP-E determines the encoding that will be used for all
-output. Input encodings are determined by the XML parser. The output encoding
-can be any encoding supported by libiconv on this system.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-The default is UTF-8. For HTTP-based outputs, an appropriate header() call will
-be made. For all SGML-based outputs, it is up to the output method to output a
-proper encoding declaration. For reasons of safety and consistency, themes and
-output formats can not override this value; if either needs to force an
-encoding or set of encodings, it must document that requirement and allow the
-system administrator to choose the proper one, and raise an error at runtime
-for an unsupported encoding.
-MESSAGE
- ,
- 'validity_func' => create_function( '$encoding',
<<<~FUNCTION
-return iconv( $encoding, $encoding, "Test string" ) === "Test string";
-FUNCTION
- ),
- 'prompt' => 'Choose an encoding',
- 'invalid_message' => 'That encoding does not appear to be supported by
your libiconv. Please try another.'
- ),
-
- 'xml_root' => array(
- 'display_name' => 'XML Root Directory',
- 'type' => PhD_Options::TYPE_ARBITRARY,
- 'default_value' => '/INVALID/PATH',
- 'description' => <<<~MESSAGE
-The location of the language trees.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-The XML root tells PhD where to find the XML files it wil be displaying in
-this installation. The expected structure is the same as that used by
-phpdoc-all, e.g. a set of directories named by language code containing the XML
-files and translations laid out by section structure. Tilde expansion is NOT
-done. Symbolic links are resolved at run time.
-MESSAGE
- ,
- 'validity_func' => create_function( '$root', <<<~FUNCTION
-$rv = realpath( $root );
-return ( $rv !== FALSE && is_dir( $rv ) && is_readable( $rv ) &&
is_executable( $rv ) && is_dir( "{$rv}/en" ) );
-FUNCTION
- ),
- 'prompt' => 'Enter the full path to the XML root',
- 'invalid_message' => <<<~MESSAGE
-The path you entered does not exist, is not a directory, is not readable, is
-not searchable, or does not contain an English directory. Please try again.
-MESSAGE
- ),
-
- 'language' => array(
- 'display_name' => 'Primary Language',
- 'type' => PhD_Options::TYPE_LIST,
- 'default_value' => 'en',
- 'description' => <<<~MESSAGE
-The language tells PhD which set of translations to use for display. The
-language is a two or four letter language code. It is assumed that
-subdirectories of the XML root are named according to the language code of the
-translations they contain. The language specified here must exist in the XML
-root.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-The default is English. English files are always the final fallback if a
-translated version of a page is not found.
-MESSAGE
- ,
- 'value_list_func' => 'OPTIONS_META_get_languages',
- 'prompt' => 'Choose a primary language code',
- 'invalid_message' => <<<~MESSAGE
-The language code you entered does not appear to exist, or is not a directory
-in the XML root. Please try again.
-MESSAGE
- ),
-
- 'fallback_language' => array(
- 'display_name' => 'Fallback Language',
- 'type' => PhD_Options::TYPE_LIST,
- 'default_value' => 'en',
- 'description' => <<<~MESSAGE
-The fallback language is used before English when PhD can not find a translated
-file in the primary language. If it is set to English, PhD immediately falls
-back to English files without any extra overhead. The language specified here
-must exist in the XML root.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-This provides an optional fallback before English if another fallback would
-make more sense for a site. The default is English, causing immediate fallback.
-MESSAGE
- ,
- 'value_list_func' => 'OPTIONS_META_get_languages',
- 'prompt' => 'Choose a fallback language code',
- 'invalid_message' => <<<~MESSAGE
-The language code you entered does not appear to exist, or is not a directory
-in the XML root. Please try again.
-MESSAGE
- ),
-
- 'enforce_revisions' => array(
- 'display_name' => 'Revision Enforce flag',
- 'type' => PhD_Options::TYPE_FLAG,
- 'default_value' => FALSE,
- 'description' => <<<~MESSAGE
-PhD is capable of using the <phd:revision/> tag to specify version control
-information for files and their translated counterparts. If the revision
-control flag is set, PhD will enforce revision matching between translated
-files and English files.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-The processor relies on whatever version control system is in use to provide
-the revision information in its proper place for the tag style in use. Use of
-the <phd:revision/> tag is strongly preferred to the use of XML comments. If a
-reivison mismatch is found, the active theme is given an opportunity to present
-an error or warning to users.
-MESSAGE
- ,
- 'prompt' => 'Type "(Y)es" to enable revision control, or
"(N)o" to disable it',
- 'invalid_message' => 'Please enter "(Y)es" or
"(N)o".'
- ),
-
- 'compatibility_mode' => array(
- 'display_name' => 'Compatibility mode',
- 'type' => PhD_Options::TYPE_FLAG,
- 'default_value' => TRUE,
- 'description' => <<<~MESSAGE
-Turning on this flag causes PhD to modify its processing in several ways to
-make it compatible with documentation that was written for a legacy form of
-DocBook publishing, specifically XSL or DSSSL.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-The specific differences are:
- - XML files without IDs are not rejected; an ID is autogenerated based on
- its path relative to the XML root.
- - XML files containing more than one root element are not rejected; the
- extra elements are treated as separate sections.
- - When revision control is on, <!-- Revision: --> and <!-- EN-Revision: -->
- tags are automatically replaced with an equivelant <phd:revision/> tag.
- - <!-- [name]: [value] --> tags are automatically replaced with equivelant
- <phd:meta/> tags.
- - Entity references and entity delcarations are replaced with equivelant
- <phd:define/>, <phd:constant/> and <phd:include/> tags.
-WARNING: This extra processing entails an extra phase during the build, which
-will slow it down considerably. Please consider converting old documents to use
-PhD elements using convert.php.
-MESSAGE
- ,
- 'prompt' => 'Type "(Y)es" to enable compatibility mode, or
"(N)o" to disable it',
- 'invalid_message' => 'Please enter "(Y)es" or
"(N)o".'
- ),
-
- 'build_log_file' => array(
- 'display_name' => 'Build Log',
- 'type' => PhD_Options::TYPE_ARBITRARY,
- 'default_value' => 'none',
- 'description' => <<<~MESSAGE
-The log file is where PhD stores the output of the first phase of operation,
-the conversion of xml_root's multitude of XML files into a single blog.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-Running the many-to-one build process can sometimes produce a copious amount of
-output, especially with the debug flag on. This setting is provided to
-automatically dump that output to a file for convenience. Multiple runs of the
-build will overwrite an existing log file, so be careful.
-MESSAGE
- ,
- 'validity_func' => create_function( '$v', <<<~FUNCTION
-return ( $v === 'none' || OPTIONS_META_validate_file_save( $v ) );
-FUNCTION
- ),
- 'prompt' => 'Enter the full path to the build log, or "none" to
log to stdout',
- 'invalid_message' => <<<~MESSAGE
-The path you entered is invalid or you don't have write permission to it.
-Please try again.
-MESSAGE
- ),
-
- 'debug' => array(
- 'display_name' => 'Debug flag',
- 'type' => PhD_Options::TYPE_FLAG,
- 'default_value' => FALSE,
- 'description' => <<<~MESSAGE
-The debug flag controls whether PhD runs in debug mode. This should NEVER be
-set in a production environment; its intended use is for PhD developers and
-experienced site administrators.
-MESSAGE
- ,
- 'details' => <<<~MESSAGE
-If set, many extra assertions are enabled and verbose error messages and
-progress information are provided. Please note that debug output is under the
-control of both the output format and the output theme, as a matter of
-consistency. This flag is only provided in the setup interface for ease of
-administration.
-MESSAGE
- ,
- 'prompt' => 'Type "(Y)es" to enable debug output, or
"(N)o" to disable it',
- 'invalid_message' => 'Please enter "(Y)es" or
"(N)o".'
- ),
-);
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/setup/PhD_Interface.class.php b/setup/PhD_Interface.class.php
deleted file mode 100644
index 7b19e2d..0000000
--- a/setup/PhD_Interface.class.php
+++ /dev/null
@@ -1,174 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | The interface for setup.php to talk to the user. Another version of |
- | this code could potentially implement a Web-based configuration. |
- +-------------------------------------------------------------------------+
-*/
-
-function PhD_Error( $message ) {
- print "ERROR: " . PhD_Output::paramString( 'Error', $message ) .
"\n";
- exit( 1 );
-}
-
-function PhD_Warning( $message ) {
- print "WARNING: " . PhD_Output::paramString( 'Warning', $message )
."\n";
-}
-
-class PhD_Interface {
-
- protected $quietMode = 0;
-
- public function __construct() {
-
- if ( php_sapi_name() != 'cli' ) {
- PhD_Error( 'ONLY_CLI_SUPPORTED' );
- }
-
- // If we someday have a version of PHP with the nice long getopt() on all systems patch...
- if ( in_array( '-h', $_SERVER[ 'argv' ] ) || in_array(
'--help', $_SERVER[ 'argv' ] ) ) {
- print PhD_Output::paramString( 'Message', 'USAGE', $_SERVER[
'argv' ][ 0 ] );
- exit( 1 );
- }
-
- if ( in_array( '-q', $_SERVER[ 'argv' ] ) || in_array(
'--quiet', $_SERVER[ 'argv' ] ) ) {
- $this->quietMode = 1;
- } else if ( in_array( '-s', $_SERVER[ 'argv' ] ) || in_array(
'--silent', $_SERVER[ 'argv' ] ) ) {
- $this->quietMode = 2;
- } else if ( in_array( '-v', $_SERVER[ 'argv' ] ) || in_array(
'--verbose', $_SERVER[ 'argv' ] ) ) {
- $this->quietMode = 0;
- }
-
- }
-
- public function __destruct() {
- }
-
- public function run() {
- global $configurator, $OPTIONS, $OPTIONS_DATA;
-
- $now = date( DATE_RFC2822 );
- print PhD_Output::paramString( 'Message', 'CONFIG_BEGIN', $now ) .
"\n\n";
-
- do {
-
- $this->displaySettings( 'CURRENT_SETTINGS' );
-
- print PhD_Output::paramString( 'Prompt', 'INSTRUCTIONS' ) .
"\n\n";
-
- foreach ( $OPTIONS_DATA as $optionName => $optionData ) {
-
- printf( "%-40s\n", "{$optionData[ 'display_name' ]}:"
);
- if ( $this->quietMode < 2 ) {
- print "{$optionData[ 'description' ]}\n";
- }
- if ( $this->quietMode < 1 ) {
- print "{$optionData[ 'details' ]}\n";
- }
-
- switch ( PhD_Options::getType( $optionName ) ) {
- case PhD_Options::TYPE_ARBITRARY:
- print PhD_Output::paramString( 'Message', 'NO_VALUES'
);
- break;
- case PhD_Options::TYPE_LIST:
- print PhD_Output::paramString( 'Message',
'AVAILABLE_VALUES',
- wordwrap( "\t" . implode( ' ',
PhD_Options::getValueList( $optionName ) ), 71, "\n\t", FALSE ) );
- break;
- case PhD_Options::TYPE_NUMERIC:
- print PhD_Output::paramString( 'Message',
'NUMERIC_VALUE',
- $optionData[ 'min_value' ], $optionData[
'max_value' ] );
- break;
- case PhD_Options::TYPE_FILESIZE:
- print PhD_Output::paramString( 'Message',
'NUMBYTES_VALUES' );
- break;
- case PhD_Options::TYPE_FLAG:
- print PhD_Output::paramString( 'Message',
'BOOLEAN_VALUES' );
- break;
- default:
- PhD_Error( 'INTERNAL_ERROR' );
- }
-
- print "\n\n";
-
- do {
- $response = $this->getLine( PhD_Output::paramString( 'Prompt',
'OPTION_PROMPT', $optionData[ 'prompt' ],
- $configurator->$optionName ) );
- if ( $response === '' ) {
- $response = $configurator->$optionName;
- }
- if ( PhD_Options::checkValidity( $optionName, $response ) === TRUE ) {
- break;
- }
- print "{$optionData[ 'invalid_message' ]}\n";
- } while ( TRUE );
-
- $configurator->$optionName = PhD_Options::getFinalValue( $optionName, $response
);
-
- print "\n";
-
- }
-
- $this->displaySettings( 'CHOSEN_SETTINGS' );
-
- do {
- $response = $this->getLine( PhD_Output::paramString( 'Prompt',
'CONFIG_COMPLETE' ) );
-
- switch ( strval( $response ) ) {
- case 'yes':
- return TRUE;
- case 'restart':
- continue 3;
- case 'quit':
- return FALSE;
- default:
- print PhD_Output::paramString( 'Prompt',
'INVALID_CONFIG_COMPLETE' );
- continue 2;
- }
- } while ( TRUE );
-
- } while ( TRUE );
-
- }
-
- public function reportSuccess() {
- print "\n" . PhD_Output::paramString( 'Message',
'CONFIG_SAVED' ) . "\n\n";
- }
-
- protected function getLine( $prompt = NULL ) {
- if ( !is_null( $prompt ) ) {
- print $prompt;
- }
-
- if ( ( $result = fgets( STDIN ) ) === FALSE ) {
- PhD_Error( 'INPUT_EOF' );
- }
- return trim( $result );
- }
-
- protected function displaySettings( $headerConst ) {
- global $configurator, $OPTIONS_DATA;
-
- print PhD_Output::paramString( 'Message', $headerConst ) . "\n";
- foreach ( $OPTIONS_DATA as $name => $data ) {
- printf( "\t%-25s: %s\n", $name,
- is_bool( $configurator->$name ) ? ( $configurator->$name ? "On" :
"Off" ) : $configurator->$name );
- }
- print "\n";
- }
-
-}
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/setup/PhD_Options.class.php b/setup/PhD_Options.class.php
deleted file mode 100644
index b90edd4..0000000
--- a/setup/PhD_Options.class.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | A facility for easily managing option metadata. |
- +-------------------------------------------------------------------------+
-*/
-
-class Phd_Options {
-
- const TYPE_ARBITRARY = 0; // Any user-entered value
- const TYPE_LIST = 1; // One of a list of enumerated values
- const TYPE_NUMERIC = 2; // Any integer
- const TYPE_FILESIZE = 3; // A positive integer including the [KMGTP[B]] suffix
- const TYPE_FLAG = 4; // Boolean flag
-
- public static function getType( $optName ) {
- global $OPTIONS_DATA;
-
- if ( empty( $OPTIONS_DATA[ $optName ] ) ) {
- return NULL;
- }
- return $OPTIONS_DATA[ $optName ][ 'type' ];
- }
-
- public static function getValueList( $optName ) { // TYPE_LIST options only
- global $OPTIONS_DATA;
-
- if ( PhD_Options::getType( $optName ) != PhD_Options::TYPE_LIST ) {
- return NULL;
- }
- return call_user_func( $OPTIONS_DATA[ $optName ][ 'value_list_func' ] );
- }
-
- public static function checkValidity( $optName, $value ) {
- global $OPTIONS_DATA;
-
- if ( ( $type = PhD_Options::getType( $optName ) ) === NULL ) {
- return NULL;
- }
-
- switch ( $type ) {
- case PhD_Options::TYPE_ARBITRARY:
- return call_user_func( $OPTIONS_DATA[ $optName ][ 'validity_func' ],
$value );
-
- case PhD_Options::TYPE_LIST:
- return in_array( $value, PhD_Options::getValueList( $optName ) );
-
- case PhD_Options::TYPE_NUMERIC:
- if ( ctype_digit( $value ) ) {
- return ( $value >= $OPTIONS_DATA[ $optName ][ 'min_value' ]
&&
- $value <= $OPTIONS_DATA[ $optName ][ 'max_value' ] );
- }
- return FALSE;
-
- case PhD_Options::TYPE_FILESIZE:
- return preg_match( '/^(\d+)(?:([KMGTP])B?)?$/iu', $value ) ? TRUE :
FALSE;
-
- case PhD_Options::TYPE_FLAG:
- return in_array( substr( strtolower( $value ), 0, 1 ), array( 1, 0, 'y',
'n' ) ) ||
- $value === TRUE || $value === FALSE;
-
- default:
- return NULL;
- }
- }
-
- public static function getFinalValue( $optName, $value ) {
- global $OPTIONS_DATA;
-
- if ( ( $type = PhD_Options::getType( $optName ) ) === NULL ) {
- return NULL;
- }
-
- switch ( $type ) {
- case PhD_Options::TYPE_ARBITRARY:
- return isset( $OPTIONS_DATA[ $optName ][ 'final_value_func' ] ) ?
- call_user_func( $OPTIONS_DATA[ $optName ][ 'final_value_func' ],
$value ) : $value;
-
- case PhD_Options::TYPE_LIST:
-
- case PhD_Options::TYPE_NUMERIC:
- return $value;
-
- case PhD_Options::TYPE_FILESIZE:
- preg_match( '/^(\d+)(?:([KMGTP])B?)?$/iu', $value, $matches );
- $multipliers = array(
- '' => 1,
- 'K' => 1024,
- 'M' => 1048576,
- 'G' => 1073741824,
- 'T' => 1099511627776,
- 'P' => 1125899906842620
- );
- return ( intval( $matches[ 1 ] ) * $multipliers[ strval( $matches[ 2 ] ) ] );
-
- case PhD_Options::TYPE_FLAG:
- return is_bool( $value ) ? $value : ( substr( strtolower( $value ), 0, 1 ) ==
'y' ? TRUE : FALSE );
-
- default:
- return NULL;
- }
- }
-
-}
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/setup/PhD_Output.class.php b/setup/PhD_Output.class.php
deleted file mode 100644
index c06f266..0000000
--- a/setup/PhD_Output.class.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | The class for formatting PhD setup messages (use this more globally?). |
- +-------------------------------------------------------------------------+
-*/
-
-class PhD_Output {
-
- protected static $argList = NULL;
- protected static function paramStringCallback( $v ) {
- $v = next( self::$argList );
- return ( is_bool( $v ) ? ( $v ? "Yes" : "No" ) : $v );
- }
- public static function paramString( $whichClass, $constName /*, ... */ ) {
- self::$argList = func_get_args(); next( self::$argList );
- $str = constant( "PhD_{$whichClass}s::{$constName}" );
- return count( self::$argList ) > 2 ?
- preg_replace_callback( '/%%%/', array( __CLASS__,
'paramStringCallback' ), $str ) :
- $str;
- }
-
-}
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/setup/Template_File.class.php b/setup/Template_File.class.php
deleted file mode 100644
index eeefe5f..0000000
--- a/setup/Template_File.class.php
+++ /dev/null
@@ -1,154 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | Provides a flexible interface for handling simple template files. |
- +-------------------------------------------------------------------------+
-*/
-
-class Template_File {
-
- const DIR_UNREADABLE = 1;
- const DIR_UNWRITEABLE = 2;
- const TEMPLATE_MISSING = 3;
- const TEMPLATE_UNREADABLE = 4;
- const FILE_IN_THE_WAY = 5;
- const FILE_UNWRITEABLE = 6;
- const NO_OUTPUT_PATH = 7;
-
- protected $_TF_templatePath = NULL;
- protected $_TF_outputPath = NULL;
- protected $_TF_substitutions = array();
-
- public $_TF_allowOverwrite = FALSE;
-
- public function __construct( $templatePath, $outputPath = NULL, $allowOverwrite = FALSE ) {
-
- if ( !is_null( $outputPath ) ) {
- if ( !$allowOverwrite && file_exists( $outputPath ) ) {
- throw new Exception( '', Template_File::FILE_IN_THE_WAY );
- }
- if ( !file_exists( dirname( $outputPath ) ) || !is_dir( dirname( $outputPath ) ) ) {
- throw new Exception( '', Template_File::DIR_UNREADABLE );
- }
- if ( !is_writeable( dirname( $outputPath ) ) ) {
- throw new Exception( '', Template_File::DIR_UNWRITEABLE );
- }
- }
-
- $this->_TF_templatePath = $templatePath;
- $this->_TF_outputPath = $outputPath;
- $this->_TF_allowOverwrite = $allowOverwrite;
-
- }
-
- public function __destruct() {
- }
-
- public function subst( $name, $value ) {
-
- $this->_TF_substitutions[ $name ] = $value;
-
- }
-
- public function unsubst( $name ) {
-
- unset( $this->_TF_substitutions[ $name ] );
-
- }
-
- public function __get( $name ) {
-
- if ( $name == 'allowOverwrite' ) {
- return $this->_TF_allowOverwrite;
- } else {
- return $this->_TF_substitutions[ $name ];
- }
-
- }
-
- public function __set( $name, $value ) {
-
- if ( $name == 'allowOverwrite' ) {
- $this->_TF_allowOverwrite = $value;
- } else {
- $this->subst( $name, $value );
- }
-
- }
-
- public function __unset( $name ) {
-
- $this->unsubst( $name );
-
- }
-
- public function writeTemplate( $outputPath = NULL, $allowOverwrite = NULL ) {
-
- if ( is_null( $outputPath ) && is_null( $this->_TF_outputPath ) ) {
- throw new Exception( '', Template_File::NO_OUTPUT_PATH );
- } else {
- $this->_TF_outputPath = is_null( $outputPath ) ? $this->_TF_outputPath :
$outputPath;
- }
-
- if ( !is_null( $allowOverwrite ) ) {
- $this->_TF_allowOverwrite = $allowOverwrite;
- }
-
- $template = $this->readTemplate( $this->_TF_templatePath );
- $template = $this->doSubstitutions( $this->_TF_substitutions, $template );
- $this->writeTemplateInternal( $this->_TF_outputPath, $template,
$this->_TF_allowOverwrite );
-
- }
-
- protected function readTemplate( $templatePath ) {
-
- if ( !file_exists( $templatePath ) ) {
- throw new Exception( '', Template_File::TEMPLATE_MISSING );
- }
- if ( !is_readable( $templatePath ) ) {
- throw new Exception( '', Template_File::TEMPLATE_UNREADABLE );
- }
-
- return file_get_contents( $templatePath );
-
- }
-
- protected function doSubstitutions( $substitutions, $template ) {
-
- return str_replace(
- array_map( create_function( '$v', 'return "@{$v}@";' ),
array_keys( $substitutions ) ),
- array_values( $substitutions ),
- $template );
-
- }
-
- protected function writeTemplateInternal( $outputPath, $template, $allowOverwrite ) {
-
- if ( file_exists( $outputPath ) ) {
- if ( !$allowOverwrite || @unlink( $outputPath ) === FALSE ) {
- throw new Exception( '', Template_File::FILE_IN_THE_WAY );
- }
- }
-
- if ( @file_put_contents( $outputPath, $template ) === FALSE ) {
- throw new Exception( '', Template_File::FILE_UNWRITEABLE );
- }
-
- }
-
-}
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/setup/config.in.php b/setup/config.in.php
deleted file mode 100644
index 984aa94..0000000
--- a/setup/config.in.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-/* This file is autogenerated by setup.php. Do not edit directly. */
-/* Generated by PhD @SETUP_REV@ at @SETUP_DATE@. */
-
-$OPTIONS = @OPTION_ARRAY@;
-
-?>
diff --git a/setup/setup.messages.php b/setup/setup.messages.php
deleted file mode 100644
index 50b7d5d..0000000
--- a/setup/setup.messages.php
+++ /dev/null
@@ -1,166 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | The text for error, warning, and status messages in setup.php. |
- +-------------------------------------------------------------------------+
-*/
-
-require_once 'PhD_Output.class.php';
-
-class PhD_Messages {
-
- const USAGE = <<<~MESSAGE
-PhD per-site configuration setup. Commandline interface.
-Usage:
-%%% [options]
- -v | --verbose Give full details on configuration options.
- This is the default.
- -q | --quiet Give shorter descriptions of configuration options.
- -s | --silent Give no descriptions of configuration options.
- -h | --help Show this message.
-MESSAGE;
-
- const CONFIG_BEGIN = <<<~MESSAGE
-PhD per-site configuration setup. Commandline interface.
-Run began at %%%.
-MESSAGE;
-
- const CURRENT_SETTINGS = <<<~MESSAGE
-Current settings:
-MESSAGE;
-
- const NO_VALUES = <<<~MESSAGE
-There is no list of possible values available.
-MESSAGE;
-
- const BOOLEAN_VALUES = <<<~MESSAGE
-This is a yes/no setting.
-MESSAGE;
-
- const NUMBYTES_VALUES = <<<~MESSAGE
-This is a value given in number of bytes. For convenience you may use any of
-the following suffixes to multiply the number by the shown factor.
- K = 1024, M = K*1024, G = M*1024, T = G*1024, P = T*1024
-MESSAGE;
-
- const AVAILABLE_VALUES = <<<~MESSAGE
-The available values in this installation are:
-%%%
-MESSAGE;
-
- const CHOSEN_SETTINGS = <<<~MESSAGE
-Chosen settings:
-MESSAGE;
-
- const CONFIG_SAVED = <<<~MESSAGE
-Your settings were successfully saved to config.php. PhD is now ready for use.
-MESSAGE;
-
-}
-
-class PhD_Errors {
-
- const ONLY_CLI_SUPPORTED = <<<~ERRMSG
-The PhD setup application requires the CLI interface.
-ERRMSG;
-
- const CONFIG_UNREADABLE = <<<~ERRMSG
-The existing config.php is not readable, or is not a regular file. Please move
-it out of the way.
-ERRMSG;
-
- const CONFIG_IN_THE_WAY = <<<~ERRMSG
-The existing config.php could not be removed. Please move it out of the way.
-ERRMSG;
-
- const CONFIG_UNWRITEABLE = <<<~ERRMSG
-The new config.php could not be written. This may indicate a permissions error,
-or that another process is attempting to access the file.
-ERRMSG;
-
- const CONFIG_DIR_INACCESSIBLE = <<<~ERRMSG
-The directory for config.php does not exist, is not a directory, or is not
-writable.
-ERRMSG;
-
- const TEMPLATE_UNREADABLE = <<<~ERRMSG
-Could not read the template file. Please ensure that it exists and that the
-directory containing it is searchable.
-ERRMSG;
-
- const TEMPLATE_MISSING = <<<~ERRMSG
-The template file does not exist or is unreadable.
-ERRMSG;
-
- const INPUT_EOF = <<<~ERRMSG
-Input ended unexpectedly.
-ERRMSG;
-
- const FORMATS_UNREADABLE = <<<~ERRMSG
-The formats directory is missing or unreadable.
-ERRMSG;
-
- const FORMATS_UNAVAILABLE = <<<~ERRMSG
-There are no output formats available.
-ERRMSG;
-
- const THEMES_UNREADABLE = <<<~ERRMSG
-The themes directory is missing or unreadable.
-ERRMSG;
-
- const THEMES_UNAVAILABLE = <<<~ERRMSG
-There are no output themes available.
-ERRMSG;
-
- const INTERNAL_ERROR = <<<~ERRMSG
-An internal error occurred. Please report this as a bug.
-ERRMSG;
-
-}
-
-class PhD_Warnings {
-
- const UNSAVED_CHANGES = <<<~WARNMSG
-Your changes were not saved.
-WARNMSG;
-
-}
-
-class PhD_Prompts {
-
- const INSTRUCTIONS = <<<~PROMPTMSG
-Press return without entering any text to leave an option at its current value.
-This will be rejected for options which require a value but whose current value
-is empty.
-PROMPTMSG;
-
- const OPTION_PROMPT = <<<~PROMPTMSG
-%%% [%%%]:
-PROMPTMSG;
-
- const CONFIG_COMPLETE = <<<~PROMPTMSG
-To confirm these settings, type "yes" now.
-To start over, type "restart".
-To quit without saving, type "quit":
-PROMPTMSG;
-
- const INVALID_CONFIG_COMPLETE = <<<~PROMPTMSG
-This is not a valid response. Please try again.
-PROMPTMSG;
-
-}
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/setup/setup.php b/setup/setup.php
deleted file mode 100644
index 900c3fa..0000000
--- a/setup/setup.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-/* $Id$
- +-------------------------------------------------------------------------+
- | Copyright(c) 2007 |
- | Authors: |
- | Gwynne Raskind <gwynne@php.net> |
- | This source file is subject to the license that is bundled with this |
- | package in the file LICENSE, and is available through the |
- | world-wide-web at the following url: |
- | http://phd.php.net/LICENSE
|
- +-------------------------------------------------------------------------+
- | A simple interface to configuration of the per-site PhD system options. |
- | Chosen options are saved in config.php, an automatically generated |
- | file. An existing config.php is presumed to offer defaults for setup. |
- | No user authentication is done by this script; do not make it |
- | accessible to non-administrators. |
- +-------------------------------------------------------------------------+
-*/
-
-$SETUP_REVISION = '$Id$';
-
-/*---------------------------------------------------------------------------*/
-require_once 'setup.messages.php';
-require_once 'Option_Metadata.inc.php';
-require_once 'Configurator.class.php';
-require_once 'PhD_Interface.class.php';
-
-/*---------------------------------------------------------------------------*/
-$interface = NULL;
-$configurator = NULL;
-
-/*---------------------------------------------------------------------------*/
-$configurator = new PhD_Configurator;
-$interface = new PhD_Interface;
-
-/*---------------------------------------------------------------------------*/
-// Fill in defaults.
-$OPTIONS = array();
-foreach ( $OPTIONS_DATA as $name => $data ) {
- $OPTIONS[ $name ] = $data[ 'default_value' ];
-}
-
-/*---------------------------------------------------------------------------*/
-// Pull in any existing config.php.
-$configurator->readConfig();
-
-/*---------------------------------------------------------------------------*/
-// Run the interface. TRUE if user chose values, FALSE if user wanted to break out
-if ( $interface->run() === TRUE ) {
- // We have a set of values. We trust the interface to have checked the validity.
- $configurator->writeConfig();
- $interface->reportSuccess();
-} else {
- PhD_Warning( 'UNSAVED_CHANGES' );
-}
-
-/*
-* vim600: sw=4 ts=4 fdm=syntax syntax=php et
-* vim<600: sw=4 ts=4
-*/
-?>
diff --git a/themes/php/bightml.php b/themes/php/bightml.php
index 51f0e03..21f4f4d 100644
--- a/themes/php/bightml.php
+++ b/themes/php/bightml.php
@@ -5,7 +5,7 @@ require_once $ROOT . '/themes/php/phpdotnet.php';
class bightml extends phpdotnet {
public function __construct(array $IDs, $filename, $ext = "html") {
parent::__construct($IDs, $filename, $ext, false);
- $this->stream = fopen("bightml.html", "w");
+ $this->stream = fopen($GLOBALS['OPTIONS']['output_dir'] .
"bightml.html", "w");
self::header();
}
public function appendData($data, $isChunk) {
@@ -33,7 +33,7 @@ class bightml extends phpdotnet {
}
public function format_qandaset($open, $name, $attrs) {
if ($open) {
- $this->tmp["qandaentry"] = array();
+ $this->cchunk["qandaentry"] = array();
$this->ostream = $this->stream;
$this->stream = fopen("php://temp/maxmemory", "r+");
return '';
diff --git a/themes/php/chunkedhtml.php b/themes/php/chunkedhtml.php
index cd2d791..db20a32 100644
--- a/themes/php/chunkedhtml.php
+++ b/themes/php/chunkedhtml.php
@@ -7,8 +7,9 @@ class chunkedhtml extends phpweb {
public function __construct(array $IDs, $filename, $ext = "html") {
phpdotnet::__construct($IDs, $filename, $ext, true);
- if(!file_exists("html") || is_file("html")) mkdir("html") or
die("Can't create the cache directory");
- elseif (file_exists('html/index.html')) unlink('html/index.html'); //
preserve back-compat
+ $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext .
DIRECTORY_SEPARATOR;
+ if(!file_exists($this->outputdir) || is_file($this->outputdir))
mkdir($this->outputdir) or die("Can't create the cache directory");
+ elseif (file_exists($this->outputdir . 'index.html'))
unlink($this->outputdir . 'index.html'); // preserve back-compat
}
public function header($id) {
$title = PhDHelper::getDescription($id, true);
@@ -48,8 +49,8 @@ NAV;
return "<hr />$nav</body></html>\n";
}
public function __destruct() {
- if (file_exists("html/manual.html") &&
!file_exists('html/index.html')) {
- copy("html/manual.html", "html/index.html");
+ if (file_exists($this->outputdir . "manual.html") &&
!file_exists($this->outputdir . 'index.html')) {
+ copy($this->outputdir . "manual.html", $this->outputdir .
"index.html");
}
}
}
diff --git a/themes/php/phpdotnet.php b/themes/php/phpdotnet.php
index bffde4c..7a530f1 100644
--- a/themes/php/phpdotnet.php
+++ b/themes/php/phpdotnet.php
@@ -32,6 +32,10 @@ abstract class phpdotnet extends PhDTheme {
'methodparam' => false,
'methodsynopsis' => false,
),
+ 'varname' => array(
+ /* DEFAULT */ false,
+ 'fieldsynopsis' => 'format_fieldsynopsis_varname',
+ ),
'xref' => 'format_link',
@@ -98,9 +102,12 @@ abstract class phpdotnet extends PhDTheme {
'type' => array(
/* DEFAULT */ 'format_type_text',
'classsynopsisinfo' => false,
- 'fieldsynopsis' => false,
- 'methodparam' => false,
- 'methodsynopsis' => false,
+ 'fieldsynopsis' => 'format_type_if_object_or_pseudo_text',
+ 'methodparam' => 'format_type_if_object_or_pseudo_text',
+ 'methodsynopsis' => array(
+ /* DEFAULT */ 'format_type_if_object_or_pseudo_text',
+ 'classsynopsis' => false,
+ ),
),
'refname' => 'format_refname_text',
@@ -112,9 +119,21 @@ abstract class phpdotnet extends PhDTheme {
protected $lang = "en";
protected $CURRENT_ID = "";
- protected $CURRENT_FUNCTION = null;
protected $refname;
+ /* Current Chunk settings */
+ protected $cchunk = array();
+ /* Default Chunk settings */
+ protected $dchunk = array(
+ "fieldsynopsis" => array(
+ "modifier" => "public",
+ ),
+ "container_chunk" => null,
+ "qandaentry" => array(
+ ),
+ "examples" => 0,
+ );
+
public function __construct(array $IDs, array $filenames, $ext = "php", $chunked =
true) {
parent::__construct($IDs, $ext);
$this->ext = $ext;
@@ -182,13 +201,17 @@ abstract class phpdotnet extends PhDTheme {
if ($open) {
$content = $fragment = "";
$class = $name;
+
if(isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) {
$linkto = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"];
$id = $href = PhDHelper::getFilename($linkto);
+
if ($id != $linkto) {
$fragment = "#$linkto";
}
- $href .= ".".$this->ext;
+ if ($this->chunked) {
+ $href .= ".".$this->ext;
+ }
} elseif(isset($attrs[PhDReader::XMLNS_XLINK]["href"])) {
$href = $attrs[PhDReader::XMLNS_XLINK]["href"];
$content = "» ";
@@ -215,15 +238,50 @@ abstract class phpdotnet extends PhDTheme {
return '<a href="' .$link.$href.$fragment. '"
class="' .$class. '">' .$content.$href.$fragment.
'</a>';
} else {
if ($this->chunked) {
- $link = "";
+ $link = $href.$fragment;
+ } elseif(isset($linkto)) {
+ if ($fragment) {
+ $link = $fragment;
+ } else {
+ $link = "#$href";
+ }
} else {
- $link = "#";
+ $link = $href;
}
- return '<a href="' .$link.$href.$fragment. '"
class="' .$class. '">' .$content;
+ return '<a href="' .$link. '" class="'
.$class. '">' .$content;
}
}
return "</a>";
}
+ public function format_fieldsynopsis_varname($open, $name, $attrs) {
+ if ($open) {
+ $href = "";
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) {
+ $linkto = $attrs[PhDReader::XMLNS_DOCBOOK]["linkend"];
+ $href = PhDHelper::getFilename($linkto);
+
+ if ($this->chunked) {
+ if ($href != $linkto) {
+ $href .= ".{$this->ext}#{$linkto}";
+ } else {
+ $href .= '.' .$this->ext;
+ }
+ } else {
+ $href = '#' .$linkto;
+ }
+ $href = '<a href="' .$href. '">';
+ }
+ if ($this->cchunk["fieldsynopsis"]["modifier"] ==
"const") {
+ return '<var class="fieldsynopsis_varname">'.$href;
+ }
+ return '<var
class="'.$name.'">'.$href.'$';
+ }
+ if (isset($attrs[PhDReader::XMLNS_DOCBOOK]["linkend"])) {
+ return '</a></var>';
+ }
+ return '</var>';
+ }
+
@@ -247,7 +305,7 @@ abstract class phpdotnet extends PhDTheme {
}
public function format_refpurpose($open, $tag, $attrs) {
if ($open) {
- return '<p class="verinfo">('
.(htmlspecialchars($this->versionInfo($this->refname), ENT_QUOTES, "UTF-8")).
')</p><p class="refpurpose">'. $this->refname. ' â
';
+ return '<p class="verinfo">('
.(htmlspecialchars($this->versionInfo($this->refname), ENT_QUOTES, "UTF-8")).
')</p><p class="refpurpose dc-title">'. $this->refname. '
â ';
}
return "</p>\n";
}
@@ -258,17 +316,9 @@ abstract class phpdotnet extends PhDTheme {
public function format_chunk($open, $name, $attrs, $props) {
if (isset($attrs[PhDReader::XMLNS_XML]["id"])) {
$this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"];
- if ($name == "refentry") {
- if(strpos($id, "function.") !== false) {
- $id = substr($id, 9);
- }
- $this->CURRENT_FUNCTION = $id;
- } else {
- $this->CURRENT_FUNCTION = null;
- }
}
if ($props["isChunk"]) {
- $this->tmp["chunk"] = array("examples" => 0);
+ $this->cchunk = $this->dchunk;
}
if (isset($props["lang"])) {
$this->lang = $props["lang"];
@@ -277,10 +327,9 @@ abstract class phpdotnet extends PhDTheme {
}
public function format_container_chunk($open, $name, $attrs, $props) {
$this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"];
- $this->CURRENT_FUNCTION = null;
if ($open) {
if ($props["isChunk"]) {
- $this->tmp["chunk"] = array("examples" => 0);
+ $this->cchunk = $this->dchunk;
}
if ($name != "reference") {
$chunks = PhDHelper::getChildren($id);
@@ -289,10 +338,14 @@ abstract class phpdotnet extends PhDTheme {
}
$content = '<h2>'.$this->autogen("toc",
$props["lang"]). '</h2><ul class="chunklist
chunklist_'.$name.'">';
foreach($chunks as $chunkid => $junk) {
- $content .= '<li><a href="' .($this->chunked ?
"" : "#").$chunkid. '.' .$this->ext. '">'
.(PhDHelper::getDescription($chunkid, true)). '</a></li>';
+ if ($this->chunked) {
+ $content .= '<li><a href="'.$chunkid. '.'
.$this->ext. '">' .(PhDHelper::getDescription($chunkid, true)).
'</a></li>';
+ } else {
+ $content .= '<li><a href="#'.$chunkid.
'">' .(PhDHelper::getDescription($chunkid, true)).
'</a></li>';
+ }
}
$content .= "</ul>\n";
- $this->tmp["container_chunk"] = $content;
+ $this->cchunk["container_chunk"] = $content;
}
return "<div>";
}
@@ -300,10 +353,14 @@ abstract class phpdotnet extends PhDTheme {
$content = "";
if ($name == "reference") {
$chunks = PhDHelper::getChildren($id);
- if (count($chunks) > 1) {
+ if (count($chunks)) {
$content = '<h2>'.$this->autogen("toc",
$props["lang"]). '</h2><ul class="chunklist
chunklist_reference">';
foreach($chunks as $chunkid => $junk) {
- $content .= '<li><a href="' .($this->chunked ?
"" : "#").$chunkid. '.' .$this->ext. '">'
.(PhDHelper::getDescription($chunkid, false)). '</a> â '
.(PhDHelper::getDescription($chunkid, true)). '</li>';
+ if ($this->chunked) {
+ $content .= '<li><a href="'.$chunkid. '.'
.$this->ext. '">' .(PhDHelper::getDescription($chunkid, false)).
'</a> â ' .(PhDHelper::getDescription($chunkid, true)).
'</li>';
+ } else {
+ $content .= '<li><a
href="#'.$chunkid.'">' .(PhDHelper::getDescription($chunkid, false)).
'</a> â ' .(PhDHelper::getDescription($chunkid, true)).
'</li>';
+ }
}
$content .= "</ul>\n";
}
@@ -317,15 +374,14 @@ abstract class phpdotnet extends PhDTheme {
return "<h1>";
}
$ret = "";
- if ($this->tmp["container_chunk"]) {
- $ret = $this->tmp["container_chunk"];
- $this->tmp["container_chunk"] = null;
+ if ($this->cchunk["container_chunk"]) {
+ $ret = $this->cchunk["container_chunk"];
+ $this->cchunk["container_chunk"] = null;
}
return "</h1>\n" .$ret;
}
public function format_root_chunk($open, $name, $attrs) {
$this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"];
- $this->CURRENT_FUNCTION = null;
if ($open) {
return "<div>";
}
@@ -377,24 +433,25 @@ abstract class phpdotnet extends PhDTheme {
if ($display_value === null) {
$display_value = $value;
}
+ $rel = "";
+ if ($this->format->role == "seealso") {
+ $rel = ' rel="rdfs-seeAlso"';
+ }
- $link = strtolower(str_replace(array("__", "_", "::",
"->"), array("", "-", "-", "-"), $value));
- $oop_link = strtolower(str_replace(array("_", "::", "->"),
array("", ".", "."), $value));
-
- if (
- (
- $this->CURRENT_FUNCTION === $link ||
- !($filename = PhDHelper::getFilename("function.$link"))
- ) &&
- (
- $this->CURRENT_ID === $oop_link ||
- !($filename = PhDHelper::getFilename($oop_link))
- )
- ) {
- return '<b>' .$display_value.($tag == "function" ?
"()" : ""). '</b>';
+ $ref = strtolower(str_replace(array("_", "::", "->"),
array("-", "-", "-"), $value));
+ if (($filename = $this->getRefnameLink($ref)) !== null && $this->CURRENT_ID
!== $filename) {
+ if ($this->chunked) {
+ return '<a href="'.$filename. '.' .$this->ext.
'" class="function"'.$rel.'>' .$display_value.($tag ==
"function" ? "()" : ""). '</a>';
+ }
+ return '<a href="#'.$filename. '"
class="function"'.$rel.'>' .$display_value.($tag == "function"
? "()" : ""). '</a>';
}
-
- return '<a href="' .($this->chunked ? "" :
"#").$filename. '.' .$this->ext. '"
class="function">' .$display_value.($tag == "function" ? "()"
: ""). '</a>';
+ return '<b>' .$display_value.($tag == "function" ? "()"
: ""). '</b>';
+ }
+ public function format_type_if_object_or_pseudo_text($type, $tagname) {
+ if (in_array(strtolower($type), array("bool", "int",
"double", "boolean", "integer", "float", "string",
"array", "object", "resource", "null"))) {
+ return false;
+ }
+ return self::format_type_text($type, $tagname);
}
public function format_type_text($type, $tagname) {
$t = strtolower($type);
@@ -445,7 +502,7 @@ abstract class phpdotnet extends PhDTheme {
return "";
}
if ($open) {
- return "<p><b>Example#"
.++$this->tmp["chunk"]["examples"]. " ";
+ return "<p><b>" . ($this->autogen('example',
$props['lang']) . ++$this->cchunk["examples"]) . " ";
}
return "</b></p>";
}
@@ -454,34 +511,37 @@ abstract class phpdotnet extends PhDTheme {
public function qandaset($stream) {
$xml = stream_get_contents($stream);
- libxml_use_internal_errors(true);
+ $old = 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"));
+ $doc->loadXML(html_entity_decode(str_replace("&",
"&amp;", "<div>$xml</div>"), ENT_QUOTES,
"UTF-8"));
+ if ($err = libxml_get_errors()) {
+ print_r($err);
+ libxml_clear_errors();
+ }
fclose($stream);
- libxml_clear_errors();
- libxml_use_internal_errors(false);
+ libxml_use_internal_errors($old);
$xpath = new DOMXPath($doc);
- $nlist = $xpath->query("//html/body/div/dl/dt");
+ $nlist = $xpath->query("//div/dl/dt");
$ret = '<div class="qandaset"><ol
class="qandaset_questions">';
$i = 0;
foreach($nlist as $node) {
- $ret .= '<li><a href="#'
.($this->tmp["qandaentry"][$i++]). '">'
.(htmlspecialchars($node->textContent,ENT_QUOTES, "UTF-8")).
'</a></li>';
+ $ret .= '<li><a href="#'
.($this->cchunk["qandaentry"][$i++]). '">' .($node->textContent).
'</a></li>';
}
- return $ret.'</ul>'.$xml.'</div>';
+ return $ret.'</ol>'.$xml.'</div>';
}
public function format_qandaentry($open, $name, $attrs) {
if ($open) {
- $this->tmp["qandaentry"][] = $attrs[PhDReader::XMLNS_XML]["id"];
+ $this->cchunk["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><a name="'
.end($this->cchunk["qandaentry"]).'"></a>';
}
return "</dd>";
}
diff --git a/themes/php/phpweb.php b/themes/php/phpweb.php
index 5fd6259..238ef05 100644
--- a/themes/php/phpweb.php
+++ b/themes/php/phpweb.php
@@ -5,31 +5,52 @@ require_once $ROOT . '/themes/php/phpdotnet.php';
class phpweb extends phpdotnet {
protected $streams = array();
protected $writeit = false;
+ protected $outputdir = '';
public function __construct($IDs, $filename, $ext = "php", $chunked = true) {
parent::__construct($IDs, $filename, $ext, $chunked);
- if (!file_exists("php") || is_file("php")) mkdir("php") or
die("Can't create the cache directory");
- if (!file_exists("php/toc") || is_file("php/toc"))
mkdir("php/toc") or die("Can't create the toc directory");
+ $this->outputdir = $GLOBALS['OPTIONS']['output_dir'] . $this->ext
. DIRECTORY_SEPARATOR;
+ if (!file_exists($this->outputdir) || is_file($this->outputdir))
mkdir($this->outputdir) or die("Can't create the cache directory");
+ if (!file_exists($this->outputdir . "toc") || is_file($this->outputdir .
"toc")) mkdir($this->outputdir . "toc") or die("Can't create the
toc directory");
}
public function writeChunk($id, $stream) {
rewind($stream);
- $filename = $this->ext."/$id.".$this->ext;
- file_put_contents($filename, $this->header($id));
- file_put_contents($filename, $stream, FILE_APPEND);
- file_put_contents($filename, $this->footer($id), FILE_APPEND);
+
+ // Create random filename when the chunk doesn't have an ID
+ if ($id === null) {
+ $filename = tempnam($this->outputdir, 'phd');
+ $newfilename = $this->outputdir . basename($filename, '.tmp') .
'.' . $this->ext;
+ if(rename($filename, $newfilename)) {
+ $filename = basename($filename, '.tmp');
+ } else {
+ throw new Exception("Cannot rename $filename to $newfilename");
+ }
+ v("WARNING: Chunk without an ID found, TOC will NOT work. Wrote content to
$newfilename.\n");
+ } else {
+ $filename = $id;
+ }
+ $filename .= '.' . $this->ext;
+
+ file_put_contents($this->outputdir . $filename, $this->header($id));
+ file_put_contents($this->outputdir . $filename, $stream, FILE_APPEND);
+ file_put_contents($this->outputdir . $filename, $this->footer($id), FILE_APPEND);
+
if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_CHUNK_WRITING) {
- v("Wrote %s\n", $filename);
+ v("Wrote %s\n", $this->outputdir . $filename);
}
}
public function appendData($data, $isChunk) {
switch($isChunk) {
case PhDReader::CLOSE_CHUNK:
$id = $this->CURRENT_ID;
+
$stream = array_pop($this->streams);
$retval = fwrite($stream, $data);
$this->writeChunk($id, $stream);
fclose($stream);
+
+ $this->CURRENT_ID = null;
return $retval;
break;
@@ -45,7 +66,7 @@ class phpweb extends phpdotnet {
public function header($id) {
$ext = '.' .$this->ext;
$parent = PhDHelper::getParent($id);
- $filename = $this->ext . DIRECTORY_SEPARATOR . "toc" . DIRECTORY_SEPARATOR .
$parent . ".inc";
+ $filename = "toc" . DIRECTORY_SEPARATOR . $parent . ".inc";
$up = array(null, null);
$incl = '';
@@ -57,7 +78,8 @@ class phpweb extends phpdotnet {
* to easily add new pages without needing to rebuild the entire
* section.
*/
- if (!file_exists($filename)) {
+ if (!file_exists($this->outputdir . $filename)) {
+ $toc = array();
foreach($siblings as $sid => $array) {
$toc[] = array($sid.$ext, empty($array["sdesc"]) ?
$array["ldesc"] : $array["sdesc"]);
@@ -73,10 +95,10 @@ class phpweb extends phpdotnet {
$TOC = ' . var_export($toc, true) . ';
$PARENTS = ' . var_export($parents, true) . ';';
- file_put_contents($filename, $content);
+ file_put_contents($this->outputdir . $filename, $content);
if ($GLOBALS["OPTIONS"]["verbose"] & VERBOSE_TOC_WRITING) {
- v("Wrote TOC (%s)\n", $filename);
+ v("Wrote TOC (%s)\n", $this->outputdir . $filename);
}
}
@@ -181,13 +203,13 @@ manual_header();
return $next;
}
public function __destruct() {
- if (file_exists("php/manual.php")) {
- copy("php/manual.php", "php/index.php");
+ if (file_exists($this->outputdir . "manual.php")) {
+ copy($this->outputdir . "manual.php", $this->outputdir .
"index.php");
}
}
public function format_qandaset($open, $name, $attrs) {
if ($open) {
- $this->tmp["qandaentry"] = array();
+ $this->cchunk["qandaentry"] = array();
$this->appendData(null, PhDReader::OPEN_CHUNK);
return '';
}
commit aec67e344854d3379dde06e79d5cc4e1c6743e83
Author: Hannes Magnusson <bjori@php.net>
Date: Sun Dec 30 14:38:22 2007 +0000
MFH: Sync to PhD 0.2.1
diff --git a/README.RENDERER b/README.RENDERER
index 8b345b6..36bead1 100644
--- a/README.RENDERER
+++ b/README.RENDERER
@@ -1,7 +1,8 @@
Installing the PhD renderer:
From Release ball:
- pear install http://doc.php.net/phd/PhD-0.2.0.tgz
+ pear install http://doc.php.net/phd/PhD-x.y.z.tgz
+ # Where x.y.z is the version number, i.e. 0.2.1
From CVS:
cvs -d:pserver:cvsread@cvs.php.net/repository co phd
@@ -36,6 +37,7 @@ Rendering the documentations for the first time:
#5) phd --docbook ~/phpdoc/.manual.xml
(Using PHP prior to 5.3:)
#5-old) phd -d ~/phpdoc/.manual.xml
+ NOTE: The shortform works on PHP5.3 too
This will create
diff --git a/build.php b/build.php
index fa2ce0f..3a9a958 100644
--- a/build.php
+++ b/build.php
@@ -41,6 +41,7 @@ require $ROOT. "/include/PhDReader.class.php";
require $ROOT. "/include/PhDPartialReader.class.php";
require $ROOT. "/include/PhDHelper.class.php";
require $ROOT. "/include/PhDFormat.class.php";
+require $ROOT. "/include/PhDTheme.class.php";
if ($OPTIONS["index"]) {
if ($OPTIONS["verbose"] & VERBOSE_INDEXING) {
@@ -98,6 +99,11 @@ foreach($OPTIONS["output_format"] as $output_format) {
default:
$themes[$themename] = new $themename($IDs);
}
+
+ // WARNING: this needs to go away when we add support for
+ // things other than xhtml
+ $themes[$themename]->registerFormat($format);
+
// If the theme returns empty callback map there is no need to include it
$tmp = $themes[$themename]->getElementMap();
@@ -138,9 +144,9 @@ foreach($OPTIONS["output_format"] as $output_format) {
$props = array(
"empty" => $reader->isEmptyElement,
"isChunk" => $isChunk,
- /* These two are not used at the moment */
"lang" => $reader->xmlLang,
"ns" => $reader->namespaceURI,
+ "sibling" => $reader->getPreviousSiblingTagName(),
);
$skip = array();
@@ -159,6 +165,7 @@ foreach($OPTIONS["output_format"] as $output_format) {
}
continue;
}
+
$funcname = $tag;
$retval = $themes[$theme]->{$funcname}($open, $nodename, $attrs,
$props);
if ($retval !== false) {
diff --git a/config.php b/config.php
index b767f90..703614b 100644
--- a/config.php
+++ b/config.php
@@ -18,7 +18,7 @@ define('VERBOSE_CHUNK_WRITING', 0x80);
define('VERBOSE_ALL',VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_PARTIAL_CHILD_READING|VERBOSE_TOC_WRITING|VERBOSE_CHUNK_WRITING);
-define("PHD_VERSION", "0.2.0");
+define("PHD_VERSION", "0.2.1");
$OPTIONS = array (
'output_format' => array('xhtml'),
@@ -85,11 +85,11 @@ foreach($args as $k => $v) {
case "d":
case "docbook":
if (is_array($v)) {
- v("Can only parse one file at a time");
+ v("Can only parse one file at a time\n");
exit(-1);
}
if (!file_exists($v) || is_dir($v) || !is_readable($v)) {
- v("'%s' is not a readable docbook file", $v);
+ v("'%s' is not a readable docbook file\n", $v);
exit(-1);
}
$OPTIONS["xml_root"] = dirname($v);
@@ -102,7 +102,7 @@ foreach($args as $k => $v) {
case "f":
case "format":
if ($v != "xhtml") {
- v("Only xhtml is supported at this time");
+ v("Only xhtml is supported at this time\n");
exit(-1);
}
break;
@@ -112,7 +112,7 @@ foreach($args as $k => $v) {
case "i":
case "index":
if (is_array($v)) {
- v("You cannot pass %s more than once", $k);
+ v("You cannot pass %s more than once\n", $k);
exit(-1);
}
switch ($v) {
@@ -127,7 +127,7 @@ foreach($args as $k => $v) {
$OPTIONS["index"] = false;
break;
default:
- v("yes/no || true/false || 1/0 expected");
+ v("yes/no || true/false || 1/0 expected\n");
exit(-1);
}
break;
@@ -167,7 +167,7 @@ foreach($args as $k => $v) {
}
break;
default:
- v("Unkown theme '%s'", $val);
+ v("Unkown theme '%s'\n", $val);
exit(-1);
}
}
@@ -205,7 +205,7 @@ foreach($args as $k => $v) {
case "V":
case "version":
v("PhD version: %s\n", PHD_VERSION);
- v("Copyright (c) 2007 The PHP Documentation Group");
+ v("Copyright (c) 2007 The PHP Documentation Group\n");
exit(0);
case "usage":
diff --git a/formats/xhtml.php b/formats/xhtml.php
index e7c5e25..7a872c0 100644
--- a/formats/xhtml.php
+++ b/formats/xhtml.php
@@ -195,7 +195,7 @@ class XHTMLPhDFormat extends PhDFormat {
'synopsis' => 'pre',
'tag' => 'code',
'table' => 'format_table',
- 'term' => 'span',
+ 'term' => 'format_term',
'tfoot' => 'format_th',
'thead' => 'format_th',
'tgroup' => 'format_tgroup',
@@ -254,6 +254,28 @@ class XHTMLPhDFormat extends PhDFormat {
/* 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',
+ ),
+ ),
);
@@ -389,6 +411,31 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</div>";
}
+
+ public function format_classsynopsis_ooclass_classname_text($value, $tag) {
+ $this->tmp["classsynopsis"]["classname"] = $value;
+ return $value;
+ }
+
+ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
+ if (!isset($this->tmp["classsynopsis"]["classname"])) {
+ return $value;
+ }
+ if (strpos($value, '::')) {
+ $explode = '::';
+ } else if (strpos($value, '->')) {
+ $explode = '->';
+ } else {
+ return $value;
+ }
+
+ list($class, $method) = explode($explode, $value);
+ if ($class !== $this->tmp["classsynopsis"]["classname"]) {
+ return $value;
+ }
+ return $method;
+ }
+
public function format_fieldsynopsis($open, $name, $attrs) {
$this->tmp["fieldsynopsis"] = array();
if ($open) {
@@ -587,6 +634,15 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</dd>\n";
}
+ public function format_term($open, $name, $attrs, $props) {
+ if ($open) {
+ if ($props["sibling"] == $name) {
+ return '<br /><span class="' .$name.
'">';
+ }
+ return '<span class="' .$name. '">';
+ }
+ return "</span>\n";
+ }
public function format_userinput($open, $name, $attrs) {
if ($open) {
return '<strong class="' .$name. '"><code>';
diff --git a/include/PhDFormat.class.php b/include/PhDFormat.class.php
index d650dbd..ad4de72 100644
--- a/include/PhDFormat.class.php
+++ b/include/PhDFormat.class.php
@@ -79,9 +79,6 @@ abstract class PhDFormat extends PhDHelper {
}
-interface PhDTheme {
- public function appendData($data, $isChunk);
-}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
diff --git a/include/PhDReader.class.php b/include/PhDReader.class.php
index 8374ba6..ea2cfb8 100644
--- a/include/PhDReader.class.php
+++ b/include/PhDReader.class.php
@@ -13,6 +13,7 @@ class PhDReader extends XMLReader {
private $STACK = array();
private $LAST_DEPTH = -1;
private $lastChunkDepth = -1;
+ private $PREVIOUS_SIBLING = "";
public $isChunk = false;
@@ -107,6 +108,10 @@ class PhDReader extends XMLReader {
public function getParentTagName() {
return $this->STACK[$this->depth-1];
}
+ public function getPreviousSiblingTagName() {
+ return $this->PREVIOUS_SIBLING;
+ }
+
public function read() {
$this->isChunk = false;
if(XMLReader::read()) {
diff --git a/include/PhDTheme.class.php b/include/PhDTheme.class.php
new file mode 100644
index 0000000..35957d5
--- /dev/null
+++ b/include/PhDTheme.class.php
@@ -0,0 +1,19 @@
+<?php
+/* $Id$ */
+
+abstract class PhDTheme extends PhDHelper implements iPhDTheme {
+ protected $format;
+ public function registerFormat($format) {
+ $this->format = $format;
+ }
+}
+
+interface iPhDTheme {
+ public function appendData($data, $isChunk);
+}
+
+/*
+ * vim600: sw=4 ts=4 fdm=syntax syntax=php et
+ * vim<600: sw=4 ts=4
+ */
+
diff --git a/package.xml b/package.xml
index c8612a7..b8b38d1 100644
--- a/package.xml
+++ b/package.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://pear.php.net/dtd/package-2.0"
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
packagerversion="1.5.4" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>PhD</name>
- <uri>http://doc.php.net/phd/phd-0.2.0</uri>
+ <uri>http://doc.php.net/phd/phd-0.2.1</uri>
<summary>A PHP based Docbook renderer</summary>
<description>
PhD is a PHP based Docbook renderer aimed to replace the Docbook-XSL
@@ -13,10 +13,10 @@
<email>bjori@php.net</email>
<active>yes</active>
</lead>
- <date>2007-11-08</date>
+ <date>2007-12-30</date>
<version>
- <release>0.2.0</release>
- <api>0.2.0</api>
+ <release>0.2.1</release>
+ <api>0.2.1</api>
</version>
<stability>
<release>snapshot</release>
@@ -24,19 +24,17 @@
</stability>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD
Style</license>
<notes>
- - Added partial rendering
- - Added various verbosity levels
- - Added getopt() parsing for few configuration options
- - Added support for errorcode, symbol and superscript elements (used by few translations)
- - Suppressed the contrib element
-
- - Fixed bug#43192 (Chunked HTML output difficult to use without TOC). (Edward Z. Yang)
- - Fixed bug#43191 (build.php fails to included necessary theme dependencies). (Edward Z. Yang,
Richard Q)
+ - Multiple <term>s should be line seperated
+ - Fixed autogenerated links to methods (Edward Z.)
+ - Compressed methodnames in classsynopsis (Edward Z.)
+ - Added HTML headers for the bightml theme
+ - Removed warnings about missing translation files
</notes>
<contents>
<dir baseinstalldir="phd" name="/">
<file baseinstalldir="phd" name="formats/xhtml.php"
role="php"/>
<file baseinstalldir="phd" name="include/PhDFormat.class.php"
role="php"/>
+ <file baseinstalldir="phd" name="include/PhDTheme.class.php"
role="php"/>
<file baseinstalldir="phd" name="include/PhDHelper.class.php"
role="php"/>
<file baseinstalldir="phd" name="include/PhDReader.class.php"
role="php"/>
<file baseinstalldir="phd" name="include/PhDPartialReader.class.php"
role="php"/>
@@ -157,6 +155,30 @@
</notes>
</release>
</changelog>
+ <changelog>
+ <release>
+ <version>
+ <release>0.2.0</release>
+ <api>0.2.0</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>devel</api>
+ </stability>
+ <date>2007-11-08</date>
+ <notes>
+ - Added partial rendering
+ - Added various verbosity levels
+ - Added getopt() parsing for few configuration options
+ - Added support for errorcode, symbol and superscript elements (used by few translations)
+ - Suppressed the contrib element
+
+ - Fixed bug#43192 (Chunked HTML output difficult to use without TOC). (Edward Z. Yang)
+ - Fixed bug#43191 (build.php fails to included necessary theme dependencies). (Edward Z. Yang,
Richard Q)
+ </notes>
+ </release>
+ </changelog>
+
</package>
<!--
vim: et sw=2 ts=2
diff --git a/phpdotnet/phd/Config.php b/phpdotnet/phd/Config.php
index b767f90..703614b 100644
--- a/phpdotnet/phd/Config.php
+++ b/phpdotnet/phd/Config.php
@@ -18,7 +18,7 @@ define('VERBOSE_CHUNK_WRITING', 0x80);
define('VERBOSE_ALL',VERBOSE_INDEXING|VERBOSE_FORMAT_RENDERING|VERBOSE_THEME_RENDERING|VERBOSE_RENDER_STYLE|VERBOSE_PARTIAL_READING|VERBOSE_PARTIAL_CHILD_READING|VERBOSE_TOC_WRITING|VERBOSE_CHUNK_WRITING);
-define("PHD_VERSION", "0.2.0");
+define("PHD_VERSION", "0.2.1");
$OPTIONS = array (
'output_format' => array('xhtml'),
@@ -85,11 +85,11 @@ foreach($args as $k => $v) {
case "d":
case "docbook":
if (is_array($v)) {
- v("Can only parse one file at a time");
+ v("Can only parse one file at a time\n");
exit(-1);
}
if (!file_exists($v) || is_dir($v) || !is_readable($v)) {
- v("'%s' is not a readable docbook file", $v);
+ v("'%s' is not a readable docbook file\n", $v);
exit(-1);
}
$OPTIONS["xml_root"] = dirname($v);
@@ -102,7 +102,7 @@ foreach($args as $k => $v) {
case "f":
case "format":
if ($v != "xhtml") {
- v("Only xhtml is supported at this time");
+ v("Only xhtml is supported at this time\n");
exit(-1);
}
break;
@@ -112,7 +112,7 @@ foreach($args as $k => $v) {
case "i":
case "index":
if (is_array($v)) {
- v("You cannot pass %s more than once", $k);
+ v("You cannot pass %s more than once\n", $k);
exit(-1);
}
switch ($v) {
@@ -127,7 +127,7 @@ foreach($args as $k => $v) {
$OPTIONS["index"] = false;
break;
default:
- v("yes/no || true/false || 1/0 expected");
+ v("yes/no || true/false || 1/0 expected\n");
exit(-1);
}
break;
@@ -167,7 +167,7 @@ foreach($args as $k => $v) {
}
break;
default:
- v("Unkown theme '%s'", $val);
+ v("Unkown theme '%s'\n", $val);
exit(-1);
}
}
@@ -205,7 +205,7 @@ foreach($args as $k => $v) {
case "V":
case "version":
v("PhD version: %s\n", PHD_VERSION);
- v("Copyright (c) 2007 The PHP Documentation Group");
+ v("Copyright (c) 2007 The PHP Documentation Group\n");
exit(0);
case "usage":
diff --git a/phpdotnet/phd/Format/Legacy.php b/phpdotnet/phd/Format/Legacy.php
index d650dbd..ad4de72 100644
--- a/phpdotnet/phd/Format/Legacy.php
+++ b/phpdotnet/phd/Format/Legacy.php
@@ -79,9 +79,6 @@ abstract class PhDFormat extends PhDHelper {
}
-interface PhDTheme {
- public function appendData($data, $isChunk);
-}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
diff --git a/phpdotnet/phd/Format/XHTML.php b/phpdotnet/phd/Format/XHTML.php
index e7c5e25..7a872c0 100644
--- a/phpdotnet/phd/Format/XHTML.php
+++ b/phpdotnet/phd/Format/XHTML.php
@@ -195,7 +195,7 @@ class XHTMLPhDFormat extends PhDFormat {
'synopsis' => 'pre',
'tag' => 'code',
'table' => 'format_table',
- 'term' => 'span',
+ 'term' => 'format_term',
'tfoot' => 'format_th',
'thead' => 'format_th',
'tgroup' => 'format_tgroup',
@@ -254,6 +254,28 @@ class XHTMLPhDFormat extends PhDFormat {
/* 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',
+ ),
+ ),
);
@@ -389,6 +411,31 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</div>";
}
+
+ public function format_classsynopsis_ooclass_classname_text($value, $tag) {
+ $this->tmp["classsynopsis"]["classname"] = $value;
+ return $value;
+ }
+
+ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
+ if (!isset($this->tmp["classsynopsis"]["classname"])) {
+ return $value;
+ }
+ if (strpos($value, '::')) {
+ $explode = '::';
+ } else if (strpos($value, '->')) {
+ $explode = '->';
+ } else {
+ return $value;
+ }
+
+ list($class, $method) = explode($explode, $value);
+ if ($class !== $this->tmp["classsynopsis"]["classname"]) {
+ return $value;
+ }
+ return $method;
+ }
+
public function format_fieldsynopsis($open, $name, $attrs) {
$this->tmp["fieldsynopsis"] = array();
if ($open) {
@@ -587,6 +634,15 @@ class XHTMLPhDFormat extends PhDFormat {
}
return "</dd>\n";
}
+ public function format_term($open, $name, $attrs, $props) {
+ if ($open) {
+ if ($props["sibling"] == $name) {
+ return '<br /><span class="' .$name.
'">';
+ }
+ return '<span class="' .$name. '">';
+ }
+ return "</span>\n";
+ }
public function format_userinput($open, $name, $attrs) {
if ($open) {
return '<strong class="' .$name. '"><code>';
diff --git a/phpdotnet/phd/Reader/Legacy.php b/phpdotnet/phd/Reader/Legacy.php
index 8374ba6..ea2cfb8 100644
--- a/phpdotnet/phd/Reader/Legacy.php
+++ b/phpdotnet/phd/Reader/Legacy.php
@@ -13,6 +13,7 @@ class PhDReader extends XMLReader {
private $STACK = array();
private $LAST_DEPTH = -1;
private $lastChunkDepth = -1;
+ private $PREVIOUS_SIBLING = "";
public $isChunk = false;
@@ -107,6 +108,10 @@ class PhDReader extends XMLReader {
public function getParentTagName() {
return $this->STACK[$this->depth-1];
}
+ public function getPreviousSiblingTagName() {
+ return $this->PREVIOUS_SIBLING;
+ }
+
public function read() {
$this->isChunk = false;
if(XMLReader::read()) {
diff --git a/phpdotnet/phd/Theme.php b/phpdotnet/phd/Theme.php
new file mode 100644
index 0000000..35957d5
--- /dev/null
+++ b/phpdotnet/phd/Theme.php
@@ -0,0 +1,19 @@
+<?php
+/* $Id$ */
+
+abstract class PhDTheme extends PhDHelper implements iPhDTheme {
+ protected $format;
+ public function registerFormat($format) {
+ $this->format = $format;
+ }
+}
+
+interface iPhDTheme {
+ public function appendData($data, $isChunk);
+}
+
+/*
+ * vim600: sw=4 ts=4 fdm=syntax syntax=php et
+ * vim<600: sw=4 ts=4
+ */
+
diff --git a/phpdotnet/phd/Theme/PHP/BigHTML.php b/phpdotnet/phd/Theme/PHP/BigHTML.php
index 92daee8..51f0e03 100644
--- a/phpdotnet/phd/Theme/PHP/BigHTML.php
+++ b/phpdotnet/phd/Theme/PHP/BigHTML.php
@@ -2,7 +2,7 @@
/* $Id$ */
require_once $ROOT . '/themes/php/phpdotnet.php';
-class bightml extends phpdotnet implements PhDTheme {
+class bightml extends phpdotnet {
public function __construct(array $IDs, $filename, $ext = "html") {
parent::__construct($IDs, $filename, $ext, false);
$this->stream = fopen("bightml.html", "w");
diff --git a/phpdotnet/phd/Theme/PHP/PHPDotNet.php b/phpdotnet/phd/Theme/PHP/PHPDotNet.php
index 46931f7..bffde4c 100644
--- a/phpdotnet/phd/Theme/PHP/PHPDotNet.php
+++ b/phpdotnet/phd/Theme/PHP/PHPDotNet.php
@@ -1,7 +1,7 @@
<?php
/* $Id$ */
-class phpdotnet extends PhDHelper {
+abstract class phpdotnet extends PhDTheme {
protected $elementmap = array(
'acronym' => 'format_suppressed_tags',
'function' => 'format_suppressed_tags',
@@ -80,7 +80,21 @@ class phpdotnet extends PhDHelper {
protected $textmap = array(
'acronym' => 'format_acronym_text',
'function' => 'format_function_text',
- 'methodname' => 'format_function_text',
+ 'methodname' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'constructorsynopsis' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'classsynopsis' =>
'format_classsynopsis_methodsynopsis_methodname_text',
+ ),
+ 'methodsynopsis' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'classsynopsis' =>
'format_classsynopsis_methodsynopsis_methodname_text',
+ ),
+ 'destructorsynopsis' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'classsynopsis' =>
'format_classsynopsis_methodsynopsis_methodname_text',
+ ),
+ ),
'type' => array(
/* DEFAULT */ 'format_type_text',
'classsynopsisinfo' => false,
@@ -353,14 +367,34 @@ class phpdotnet extends PhDHelper {
/* ignore it */
return "";
}
- public function format_function_text($value, $tag) {
+
+ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
+ $display_value =
$this->format->format_classsynopsis_methodsynopsis_methodname_text($value, $tag);
+ return $this->format_function_text($value, $tag, $display_value);
+ }
+
+ public function format_function_text($value, $tag, $display_value = null) {
+ if ($display_value === null) {
+ $display_value = $value;
+ }
+
$link = strtolower(str_replace(array("__", "_", "::",
"->"), array("", "-", "-", "-"), $value));
-
- if ($this->CURRENT_FUNCTION === $link || !($filename =
PhDHelper::getFilename("function.$link"))) {
- return '<b>' .$value.($tag == "function" ? "()" :
""). '</b>';
+ $oop_link = strtolower(str_replace(array("_", "::", "->"),
array("", ".", "."), $value));
+
+ if (
+ (
+ $this->CURRENT_FUNCTION === $link ||
+ !($filename = PhDHelper::getFilename("function.$link"))
+ ) &&
+ (
+ $this->CURRENT_ID === $oop_link ||
+ !($filename = PhDHelper::getFilename($oop_link))
+ )
+ ) {
+ return '<b>' .$display_value.($tag == "function" ?
"()" : ""). '</b>';
}
- return '<a href="' .($this->chunked ? "" :
"#").$filename. '.' .$this->ext. '"
class="function">' .$value.($tag == "function" ? "()" :
""). '</a>';
+ return '<a href="' .($this->chunked ? "" :
"#").$filename. '.' .$this->ext. '"
class="function">' .$display_value.($tag == "function" ? "()"
: ""). '</a>';
}
public function format_type_text($type, $tagname) {
$t = strtolower($type);
@@ -392,7 +426,11 @@ class phpdotnet extends PhDHelper {
$href = "language.pseudo-types";
$fragment = "language.types.$t";
break;
+ default:
+ /* Check if its a classname. */
+ $href = PhDTheme::getFilename("class.$t");
}
+
if ($href && $this->chunked) {
return '<a href="' .$href. '.' .$this->ext.($fragment ?
"#$fragment" : ""). '" class="' .$tagname. ' '
.$type. '">' .$type. '</a>';
}
diff --git a/phpdotnet/phd/Theme/PHP/Web.php b/phpdotnet/phd/Theme/PHP/Web.php
index 33e4d16..5fd6259 100644
--- a/phpdotnet/phd/Theme/PHP/Web.php
+++ b/phpdotnet/phd/Theme/PHP/Web.php
@@ -2,7 +2,7 @@
/* $Id$ */
require_once $ROOT . '/themes/php/phpdotnet.php';
-class phpweb extends phpdotnet implements PhDTheme {
+class phpweb extends phpdotnet {
protected $streams = array();
protected $writeit = false;
diff --git a/themes/php/bightml.php b/themes/php/bightml.php
index 92daee8..51f0e03 100644
--- a/themes/php/bightml.php
+++ b/themes/php/bightml.php
@@ -2,7 +2,7 @@
/* $Id$ */
require_once $ROOT . '/themes/php/phpdotnet.php';
-class bightml extends phpdotnet implements PhDTheme {
+class bightml extends phpdotnet {
public function __construct(array $IDs, $filename, $ext = "html") {
parent::__construct($IDs, $filename, $ext, false);
$this->stream = fopen("bightml.html", "w");
diff --git a/themes/php/phpdotnet.php b/themes/php/phpdotnet.php
index 46931f7..bffde4c 100644
--- a/themes/php/phpdotnet.php
+++ b/themes/php/phpdotnet.php
@@ -1,7 +1,7 @@
<?php
/* $Id$ */
-class phpdotnet extends PhDHelper {
+abstract class phpdotnet extends PhDTheme {
protected $elementmap = array(
'acronym' => 'format_suppressed_tags',
'function' => 'format_suppressed_tags',
@@ -80,7 +80,21 @@ class phpdotnet extends PhDHelper {
protected $textmap = array(
'acronym' => 'format_acronym_text',
'function' => 'format_function_text',
- 'methodname' => 'format_function_text',
+ 'methodname' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'constructorsynopsis' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'classsynopsis' =>
'format_classsynopsis_methodsynopsis_methodname_text',
+ ),
+ 'methodsynopsis' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'classsynopsis' =>
'format_classsynopsis_methodsynopsis_methodname_text',
+ ),
+ 'destructorsynopsis' => array(
+ /* DEFAULT */ 'format_function_text',
+ 'classsynopsis' =>
'format_classsynopsis_methodsynopsis_methodname_text',
+ ),
+ ),
'type' => array(
/* DEFAULT */ 'format_type_text',
'classsynopsisinfo' => false,
@@ -353,14 +367,34 @@ class phpdotnet extends PhDHelper {
/* ignore it */
return "";
}
- public function format_function_text($value, $tag) {
+
+ public function format_classsynopsis_methodsynopsis_methodname_text($value, $tag) {
+ $display_value =
$this->format->format_classsynopsis_methodsynopsis_methodname_text($value, $tag);
+ return $this->format_function_text($value, $tag, $display_value);
+ }
+
+ public function format_function_text($value, $tag, $display_value = null) {
+ if ($display_value === null) {
+ $display_value = $value;
+ }
+
$link = strtolower(str_replace(array("__", "_", "::",
"->"), array("", "-", "-", "-"), $value));
-
- if ($this->CURRENT_FUNCTION === $link || !($filename =
PhDHelper::getFilename("function.$link"))) {
- return '<b>' .$value.($tag == "function" ? "()" :
""). '</b>';
+ $oop_link = strtolower(str_replace(array("_", "::", "->"),
array("", ".", "."), $value));
+
+ if (
+ (
+ $this->CURRENT_FUNCTION === $link ||
+ !($filename = PhDHelper::getFilename("function.$link"))
+ ) &&
+ (
+ $this->CURRENT_ID === $oop_link ||
+ !($filename = PhDHelper::getFilename($oop_link))
+ )
+ ) {
+ return '<b>' .$display_value.($tag == "function" ?
"()" : ""). '</b>';
}
- return '<a href="' .($this->chunked ? "" :
"#").$filename. '.' .$this->ext. '"
class="function">' .$value.($tag == "function" ? "()" :
""). '</a>';
+ return '<a href="' .($this->chunked ? "" :
"#").$filename. '.' .$this->ext. '"
class="function">' .$display_value.($tag == "function" ? "()"
: ""). '</a>';
}
public function format_type_text($type, $tagname) {
$t = strtolower($type);
@@ -392,7 +426,11 @@ class phpdotnet extends PhDHelper {
$href = "language.pseudo-types";
$fragment = "language.types.$t";
break;
+ default:
+ /* Check if its a classname. */
+ $href = PhDTheme::getFilename("class.$t");
}
+
if ($href && $this->chunked) {
return '<a href="' .$href. '.' .$this->ext.($fragment ?
"#$fragment" : ""). '" class="' .$tagname. ' '
.$type. '">' .$type. '</a>';
}
diff --git a/themes/php/phpweb.php b/themes/php/phpweb.php
index 33e4d16..5fd6259 100644
--- a/themes/php/phpweb.php
+++ b/themes/php/phpweb.php
@@ -2,7 +2,7 @@
/* $Id$ */
require_once $ROOT . '/themes/php/phpdotnet.php';
-class phpweb extends phpdotnet implements PhDTheme {
+class phpweb extends phpdotnet {
protected $streams = array();
protected $writeit = false;
commit 0e2c07e422de8b5bf519829830ac84709e1a737d
Author: Hannes Magnusson <bjori@php.net>
Date: Sun Nov 25 20:29:32 2007 +0000
file PhDTheme.class.php was added on branch rsync on 2007-12-30 14:38:22 +0000
diff --git a/phpdotnet/phd/Theme.php b/phpdotnet/phd/Theme.php
deleted file mode 100644
index 35957d5..0000000
--- a/phpdotnet/phd/Theme.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-/* $Id$ */
-
-abstract class PhDTheme extends PhDHelper implements iPhDTheme {
- protected $format;
- public function registerFormat($format) {
- $this->format = $format;
- }
-}
-
-interface iPhDTheme {
- public function appendData($data, $isChunk);
-}
-
-/*
- * vim600: sw=4 ts=4 fdm=syntax syntax=php et
- * vim<600: sw=4 ts=4
- */
-
commit a96f821127721f198d19e96cee4e9564975f7499
Author: SVN Migration <svn@php.net>
Date: Sun Nov 25 20:29:31 2007 +0000
This commit was manufactured by cvs2svn to create branch 'rsync'.
diff --git a/phpdotnet/phd/Theme.php b/phpdotnet/phd/Theme.php
new file mode 100644
index 0000000..35957d5
--- /dev/null
+++ b/phpdotnet/phd/Theme.php
@@ -0,0 +1,19 @@
+<?php
+/* $Id$ */
+
+abstract class PhDTheme extends PhDHelper implements iPhDTheme {
+ protected $format;
+ public function registerFormat($format) {
+ $this->format = $format;
+ }
+}
+
+interface iPhDTheme {
+ public function appendData($data, $isChunk);
+}
+
+/*
+ * vim600: sw=4 ts=4 fdm=syntax syntax=php et
+ * vim<600: sw=4 ts=4
+ */
+
commit 406f72476ff809dc4e9e8006314370dbca43e62a
Author: Hannes Magnusson <bjori@php.net>
Date: Sun Nov 25 14:11:26 2007 +0000
MFH: Add some html headers and set the charset to UTF-8
diff --git a/phpdotnet/phd/Theme/PHP/BigHTML.php b/phpdotnet/phd/Theme/PHP/BigHTML.php
index da3887d..92daee8 100644
--- a/phpdotnet/phd/Theme/PHP/BigHTML.php
+++ b/phpdotnet/phd/Theme/PHP/BigHTML.php
@@ -19,7 +19,14 @@ class bightml extends phpdotnet implements PhDTheme {
fclose($this->stream);
}
public function header() {
- fwrite($this->stream, "<html><body>");
+ fwrite($this->stream, '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title>PHP Manual</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ </head>
+ <body>');
+
}
public function footer() {
fwrite($this->stream, "</body></html>");
diff --git a/themes/php/bightml.php b/themes/php/bightml.php
index da3887d..92daee8 100644
--- a/themes/php/bightml.php
+++ b/themes/php/bightml.php
@@ -19,7 +19,14 @@ class bightml extends phpdotnet implements PhDTheme {
fclose($this->stream);
}
public function header() {
- fwrite($this->stream, "<html><body>");
+ fwrite($this->stream, '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title>PHP Manual</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ </head>
+ <body>');
+
}
public function footer() {
fwrite($this->stream, "</body></html>");
commit 3eeca042ea43548deeb8289820908afe15af26ba
Author: Hannes Magnusson <bjori@php.net>
Date: Sun Nov 25 13:08:29 2007 +0000
Don't throw a warning on not-found-translation-file
diff --git a/include/PhDHelper.class.php b/include/PhDHelper.class.php
index 728a6f4..ce3f157 100644
--- a/include/PhDHelper.class.php
+++ b/include/PhDHelper.class.php
@@ -37,7 +37,7 @@ class PhDHelper {
$filename = dirname(__FILE__) ."/langs/$lang.xml";
$r = new XMLReader;
- if (!$r->open($filename)) {
+ if (!file_exists($filename) || !$r->open($filename)) {
if ($lang == "en") {
throw new Exception("Cannot open $filename");
}
diff --git a/phpdotnet/phd/Helper.php b/phpdotnet/phd/Helper.php
index 728a6f4..ce3f157 100644
--- a/phpdotnet/phd/Helper.php
+++ b/phpdotnet/phd/Helper.php
@@ -37,7 +37,7 @@ class PhDHelper {
$filename = dirname(__FILE__) ."/langs/$lang.xml";
$r = new XMLReader;
- if (!$r->open($filename)) {
+ if (!file_exists($filename) || !$r->open($filename)) {
if ($lang == "en") {
throw new Exception("Cannot open $filename");
}
commit dbad06db2bd2d946beee13bae813f01b03801ca6
Author: SVN Migration <svn@php.net>
Date: Tue Nov 20 22:26:43 2007 +0000
This commit was manufactured by cvs2svn to create branch 'rsync'.
Thank you for your contribution.