FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Table.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class Table extends \Rsi\Fred\Controller\View\Html\Builder{
6 
7  public function build($ids){
8  $html = $this->html;
9  $hidden = $table = '';
10  foreach($this->expand($ids) as $id) if(is_array($id)){ //multi widget row
11  $first_caption = $widgets = false;
12  foreach($id as $sub){
13  $caption = $this->renderCaption($sub);
14  $widget = $this->renderWidget($sub);
15  if($caption === false) $hidden .= $widget;
16  else{
17  if($first_caption === false) $first_caption = $caption;
18  else $widgets .= $caption;
19  $widgets .= $widget;
20  }
21  }
22  if($first_caption || $widgets) $table .= $html->tr(
23  $html->th($first_caption,null,'row') . $html->td($widgets),['class' => 'fred-multi ids-' . implode('-',$id)]
24  );
25  }
26  else{ //single widget row
27  $caption = $this->renderCaption($id);
28  $widget = $this->renderWidget($id);
29  if($caption === false) $hidden .= $widget;
30  elseif(in_array(substr($id,0,1),[self::RENDER_BOTH,self::RENDER_WIDGET])){
31  if($caption) $table .= $html->tr($html->th($caption,['colspan' => 2]));
32  $table .= $html->tr($html->td($widget,['colspan' => 2]));
33  }
34  else $table .= $html->tr($html->th($caption,null,'row') . $html->td($widget),['class' => 'fred-row id-' . $id]);
35  }
36  return $hidden . $html->table($table,['role' => 'presentation']);
37  }
38 
39 }