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