Research Labs

2026-09-17 20:38 UTCopen field data · live

inc/streampage.php

Snapshot 2026.09.17-a2894de (current) · 30 lines · 2,223 bytes · tree · plain text

SHA-256 aa298edcdb72d00b341283a821760eb2c0b91e102bed34a4b58fc6554c3d1f1c
Functions: render_stream_page L4-L30
1<?php
2/* Generic renderer: give it a page title, intro, and stream codes. */
3require_once __DIR__.'/layout.php';
4function render_stream_page(string $slug,string $title,string $intro,array $codes,array $opts=[]): void {
5 page_header($title,$slug);
6 echo '<h1>'.h($title).'</h1><p class="lede">'.h($intro).'</p>';
7 $from=$_GET['from']??date('Y-m-d',strtotime('-30 days')); $to=$_GET['to']??date('Y-m-d');
8 echo '<form class="controls" method="get"><input type="hidden" name="p" value="'.h($slug).'">'
9 .'<div><label>FROM</label><input type="date" name="from" value="'.h($from).'"></div>'
10 .'<div><label>TO</label><input type="date" name="to" value="'.h($to).'"></div>'
11 .'<button>Apply</button></form>';
12 $shown=0;
13 foreach($codes as $code){
14 $s=stream_by_code($code);
15 if(!$s){ echo '<div class="card"><h3>'.h($code).'</h3><div class="kv">Stream not configured yet; accounted for in schema.</div></div>'; continue; }
16 if(!visible($s)){ echo '<div class="card"><h3>'.h($s['label']).'</h3><div class="kv">Restricted stream: '.h($s['embargo_note']?:'available via keyed API or by agreement').'.</div></div>'; continue; }
17 $shown++;
18 $rows=series($s,$from.' 00:00:00',$to.' 23:59:59');
19 $last=latest($s);
20 echo '<div class="card"><h3>'.h($s['label']).' '.mode_badge($s).'</h3>';
21 echo '<div class="kv">'.inst_status_badge($s['inst_status']).' · '.h($s['inst_name']).(function_exists('code_link')&&code_link('x')!==''?' · code: '.code_link('pages/'.$slug.'.php',null,'page').' · '.code_link('inc/streampage.php','render_stream_page','renderer').' · '.code_link('inc/helpers.php','series','series'):'').'</div>';
22 if($last) echo '<div class="big">'.h(number_format((float)$last['value'],2)).'<span class="unit">'.h($s['unit']).'</span></div><div class="kv">latest · '.h($last['ts']).'</div>';
23 echo '<div class="chart" data-chart=\''.h(json_encode(['unit'=>$s['unit'],'series'=>[['label'=>$s['label'],'slot'=>(int)$s['series_slot'],'data'=>array_map(fn($r)=>[substr($r['ts'],0,16),(float)$r['value']],$rows)]]])).'\'></div>';
24 echo instrument_card($s);
25 echo '</div>';
26 }
27 if(isset($opts['note'])) echo '<p class="note">'.h($opts['note']).'</p>';
28 page_footer();
29}
30

Lines can be cited as inc/streampage.php L120-L140, platform code 2026.09.17-a2894de; add #L120-L140 to this page's address to highlight them. Source shown for scrutiny of the research platform. All rights reserved. Not offered as installable software.