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