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