svn: /phd/trunk/ package.xml phpdotnet/phd/Format.php phpdotnet/phd/Package/PHP/XHTML.php
| From: | Richard Quadling | Date: | Fri, 03 Jun 2011 13:14:47 +0000 |
| Subject: | svn: /phd/trunk/ package.xml phpdotnet/phd/Format.php phpdotnet/phd/Package/PHP/XHTML.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-8196@lists.php.net to get a copy of this message | ||
rquadling Fri, 03 Jun 2011 13:14:47 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=311770
Log:
Added Format::getTree() method to allow the current location in the tree to be reportable.
Changed paths:
U phd/trunk/package.xml
U phd/trunk/phpdotnet/phd/Format.php
U phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php
Modified: phd/trunk/package.xml
===================================================================
--- phd/trunk/package.xml 2011-06-03 11:48:54 UTC (rev 311769)
+++ phd/trunk/package.xml 2011-06-03 13:14:47 UTC (rev 311770)
@@ -79,6 +79,7 @@
- Serbian (Nikola Smolenski)
- Fixed bug#52664 - "Missing" example#1. (Hannes)
- Added --packagedir option to use external packages. (Moacir)
+ - Added Format::getTree() method to allow the current location in the tree to be reportable.
(Richard Quadling)
</notes>
<contents>
Modified: phd/trunk/phpdotnet/phd/Format.php
===================================================================
--- phd/trunk/phpdotnet/phd/Format.php 2011-06-03 11:48:54 UTC (rev 311769)
+++ phd/trunk/phpdotnet/phd/Format.php 2011-06-03 13:14:47 UTC (rev 311770)
@@ -558,6 +558,45 @@
);
}
+ /**
+ * Provide a nested list of IDs from the document root to the CURRENT_ID.
+ *
+ * @param string $name The name of the current element.
+ * @param mixed[] $props Properties relating to the current element.
+ *
+ * @return string A nested list of IDs from the root to the CURRENT_ID.
+ */
+ public function getTree($name, $props)
+ {
+ /* Build the list of IDs from the CURRENT_ID to the root. */
+ $ids = array();
+ $id = $this->CURRENT_ID;
+ while($id != '')
+ {
+ $ids[] = '<' . $this->indexes[$id]['element'] . '
id="' . $id . '">';
+ $id = $this->indexes[$id]['parent_id'];
+ }
+
+ /* Reverse the list so that it goes form the root to the CURRENT_ID. */
+ $ids = array_reverse($ids);
+
+ /* Build an indented tree view of the ids. */
+ $tree = '';
+ $indent = 0;
+ array_walk($ids, function($value, $key) use(&$tree, &$indent)
+ {
+ $tree .= str_repeat(' ', $indent++) . $value . PHP_EOL;
+ });
+
+ // Add the open and closed sibling and the current element.
+ $tree .=
+ str_repeat(' ', $indent) . '<' . $props['sibling'] .
'>' . PHP_EOL .
+ str_repeat(' ', $indent) . '...' . PHP_EOL .
+ str_repeat(' ', $indent) . '</' . $props['sibling'] .
'>' . PHP_EOL .
+ str_repeat(' ', $indent) . '<' . $name . '>' . PHP_EOL;
+
+ return $tree;
+ }
}
/*
Modified: phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php
===================================================================
--- phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php 2011-06-03 11:48:54 UTC (rev 311769)
+++ phd/trunk/phpdotnet/phd/Package/PHP/XHTML.php 2011-06-03 13:14:47 UTC (rev 311770)
@@ -566,7 +566,7 @@
}
else {
$id = uniqid();
- v("Uhm. Can't find an ID for a chunk? - Generating a random one
(%s)", $id, E_USER_WARNING);
+ v("Uhm. Can't find an ID for a chunk? - Generating a random one
(%s)\n%s", $id, $this->getTree($name, $props), E_USER_WARNING);
}
$this->CURRENT_CHUNK = $this->CURRENT_ID = $id;