1
0
mirror of synced 2024-12-13 22:56:04 +03:00
doctrine2/manual/documentation2.php

155 lines
3.8 KiB
PHP
Raw Normal View History

2007-02-19 23:00:40 +03:00
<?php
include("top.php");
require_once("highlight.php");
2007-02-23 22:41:42 +03:00
error_reporting(E_ALL);
2007-02-25 22:30:29 +03:00
set_include_path(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'vendor/');
2007-02-23 22:41:42 +03:00
2007-02-19 23:00:40 +03:00
$f = file_get_contents('menu.php');
$a = explode(PHP_EOL, $f);
$res = array();
$curr = false;
2007-02-23 22:41:42 +03:00
require_once('Text/Wiki.php');
2007-02-25 22:37:19 +03:00
require_once('Text/Wiki/Mediawiki.php');
2007-02-23 22:41:42 +03:00
2007-02-19 23:00:40 +03:00
class DocTool
{
private $index;
protected $highlighter;
2007-02-23 22:41:42 +03:00
protected $wiki;
2007-02-19 23:00:40 +03:00
public function __construct()
{
$this->highlighter = new PHP_Highlight;
2007-02-23 22:41:42 +03:00
$this->wiki = new Text_Wiki;
2007-02-19 23:00:40 +03:00
}
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;
}
2007-02-25 22:34:29 +03:00
public function renderBlock($name)
{
2007-02-19 23:00:40 +03:00
2007-02-25 22:34:29 +03:00
if (file_exists("docs/$name.php")) {
2007-02-19 23:00:40 +03:00
$c = file_get_contents("docs/$name.php");
2007-02-25 22:34:29 +03:00
if (substr($c, 0, 5) == "<?php") {
2007-02-19 23:00:40 +03:00
include("docs/$name.php");
2007-02-25 22:36:21 +03:00
} elseif (strpos($c, '<br \>') !== false ||
2007-03-02 01:41:41 +03:00
strpos($c, '<br />') !== false ||
2007-02-25 22:40:55 +03:00
strpos($c, '<ul>') !== false ||
strpos($c, '<p>') !== false) {
2007-02-25 22:34:29 +03:00
print $c;
2007-02-19 23:00:40 +03:00
} else {
2007-02-23 22:41:42 +03:00
print $this->wiki->transform($c) . "<br><br>";
2007-02-19 23:00:40 +03:00
}
}
2007-02-25 22:34:29 +03:00
if (file_exists("codes/$name.php")) {
2007-02-19 23:00:40 +03:00
$c = file_get_contents("codes/$name.php");
$c = trim($c);
$this->renderCode($c);
}
}
2007-02-25 22:34:29 +03:00
public function renderCode($code = null)
{
2007-02-19 23:00:40 +03:00
if( ! empty($code)) {
$this->highlighter->loadString($code);
2007-02-21 22:46:47 +03:00
print "<table border=1 class='dashed' cellpadding=0 cellspacing=0>";
2007-02-19 23:00:40 +03:00
print "<tr><td><b>";
$this->highlighter->toHtml();
print "</b></td></tr>";
print "</table>";
}
}
}
print "<pre>";
$doc = new DocTool();
function renderCode($code = null)
{
global $doc;
return $doc->renderCode($code);
}
$i = $doc->parseIndex2($a);
//print_r($i);
?>
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
<td width=50>
<td>
<td align="left" valign="top">
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
2007-02-21 22:46:47 +03:00
<td colspan=3 bgcolor="white">
2007-02-19 23:00:40 +03:00
<img src="images/logo.jpg" align="left"><b class="title">Doctrine - PHP Data Persistence and ORM Tool</b>
<hr>
</td>
</tr>
<tr>
<td bgcolor="white" valign="top">
<?php
2007-02-21 22:46:47 +03:00
include('content.php');
2007-02-19 23:00:40 +03:00
?>
</td>
</tr>
</td>
<td>
</td>
</tr>
</table>