afficher la version de l'application
This commit is contained in:
parent
2a92a9a07e
commit
c4e02d5bcf
@ -32,6 +32,7 @@ class nb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static final function menu($text, ?array $links=null, ?array $options=null): array {
|
static final function menu($text, ?array $links=null, ?array $options=null): array {
|
||||||
|
$links = array_filter($links, function($link) { return $link !== null; });
|
||||||
$item = ["item" => "menu", "links" => $links, "value" => $text];
|
$item = ["item" => "menu", "links" => $links, "value" => $text];
|
||||||
if ($options !== null) $item = array_merge($item, $options);
|
if ($options !== null) $item = array_merge($item, $options);
|
||||||
return $item;
|
return $item;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace nur\v\vp;
|
namespace nur\v\vp;
|
||||||
|
|
||||||
|
use nulib\app;
|
||||||
use nur\authz;
|
use nur\authz;
|
||||||
use nur\b\authnz\IAuthzUser;
|
use nur\b\authnz\IAuthzUser;
|
||||||
use nur\config;
|
use nur\config;
|
||||||
@ -46,6 +47,21 @@ class NavigablePage extends AInitAuthzPage implements INavigablePage {
|
|||||||
|
|
||||||
const MENU_SULOGIN = true;
|
const MENU_SULOGIN = true;
|
||||||
|
|
||||||
|
protected function getAppVersionNbtext(): ?array {
|
||||||
|
$app = app::get();
|
||||||
|
$projdir = $app->getProjdir();
|
||||||
|
$versionfile = "$projdir/VERSION.txt";
|
||||||
|
if (file_exists($versionfile)) {
|
||||||
|
$name = $app->getName();
|
||||||
|
$version = file_get_contents($versionfile);
|
||||||
|
return nb::text([
|
||||||
|
"style" => "margin: 0 15px",
|
||||||
|
"$name v$version"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getAuthzNbtext(IAuthzUser $user): array {
|
protected function getAuthzNbtext(IAuthzUser $user): array {
|
||||||
$username = $user->getUsername();
|
$username = $user->getUsername();
|
||||||
$role = $user->getRole();
|
$role = $user->getRole();
|
||||||
@ -95,6 +111,7 @@ class NavigablePage extends AInitAuthzPage implements INavigablePage {
|
|||||||
$user = authz::get();
|
$user = authz::get();
|
||||||
navbar::nav(["align" => "right"], [
|
navbar::nav(["align" => "right"], [
|
||||||
nb::menu(icon::user($user->getShortName()), [
|
nb::menu(icon::user($user->getShortName()), [
|
||||||
|
$this->getAppVersionNbtext(),
|
||||||
$this->getAuthzNbtext($user),
|
$this->getAuthzNbtext($user),
|
||||||
$this->getLogoutNblink(),
|
$this->getLogoutNblink(),
|
||||||
]),
|
]),
|
||||||
|
Loading…
Reference in New Issue
Block a user