8
0

* multi-language support.

Dieser Commit ist enthalten in:
larukedi 2013-08-23 22:49:08 +03:00
Ursprung f540c54482
Commit ca377311e9
2 geänderte Dateien mit 52 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -66,11 +66,26 @@ software, even if advised of the possibility of such damage.
require_once('libs/functions.php');
$options = get_options();
$tree = get_tree("docs", $base_url);
$homepage_url = homepage_url($tree);
$docs_url = docs_url($tree);
$url_params = url_params();
$page = load_page($tree);
if (count($options['languages']) > 0 && count($url_params) > 0 && strlen($url_params[0]) > 0) {
$language = array_shift($url_params);
$base_path = "docs/" . $language;
} else {
$language = null;
$base_path = "docs";
}
$tree = get_tree($base_path, $base_url, '', true, $language);
if ($language === null) {
$homepage_url = homepage_url($tree);
$docs_url = docs_url($tree);
} else {
$homepage_url = "/";
}
$page = load_page($tree, $url_params);
// If a timezone has been set in the config file, override the default PHP timezone for this application.
if(isset($options['timezone']))
@ -138,7 +153,7 @@ if ($homepage && $homepage_url !== '/') {
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand pull-left" href="<?php echo $base_url ?>/<?php echo $homepage_url;?>"><?php echo $options['title']; ?></a>
<a class="brand pull-left" href="<?php echo $base_url ?><?php echo $homepage_url;?>"><?php echo $options['title']; ?></a>
<p class="navbar-text pull-right">
Generated by <a href="http://daux.io">Daux.io</a>
</p>
@ -174,9 +189,17 @@ if ($homepage && $homepage_url !== '/') {
View On GitHub
</a>
<?php } ?>
<?php if (count($options['languages']) > 0) { ?>
<?php foreach ($options['languages'] as $language_key => $language_name) { ?>
<a href="<?php echo $base_url . "/" . $language_key . "/"; ?>" class="btn btn-primary btn-hero">
<?php echo $language_name; ?>
</a>
<?php } ?>
<?php } else { ?>
<a href="<?php echo $docs_url;?>" class="btn btn-primary btn-hero">
View Documentation
</a>
<?php } ?>
</div>
</div>
</div>
@ -246,7 +269,7 @@ if ($homepage && $homepage_url !== '/') {
</div>
<div id="sub-nav-collapse" class="sub-nav-collapse">
<!-- Navigation -->
<?php echo build_nav($tree); ?>
<?php echo build_nav($tree, $url_params); ?>
<?php if (!empty($options['links']) || !empty($options['twitter'])) { ?>
<div class="well well-sidebar">

Datei anzeigen

@ -44,7 +44,8 @@ function get_options() {
'clean_urls' => true,
'google_analytics' => false,
'piwik_analytics' => false,
'ignore' => array()
'ignore' => array(),
'languages' => array()
);
// Load User Config
@ -75,7 +76,7 @@ function homepage_url($tree) {
if (isset($tree['index'])) {
return '/';
} else {
return docs_url($tree);
return docs_url($tree, false);
}
}
@ -101,8 +102,12 @@ function docs_url($tree, $branch = false) {
}
}
function load_page($tree) {
$branch = find_branch($tree);
function load_page($tree, $url_params) {
if (count($url_params) > 0) {
$branch = find_branch($tree, $url_params);
} else {
$branch = current($tree);
}
$page = array();
@ -129,9 +134,8 @@ function load_page($tree) {
return $page;
}
function find_branch($tree) {
$path = url_params();
foreach($path as $peice) {
function find_branch($tree, $url_params) {
foreach($url_params as $peice) {
// Check for homepage
if (empty($peice)) {
$peice = 'index';
@ -182,13 +186,10 @@ function clean_name($text) {
return $text;
}
function build_nav($tree, $url_params = false) {
function build_nav($tree, $url_params) {
// Remove Index
unset($tree['index']);
if (!is_array($url_params)) {
$url_params = url_params();
}
$url_path = url_path();
$html = '<ul class="nav nav-list">';
foreach($tree as $key => $val) {
@ -244,7 +245,7 @@ function get_ignored() {
return $all_ignored;
}
function get_tree($path = '.', $clean_path = '', $title = '', $first = true){
function get_tree($path = '.', $clean_path = '', $title = '', $first = true, $language = null){
$options = get_options();
$tree = array();
$ignore = get_ignored();
@ -262,6 +263,12 @@ function get_tree($path = '.', $clean_path = '', $title = '', $first = true){
// Sort paths
sort($paths);
if ($first && $language !== null) {
$language_path = $language . "/";
} else {
$language_path = "";
}
// Loop through the paths
// while(false !== ($file = readdir($dh))){
@ -277,16 +284,16 @@ function get_tree($path = '.', $clean_path = '', $title = '', $first = true){
{
if($first)
{
$url = $clean_path . '/index.php/' . $clean_sort;
$url = $clean_path . '/' . $language_path . 'index.php/' . $clean_sort;
}
else
{
$url = $clean_path . '/' . $clean_sort;
$url = $clean_path . '/' . $language_path . $clean_sort;
}
}
else
{
$url = $clean_path . '/' . $clean_sort;
$url = $clean_path . '/' . $language_path . $clean_sort;
}
$clean_name = clean_name($clean_sort);
@ -307,7 +314,7 @@ function get_tree($path = '.', $clean_path = '', $title = '', $first = true){
'path' => $full_path,
'clean' => $clean_sort,
'url' => $url,
'tree'=> get_tree($full_path, $url, $full_title, false)
'tree'=> get_tree($full_path, $url, $full_title, false, $language)
);
} else {
// File