iliaa Tue May 25 16:15:04 2004 EDT
Modified files:
/livedocs xml_classes5.php livedoc_funcs.php style_mapping.php
Log:
More tunning.
http://cvs.php.net/diff.php/livedocs/xml_classes5.php?r1=1.3&r2=1.4&ty=u
Index: livedocs/xml_classes5.php
diff -u livedocs/xml_classes5.php:1.3 livedocs/xml_classes5.php:1.4
--- livedocs/xml_classes5.php:1.3 Tue May 25 15:07:13 2004
+++ livedocs/xml_classes5.php Tue May 25 16:15:03 2004
@@ -19,7 +19,7 @@
// | PHP 5 style |
// +----------------------------------------------------------------------+
//
-// $Id: xml_classes5.php,v 1.3 2004/05/25 19:07:13 iliaa Exp $
+// $Id: xml_classes5.php,v 1.4 2004/05/25 20:15:03 iliaa Exp $
class Node { /* {{{ */
@@ -46,9 +46,10 @@
if ($mapent[0][0] == $this->tagname) {
$n = $this->parent;
$match = true;
- $c = count($mapent[0]);
- for ($i = 1; $i < $c; $i++) {
- if ($n->tagname != $mapent[0][$i]) {
+ foreach ($mapent[0] as $v) {
+ if ($v == $mapent[0][0]) continue;
+
+ if ($n->tagname != $v) {
$match = false;
break;
}
@@ -65,7 +66,7 @@
}
if (isset($this->attributes['id'])) {
- $anchor = sprintf('<a name="%s"></a>',
$this->attributes['id']);
+ $anchor = '<a name="'.$this->attributes['id'].'"></a>';
} else {
$anchor = '';
}
@@ -121,7 +122,7 @@
/* look for children that match */
foreach ($this->children as &$child) {
$x = $this->select_node($child, $id);
- if (is_object($x)) {
+ if (!empty($x)) {
return $x;
}
}
@@ -143,8 +144,7 @@
function set_parent($parent)
{
$this->parent = $parent;
- $this->index = count($parent->children);
- $parent->children[$this->index] = $this;
+ $parent->children[] = $this;
}
function compress()
@@ -213,7 +213,7 @@
function release()
{
foreach ($this->children as &$child) {
- if (is_object($child)) {
+ if (!empty($child)) {
$child->release();
}
$child = null;
@@ -234,16 +234,13 @@
var $current = null;
function __destruct() {
- if (is_object($this->top)) {
+ if (!empty($this->top)) {
$this->top->release();
}
- if (is_object($this->current)) {
+ if (!empty($this->current)) {
$this->current->release();
}
- $this->top = null;
- unset($this->top);
- $this->current = null;
- unset($this->current);
+ unset($this->top, $this->current);
}
function DocBookToHTML($xml, $id = null)
@@ -275,7 +272,7 @@
if ($id !== null) {
$newtop = $this->top->select_node($id);
- if (is_object($newtop)) {
+ if (!empty($newtop)) {
$this->top = $newtop;
$this->top->parent = null;
}
@@ -287,7 +284,7 @@
{
/* pre-parse the map */
- if (!is_object($this->top)) {
+ if (empty($this->top)) {
return "<div class=\"warning\">XML document contained no
data</div>";
}
http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.3&r2=1.4&ty=u
Index: livedocs/livedoc_funcs.php
diff -u livedocs/livedoc_funcs.php:1.3 livedocs/livedoc_funcs.php:1.4
--- livedocs/livedoc_funcs.php:1.3 Tue May 25 15:07:13 2004
+++ livedocs/livedoc_funcs.php Tue May 25 16:15:03 2004
@@ -32,7 +32,7 @@
/* Get parent ID and child IDs */
/* - first we get the first three parts of the path */
$last_item = 'manual';
- if (($r = sqlite_single_query($idx, "SELECT path FROM toc WHERE docbook_id =
'$current_page' LIMIT 1", SQLITE_NUM))) {
+ if (($r = sqlite_single_query($idx, "SELECT path FROM toc WHERE docbook_id =
'$current_page' LIMIT 1"))) {
$path = explode(",", $r);
foreach ($path as $item) {
$nav .= do_nav_line($item, 'up', $current_page, $lang, $dummy);
@@ -253,7 +253,7 @@
function format_user_notes($id)
{
$notes = sqlite_array_query($GLOBALS['NOTESDB'], "SELECT id, xwhen, who, note
from notes where sect='$id' order by xwhen desc");
- if (count($notes) == 0)
+ if (empty($notes))
return '';
$inner = <<<HTML
@@ -325,26 +325,18 @@
$stag = 'function';
$etag = 'function';
- switch (count($parts)) {
- case 4:
- $id = 'function.' . $parts[3];
- $func_name = lookup_title($id);
- break;
-
- case 5:
- if ($parts[3] == 'class') {
- $id = 'class.' . $parts[4];
- $func_name = str_replace('-', '_', $parts[4]);
- $stag = "xref linkend=\"$id\"";
- $etag = "xref";
- break;
- }
- /* fall through */
-
- default:
- /* some weird node type we don't understand */
- $id = $ref;
- $func_name = 'Unknown ??';
+ if (isset($parts[4]) && $parts[3] == 'class') {
+ $id = 'class.' . $parts[4];
+ $func_name = str_replace('-', '_', $parts[4]);
+ $stag = "xref linkend=\"$id\"";
+ $etag = "xref";
+ } else if (isset($parts[3])) {
+ $id = 'function.' . $parts[3];
+ $func_name = lookup_title($id);
+ } else {
+ /* some weird node type we don't understand */
+ $id = $ref;
+ $func_name = 'Unknown ??';
}
if ($parts[3] == 'class') {
http://cvs.php.net/diff.php/livedocs/style_mapping.php?r1=1.16&r2=1.17&ty=u
Index: livedocs/style_mapping.php
diff -u livedocs/style_mapping.php:1.16 livedocs/style_mapping.php:1.17
--- livedocs/style_mapping.php:1.16 Tue May 25 15:07:13 2004
+++ livedocs/style_mapping.php Tue May 25 16:15:03 2004
@@ -18,7 +18,7 @@
// | Helper functions for formatting elements |
// +----------------------------------------------------------------------+
//
-// $Id: style_mapping.php,v 1.16 2004/05/25 19:07:13 iliaa Exp $
+// $Id: style_mapping.php,v 1.17 2004/05/25 20:15:03 iliaa Exp $
// almost XPATH.. ;-)
$map = array(
@@ -365,7 +365,7 @@
/* build up prototype */
$type = $node->children[0]->content;
$fname = $node->children[1]->content;
- if (!strlen(trim($fname))) { // it's a class
+ if (!trim($fname)) { // it's a class
$fname = $node->children[3]->content;
}
$params = "";