1308cc83fSAndreas Gohr<?php 2308cc83fSAndreas Gohr 3308cc83fSAndreas Gohr/** 4308cc83fSAndreas Gohr * DokuWiki Plugin struct (Syntax Component) 5308cc83fSAndreas Gohr * 6308cc83fSAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 7308cc83fSAndreas Gohr * @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de> 8308cc83fSAndreas Gohr */ 9308cc83fSAndreas Gohr 10308cc83fSAndreas Gohruse dokuwiki\plugin\struct\meta\AggregationEditorTable; 11308cc83fSAndreas Gohr 12308cc83fSAndreas Gohrclass syntax_plugin_struct_global extends syntax_plugin_struct_table 13308cc83fSAndreas Gohr{ 14308cc83fSAndreas Gohr /** @var string which class to use for output */ 15308cc83fSAndreas Gohr protected $tableclass = AggregationEditorTable::class; 16308cc83fSAndreas Gohr 17308cc83fSAndreas Gohr /** 18308cc83fSAndreas Gohr * Connect lookup pattern to lexer. 19308cc83fSAndreas Gohr * 20308cc83fSAndreas Gohr * @param string $mode Parser mode 21308cc83fSAndreas Gohr */ 22308cc83fSAndreas Gohr public function connectTo($mode) 23308cc83fSAndreas Gohr { 24308cc83fSAndreas Gohr $this->Lexer->addSpecialPattern('----+ *struct global *-+\n.*?\n----+', $mode, 'plugin_struct_global'); 25308cc83fSAndreas Gohr 26308cc83fSAndreas Gohr // deprecated: 27308cc83fSAndreas Gohr $this->Lexer->addSpecialPattern('----+ *struct lookup *-+\n.*?\n----+', $mode, 'plugin_struct_global'); 28308cc83fSAndreas Gohr } 29308cc83fSAndreas Gohr 30308cc83fSAndreas Gohr /** 31308cc83fSAndreas Gohr * Handle matches of the struct syntax 32308cc83fSAndreas Gohr * 33308cc83fSAndreas Gohr * @param string $match The match of the syntax 34308cc83fSAndreas Gohr * @param int $state The state of the handler 35308cc83fSAndreas Gohr * @param int $pos The position in the document 36308cc83fSAndreas Gohr * @param Doku_Handler $handler The handler 37308cc83fSAndreas Gohr * @return array Data for the renderer 38308cc83fSAndreas Gohr */ 39308cc83fSAndreas Gohr public function handle($match, $state, $pos, Doku_Handler $handler) 40308cc83fSAndreas Gohr { 41308cc83fSAndreas Gohr // usual parsing 42308cc83fSAndreas Gohr $config = parent::handle($match, $state, $pos, $handler); 43308cc83fSAndreas Gohr if (is_null($config)) return null; 44308cc83fSAndreas Gohr 45308cc83fSAndreas Gohr // adjust some things for the lookup editor 46308cc83fSAndreas Gohr $config['cols'] = array('*'); // always select all columns 47308cc83fSAndreas Gohr if (isset($config['rownumbers'])) unset($config['rownumbers']); // this annoying to update dynamically 48308cc83fSAndreas Gohr return $config; 49308cc83fSAndreas Gohr } 50308cc83fSAndreas Gohr 51308cc83fSAndreas Gohr /** 52308cc83fSAndreas Gohr * Filter based on primary key columns 53308cc83fSAndreas Gohr * 54308cc83fSAndreas Gohr * @param array $config 55308cc83fSAndreas Gohr * @return array 56308cc83fSAndreas Gohr */ 57308cc83fSAndreas Gohr protected function addTypeFilter($config) 58308cc83fSAndreas Gohr { 59*17a3a578SAndreas Gohr $config['filter'][] = [ 60*17a3a578SAndreas Gohr '%rowid%', '!=', 61*17a3a578SAndreas Gohr (string)\dokuwiki\plugin\struct\meta\AccessTablePage::DEFAULT_PAGE_RID, 'AND' 62*17a3a578SAndreas Gohr ]; 63308cc83fSAndreas Gohr $config['filter'][] = ['%pageid%', '=*', '^(?![\s\S])', 'AND']; 64308cc83fSAndreas Gohr $config['withpid'] = 0; // flag for the editor to distinguish data types 65308cc83fSAndreas Gohr return $config; 66308cc83fSAndreas Gohr } 67308cc83fSAndreas Gohr} 68