1<?php
2
3namespace dokuwiki\plugin\structat\meta;
4
5use dokuwiki\plugin\struct\meta\SearchConfig;
6use dokuwiki\plugin\struct\meta\SearchConfigParameters;
7
8/**
9 * Manage dynamic parameters for aggregations
10 *
11 * @package dokuwiki\plugin\struct\meta
12 */
13class SearchConfigAtParameters extends SearchConfigParameters {
14
15    /** @var string parameter name to pass at */
16    public static $PARAM_AT = 'structat';
17
18    /** @var int */
19    protected $at = 0;
20
21    public function __construct(SearchConfig $searchConfig) {
22        global $INPUT;
23
24        parent::__construct($searchConfig);
25
26        if ($INPUT->has(self::$PARAM_AT)) {
27            $this->setAt($INPUT->int(self::$PARAM_AT));
28        }
29    }
30
31    /**
32     * Set the at
33     *
34     * @param int $at
35     */
36    public function setAt($at)
37    {
38        $this->at = $at;
39    }
40
41    /**
42     * Updates the given config array with the values currently set
43     *
44     * This should only be called once at the initialization
45     *
46     * @param array $config
47     * @return array
48     */
49    public function updateConfig($config)
50    {
51        $config = parent::updateConfig($config);
52        if ($this->at) {
53            $config['at'] = $this->at;
54        }
55
56        return $config;
57    }
58}
59