Skip to content
wiki.fftac.org

Page Study - Source Excerpt 01

Back to Page Study

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/themes/spiralist/page-study.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/themes/spiralist/page-study.php

<?php

if (!defined('ABSPATH')) {
    exit;
}

get_header();

$ui_text = static function (string $key, string $fallback): string {
    return function_exists('spiralist_get_ui_text') ? spiralist_get_ui_text($key, $fallback) : $fallback;
};

$folio_response = rest_do_request(new WP_REST_Request('GET', '/uaix/v1/manuscript-folio'));
$folio_payload = $folio_response instanceof WP_REST_Response ? $folio_response->get_data() : [];
$folio = is_array($folio_payload) ? (array) ($folio_payload['folio'] ?? []) : [];
$symbols = is_array($folio_payload) ? (array) ($folio_payload['symbols'] ?? []) : [];
$prompts = is_array($folio_payload) ? (array) ($folio_payload['related_prompts'] ?? []) : [];
$glossary = is_array($folio_payload) ? (array) ($folio_payload['glossary'] ?? []) : [];
$folio_image = (array) ($folio['image'] ?? []);
$study_bootstrap = [
    'endpoint' => rest_url('uaix/v1/manuscript-folio'),
    'initialFolio' => $folio_payload,
];
$run_prompt_url = function_exists('spiralist_get_run_prompt_page_url') ? spiralist_get_run_prompt_page_url() : home_url('/prompt-generator/');
$folio_title = trim((string) ($folio['title'] ?? $ui_text('page.study.surface.title', 'Current manuscript folio')));
$folio_summary = trim((string) ($folio['summary'] ?? $folio['caption'] ?? ''));
$folio_terms = array_values(array_filter(array_map(
    static fn($symbol): string => is_array($symbol) ? trim((string) ($symbol['label'] ?? $symbol['id'] ?? '')) : '',
    $symbols
), 'strlen'));
$folio_context_parts = array_filter([
    $folio_title !== '' ? 'Folio: ' . $folio_title : '',
    !empty($folio['section']) ? 'Section: ' . (string) $folio['section'] : '',
    $folio_summary !== '' ? 'Summary: ' . $folio_summary : '',
    !empty($folio_terms) ? 'Extracted symbols: ' . implode(', ', array_slice($folio_terms, 0, 8)) : '',
    !empty($folio['route_url']) ? 'Source URL: ' . (string) $folio['route_url'] : '',
]);
$folio_context = trim(preg_replace('/\s+/', ' ', implode(' ', $folio_context_parts)) ?: '');
if (function_exists('mb_substr')) {
    $folio_context = mb_substr($folio_context, 0, 900);
} else {
    $folio_context = substr($folio_context, 0, 900);
}
$build_prompt_bridge_url = static function (array $args) use ($run_prompt_url): string {
    return add_query_arg($args, $run_prompt_url) . '#portable-prompt-builder';
};
$folio_action_bridges = [
    [
        'label' => $ui_text('page.study.bridge.explain.label', 'Explain'),
        'title' => $ui_text('page.study.bridge.explain.title', 'Explain this folio'),
        'copy' => $ui_text('page.study.bridge.explain.copy', 'Open the prompt builder with this folio loaded for plain-language interpretation.'),
        'url' => $build_prompt_bridge_url([
            'mode' => 'understand-spiralism',
            'subject' => $folio_title,
            'task' => 'Explain this manuscript folio in plain language and connect it to Spiralism.',
            'context' => $folio_context,
        ]),
    ],
    [
        'label' => $ui_text('page.study.bridge.symbols.label', 'Symbols'),
        'title' => $ui_text('page.study.bridge.symbols.title', 'Map the symbols'),
        'copy' => $ui_text('page.study.bridge.symbols.copy', 'Turn the extracted terms into a symbolic reading with grounded limits.'),
        'url' => $build_prompt_bridge_url([
            'mode' => 'decode-symbol',
            'subject' => !empty($folio_terms) ? implode(', ', array_slice($folio_terms, 0, 6)) : $folio_title,
            'task' => 'Map the visible symbols and terms in this folio without inventing hidden authority.',
            'context' => $folio_context,
        ]),
    ],
    [
        'label' => $ui_text('page.study.bridge.prompt.label', 'Prompt'),
        'title' => $ui_text('page.study.bridge.prompt.title', 'Build a reusable prompt'),
        'copy' => $ui_text('page.study.bridge.prompt.copy', 'Use this folio as source material for a reusable prompt ladder.'),
        'url' => $build_prompt_bridge_url([
            'mode' => 'prompt-ladder',
            'subject' => $folio_title,
            'task' => 'Turn this folio context into a reusable Spiralist prompt ladder.',
            'context' => $folio_context,
        ]),
    ],
    [
        'label' => $ui_text('page.study.bridge.review.label', 'Review'),
        'title' => $ui_text('page.study.bridge.review.title', 'Review safety and claims'),
        'copy' => $ui_text('page.study.bridge.review.copy', 'Check whether a proposed interpretation overclaims, anthropomorphizes, or loses source grounding.'),
        'url' => $build_prompt_bridge_url([
            'mode' => 'spiralist-risk-review',
            'subject' => $folio_title,
            'task' => 'Review a folio interpretation for overclaiming, unsupported certainty, and grounded next steps.',
            'context' => $folio_context,
        ]),
    ],
];
?>
<main class="spiralist-page spiralist-page--study">
    <script type="application/json" id="spiralist-study-bootstrap"><?php echo wp_json_encode($study_bootstrap, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); ?></script>

    <section class="spiralist-page-hero">
        <div class="spiralist-shell spiralist-page-hero__content">
            <p class="spiralist-kicker"><?php echo esc_html($ui_text('page.study.hero.kicker', 'Unified Study Surface')); ?></p>
            <h1><?php echo esc_html($ui_text('page.study.hero.title', 'Read the manuscript with symbols, prompts, and glossary in view.')); ?></h1>
            <p class="spiralist-page-hero__copy"><?php echo esc_html($ui_text('page.study.hero.copy', 'The Study path now treats each folio as a working surface: image, transcription, extracted symbols, related prompt systems, and machine-readable context stay together.')); ?></p>
            <div class="spiralist-cta-row">
                <a class="spiralist-button spiralist-button--primary" href="<?php echo esc_url((string) ($folio['route_url'] ?? (function_exists('spiralist_get_manuscript_page_url') ? spiralist_get_manuscript_page_url() : home_url('/manuscript/')))); ?>"><?php echo esc_html($ui_text('page.study.hero.open_folio', 'Open Full Folio')); ?></a>
                <a class="spiralist-button spiralist-button--secondary" href="<?php echo esc_url(function_exists('spiralist_get_symbols_page_url') ? spiralist_get_symbols_page_url() : home_url('/symbols/')); ?>"><?php echo esc_html($ui_text('page.study.hero.symbols', 'Symbol Explorer')); ?></a>
                <a class="spiralist-button spiralist-button--tertiary" href="<?php echo esc_url(function_exists('spiralist_get_prompts_page_url') ? spiralist_get_prompts_page_url() : home_url('/prompts/')); ?>"><?php echo esc_html($ui_text('page.study.hero.prompts', 'Prompt Library')); ?></a>
            </div>
        </div>
    </section>

    <section class="spiralist-page-section spiralist-page-section--compact" aria-labelledby="study-surface-title">
        <div class="spiralist-shell">
            <div class="spiralist-section-head">
                <div>
                    <p class="spiralist-section-tag"><?php echo esc_html($ui_text('page.study.surface.tag', 'Side-by-side Reading')); ?></p>
                    <h2 class="spiralist-section-title" id="study-surface-title"><?php echo esc_html((string) ($folio['title'] ?? $ui_text('page.study.surface.title', 'Current manuscript folio'))); ?></h2>
                </div>
                <?php if (!empty($folio['sequence'])) : ?>
                    <span class="spiralist-chip"><?php echo esc_html(sprintf($ui_text('page.study.surface.sequence', 'Folio %d'), (int) $folio['sequence'])); ?></span>
                <?php endif; ?>
            </div>

            <div class="spiralist-grid spiralist-grid--split">
                <article class="spiralist-panel">
                    <?php if (!empty($folio_image['large'])) : ?>
                        <figure class="spiralist-manuscript-preview">
                            <img src="<?php echo esc_url((string) $folio_image['large']); ?>" alt="<?php echo esc_attr((string) ($folio_image['alt'] ?? $folio['title'] ?? 'Manuscript folio')); ?>" loading="lazy" />
                        </figure>
                    <?php endif; ?>
                    <p class="spiralist-section-tag"><?php echo esc_html((string) ($folio['section'] ?? $ui_text('page.study.surface.section', 'Manuscript'))); ?></p>
                    <h3 class="spiralist-card-title"><?php echo esc_html($ui_text('page.study.transcription.title', 'Transcription')); ?></h3>
                    <p><?php echo esc_html((string) ($folio['transcription'] ?? $folio['summary'] ?? $ui_text('page.study.transcription.empty', 'No transcription is available for this folio yet.'))); ?></p>
                    <?php if (!empty($folio['caption'])) : ?>
                        <p class="spiralist-muted"><?php echo esc_html((string) $folio['caption']); ?></p>