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