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 /** @inheritdoc */ 15 public function render($showNotFound = false) 16 { 17 parent::render(); // never show not found 18 } 19 20 21 /** 22 * Adds additional info to document and renderer in XHTML mode 23 * 24 * We add the schema name as data attribute 25 * 26 * @see finishScope() 27 */ 28 public function startScope() 29 { 30 // unique identifier for this aggregation 31 $hash = md5(var_export($this->data, true)); 32 $this->renderer->info['struct_table_hash'] = $hash; 33 34 if ($this->mode != 'xhtml') return; 35 36 $table = $this->columns[0]->getTable(); 37 38 $config = $this->searchConfig->getConf(); 39 if (isset($config['filter'])) unset($config['filter']); 40 $config = hsc(json_encode($config, JSON_THROW_ON_ERROR)); 41 42 // wrapping div 43 $classes = $this->getScopeClasses(); 44 $classes[] = 'structaggregationeditor'; 45 $classes = implode(' ', $classes); 46 $this->renderer->doc .= "<div id=\"$hash\" 47 class=\"$classes\" 48 data-schema=\"$table\" data-searchconf=\"$config\">"; 49 } 50 51 /** 52 * We do not output a row for empty tables 53 */ 54 protected function renderEmptyResult() 55 { 56 } 57 58 /** 59 * Renders the first result row and returns it 60 * 61 * Only used for rendering new rows via JS (where the first row is the only one) 62 * 63 * @return string 64 */ 65 public function getFirstRow() 66 { 67 // XHTML renderer doesn't like calling ->tablerow_open() without 68 // ->table_open() first, since it leaves some internal variables unset. 69 // Therefore, call ->table_open() and throw away the generated HTML. 70 $this->renderer->table_open(); 71 $this->renderer->doc = ''; 72 73 $this->renderResultRow(0, $this->searchConfig->getRows()[0]); 74 return $this->renderer->doc; 75 } 76} 77