highlighter = new PHP_Highlight;
$this->wiki = new Text_Wiki;
}
public function parseIndex2($index)
{
$ret = array();
$path = array();
$counters = array();
foreach ($index as $k => $v) {
if (empty($v)) {
continue;
}
$v = rtrim($v);
$i = count($path) - 1;
$i = ($i > 0) ? $i : 0;
$indent = substr_count($v, ' ');
if ( ! isset($counters[$indent])) {
$counters[$indent] = 0;
}
if ($indent > $i) {
$counters[$indent]++;
$path[] = trim($v);
} else {
$steps = abs($i - $indent);
$key = ($i - $steps);
while ($steps--) {
array_pop($path);
array_pop($counters);
}
$counters[$key]++;
$path[$key] = trim($v);
}
$chapterName = implode(' - ', $path);
$ret[] = array('index' => implode('.', $counters),
'name' => $chapterName);
}
return $ret;
}
public function renderBlock($name) {
if(file_exists("docs/$name.php")) {
$c = file_get_contents("docs/$name.php");
if(substr($c, 0, 5) == "wiki->transform($c) . "
";
}
}
if(file_exists("codes/$name.php")) {
$c = file_get_contents("codes/$name.php");
$c = trim($c);
$this->renderCode($c);
}
}
public function renderCode($code = null) {
if( ! empty($code)) {
$this->highlighter->loadString($code);
print "
";
print "";
$this->highlighter->toHtml();
print " |
";
print "
";
}
}
}
print "";
$doc = new DocTool();
function renderCode($code = null)
{
global $doc;
return $doc->renderCode($code);
}
$i = $doc->parseIndex2($a);
//print_r($i);
?>
|
|
Doctrine - PHP Data Persistence and ORM Tool
|
|
|
|