1<?php
2
3namespace dokuwiki\plugin\struct\meta;
4
5use dokuwiki\plugin\struct\types\AutoSummary;
6
7/**
8 * Class SummaryColumn
9 *
10 * Just like a column, but does not reference one of the col* data columns but the pid column.
11 *
12 * @package dokuwiki\plugin\struct\meta
13 */
14class SummaryColumn extends Column
15{
16    /**
17     * PageColumn constructor.
18     *
19     * @param int $sort
20     * @param PageMeta $type
21     * @param string $table
22     */
23    public function __construct($sort, AutoSummary $type, $table = '')
24    {
25        if ($type->isMulti()) throw new StructException('SummaryColumns can not be multi value types!');
26        parent::__construct($sort, $type, 0, true, $table);
27        $this->getType()->setContext($this);
28    }
29
30    public function getColref()
31    {
32        throw new StructException('Accessing the colref of a SummaryColumn makes no sense');
33    }
34
35    /**
36     * @param bool $enforceSingleColumn ignored
37     * @return string
38     */
39    public function getColName($enforceSingleColumn = true)
40    {
41        return 'lastsummary';
42    }
43
44    /**
45     * @param bool $enforceSingleColumn ignored
46     * @return string
47     */
48    public function getFullColName($enforceSingleColumn = true)
49    {
50        $col = 'titles.' . $this->getColName($enforceSingleColumn);
51        return $col;
52    }
53
54    /**
55     * @return string always '%lastsummary%'
56     */
57    public function getLabel()
58    {
59        return '%lastsummary%';
60    }
61
62    /**
63     * @return string always '%lastsummary%'
64     */
65    public function getFullQualifiedLabel()
66    {
67        // There is only one pageid for each row because we JOIN on it
68        // so we do not prefix it with the table
69        return $this->getLabel();
70    }
71
72    /**
73     * @return string preconfigured label
74     */
75    public function getTranslatedLabel()
76    {
77        /** @var \helper_plugin_struct_config $helper */
78        $helper = plugin_load('helper', 'struct_config');
79        return $helper->getLang('summarylabel');
80    }
81}
82