". htmlspecialchars($matches[2], ENT_NOQUOTES) ."\n";
$mode = 41;
} elseif (preg_match($begins_code, $line)) {
$result .= "";
$mode = 40;
} else {
$len = strlen($line);
if (($len < 40) && ($line[$len-1] == ':') && (!strpos($line, '.'))) {
$result .= "\n". htmlspecialchars(substr($line, 0, strlen($line)-1), ENT_NOQUOTES) ."
\n";
} else {
$tmp .= $line . ' ';
$mode = 10;
};
};
};
break;
case 10 :
if ($line != '') {
$tmp .= $line . ' ';
} else {
$tmp = rtrim($tmp);
$len = strlen($tmp);
if (($len < 40) && ($tmp[strlen($tmp)-1] == ':') && (!strpos($tmp, '.'))) {
$result .= "\n". htmlspecialchars(substr($tmp, 0, strlen($tmp)-1), ENT_NOQUOTES) ."
\n";
} else {
$result .= "" . $this->_inlineXHTML($tmp, $parent) . "
\n";
};
$tmp = '';
$mode = 0;
};
break;
case 21 :
if ($line != '') {
if (preg_match($is_dtdd, $line, $matches)) {
$result .= $this->_inlineXHTML($tmp, $parent) . "" . $this->_inlineXHTML($tmp, $parent) . "
\n"; }; break; case 21 : $result .= $this->_inlineXHTML($tmp, $parent) . "\n\n\n"; break; case 31 : $result .= $this->_inlineXHTML($tmp, $parent) . "\n\n"; break; case 40 : case 41 : $result .= "\n"; break; default : // 0 or unknown = do nothing break; }; return($result); } // Method: parseFile // // Load a file from disk into this instance. Internally, this is a // wrapper around"; print_r($structure); echo "\n"; exit(); $this->source = array(); $lastClass = ''; foreach ($structure as $block) { if ($next = $block[$idxComment]) { // Parse special first line // CAUTION: Not using our NDlite_kwd regex here: we're at the // first line of a comment block, which must start in this // format. If something goes wrong, we fall in $valid=false // safely. preg_match("/[ \t]*((private)[ \t]?)?([^ :]+):[ \t]*([^ \t].*)/i",$next[0],$headers); array_shift($next); while ((count($next) > 0) && ($next[0] == '')) array_shift($next); $private = false; if ($headers[2] == 'Private' || $headers[2] == 'private') $private = true; $parent = ''; $valid = true; $kwd_type = NDLITE_K_GENERIC; // CAUTION: Using class, not group, to determine parents. if (preg_match("/^(${NDlite_kwd_class})\$/i", $headers[3])) { $lastClass = htmlspecialchars($headers[4]); $kwd_type = NDLITE_K_GROUP; } elseif (preg_match("/^(${NDlite_kwd_group})\$/i", $headers[3])) { $parent = $lastClass; $kwd_type = NDLITE_K_GROUP; } elseif (preg_match("/^(${NDlite_kwd_child})\$/i", $headers[3])) { $parent = $lastClass; $kwd_type = NDLITE_K_CHILD; } elseif (!preg_match("/^(${NDlite_kwd_generic})\$/i", $headers[3])) { $valid = false; // echo "DEBUG IGNORING: '${headers[3]}'\n"; }; if ($valid) array_push($this->source, array( 'private' => $private, 'type' => $headers[3], 'NDtype' => $kwd_type, 'id' => htmlspecialchars($headers[4]), 'parent' => $parent, 'lines' => $next, 'code' => trim($block[$idxCode]) )); }; }; // First block gets special treatment. $this->intro = array_shift($this->source); return(true); } // Method: guessTitle // // Guess the title of this instance. Only useful after parsing some // source. // // Parameters: // fallback - Alternative if no suitable candidate is found. (Optional.) // // Returns: // The first of "File", "Title", "Class" or "Group" title found, or your // fallback if none is found, or false if no fallback is provided. // function guessTitle($fallback = false) { $result = $fallback; if ($this->intro['NDtype'] == NDLITE_K_GROUP) { $result = $this->intro['id']; } else { foreach ($this->source as $block) { if ($block['NDtype'] == NDLITE_K_GROUP) { $result = $block['id']; break; }; }; }; return($result); } // Private Method: _linesToAbstract // // Extract the first sentence or paragraph from an array of lines. Used // for summary in
" . $this->intro['code'] . "\n\n";
// };
$result .= $this->_linesToXHTML($this->intro['lines'], $this->intro['parent']);
// Table of contents
if ($flag_summary) {
$result .= "\n" . $block['code'] . "\n\n";
};
};
$result .= $this->_linesToXHTML($block['lines'], $block['parent']);
};
return($result);
}
}
?>