allow parent directory, add version selector in home page

This commit is contained in:
Daniel Seifert 2018-07-10 21:57:31 +02:00
parent 416681f8bd
commit e56a30650c
2 changed files with 41 additions and 7 deletions

View File

@ -21,6 +21,40 @@
<?= ($params['author'])? '<div>' . $this->translate("author") . ': ' . $params['author'] . '</div>' : '' ?>
<?= ($params['moduledate'])? '<div>' . $this->translate("moduledate") . ': ' . $params['moduledate'] . '</div>' : '' ?>
<?= ($params['moduleversion'])? '<div>' . $this->translate("version") . ': ' . $params['moduleversion'] . '</div>' : '' ?>
<?php
if ($params['versionselector']) {
echo "<div>";
echo $this->translate("selectversion").': ';
$code = '
<select onchange="window.location.href=this.options[this.selectedIndex].value" size="1">
<?php
$versionpath = implode("/", array_slice(explode("/", $_SERVER[\'SCRIPT_NAME\']), '. $params['versiondirectoryindex'] .'));
$modulepath = implode("/", array_slice(explode("/", $_SERVER[\'SCRIPT_NAME\']), 0, '. $params['versiondirectoryindex'] .'));
$path = str_replace($versionpath, "", $_SERVER[\'SCRIPT_FILENAME\']);
$paths = explode(\'/\', $versionpath);
$currpath = $paths[0];
$dirs = array_filter(glob($path . \'/*\'), \'is_dir\');
arsort($dirs);
foreach ($dirs as $dir) {
$dir = str_replace($path.\'/\', \'\', $dir);
$selected = ($dir === $currpath) ? \'selected="selected"\' : "";
echo \'<option value="\'. $modulepath .\'/\'. $dir .\'" \'. $selected .\'>\'. $dir .\'</option>\';
}
?>
';
echo $code;
echo "</select>";
echo "</div>";
}
?>
<?= ($params['editors'])? '<div>' . $this->translate("editors") . ': ' . $params['editors'] . '</div>' : '' ?>
</div>
</div>

View File

@ -33,18 +33,19 @@
<select onchange="window.location.href=this.options[this.selectedIndex].value" size="1">
<?php
$path = str_replace($_SERVER[\'SCRIPT_NAME\'], "", $_SERVER[\'SCRIPT_FILENAME\']);
$paths = explode(\'/\', $_SERVER[\'SCRIPT_NAME\']);
$currpath = $paths[1];
$versionpath = implode("/", array_slice(explode("/", $_SERVER[\'SCRIPT_NAME\']), '. $params['versiondirectoryindex'] .'));
$modulepath = implode("/", array_slice(explode("/", $_SERVER[\'SCRIPT_NAME\']), 0, '. $params['versiondirectoryindex'] .'));
$path = str_replace($versionpath, "", $_SERVER[\'SCRIPT_FILENAME\']);
$paths = explode(\'/\', $versionpath);
$currpath = $paths[0];
$dirs = array_filter(glob($path . \'/*\'), \'is_dir\');
arsort($dirs);
foreach ($dirs as $dir) {
$dir = str_replace($path.\'/\', \'\', $dir);
$selected = ($dir === $currpath) ? \'selected="selected"\' : "";
echo \'<option value="/\'. $dir .\'" \'. $selected .\'>\'. $dir .\'</option>\';
echo \'<option value="\'. $modulepath .\'/\'. $dir .\'" \'. $selected .\'>\'. $dir .\'</option>\';
}
?>
';
@ -113,4 +114,3 @@
</div>
</div>
</div>