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.
151 lines
4.6 KiB
PHP
151 lines
4.6 KiB
PHP
<?php
|
|
require_once "$PROJECT_ROOT/php/utils/utils.php";
|
|
require_once "$PROJECT_ROOT/php/utils/servers-rooms.php";
|
|
|
|
/**
|
|
* @var CommunityRoom[] $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 displayed requires updating
|
|
// the --expanded-static-column-width and --collapsed-static-column-width CSS variables.
|
|
|
|
$TABLE_COLUMNS = [
|
|
['id' => "identifier", 'name' => "Identifier", 'name_long' => "Room identifier"],
|
|
['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']?>">
|
|
<?=$column['name']?>
|
|
|
|
</th>
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
<?php foreach ($rooms as $id => $room): ?>
|
|
<?php
|
|
$pubkey = $room->server->get_pubkey();
|
|
$icon_hue = hexdec($pubkey[2] . $pubkey[2]);
|
|
$icon_color = "hsl($icon_hue, 80%, 50%)";
|
|
|
|
$hostname = $room->server->get_base_url();
|
|
|
|
$id = html_sanitize($room->get_room_identifier());
|
|
$language = html_sanitize($room->language_flag);
|
|
$name = html_sanitize($room->name);
|
|
$desc = html_sanitize($room->description);
|
|
$users = html_sanitize($room->active_users);
|
|
$users_cutoff = html_sanitize($room->format_user_cutoff_period());
|
|
$preview_link = html_sanitize($room->get_preview_url());
|
|
$join_link = html_sanitize($room->get_join_url());
|
|
$pubkey = html_sanitize($pubkey);
|
|
$hostname = html_sanitize($hostname);
|
|
?>
|
|
|
|
<tr id="<?=$id?>" itemscope itemtype="https://schema.org/EntryPoint"
|
|
data-identifier="<?=$id?>"
|
|
data-pubkey="<?=$pubkey?>"
|
|
data-hostname="<?=$hostname?>"
|
|
>
|
|
<td class="td_identifier" itemprop="identifier"><?=$id?></td>
|
|
<td class="td_language" title="Language flag for '<?=$name?>'"><?=$language?></td>
|
|
<td class="td_name"
|
|
data-sort-by="<?=strtolower($name)?>"
|
|
>
|
|
<a
|
|
href="<?=$preview_link?>"
|
|
target="_blank"
|
|
title="Click here to preview '<?=$name?>'"
|
|
rel="noopener noreferrer"
|
|
itemprop="name"
|
|
><?=
|
|
$name
|
|
?></a>
|
|
<span class="room-labels-container">
|
|
<?php foreach ($room->get_room_tags() as $tag): ?>
|
|
<span
|
|
class="room-label <?=$tag->get_tag_classname()?> badge"
|
|
title="<?=$tag->description?>"
|
|
><?=
|
|
truncate($tag->text, 16)
|
|
?></span>
|
|
<?php endforeach; ?>
|
|
</span>
|
|
</td>
|
|
<td
|
|
class="td_description"
|
|
title="Description for '<?=$name?>':
|
|
|
|
<?=$desc?>"
|
|
itemprop="description"
|
|
><?=$desc?></td>
|
|
<td
|
|
class="td_users"
|
|
title="'<?=$name?>' has had <?=$users?> active users in the last <?=$users_cutoff?>."
|
|
><?=$users?></td>
|
|
<td class="td_preview" itemprop="url">
|
|
<a
|
|
href="<?=$preview_link?>"
|
|
title="Click here to preview '<?=$name?>'"
|
|
target="_blank"
|
|
rel="noopener noreferrer nofollow"
|
|
>
|
|
<span class="protocol-indicator"></span>
|
|
</a>
|
|
</td>
|
|
<td class="td_qr_code">
|
|
<img
|
|
class="qr-code-icon"
|
|
src="qrcode-solid.svg"
|
|
alt="Pictogram of a QR code"
|
|
title="Click here to view the QR Code for '<?=$name?>'"
|
|
>
|
|
</td>
|
|
<td class="td_server_icon"
|
|
data-sort-by="<?=$pubkey?>"
|
|
title="Host: <?=$hostname?> (<?=$pubkey?>)"
|
|
item="image"
|
|
>
|
|
<div class="td_server_icon-circle" style="background-color: <?=$icon_color?>">
|
|
<span><?=strtoupper($pubkey[0] . $pubkey[1])?></span>
|
|
</div>
|
|
</td>
|
|
<td class="td_join_url">
|
|
<div class="join_url_container" data-url="<?=$join_link?>">
|
|
<a class="join_url show-from-w5" title="<?=$join_link?>"
|
|
><?=truncate($join_link, 32)?></a>
|
|
<a
|
|
class="noscript"
|
|
title="Copy this link to join '<?=$name?>'."
|
|
href="<?=$join_link?>"
|
|
rel="external nofollow"
|
|
>Copy link</a>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</table>
|