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]); 39 // only one result 40 } elseif ($show_not_found) { 41 $this->renderer->cdata($this->helper->getLang('none')); 42 } 43 } 44 45 /** 46 * @param Value[] $resultrow 47 */ 48 protected function renderValue($resultrow) 49 { 50 foreach ($resultrow as $value) { 51 if ($value->isEmpty()) { 52 continue; 53 } 54 if ($this->mode == 'xhtml') { 55 $type = 'struct_' . strtolower($value->getColumn()->getType()->getClass()); 56 $this->renderer->doc .= '<span class="' . $type . '">'; 57 } 58 $value->render($this->renderer, $this->mode); 59 if ($this->mode == 'xhtml') { 60 $this->renderer->doc .= '</span>'; 61 } 62 } 63 } 64} 65