Skip to content
wiki.fftac.org

Foundation - Source Excerpt 38

Back to Foundation

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

$records[(string) ($briefing['record_id'] ?? '')] = $briefing;
    }

    foreach (antichrist_engine_foundation_get_enriched_timeline_entries() as $timeline_entry) {
        $records[(string) ($timeline_entry['record_id'] ?? '')] = $timeline_entry;
    }

    foreach (antichrist_engine_foundation_get_enriched_claim_dossiers() as $claim) {
        $records[(string) ($claim['record_id'] ?? '')] = $claim;
    }

    foreach (antichrist_engine_foundation_get_projection_ledger_entries() as $projection) {
        $records[(string) ($projection['record_id'] ?? '')] = $projection;
    }

    foreach (antichrist_engine_foundation_get_research_api_sources() as $source) {
        $records[(string) ($source['record_id'] ?? '')] = $source;
    }

    return array_filter($records);
}

/**
 * Resolves the currently requested focused research record, if any.
 *
 * @param array<string, mixed>|null $input Optional query input.
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_get_active_research_record($input = null)
{
    if (!antichrist_engine_foundation_is_research_page_request()) {
        return array();
    }

    $input     = is_array($input) ? $input : $_GET;
    $record_id = antichrist_engine_foundation_clean_record_query($input['record'] ?? '');

    if ('' === $record_id) {
        return array();
    }

    return antichrist_engine_foundation_get_research_record_lookup()[$record_id] ?? array();
}

/**
 * Builds a focused meta description for a research record.
 *
 * @param array<string, mixed> $record Research record data.
 * @return string
 */
function antichrist_engine_foundation_get_research_record_meta_description($record)
{
    $type = (string) ($record['record_type'] ?? '');

    if ('claim' === $type) {
        $verdicts        = antichrist_engine_foundation_claim_verdicts();
        $evidence_levels = antichrist_engine_foundation_claim_evidence_levels();
        $verdict_label   = (string) ($verdicts[$record['verdict'] ?? '']['label'] ?? '');
        $evidence_label  = (string) ($evidence_levels[$record['evidence'] ?? '']['label'] ?? '');

        return trim(implode(' ', array_filter(array(
            sprintf(
                /* translators: 1: claim title, 2: claim record ID. */
                __('%1$s is tracked as claim dossier %2$s.', 'antichrist-engine'),
                (string) ($record['title'] ?? ''),
                (string) ($record['record_id'] ?? '')
            ),
            $verdict_label ? sprintf(__('Verdict: %s.', 'antichrist-engine'), $verdict_label) : '',
            $evidence_label ? sprintf(__('Evidence posture: %s.', 'antichrist-engine'), $evidence_label) : '',
            (string) ($record['summary'] ?? ''),
        ))));
    }

    if ('projection' === $type) {
        return trim(implode(' ', array_filter(array(
            sprintf(
                /* translators: 1: projection record ID, 2: claim record ID. */
                __('Projection ledger entry %1$s traces claim dossier %2$s through a specific chronology checkpoint.', 'antichrist-engine'),
                (string) ($record['record_id'] ?? ''),
                (string) ($record['claim_record_id'] ?? '')
            ),
            !empty($record['period']) ? sprintf(__('Period: %s.', 'antichrist-engine'), (string) $record['period']) : '',
            !empty($record['status']) ? sprintf(__('Outcome: %s.', 'antichrist-engine'), (string) $record['status']) : '',
            (string) ($record['summary'] ?? ''),
        ))));
    }

    if ('source' === $type) {
        return sprintf(
            /* translators: 1: source title, 2: publisher, 3: source record ID, 4: citation count. */
            __('%1$s from %2$s is tracked as source record %3$s and is currently cited by %4$s claim dossiers.', 'antichrist-engine'),
            (string) ($record['title'] ?? ''),
            (string) ($record['publisher'] ?? __('Unknown publisher', 'antichrist-engine')),
            (string) ($record['record_id'] ?? ''),
            number_format_i18n((int) ($record['citation_count'] ?? 0))
        ) . ' ' . (string) ($record['note'] ?? '');
    }

    if ('timeline' === $type) {
        return sprintf(
            /* translators: 1: timeline record ID, 2: year label, 3: timeline title. */
            __('Timeline entry %1$s covers %2$s and the dossier "%3$s".', 'antichrist-engine'),
            (string) ($record['record_id'] ?? ''),
            (string) ($record['year'] ?? ''),
            (string) ($record['title'] ?? '')
        ) . ' ' . (string) ($record['summary'] ?? '');
    }

    if ('briefing' === $type) {
        return sprintf(
            /* translators: 1: briefing title, 2: briefing record ID, 3: briefing duration. */
            __('%1$s is executive briefing %2$s with an estimated duration of %3$s.', 'antichrist-engine'),
            (string) ($record['title'] ?? ''),
            (string) ($record['record_id'] ?? ''),
            (string) ($record['duration'] ?? __('short read', 'antichrist-engine'))
        ) . ' ' . (string) ($record['summary'] ?? '');
    }

    return trim(implode(' ', array_filter(array(
        (string) ($record['title'] ?? ''),
        (string) ($record['record_id'] ?? ''),
        (string) ($record['summary'] ?? ''),
    ))));
}

/**
 * Builds structured data for a focused research record.
 *
 * @param array<string, mixed> $record          Research record data.
 * @param string               $current_url     Current request URL.
 * @param string               $webpage_id      Current webpage graph ID.
 * @param string               $organization_id Publisher organization graph ID.
 * @param string               $description     Current record description.
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_get_research_record_structured_data_graph($record, $current_url, $webpage_id, $organization_id, $description)
{
    $graph = array(
        '@type'       => 'CreativeWork',
        '@id'         => $current_url . '#record',
        'url'         => $current_url,
        'name'        => (string) ($record['title'] ?? ''),
        'description' => $description,
        'identifier'  => (string) ($record['record_id'] ?? ''),
        'genre'       => (string) ($record['type_label'] ?? __('Research Record', 'antichrist-engine')),
        'isPartOf'    => array('@id' => $webpage_id),
        'publisher'   => array('@id' => $organization_id),
    );

    if (!empty($record['keywords'])) {
        $graph['keywords'] = (string) $record['keywords'];
    }

    if (!empty($record['record_type'])) {
        $graph['additionalType'] = (string) ($record['record_type']);
    }

    if (!empty($record['atlas_url'])) {
        $graph['subjectOf'] = array(
            '@type' => 'WebPage',
            'url'   => (string) $record['atlas_url'],
        );
    }

    return $graph;
}

/**
 * Builds the public fact-check summary derived from claim dossiers.
 *
 * @return array<string, mixed>
 */
function antichrist_engine_foundation_get_research_fact_check_summary()
{
    $claims              = antichrist_engine_foundation_claim_dossiers();
    $verdict_definitions = antichrist_engine_foundation_claim_verdicts();
    $evidence_levels     = antichrist_engine_foundation_claim_evidence_levels();
    $verdicts            = array();
    $evidence            = array();
    $chronology_total    = 0;

    foreach ($verdict_definitions as $slug => $definition) {
        $verdicts[$slug] = array(
            'slug'        => $slug,
            'label'       => $definition['label'],
            'description' => $definition['description'],
            'count'       => 0,
        );
    }

    foreach ($evidence_levels as $slug => $definition) {
        $evidence[$slug] = array(
            'slug'        => $slug,
            'label'       => $definition['label'],
            'description' => $definition['description'],
            'count'       => 0,
        );
    }

    foreach ($claims as $claim) {
        $verdict_slug  = $claim['verdict'] ?? '';
        $evidence_slug = $claim['evidence'] ?? '';

        if ($verdict_slug && isset($verdicts[$verdict_slug])) {
            $verdicts[$verdict_slug]['count']++;
        }

        if ($evidence_slug && isset($evidence[$evidence_slug])) {
            $evidence[$evidence_slug]['count']++;
        }

        $chronology_total += count($claim['episodes'] ?? array());
    }

    return array(
        'claims_total'        => count($claims),
        'chronology_total'    => $chronology_total,
        'projection_total'    => $chronology_total,
        'source_total'        => count(antichrist_engine_foundation_research_sources()),
        'verdicts'            => array_values($verdicts),