resolve_slug(); if (!$slug) { return ''; } // Only render on registered association channels. if (!$this->is_registered_association($slug)) { return ''; } $addons = $this->load_registry(); if (empty($addons)) { return ''; } $module = \App::$module ?? ''; $slug_safe = htmlspecialchars($slug, ENT_QUOTES, 'UTF-8'); if (function_exists('head_add_css')) { head_add_css('/addon/vs01/view/css/civicnav.css'); } $out = '
'; $out .= '
Diagnostic Record
'; $out .= ''; $out .= '
'; return $out; } // ------------------------------------------------------------------------- // SLUG RESOLUTION // ------------------------------------------------------------------------- private function resolve_slug() { $module = \App::$module ?? ''; // On addon module pages (vs01, dsc01, scn01): slug is argv(1). if (in_array($module, ['vs01', 'dsc01', 'scn01'], true)) { return \argv(1) ?? ''; } // On the channel page: slug is the local part of channel_address. if ($module === 'channel') { $addr = \App::$profile['channel_address'] ?? ''; if ($addr) { // channel_address may be bare (kingsrow-wdca) or full (kingsrow-wdca@node). return explode('@', $addr)[0]; } } return ''; } // ------------------------------------------------------------------------- // ASSOCIATION GUARD // ------------------------------------------------------------------------- private function is_registered_association($slug) { $raw = @file_get_contents('addon/vs01/config.json'); if ($raw === false) { return false; } $config = json_decode($raw, true); if (json_last_error() !== JSON_ERROR_NONE) { return false; } return isset($config['associations'][$slug]); } // ------------------------------------------------------------------------- // REGISTRY LOADER // ------------------------------------------------------------------------- private function load_registry() { $raw = @file_get_contents('addon/vs01/civicnav.json'); if ($raw === false) { // Fall back to template defaults if runtime file not present. $raw = @file_get_contents('addon/vs01/civicnav.json.template'); } if ($raw === false) { return []; } $data = json_decode($raw, true); if (json_last_error() !== JSON_ERROR_NONE) { return []; } return $data['addons'] ?? []; } }