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 { | ||||
|     $links = array_filter($links, function($link) { return $link !== null; }); | ||||
|     $item = ["item" => "menu", "links" => $links, "value" => $text]; | ||||
|     if ($options !== null) $item = array_merge($item, $options); | ||||
|     return $item; | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| <?php | ||||
| namespace nur\v\vp; | ||||
| 
 | ||||
| use nulib\app; | ||||
| use nur\authz; | ||||
| use nur\b\authnz\IAuthzUser; | ||||
| use nur\config; | ||||
| @ -46,6 +47,21 @@ class NavigablePage extends AInitAuthzPage implements INavigablePage { | ||||
| 
 | ||||
|   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 { | ||||
|     $username = $user->getUsername(); | ||||
|     $role = $user->getRole(); | ||||
| @ -95,6 +111,7 @@ class NavigablePage extends AInitAuthzPage implements INavigablePage { | ||||
|       $user = authz::get(); | ||||
|       navbar::nav(["align" => "right"], [ | ||||
|         nb::menu(icon::user($user->getShortName()), [ | ||||
|           $this->getAppVersionNbtext(), | ||||
|           $this->getAuthzNbtext($user), | ||||
|           $this->getLogoutNblink(), | ||||
|         ]), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user