2014-02-27 18:30:40 +01:00
|
|
|
<?php
|
|
|
|
// Generate Page
|
|
|
|
function generate_live($page) {
|
|
|
|
global $options, $multilanguage, $output_language, $base, $base_path, $mode;
|
|
|
|
$mode = 'Live';
|
|
|
|
if ($multilanguage) {
|
|
|
|
$b = explode('/', clean_url($page, "Live"));
|
|
|
|
$output_language = $b[0];
|
|
|
|
}
|
2014-03-04 12:58:20 +01:00
|
|
|
$file = clean_url_to_file($page);
|
2014-06-11 19:21:07 +02:00
|
|
|
if (!is_file($file)) $file = FALSE;
|
|
|
|
return generate_page($file);
|
2014-02-27 18:30:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clean Live Url
|
|
|
|
function clean_live($url) {
|
|
|
|
return clean_url($url, "Live");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Retrieve File From Clean URL
|
|
|
|
function clean_url_to_file($url) {
|
|
|
|
global $tree, $docs_path;
|
|
|
|
$location = getfile($tree, $url, $docs_path);
|
|
|
|
return $location;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get File from $url
|
|
|
|
function getfile($tree, $url, $current_dir, $flag = FALSE) {
|
|
|
|
global $docs_path, $base_doc, $options;
|
2014-06-27 00:00:38 +02:00
|
|
|
$url = clean_url($url, "Live", true);
|
2014-07-01 17:22:03 +02:00
|
|
|
if ($options['clean_urls'] == true) $url = explode("?", $url)[0];
|
2014-02-27 18:30:40 +01:00
|
|
|
if ($url === '' || $url === 'index') {
|
|
|
|
if (is_file($docs_path . "/index.md")) return $docs_path . "/index.md";
|
|
|
|
else {
|
|
|
|
if (empty($options['languages'])) return $base_doc;
|
2014-03-04 12:36:29 +01:00
|
|
|
else {
|
2014-06-11 19:21:07 +02:00
|
|
|
$t = array_keys($base_doc);
|
|
|
|
return $base_doc[$t[0]];
|
2014-03-04 12:36:29 +01:00
|
|
|
}
|
2014-02-27 18:30:40 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$url = explode("/", $url);
|
|
|
|
$file = $docs_path;
|
|
|
|
foreach ($url as $part) {
|
2014-03-04 12:58:20 +01:00
|
|
|
if (isset($tree)) {
|
|
|
|
$dirs = array_keys($tree);
|
|
|
|
$key = array_search($part, array_map("clean_live", $dirs));
|
|
|
|
} else $key = FALSE;
|
2014-02-27 18:30:40 +01:00
|
|
|
if ($key === FALSE) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
$file .= '/' . $dirs[$key];
|
|
|
|
$tree = $tree[$dirs[$key]];
|
|
|
|
}
|
2014-04-09 23:23:23 +02:00
|
|
|
if (is_file($file . "/index.md")) $file = $file . "/index.md";
|
2014-02-27 18:30:40 +01:00
|
|
|
return $file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|