xref: /plugin/struct/meta/Aggregation.php (revision 1ee0a2dc290e607b00cb9d6d919f4f60a00fcd2d)
1<?php
2
3namespace dokuwiki\plugin\struct\meta;
4
5/**
6 * Base contract for Aggregations
7 *
8 * @package dokuwiki\plugin\struct\meta
9 */
10abstract class Aggregation {
11
12    /** @var string the page id of the page this is rendered to */
13    protected $id;
14
15    /** @var string the Type of renderer used */
16    protected $mode;
17
18    /** @var \Doku_Renderer the DokuWiki renderer used to create the output */
19    protected $renderer;
20
21    /** @var SearchConfig the configured search - gives access to columns etc. */
22    protected $searchConfig;
23
24    /** @var Column[] the list of columns to be displayed */
25    protected $columns;
26
27    /** @var  Value[][] the search result */
28    protected $result;
29
30    /** @var int number of all results */
31    protected $resultCount;
32
33    /**
34     * @todo we might be able to get rid of this helper and move this to SearchConfig
35     * @var \helper_plugin_struct_config
36     */
37    protected $helper;
38
39    /**
40     * @var array the original configuration data
41     */
42    protected $data;
43
44    /**
45     * Initialize the Aggregation renderer and executes the search
46     *
47     * You need to call @param string $id
48     * @param string $mode
49     * @param \Doku_Renderer $renderer
50     * @param SearchConfig $searchConfig
51     * @see render() on the resulting object.
52     *
53     */
54    public function __construct($id, $mode, \Doku_Renderer $renderer, SearchConfig $searchConfig)
55    {
56        $this->id = $id;
57        $this->mode = $mode;
58        $this->renderer = $renderer;
59        $this->searchConfig = $searchConfig;
60        $this->data = $searchConfig->getConf();
61        $this->columns = $searchConfig->getColumns();
62        $this->result = $this->searchConfig->execute();
63        $this->resultCount = $this->searchConfig->getCount();
64        $this->helper = plugin_load('helper', 'struct_config');
65    }
66
67    /**
68     * Returns the page id the aggregation is used on
69     */
70    public function getID()
71    {
72        return $this->id;
73    }
74
75    /**
76     * Create the table on the renderer
77     *
78     * @param bool $showNotFound show a not found message when no data available?
79     */
80    abstract public function render($showNotFound = false);
81
82}
83