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); 28*1f4dc0b9SMichael Grosse $this->getType()->setContext($this); 29cadfc3ccSAndreas Gohr } 30cadfc3ccSAndreas Gohr 31cadfc3ccSAndreas Gohr public function getColref() { 32cadfc3ccSAndreas Gohr throw new StructException('Accessing the colref of a RevisionColumn makes no sense'); 33cadfc3ccSAndreas Gohr } 34cadfc3ccSAndreas Gohr 35cadfc3ccSAndreas Gohr /** 365a11127fSAndreas Gohr * @param bool $enforceSingleColumn ignored 37cadfc3ccSAndreas Gohr * @return string 38cadfc3ccSAndreas Gohr */ 395a11127fSAndreas Gohr public function getColName($enforceSingleColumn = true) { 40cadfc3ccSAndreas Gohr return 'rev'; 41cadfc3ccSAndreas Gohr } 42cadfc3ccSAndreas Gohr 43cadfc3ccSAndreas Gohr /** 445a11127fSAndreas Gohr * @param bool $enforceSingleColumn ignored 45cadfc3ccSAndreas Gohr * @return string 46cadfc3ccSAndreas Gohr */ 475a11127fSAndreas Gohr public function getFullColName($enforceSingleColumn = true) { 485a11127fSAndreas Gohr $col = $this->getColName($enforceSingleColumn); 49cadfc3ccSAndreas Gohr if($this->table) $col = 'data_'.$this->table.'.'.$col; 50cadfc3ccSAndreas Gohr return $col; 51cadfc3ccSAndreas Gohr } 52cadfc3ccSAndreas Gohr 53cadfc3ccSAndreas Gohr /** 54cadfc3ccSAndreas Gohr * @return string always '%lastupdate%' 55cadfc3ccSAndreas Gohr */ 56cadfc3ccSAndreas Gohr public function getLabel() { 57cadfc3ccSAndreas Gohr return '%lastupdate%'; 58cadfc3ccSAndreas Gohr } 59cadfc3ccSAndreas Gohr 60cadfc3ccSAndreas Gohr /** 61cadfc3ccSAndreas Gohr * @return string always '%lastupdate%' 62cadfc3ccSAndreas Gohr */ 63cadfc3ccSAndreas Gohr public function getFullQualifiedLabel() { 64cadfc3ccSAndreas Gohr // There is only one pageid for each row because we JOIN on it 65cadfc3ccSAndreas Gohr // so we do not prefix it with the table 66cadfc3ccSAndreas Gohr return $this->getLabel(); 67cadfc3ccSAndreas Gohr } 68cadfc3ccSAndreas Gohr 69cadfc3ccSAndreas Gohr /** 70cadfc3ccSAndreas Gohr * @return string preconfigured label 71cadfc3ccSAndreas Gohr */ 72cadfc3ccSAndreas Gohr public function getTranslatedLabel() { 73cadfc3ccSAndreas Gohr /** @var \helper_plugin_struct_config $helper */ 74cadfc3ccSAndreas Gohr $helper = plugin_load('helper', 'struct_config'); 75cadfc3ccSAndreas Gohr return $helper->getLang('revisionlabel'); 76cadfc3ccSAndreas Gohr } 77cadfc3ccSAndreas Gohr 78cadfc3ccSAndreas Gohr} 79