2007-06-13 02:18:21 +04:00
|
|
|
<?php
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
2007-07-20 12:03:04 +04:00
|
|
|
$includePath = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'vendor'
|
|
|
|
. PATH_SEPARATOR . dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lib';
|
2007-06-13 02:18:21 +04:00
|
|
|
|
|
|
|
set_include_path($includePath);
|
|
|
|
|
|
|
|
require_once('Sensei/Sensei.php');
|
|
|
|
require_once('DocTool.php');
|
2007-07-09 00:38:32 +04:00
|
|
|
require_once('Cache.php');
|
2007-06-13 02:18:21 +04:00
|
|
|
|
|
|
|
spl_autoload_register(array('Sensei', 'autoload'));
|
|
|
|
|
2007-07-09 13:24:05 +04:00
|
|
|
// Executes the 'svn info' command for the current directory and parses the last
|
|
|
|
// changed revision.
|
|
|
|
$revision = 0;
|
2007-07-09 00:38:32 +04:00
|
|
|
exec('svn info .', $output);
|
|
|
|
foreach ($output as $line) {
|
2007-07-09 13:24:05 +04:00
|
|
|
if (preg_match('/^Last Changed Rev: ([0-9]+)$/', $line, $matches)) {
|
|
|
|
$revision = $matches[1];
|
2007-07-09 00:38:32 +04:00
|
|
|
break;
|
|
|
|
}
|
2007-06-13 02:18:21 +04:00
|
|
|
}
|
|
|
|
|
2007-07-09 13:24:05 +04:00
|
|
|
$cacheDir = './cache/';
|
|
|
|
$cacheRevFile = $cacheDir . 'revision.txt';
|
|
|
|
$cacheRev = 0;
|
|
|
|
|
|
|
|
$cache = new Cache($cacheDir, 'cache');
|
|
|
|
|
|
|
|
// Checks the revision cache files were created from
|
|
|
|
if (file_exists($cacheRevFile)) {
|
|
|
|
$cacheRev = (int) file_get_contents($cacheRevFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Empties the cache directory and saves the current revision to a file, if SVN
|
|
|
|
// revision is greater than cache revision
|
|
|
|
if ($revision > $cacheRev) {
|
|
|
|
$cache->clear();
|
|
|
|
@file_put_contents($cacheRevFile, $revision);
|
|
|
|
}
|
|
|
|
|
2007-06-13 02:18:21 +04:00
|
|
|
|
2007-07-09 00:38:32 +04:00
|
|
|
if ($cache->begin()) {
|
2007-06-13 02:18:21 +04:00
|
|
|
|
2007-07-09 14:29:20 +04:00
|
|
|
$tool = new DocTool('docs/en.txt');
|
2007-07-09 00:38:32 +04:00
|
|
|
// $tool->setOption('clean-url', true);
|
|
|
|
|
2007-06-13 02:18:21 +04:00
|
|
|
$baseUrl = '';
|
2007-07-09 00:38:32 +04:00
|
|
|
$title = 'Doctrine Manual';
|
|
|
|
$section = null;
|
|
|
|
|
|
|
|
if (isset($_GET['chapter'])) {
|
|
|
|
$section = $tool->findByPath($_GET['chapter']);
|
|
|
|
if ($tool->getOption('clean-url')) {
|
|
|
|
$baseUrl = '../';
|
|
|
|
}
|
2007-06-13 02:18:21 +04:00
|
|
|
}
|
2007-07-09 00:38:32 +04:00
|
|
|
|
|
|
|
if (isset($_GET['one-page'])) {
|
|
|
|
$tool->setOption('one-page', true);
|
|
|
|
$tool->setOption('max-level', 0);
|
|
|
|
$section = null;
|
|
|
|
$baseUrl = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($section) {
|
|
|
|
while ($section->getLevel() > 1) {
|
|
|
|
$section = $section->getParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
$tool->setOption('section', $section);
|
|
|
|
$title .= ' - Chapter ' . $section->getIndex() . ' ' . $section->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($tool->getOption('clean-url')) {
|
|
|
|
$tool->setOption('base-url', $baseUrl);
|
|
|
|
}
|
|
|
|
|
|
|
|
include 'template.php';
|
|
|
|
|
|
|
|
$cache->end();
|
2007-06-13 02:18:21 +04:00
|
|
|
}
|