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