xref: /plugin/struct/meta/PageColumn.php (revision 27f6439f6ee2767a0eee1b989257585d2bfa6280)
10561158fSAndreas Gohr<?php
20561158fSAndreas Gohr
3ba766201SAndreas Gohrnamespace dokuwiki\plugin\struct\meta;
40561158fSAndreas Gohr
5ba766201SAndreas Gohruse dokuwiki\plugin\struct\types\AbstractBaseType;
60561158fSAndreas Gohr
70561158fSAndreas Gohr/**
80561158fSAndreas Gohr * Class PageColumn
90561158fSAndreas Gohr *
100561158fSAndreas Gohr * Just like a column, but does not reference one of the col* data columns but the pid column.
110561158fSAndreas Gohr *
12ba766201SAndreas Gohr * @package dokuwiki\plugin\struct\meta
130561158fSAndreas Gohr */
140561158fSAndreas Gohrclass PageColumn extends Column {
150561158fSAndreas Gohr
160561158fSAndreas Gohr    /**
170561158fSAndreas Gohr     * PageColumn constructor.
180561158fSAndreas Gohr     *
190561158fSAndreas Gohr     * @param int $sort
200561158fSAndreas Gohr     * @param AbstractBaseType $type This should be Page or Title
210561158fSAndreas Gohr     * @param string $table
220561158fSAndreas Gohr     */
230561158fSAndreas Gohr    public function __construct($sort, AbstractBaseType $type, $table='') {
245b2d2a8cSAndreas Gohr        if($type->isMulti()) throw new StructException('PageColumns can not be multi value types!');
250561158fSAndreas Gohr        parent::__construct($sort, $type, 0, true, $table);
260561158fSAndreas Gohr    }
270561158fSAndreas Gohr
280561158fSAndreas Gohr    public function getColref() {
290561158fSAndreas Gohr        throw new StructException('Accessing the colref of a PageColumn makes no sense');
300561158fSAndreas Gohr    }
310561158fSAndreas Gohr
32d1b04e89SAndreas Gohr    /**
33066fcfb7SMichael Grosse     * @param bool $forceSingleColumn ignored
34d1b04e89SAndreas Gohr     * @return string
35d1b04e89SAndreas Gohr     */
36066fcfb7SMichael Grosse    public function getColName($forceSingleColumn = true) {
37*27f6439fSAndreas Gohr        return 'pid';
38*27f6439fSAndreas Gohr    }
39*27f6439fSAndreas Gohr
40*27f6439fSAndreas Gohr    /**
41*27f6439fSAndreas Gohr     * @param bool $forceSingleColumn ignored
42*27f6439fSAndreas Gohr     * @return string
43*27f6439fSAndreas Gohr     */
44*27f6439fSAndreas Gohr    public function getFullColName($forceSingleColumn = true) {
45*27f6439fSAndreas Gohr        $col = $this->getColName($forceSingleColumn);
465b2d2a8cSAndreas Gohr        if($this->table) $col = 'data_'.$this->table.'.'.$col;
47d1b04e89SAndreas Gohr        return $col;
48d1b04e89SAndreas Gohr    }
49d1b04e89SAndreas Gohr
509447008bSAndreas Gohr    /**
519447008bSAndreas Gohr     * @return string always '%pageid%'
529447008bSAndreas Gohr     */
539447008bSAndreas Gohr    public function getLabel() {
549447008bSAndreas Gohr        return '%pageid%';
559447008bSAndreas Gohr    }
569447008bSAndreas Gohr
57c74e0e40SAndreas Gohr    /**
58c74e0e40SAndreas Gohr     * @return string always '%pageid%'
59c74e0e40SAndreas Gohr     */
60c74e0e40SAndreas Gohr    public function getFullQualifiedLabel() {
61c74e0e40SAndreas Gohr        // There is only one pageid for each row because we JOIN on it
62c74e0e40SAndreas Gohr        // so we do not prefix it with the table
63c74e0e40SAndreas Gohr        return '%pageid%';
64c74e0e40SAndreas Gohr    }
65c74e0e40SAndreas Gohr
660561158fSAndreas Gohr}
67