47 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| namespace nur\v;
 | |
| 
 | |
| /**
 | |
|  * Class nb: composants pour navbar
 | |
|  */
 | |
| class nb {
 | |
|   static final function brand($brand, ?array $options=null): array {
 | |
|     $item = ["item" => "brand", "value" => $brand];
 | |
|     if ($options !== null) $item = array_merge($item, $options);
 | |
|     return $item;
 | |
|   }
 | |
| 
 | |
|   static final function text($text, ?array $options=null): array {
 | |
|     $item = ["item" => "text", "value" => $text];
 | |
|     if ($options !== null) $item = array_merge($item, $options);
 | |
|     return $item;
 | |
|   }
 | |
| 
 | |
|   static final function link($url, $link=null, ?array $options=null): array {
 | |
|     if ($link === null) $link = $url;
 | |
|     $item = ["item" => "link", "url" => $url, "value" => $link];
 | |
|     if ($options !== null) $item = array_merge($item, $options);
 | |
|     return $item;
 | |
|   }
 | |
| 
 | |
|   static final function button($url, $button=null, ?array $options=null): array {
 | |
|     if ($button === null) $button = $url;
 | |
|     $item = ["item" => "button", "url" => $url, "value" => $button];
 | |
|     if ($options !== null) $item = array_merge($item, $options);
 | |
|     return $item;
 | |
|   }
 | |
| 
 | |
|   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;
 | |
|   }
 | |
| 
 | |
|   static final function literal($literal, ?array $options=null): array {
 | |
|     $item = ["item" => "literal", "value" => $literal];
 | |
|     if ($options !== null) $item = array_merge($item, $options);
 | |
|     return $item;
 | |
|   }
 | |
| }
 |