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