1308cc83fSAndreas Gohr<?php 2308cc83fSAndreas Gohr 3308cc83fSAndreas Gohrnamespace dokuwiki\plugin\struct\meta; 4308cc83fSAndreas Gohr 5308cc83fSAndreas Gohr/** 6308cc83fSAndreas Gohr * Class AggregationEditorTable 7308cc83fSAndreas Gohr * 8308cc83fSAndreas Gohr * An AggregationTable for editing global and serial tables 9308cc83fSAndreas Gohr * 10308cc83fSAndreas Gohr * @package dokuwiki\plugin\struct\meta 11308cc83fSAndreas Gohr */ 12308cc83fSAndreas Gohrclass AggregationEditorTable extends AggregationTable 13308cc83fSAndreas Gohr{ 14d90aa848SAndreas Gohr /** @inheritdoc */ 15d90aa848SAndreas Gohr public function render($showNotFound = false) 16d90aa848SAndreas Gohr { 17d90aa848SAndreas Gohr parent::render(); // never show not found 18d90aa848SAndreas Gohr } 19d90aa848SAndreas Gohr 20308cc83fSAndreas Gohr 21308cc83fSAndreas Gohr /** 22308cc83fSAndreas Gohr * Adds additional info to document and renderer in XHTML mode 23308cc83fSAndreas Gohr * 24308cc83fSAndreas Gohr * We add the schema name as data attribute 25308cc83fSAndreas Gohr * 26308cc83fSAndreas Gohr * @see finishScope() 27308cc83fSAndreas Gohr */ 28af0ce8d2SAndreas Gohr public function startScope() 29308cc83fSAndreas Gohr { 3067f70d54SAnna Dabrowska // unique identifier for this aggregation 3167f70d54SAnna Dabrowska $hash = md5(var_export($this->data, true)); 3267f70d54SAnna Dabrowska $this->renderer->info['struct_table_hash'] = $hash; 33308cc83fSAndreas Gohr 34308cc83fSAndreas Gohr if ($this->mode != 'xhtml') return; 35308cc83fSAndreas Gohr 36308cc83fSAndreas Gohr $table = $this->columns[0]->getTable(); 37308cc83fSAndreas Gohr 38308cc83fSAndreas Gohr $config = $this->searchConfig->getConf(); 39308cc83fSAndreas Gohr if (isset($config['filter'])) unset($config['filter']); 405e29103aSannda $config = hsc(json_encode($config, JSON_THROW_ON_ERROR)); 41308cc83fSAndreas Gohr 42308cc83fSAndreas Gohr // wrapping div 43af0ce8d2SAndreas Gohr $classes = $this->getScopeClasses(); 44af0ce8d2SAndreas Gohr $classes[] = 'structaggregationeditor'; 457234bfb1Ssplitbrain $classes = implode(' ', $classes); 464b00515cSAnna Dabrowska $this->renderer->doc .= "<div id=\"$hash\" 474b00515cSAnna Dabrowska class=\"$classes\" 4817a3a578SAndreas Gohr data-schema=\"$table\" data-searchconf=\"$config\">"; 49308cc83fSAndreas Gohr } 50308cc83fSAndreas Gohr 51308cc83fSAndreas Gohr /** 52308cc83fSAndreas Gohr * We do not output a row for empty tables 53308cc83fSAndreas Gohr */ 54308cc83fSAndreas Gohr protected function renderEmptyResult() 55308cc83fSAndreas Gohr { 56308cc83fSAndreas Gohr } 57308cc83fSAndreas Gohr 58308cc83fSAndreas Gohr /** 59308cc83fSAndreas Gohr * Renders the first result row and returns it 60308cc83fSAndreas Gohr * 61308cc83fSAndreas Gohr * Only used for rendering new rows via JS (where the first row is the only one) 62308cc83fSAndreas Gohr * 63308cc83fSAndreas Gohr * @return string 64308cc83fSAndreas Gohr */ 65308cc83fSAndreas Gohr public function getFirstRow() 66308cc83fSAndreas Gohr { 67308cc83fSAndreas Gohr // XHTML renderer doesn't like calling ->tablerow_open() without 68308cc83fSAndreas Gohr // ->table_open() first, since it leaves some internal variables unset. 69308cc83fSAndreas Gohr // Therefore, call ->table_open() and throw away the generated HTML. 70308cc83fSAndreas Gohr $this->renderer->table_open(); 71308cc83fSAndreas Gohr $this->renderer->doc = ''; 72308cc83fSAndreas Gohr 73*ba7f5789SAnna Dabrowska $this->renderResultRow(0, $this->searchConfig->getRows()[0]); 74308cc83fSAndreas Gohr return $this->renderer->doc; 75308cc83fSAndreas Gohr } 76308cc83fSAndreas Gohr} 77