1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
$em_dir = SRCDIR . "/static/emoticons";
$emoticons = array_map(
fn($i) => [
pathinfo($i, PATHINFO_FILENAME),
getimagesize($em_dir . "/" . $i)["3"]
],
array_values(
array_filter(
scandir($em_dir),
fn($i) =>
$i[0] !== "." &&
is_file($em_dir . "/" . $i) &&
strtolower(pathinfo($i, PATHINFO_EXTENSION)) === "gif"
)
)
);
usort($emoticons, fn($a, $b) => strlen($b[0]) <=> strlen($a[0]));
$emoticons_alpha_lookup = [];
foreach ($emoticons as $i => $emoticon) {
$emoticons_alpha_lookup []= [$i, $emoticon[0]];
}
usort($emoticons_alpha_lookup, fn($a, $b) => $a[1] <=> $b[1]);
$emoticons_alpha_lookup = array_column($emoticons_alpha_lookup, 0);
return [
"emoticons.js",
"/* auto-generated at " . date("c") . " */\nvar EMOTICONS = " .
json_encode([
$emoticons,
$emoticons_alpha_lookup,
], JSON_PRETTY_PRINT) . ";\n",
];
|