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