1<?php 2 3 4/** 5 * Matches the default syntax: 6 * {{entry>section/path/to/entry|display*}} [Deprecated] 7 * OR 8 * {{entry>section;path/to/item;display*}} [Preferred: matches default syntax] 9 * e.g. 10 * {{entry>2;Home/Gardening/Bonsai;Planting Bonsai*}} 11 * 12 * Display formatting: 13 * ...|text}} User-defined text 14 * ...|text*}} User-defined text + star(*) 15 * ...|-}} No text, i.e. hidden 16 * ...|-*}} No text, but show star(*) 17 * ...|*}} Use entry text + star(*) 18 * ...|}} Use entry text 19 * ...}} Use entry text (default) 20 * 21 * Therefore: '-' => no text at all 22 * '*' => add a star symbol to end. 23 * 24 * This is the standard format and all other syntax matchers are converted into this format for processing 25 */ 26class SI_EntryDefault extends SI_Entry { 27 28 public $order = 30; 29 public $type = 'default'; 30 public $section = 0; 31 public $types = array(); 32 33 // first is for Dokuwiki syntax parser matching, second for internal lexing 34 public $regex = '\{\{entry>.+?\}\}'; 35 // this regex allows for both old and new syntax (nasty!) 36 private $_regex = '`\{\{entry>(?:(\d+)[;\/])?([^|;}]+)(?:[;|](.*?)(\*?))?\}\}`'; 37 38 // [1] = section; [2] = entry; [3] = display; [4] = star 39 40 41 function match($text) { 42 $this->items = array(); 43 $matches = array(); 44 $hits = preg_match_all($this->_regex, $text, $matches, PREG_SET_ORDER); 45 if ($hits > 0) { 46 foreach ($matches as $match) { 47 $item = &$this->items[]; 48 $item['section'] = ( ! empty($match[1])) ? $match[1] : $this->section; 49 // special case: default items can be of any type/section... 50 $item['type'] = $this->type; 51 if ($item['type']== 'default' && isset($this->types[$item['section']])) { 52 $item['type'] = $this->types[$item['section']]; 53 } 54 $item['entry'] = $match[2]; 55 if (isset($match[3])) { 56 $item['display'] = $match[3]; 57 $item['star'] = ($match[4] == '*'); 58 } else { 59 $item['display'] = ''; 60 $item['star'] = false; 61 } 62 } 63 return true; 64 } else { 65 return false; 66 } 67 } 68}