1<?php 2 3namespace dokuwiki\plugin\struct\meta; 4 5/** 6 * Class AggregationValue 7 * 8 * @package dokuwiki\plugin\struct\meta 9 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 10 * @author Iain Hallam <iain@nineworlds.net> 11 */ 12class AggregationValue extends Aggregation 13{ 14 /** 15 * @var Column the column to be displayed 16 */ 17 protected $column; 18 19 /** @inheritdoc */ 20 public function __construct($id, $mode, \Doku_Renderer $renderer, SearchConfig $searchConfig) 21 { 22 // limit to first result 23 $searchConfig->setLimit(1); 24 $searchConfig->setOffset(0); 25 26 parent::__construct($id, $mode, $renderer, $searchConfig); 27 } 28 29 /** 30 * Create the output on the renderer 31 * 32 * @param int $show_not_found Whether to display the default text for no records 33 */ 34 public function render($show_not_found = 0) 35 { 36 // Check that we actually got a result 37 if ($this->resultCount) { 38 $this->renderValue($this->result[0]); // only one result 39 } else { 40 if ($show_not_found) { 41 $this->renderer->cdata($this->helper->getLang('none')); 42 } 43 } 44 } 45 46 /** 47 * @param Value[] $resultrow 48 */ 49 protected function renderValue($resultrow) 50 { 51 foreach ($resultrow as $column => $value) { 52 if ($value->isEmpty()) { 53 continue; 54 } 55 if ($this->mode == 'xhtml') { 56 $type = 'struct_' . strtolower($value->getColumn()->getType()->getClass()); 57 $this->renderer->doc .= '<span class="' . $type . '">'; 58 } 59 $value->render($this->renderer, $this->mode); 60 if ($this->mode == 'xhtml') { 61 $this->renderer->doc .= '</span>'; 62 } 63 } 64 } 65} 66