1<?php 2 3namespace dokuwiki\plugin\struct\meta; 4 5/** 6 * Class AggregationEditorTable 7 * 8 * An AggregationTable for editing global and serial tables 9 * 10 * @package dokuwiki\plugin\struct\meta 11 */ 12class AggregationEditorTable extends AggregationTable 13{ 14 /** 15 * @var bool skip full table when no results found 16 */ 17 protected $simplenone = false; 18 19 /** 20 * Adds additional info to document and renderer in XHTML mode 21 * 22 * We add the schema name as data attribute 23 * 24 * @see finishScope() 25 */ 26 protected function startScope() 27 { 28 // unique identifier for this aggregation 29 $this->renderer->info['struct_table_hash'] = md5(var_export($this->data, true)); 30 31 if ($this->mode != 'xhtml') return; 32 33 $table = $this->columns[0]->getTable(); 34 35 $config = $this->searchConfig->getConf(); 36 if (isset($config['filter'])) unset($config['filter']); 37 $config = hsc(json_encode($config)); 38 39 // wrapping div 40 $this->renderer->doc .= "<div class=\"structaggregation structaggregationeditor\" data-schema=\"$table\" data-searchconf=\"$config\">"; 41 42 // unique identifier for this aggregation 43 $this->renderer->info['struct_table_hash'] = md5(var_export($this->data, true)); 44 } 45 46 /** 47 * We do not output a row for empty tables 48 */ 49 protected function renderEmptyResult() 50 { 51 } 52 53 /** 54 * Renders the first result row and returns it 55 * 56 * Only used for rendering new rows via JS (where the first row is the only one) 57 * 58 * @return string 59 */ 60 public function getFirstRow() 61 { 62 // XHTML renderer doesn't like calling ->tablerow_open() without 63 // ->table_open() first, since it leaves some internal variables unset. 64 // Therefore, call ->table_open() and throw away the generated HTML. 65 $this->renderer->table_open(); 66 $this->renderer->doc = ''; 67 68 $this->renderResultRow(0, $this->result[0]); 69 return $this->renderer->doc; 70 } 71} 72