1<?php 2 3/** 4 * DokuWiki Plugin struct (Syntax Component) 5 * 6 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 7 * @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de> 8 */ 9 10use dokuwiki\plugin\struct\meta\AggregationEditorTable; 11 12// must be run within Dokuwiki 13if (!defined('DOKU_INC')) die(); 14 15class syntax_plugin_struct_global extends syntax_plugin_struct_table 16{ 17 18 /** @var string which class to use for output */ 19 protected $tableclass = AggregationEditorTable::class; 20 21 /** 22 * Connect lookup pattern to lexer. 23 * 24 * @param string $mode Parser mode 25 */ 26 public function connectTo($mode) 27 { 28 $this->Lexer->addSpecialPattern('----+ *struct global *-+\n.*?\n----+', $mode, 'plugin_struct_global'); 29 30 // deprecated: 31 $this->Lexer->addSpecialPattern('----+ *struct lookup *-+\n.*?\n----+', $mode, 'plugin_struct_global'); 32 } 33 34 /** 35 * Handle matches of the struct syntax 36 * 37 * @param string $match The match of the syntax 38 * @param int $state The state of the handler 39 * @param int $pos The position in the document 40 * @param Doku_Handler $handler The handler 41 * @return array Data for the renderer 42 */ 43 public function handle($match, $state, $pos, Doku_Handler $handler) 44 { 45 // usual parsing 46 $config = parent::handle($match, $state, $pos, $handler); 47 if (is_null($config)) return null; 48 49 // adjust some things for the lookup editor 50 $config['cols'] = array('*'); // always select all columns 51 if (isset($config['rownumbers'])) unset($config['rownumbers']); // this annoying to update dynamically 52 return $config; 53 } 54 55 /** 56 * Filter based on primary key columns 57 * 58 * @param array $config 59 * @return array 60 */ 61 protected function addTypeFilter($config) 62 { 63 $config['filter'][] = ['%rowid%', '!=', (string)\dokuwiki\plugin\struct\meta\AccessTablePage::DEFAULT_PAGE_RID, 'AND']; 64 $config['filter'][] = ['%pageid%', '=*', '^(?![\s\S])', 'AND']; 65 $config['withpid'] = 0; // flag for the editor to distinguish data types 66 return $config; 67 } 68} 69