cvs: phpdoc /scripts extensions.xml.php
| From: | Nuno Lopes | Date: | Tue, 06 Sep 2005 12:45:31 +0000 |
| Subject: | cvs: phpdoc /scripts extensions.xml.php | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969369922@lists.php.net to get a copy of this message | ||
nlopess Tue Sep 6 08:45:31 2005 EDT
Modified files:
/phpdoc/scripts extensions.xml.php
Log:
everybody likes a good hack :) so I've made a hack to avoid entities beeing replaced. This
efectively closes the extension categorization problem
http://cvs.php.net/diff.php/phpdoc/scripts/extensions.xml.php?r1=1.3&r2=1.4&ty=u
Index: phpdoc/scripts/extensions.xml.php
diff -u phpdoc/scripts/extensions.xml.php:1.3 phpdoc/scripts/extensions.xml.php:1.4
--- phpdoc/scripts/extensions.xml.php:1.3 Mon Sep 5 14:03:23 2005
+++ phpdoc/scripts/extensions.xml.php Tue Sep 6 08:45:28 2005
@@ -16,7 +16,7 @@
| Authors: Nuno Lopes <nlopess@php.net> |
+----------------------------------------------------------------------+
- $Id: extensions.xml.php,v 1.3 2005/09/05 18:03:23 nlopess Exp $
+ $Id: extensions.xml.php,v 1.4 2005/09/06 12:45:28 nlopess Exp $
*/
@@ -98,19 +98,25 @@
// ---------- generate the text to write -------------
-$simplexml = simplexml_load_file("$basedir/en/appendices/extensions.xml", null,
~LIBXML_DTDVALID);
+
+$xml = file_get_contents("$basedir/en/appendices/extensions.xml");
+// little hack to avoid loosing the entities
+$xml = preg_replace('/&([^;]+);/', PHP_EOL.'<!--'.PHP_EOL.'entity:
"$1"'.PHP_EOL.'-->'.PHP_EOL, $xml);
+
+$simplexml = simplexml_load_string($xml, null, ~LIBXML_DTDVALID);
+
foreach ($simplexml as &$node) {
$tmp = explode('.', (string)$node->attributes());
$section = ucfirst($tmp[1]); // Purpose, State or Membership
- foreach ($node as &$topnode) {
+ foreach ($node->section as &$topnode) {
$tmp = explode('.', (string)$topnode->attributes());
$topname = $tmp[count($tmp)-1];
// this means that we have 2 levels (e.g. basic.*)
- if ((bool)$topnode->children()) {
+ if ($topnode->section->itemizedlist->listitem->para->xref) {
foreach ($topnode as &$lastnode) {
$tmp = explode('.', (string)$lastnode->attributes());
$name = $tmp[1].'.'.$tmp[2];
@@ -152,6 +158,8 @@
$xml = strtr(html_entity_decode($simplexml->asXML()), array("\r\n" =>
"\n", "\r" => PHP_EOL, "\n" => PHP_EOL));
+// get the entities back again
+$xml = preg_replace('/( +)[\r\n]+<!--\s+entity:
"([^"]+)"\s+-->[\r\n]+/', '$1&$2;'.PHP_EOL.PHP_EOL, $xml);
file_put_contents("$basedir/en/appendices/extensions.xml", $xml);