<?php
/**
* Common control library 0.1 for Conjuro.
*/
return [
new class("html") extends Control{
protected function renderControl($meta,$data) {
echo $meta["html"];
}
},
new class("img") extends Control{
protected function renderControl($meta,$data) {
c()->rhtml(
'img',
['id'=>$meta['id'],'class'=>$meta['class'],'src'=>$meta['src']]
);
}
},
new class("builder") extends Control{
protected function renderControl($meta,$data) {
include "Conjuro/Builder.php";
}
},
new class("form") extends Control{
protected function renderControl($meta,$data) {
$cols=$meta["columns"];
c()->rhtml(
'form',
['id'=>$meta['id'],'class'=>$meta['class']],
fn()=>c()->rhtml(
'table',
['class'=>'form-body-table'],
function() use($meta,$data){
echo '<tr>';
$col=0;
foreach($meta['childs'] as $child){
c()->renderContent($child,$data);
if($col++>=$cols){
echo '</tr><tr>';
}
}
echo '</tr>';
}
)
);
}
},
new class("form-data") extends Control{
protected function renderControl($meta,$data) {
if ($meta['id']){
$lid=$meta["id"].'-label';
$vid=$meta["id"].'-value';
}
c()->rhtml('td',['id'=>$lid,'class'=>'form-data-label '.$meta["class"]],fn()=>print(htmlentities($meta["label"])));
c()->rhtml('td',['id'=>$vid,'class'=>'form-data-value '.$meta["class"]]);
}
}
];
?>