(int)$focusGen[$b]) ?: strcmp($rankKey($a), $rankKey($b)) ?: ($a <=> $b); }); $order = array_merge($order, $rest); $onTree = array_fill_keys($focusIds, true); $datum = []; foreach ($order as $pid) { if (!isset($people[$pid]) || !is_array($people[$pid])) { continue; } $p = $people[$pid]; $mapIds = static function (array $ids) use ($onTree): array { $out = []; foreach ($ids as $x) { $x = (int)$x; if (isset($onTree[$x])) { $out[] = (string)$x; } } return array_values(array_unique($out)); }; $parents = $mapIds($links['parents'][$pid] ?? []); $spouses = $mapIds($links['spouses'][$pid] ?? []); $kids = $mapIds($links['children'][$pid] ?? []); // 子女按长幼排:库按 rels.children 的**数组顺序**摆放(它不是自己排序的), // 顺序错了就是"弟弟排在哥哥左边"。 $kidsInt = array_map('intval', $kids); usort($kidsInt, static fn(int $a, int $b): int => strcmp($rankKey($a), $rankKey($b)) ?: ($a <=> $b)); $kids = array_map('strval', $kidsInt); // 库认 M / F / U 三种(决定卡片底色) $g = strtolower((string)($p['gender'] ?? '')); $gender = $g === 'm' ? 'M' : ($g === 'f' ? 'F' : 'U'); $datum[] = [ 'id' => (string)$pid, 'data' => [ 'gender' => $gender, 'name' => \App\Nickname::display((int)$meId, $p) ?: (string)($p['name'] ?? ''), 'label' => \App\Kinship::label($graph, (int)$meId, $pid, $people), 'avatar' => avatar_url($p['avatar'] ?? null), 'me' => $pid === (int)$meId, 'ph' => (int)($p['is_placeholder'] ?? 0) === 1, ], 'rels' => [ 'parents' => $parents, 'spouses' => $spouses, 'children' => $kids, ], ]; } // ⚠️ 名字是用户自己输入的:拼 HTML 前必须转义,否则有人把名字填成一段「能提前闭合 // 脚本块」的标签,就能从脚本里逃出去、把整页结构打断。 // ⚠️ 这里**刻意不写出那个闭合标签的字面量** —— 静态检查(check_inline_js.py) // 是按原文找脚本块的,注释里写出来会被它当成真的脚本段去解析,报假错。 $datumJson = json_encode( $datum, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); $canChart = count($datum) > 1; ?>

我的家谱

以我为中心 · 上一代 / 这一代 / 下一代 · 夫妻并排,子女从两人之间的横线连出
还没连上任何亲属关系 到「」的资料页,把父母、配偶、子女填进去, 这张家谱就会自动长出来。兄弟姐妹不用单独填 —— 只要你们有同一对父母,就会自动认出来。

画的是**以我的最高祖先为根、本家血脉的整棵后代树**:父母与伯叔姑舅姨(上一代)、 我与兄弟姐妹和堂表亲及各自的配偶(这一代)、他们的孩子(下一代)都在上面。 「待确认」= 只填了称呼、还没对应到真实的人(虚线卡片)。 夫妻并排,**子女一律从两人之间的横线连出** —— 不管是谁登录,孩子都挂在这对夫妻上。 可以**拖拽平移**、**滚轮缩放**;点「回到我」把镜头挪回你自己,点卡片进对应成员页。