8
0
daux.io/libs/live.php

59 Zeilen
1.9 KiB
PHP

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];
}
$file = clean_url_to_file($page);
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;
$url = clean_url($url, "Live");
if ($url === '' || $url === 'index') {
if (is_file($docs_path . "/index.md")) return $docs_path . "/index.md";
else {
if (empty($options['languages'])) return $base_doc;
else {
$t = array_keys($base_doc);
return $base_doc[$t[0]];
}
2014-02-27 18:30:40 +01:00
}
} else {
$url = explode("/", $url);
$file = $docs_path;
foreach ($url as $part) {
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;
}
}
?>