You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
<?php
 | 
						|
	require_once '+components/table/table-fragment.php';
 | 
						|
 | 
						|
	/**
 | 
						|
	 * @param CommunityRoom[] $rooms
 | 
						|
	 */
 | 
						|
	function renderCommunityRoomTable(array $rooms) {
 | 
						|
 | 
						|
		// Once handlers are attached in JS, this check ceases to be useful.
 | 
						|
		function column_sortable($id) {
 | 
						|
			// Join URL contents are not guaranteed to have visible text.
 | 
						|
			return $id != "qr_code" && $id != "preview" && $id != "join_url";
 | 
						|
		}
 | 
						|
 | 
						|
		function sort_onclick($colno) {
 | 
						|
			global $TABLE_COLUMNS;
 | 
						|
			$column = $TABLE_COLUMNS[$colno];
 | 
						|
			$name = isset($column['name_long']) ? $column['name_long'] : $column['name'];
 | 
						|
			if (!column_sortable($column['id'])) return " title='$name'";
 | 
						|
			return " title='Click to sort by $name.'";
 | 
						|
		}
 | 
						|
 | 
						|
		// Note: Changing the names or columns displayed requires updating
 | 
						|
		// the --expanded-static-column-width and --collapsed-static-column-width CSS variables.
 | 
						|
 | 
						|
		$TABLE_COLUMNS = [
 | 
						|
			['id' => "language", 'name' => "L", 'name_long' => "Language"],
 | 
						|
			['id' => "name", 'name' => "Name"],
 | 
						|
			['id' => "description", 'name' => "About", 'name_long' => "Description"],
 | 
						|
			['id' => "users", 'name' => "#", 'name_long' => "Active Users"],
 | 
						|
			['id' => "preview", 'name' => "Preview"],
 | 
						|
			['id' => "qr_code", 'name' => "QR", 'name_long' => "QR Code (for use in-app)"],
 | 
						|
			['id' => "server_icon", 'name' => "Host", 'name_long' => "Server host"],
 | 
						|
			['id' => "join_url", 'name' => "URL", 'name_long' => "Join URL (for use in-app)"],
 | 
						|
		];
 | 
						|
	?>
 | 
						|
 | 
						|
	<table id="tbl_communities">
 | 
						|
		<tr>
 | 
						|
<?php foreach ($TABLE_COLUMNS as $colno => $column): ?>
 | 
						|
			<th<?=sort_onclick($colno)?> id="th_<?=$column['id']?>" class="tbl_communities__th">
 | 
						|
				<?=$column['name']?>
 | 
						|
 | 
						|
			</th>
 | 
						|
<?php endforeach; ?>
 | 
						|
		</tr>
 | 
						|
<?php renderCommunityRoomTableFragment($rooms); ?>
 | 
						|
	</table>
 | 
						|
<?php
 | 
						|
}
 | 
						|
?>
 |