Foundation - Source Excerpt 36
Summary
This source excerpt preserves a bounded section of Anti-Christ.org/wp-content/plugins/fftac-foundation-core/inc/foundation.php so readers can inspect the evidence without opening the full source file.
**Source path:** Anti-Christ.org/wp-content/plugins/fftac-foundation-core/inc/foundation.php
'atlas_url' => antichrist_engine_foundation_build_target_url('research', array(), $anchor),
'research_url' => antichrist_engine_foundation_build_target_url('research', array(), $anchor),
'record_request_url' => $record_request_url,
'record_url' => $record_request_url . '#research-record',
'record_type' => 'projection',
'type_label' => $type_labels['projection'],
'source_count' => (int) ($claim['source_count'] ?? 0),
'source_references' => (array) ($claim['source_references'] ?? array()),
'keywords' => $keywords,
'searchable' => antichrist_engine_foundation_normalize_search_text($keywords),
);
}
}
return $entries;
}
/**
* Builds a machine-readable relationship map for the research atlas.
*
* @return array<string, mixed>
*/
function antichrist_engine_foundation_get_research_connection_map()
{
static $map = null;
if (null !== $map) {
return $map;
}
$claim_labels = antichrist_engine_foundation_get_claim_category_labels();
$verdicts = antichrist_engine_foundation_claim_verdicts();
$claims = antichrist_engine_foundation_get_enriched_claim_dossiers();
$sources = antichrist_engine_foundation_get_research_api_sources();
$claim_lookup = array();
$source_hubs = array();
$source_hub_lookup = array();
$nodes = array();
$edges = array();
$edge_keys = array();
$claim_lanes = array();
$claim_bridges = array();
$citation_edges = 0;
$relation_edges = 0;
foreach ($claims as $claim) {
$claim_lookup[(string) ($claim['record_id'] ?? '')] = $claim;
}
foreach ($sources as $source) {
if (empty($source['citation_count'])) {
continue;
}
$lane_counts = array();
foreach ((array) ($source['claim_references'] ?? array()) as $claim_reference) {
$lane_slug = sanitize_key((string) ($claim_reference['category'] ?? ''));
if ('' === $lane_slug) {
continue;
}
if (!isset($lane_counts[$lane_slug])) {
$lane_counts[$lane_slug] = 0;
}
$lane_counts[$lane_slug]++;
}
arsort($lane_counts);
$lane_breakdown = array();
foreach ($lane_counts as $lane_slug => $count) {
$lane_breakdown[] = array(
'slug' => $lane_slug,
'label' => (string) ($claim_labels[$lane_slug] ?? ucwords(str_replace('-', ' ', $lane_slug))),
'count' => (int) $count,
'url' => antichrist_engine_foundation_build_target_url('research', array(
'claim_category' => $lane_slug,
), 'claim-index'),
);
}
$lane_slugs = array_values(array_map(static function ($lane) {
return (string) ($lane['slug'] ?? '');
}, $lane_breakdown));
$lane_labels = array_values(array_map(static function ($lane) {
return (string) ($lane['label'] ?? '');
}, $lane_breakdown));
$source_hub = array_merge($source, array(
'lane_total' => count($lane_breakdown),
'lane_slugs' => array_values(array_filter($lane_slugs)),
'lane_labels' => array_values(array_filter($lane_labels)),
'lane_breakdown' => $lane_breakdown,
));
$source_hubs[] = $source_hub;
$source_hub_lookup[(string) ($source_hub['record_id'] ?? '')] = $source_hub;
$nodes[] = array(
'id' => (string) $source_hub['record_id'],
'record_id' => (string) $source_hub['record_id'],
'type' => 'source',
'title' => (string) ($source_hub['title'] ?? ''),
'group' => (string) ($source_hub['group'] ?? __('Source Library', 'antichrist-engine')),
'url' => (string) ($source_hub['record_url'] ?? $source_hub['research_url'] ?? ''),
'citation_count' => (int) ($source_hub['citation_count'] ?? 0),
'lane_total' => (int) ($source_hub['lane_total'] ?? 0),
'lane_slugs' => (array) ($source_hub['lane_slugs'] ?? array()),
);
}
foreach ($claims as $claim) {
$category = (string) ($claim['category'] ?? '');
$record_id = (string) ($claim['record_id'] ?? '');
$category_label = (string) ($claim_labels[$category] ?? ucwords(str_replace('-', ' ', $category)));
$nodes[] = array(
'id' => $record_id,
'record_id' => $record_id,
'type' => 'claim',
'title' => (string) ($claim['title'] ?? ''),
'group' => $category,
'group_label' => $category_label,
'url' => (string) ($claim['record_url'] ?? $claim['research_url'] ?? ''),
'source_count' => (int) ($claim['source_count'] ?? 0),
'episode_count' => (int) ($claim['episode_count'] ?? 0),
'verdict' => (string) ($claim['verdict'] ?? ''),
'evidence' => (string) ($claim['evidence'] ?? ''),
'related_count' => (int) ($claim['related_claim_count'] ?? count((array) ($claim['related_claims'] ?? array()))),
);
if (!isset($claim_lanes[$category])) {
$claim_lanes[$category] = array(
'slug' => $category,
'label' => $category_label,
'claim_count' => 0,
'source_total' => 0,
'citation_edges' => 0,
'url' => antichrist_engine_foundation_build_target_url('research', array(
'claim_category' => $category,
), 'claim-index'),
'claim_references' => array(),
'source_ids' => array(),
'source_counts' => array(),
'verdict_counts' => array(),
);
}
$claim_lanes[$category]['claim_count']++;
$claim_lanes[$category]['claim_references'][] = array(
'record_id' => $record_id,
'title' => (string) ($claim['title'] ?? ''),
'record_url' => (string) ($claim['record_url'] ?? $claim['research_url'] ?? ''),
'source_count' => (int) ($claim['source_count'] ?? 0),
'episode_count'=> (int) ($claim['episode_count'] ?? 0),
);
if (!empty($claim['verdict'])) {
$verdict_slug = (string) $claim['verdict'];
if (!isset($claim_lanes[$category]['verdict_counts'][$verdict_slug])) {
$claim_lanes[$category]['verdict_counts'][$verdict_slug] = 0;
}
$claim_lanes[$category]['verdict_counts'][$verdict_slug]++;
}
foreach ((array) ($claim['source_references'] ?? array()) as $source_reference) {
$source_record_id = (string) ($source_reference['record_id'] ?? '');
if ('' === $source_record_id) {
continue;
}
$edge_key = 'citation:' . $record_id . ':' . $source_record_id;
if (!isset($edge_keys[$edge_key])) {
$edge_keys[$edge_key] = true;
$edges[] = array(
'from' => $record_id,
'to' => $source_record_id,
'type' => 'citation',
'weight' => 1,
);
$citation_edges++;
}
$claim_lanes[$category]['citation_edges']++;
$claim_lanes[$category]['source_ids'][$source_record_id] = true;
if (!isset($claim_lanes[$category]['source_counts'][$source_record_id])) {
$claim_lanes[$category]['source_counts'][$source_record_id] = 0;
}
$claim_lanes[$category]['source_counts'][$source_record_id]++;
}
foreach ((array) ($claim['related_claims'] ?? array()) as $related_claim) {
$pair = array($record_id, (string) ($related_claim['record_id'] ?? ''));
sort($pair, SORT_STRING);
if ('' === $pair[0] || '' === $pair[1]) {
continue;
}
$edge_key = 'related:' . implode(':', $pair);
if (isset($edge_keys[$edge_key])) {
continue;
}
$edge_keys[$edge_key] = true;