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