Skip to content
wiki.fftac.org

Foundation - Source Excerpt 32

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

'content'      => antichrist_engine_foundation_convert_rows_to_csv(antichrist_engine_foundation_get_research_timeline_export_rows()),
        );
    }

    if ('projections_csv' === $slug) {
        return array(
            'filename'     => 'fftac-research-projection-ledger.csv',
            'content_type' => 'text/csv; charset=utf-8',
            'content'      => antichrist_engine_foundation_convert_rows_to_csv(antichrist_engine_foundation_get_research_projection_export_rows()),
        );
    }

    if ('sources_csv' === $slug) {
        return array(
            'filename'     => 'fftac-research-sources.csv',
            'content_type' => 'text/csv; charset=utf-8',
            'content'      => antichrist_engine_foundation_convert_rows_to_csv(antichrist_engine_foundation_get_research_source_export_rows()),
        );
    }

    if ('records_ndjson' === $slug) {
        $lines = array_map(static function ($row) {
            return wp_json_encode($row, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        }, antichrist_engine_foundation_get_research_record_export_rows());

        return array(
            'filename'     => 'fftac-research-records.ndjson',
            'content_type' => 'application/x-ndjson; charset=utf-8',
            'content'      => implode("\n", $lines) . "\n",
        );
    }

    if ('provenance_txt' === $slug) {
        return array(
            'filename'     => 'fftac-research-provenance.txt',
            'content_type' => 'text/plain; charset=utf-8',
            'content'      => antichrist_engine_foundation_get_research_export_provenance_text(),
        );
    }

    return array();
}

/**
 * Returns public metadata for richer research download formats.
 *
 * @return array<int, array<string, string>>
 */
function antichrist_engine_foundation_get_research_export_downloads()
{
    $route_map = antichrist_engine_foundation_get_research_export_download_route_map();
    $counts    = antichrist_engine_foundation_get_research_api_overview()['counts'] ?? array();

    return array(
        array(
            'slug'           => 'claims_csv',
            'title'          => __('Claim dossier table', 'antichrist-engine'),
            'summary'        => __('A flat CSV of the live claim index with verdicts, evidence posture, related record IDs, and direct record URLs.', 'antichrist-engine'),
            'format_label'   => 'CSV',
            'filename'       => 'fftac-research-claims.csv',
            'meta'           => sprintf(
                /* translators: %s is the claims row count. */
                __('%s rows / spreadsheet-ready', 'antichrist-engine'),
                number_format_i18n((int) ($counts['claims'] ?? 0))
            ),
            'url'            => (string) ($route_map['claims_csv'] ?? ''),
            'cta'            => __('Download claims CSV', 'antichrist-engine'),
            'secondary_url'  => antichrist_engine_foundation_get_research_api_route_map()['claims'] ?? '',
            'secondary_label'=> __('Open JSON route', 'antichrist-engine'),
        ),
        array(
            'slug'           => 'timeline_csv',
            'title'          => __('Historical timeline table', 'antichrist-engine'),
            'summary'        => __('A CSV chronology of timeline entries with lanes, tags, record handles, and focused record URLs.', 'antichrist-engine'),
            'format_label'   => 'CSV',
            'filename'       => 'fftac-research-timeline.csv',
            'meta'           => sprintf(
                /* translators: %s is the timeline row count. */
                __('%s rows / chronology export', 'antichrist-engine'),
                number_format_i18n((int) ($counts['timeline'] ?? 0))
            ),
            'url'            => (string) ($route_map['timeline_csv'] ?? ''),
            'cta'            => __('Download timeline CSV', 'antichrist-engine'),
            'secondary_url'  => antichrist_engine_foundation_get_research_api_route_map()['timeline'] ?? '',
            'secondary_label'=> __('Open JSON route', 'antichrist-engine'),
        ),
        array(
            'slug'           => 'projections_csv',
            'title'          => __('Projection ledger table', 'antichrist-engine'),
            'summary'        => __('A flat chronology ledger of prophecy-claim episodes with parent dossier IDs, outcomes, source trails, and focused record URLs.', 'antichrist-engine'),
            'format_label'   => 'CSV',
            'filename'       => 'fftac-research-projection-ledger.csv',
            'meta'           => sprintf(
                /* translators: %s is the projection-ledger row count. */
                __('%s rows / prediction-history export', 'antichrist-engine'),
                number_format_i18n(count(antichrist_engine_foundation_get_projection_ledger_entries()))
            ),
            'url'            => (string) ($route_map['projections_csv'] ?? ''),
            'cta'            => __('Download projection ledger CSV', 'antichrist-engine'),
            'secondary_url'  => antichrist_engine_foundation_get_research_api_route_map()['projections'] ?? '',
            'secondary_label'=> __('Open JSON route', 'antichrist-engine'),
        ),
        array(
            'slug'           => 'sources_csv',
            'title'          => __('Source library table', 'antichrist-engine'),
            'summary'        => __('A CSV export of the current source library with publishers, citation counts, claim references, and outward URLs.', 'antichrist-engine'),
            'format_label'   => 'CSV',
            'filename'       => 'fftac-research-sources.csv',
            'meta'           => sprintf(
                /* translators: %s is the source row count. */
                __('%s rows / citation trail export', 'antichrist-engine'),
                number_format_i18n((int) ($counts['sources'] ?? 0))
            ),
            'url'            => (string) ($route_map['sources_csv'] ?? ''),
            'cta'            => __('Download sources CSV', 'antichrist-engine'),
            'secondary_url'  => antichrist_engine_foundation_get_research_api_route_map()['sources'] ?? '',
            'secondary_label'=> __('Open JSON route', 'antichrist-engine'),
        ),
        array(
            'slug'           => 'records_ndjson',
            'title'          => __('Unified record stream', 'antichrist-engine'),
            'summary'        => __('An NDJSON export that flattens briefings, timeline entries, claim dossiers, and source records into one line-delimited stream.', 'antichrist-engine'),
            'format_label'   => 'NDJSON',
            'filename'       => 'fftac-research-records.ndjson',
            'meta'           => sprintf(
                /* translators: %s is the record row count. */
                __('%s records / ingestion-ready', 'antichrist-engine'),
                number_format_i18n(count(antichrist_engine_foundation_get_research_record_lookup()))
            ),
            'url'            => (string) ($route_map['records_ndjson'] ?? ''),
            'cta'            => __('Download NDJSON', 'antichrist-engine'),
            'secondary_url'  => antichrist_engine_foundation_get_research_api_route_map()['export'] ?? '',
            'secondary_label'=> __('Open full JSON export', 'antichrist-engine'),
        ),
        array(
            'slug'           => 'provenance_txt',
            'title'          => __('Provenance note', 'antichrist-engine'),
            'summary'        => __('A plain-text manifest with generation time, record counts, primary JSON routes, and attribution guidance for reuse.', 'antichrist-engine'),
            'format_label'   => 'TXT',
            'filename'       => 'fftac-research-provenance.txt',
            'meta'           => __('1 file / citation support', 'antichrist-engine'),
            'url'            => (string) ($route_map['provenance_txt'] ?? ''),
            'cta'            => __('Download provenance note', 'antichrist-engine'),
            'secondary_url'  => antichrist_engine_foundation_get_page_url('standards'),
            'secondary_label'=> __('Open standards file', 'antichrist-engine'),
        ),
    );
}

/**
 * Streams richer research export downloads when requested.
 *
 * @return void
 */
function antichrist_engine_foundation_handle_research_export_download_request()
{
    if (is_admin() || wp_doing_ajax()) {
        return;
    }

    $slug = sanitize_key((string) ($_GET['fftac_download'] ?? ''));

    if ('' === $slug) {
        return;
    }

    $payload = antichrist_engine_foundation_get_research_export_download_payload($slug);

    if (!$payload) {
        return;
    }

    $filename = preg_replace('/[^A-Za-z0-9._-]/', '-', (string) ($payload['filename'] ?? 'fftac-export.txt'));