10561158fSAndreas Gohr<?php 20561158fSAndreas Gohr 3ba766201SAndreas Gohrnamespace dokuwiki\plugin\struct\meta; 40561158fSAndreas Gohr 5918ccc27SAndreas Gohruse dokuwiki\plugin\struct\types\Page; 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 */ 14*d6d97f60SAnna Dabrowskaclass PageColumn extends Column 15*d6d97f60SAnna Dabrowska{ 160561158fSAndreas Gohr /** 170561158fSAndreas Gohr * PageColumn constructor. 180561158fSAndreas Gohr * 190561158fSAndreas Gohr * @param int $sort 203aad9612SMichael Grosse * @param PageMeta $type 210561158fSAndreas Gohr * @param string $table 220561158fSAndreas Gohr */ 23*d6d97f60SAnna Dabrowska public function __construct($sort, Page $type, $table = '') 24*d6d97f60SAnna Dabrowska { 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 29*d6d97f60SAnna Dabrowska public function getColref() 30*d6d97f60SAnna Dabrowska { 310561158fSAndreas Gohr throw new StructException('Accessing the colref of a PageColumn makes no sense'); 320561158fSAndreas Gohr } 330561158fSAndreas Gohr 34d1b04e89SAndreas Gohr /** 355a11127fSAndreas Gohr * @param bool $enforceSingleColumn ignored 36d1b04e89SAndreas Gohr * @return string 37d1b04e89SAndreas Gohr */ 38*d6d97f60SAnna Dabrowska public function getColName($enforceSingleColumn = true) 39*d6d97f60SAnna Dabrowska { 4027f6439fSAndreas Gohr return 'pid'; 4127f6439fSAndreas Gohr } 4227f6439fSAndreas Gohr 4327f6439fSAndreas Gohr /** 445a11127fSAndreas Gohr * @param bool $enforceSingleColumn ignored 4527f6439fSAndreas Gohr * @return string 4627f6439fSAndreas Gohr */ 47*d6d97f60SAnna Dabrowska public function getFullColName($enforceSingleColumn = true) 48*d6d97f60SAnna Dabrowska { 495a11127fSAndreas Gohr $col = $this->getColName($enforceSingleColumn); 505b2d2a8cSAndreas Gohr if ($this->table) $col = 'data_' . $this->table . '.' . $col; 51d1b04e89SAndreas Gohr return $col; 52d1b04e89SAndreas Gohr } 53d1b04e89SAndreas Gohr 549447008bSAndreas Gohr /** 559447008bSAndreas Gohr * @return string always '%pageid%' 569447008bSAndreas Gohr */ 57*d6d97f60SAnna Dabrowska public function getLabel() 58*d6d97f60SAnna Dabrowska { 59db7315f6SAndreas Gohr $conf = $this->getType()->getConfig(); 60db7315f6SAndreas Gohr if ($conf['usetitles']) { 61db7315f6SAndreas Gohr return '%title%'; 62db7315f6SAndreas Gohr } else { 639447008bSAndreas Gohr return '%pageid%'; 649447008bSAndreas Gohr } 65db7315f6SAndreas Gohr } 669447008bSAndreas Gohr 67c74e0e40SAndreas Gohr /** 68c74e0e40SAndreas Gohr * @return string always '%pageid%' 69c74e0e40SAndreas Gohr */ 70*d6d97f60SAnna Dabrowska public function getFullQualifiedLabel() 71*d6d97f60SAnna Dabrowska { 72c74e0e40SAndreas Gohr // There is only one pageid for each row because we JOIN on it 73c74e0e40SAndreas Gohr // so we do not prefix it with the table 74db7315f6SAndreas Gohr return $this->getLabel(); 75c74e0e40SAndreas Gohr } 76c74e0e40SAndreas Gohr 7701f8b845SAndreas Gohr /** 7801f8b845SAndreas Gohr * @return string preconfigured label 7901f8b845SAndreas Gohr */ 80*d6d97f60SAnna Dabrowska public function getTranslatedLabel() 81*d6d97f60SAnna Dabrowska { 8201f8b845SAndreas Gohr /** @var \helper_plugin_struct_config $helper */ 8301f8b845SAndreas Gohr $helper = plugin_load('helper', 'struct_config'); 8401f8b845SAndreas Gohr return $helper->getLang('pagelabel'); 8501f8b845SAndreas Gohr } 860561158fSAndreas Gohr} 87