highlighter = new PHP_Highlight; } 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; } /** if ($indent == $i) { $path[$i] = $v; } else { */ public function parseIndex($index, $path = array(), $counters = array()) { $ret = array(); foreach ($index as $k => $v) { $i = count($path) - 1; $counters[$i]++; if (is_array($v)) { if ( ! is_numeric($k)) { $tmp = $path; $tmp[] = $k; $chapterName = ( ! empty($path)) ? implode(' - ', $path) . ' - ' . $k : $k; $ret[] = array('index' => implode('.', $counters), 'name' => $chapterName); } $ret = array_merge($ret, $this->parseIndex($v, $tmp, $counters)); } else { $chapterName = ( ! empty($path)) ? implode(' - ', $path) . ' - ' . $v : $v; $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) == "
"; } } 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 ""; print "
"; $this->highlighter->toHtml(); 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
$v) { $indexes = explode('.', $v['index']); $level = count($indexes); $e = explode(' - ', $v['name']); print '
 '. $v['index'] . '. " . end($e) ."
"; } } else { $e = explode(' - ', $_GET['chapter']); $subchapters = false; $found = false; foreach ($i as $k => $v) { if ($found) { if (strncmp($v['name'], $_GET['chapter'], strlen($_GET['chapter'])) === 0) { $subchapters = true; } break; } $parts = explode(' - ', $v['name']); $indexes = explode('.', $v['index']); if ($v['name'] === $_GET['chapter']) { $prev = $i[($k - 1)]; $next = $i[($k + 1)]; $foundKey = ($k + 1); $found = $v; } } ?>
>Prev >Next
 

Table of contents
' . implode(' - ', $p); ?>

renderBlock($found['name']); } ?>