1<?php 2 3namespace plugin\struct\meta; 4 5use plugin\struct\types\AbstractBaseType; 6 7/** 8 * Class Column 9 * 10 * This represents a single column within a schema and contains the configured BaseType as well as the 11 * column reference to the data table. 12 * 13 * It basically combines the information how a column's content behaves (as defines in the BaseType and its 14 * configuration) with where to find that content and adds some basic meta data (like sort or enabled) 15 * 16 * @package plugin\struct\meta 17 */ 18class Column { 19 20 /** @var int fields are sorted by this value */ 21 protected $sort; 22 /** @var AbstractBaseType the type of this column */ 23 protected $type; 24 /** @var int the ID of the currently used type */ 25 protected $tid; 26 /** @var int the column in the datatable. columns count from 1 */ 27 protected $colref; 28 /** @var bool is this column still enabled? */ 29 protected $enabled=true; 30 31 /** 32 * Column constructor. 33 * @param int $sort 34 * @param AbstractBaseType $type 35 * @param int $tid 36 * @param int $colref 37 * @param bool $enabled 38 */ 39 public function __construct($sort, AbstractBaseType $type, $tid = 0, $colref=0, $enabled=true) { 40 $this->sort = (int) $sort; 41 $this->type = $type; 42 $this->tid = (int) $tid; 43 $this->colref = (int) $colref; 44 $this->enabled = (bool) $enabled; 45 } 46 47 /** 48 * @return int 49 */ 50 public function getSort() { 51 return $this->sort; 52 } 53 54 /** 55 * @return int 56 */ 57 public function getTid() { 58 return $this->tid; 59 } 60 61 /** 62 * @return AbstractBaseType 63 */ 64 public function getType() { 65 return $this->type; 66 } 67 68 /** 69 * @return int 70 */ 71 public function getColref() { 72 return $this->colref; 73 } 74 75 /** 76 * @return boolean 77 */ 78 public function isEnabled() { 79 return $this->enabled; 80 } 81 82 /** 83 * Returns a list of all available types 84 * 85 * @return array 86 */ 87 static public function allTypes() { 88 $types = array(); 89 $files = glob(DOKU_PLUGIN . 'struct/types/*.php'); 90 foreach($files as $file) { 91 $file = basename($file, '.php'); 92 if(substr($file, 0, 8) == 'Abstract') continue; 93 $types[] = $file; 94 } 95 sort($types); 96 97 return $types; 98 } 99 100} 101