10561158fSAndreas Gohr<?php 20561158fSAndreas Gohr 3ba766201SAndreas Gohrnamespace dokuwiki\plugin\struct\meta; 40561158fSAndreas Gohr 5ba766201SAndreas Gohruse dokuwiki\plugin\struct\types\AbstractBaseType; 6*918ccc27SAndreas Gohruse dokuwiki\plugin\struct\types\Page; 70561158fSAndreas Gohr 80561158fSAndreas Gohr/** 90561158fSAndreas Gohr * Class PageColumn 100561158fSAndreas Gohr * 110561158fSAndreas Gohr * Just like a column, but does not reference one of the col* data columns but the pid column. 120561158fSAndreas Gohr * 13ba766201SAndreas Gohr * @package dokuwiki\plugin\struct\meta 140561158fSAndreas Gohr */ 150561158fSAndreas Gohrclass PageColumn extends Column { 160561158fSAndreas Gohr 170561158fSAndreas Gohr /** 180561158fSAndreas Gohr * PageColumn constructor. 190561158fSAndreas Gohr * 200561158fSAndreas Gohr * @param int $sort 21*918ccc27SAndreas Gohr * @param Page $type 220561158fSAndreas Gohr * @param string $table 230561158fSAndreas Gohr */ 24*918ccc27SAndreas Gohr public function __construct($sort, Page $type, $table='') { 255b2d2a8cSAndreas Gohr if($type->isMulti()) throw new StructException('PageColumns can not be multi value types!'); 260561158fSAndreas Gohr parent::__construct($sort, $type, 0, true, $table); 270561158fSAndreas Gohr } 280561158fSAndreas Gohr 290561158fSAndreas Gohr public function getColref() { 300561158fSAndreas Gohr throw new StructException('Accessing the colref of a PageColumn makes no sense'); 310561158fSAndreas Gohr } 320561158fSAndreas Gohr 33d1b04e89SAndreas Gohr /** 34066fcfb7SMichael Grosse * @param bool $forceSingleColumn ignored 35d1b04e89SAndreas Gohr * @return string 36d1b04e89SAndreas Gohr */ 37066fcfb7SMichael Grosse public function getColName($forceSingleColumn = true) { 3827f6439fSAndreas Gohr return 'pid'; 3927f6439fSAndreas Gohr } 4027f6439fSAndreas Gohr 4127f6439fSAndreas Gohr /** 4227f6439fSAndreas Gohr * @param bool $forceSingleColumn ignored 4327f6439fSAndreas Gohr * @return string 4427f6439fSAndreas Gohr */ 4527f6439fSAndreas Gohr public function getFullColName($forceSingleColumn = true) { 4627f6439fSAndreas Gohr $col = $this->getColName($forceSingleColumn); 475b2d2a8cSAndreas Gohr if($this->table) $col = 'data_'.$this->table.'.'.$col; 48d1b04e89SAndreas Gohr return $col; 49d1b04e89SAndreas Gohr } 50d1b04e89SAndreas Gohr 519447008bSAndreas Gohr /** 529447008bSAndreas Gohr * @return string always '%pageid%' 539447008bSAndreas Gohr */ 549447008bSAndreas Gohr public function getLabel() { 55db7315f6SAndreas Gohr $conf = $this->getType()->getConfig(); 56db7315f6SAndreas Gohr if($conf['usetitles']) { 57db7315f6SAndreas Gohr return '%title%'; 58db7315f6SAndreas Gohr } else { 599447008bSAndreas Gohr return '%pageid%'; 609447008bSAndreas Gohr } 61db7315f6SAndreas Gohr } 629447008bSAndreas Gohr 63c74e0e40SAndreas Gohr /** 64c74e0e40SAndreas Gohr * @return string always '%pageid%' 65c74e0e40SAndreas Gohr */ 66c74e0e40SAndreas Gohr public function getFullQualifiedLabel() { 67c74e0e40SAndreas Gohr // There is only one pageid for each row because we JOIN on it 68c74e0e40SAndreas Gohr // so we do not prefix it with the table 69db7315f6SAndreas Gohr return $this->getLabel(); 70c74e0e40SAndreas Gohr } 71c74e0e40SAndreas Gohr 720561158fSAndreas Gohr} 73