xref: /plugin/struct/meta/PageColumn.php (revision 080fdc707e5e013dcbe18debbe547aa51d85f504)
1<?php
2
3namespace dokuwiki\plugin\struct\meta;
4
5use dokuwiki\plugin\struct\types\AbstractBaseType;
6
7/**
8 * Class PageColumn
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 PageColumn extends Column {
15
16    /**
17     * PageColumn constructor.
18     *
19     * @param int $sort
20     * @param AbstractBaseType $type This should be Page or Title
21     * @param string $table
22     */
23    public function __construct($sort, AbstractBaseType $type, $table='') {
24        if($type->isMulti()) throw new StructException('PageColumns can not be multi value types!');
25        parent::__construct($sort, $type, 0, true, $table);
26    }
27
28    public function getColref() {
29        throw new StructException('Accessing the colref of a PageColumn makes no sense');
30    }
31
32    /**
33     * @param bool $forceSingleColumn ignored
34     * @return string
35     */
36    public function getColName($forceSingleColumn = true) {
37        $col = 'pid';
38        if($this->table) $col = 'data_'.$this->table.'.'.$col;
39        return $col;
40    }
41
42    /**
43     * @return string always '%pageid%'
44     */
45    public function getLabel() {
46        return '%pageid%';
47    }
48
49    /**
50     * @return string always '%pageid%'
51     */
52    public function getFullQualifiedLabel() {
53        // There is only one pageid for each row because we JOIN on it
54        // so we do not prefix it with the table
55        return '%pageid%';
56    }
57
58}
59